Внедрение шаблонизатора. Решение самых идиотских ошибок вёрстки. Кое-где исправлены ошибки синтаксиса php.

This commit is contained in:
Igor Barkov (iwork)
2020-09-30 22:12:34 +03:00
parent 8b1a2e9b38
commit a4de6c51a3
41 changed files with 4688 additions and 5715 deletions
+182 -152
View File
@@ -1,22 +1,29 @@
<?php
session_start();
if(empty($_SESSION['uid'])) { header('Location: index.php'); exit; }
if (empty($_SESSION['uid'])) {
header('Location: index.php');
exit;
}
require_once "functions.php";
$d = mysql_fetch_array(mysql_query("SELECT SUM(`massa`) AS `mass` FROM `inventory` WHERE `owner` = '{$user['id']}' AND `dressed` = 0 AND `setsale` = 0"));
$in = mysql_fetch_array(mysql_query('SELECT COUNT(*) AS `cnt` FROM `inventory` WHERE `owner` = "-101'.$user['id'].'"'));
$hostel = mysql_fetch_array(mysql_query('SELECT * FROM `hostel` WHERE `uid` = "'.$user['id'].'" LIMIT 1'));
$in = mysql_fetch_array(mysql_query('SELECT COUNT(*) AS `cnt` FROM `inventory` WHERE `owner` = "-101' . $user['id'] . '"'));
$hostel = mysql_fetch_array(mysql_query('SELECT * FROM `hostel` WHERE `uid` = "' . $user['id'] . '" LIMIT 1'));
$base = array(1 => 15, 2 => 30, 3 => 50, 4 => 100);
$vips = array(1 => 0.15, 2 => 0.30, 3 => 0.45);
$base = [1 => 15, 2 => 30, 3 => 50, 4 => 100];
$vips = [1 => 0.15, 2 => 0.30, 3 => 0.45];
function show_item($row, $txt, $place)
{
if (($row['maxdur'] <= $row['duration']) || ($row['dategoden'] && $row['dategoden'] <= time())) destructitem($row['id']);
if (($row['maxdur'] <= $row['duration']) || ($row['dategoden'] && $row['dategoden'] <= time())) {
destructitem($row['id']);
}
$r = '';
$ntxt = "В инвентаре";
if ($txt == "В сундук") $ntxt = "В сундуке";
if ($txt == "В сундук") {
$ntxt = "В сундуке";
}
$magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $$row['magic'])->fetch_assoc();
$incmagic = mysql_fetch_array(mysql_query('SELECT * FROM `magic` WHERE `id` = \'' . $row['includemagic'] . '\' LIMIT 1'));
@@ -28,8 +35,8 @@ function show_item($row, $txt, $place)
$magic['time'] = $incmagic['time'];
$magic['targeted'] = $incmagic['targeted'];
}
#href="?search=1&otdel='.$row['otdel'].'&place='.$place.'&itm='.$row['id'].'&set=1"
if (isset($row['id'])) {
//todo подтянуть отображение предмета из класса
$r .= '<div id="inv_' . $row['id'] . '"><table><tbody>';
$r .= '<tr valign="top" style="border: 2px groove threedface;">';
$r .= '<td class="even links original"><img src="/i/sh/' . $row['img'] . '">
@@ -56,7 +63,9 @@ function show_item($row, $txt, $place)
if (!$row['needident']) {
if ($magic['chanse']) {
if ($magic['chanse'] >= 95) $magic['chanse'] = 95;
if ($magic['chanse'] >= 95) {
$magic['chanse'] = 95;
}
$r .= 'Вероятность срабатывания: ' . $magic['chanse'] . '%<br />';
}
if ($magic['time']) {
@@ -67,7 +76,7 @@ function show_item($row, $txt, $place)
}
$r .= '<div class="need">';
$user = array();
$user = [];
if ($row['nsila']) {
$r .= '&bull; ';
@@ -238,7 +247,7 @@ function show_item($row, $txt, $place)
$r .= '<span style="color: maroon;"><b>Свойства предмета не идентифицированы</b></span><br />';
}
$osob = array(22, 23);
$osob = [22, 23];
if (in_array($row['type'], $osob)) {
$r .= 'Особенности:<br />';
if ($row['type'] == 22) {
@@ -277,164 +286,185 @@ function show_itm_hostel($uid, $otdel, $type = 1)
return $r;
}
if($user['vip'] > 0 && $user['vip_time'] > time()) {
$count = $base[$hostel['type']];
$count += floor($base[$hostel['type']]*$vips[$user['vip']]);
if ($user['vip'] > 0 && $user['vip_time'] > time()) {
$count = $base[$hostel['type']];
$count += floor($base[$hostel['type']] * $vips[$user['vip']]);
} else {
$count = $base[$hostel['type']];
$count = $base[$hostel['type']];
}
if($_GET['search']) {
$r = show_itm_hostel($user['id'], (int)$_GET['otdel'], (int)$_GET['place']);
if ($_GET['search']) {
$r = show_itm_hostel($user['id'], (int)$_GET['otdel'], (int)$_GET['place']);
} else {
$r = '<tr><td width="100%" align="center" class="even" style="text-align: center;"><b><center>Поиск ...</center></b></td></tr>';
$r = '<tr><td width="100%" align="center" class="even" style="text-align: center;"><b><center>Поиск ...</center></b></td></tr>';
}
if($_GET['set'] && $_GET['set'] == 1) {
$it = mysql_fetch_array(mysql_query('SELECT `id`, `owner` FROM `inventory` WHERE `id` = "'.(int)$_GET['itm'].'" LIMIT 1'));
if(isset($it['id'])) {
if($it['owner'] == $user['id']) {
if($in['cnt'] < $count) {
mysql_query('UPDATE `inventory` SET `owner` = "-101'.$user['id'].'" WHERE `id` = "'.$it['id'].'" LIMIT 1');
$in['cnt']++;
} else {
$error = 'Не хватает места ...';
}
} elseif($it['owner'] == '-101'.$user['id']) {
mysql_query('UPDATE `inventory` SET `owner` = "'.$user['id'].'" WHERE `id` = "'.$it['id'].'" LIMIT 1');
$in['cnt']--;
if ($_GET['set'] && $_GET['set'] == 1) {
$it = mysql_fetch_array(mysql_query('SELECT `id`, `owner` FROM `inventory` WHERE `id` = "' . (int)$_GET['itm'] . '" LIMIT 1'));
if (isset($it['id'])) {
if ($it['owner'] == $user['id']) {
if ($in['cnt'] < $count) {
mysql_query('UPDATE `inventory` SET `owner` = "-101' . $user['id'] . '" WHERE `id` = "' . $it['id'] . '" LIMIT 1');
$in['cnt']++;
} else {
$error = 'Не хватает места ...';
}
} elseif ($it['owner'] == '-101' . $user['id']) {
mysql_query('UPDATE `inventory` SET `owner` = "' . $user['id'] . '" WHERE `id` = "' . $it['id'] . '" LIMIT 1');
$in['cnt']--;
}
}
}
unset($it);
header('Location: hostel_room.php?search=1&otdel='.$_GET['otdel'].'&place='.$_GET['place']);
unset($it);
header('Location: hostel_room.php?search=1&otdel=' . $_GET['otdel'] . '&place=' . $_GET['place']);
}
if($_GET['search']) {
$r = show_itm_hostel($user['id'], (int)$_GET['otdel'], (int)$_GET['place']);
if ($_GET['search']) {
$r = show_itm_hostel($user['id'], (int)$_GET['otdel'], (int)$_GET['place']);
}
#######
$w = (270*$d['mass']/get_meshok()); $w_a = 270-$w;
$h = (270*$in['cnt']/$count); $h_a = 270-$h;
$w = (270 * $d['mass'] / get_meshok());
$w_a = 270 - $w;
$h = (270 * $in['cnt'] / $count);
$h_a = 270 - $h;
#######
if($_GET['go_back'] == 1) {
mysql_query('UPDATE `users`,`online` SET `users`.`room` = 660, `online`.`room` = 660 WHERE `users`.`id` = "'.$user['id'].'" AND `online`.`id` = "'.$user['id'].'"');
header('Location: hostel.php');
if ($_GET['go_back'] == 1) {
mysql_query('UPDATE `users`,`online` SET `users`.`room` = 660, `online`.`room` = 660 WHERE `users`.`id` = "' . $user['id'] . '" AND `online`.`id` = "' . $user['id'] . '"');
header('Location: hostel.php');
}
Template::header('hostel_room');
?>
<!doctype html>
<html>
<head>
<title>404</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="ru" />
<script src="js/ajaxLoad.js"></script>
<link rel="stylesheet" type="text/css" href="css/hostel.css" />
</head>
<body>
<div class="contentContainer" id="hostelContainer">
<div id="systemMsg" class="system-msg"></div><div class="buttonContainer">
<input type="button" class="btns" value="Обновить" onclick="location.href='hostel_room.php';" />
<input type="button" class="btns button-route" value="Спуститься" onclick="location.href='?go_back=1';" />
<h1>Комнатуха</h1>
</div>
<style type="text/css">
.hides {
display: none;
}
#hstInventory td.item {
width: 85%;
}
#hstInventory td.links {
text-align:center;
vertical-align:middle;
width:117px;
}
#hstInventory td.links span {
display: block;
}
#hstInventory td.original span.pk-current{
display:none;
}
#hstInventory td.moved {
font-weight: bold;
}
#hstInventory td.odd {
background-color: #c7c7c7;
}
#hstInventory td.even {
background-color: #d5d5d5;
}
<script src="js/ajaxLoad.js"></script>
<link rel="stylesheet" type="text/css" href="css/hostel.css"/>
<div class="contentContainer" id="hostelContainer">
<div id="systemMsg" class="system-msg"></div>
<div class="buttonContainer">
<input type="button" class="btns" value="Обновить" onclick="location.href='hostel_room.php';"/>
<input type="button" class="btns button-route" value="Спуститься" onclick="location.href='?go_back=1';"/>
<h1>Комнатуха</h1>
</div>
<style type="text/css">
.hides {
display: none;
}
label{
font-weight: bold;
margin-right:15px;
}
</style>
<script>
function hide_this(id) {
const node = document.getElementById(id);
if(node) {
node.style.display = 'none';
}
}
</script>
<div style="overflow: hidden;">
<fieldset id="hstInventoryA" style="width: 377px; float: left; text-align: center;">
<legend>Фильтр инвентаря</legend>
<div style="height: 53px">
<form method="GET">
<input type="radio" class="radio" id="hstF1" name="place" value="2" /><label for="hstF1">мешок</label>
<input type="radio" class="radio" id="hstF2" name="place" value="1" /><label for="hstF2">сундук</label>
#hstInventory td.item {
width: 85%;
}
<div style="height: 5px;overflow: hidden;"></div>
<select name="otdel">
<option value="-1">&nbsp;</option>
<optgroup label="Оружие">
<option value="1">кастеты,ножи</option>
<option value="11">топоры</option>
<option value="12">дубины,булавы</option>
<option value="13">мечи</option>
</optgroup>
<optgroup label="Одежда">
<option value="2">сапоги</option>
<option value="21">перчатки</option>
<option value="22">легкая броня</option>
<option value="23">тяжелая броня</option>
<option value="24">шлемы</option>
</optgroup>
<optgroup label="Щиты">
<option value="3">щиты</option>
</optgroup>
<optgroup label="Ювелирные товары">
<option value="4">серьги</option>
<option value="41">ожерелья</option>
<option value="42">кольца</option>
</optgroup>
<optgroup label="Заклинания">
<option value="5">нейтральные</option>
<option value="51">боевые и защитные</option>
</optgroup>
<optgroup label="Амуниция">
<option value="6">амуниция</option>
</optgroup>
</select>&nbsp;
<input type="submit" class="button" style="margin-right: 20px;" value="Поиск" name="search" />
</form>
</div>
</fieldset>
<fieldset id="hstInventoryB"><legend>Состояние</legend>
<div style="height: 53px">
<div class="progressBar" style='height:14px'><img title="Мешок за спиной" src="/i/bag.gif" height="14px"><img title="Мешок за спиной" src="/i/660000.gif" style="width: <?=$w;?>px; height: 14px;"><img title="Мешок за спиной" src="/i/1silver.gif" style=" width: <?=$w_a;?>px; height:14px"><tt style="font-size:13px"> <?=$d['mass'];?>/<?=get_meshok()?></tt></div><div class="progressBar" style='height:14px'><img title="Заполнение сундука" src="/i/chest.gif" height="14px"><img title="Заполнение сундука" src="/i/1blue.gif" style=" width: <?=$h;?>px; height:14px"><img title="Заполнение сундука" src="/i/1silver.gif" style=" width: <?=$h_a;?>px; height:14px"><tt style="font-size:13px"> <?=$in['cnt'];?>/<?=$count;?></tt></div></div>
</fieldset>
</div>
#hstInventory td.links {
text-align: center;
vertical-align: middle;
width: 117px;
}
<div id="hstInventory" style="width: 100%; background-color: #a5a5a5;">
<?=$r;?>
</div>
<center><? if($error != '') { echo '<br /><b style=\'color: Red;\'>'.$error.'</b>'; } ?></center>
</body>
</html>
#hstInventory td.links span {
display: block;
}
#hstInventory td.original span.pk-current {
display: none;
}
#hstInventory td.moved {
font-weight: bold;
}
#hstInventory td.odd {
background-color: #c7c7c7;
}
#hstInventory td.even {
background-color: #d5d5d5;
}
label {
font-weight: bold;
margin-right: 15px;
}
</style>
<script>
function hide_this(id) {
const node = document.getElementById(id);
if (node) {
node.style.display = 'none';
}
}
</script>
<div style="overflow: hidden;">
<fieldset id="hstInventoryA" style="width: 377px; float: left; text-align: center;">
<legend>Фильтр инвентаря</legend>
<div style="height: 53px">
<form method="GET">
<input type="radio" class="radio" id="hstF1" name="place" value="2"/><label
for="hstF1">мешок</label>
<input type="radio" class="radio" id="hstF2" name="place" value="1"/><label
for="hstF2">сундук</label>
<div style="height: 5px;overflow: hidden;"></div>
<select name="otdel">
<option value="-1">&nbsp;</option>
<optgroup label="Оружие">
<option value="1">кастеты,ножи</option>
<option value="11">топоры</option>
<option value="12">дубины,булавы</option>
<option value="13">мечи</option>
</optgroup>
<optgroup label="Одежда">
<option value="2">сапоги</option>
<option value="21">перчатки</option>
<option value="22">легкая броня</option>
<option value="23">тяжелая броня</option>
<option value="24">шлемы</option>
</optgroup>
<optgroup label="Щиты">
<option value="3">щиты</option>
</optgroup>
<optgroup label="Ювелирные товары">
<option value="4">серьги</option>
<option value="41">ожерелья</option>
<option value="42">кольца</option>
</optgroup>
<optgroup label="Заклинания">
<option value="5">нейтральные</option>
<option value="51">боевые и защитные</option>
</optgroup>
<optgroup label="Амуниция">
<option value="6">амуниция</option>
</optgroup>
</select>&nbsp;
<input type="submit" class="button" style="margin-right: 20px;" value="Поиск" name="search"/>
</form>
</div>
</fieldset>
<fieldset id="hstInventoryB">
<legend>Состояние</legend>
<div style="height: 53px">
<div class="progressBar" style='height:14px'><img title="Мешок за спиной" src="/i/bag.gif"
height="14px"><img title="Мешок за спиной"
src="/i/660000.gif"
style="width: <?= $w; ?>px; height: 14px;"><img
title="Мешок за спиной" src="/i/1silver.gif"
style=" width: <?= $w_a; ?>px; height:14px"><tt
style="font-size:13px"> <?= $d['mass']; ?>/<?= get_meshok() ?></tt></div>
<div class="progressBar" style='height:14px'><img title="Заполнение сундука" src="/i/chest.gif"
height="14px"><img title="Заполнение сундука"
src="/i/1blue.gif"
style=" width: <?= $h; ?>px; height:14px"><img
title="Заполнение сундука" src="/i/1silver.gif"
style=" width: <?= $h_a; ?>px; height:14px"><tt
style="font-size:13px"> <?= $in['cnt']; ?>/<?= $count; ?></tt></div>
</div>
</fieldset>
</div>
<div id="hstInventory" style="width: 100%; background-color: #a5a5a5;">
<?= $r; ?>
</div>
<?php
if (!empty($error)) {
echo sprintf('<div style="text-align: center; font-weight: bold; color: #f80000;">%s</div>', $error);
}