Регистрации персонажей только для администраторов в отдельный класс.

This commit is contained in:
Ivor Barhansky 2023-12-08 17:55:27 +02:00
parent 99341cfd07
commit cda265c799
2 changed files with 63 additions and 80 deletions

View File

@ -3,34 +3,71 @@
namespace Moderation;
use Core\Db;
use DateTime;
use DateTimeImmutable;
use User;
class UserRegistrationList
{
public function get(DateTime $date)
/** Ðåãèñòðàöèè ïåðñîíàæåé: òîëüêî äëÿ àäìèíèñòðàòîðîâ.
* @return void
*/
public static function get(): void
{
$from = $date->getTimestamp();
$to = $date->modify('+ 1 day')->getTimestamp();
$list = Db::getRows("select id, banned, molch1, battle, host_reg, online from users where timereg between ? and ? and bot_id = 0 and bithday != '01.01.1800' order by id", [$from, $to]);
$str = '';
foreach ($list as $user) {
$time = new DateTime();
$loginColor = 'black';
if ($user['banned']) {
$loginColor = 'red';
}
if ($user['online'] > $time->modify('- 10 minutes')->getTimestamp()) {
$loginColor = 'green';
}
if ($user['molch1'] > 0) {
$molch1Duration = new DateTimeImmutable($user['molch1']);
}
$str .= "<li><span style='color: $loginColor'>" . User::getLogin($user['id'] . "</span>");
$query = "select users.id, host_reg, banned, battle, online, molch1
from users left join stats on users.id = stats.id
where bithday != '01.01.1800' and bot = 0 and timereg between ? and ? order by users.id";
$pld520 = date('d.m.Y');
if (isset($_POST['loginLD520'])) {
$pld520 = $_POST['loginLD520'];
}
$pld520TS = strtotime(str_replace(".", "-", $pld520));
$pld520 = date('d.m.Y', $pld520TS);
?>
<script>
const regx = document.getElementById('loginLD520')
function regprev() {
regx.value = '<?= date('d.m.Y', ($pld520TS - 86400)) ?>';
}
function regnext() {
regx.value = '<?= date('d.m.Y', ($pld520TS + 86400)) ?>';
}
</script>
<div style="padding:0 10px 5px 10px; margin:5px; border-bottom:1px solid #cac9c7;">
<h4>Ðåãèñòðàöèè ïåðñîíàæåé</h4>
<label for="loginLD520">Äàòà ðåãèñòðàöèè</label>
<input name="pometka520" class="btn btn-success" onclick="regprev()" type="submit" value="&laquo;"/>
<input value="<?= $pld520 ?>" name="loginLD520" type="text" id="loginLD520" size="20" maxlength="10"/>
<input name="pometka520" class="btn btn-success" onclick="regnext()" type="submit" value="&raquo;"/>
<input type="submit" name="pometka520" id="pometka520" class="btn" value="Ïîêàçàòü"/>
<?php if (isset($_POST['pometka520'])): ?>
<br><b style="color: red;">Ïåðñîíàæè çàðåãèñòðèðîâàííûå <?= $pld520 ?></b>
<ol>
<?php foreach (Db::getRows($query, [$pld520TS, $pld520TS + 86400]) as $pl):
$logincolor = match (true) {
$pl['banned'] > 0 => 'red',
$pl['online'] > time() - 520 => 'green',
default => 'black',
};
?>
<li>
<span style="color: <?= $logincolor ?>"> <?= User::getLogin($pl['id']) ?> </span>
<?php if ($pl['molch1'] > time()): ?>
<i>(ìîë÷èò)</i>
<?php endif; ?>
<?php if ($pl['battle'] > 0): ?>
<a href="/logs.php?log=<?= $pl['battle'] ?>" target="_blank">(â áîþ)</a>
<?php endif; ?>
<?php if ($pl['host_reg'] > 0): ?>
<small>(ðåôåðàë ïåðñîíàæà <?= User::getLogin($pl['host_reg']) ?>)</small>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
</div>
<?php
}
}
}

View File

@ -817,62 +817,8 @@ if ($go == 3 && $u->info['admin'] > 0) {
/** Мегафон только для администраторов. */
Announcement::init();
/** Регистрации персонажей только для администраторов. */
$pld520 = date('d.m.Y');
if (isset($_POST['loginLD520'])) {
$pld520 = $_POST['loginLD520'];
}
$pld520TS = strtotime(str_replace(".", "-", $pld520));
$pld520 = date('d.m.Y', $pld520TS);
?>
<div style="padding:0 10px 5px 10px; margin:5px; border-bottom:1px solid #cac9c7;">
<h4>Регистрации персонажей</h4>
Дата регистрации
<input name="pometka520" class="btn btn-success"
onclick="document.getElementById('loginLD520').value='<?= date(
'd.m.Y', ($pld520TS - 86400)
) ?>';" type="submit" value="&laquo;"/>
<input value="<?= $pld520 ?>" name="loginLD520" type="text" id="loginLD520" size="20"
maxlength="10"/>
<input name="pometka520" class="btn btn-success"
onclick="document.getElementById('loginLD520').value='<?= date(
'd.m.Y', ($pld520TS + 86400)
) ?>';" type="submit" value="&raquo;"/>
<input type="submit" name="pometka520" id="pometka520" class="btn" value="Показать"/>
<?php
if (isset($_POST['pometka520'])) {
$sp = mysql_query(
'SELECT `users`.`id`,`users`.`host_reg`,`users`.`banned`,`users`.`battle`,`users`.`online`,`users`.`molch1`,`users`.`bithday` FROM `users` LEFT JOIN `stats` ON `stats`.`id` = `users`.`id` WHERE `users`.`bithday` != "01.01.1800" AND `stats`.`bot` = 0 AND `users`.`timereg` >= ' . $pld520TS . ' AND `users`.`timereg` < ' . ($pld520TS + 86400) . ' ORDER BY `users`.`id` ASC'
);
$i = 1;
echo '<br><b style="color: red;">Персонажи зарегистрированные ' . $pld520 . '</b>';
while ($pl = mysql_fetch_array($sp)) {
$urt5202 = '<br>' . $i . '. ' . User::getLogin($pl['id']);
if ($pl['banned'] > 0) {
$urt5202 = '<font color=red>' . $urt5202 . '</font>';
} elseif ($pl['online'] > time() - 520) {
$urt5202 = '<font color=green>' . $urt5202 . '</font>';
}
if ($pl['molch1'] > time()) {
$urt5202 .= ' <img title="На персонаже молчанка" src=//img.new-combats.tech/i/sleep2.gif width=24 height=15>';
}
if ($pl['battle'] > 0) {
$urt5202 .= ' <a href="/logs.php?log=' . $pl['battle'] . '" target="_blank"><img src=//img.new-combats.tech/i/fighttype0.gif title="Персонаж в поединке"></a>';
}
if ($pl['host_reg'] > 0) {
$urt5202 .= ' &nbsp; <small>(Реферал персонажа ' . User::getLogin($pl['host_reg']) . ')</small>';
}
$urt520 .= $urt5202;
$i++;
}
echo $urt520;
unset($urt520, $i, $pl, $sp);
}
?>
</div>
<?php
/** Регистрации персонажей только для администраторов. */
UserRegistrationList::get();
/** Kог действий модераторов только для администраторов. */
$dsee = [];