Файл: zamok/ataka.php
Строк: 78
<?
include_once '../core/system.php';
echo only_reg();
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `zamok` WHERE `id` = '".intval($_GET['id'])."'"),0) == true){
$zamok = mysql_fetch_assoc(mysql_query("SELECT * FROM `zamok` WHERE `id` = '".intval($_GET['id'])."'"));
}else{
$_SESSION['err'] = "Нет такого замка!";
header('Location: index.php');
exit();
}
if($user[health] < 20){
$_SESSION['light'] = "<span class='dred'>Для нападения нужно <img src='/images/icon/health.png' alt=''/> 20 Здоровья</span><br/>Здоровье восстанавливается со временем или за золото<br><div class='separ'></div><a class='btn' href='/moduls/ckoldun.php?act=ok'><span class='end'><span class='label'>Восстановить <img src='/images/icon/health.png' alt=''/> 100% здоровья</span></span></a><br><span class='grey'>Цена: <img src='/images/icon/gold.png' alt=''/> 10 золота</span>";
header("Location: zamok.php?id=$zamok[id]");
exit();
}
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '".$zamok[id_user]."'"));
$gold = $ank[level]*2;
$user_uron = rand(1,$user[sila]-79);
$zamok_uron = rand(1,$zamok[param]-1000);
if($user[mana] > 49){
if($user_uron < $zamok_uron){
mysql_query("update `user` set `mana`='".($user['mana']-50)."', `health`='".($user['health']-$zamok_uron)."' where (`id` = '".$user['id']."')");
mysql_query("update `zamok` set `param` = '".($zamok['param']-$user_uron)."' where (`id` = '".$zamok['id']."')");
header("Location: zamok.php?id=$zamok[id]");
$_SESSION['light'] = "<h2 class='dred' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Поражение <img src='/images/icon/2hit.png' alt=''/></h2>";
exit();
}else{
mysql_query("update `user` set `gold` = '".($user['gold']+$gold)."',`mana`='".($user['mana']-50)."', `health`='".($user['health']-$zamok_uron)."' where (`id` = '".$user['id']."')");
mysql_query("update `zamok` set `param` = '".($zamok['param']-$user_uron)."' where (`id` = '".$zamok['id']."')");
header("Location: zamok.php?id=$zamok[id]");
$_SESSION['light'] = "<h2 class='dgreen' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Победа <img src='/images/icon/2hit.png' alt=''/></h2><div class='separ'></div><img src='/images/icon/gold.png' alt='exp'/> ".$gold." золота";
exit();
}
}else{
$_SESSION['light'] = "<span class='dred'>Для нападения нужно <img src='/images/icon/mana.png' alt=''/> 50 маны</span><br/>Мана восстанавливается со временем или за золото<br><div class='separ'></div><a class='btn' href='/moduls/ckoldun.php?act=ok'><span class='end'><span class='label'>Восстановить <img src='/images/icon/mana.png' alt=''/> 100% маны</span></span></a><br><span class='grey'>Цена: <img src='/images/icon/gold.png' alt=''/> 10 золота</span>";
header("Location: zamok.php?id=$zamok[id]");
exit();
}
?>