Файл: b_okr_elic.php
Строк: 31
<?
define('PROTECTOR', 1);
$textl='Битва';
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
$bat=mysql_query("SELECT * FROM `okr_usrs` WHERE `usr`='".$udata['id']."'");
$bt=mysql_fetch_array($bat);
$bts_mob=mysql_query("SELECT * FROM `okr_mobs` WHERE `id`='".$bt['enemy']."'");
$num=mysql_num_rows($bts_mob);
if($num!=0)
{
$bts=mysql_fetch_array($bts_mob);
$els=mysql_real_escape_string($_GET['elic']);
$elic=mysql_query("SELECT * FROM `elic` WHERE `id`='".$els."' and `usr`='".$udata['id']."' and `status`='on'");
$cd=mysql_num_rows($elic);
if($cd==0)
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
else
{
$el=mysql_fetch_array($elic);
if($el['time']>time())
{
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
if($st['hp']==$st['hp_max'])
{
$lg='<img src=img/main/e22.png> <font color=#999999>нет эффекта от эликсира.</font>';
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='".$lg."'
");
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
}
$hp=$st['hp']+$el['ef'];
if($hp>$st['hp_max'])
{
$hp=$st['hp_max'];
}
mysql_query("UPDATE `users_stats` SET `hp`='".$hp."' WHERE `usr`='".$udata['id']."'");
$elk=$el['kol']-1;
if($elk==0)
{
mysql_query("DELETE FROM `elic` WHERE `id`='".$el['id']."'");
}
else
{
$time=time()+$el['rest'];
mysql_query("UPDATE `elic` SET `kol`='".$elk."', `time`='".$time."' WHERE `id`='".$el['id']."'");
}
if($el['ef']!=20000)
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='<img src=img/main/p21.png> <font color=#009900>Ваше здоровье +".$el['ef']."</font>'
");
}
else
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='<img src=img/main/p21.png> <font color=#009900>Ваше здоровье восстановлено</font>'
");
}
$dost=mysql_fetch_array(mysql_query("SELECT * FROM `users_dost` WHERE `usr`='".$udata['id']."'"));
$dk=$dost['elic_exp']+1;
mysql_query("UPDATE `users_dost` SET `elic_exp`='".$dk."' WHERE `id`='".$dost['id']."'");
}
}
header('location: '.$_SERVER['HTTP_REFERER'].'');exit;
?>