View file techno/files/func.php

File size: 9.69Kb
<?php
defined('PROTECTOR') or die('Error: restricted access');
function zasad(){}
function ryd(){
global $inryd;
if ($inryd=='1'){
header ('Location: rydnik.php?');exit;}}
//////////БОИ
function going(){
global $in_battle,$inpk,$inar,$inzasada;
///////////////////////////////БОЙ/////////////////////
if ($in_battle=='1'){
header ('Location: battle.php?');exit;}
/////////////////////////////////////////////////////////////////
elseif ($inpk=='1'){
header ('Location: pk.php?');exit;}
///////////////////////////////////////////////////////////////////
elseif ($inar=='1'){
header ('Location: combat.php?');exit;}}
##############################################################################################

function auto_clean(){
global $log;
$req=mysql_query("SELECT * FROM log WHERE usr = '$log' LIMIT 20");
$avto = mysql_num_rows($req);
if($avto>='20'){
$lim=round($avto/2);
mysql_query("DELETE FROM `log` WHERE `usr` = '$log' LIMIT $lim");}}

function del_log($lpl){
global $log;
mysql_query("DELETE FROM `log` WHERE `usr` = '$log' and `place` = '$lpl'");}

function smiles($string){
$dir = opendir ("pic/smiles"); 
while ($file = readdir ($dir)) {
if (ereg (".gif$", "$file")){
$file2=str_replace(".gif","",$file);
$string=str_replace(":$file2",'<img src="pic/smiles/'.$file.'" alt="">',$string);}}
closedir ($dir);
return $string;  }

function log_msg($tlog){
global $log;
$req=mysql_query("SELECT * FROM log WHERE usr = '$log' and place='$tlog' and timer>='".time()."' ORDER BY id DESC LIMIT 6");
$avto = mysql_num_rows($req);
if($avto>=1){
echo'<div class="log">';
While($ilok = mysql_fetch_assoc($req))
{
if($ilok['kto']=='system'){$color='#AAAAAA';}
if($ilok['kto']=='user'){$color='#66FF66';}
if($ilok['kto']=='enemy'){$color='#FF6633';}
echo '<small><font color="'.$color.'">'.$ilok[text].'</font></small><br/>';}
echo'</div>';}}

function log_duel($tlog){
global $log;
$req=mysql_query("SELECT * FROM duellog WHERE opon = '$log' or usr = '$log' and timer>='".time()."' ORDER BY id DESC LIMIT 6");
$avto = mysql_num_rows($req);
if($avto>=1){

While($ilok = mysql_fetch_assoc($req))
{
if($ilok[usr]=="system"){$color='#AAAAAA';}
if($ilok[usr]!=="$log"){$color='#FF6633';}
if($ilok[usr]=="$log"){$color='#CCCCCC';}
if($ilok[umen]==1 and $ilok[usr]=="$log"){$color='#71CC71';}
if($ilok[umen]==1 and $ilok[usr]!=="$log"){$color='#FF6633';}
if($ilok[uron]>0){
echo '<font color="#7f9fae">'.$ilok[usr].' </font><font color="'.$color.'">'.$ilok[text].'</font> <font color="#7f9fae">'.$ilok[opon].'</font> -'.$ilok[uron].'<br/>';}
else{echo '<font color="#AAAAAA">'.$ilok[text].'</font><br/>';}
}
}}

function idlog($idlog){}

