diff --git a/repair.php b/repair.php index 0ca3382..138b8a6 100644 --- a/repair.php +++ b/repair.php @@ -12,22 +12,26 @@ if ($user['battle'] != 0) { die(); } -// Гравировка 30 кред. -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'))) +// Гравировка 30 кред. Максимум 32 символа. +if (input::post('gravirovka_text') AND input::post('itemId') AND ($user['money'] >= 30)) { + if (33 > iconv_strlen(input::post('gravirovka_text'))) { + 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']); + $status = 'Гравировка добавлена!'; + } else $status = 'Превышен лимит в 32 символа!'; } -// Снять гравировку -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 (input::post('gravirovka_remove')) { + db::c()->query('UPDATE `inventory` SET `text` = ?n WHERE `id` = ?i AND `owner` = ?i', null, input::post('gravirovka_remove'), $_SESSION['uid']); + $status = 'Гравировка удалена!'; } // Ремонт 0,5 кред за единицу. -if (input::post('action') == 'repair') { +if (input::post('action') == 'repair' AND input::post('itemId')) { $q = db::c()->query('SELECT `name`, `duration` FROM `inventory` WHERE id = ?i', input::post('itemId'))->fetch_assoc(); if (ceil($q['duration'] / 2) < $user['money']) { - db::c()->query('UPDATE `inventory` SET `maxdur` = `maxdur` - 1, `duration` = 0 WHERE `id` = ?i AND `owner` = ?i', input::post('itemId'), $_SESSION['uid']); + db::c()->query('UPDATE `inventory` SET `maxdur` = `maxdur` - 1, `duration` = 0 WHERE `dressed` = 0 AND `setsale` = 0 AND `id` = ?i AND `owner` = ?i', input::post('itemId'), $_SESSION['uid']); db::c()->query('UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i', ceil($q['duration'] / 2), $_SESSION['uid']); addToDelo('Отремонтирован предмет «' . $q['name'] . '» id:(' . input::post('itemId') . ') за ' . ceil($q['duration'] / 2) . ' кр.'); $status = 'Предмет отремонтирован!'; @@ -267,11 +271,11 @@ if ($_GET['podgon']) { } if (input::post('goto') == 'remont') { - $remont_query = db::c()->query('SELECT `name`,`duration`,`maxdur`,`img`,`id` FROM `inventory` WHERE `type` < 12 AND `dressed` = 0 AND `isrep` = 1 AND `setsale` = 0 AND `duration` > 0 AND `owner` = ?i ORDER BY `update` DESC', $_SESSION['uid']); + $remont_query = db::c()->query('SELECT `id`,`name`,`img`,`duration`,`maxdur` FROM `inventory` WHERE `type` < 12 AND `dressed` = 0 AND `isrep` = 1 AND `setsale` = 0 AND `duration` > 0 AND `owner` = ?i ORDER BY `update` DESC', $_SESSION['uid']); } if (input::post('goto') == 'gravirovka') { - $gravirovka_query = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `type` = 3 AND `name` NOT LIKE "?S" AND `setsale` = 0 OR `text` <> "?s" AND `owner` = ?i ORDER by `update` DESC', $_SESSION['uid'], '%Букет%', '', $_SESSION['uid']); + $gravirovka_query = db::c()->query('SELECT `id`,`name`,`img`,`text` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `type` = 3 AND `name` NOT LIKE "?S" AND `setsale` = 0 OR `text` <> "?s" AND `owner` = ?i ORDER by `update` DESC', $_SESSION['uid'], '%Букет%', '', $_SESSION['uid']); } ?> @@ -284,7 +288,6 @@ if (input::post('goto') == 'gravirovka') {