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;
|
||||
}
|
||||
|
||||
$rang = 'Модератор';
|
||||
|
||||
if (isset($_GET['remod'])) {
|
||||
if ($_GET['remod'] == 1) {
|
||||
$_SESSION['remod'] = 3;
|
||||
} else {
|
||||
$_SESSION['remod'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$merror = '';
|
||||
$uer = '';
|
||||
|
||||
@ -50,23 +40,23 @@ if (!empty($_POST['logingo'])) {
|
||||
$moderation->depersonalize($_POST['time']);
|
||||
} elseif (!empty($_POST['undepersonalize'])) {
|
||||
$moderation->undepersonalize();
|
||||
} elseif (!empty($_POST['ban'])) {
|
||||
} elseif (!empty($_POST['ban']) && $m->canBlockUsers) {
|
||||
$moderation->ban();
|
||||
} elseif (!empty($_POST['unban'])) {
|
||||
} elseif (!empty($_POST['unban']) && $m->canBlockUsers) {
|
||||
$moderation->unban();
|
||||
} elseif (!empty($_POST['addmoderator'])) {
|
||||
} elseif (!empty($_POST['addmoderator']) && $m->isAdmin) {
|
||||
$administration->addmoderator();
|
||||
} elseif (!empty($_POST['deletemoderator'])) {
|
||||
} elseif (!empty($_POST['deletemoderator']) && $m->isAdmin) {
|
||||
$administration->removemoderator();
|
||||
} elseif (!empty($_POST['changegender'])) {
|
||||
} elseif (!empty($_POST['changegender']) && $m->isAdmin) {
|
||||
$administration->changegender();
|
||||
} elseif (!empty($_POST['changelogin']) && !empty($_POST['newLogin'])) {
|
||||
} elseif (!empty($_POST['changelogin']) && !empty($_POST['newLogin']) && $m->isAdmin) {
|
||||
$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']);
|
||||
} elseif (!empty($_POST['kickfrombattle'])) {
|
||||
} elseif (!empty($_POST['kickfrombattle']) && $m->isAdmin) {
|
||||
$administration->kickfrombattle();
|
||||
} elseif (!empty($_POST['toggleinvisibility'])) {
|
||||
} elseif (!empty($_POST['toggleinvisibility']) && $m->isAdmin) {
|
||||
$administration->toggleinvisibility();
|
||||
}
|
||||
|
||||
@ -93,7 +83,7 @@ if (isset($_GET['go'])) {
|
||||
$go = round($_GET['go']);
|
||||
}
|
||||
|
||||
if ($go == 3 && $u->info['admin'] > 0) {
|
||||
if ($go == 3 && $m->isAdmin) {
|
||||
?>
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
@ -227,11 +217,11 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
} elseif ($go == 2 && $u->info['admin'] > 0) {
|
||||
} elseif ($go == 2 && $m->isAdmin) {
|
||||
if (isset($_POST['q_name'])) {
|
||||
$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
|
||||
[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['lvl'] = explode('-', $_POST['q_lvl']);
|
||||
$qd['info'] = $_POST['q_info'];
|
||||
@ -239,7 +229,6 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
$qd['line'] = $_POST['q_line2'];
|
||||
}
|
||||
if ($_POST['q_fast'] == 1) {
|
||||
$qd['city'] = $_POST['q_fast_city'];
|
||||
$gd['fast'] = 1;
|
||||
}
|
||||
if ($_POST['align1'] == 1) {
|
||||
@ -257,7 +246,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
}
|
||||
} else {
|
||||
$i = -2;
|
||||
$qd['act_date'] = trim($qd['act_date'], ':|:');
|
||||
$qd['act_date'] = trim($qd['act_date'], ':|');
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -269,7 +258,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
}
|
||||
} else {
|
||||
$i = -2;
|
||||
$qd['tr_date'] = trim($qd['tr_date'], ':|:');
|
||||
$qd['tr_date'] = trim($qd['tr_date'], ':|');
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -281,7 +270,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
}
|
||||
} else {
|
||||
$i = -2;
|
||||
$qd['win_date'] = trim($qd['win_date'], ':|:');
|
||||
$qd['win_date'] = trim($qd['win_date'], ':|');
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -293,7 +282,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
}
|
||||
} else {
|
||||
$i = -2;
|
||||
$qd['lose_date'] = trim($qd['lose_date'], ':|:');
|
||||
$qd['lose_date'] = trim($qd['lose_date'], ':|');
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -397,18 +386,43 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
</script>
|
||||
|
||||
<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>
|
||||
<td align="center"><h3>Редактор заданий</h3></td>
|
||||
<td width="150" align="right">
|
||||
<td class="center"><h3>Редактор заданий</h3></td>
|
||||
<td style="width: 150px; text-align: right;">
|
||||
<input type="button" class="btn btn-success" value="Вернуться" onclick="location='/main.php?moderation';"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#E1E1E1">
|
||||
<table class="cs0 cp5 newquest">
|
||||
<!-- -->
|
||||
<tr>
|
||||
<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;">
|
||||
<b>Панель добавления новых заданий:</b><br>
|
||||
<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>
|
||||
<td width="200" valign="top"><label for="q_name">Название задания</label></td>
|
||||
<td><input name="q_name" id="q_name" value="" size="60" maxlength="50"/>
|
||||
<td class="vtop" style="width: 200px;"><label for="q_name">Название задания</label></td>
|
||||
<td><input name="q_name" id="q_name" size="60" maxlength="50">
|
||||
</td>
|
||||
</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>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Действия</td>
|
||||
<td valign="top" id="qact"><a href="javascript:void(0)" onclick="addqact()"><small>[+] добавить</small></a></td>
|
||||
<td class="vtop">Действия</td>
|
||||
<td class="vtop" id="qact"><a href="javascript:void(0)" onclick="addqact()"><small>[+] добавить</small></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Условия</td>
|
||||
<td valign="top" id="qtr"><a href="javascript:void(0)" onclick="addqtr()"><small>[+] добавить</small></a></td>
|
||||
<td class="vtop">Условия</td>
|
||||
<td class="vtop" id="qtr"><a href="javascript:void(0)" onclick="addqtr()"><small>[+] добавить</small></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Награда</td>
|
||||
<td valign="top" id="qng"><a href="javascript:void(0)" onclick="addqng()"><small>[+] добавить</small></a></td>
|
||||
<td class="vtop">Награда</td>
|
||||
<td class="vtop" id="qng"><a href="javascript:void(0)" onclick="addqng()"><small>[+] добавить</small></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">Неудача</td>
|
||||
<td valign="top" id="qnk"><a href="javascript:void(0)" onclick="addqnk()"><small>[+] добавить</small></a></td>
|
||||
<td class="vtop">Неудача</td>
|
||||
<td class="vtop" id="qnk"><a href="javascript:void(0)" onclick="addqnk()"><small>[+] добавить</small></a></td>
|
||||
</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>
|
||||
</tr>
|
||||
<tr style="background-color: #cbcbcb">
|
||||
<td align="center" valign="top">
|
||||
<label><input name="q_line1" type="checkbox" id="checkbox3" value="1"/>
|
||||
<td class="vtop center">
|
||||
<label><input name="q_line1" type="checkbox" id="checkbox3" value="1">
|
||||
Линейное задание</label>
|
||||
</td>
|
||||
<td bgcolor="#CBCBCB">
|
||||
<label><input name="q_line2" id="q_line3" value="" size="5" maxlength="3"/>
|
||||
<td>
|
||||
<label><input name="q_line2" id="q_line3" size="5" maxlength="3">
|
||||
, id линейного сюжета</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="background-color: #cbcbcb">
|
||||
<td align="center" valign="top">
|
||||
<label><input name="q_fast" type="checkbox" id="q_fast" value="1"/>
|
||||
<td class="vtop center">
|
||||
<label><input name="q_fast" type="checkbox" id="q_fast" value="1">
|
||||
Быстрое задание</label>
|
||||
</td>
|
||||
<td>
|
||||
<label><input name="q_fast_city" id="q_fast_city" value="capitalcity" size="50" maxlength="50">
|
||||
, город которым ограничен квест <small>(стереть, если не ограничен)</small><label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="background-color: #cbcbcb">
|
||||
<td align="center" valign="top">
|
||||
<td class="vtop center">
|
||||
<small>
|
||||
<label>
|
||||
<input name="q_align1" type="checkbox" id="q_align1" value="1">Свет,
|
||||
@ -497,7 +508,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
<!-- -->
|
||||
</table>
|
||||
|
||||
<table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#E1E1E1">
|
||||
<table class="cs0 cp5 newquest">
|
||||
<!-- -->
|
||||
<?php
|
||||
if (isset($_GET['delq'])) {
|
||||
@ -542,30 +553,7 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
padding: 10px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
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 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="md" id="moddata"></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">
|
||||
<?php
|
||||
$uer = '';
|
||||
//используем заклятия
|
||||
//используем заклятия (старая реализация, замещается)
|
||||
if (isset($_GET['usemod'])) {
|
||||
|
||||
if (isset($_POST['usevampir'])) {
|
||||
require_once('moder/usevampir.php');
|
||||
} elseif (isset($_POST['teleport'])) {
|
||||
@ -604,11 +591,8 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
}
|
||||
|
||||
echo '<span style="color: red; ">' . $uer . '</span>';
|
||||
//Темная склонка, кусается сука!)
|
||||
?>
|
||||
<br/>
|
||||
|
||||
<?php if ($m->isModerator): ?>
|
||||
<br>
|
||||
<div style="padding:10px; margin:5px; border-bottom:1px solid #cac9c7;">
|
||||
<h4>Наложить/Снять наказание</h4>
|
||||
<form method="post" id="moderation">
|
||||
@ -669,8 +653,8 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
<button disabled>Добавить опыта</button> <i style="color: grey">- очень сломанная херня.</i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif;
|
||||
|
||||
<?php
|
||||
if ($m->isAdmin) {
|
||||
/** Мегафон только для администраторов. */
|
||||
Announcement::init();
|
||||
@ -714,7 +698,6 @@ if ($go == 3 && $u->info['admin'] > 0) {
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
|
||||
} ?>
|
||||
</form>
|
||||
<?php
|
||||
|
Loading…
Reference in New Issue
Block a user