From 6ac1056b532aed988b4133aafd74c792ced17a90 Mon Sep 17 00:00:00 2001 From: "Igor Barkov [iwork]" Date: Fri, 15 Feb 2019 16:11:58 +0200 Subject: [PATCH] putting to shop to class --- classes/Item.php | 1 + classes/ShopItem.php | 6 ++-- comission.php | 81 +++++++++++++++++++++----------------------- 3 files changed, 43 insertions(+), 45 deletions(-) diff --git a/classes/Item.php b/classes/Item.php index 39d191c..38c8da9 100644 --- a/classes/Item.php +++ b/classes/Item.php @@ -84,6 +84,7 @@ abstract class Item public $zeton; public $onlyone; public $shshop; + public $otdel; /** diff --git a/classes/ShopItem.php b/classes/ShopItem.php index faf32fb..b49a981 100644 --- a/classes/ShopItem.php +++ b/classes/ShopItem.php @@ -47,13 +47,13 @@ class ShopItem extends Item $btnValue = "Продать"; $btnLink = "/shop.php?sell={$this->id}&rnd=" . mt_rand(); break; - case 'marketback': - $btnValue = "Снять товар с продажи"; + case 'marketgetback': + $btnValue = "Снять с продажи"; $btnLink = "?back={$this->id}&rnd=" . mt_rand(); break; case 'marketshowmore': $btnValue = "Развернуть"; - $btnLink = "?max={$this->name}&rnd=" . mt_rand(); + $btnLink = "?otdel={$this->otdel}&set={$this->id}&rnd=" . mt_rand(); break; } diff --git a/comission.php b/comission.php index b980dea..bdcb053 100644 --- a/comission.php +++ b/comission.php @@ -18,9 +18,9 @@ if ($user['battle'] != 0) { $get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING')); -$itemCost = checkIntInRange($_GET['kredit']); -$itemId = checkIntInRange($_GET['n']); -$returningItemId = checkIntInRange($_GET['back']); +if (isset($_GET['kredit'])) $itemCost = checkIntInRange($_GET['kredit']); +if (isset($_GET['n'])) $itemId = checkIntInRange($_GET['n']); +if (isset($_GET['back'])) $returningItemId = checkIntInRange($_GET['back']); if ($itemCost && $itemId) { $commission = ceil($itemCost / 10); # 10% от суммы с округлением вверх. @@ -47,18 +47,13 @@ if ($returningItemId) { } -if (($_GET['set'] OR $_POST['set'])) { - if ($_GET['set']) { - $set = $_GET['set']; - } - if ($_POST['set']) { - $set = $_POST['set']; - } +if ($_GET['set']) { + if (!$_POST['count'] || !is_numeric($_POST['count']) || $_POST['count'] <= 0) { $_POST['count'] = 1; } if (is_numeric($set) && $set > 0) { - $dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `dressed`=0 AND `id` = '{$set}' and `owner`!='" . $user['id'] . "' AND `setsale` > '0' LIMIT 1;")); + $dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `dressed`=0 AND `id` = '{$set}' and `owner`!='" . $user['id'] . "' AND `setsale` > 0")); $userfrom = mysql_fetch_array(mysql_query("SELECT `login`,`id` FROM `users` WHERE `id` = '" . $dress['owner'] . "' LIMIT 1;")); $d = mysql_fetch_array(mysql_query("SELECT sum(`massa`) FROM `inventory` WHERE `owner` = '{$_SESSION['uid']}' AND `dressed` = 0 AND `setsale` = 0 ; ")); if ($userfrom['id'] && $dress['id']) { @@ -102,6 +97,24 @@ if (($_GET['set'] OR $_POST['set'])) { } } +if ($get === 'sale') { + $data = db::c()->query('SELECT `inventory`.*, + `magic`.`name` AS `magic_name`, + `magic`.`chanse` AS `magic_chanse`, + `magic`.`time` AS `magic_time`, + `magic`.`file` AS `magic_file`, + `magic`.`targeted` AS `magic_targeted`, + `magic`.`needcharge` AS `magic_needcharge`, + `magic`.`img` AS `magic_img`, + 0 AS `maxdur` + +FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `setsale` = 0 AND `dressed` = 0 AND `present` = "?s" AND `owner` = ?i ORDER BY `update` DESC ', '', $_SESSION['uid']); + $iteminfo = []; + while ($row = $data->fetch_assoc()) { + $iteminfo[] = new ShopItem($row); + } +} + if ($get === 'unsale') { $data = db::c()->query('SELECT `inventory`.*, `magic`.`name` AS `magic_name`, @@ -232,46 +245,30 @@ switch ($shopCategoryTypeNumber) { } } elseif ($get === 'sale') { echo "Комиссия за услуги магазина составляет 10% от цены, по которой вы предлагаете предмет."; - $data = db::c()->query('SELECT * FROM `inventory` WHERE `setsale` = 0 AND `dressed` = 0 AND `present` = "?s" AND `owner` = ?i ORDER BY `update` DESC ', '', $_SESSION['uid']); - - while ($row = $data->fetch_assoc()) { - ?> - - -
- cдать в магазин - - - - - - "; - $ii->printImage(); - $ii->printControls('marketback'); + $ii->printImage(); ?> +
"; + "; + echo ""; + $ii->printInfo(); + echo ""; + } + + } elseif ($get === 'unsale') { + + foreach ($iteminfo as $ii) { + echo ""; + $ii->printImage(); + $ii->printControls('marketgetback'); echo ""; echo ""; $ii->printInfo(); echo ""; } -// while ($row = $data->fetch_assoc()) { -// ?> - - - - - - - - -query('SELECT DISTINCT `img`, `name`, `nalign`, `massa` FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `present` = "?s" AND `otdel` = "?s" GROUP BY `img` ORDER BY `cost` ASC', '', $_GET['otdel']); $replacements = ['+1','+2','+3','+4','+5',' (мф)'];