Файл: avan.php
Строк: 145
<?
define('PROTECTOR', 1);
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
$textl='Аванпост';
include($path.'files/core.php');
if($udata['lvl']<16)
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Аванпост доступен с 16 уровня!'
");
header('location: game.php');exit;
}
if($udata['lvl']>=16 and $udata['lvl']<=30)
{
$g=2;
}
elseif($udata['lvl']>=31 and $udata['lvl']<=38)
{
$g=3;
}
elseif($udata['lvl']>=39 and $udata['lvl']<=50)
{
$g=4;
}
elseif($udata['lvl']>=51 and $udata['lvl']<=60)
{
$g=5;
}
$avan_usr=mysql_query("SELECT * FROM `avan_usr` WHERE `usr`='".$udata['id']."'");
$avan=mysql_num_rows($avan_usr);
if($avan==0)
{
if(isset($_GET['vst']))
{
$id=mysql_real_escape_string($_GET['vst']);
$avb=mysql_query("SELECT * FROM `avan` WHERE `gorod`='".$g."' and `id`='".$id."' and `open`>'".time()."'");
$num=mysql_num_rows($avb);
if($num==0)
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Ошибка!'
");
header('location: ?');exit;
}
else
{
$av=mysql_fetch_array($avb);
$udata['hp1']=$udata['hp1']+$udata['hp2'];
$udata['sila1']=$udata['sila1']+$udata['sila2'];
$udata['arm1']=$udata['arm1']+$udata['arm2'];
$ss=$udata['hp1']+$udata['sila1']+$udata['arm1'];
if($ss<=$av['stat'] or $av['stat']==0)
{
mysql_query("INSERT INTO `avan_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='usr',
`arr`='".$av['id']."',
`hp`='".$udata['hp']."',
`arm`='".$udata['arm']."',
`sila`='".$udata['sila']."'
");
$tr=mysql_query("SELECT * FROM `pit` WHERE `usr`='".$udata['id']."' and `status`='1'");
$num=mysql_num_rows($tr);
if($num!=0)
{
$t=mysql_fetch_array($tr);
$kn=mysql_num_rows(mysql_query("SELECT * FROM `item` WHERE `tip`='knyt' and `usr`='".$udata['id']."' and `status`='on'"));
if($kn!=0)
{
$t['hp']=round($t['hp']+$t['hp']/100*15);
$t['sila']=round($t['sila']+$t['sila']/100*15);
$t['arm']=round($t['arm']+$t['arm']/100*15);
}
$kn2=mysql_num_rows(mysql_query("SELECT * FROM `item` WHERE `tip`='knyt2' and `usr`='".$udata['id']."' and `status`='on'"));
if($kn2!=0)
{
$t['hp']=round($t['hp']+$t['hp']/100*30);
$t['sila']=round($t['sila']+$t['sila']/100*30);
$t['arm']=round($t['arm']+$t['arm']/100*30);
}
mysql_query("INSERT INTO `avan_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='pit',
`arr`='".$av['id']."',
`pit`='".$t['id']."',
`hp`='".$t['hp']."',
`arm`='".$t['arm']."',
`sila`='".$t['sila']."'
");
}
}
else
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Недопустимое количество статов.'
");
}
}
header('location: ?');exit;
}
include($path.'files/head.php');
include($path.'files/zag.php');
echo '<table width=100%>
<tr>
<td width=35%>
<a href=game.php><div style="background: #882222; border-radius: 7px 0 0 7px" class="m p bts bbs brs bls" align=center>Главная</div></a>
</td><td>';
echo '<a href=?><div class="line bts brs bls bbs p m" style="border-radius: 0 7px 7px 0">
<font color=#ffffff>Аванпост
</font>
</div></a></td></tr></table>';
echo '<div class="bat bts brs bls bbs p">';
echo '<div align=center><img src=img/inter/17.jpg></div>
';
$avb=mysql_query("SELECT * FROM `avan` WHERE `gorod`='".$g."' ORDER BY `id` ASC");
while($av=mysql_fetch_array($avb))
{
echo '<div class="head p m">';
echo '<img src=img/main/i25.png> <font color=#ff9900><b>'.$av['name'].'</b></font>'; if($av['stat']>0){echo' <img src=img/main/p28.png>'.$av['stat'].'';}
echo '<br>';
if($av['status']==0)
{
echo '<img src=img/main/i26.png> <font color=#00ff00>Все спокойно</font><br>';
$ysl=mysql_num_rows(mysql_query("SELECT * FROM `item` WHERE `usr`='".$udata['id']."' and `tip`='avan'"));
if($ysl!=0)
{
$time=$av['time_open']-time();
if($time>=60)
{
$t=round($time/60).'м.';
}
else
{
$t=$time.'c.';
}
echo '<img src=img/main/e28.png> <font color=#ff0000>Открытие через: </font><font color=#00ff99>'.$t.'</font>';
}
}
elseif($av['status']!=0 and $av['open']>time())
{
$time=$av['open']-time();
if($time>=60)
{
$time2=round($time/60).'м.';
}
else
{
$time2=$time.'c.';
}
echo '<img src=img/main/i26.png> <font color=#ff0000>Подготовка к битве</font> <img src=img/main/e12.png>'.$time2.'<br>
<img src=img/main/i26.png> <a href=?vst='.$av['id'].'>Вступить</a>
';
}
elseif($av['status']!=0 and $av['open']<=time() and $av['close']>time())
{
echo '<img src=img/main/i26.png> <font color=#ff0000>Идет бой</font>';
}
echo'</div>';
}
}
else
{
if(isset($_GET['leave']))
{
mysql_query("DELETE FROM `avan_usr` WHERE `usr`='".$udata['id']."'");
header('location: ?');exit;
}
$a_us=mysql_fetch_array($avan_usr);
$avb=mysql_query("SELECT * FROM `avan` WHERE `gorod`='".$g."' and `id`='".$a_us['arr']."' ORDER BY `id` ASC");
$av=mysql_fetch_array($avb);
if($av['open']>time())
{
include($path.'files/head.php');
include($path.'files/zag.php');
echo '<table width=100%>
<tr>
<td width=35%>
<a href=game.php><div style="background: #882222; border-radius: 7px 0 0 7px" class="m p bts bbs brs bls" align=center>Главная</div></a>
</td><td>';
echo '<a href=?><div class="line bts brs bls bbs p m" style="border-radius: 0 7px 7px 0">
<font color=#ffffff>'.$av['name'].'
</font>
</div></a></td></tr></table>';
echo '<div class="bat bts brs bls bbs p">';
$time=$av['open']-time();
if($time>=60)
{
$time2=round($time/60).'м.';
}
else
{
$time2=$time.'c.';
}
echo '<img src=img/main/i26.png> <font color=#ff0000>До боя:</font> <img src=img/main/e12.png>'.$time2.'<br>
<img src=img/main/i26.png> <a href=?leave>Покинуть</a>
';
echo '</div></div>';
echo '<div class="v8"><div class="line m bbs bts brs bls b p v12">Участники</div><div class="bat bts brs bls bbs p t1">';
$aq=mysql_query("SELECT * FROM `avan_usr` WHERE `arr`='".$av['id']."' and `tip`!='pit'");
while($arrs=mysql_fetch_array($aq))
{
$usrz=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$arrs['usr']."'"));
echo '<img src=img/main/c'.$usrz['klass'].'.png> <img src=img/main/r'.$usrz['rasa'].'.png>
<a href=info.php?id='.$usrz['id'].'>'.$usrz['usr'].'</a> <img src=img/main/p10.png> '.$usrz['lvl'].'<br>';
}
}
else
{
header('location: b_av.php');exit;
}
}
echo '</div></div>';
include('files/down.php');
?>