Файл: cron/reit.php
Строк: 48
<?
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);
$dsa=date('H');
$boss=mysql_fetch_array(mysql_query("SELECT * FROM `boss_activ` WHERE `id`='1'"));
if($boss['activ']==0)
{
if($boss['time_start']<=time())
{
$bs=rand(1,4);
$t_st=time();
$t_fh=$t_st+7200;
mysql_query("UPDATE `boss_activ` SET `activ`='1', `boss`='".$bs."', `time_start`='".$t_st."', `time_close`='".$t_fh."' WHERE `id`='".$boss['id']."'");
$bos=mysql_fetch_array(mysql_query("SELECT * FROM `boss` WHERE `id`='".$bs."'"));
$lvlb=$bos['lvl']-1;
$bos['hp']=$bos['hp']+$lvlb*$bos['lvl_hp'];
$bos['sila']=$bos['sila']+$lvlb*$bos['lvl_sila'];
$bos['arm']=$bos['arm']+$lvlb*$bos['lvl_arm'];
mysql_query("INSERT INTO `boss_usr` SET
`id`='',
`tip`='boss',
`name`='".$bos['name']."',
`hp`='".$bos['hp']."',
`arm`='".$bos['arm']."',
`sila`='".$bos['sila']."'
");
}
}
else
{
$bosa=mysql_num_rows(mysql_query("SELECT * FROM `boss_usr` WHERE `tip`='boss'"));
if($bosa==0)
{
$t_st=time()+rand(40000,65000);
$bos=mysql_fetch_array(mysql_query("SELECT * FROM `boss` WHERE `id`='".$boss['boss']."'"));
$b_lvl=$bos['lvl']+1;
mysql_query("UPDATE `boss` SET `lvl`='".$b_lvl."' WHERE `id`='".$bos['id']."'");
mysql_query("UPDATE `boss_activ` SET `activ`='0', `boss`='0', `time_start`='".$t_st."', `time_close`='0' WHERE `id`='".$boss['id']."'");
mysql_query("DELETE FROM `boss_usr`");
mysql_query("DELETE FROM `log_boss`");
$reit=mysql_query("SELECT * FROM `boss_reit`");
while($br=mysql_fetch_array($reit))
{
$bez=round($br['yron']/5000);
$bez=$bez+round($bez/100*25);
$us=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$br['usr']."'"));
$km=$us['km']+$bez;
mysql_query("UPDATE `users` SET `km`='".$km."' WHERE `id`='".$us['id']."'");
$text_ok='Битва против Босса: "'.$bos['name'].'" окончена. Вы нанесли '.$br['yron'].' урона. Ваша награда: Кристалл Монстробоя<img src=img/main/71.png>'.$bez.'';
$rows2_ok=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$us['id']."'"));
mysql_query("UPDATE `msg_kont` SET `read`='1', `time`='".time()."' WHERE `usr2`='0' and `usr1`='".$us['id']."'");
$rows2_oks=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$us['id']."'"));
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows2_oks['id']."',
`vhod`='1',
`time`='".time()."',
`text`='".$text_ok."',
`usr`='".$us['id']."'
");
}
mysql_query("DELETE FROM `boss_reit`");
}
else
{
if($boss['time_close']<=time())
{
$t_st=time()+rand(40000,65000);
$bos=mysql_fetch_array(mysql_query("SELECT * FROM `boss` WHERE `id`='".$boss['boss']."'"));
mysql_query("UPDATE `boss_activ` SET `activ`='0', `boss`='0', `time_start`='".$t_st."', `time_close`='0' WHERE `id`='".$boss['id']."'");
mysql_query("DELETE FROM `boss_usr`");
mysql_query("DELETE FROM `log_boss`");
$reit=mysql_query("SELECT * FROM `boss_reit`");
while($br=mysql_fetch_array($reit))
{
$bez=round($br['yron']/5000);
$us=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$br['usr']."'"));
$km=$us['km']+$bez;
mysql_query("UPDATE `users` SET `km`='".$km."' WHERE `id`='".$us['id']."'");
$text_ok='Битва против Босса: "'.$bos['name'].'" окончена. Вы нанесли '.$br['yron'].' урона. Ваша награда: Кристалл Монстробоя<img src=img/main/71.png>'.$bez.'';
$rows2_ok=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$us['id']."'"));
mysql_query("UPDATE `msg_kont` SET `read`='1', `time`='".time()."' WHERE `usr2`='0' and `usr1`='".$us['id']."'");
$rows2_oks=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$us['id']."'"));
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows2_oks['id']."',
`vhod`='1',
`time`='".time()."',
`text`='".$text_ok."',
`usr`='".$us['id']."'
");
}
mysql_query("DELETE FROM `boss_reit`");
}
}
}
?>