///РЕФЕРАЛЫ
function ref(){
global $log,$udata,$set;
if(!empty($udata['ref'])){
if($udata['lvl']>='10' and $udata['ref']!='not'){

$req = mysql_query("SELECT `exp`,`money`,`usr` FROM `users` WHERE `id` = '$udata[ref]' LIMIT 1");
// //////////////////////////
$avto = mysql_num_rows($req);
$refec = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `users` WHERE `id` = '$udata[ref]' LIMIT 1");
$usdata = mysql_fetch_array($req);
$res = mysql_query("SELECT * FROM `set` WHERE `usr` = '$usdata[usr]' LIMIT 1");
$set = mysql_fetch_array($res);
if ($avto == 1) {
    $refer = mysql_fetch_array($req);
    $refer[money]=$usdata[money]+1500;
    $refer[exp]=$usdata[exp]+1500;
    $refer[almaz]=$usdata[almaz]+3;
    $time = date("H:i d.m.y");
    $text = "Ваш друг $udata[usr] дошел до 10 уровня, 3 алмаза, а также сумма 1500 монет и 1500 опыта была успешно вам перечислена!";
    mysql_query("UPDATE `users` SET `money` = '$refer[money]', `exp`='$refer[exp]', `almaz`='$refer[almaz]' WHERE `id` = '$udata[ref]' LIMIT 1");
    mysql_query("UPDATE `set` SET `friend` = '$set[friend]'+'1' WHERE `usr` = '$usdata[usr]' LIMIT 1");
    mysql_query("UPDATE `users` SET `ref` = 'not' WHERE `usr` = '$log' LIMIT 1");
    mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Система', `user_to` = '$refec[usr]', `time` = '$time', `read` = 1, `mail_msg` = '$text'");}}}}
/////////////////////


function vip(){
global $log,$udata,$set;
$sett = mysql_query("SELECT * FROM `set` WHERE `usr` = '$log' LIMIT 1");
$set = mysql_fetch_assoc($sett);
$time = time();
if($set[vip]==on and $time >= $set[viptime]){
mysql_query("UPDATE `set` SET `vip` = 'off' WHERE `usr` = '$log' LIMIT 1");
$time = date("H:i d.m.y");
$text = "Закончилось время вашего vip-статуса";
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'VIP', `user_to` = '$log', `time` = '$time', `read` = 1, `mail_msg` = '$text'");}}

function domin(){
global $udata;

$req=mysql_query("SELECT * FROM domination WHERE id = '1'");
$dom = mysql_fetch_assoc($req);
if($udata['storona']=='white'){
$my=$dom['white'];
$enemy=$dom['black'];
}else{
$my=$dom['black'];
$enemy=$dom['white'];
}
$all=$my+$enemy;
$domin=round($my/$all * 100);
if($domin<='15'){
echo' <img src="pic/main/towerscontrol1.png" alt="d">';
}elseif($domin<='30'){
echo' <img src="pic/main/towerscontrol2.png" alt="d">';
}elseif($domin<='45'){
echo' <img src="pic/main/towerscontrol3.png" alt="d">';
}elseif($domin<='55'){
echo' <img src="pic/main/towerscontrol4.png" alt="d">';
}elseif($domin<='70'){
echo' <img src="pic/main/towerscontrol5.png" alt="d">';
}elseif($domin<='85'){
echo' <img src="pic/main/towerscontrol6.png" alt="d">';
}elseif($domin<='100'){
echo' <img src="pic/main/towerscontrol7.png" alt="d">';}}

/////АУРЫ//////////////
function aura(){
global $log,$udata;
$time=time();
///////
$req = mysql_query("SELECT * FROM `aurs` WHERE `actimer`<'$time' and `usr`='$log'");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto=='1'){
$req = mysql_query("SELECT * FROM `item_aura` WHERE `usr` = '$log' and `status`='1' LIMIT 1");
$avto=mysql_num_rows($req);
if($avto=='1'){
$mag = mysql_fetch_array($req);

$nlovk=$udata[lovk]-$mag[lovk];
$nsila=$udata[sila]-$mag[sila];
$nprotect=$udata[prot]-$mag[protect];
$nhp=$udata[hpall]-$mag[hp];
$nmp=$udata[mpall]-$mag[mp];
$nkrit=$udata[krit]-$mag[krit];
$nukrit=$udata[ukrit]-$mag[ukrit];

mysql_query("UPDATE `users` SET
         `sila` = '$nsila',
         `lovk` = '$nlovk',
         `prot` = '$nprotect',
         `hpall` = '$nhp',
         `mpall` = '$nmp',
         `krit` = '$nkrit',
         `ukrit` = '$nukrit'
          WHERE `usr` = '$log'") or die (mysql_error());



mysql_query("DELETE FROM `item_aura` WHERE `id` = '$mag[id]' LIMIT 1");
mysql_query("DELETE FROM `aurs` WHERE `usr` = '$log' LIMIT 1");
}
}
}
////////////////////////

//////////////ЧИСТИМ АРЕНУ
function clear_arena(){}
//////////////////////

///////КОРМИМ ПИТОВ
function pit_eda(){
global $log;

$time=time();
$req = mysql_query("SELECT `dies`,`eda`,`name`,`korm`,`status` FROM `pit` WHERE `usr` = '$log' LIMIT 1") or die(mysql_error());
$avto=mysql_num_rows($req);
if($avto>='1'){
$pit = mysql_fetch_assoc($req);
$proc=(($pit['korm']-$time)/$pit['eda'])*100;
if($proc<=0 and $pit['status']!="die"){
$pit['dies']=$pit['dies']+1;
mysql_query("UPDATE `pit` SET `hp` = '0',`dies`='$pit[dies]',`status`='die' WHERE `usr` = '$log' LIMIT 1");
///пишем письмо
$time = date("H:i d.m.y");
$text = $pit[name].' погиб от голода! Вы можете его воскресить в питомнике!';
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Зверовод', `user_to` = '$log', `time` = '$time', `read` = 1, `mail_msg` = '$text'");
}
}
}
////////////////

//навигация
function place_okr(){}

//навигация
function place_zamok(){}

//навигация
function place_tower(){}

//навигация
function place_city(){}

/* NEW FUNC MedveD */
function time_left($tl)
{
$d=3600*24;
$day=floor($tl/$d);
$tl=$tl-($d*$day);

$hour=floor($tl/3600);
$tl=$tl-(3600*$hour);

$minute=floor($tl/60);
$tl=$tl-(60*$minute);

$second=floor($tl);

$dayt="".($day>0?"$day д. ":null)."";
$hourt="".($hour>0?"$hour ч. ":null)."";
$minutet="".($minute>0?"$minute м. ":null)."";
$secondt="".($second>0?"$second с. ":null)."";
if($day>0)
{
$minutet=NULL;
$secondt=NULL;
}
if($hour>0 && $day==0)
{
$secondt=NULL;
$dayt=NULL;
}
return "$dayt$hourt$minutet$secondt";
}

function hsc($text)
{
return htmlspecialchars($text);
}

function my_esc($str){
return mysql_real_escape_string($str);
}
function page($k_page=1){ // Выдает текущую страницу
$page=1;
if (isset($_GET['page'])){
if ($_GET['page']=='end')$page=intval($k_page);elseif(is_numeric($_GET['page'])) $page=intval($_GET['page']);}
if ($page<1)$page=1;
if ($page>$k_page)$page=$k_page;
return $page;}

function k_page($k_post=0,$k_p_str=10){ // Высчитывает количество страниц
if ($k_post!=0){$v_pages=ceil($k_post/$k_p_str);return $v_pages;}
else return 1;}

function str($link='?',$k_page=1,$page=1){ // Вывод номеров страниц
if ($page<1)$page=1;
echo "";
if ($page!=1)echo "<a href=\"".$link."page=".($page-1)."\" title='Предыдущая страница (№".($page-1).")'><<</a> ";else echo "<strong><<</strong> ";
if ($page!=1)echo "<a href=\"".$link."page=1\" title='Страница №1'>1</a>";else echo "<strong>1</strong>";
for ($ot=-3; $ot<=3; $ot++){
if ($page+$ot>1 && $page+$ot<$k_page){
if ($ot==-3 && $page+$ot>2)echo " ..";
if ($ot!=0)echo " <a href=\"".$link."page=".($page+$ot)."\" title='Страница №".($page+$ot)."'>".($page+$ot)."</a>";else echo " <strong>".($page+$ot)."</strong>";
if ($ot==3 && $page+$ot<$k_page-1)echo " ..";}}
if ($page!=$k_page)echo " <a href=\"".$link."page=end\" title='Страница №$k_page'>$k_page</a> ";elseif ($k_page>1)echo " <strong>$k_page</strong> ";
if ($page!=$k_page)echo "<a href=\"".$link."page=".($page+1)."\" title='Следующая страница (№".($page+1).")'>>></a> ";else echo "<strong>>></strong>";
}
/* NEW FUNC MedveD */

?>