<?
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($zamok[param] < 1){
mysql_query("update `zamok` set `id_user` = '$user[id]', `param` = '$zamok[param]'WHERE `id` = '$zamok[id]'");
mysql_query("UPDATE `user` SET `keys` = '".($user['silver']-0)."', `keys` = '".($user['keys']+5)."' WHERE `id` = '$user[id]' LIMIT 1");
header("Location: zamok.php?id=$zamok[id]");
$_SESSION['light'] = "<h2 class='dgreen' style='font-weight:bold;'> $zamok[name]</h2><div class='separ'></div>Вы завладели Замком!<br>Вы получили 5 ключей!";
}else{
header("Location: zamok.php?id=$zamok[id]");
$_SESSION['err'] = "В замке ещё ни все убиты!";
exit();
}
?>