Refactor _mod.php by stripping out conditional moderator statements. The update centralizes authorization checks for various moderation actions such as blocking users and appointing new moderators. It also optimizes several lines in the code by suppressing unnecessary components. The old method of using 'admin' has been replaced by an object-oriented 'm' class to streamline and improve code maintenance.
This commit is contained in:
parent
8c4778c093
commit
dac8ffef5d
@ -15,16 +15,6 @@ if (!$m->isModerator) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rang = 'Модератор';
|
|
||||||
|
|
||||||
if (isset($_GET['remod'])) {
|
|
||||||
if ($_GET['remod'] == 1) {
|
|
||||||
$_SESSION['remod'] = 3;
|
|
||||||
} else {
|
|
||||||
$_SESSION['remod'] = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$merror = '';
|
$merror = '';
|
||||||
$uer = '';
|
$uer = '';
|
||||||
|
|
||||||
@ -50,23 +40,23 @@ if (!empty($_POST['logingo'])) {
|
|||||||
$moderation->depersonalize($_POST['time']);
|
$moderation->depersonalize($_POST['time']);
|
||||||
} elseif (!empty($_POST['undepersonalize'])) {
|
} elseif (!empty($_POST['undepersonalize'])) {
|
||||||
$moderation->undepersonalize();
|
$moderation->undepersonalize();
|
||||||
} elseif (!empty($_POST['ban'])) {
|
} elseif (!empty($_POST['ban']) && $m->canBlockUsers) {
|
||||||
$moderation->ban();
|
$moderation->ban();
|
||||||
} elseif (!empty($_POST['unban'])) {
|
} elseif (!empty($_POST['unban']) && $m->canBlockUsers) {
|
||||||
$moderation->unban();
|
$moderation->unban();
|
||||||
} elseif (!empty($_POST['addmoderator'])) {
|
} elseif (!empty($_POST['addmoderator']) && $m->isAdmin) {
|
||||||
$administration->addmoderator();
|
$administration->addmoderator();
|
||||||
} elseif (!empty($_POST['deletemoderator'])) {
|
} elseif (!empty($_POST['deletemoderator']) && $m->isAdmin) {
|
||||||
$administration->removemoderator();
|
$administration->removemoderator();
|
||||||
} elseif (!empty($_POST['changegender'])) {
|
} elseif (!empty($_POST['changegender']) && $m->isAdmin) {
|
||||||
$administration->changegender();
|
$administration->changegender();
|
||||||
} elseif (!empty($_POST['changelogin']) && !empty($_POST['newLogin'])) {
|
} elseif (!empty($_POST['changelogin']) && !empty($_POST['newLogin']) && $m->isAdmin) {
|
||||||
$administration->changelogin($_POST['newLogin']);
|
$administration->changelogin($_POST['newLogin']);
|
||||||
} elseif (!empty($_POST['giveitem']) && !empty($_POST['itemId'])) {
|
} elseif (!empty($_POST['giveitem']) && !empty($_POST['itemId']) && $m->isAdmin) {
|
||||||
$administration->additem((int)$_POST['itemId']);
|
$administration->additem((int)$_POST['itemId']);
|
||||||
} elseif (!empty($_POST['kickfrombattle'])) {
|
} elseif (!empty($_POST['kickfrombattle']) && $m->isAdmin) {
|
||||||
$administration->kickfrombattle();
|
$administration->kickfrombattle();
|
||||||
} elseif (!empty($_POST['toggleinvisibility'])) {
|
} elseif (!empty($_POST['toggleinvisibility']) && $m->isAdmin) {
|
||||||
$administration->toggleinvisibility();
|
$administration->toggleinvisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +83,7 @@ if (isset($_GET['go'])) {
|
|||||||
$go = round($_GET['go']);
|
$go = round($_GET['go']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($go == 3 && $u->info['admin'] > 0) {
|
if ($go == 3 && $m->isAdmin) {
|
||||||
?>
|
?>
|
||||||
<table style="width: 100%">
|
<table style="width: 100%">
|
||||||
<tr>
|
<tr>
|
||||||
@ -227,11 +217,11 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
} elseif ($go == 2 && $u->info['admin'] > 0) {
|
} elseif ($go == 2 && $m->isAdmin) {
|
||||||
if (isset($_POST['q_name'])) {
|
if (isset($_POST['q_name'])) {
|
||||||
$qd = [];
|
$qd = [];
|
||||||
/* Array ([q_act_atr_1] => 0 [q_act_val_1] => [q_tr_atr_1] => 0 [q_tr_val_1] => [q_ng_atr_1] => 0 [q_ng_val_1] => [q_nk_atr_NaN] => 0
|
/* Array ([q_act_atr_1] => 0 [q_act_val_1] => [q_tr_atr_1] => 0 [q_tr_val_1] => [q_ng_atr_1] => 0 [q_ng_val_1] => [q_nk_atr_NaN] => 0
|
||||||
[q_nk_val_NaN] => [q_info] => test описание [q_line1] => 1 [q_line2] => 1 [q_fast] => 1 [q_fast_city] => capitalcity [q_align1] => 1 [q_align2] => 1 [q_align3] => 1 ) */
|
[q_nk_val_NaN] => [q_info] => test описание [q_line1] => 1 [q_line2] => 1 [q_fast] => 1 [q_align1] => 1 [q_align2] => 1 [q_align3] => 1 ) */
|
||||||
$qd['name'] = $_POST['q_name'];
|
$qd['name'] = $_POST['q_name'];
|
||||||
$qd['lvl'] = explode('-', $_POST['q_lvl']);
|
$qd['lvl'] = explode('-', $_POST['q_lvl']);
|
||||||
$qd['info'] = $_POST['q_info'];
|
$qd['info'] = $_POST['q_info'];
|
||||||
@ -239,7 +229,6 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
$qd['line'] = $_POST['q_line2'];
|
$qd['line'] = $_POST['q_line2'];
|
||||||
}
|
}
|
||||||
if ($_POST['q_fast'] == 1) {
|
if ($_POST['q_fast'] == 1) {
|
||||||
$qd['city'] = $_POST['q_fast_city'];
|
|
||||||
$gd['fast'] = 1;
|
$gd['fast'] = 1;
|
||||||
}
|
}
|
||||||
if ($_POST['align1'] == 1) {
|
if ($_POST['align1'] == 1) {
|
||||||
@ -257,7 +246,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$i = -2;
|
$i = -2;
|
||||||
$qd['act_date'] = trim($qd['act_date'], ':|:');
|
$qd['act_date'] = trim($qd['act_date'], ':|');
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -269,7 +258,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$i = -2;
|
$i = -2;
|
||||||
$qd['tr_date'] = trim($qd['tr_date'], ':|:');
|
$qd['tr_date'] = trim($qd['tr_date'], ':|');
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -281,7 +270,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$i = -2;
|
$i = -2;
|
||||||
$qd['win_date'] = trim($qd['win_date'], ':|:');
|
$qd['win_date'] = trim($qd['win_date'], ':|');
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -293,7 +282,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$i = -2;
|
$i = -2;
|
||||||
$qd['lose_date'] = trim($qd['lose_date'], ':|:');
|
$qd['lose_date'] = trim($qd['lose_date'], ':|');
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -397,18 +386,43 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<title>Текстовое поле</title>
|
<title>Текстовое поле</title>
|
||||||
|
<style>
|
||||||
|
.vtop {
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
<table width="100%">
|
.center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.cs0 {
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.cp5 {
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.cp5 td {
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.newquest {
|
||||||
|
width: 100%;
|
||||||
|
border: 0;
|
||||||
|
background-color: #e1e1e1;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<table style="width: 100%;">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center"><h3>Редактор заданий</h3></td>
|
<td class="center"><h3>Редактор заданий</h3></td>
|
||||||
<td width="150" align="right">
|
<td style="width: 150px; text-align: right;">
|
||||||
<input type="button" class="btn btn-success" value="Вернуться" onclick="location='/main.php?moderation';"/>
|
<input type="button" class="btn btn-success" value="Вернуться" onclick="location='/main.php?moderation';"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
<table class="cs0 cp5 newquest">
|
||||||
<table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#E1E1E1">
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<tr>
|
<tr>
|
||||||
<td style="border-bottom:1px solid #CCCCCC;">
|
<td style="border-bottom:1px solid #CCCCCC;">
|
||||||
@ -422,58 +436,55 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
<td style="border-bottom:1px solid #CCCCCC; background-color: #dadada;">
|
<td style="border-bottom:1px solid #CCCCCC; background-color: #dadada;">
|
||||||
<b>Панель добавления новых заданий:</b><br>
|
<b>Панель добавления новых заданий:</b><br>
|
||||||
<form method="post" action="/main.php?moderation&go=2">
|
<form method="post" action="/main.php?moderation&go=2">
|
||||||
<table width="100%" border="0" cellspacing="0" cellpadding="5">
|
|
||||||
|
<table class="cs0 cp5" style="width: 100%; border: 0;">
|
||||||
<tr>
|
<tr>
|
||||||
<td width="200" valign="top"><label for="q_name">Название задания</label></td>
|
<td class="vtop" style="width: 200px;"><label for="q_name">Название задания</label></td>
|
||||||
<td><input name="q_name" id="q_name" value="" size="60" maxlength="50"/>
|
<td><input name="q_name" id="q_name" size="60" maxlength="50">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top"><label for="q_lvl">Уровень задания</label></td>
|
<td class="vtop"><label for="q_lvl">Уровень задания</label></td>
|
||||||
<td><input name="q_lvl" id="q_lvl" value="0-21" size="10" maxlength="5"/></td>
|
<td><input name="q_lvl" id="q_lvl" value="0-21" size="10" maxlength="5"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top">Действия</td>
|
<td class="vtop">Действия</td>
|
||||||
<td valign="top" id="qact"><a href="javascript:void(0)" onclick="addqact()"><small>[+] добавить</small></a></td>
|
<td class="vtop" id="qact"><a href="javascript:void(0)" onclick="addqact()"><small>[+] добавить</small></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top">Условия</td>
|
<td class="vtop">Условия</td>
|
||||||
<td valign="top" id="qtr"><a href="javascript:void(0)" onclick="addqtr()"><small>[+] добавить</small></a></td>
|
<td class="vtop" id="qtr"><a href="javascript:void(0)" onclick="addqtr()"><small>[+] добавить</small></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top">Награда</td>
|
<td class="vtop">Награда</td>
|
||||||
<td valign="top" id="qng"><a href="javascript:void(0)" onclick="addqng()"><small>[+] добавить</small></a></td>
|
<td class="vtop" id="qng"><a href="javascript:void(0)" onclick="addqng()"><small>[+] добавить</small></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top">Неудача</td>
|
<td class="vtop">Неудача</td>
|
||||||
<td valign="top" id="qnk"><a href="javascript:void(0)" onclick="addqnk()"><small>[+] добавить</small></a></td>
|
<td class="vtop" id="qnk"><a href="javascript:void(0)" onclick="addqnk()"><small>[+] добавить</small></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top"><label for="q_info">Описание задания</label></td>
|
<td class="vtop"><label for="q_info">Описание задания</label></td>
|
||||||
<td><textarea name="q_info" id="q_info" style="width:90%" rows="7"></textarea></td>
|
<td><textarea name="q_info" id="q_info" style="width:90%" rows="7"></textarea></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="background-color: #cbcbcb">
|
<tr style="background-color: #cbcbcb">
|
||||||
<td align="center" valign="top">
|
<td class="vtop center">
|
||||||
<label><input name="q_line1" type="checkbox" id="checkbox3" value="1"/>
|
<label><input name="q_line1" type="checkbox" id="checkbox3" value="1">
|
||||||
Линейное задание</label>
|
Линейное задание</label>
|
||||||
</td>
|
</td>
|
||||||
<td bgcolor="#CBCBCB">
|
<td>
|
||||||
<label><input name="q_line2" id="q_line3" value="" size="5" maxlength="3"/>
|
<label><input name="q_line2" id="q_line3" size="5" maxlength="3">
|
||||||
, id линейного сюжета</label>
|
, id линейного сюжета</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="background-color: #cbcbcb">
|
<tr style="background-color: #cbcbcb">
|
||||||
<td align="center" valign="top">
|
<td class="vtop center">
|
||||||
<label><input name="q_fast" type="checkbox" id="q_fast" value="1"/>
|
<label><input name="q_fast" type="checkbox" id="q_fast" value="1">
|
||||||
Быстрое задание</label>
|
Быстрое задание</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
|
||||||
<label><input name="q_fast_city" id="q_fast_city" value="capitalcity" size="50" maxlength="50">
|
|
||||||
, город которым ограничен квест <small>(стереть, если не ограничен)</small><label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr style="background-color: #cbcbcb">
|
<tr style="background-color: #cbcbcb">
|
||||||
<td align="center" valign="top">
|
<td class="vtop center">
|
||||||
<small>
|
<small>
|
||||||
<label>
|
<label>
|
||||||
<input name="q_align1" type="checkbox" id="q_align1" value="1">Свет,
|
<input name="q_align1" type="checkbox" id="q_align1" value="1">Свет,
|
||||||
@ -497,7 +508,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
<!-- -->
|
<!-- -->
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#E1E1E1">
|
<table class="cs0 cp5 newquest">
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<?php
|
<?php
|
||||||
if (isset($_GET['delq'])) {
|
if (isset($_GET['delq'])) {
|
||||||
@ -542,30 +553,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<div id="useMagic" style="display:none; position:absolute; border:solid 1px #776f59; left: 50px; top: 186px;" class="modpow">
|
||||||
function openMod(title, dat) {
|
|
||||||
const d = document.getElementById('useMagic');
|
|
||||||
if (d) {
|
|
||||||
document.getElementById('modtitle').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top">' + title + '</td><td width="30" valign="top"><div align="right"><a title="Закрыть окно" onClick="closeMod(); return false;" href="#">x</a></div></td></tr></table>';
|
|
||||||
document.getElementById('moddata').innerHTML = dat;
|
|
||||||
d.style.display = '';
|
|
||||||
top.chat.inObj = top.frames['main'].document.getElementById('logingo');
|
|
||||||
top.frames['main'].document.getElementById('logingo').focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeMod() {
|
|
||||||
const d = document.getElementById('useMagic');
|
|
||||||
if (d) {
|
|
||||||
document.getElementById('modtitle').innerHTML = '';
|
|
||||||
document.getElementById('moddata').innerHTML = '';
|
|
||||||
d.style.display = 'none';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<div id="useMagic"
|
|
||||||
style="display:none; position:absolute; border:solid 1px #776f59; left: 50px; top: 186px;"
|
|
||||||
class="modpow">
|
|
||||||
<div class="mt" id="modtitle"></div>
|
<div class="mt" id="modtitle"></div>
|
||||||
<div class="md" id="moddata"></div>
|
<div class="md" id="moddata"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -583,9 +571,8 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
<form action="/main.php?moderation&rnd=<?= PassGen::intCode() ?>" method="post" name="F1" id="F1">
|
<form action="/main.php?moderation&rnd=<?= PassGen::intCode() ?>" method="post" name="F1" id="F1">
|
||||||
<?php
|
<?php
|
||||||
$uer = '';
|
$uer = '';
|
||||||
//используем заклятия
|
//используем заклятия (старая реализация, замещается)
|
||||||
if (isset($_GET['usemod'])) {
|
if (isset($_GET['usemod'])) {
|
||||||
|
|
||||||
if (isset($_POST['usevampir'])) {
|
if (isset($_POST['usevampir'])) {
|
||||||
require_once('moder/usevampir.php');
|
require_once('moder/usevampir.php');
|
||||||
} elseif (isset($_POST['teleport'])) {
|
} elseif (isset($_POST['teleport'])) {
|
||||||
@ -604,11 +591,8 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo '<span style="color: red; ">' . $uer . '</span>';
|
echo '<span style="color: red; ">' . $uer . '</span>';
|
||||||
//Темная склонка, кусается сука!)
|
|
||||||
?>
|
?>
|
||||||
<br/>
|
<br>
|
||||||
|
|
||||||
<?php if ($m->isModerator): ?>
|
|
||||||
<div style="padding:10px; margin:5px; border-bottom:1px solid #cac9c7;">
|
<div style="padding:10px; margin:5px; border-bottom:1px solid #cac9c7;">
|
||||||
<h4>Наложить/Снять наказание</h4>
|
<h4>Наложить/Снять наказание</h4>
|
||||||
<form method="post" id="moderation">
|
<form method="post" id="moderation">
|
||||||
@ -669,8 +653,8 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
<button disabled>Добавить опыта</button> <i style="color: grey">- очень сломанная херня.</i>
|
<button disabled>Добавить опыта</button> <i style="color: grey">- очень сломанная херня.</i>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif;
|
|
||||||
|
|
||||||
|
<?php
|
||||||
if ($m->isAdmin) {
|
if ($m->isAdmin) {
|
||||||
/** Мегафон только для администраторов. */
|
/** Мегафон только для администраторов. */
|
||||||
Announcement::init();
|
Announcement::init();
|
||||||
@ -714,7 +698,6 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
|||||||
HTML;
|
HTML;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} ?>
|
} ?>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
|
Loading…
Reference in New Issue
Block a user