diff --git a/inf.php b/inf.php
index a66a3b1..65d45d3 100644
--- a/inf.php
+++ b/inf.php
@@ -8,7 +8,19 @@ $uid = $_SESSION['uid'] ?? null;
// FROM `users`
// WHERE `login` = "?s" OR `id` = "?s"', $login, $login)->fetch_assoc();
$user = new User($_SESSION['uid']);
-$own = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = "?s"', $uid)->fetch_assoc();
+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;
+}
+
//$presents = db::c()->query('SELECT img, sender FROM `users_presents` WHERE expiration_date >= "?s" AND owner = ?i', date('Y-m-d'), $user->id);
$presents = [];
@@ -33,19 +45,22 @@ if (empty($user->id)): ?>
-admin === 1 && $own['admin'] != 1 && file_exists('customuserdata/' . $user['id'])) {die(file_get_contents('customuserdata/' . $user['id']));} ?>
+admin === 1 && private_access($uid) !== ADMINISTRATOR_ACCESS && file_exists('customuserdata/' . $user['id'])) {
+ die(file_get_contents('customuserdata/' . $user['id']));
+} ?>
- = showinf_pers($user['id']);
+ married)): ?>
-
+
|
-
+
|
@@ -53,8 +68,12 @@ if (empty($user->id)): ?>
query('SELECT `time` FROM `effects` WHERE `owner` = ?i AND `type` = ?i ', $user->id, 5)->fetch_assoc();
-if ($effect['time'] && ($own['admin'] != 1)) {die('Персонаж обезличен!
');}
-if (!empty($user->realname)) {echo "Имя: " . $user->realname . "
";}
+if ($effect['time'] && !private_access($uid)) {
+ die('Персонаж обезличен!
');
+}
+if (!empty($user->realname)) {
+ echo "Имя: " . $user->realname . "
";
+}
?>
= nl2br($user->info) ?>
@@ -70,12 +89,8 @@ if (!empty($user->realname)) {echo "Имя: " . $user->realname . "
";}
admin)) || (!empty($own['admin']))) {$showModeratorInfo = true;}
-
-if ($showModeratorInfo == 1) {
+if ((private_access($uid) === MODERATOR_ACCESS && !$user->admin) || private_access($uid) === ADMINISTRATOR_ACCESS) {
//$ld = db::c()->query('SELECT * FROM `lichka` WHERE `pers` = ?i ORDER BY `id` ASC', $user['id']);
$ld = db::c()->query();
echo "Личное дело
";
@@ -85,22 +100,38 @@ if ($showModeratorInfo == 1) {
}
echo "Дополнительные сведения
";
- if (!empty($user->id)) {echo "ID: " . $user->id . "
";}
- if (!empty($user->email)) {echo "E-mail: " . $user->email . "
";}
- if (!empty($user->borndate)) {echo "День рождения: " . $user->borndate . "
";}
- if (!empty($user->ip)) {echo "IP при регистрации: " . $user->ip . "
";}
+ if (!empty($user->id)) {
+ echo "ID: " . $user->id . "
";
+ }
+ if (!empty($user->email)) {
+ echo "E-mail: " . $user->email . "
";
+ }
+ if (!empty($user->borndate)) {
+ echo "День рождения: " . $user->borndate . "
";
+ }
+ if (!empty($user->ip)) {
+ echo "IP при регистрации: " . $user->ip . "
";
+ }
}
-if ($own['admin'] == 1) {
- if (!empty($user->exp)) {echo "Oпыт: " . $user->exp . "
";}
- if (!empty($user->stats)) {echo "Число неиспользованных UP-ов: " . $user->stats . "
";}
- if (!empty($user->money)) {echo "Кредитов: " . $user->money . "
";}
- if (!empty($user->room)) {echo "Комната: " . $user->room . "
";}
+if (private_access($uid) === ADMINISTRATOR_ACCESS) {
+ if (!empty($user->exp)) {
+ echo "Oпыт: " . $user->exp . "
";
+ }
+ if (!empty($user->stats)) {
+ echo "Число неиспользованных UP-ов: " . $user->stats . "
";
+ }
+ if (!empty($user->money)) {
+ echo "Кредитов: " . $user->money . "
";
+ }
+ if (!empty($user->room)) {
+ echo "Комната: " . $user->room . "
";
+ }
echo "Банковские счета
";
$bankInfo = new Bank($user->id);
- echo "Счет: " . $bankInfo->user_id.PHP_EOL;
- echo "Деньги на счету: " . $bankInfo->money.PHP_EOL;
+ echo "Счет: " . $bankInfo->user_id . PHP_EOL;
+ echo "Деньги на счету: " . $bankInfo->money . PHP_EOL;
}
?>