Файл: cron/game/game1.php
Строк: 141
<?
define('PROTECTOR', 1);
$db_host = "localhost";
$db_user = "root";
$db_table = "sidonia";
$db_pass = "";
$connect = @ mysql_pconnect($db_host, $db_user, $db_pass) or die('cannot connect to server');
@ mysql_select_db($db_table) or die('cannot connect to db');
@ mysql_query("SET NAMES 'utf8'", $connect);
$awww=mysql_query("SELECT * FROM `arena_usr`");
while($aww=mysql_fetch_array($awww))
{
$awq=mysql_num_rows(mysql_query("SELECT * FROM `arena` WHERE `id`='".$aww['arr']."'"));
if($awq==0)
{
mysql_query("DELETE FROM `arena_usr` WHERE `id`='".$aww['id']."'");
}
}
$timeqss=time()-1800;
mysql_query("DELETE FROM `arena` WHERE `time`<='".$timeqss."'");
$rty=mysql_query("SELECT * FROM `pit`");
while($rt=mysql_fetch_array($rty))
{
$lvl=$rt['lvl']+1;
$exzn=mysql_num_rows(mysql_query("SELECT * FROM `lvl_pit` WHERE `lvl`='".$lvl."'"));
if($exzn!=0)
{
$ex=mysql_fetch_array(mysql_query("SELECT * FROM `lvl_pit` WHERE `lvl`='".$lvl."'"));
if($rt['exp']>=$ex['exp'])
{
$kl=$rt['lvl']+1;
if($kl<11)
{
if($rt['tip']==1)
{
$hp=$rt['hp1']+4;
$sila=$rt['sila1']+5;
$arm=$rt['arm1']+4;
}
if($rt['tip']==2)
{
$hp=$rt['hp1']+5;
$sila=$rt['sila1']+4;
$arm=$rt['arm1']+4;
}
if($rt['tip']==3)
{
$hp=$rt['hp1']+4;
$sila=$rt['sila1']+4;
$arm=$rt['arm1']+5;
}
if($rt['tip']==4)
{
$hp=$rt['hp1']+6;
$sila=$rt['sila1']+6;
$arm=$rt['arm1']+6;
}
}
else
{
$hp=$rt['hp1']+7;
$sila=$rt['sila1']+7;
$arm=$rt['arm1']+7;
}
$skk=1;
$skill2=$rt['skill_up']+$skk;
if($kl==10 or $kl==20 or $kl==30 or $kl==40)
{
$skill=$rt['skill']+1;
}
else
{
$skill=$rt['skill'];
}
mysql_query("UPDATE `pit` SET `lvl`='".$kl."', `hp1`='".$hp."', `sila1`='".$sila."', `arm1`='".$arm."', `skill`='".$skill."', `skill_up`='".$skill2."' WHERE `id`='".$rt['id']."'");
}
}
}
$ts=time();
$rest=mysql_query("SELECT * FROM `bazar_res` WHERE `time`<='".$ts."'");
while($res=mysql_fetch_array($rest))
{
$us=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$res['usr']."'"));
$kol=$us[''.$res['res'].'']+$res['kol'];
mysql_query("UPDATE `users` SET `".$res['res']."`='".$kol."' WHERE `id`='".$us['id']."'");
mysql_query("DELETE FROM `bazar_res` WHERE `id`='".$res['id']."'");
}
$timeq=time();
$bafs=mysql_query("SELECT * FROM `baf` WHERE `time`<'".$timeq."'");
$bafa=mysql_num_rows($bafs);
if($bafa!=0)
{
$bafas=mysql_fetch_array($bafs);
mysql_query("DELETE FROM `baf` WHERE `id`='".$bafas['id']."'");
}
$gtr=mysql_query("SELECT * FROM `gift` WHERE `time`<'".$timeq."'");
$gtrs=mysql_num_rows($gtr);
if($gtrs!=0)
{
$gt=mysql_fetch_array($gtr);
mysql_query("DELETE FROM `gift` WHERE `id`='".$gt['id']."'");
}
$drt=date('d');
$rai_tv=mysql_fetch_array(mysql_query("SELECT * FROM `aaa` WHERE `id`='6'"));
if($rai_tv['day']!=$drt)
{
$urtv=mysql_query("SELECT * FROM `users` WHERE `rt`>'1' or `rt_p`<'10'");
while($urt=mysql_fetch_array($urtv))
{
$rt_p='10';
$rt_max=$urt['rt'];
mysql_query("UPDATE `users` SET `rt_p`='".$rt_p."', `rt_max`='".$rt_max."', `rt`='1' WHERE `id`='".$urt['id']."'");
mysql_query("UPDATE `aaa` SET `day`='".$drt."' WHERE `id`='6'");
}
}
$tres=time();
$resgi=mysql_query("SELECT * FROM `sectors` WHERE `res`<'".$tres."' and `clan`!='0'");
$gres=mysql_num_rows($resgi);
if($gres!=0)
{
while($gress=mysql_fetch_array($resgi))
{
$gi=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$gress['clan']."'"));
if($gress['tip']=='iss')
{
$iss=$gi['wood']+3;
$lazyr=$gi['steel'];
$bagr=$gi['energy'];
}
elseif($gress['tip']=='lazyr')
{
$iss=$gi['wood'];
$lazyr=$gi['steel']+3;
$bagr=$gi['energy'];
}
elseif($gress['tip']=='bagr')
{
$iss=$gi['wood'];
$lazyr=$gi['steel'];
$bagr=$gi['energy']+3;
}
else
{
$iss=$gi['wood'];
$lazyr=$gi['steel'];
$bagr=$gi['energy'];
}
$reit=$gi['reit']+10;
mysql_query("UPDATE `clan` SET `wood`='".$iss."', `steel`='".$lazyr."', `energy`='".$bagr."', `reit`='".$reit."' WHERE `id`='".$gi['id']."'");
$tyt=time()+7200;
mysql_query("UPDATE `sectors` SET `res`='".$tyt."' WHERE `id`='".$gress['id']."'");
}
}
mysql_query("DELETE FROM `terr_usr` WHERE `time_close`<'".time()."'");
mysql_query("UPDATE `sectors` SET `att_clan`='0' WHERE `time_close`<'".time()."' and `att_clan`!='0'");
$trw=time()-172800;
$resq=mysql_query("SELECT * FROM `adm_res` WHERE `time`<'".$trw."'");
$ares=mysql_num_rows($resq);
if($ares!=0)
{
$aress=mysql_fetch_array($resq);
mysql_query("DELETE FROM `adm_res` WHERE `id`='".$aress['id']."'");
}
$avan_open_close=mysql_query("SELECT * FROM `avan` WHERE `open`<='".time()."' and `status`!='0'");
while($av_op_cl=mysql_fetch_array($avan_open_close))
{
$ure=mysql_num_rows(mysql_query("SELECT * FROM `avan_usr` WHERE `arr`='".$av_op_cl['id']."' and `status`='0' and `tip`='usr'"));
if($ure==0)
{
mysql_query("UPDATE `avan` SET `status`='0', `volna`='0', `etap`='1' WHERE `id`='".$av_op_cl['id']."'");
mysql_query("DELETE FROM `avan_usr` WHERE `arr`='".$av_op_cl['id']."'");
mysql_query("DELETE FROM `avan_mob` WHERE `arr`='".$av_op_cl['id']."'");
mysql_query("DELETE FROM `log_avan` WHERE `arr`='".$av_op_cl['id']."'");
}
}
mysql_query("DELETE FROM `arena_duel_usr` WHERE `time`<'".time()."' and `ok`<'2'");
$bz_delest=mysql_query("SELECT * FROM `arena` WHERE `time`<'".time()."'");
while($bz_del=mysql_fetch_array($bz_delest))
{
$num_bz_usz=mysql_num_rows(mysql_query("SELECT * FROM `arena_usr` WHERE `arr`='".$bz_del['id']."' and `tip`='usr' and `status`!='0'"));
if($num_bz_usz==0)
{
$num_bz_us=mysql_num_rows(mysql_query("SELECT * FROM `arena_usr` WHERE `arr`='".$bz_del['id']."' and `tip`='usr' and `status`='0'"));
if($num_bz_us<4)
{
mysql_query("DELETE FROM `arena_usr` WHERE `arr`='".$bz_del['id']."' and `status`='0'");
mysql_query("DELETE FROM `arena` WHERE `id`='".$bz_del['id']."'");
}
}
}
$arena_otkat=mysql_fetch_array(mysql_query("SELECT * FROM `arena_otkat` WHERE `id`='1'"));
if($arena_otkat['ar_mob']<time())
{
$users=mysql_query("SELECT * FROM `users`");
while($us=mysql_fetch_array($users))
{
if($us['arena_mob_kol']<10)
{
$kol1=$us['arena_mob_kol']+1;
mysql_query("UPDATE `users` SET `arena_mob_kol`='".$kol1."' WHERE `id`='".$us['id']."'");
}
$ar_mob=time()+3600;
mysql_query("UPDATE `arena_otkat` SET `ar_mob`='".$ar_mob."' WHERE `id`='1'");
}
}
if($arena_otkat['ar_duel']<time())
{
$users=mysql_query("SELECT * FROM `users`");
while($us=mysql_fetch_array($users))
{
if($us['arena_duel_kol']<10)
{
$kol1=$us['arena_duel_kol']+1;
mysql_query("UPDATE `users` SET `arena_duel_kol`='".$kol1."' WHERE `id`='".$us['id']."'");
}
$ar_mob=time()+3600;
mysql_query("UPDATE `arena_otkat` SET `ar_duel`='".$ar_mob."' WHERE `id`='1'");
}
}
if($arena_otkat['ar_bz']<time())
{
$users=mysql_query("SELECT * FROM `users`");
while($us=mysql_fetch_array($users))
{
if($us['arena_bz_kol']<5)
{
$kol1=$us['arena_bz_kol']+1;
mysql_query("UPDATE `users` SET `arena_bz_kol`='".$kol1."' WHERE `id`='".$us['id']."'");
}
$ar_mob=time()+7200;
mysql_query("UPDATE `arena_otkat` SET `ar_bz`='".$ar_mob."' WHERE `id`='1'");
}
}
$ittr=mysql_query("SELECT * FROM `item` WHERE `times`>'0'");
while($iyt=mysql_fetch_array($ittr))
{
if($iyt['times']<time())
{
mysql_query("DELETE FROM `item` WHERE `id`='".$iyt['id']."'");
}
}
$avan_close=mysql_query("SELECT * FROM `avan` WHERE `close`<='".time()."' and `status`!='0'");
while($av_cl=mysql_fetch_array($avan_close))
{
mysql_query("UPDATE `avan` SET `status`='0', `volna`='0', `etap`='1' WHERE `id`='".$av_cl['id']."'");
mysql_query("DELETE FROM `avan_usr` WHERE `arr`='".$av_cl['id']."'");
mysql_query("DELETE FROM `avan_mob` WHERE `arr`='".$av_cl['id']."'");
mysql_query("DELETE FROM `log_avan` WHERE `arr`='".$av_op_cl['id']."'");
}
mysql_query("DELETE FROM `labir_usr_blok` WHERE `time`<'".time()."'");
$avan_open=mysql_query("SELECT * FROM `avan` WHERE `time_open`<='".time()."' and `status`='0'");
while($av_op=mysql_fetch_array($avan_open))
{
$open=time()+600;
$close=time()+3600+600;
$time_open=$close+rand(1800,7200);
mysql_query("UPDATE `avan` SET `status`='1', `volna`='0', `etap`='1', `open`='".$open."', `time_open`='".$time_open."', `close`='".$close."' WHERE `id`='".$av_op['id']."'");
}
$times=time()-21600;
$timess=time()-259200;
mysql_query("DELETE FROM `chat` WHERE `time`<'".$times."'");
mysql_query("DELETE FROM `chat_md` WHERE `time`<'".$times."'");
mysql_query("DELETE FROM `chat_r` WHERE `time`<'".$times."'");
mysql_query("DELETE FROM `chat_clan` WHERE `time`<'".$times."'");
mysql_query("DELETE FROM `msg_dialog` WHERE `time`<'".$timess."'");
mysql_query("DELETE FROM `vip` WHERE `time`<'".time()."'");
mysql_query("DELETE FROM `log_str` WHERE `usr`<'2'");
mysql_query("DELETE FROM `log_terr` WHERE `usr`<'2'");
mysql_query("DELETE FROM `log_avan` WHERE `usr`<'2' or `arr`='0'");
mysql_query("DELETE FROM `log_arena` WHERE `usr`<'2'");
mysql_query("DELETE FROM `log_nebes` WHERE `usr`<'2'");
mysql_query("DELETE FROM `log_labir` WHERE `usr`<'2'");
mysql_query("DELETE FROM `log_arena_m` WHERE `usr`<'2'");
$dw=date('d');
mysql_query("DELETE FROM `kvest` WHERE `d`!='".$dw."'");
$prettty=mysql_query("SELECT * FROM `straz` WHERE `rasa`!='0'");
while($vpras=mysql_fetch_array($prettty))
{
if($vpras['time']<=time())
{
$prana=mysql_fetch_array(mysql_query("SELECT * FROM `prana` WHERE `rasa`='".$vpras['rasa']."' and `gorod`='".$vpras['arr']."'"));
$pra=$prana['prana']+3;
$t=time()+12;
mysql_query("UPDATE `prana` SET `prana`='".$pra."' WHERE `id`='".$prana['id']."'");
mysql_query("UPDATE `straz` SET `time`='".$t."' WHERE `id`='".$vpras['id']."'");
}
}
$timeq=time();
$banss=mysql_query("SELECT * FROM `ban` WHERE `time`<'".$timeq."'");
$bansa=mysql_num_rows($banss);
if($bansa!=0)
{
$bansas=mysql_fetch_array($banss);
mysql_query("DELETE FROM `ban` WHERE `id`='".$bansas['id']."'");
}
$pdt=date('H');
$pdz_blok=mysql_query("SELECT * FROM `pdz_blok` WHERE `t`!='".$pdt."'");
while($pbv=mysql_fetch_array($pdz_blok))
{
mysql_query("DELETE FROM `pdz_blok` WHERE `id`='".$pbv['id']."'");
}
?>