Перенос всей отображаемой публичной информации персонажа в класс. Чистка кода. Комментарии для упрощения навигации.
This commit is contained in:
parent
3c2816c400
commit
e01bba54f8
@ -79,56 +79,56 @@ EMPTY_SLOT;
|
||||
} else {
|
||||
$this->showItem(1);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div><!-- slot-1 -->';
|
||||
echo '<div class="slot-2">';
|
||||
if (isset($dressed_item[2])) {
|
||||
$this->showItem($dressed_item[2]);
|
||||
} else {
|
||||
$this->showItem(2);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div><!-- slot-2 -->';
|
||||
echo '<div class="slot-3">';
|
||||
if (isset($dressed_item[3])) {
|
||||
$this->showItem($dressed_item[3]);
|
||||
} else {
|
||||
$this->showItem(3);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div><!-- slot-3 -->';
|
||||
echo '<div class="slot-4">';
|
||||
if (isset($dressed_item[4])) {
|
||||
$this->showItem($dressed_item[4]);
|
||||
} else {
|
||||
$this->showItem(4);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div><!-- slot-4 -->';
|
||||
echo '<div class="slot-5">';
|
||||
if (isset($dressed_item[5])) {
|
||||
$this->showItem($dressed_item[5]);
|
||||
} else {
|
||||
$this->showItem(5);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div><!-- slot-5 -->';
|
||||
echo '<div class="slot-6">';
|
||||
if (isset($dressed_item[6])) {
|
||||
$this->showItem($dressed_item[6]);
|
||||
} else {
|
||||
$this->showItem(6);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div><!-- slot-6 -->';
|
||||
echo '<div class="slot-7">';
|
||||
if (isset($dressed_item[7])) {
|
||||
$this->showItem($dressed_item[7]);
|
||||
} else {
|
||||
$this->showItem(7);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div><!-- slot-7 -->';
|
||||
echo '<div class="slot-8">';
|
||||
if (isset($dressed_item[8])) {
|
||||
$this->showItem($dressed_item[8]);
|
||||
} else {
|
||||
$this->showItem(8);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div><!-- slot-8 -->';
|
||||
echo '<div class="slot-lower">';
|
||||
if (isset($dressed_item[9])) {
|
||||
$this->showItem($dressed_item[9]);
|
||||
@ -145,27 +145,37 @@ EMPTY_SLOT;
|
||||
} else {
|
||||
$this->showItem(11);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div><!-- slot-lower -->';
|
||||
echo '<div class="slot-image">';
|
||||
echo sprintf('<img src="/i/shadow/%s" width="200" height="430" alt="%s">', $this->shadow, $this->login);
|
||||
echo '</div>';
|
||||
echo '</div><!-- slot-image -->';
|
||||
echo '<div class="user-signs">';
|
||||
echo sprintf('<img src="i/zodiac/%s.png" alt="Родовой знак">', star_sign($this->borndate));
|
||||
echo '</div>';
|
||||
echo '</div><!-- user-signs -->';
|
||||
echo '<div class="user-info">';
|
||||
echo '<div class="stats-container">';
|
||||
echo '<div class="column">';
|
||||
echo 'Уровень<br>Сила<br>Ловкость<br>Интуиция<br>Выносливость<br>Интеллект<br>Мудрость<br>Находится в:';
|
||||
echo '</div>';
|
||||
echo '</div><!-- column -->';
|
||||
echo '<div class="column">';
|
||||
echo $this->level . '<br>' . $this->strength . '<br>' . $this->dexterity . '<br>' . $this->intuition . '<br>' . $this->endurance . '<br>' . $this->intelligence . '<br>' . $this->wisdom . '<br>' . $this->getRoomName($this->room);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div><!-- column -->';
|
||||
echo '</div><!-- stats-container -->';
|
||||
if ($this->married) {
|
||||
echo sprintf('<a href = "inf.php?%s" target = _blank ><img alt = "В браке с %s" src = "i/married.gif" title = "В браке с %s"></a >', $this->married, $this->married, $this->married);
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div><!-- user-info -->';
|
||||
echo '</div><!-- user-info-container -->';
|
||||
echo '<hr><!-- Нижняя часть -->';
|
||||
echo '<div class="user-info-container-lower">';
|
||||
echo '<h2>Об игроке</h2>';
|
||||
if ($this->realname) {
|
||||
echo sprintf('Имя: %s<br>', $this->realname);
|
||||
}
|
||||
if ($this->info) {
|
||||
echo nl2br($this->info);
|
||||
}
|
||||
echo '</div><!-- user-info-container-lower -->';
|
||||
}
|
||||
|
||||
}
|
@ -397,3 +397,10 @@ div.user-info-container > div.user-signs {
|
||||
grid-column: 5;
|
||||
grid-row: 1 / 6;
|
||||
}
|
||||
/*-----------------------------*/
|
||||
div.debug {
|
||||
background:#fef;
|
||||
border:1px dashed #faf;
|
||||
border-radius:5px;
|
||||
padding:5px;
|
||||
}
|
33
inf.php
33
inf.php
@ -2,15 +2,13 @@
|
||||
session_start();
|
||||
include_once 'functions.php';
|
||||
include_once 'models/PresentsModel.php';
|
||||
//$login = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
|
||||
|
||||
$login = urldecode($_SERVER['QUERY_STRING']) ?? '';
|
||||
$uid = $_SESSION['uid'] ?? null;
|
||||
//$user = db::c()->query('SELECT `id`,`login`,`married`,`win`,borndate,`align`,`admin`,`realname`,`info`,`prof1`,`prof2`,`email`,`ip`,`exp`,`stats`,`money`,`room`,`doblest`
|
||||
// FROM `users`
|
||||
// WHERE `login` = "?s" OR `id` = "?s"', $login, $login)->fetch_assoc();
|
||||
$user = new User($login);
|
||||
const MODERATOR_ACCESS = 1;
|
||||
const ADMINISTRATOR_ACCESS = 2;
|
||||
|
||||
function private_access($uid)
|
||||
{
|
||||
$own = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = "?s"', $uid)->fetch_assoc();
|
||||
@ -50,30 +48,21 @@ if (empty($user->id)): ?>
|
||||
die(file_get_contents('customuserdata/' . $user['id']));
|
||||
}
|
||||
try {
|
||||
$user->showUserInfo();
|
||||
} catch (Exception $e) {
|
||||
echo "<div class='private'>Ошибка генератора showUserInfo() в User.php: {$e}</div>";
|
||||
} ?>
|
||||
|
||||
<hr>
|
||||
<!-- Нижняя часть -->
|
||||
<?php
|
||||
try {
|
||||
$effect = db::c()->query('SELECT `time` FROM `effects` WHERE `owner` = ?i AND `type` = ?i ', $user->id, 5)->fetch_assoc();
|
||||
$effect = db::c()->query('SELECT `time` FROM `effects` WHERE `owner` = ?i AND `type` = ?i ', $this->id, 5)->fetch_assoc();
|
||||
if ($effect['time'] && !private_access($uid)) {
|
||||
die('<h3>Персонаж обезличен!</h3>');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo "<div class='private'>Ошибка обезличивателя: {$e}</div>";
|
||||
echo "<div class='debug'>Ошибка обезличивателя: {$e}</div>";
|
||||
}
|
||||
if (!empty($user->realname)) {
|
||||
echo "Имя: " . $user->realname . "<br>";
|
||||
try {
|
||||
$user->showUserInfo();
|
||||
} catch (Exception $e) {
|
||||
echo "<div class='debug'>Ошибка генератора showUserInfo() в User.php: {$e}</div>";
|
||||
}
|
||||
?>
|
||||
<p style="font-family: Consolas,monospace;"><?= nl2br($user->info) ?></p>
|
||||
<hr>
|
||||
<?php include_once 'views/presents-list.php'; ?>
|
||||
<?php
|
||||
|
||||
include_once 'views/presents-list.php';
|
||||
|
||||
# Секретный раздел
|
||||
# Если я любой паладин, и смотрю не админа, или я сам админ.
|
||||
if ((private_access($uid) === MODERATOR_ACCESS && !$user->admin) || private_access($uid) === ADMINISTRATOR_ACCESS) {
|
||||
|
Loading…
Reference in New Issue
Block a user