level < 1) { header("Location: main.php"); exit; } if ($user->room != 25) { header("Location: main.php"); exit; } if ($user->battle) { header('location: fbattle.php'); exit; } $get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING')); $putItemCost = (int)filter_input(INPUT_POST, 'cost', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); $putItemId = (int)filter_input(INPUT_POST, 'putId', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); $returningItemId = (int)filter_input(INPUT_GET, 'back', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); $byingItemId = (int)filter_input(INPUT_GET, 'set', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); if ($putItemId) { $dress = db::c()->query('SELECT `name`,`duration`,`maxdur`,`cost` FROM `inventory` WHERE `dressed` = 0 AND `id` = ?i AND `owner` = ?i', $putItemId, $_SESSION['uid'])->fetch_assoc(); if (empty($putItemCost)) $putItemCost = $dress['cost']; $commission = ceil($putItemCost / 10); # 10% от суммы с округлением вверх. if ($user['money'] > $commission) { if (db::c()->getAffectedRows()) { $deloText = "{$user['login']} выставил товар: «{$dress['name']}» id:({$putItemId}) [{$dress['duration']}/{$dress['maxdur']}] на продажу в комиссионку за {$putItemCost} кр. "; addToDelo($deloText); db::c()->query('UPDATE `inventory` SET `setsale` = ?i WHERE `id` = ?i', $putItemCost, $putItemId); db::c()->query('UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i', $commission, $_SESSION['uid']); $status = "Вы сдали в магазин «{$dress['name']}» за {$putItemCost} кр. Вычтено за услуги магазина: {$commission} кр."; } else $status = "Предмет не найден в инвентаре!"; } else $status = "У вас не хватает " . $commission - $user['money'] . " кр. чтобы оплатить комиссию!"; } if ($returningItemId) { $dress = db::c()->query('SELECT `name`,`duration`,`maxdur` FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `id` = ?i AND `owner` = ?i', $returningItemId, $_SESSION['uid'])->fetch_assoc(); if (db::c()->getAffectedRows()) { $deloText = "{$user['login']} забрал свой товар: «{$dress['name']}» id:({$returningItemId}) [{$dress['duration']}/{$dress['maxdur']}] из комиссионки."; addToDelo($deloText); db::c()->query('UPDATE `inventory` SET `setsale` = 0 WHERE `id` = ?i', $returningItemId); $status = "Вы забрали из магазина ваш «{$dress['name']}»."; } else $status = "Предмет не найден на полках магазина!"; } if ($byingItemId) { $dress = db::c()->query('SELECT `name`,`owner`,`duration`,`maxdur`,`setsale` FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `id` = ?i', $byingItemId)->fetch_assoc(); $seller = db::c()->query('SELECT `login` FROM `users` WHERE `id` =?i', $dress['owner'])->fetch_assoc(); if ($dress['setsale']) { if ($user['money'] >= $dress['setsale']) { db::c()->query('UPDATE `inventory` SET `setsale` = 0, `owner` = ?i WHERE `id` = ?i', $_SESSION['uid'], $byingItemId); db::c()->query('UPDATE `users` set `money` = `money` - ?i WHERE `id` = ?i', $dress['setsale'], $_SESSION['uid']); db::c()->query('UPDATE `users` set `money` = `money` + ?i WHERE `id` = ?i', $dress['setsale'], $dress['owner']); $status = "Вы купили «{$dress['name']}» за {$dress['setsale']} кр."; $deloText = "{$user['login']} купил на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] у {$seller['login']} за {$dress['setsale']} кр."; addToDelo($deloText); $deloText = "{$seller['login']} продал на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] персонажу {$user['login']} за {$dress['setsale']} кр."; addToDelo($deloText, $dress['owner']); $user['money'] = $user['money'] - $dress['setsale']; telegraph($dress['owner'],"Предмет «{$dress['name']}» продан на рынке за {$dress['setsale']} кр."); } else $status = "Недостаточно средств!"; } else $status = "Предмет не найден на полках магазина!"; } $classPrintControlName = "marketbuy"; 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']); $classPrintControlName = "marketput"; } elseif ($get === 'unsale') { $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 `owner` = ?i ORDER BY `update` DESC', $_SESSION['uid']); $classPrintControlName = "marketgetback"; } else if (!empty($_POST['search'])) { $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 `dressed` = 0 AND `inventory`.`name` LIKE "%?S%" AND `setsale` > 0 ORDER BY `setsale` ASC', $_POST['search']); } else { $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 `dressed` = 0 AND `setsale` > 0 ORDER BY `setsale` ASC'); } $iteminfo = []; while ($row = $data->fetch_assoc()) { $iteminfo[] = new ShopItem($row); } ?>
|
Масса всех ваших вещей: = getItemsMassaInfo() ?>
У вас в наличии: = $user['money'] ?> кр. |