query('SELECT SUM(`massa`) FROM `inventory` WHERE `dressed` = 0 AND `owner` = ?i', $_SESSION['uid'])->fetch_assoc(); if ($user['room'] != 23) { header("Location: main.php"); die(); } if ($user['battle'] != 0) { header('location: fbattle.php'); die(); } // Гравировка if (input::post('set') && input::post('count') && ($user['money'] >= 30)) { if (db::c()->query('UPDATE `inventory` SET `text` = "?s" WHERE `dressed` = 0 AND `setsale` = 0 AND `owner` = ?i AND `id` = ?i', input::post('count'), $_SESSION['uid'], input::post('set'))) db::c()->query('UPDATE `users` SET `money` = `money` - 30 WHERE `id` = ?i', $_SESSION['uid']); } // Снять гравировку if ($_GET['rep'] && ($_GET['sid'] == 2)) { mysql_query("UPDATE `inventory` SET `text` = '' WHERE `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '" . (int)$_GET['rep'] . "' LIMIT 1"); } // Полный ремонт if ($_GET['sid'] && $_GET['rep']) { $row = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `isrep` = 1 AND `owner` = '{$user['id']}' AND `dressed` = 0 AND `id` = '{$_GET['rep']}' AND `setsale`=0 LIMIT 1;")); $full = $row['duration']; if ($row['duration'] > 1) { //$onecost=$row['cost']/($row['maxdur']*10); //if($onecost < 0.1) {$onecost=0.1;} $onecost = 0.1; if (round($onecost * $full) <= $user['money']) { if (mysql_query("UPDATE `inventory` SET `duration` = '0' WHERE `id` = {$_GET['rep']}")) { $err = "Произведен ремонт предмета \"{$row['name']}\" за " . (round($onecost, 2) * $full) . " кр. "; mysql_query("UPDATE `users` set `money` = `money`- '" . (round($onecost, 2) * $full) . "' WHERE id = {$user['id']}"); mysql_query("INSERT INTO `delo` (`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','{$user['id']}','Отремонтирован предмет \"" . $row['name'] . "\" id:(cap" . $row['id'] . ") [0/" . $row['maxdur'] . "] у \"" . $user['login'] . "\" за " . (round($onecost, 2) * $full) . " кр. ',1,'" . time() . "');"); $user['money'] = $user['money'] - (round($onecost, 2) * $full); if (rand(1, 5) == 1) { $err .= "К сожалению максимальная долговечность предмета из-за ремонта уменьшилась."; mysql_query("UPDATE `inventory` SET `maxdur` = `maxdur`-1 WHERE `id` = {$_GET['rep']}"); } } } else { $err = "Недостаточно денег."; } } } ?>