<?
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();
}
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id`  = '".$zamok[id_user]."'"));
if($user[id] == $ank[id]){
if($user[gold] > 500){
mysql_query("UPDATE `zamok` SET `param` = '".($zamok[param]+500)."', `titan1` = '".($zamok[titan1]+1)."' WHERE `id` = '$_GET[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `gold` = '".($user[gold]-500)."' WHERE `id` = '$user[id]' LIMIT 1");
header("Location: zamok.php?id=$zamok[id]");
$_SESSION['message'] = 'Титан нанят!';
exit();
}else{
header("Location: zamok.php?id=$zamok[id]");
$_SESSION['err'] = 'Нужно больше золота!';
exit();
}
}else{
header("Location: zamok.php?id=$zamok[id]");
$_SESSION['err'] = 'Это не ваш замок!';
exit();
}
?>