Выдача информации с учётом статусов.

This commit is contained in:
lopar 2020-07-06 08:56:25 +03:00
parent 2a0f454343
commit b9ed3a039e
2 changed files with 53 additions and 50 deletions

View File

@ -1,6 +1,5 @@
<?php
class User
{
public $id;
@ -34,6 +33,7 @@ class User
public $stat_points;
//Статусы того, кто смотрит на информацию.
public $watcher_id;
protected $watcherIsAdmin;
protected $watcherIsModerator;
@ -42,18 +42,11 @@ class User
public function __construct($user)
{
$user_query = db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc();
$watchingUser_query = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
foreach ($this as $key => $value) {
if (isset($user_query[$key])) {
$this->$key = $user_query[$key];
}
}
if ($watchingUser_query['admin']) {
$this->watcherIsAdmin = 1;
}
if ($watchingUser_query['align'] == 1) {
$this->watcherIsModerator = 1;
}
}
protected function showItem($item = 0)
@ -73,7 +66,7 @@ EMPTY_SLOT;
}
}
public function showUserInfo()
public function UserInfo()
{
$dressed_items = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->id);
while ($row = $dressed_items->fetch_assoc()) {
@ -188,12 +181,12 @@ EMPTY_SLOT;
if ($this->watcherIsAdmin || $this->watcherIsModerator) {
echo '<div class="secret-info">';
$infoString = '<b>Личное дело</b><br>ИД Игрока: %s<br> ДР Игрока: %s<br> IP Регистрации: %s';
echo sprintf($infoString, $this->id, date('d.m.Y', strtotime($this->borndate)), $this->ip);
$infoString = '<b>Личное дело</b><br>E-Mail: %s<br> ДР Игрока: %s<br> IP Регистрации: %s';
echo sprintf($infoString, $this->email, date('d.m.Y', strtotime($this->borndate)), $this->ip);
if ($this->watcherIsAdmin) {
$this->Bank = new Bank($this->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);
$infoString = '<br><span>ИД Игрока: %s<br> ИД Комнаты: %s<br> Деньги: %s<br> Деньги в банке: %s<br> Опыт: %s<br> Нераспределённые очки: %s<br> Текущая сессия: %s</span>';
echo sprintf($infoString, $this->id, $this->room, $this->money, $this->Bank->money, $this->experience, $this->stat_points, $this->email, $this->session_id);
}
$this->UserLogs = new UserLogModel($this->id);
echo '<div class="secret-info-user-log">';
@ -205,21 +198,51 @@ EMPTY_SLOT;
}
}
public function showStarSign() {
/*
* 1 aries
* 2 taurus
* 3 gemini
* 4 cancer
* 5 leo
* 6 virgo
* 7 libra
* 8 scorpio
* 9 sagittarios
* 10 capricorn
* 11 aquarius
* 12 pisches
*/
private function WatcherStatus() {
$query = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = ?i', $this->watcher_id)->fetch_assoc();
if ($query['admin']) {
$this->watcherIsAdmin = 1;
}
if ($query['align'] == 1) {
$this->watcherIsModerator = 1;
}
}
public function showUserInfo()
{
$this->effects = new EffectsModel($this->id);
$this->WatcherStatus();
if ($this->block && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) {
throw new Exception('<span class="error">Персонаж ' . $this->login . ' заблокирован!</span>');
} elseif ($this->effects->getHideUserInfoStatus() && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) {
if ($this->effects->getHideUserInfoStatus() == -1) {
$date = 'навсегда';
} else {
$date = 'до' . date('d.m.Y', strtotime($this->effects->getHideUserInfoStatus()));
}
throw new Exception('<span class="error">Персонаж ' . $this->login . ' обезличен ' . $date . '.</span>');
} else {
$this->UserInfo();
}
}
public function showStarSign()
{
/*
* 1 aries
* 2 taurus
* 3 gemini
* 4 cancer
* 5 leo
* 6 virgo
* 7 libra
* 8 scorpio
* 9 sagittarios
* 10 capricorn
* 11 aquarius
* 12 pisches
*/
$zodiac[356] = "10";
$zodiac[326] = "09";
$zodiac[296] = "08";
@ -235,7 +258,7 @@ EMPTY_SLOT;
$zodiac[0] = "10";
$dayOfYear = date("z", strtotime($this->borndate));
$isLeapYear = date("L", strtotime($this->borndate)); //Высокосный?
if ($isLeapYear && $dayOfYear >59) {
if ($isLeapYear && $dayOfYear > 59) {
--$dayOfYear;
}
foreach ($zodiac as $day => $sign) {
@ -246,17 +269,4 @@ EMPTY_SLOT;
return $sign ?? null;
}
public function showPrivateUserInfo() {
$this->watchingUser;
function privateAccessCheck()
{
$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;
}
}
}

View File

@ -1,14 +1,12 @@
<?php
session_start();
include_once 'config.php';
//include_once 'models/PresentsModel.php';
$login = urldecode($_SERVER['QUERY_STRING']) ?? '';
$uid = $_SESSION['uid'] ?? null;
$user = new User($login);
$presentsModel = new PresentsModel($user->id);
$presentsList = $presentsModel->getAllPresents();
$user->watcher_id = $_SESSION['uid'] ?? null;
if (empty($user->id)): ?>
<!doctype html>
<html lang="ru">
@ -32,11 +30,6 @@ if (empty($user->id)): ?>
<body>
<?php
$hideInfo = new EffectsModel($user->id);
if ($hideInfo->getHideUserInfoStatus()) {
exit('<h3>Персонаж обезличен!</h3>');
}
try {
$user->showUserInfo();
} catch (Exception $e_showUserInfo) {