added headers and status

This commit is contained in:
Igor Barkov [iwork] 2019-02-15 19:23:43 +02:00
parent ab5cd2b9cc
commit 9c299cabed
2 changed files with 49 additions and 53 deletions

View File

@ -21,6 +21,7 @@ $get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
$itemCost = (int)filter_input(INPUT_POST, 'cost', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); $itemCost = (int)filter_input(INPUT_POST, 'cost', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
$itemId = (int)filter_input(INPUT_POST, 'putId', FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]); $itemId = (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]]); $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 ($itemCost && $itemId) { if ($itemCost && $itemId) {
$commission = ceil($itemCost / 10); # 10% от суммы с округлением вверх. $commission = ceil($itemCost / 10); # 10% от суммы с округлением вверх.
@ -46,14 +47,7 @@ if ($returningItemId) {
} else $status = "Предмет не найден на полках магазина!"; } else $status = "Предмет не найден на полках магазина!";
} }
if ($byingItemId) {
if (isset($_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")); $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;")); $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 ; ")); $d = mysql_fetch_array(mysql_query("SELECT sum(`massa`) FROM `inventory` WHERE `owner` = '{$_SESSION['uid']}' AND `dressed` = 0 AND `setsale` = 0 ; "));
@ -93,9 +87,6 @@ if (isset($_GET['set'])) {
} else { } else {
echo "<font color=red><b>Вещь не найдена в магазине</b></font>"; echo "<font color=red><b>Вещь не найдена в магазине</b></font>";
} }
} else {
echo "<font color=red><b>Не надо так делать</b></font>";
}
} }
if ($get === 'sale') { if ($get === 'sale') {
@ -213,8 +204,12 @@ switch ($shopCategoryTypeNumber) {
<link rel=stylesheet href="css/main.css"> <link rel=stylesheet href="css/main.css">
<script src="js/main.js"></script> <script src="js/main.js"></script>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Рынок</title>
</HEAD> </HEAD>
<body> <body>
<h1>Рынок</h1>
<a href=# onclick=hrefToFrame('city.php?cp')> ← выйти на Центральную площадь</a>
<div><?php if (!empty($status)) err($status); ?></div>
<div style="float: right;"> <div style="float: right;">
<button onclick="hrefToFrame('?sale')">Сдать вещи в магазин</button> <button onclick="hrefToFrame('?sale')">Сдать вещи в магазин</button>
<button onclick="hrefToFrame('?unsale')">Забрать вещи из магазина</button> <button onclick="hrefToFrame('?unsale')">Забрать вещи из магазина</button>
@ -230,8 +225,7 @@ switch ($shopCategoryTypeNumber) {
<?php <?php
if ($get === 'sale') { if ($get === 'sale') {
echo "Выставить товар на продажу.<br>Комиссия за услуги магазина составляет 10% от цены, по которой вы предлагаете предмет."; echo "Выставить товар на продажу.<br>Комиссия за услуги магазина составляет 10% от цены, по которой вы предлагаете предмет.";
} } elseif ($get === 'unsale') echo "Забрать свой товар";
elseif ($get === 'unsale') echo "Забрать свой товар";
else echo "Отдел «" . $shopCategoryType . "»"; ?> else echo "Отдел «" . $shopCategoryType . "»"; ?>
</TH> </TH>
</TR> </TR>
@ -277,7 +271,7 @@ switch ($shopCategoryTypeNumber) {
} else { } else {
$data = db::c()->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']); $data = db::c()->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',' (мф)']; $replacements = ['+1', '+2', '+3', '+4', '+5', ' (мф)'];
while ($row = $data->fetch_assoc()) { while ($row = $data->fetch_assoc()) {
$item_name = str_replace($replacements, '', $row['name']); $item_name = str_replace($replacements, '', $row['name']);
$item = db::c()->query('SELECT COUNT(`id`), MIN(`duration`), MIN(`maxdur`), MAX(`duration`), MAX(`maxdur`), MIN(`setsale`), MAX(`setsale`) FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `present` = "?s" AND `name` LIKE "?S%"', '', $item_name)->fetch_row(); $item = db::c()->query('SELECT COUNT(`id`), MIN(`duration`), MIN(`maxdur`), MAX(`duration`), MAX(`maxdur`), MIN(`setsale`), MAX(`setsale`) FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `present` = "?s" AND `name` LIKE "?S%"', '', $item_name)->fetch_row();
@ -292,7 +286,8 @@ switch ($shopCategoryTypeNumber) {
(Масса: <?= $row['massa'] ?>) <BR> (Масса: <?= $row['massa'] ?>) <BR>
<b>Цена: <?= round($item[5], 2) ?> - <?= round($item[6], 2) ?> кр.</b> <b>Цена: <?= round($item[5], 2) ?> - <?= round($item[6], 2) ?> кр.</b>
<small>(количество: <?= $item[0] ?>)</small> <small>(количество: <?= $item[0] ?>)</small>
<BR>Долговечность: <?= $item[1] ?>-<?= $item[2] ?>/<?= $item[3] ?> -<?= $item[4] ?><BR> <BR>Долговечность: <?= $item[1] ?>-<?= $item[2] ?>/<?= $item[3] ?>
-<?= $item[4] ?><BR>
</TD> </TD>
</TR> </TR>
<? <?

View File

@ -36,8 +36,9 @@ if (empty($user['id'])): ?>
<td style="width: 250px; vertical-align: top;"> <td style="width: 250px; vertical-align: top;">
<?= showinf_pers($user['id']); <?= showinf_pers($user['id']);
if (!empty($user['married'])): ?> if (!empty($user['married'])): ?>
<a href="inf.php?<?= $user['married'] ?>" target=_blank><img src="i/married.gif" <a href="inf.php?<?= $user['married'] ?>" target=_blank>
title="В браке с <?= $user['married'] ?>"></a>"; <img src="i/married.gif" title="В браке с <?= $user['married'] ?>">
</a>
<?php endif; ?> <?php endif; ?>
</td> </td>
<td style="vertical-align: top; width: 100px; text-align: center;"> <td style="vertical-align: top; width: 100px; text-align: center;">