Разбивка inf.php по классам.
This commit is contained in:
parent
3317ab845d
commit
461cec852d
@ -28,9 +28,10 @@ class User
|
||||
|
||||
// Пока несуществующие, для совместимости.
|
||||
public $married;
|
||||
public $exp;
|
||||
public $stats;
|
||||
public $shadow;
|
||||
public $experience;
|
||||
public $stat_points;
|
||||
|
||||
//Статусы того, кто смотрит на информацию.
|
||||
protected $watcherIsAdmin;
|
||||
@ -187,10 +188,16 @@ EMPTY_SLOT;
|
||||
|
||||
if ($this->watcherIsAdmin || $this->watcherIsModerator) {
|
||||
echo '<div class="secretInfo">';
|
||||
echo sprintf('<b>Личное дело</b><br>ИД Игрока: %s<br> ДР Игрока: %s<br> IP Регистрации: %s', $this->id, date('d.m.Y', strtotime($this->borndate)), $this->ip);
|
||||
$infoString = '<b>Личное дело</b><br>ИД Игрока: %s<br> ДР Игрока: %s<br> IP Регистрации: %s';
|
||||
echo sprintf($infoString, $this->id, date('d.m.Y', strtotime($this->borndate)), $this->ip);
|
||||
if ($this->watcherIsAdmin) {
|
||||
$this->Bank = new Bank($this->id);
|
||||
echo sprintf('<span>ИД Комнаты: %s<br> Деньги в банке: %s<br> E-Mail: %s<br> Текущая сессия: %s</span>>', $this->room, $this->Bank->money, $this->email, $this->session_id);
|
||||
$infoString = '<br><span>ИД Комнаты: %s<br> Деньги: %s<br> Деньги в банке: %s<br> Опыт: %s<br> Нераспределённые очки: %s<br> E-Mail: %s<br> Текущая сессия: %s</span>';
|
||||
echo sprintf($infoString, $this->room, $this->money, $this->Bank->money, $this->experience, $this->stat_points, $this->email, $this->session_id);
|
||||
}
|
||||
$this->UserLogs = new UserLogModel($this->id);
|
||||
while ($userLogRow = $this->UserLogs->getUserLog()->fetch_object()) {
|
||||
echo sprintf('<code>%s</code><br>', date("d.m.Y H:i ", strtotime($userLogRow->date)) . $userLogRow->text);
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
@ -27,7 +27,12 @@ require_once('Database/db.php');
|
||||
* Автозагрузка классов.
|
||||
*/
|
||||
spl_autoload_register(function ($class_name) {
|
||||
include_once 'classes/' . $class_name . '.php';
|
||||
if (file_exists(sprintf('classes/%s.php', $class_name))) {
|
||||
require_once sprintf('classes/%s.php', $class_name);
|
||||
} elseif (file_exists(sprintf('models/%s.php', $class_name))) {
|
||||
require_once sprintf('models/%s.php', $class_name);
|
||||
}
|
||||
throw new Exception("Невозможно загрузить $class_name.");
|
||||
});
|
||||
|
||||
/* === Для нападалок. Сперва комнаты в которых нельзя напасть, потом персонаж на которого нельзя напасть. === */
|
||||
|
@ -417,5 +417,5 @@ div.secretInfo {
|
||||
padding:5px;
|
||||
}
|
||||
div.secretInfo > span {
|
||||
color: #f80000;
|
||||
color: #966;
|
||||
}
|
77
inf.php
77
inf.php
@ -1,27 +1,13 @@
|
||||
<?php
|
||||
session_start();
|
||||
include_once 'config.php';
|
||||
include_once 'models/PresentsModel.php';
|
||||
//include_once 'models/PresentsModel.php';
|
||||
|
||||
$login = urldecode($_SERVER['QUERY_STRING']) ?? '';
|
||||
$uid = $_SESSION['uid'] ?? null;
|
||||
$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` = ?i', $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);
|
||||
$presentsModel = new PresentsModel($user->id);
|
||||
$presentsList = $presentsModel->getAllPresents();
|
||||
|
||||
if (empty($user->id)): ?>
|
||||
<!doctype html>
|
||||
@ -45,14 +31,12 @@ if (empty($user->id)): ?>
|
||||
</head>
|
||||
<body>
|
||||
<?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_hide_info) {
|
||||
echo "<div class='debug'>Ошибка обезличивателя: {$e_hide_info}</div>";
|
||||
|
||||
$hideInfo = new EffectsModel($user->id);
|
||||
if ($hideInfo->getHideUserInfoStatus()) {
|
||||
exit('<h3>Персонаж обезличен!</h3>');
|
||||
}
|
||||
|
||||
try {
|
||||
$user->showUserInfo();
|
||||
} catch (Exception $e_showUserInfo) {
|
||||
@ -61,52 +45,7 @@ try {
|
||||
|
||||
include_once 'views/presents-list.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>
|
||||
|
30
models/EffectsModel.php
Normal file
30
models/EffectsModel.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lopiu
|
||||
* Date: 05.07.2020
|
||||
* Time: 23:32
|
||||
*/
|
||||
|
||||
class EffectsModel
|
||||
{
|
||||
protected $DB;
|
||||
const EFFECT_HIDEUSERINFO = 5;
|
||||
public function __construct(int $user_id) {
|
||||
$this->DB = db::c()->query('SELECT * FROM effects WHERE owner_id = ?i', $user_id);
|
||||
throw new Exception('<div class="debug">Не могу подключиться к таблице effects!</div>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка обезличен ли персонаж.
|
||||
* @return int date() до конца эффекта или 0.
|
||||
*/
|
||||
public function getHideUserInfoStatus()
|
||||
{
|
||||
while ($row = $this->DB->fetch_object()) {
|
||||
if ($row->type == self::EFFECT_HIDEUSERINFO) {
|
||||
return $row->time;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -7,7 +7,20 @@
|
||||
|
||||
class PresentsModel
|
||||
{
|
||||
public function getAllPresents($user_id) {
|
||||
return db::c()->query('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?i', $user_id);
|
||||
protected $DB;
|
||||
|
||||
public function __construct(int $user_id)
|
||||
{
|
||||
$this->DB = db::c()->query('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?i', $user_id);
|
||||
}
|
||||
|
||||
public function getAllPresents()
|
||||
{
|
||||
return $this->DB;
|
||||
}
|
||||
|
||||
public function getPresentsSum()
|
||||
{
|
||||
return $this->DB->getNumRows();
|
||||
}
|
||||
}
|
22
models/UserLogModel.php
Normal file
22
models/UserLogModel.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lopiu
|
||||
* Date: 05.07.2020
|
||||
* Time: 22:38
|
||||
*/
|
||||
|
||||
class UserLogModel
|
||||
{
|
||||
protected $DB;
|
||||
|
||||
public function __construct(int $user_id)
|
||||
{
|
||||
$this->DB = db::c()->query('SELECT * FROM users_logs WHERE user_id = ?i ORDER BY `id` ASC', $user_id);
|
||||
|
||||
}
|
||||
|
||||
public function getUserLog()
|
||||
{
|
||||
return $this->DB;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user