battles/inf.php

141 lines
5.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
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();
if ($own['admin'] === 1) {
return ADMINISTRATOR_ACCESS;
} elseif ($own['align'] === 1) {
return MODERATOR_ACCESS;
}
return false;
}
$presentsModel = new PresentsModel();
$presentsList = $presentsModel->getAllPresents($user->id);
if (empty($user->id)): ?>
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>Ошибка</title>
</head>
<body style="color: #666; background-color: #d5d5d5; text-align: center; font-family: Consolas,monospace;">
Ошибка: персонаж <em><?=$login?></em> не найден...
<p><a style="color: #99f" href="javascript:window.history.go(-1);">←назад</a></p>
</body>
</html>
<?php exit(); endif; ?>
<html lang="ru">
<head>
<title>Информация о <?= $user->login ?></title>
<meta charset=UTF-8"/>
<link href="css/main.css" rel="stylesheet">
</head>
<body>
<?php if ($user->admin === 1 && private_access($uid) !== ADMINISTRATOR_ACCESS && file_exists('customuserdata/' . $user['id'])) {
die(file_get_contents('customuserdata/' . $user['id']));
} ?>
<table width=100%>
<tr>
<td style="width: 250px; vertical-align: top;">
<?php
try {echo showinf_pers($user->id);} catch (Exception $e) {echo "<div class='private'>Ошибка генератора персонажа showinf_pers(): {$e}</div>";}
try {$user->showUserInfo();} catch (Exception $e) {echo "<div class='private'>Ошибка классового генератора персонажа showUserInfo(): {$e}</div>";}
if (!empty($user->married)): ?>
<a href="inf.php?<?= $user->married ?>" target=_blank>
<img alt="В браке с <?= $user->married ?>" src="i/married.gif"
title="В браке с <?= $user->married ?>">
</a>
<?php endif; ?>
</td>
<td style="vertical-align: top; width: 100px; text-align: center;">
<img src="i/zodiac/<?= star_sign($user->borndate); ?>.png" alt="Родовой знак">
</td>
</tr>
</table>
<hr>
<!-- Нижняя часть -->
<?php
try {
$effect = db::c()->query('SELECT `time` FROM `effects` WHERE `owner` = ?i AND `type` = ?i ', $user->id, 5)->fetch_assoc();
if ($effect['time'] && !private_access($uid)) {
die('<h3>Персонаж обезличен!</h3>');
}
} catch (Exception $e) {echo "<div class='private'>Ошибка обезличивателя: {$e}</div>";}
if (!empty($user->realname)) {
echo "Имя: " . $user->realname . "<br>";
}
?>
<p style="font-family: Consolas,monospace;"><?= nl2br($user->info) ?></p>
<hr>
<?php include_once 'views/presents-list.php'; ?>
<?php
# Секретный раздел
# Если я любой паладин, и смотрю не админа, или я сам админ.
if ((private_access($uid) === MODERATOR_ACCESS && !$user->admin) || private_access($uid) === ADMINISTRATOR_ACCESS) {
$ld = db::c()->query('SELECT * FROM users_logs WHERE user_id = ?i ORDER BY `id` ASC', $user->id);
echo "<H4>Личное дело</H4>";
while ($row_ld = $ld->fetch_assoc()) {
$text = date("d.m.Y H:i ", $row_ld['date']) . $row_ld['text'];
echo "<code>$text</code><br />";
}
echo "<H4>Дополнительные сведения</H4>";
if (!empty($user->id)) {
echo "ID: " . $user->id . "<br>";
}
if (!empty($user->email)) {
echo "E-mail: " . $user->email . "<br>";
}
if (!empty($user->borndate)) {
echo "День рождения: " . $user->borndate . "<br>";
}
if (!empty($user->ip)) {
echo "IP при регистрации: " . $user->ip . "<br>";
}
}
if (private_access($uid) === ADMINISTRATOR_ACCESS) {
if (!empty($user->exp)) {
echo "Oпыт: " . $user->exp . "<br>";
}
if (!empty($user->stats)) {
echo "Число неиспользованных UP-ов: " . $user->stats . "<br>";
}
if (!empty($user->money)) {
echo "Кредитов: " . $user->money . "<br>";
}
if (!empty($user->room)) {
echo "Комната: " . $user->room . "<br>";
}
echo "<H4>Банковские счета</H4>";
$bankInfo = new Bank($user->id);
echo "Счет: " . $bankInfo->user_id . PHP_EOL;
echo "Деньги на счету: " . $bankInfo->money . PHP_EOL;
}
?>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/showthing.js"></script>
<script>
$(function () {
$(".tooltip").tipTip({maxWidth: "auto", edgeOffset: 0, fadeIn: 300, fadeOut: 500});
});
</script>
</body>
</html>