From 30ae0642dbbb624d4ca471609d6a7ae38446fd33 Mon Sep 17 00:00:00 2001 From: lopar Date: Fri, 22 Jun 2018 22:33:11 +0300 Subject: [PATCH] Fix errors --- ashop.php | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/ashop.php b/ashop.php index c6a8ac0..d5ddd4d 100644 --- a/ashop.php +++ b/ashop.php @@ -17,21 +17,18 @@ if ($user['battle'] != 0) { $bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id`=?i', $_SESSION['uid'])->fetch_assoc(); -if (($_GET['set'] OR $_POST['set'])) { - if ($_GET['set']) { - $set = $_GET['set']; - } - if ($_POST['set']) { - $set = $_POST['set']; - } - if (!$_POST['count']) { - $_POST['count'] = 1; - } - if (!is_numeric($_POST['count']) || $_POST['count'] != ((int)$_POST['count'])) { - $_POST['count'] = 0; - $count_ok = 0; - } elseif ($_POST['count'] < 1) { - $_POST['count'] = 0; +//$set = isset($_POST['set']) ? $_POST['set'] : ''; +//$var = $value ?: "Другое значение"; + +if (isset($_GET['set']) OR isset($_POST['set'])){ + + $set = empty($_GET['set']) ?: $_GET['set']; + $set = empty($_POST['set']) ?: $_POST['set']; + + $count = isset($_POST['count']) && is_numeric($_POST['count']) ? $_POST['count'] : 0; + + if ($count < 1) { + $count = 0; $count_ok = 0; } else $count_ok = 1; @@ -131,12 +128,10 @@ if (($_GET['set'] OR $_POST['set'])) { - > +
>
- - query('SELECT `id`,`login`,`room` FROM `users` WHERE `login` = ?i', $_POST['to_login'])->fetch_assoc(); @@ -226,7 +221,7 @@ if (($_GET['set'] OR $_POST['set'])) { $from = $user['login']; } - db::c()->query('UPDATE `inventory` SET `owner` = ?i, `present` = "?s", `letter` = "?s" WHERE `present` = "?s" AND `id` = ?i AND `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $to['id'], $from, $_POST['podarok2'], null, $_POST['flower'], $_SESSION['uid']); + db::c()->query('UPDATE `inventory` SET `owner` = ?i, `present` = "?s", `letter` = "?s" WHERE `present` = "?s" AND `id` = "?s" AND `owner` = ?i AND `dressed` = 0 AND `setsale` = 0', $to['id'], $from, $_POST['podarok2'], null, $_POST['flower'], $_SESSION['uid']); $res = db::c()->query('SELECT `id`,`name`,`duration`,`maxdur` FROM `inventory` WHERE `id` = ?i', $_POST['flower'])->fetch_assoc(); $deloTextSender = "Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\""; $deloTextReceiver = "Подарен предмет \"" . $res['name'] . "\" id:(cap" . $res['id'] . ") [" . $res['duration'] . "/" . $res['maxdur'] . "] от \"" . $user['login'] . "\" к \"" . $to['login'] . "\"";