battles/admin/admin.php

160 lines
6.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
session_start();
require_once '../functions.php';
use Battles\Bank;
use Battles\Database\DBPDO;
use Battles\Moderation;
use Battles\Nick;
use Battles\Template;
use Battles\User;
$user = $user ?? new User($_SESSION['uid']);
if (!$user->getAdmin()) {
header("HTTP/1.0 404 Not Found");
exit;
}
if (isset($_GET['sleep'])) {
Moderation::muteChat($user->getId(), strtotime('15min'));
}
if (isset($_POST['ldnick']) && isset($_POST['ldtext'])) {
Moderation::addToUserLog($_POST['ldnick'], $_POST['ldtext'], $user->getId());
}
if (isset($_POST['syschatmsg'])) {
Moderation::addChatSysMsg($_POST['syschatmsg']);
}
//clans to reg
$unregisteredClans = new class {
public $db;
public function getList()
{
$row = $this->db->ofetchAll('SELECT * FROM clans WHERE status = 0');
$i = 0;
while ($i < count($row)) {
$id = $row[$i]->owner_id;
$login = Nick::id($row[$i]->owner_id)->short(1);
$fullName = $row[$i]->full_name;
$shortName = $row[$i]->short_name;
$info = nl2br($row[$i]->info);
$i++;
echo <<<UNREGCLANLIST
<div>
<fieldset style="display: inline;">
<legend>$fullName [$shortName]</legend>
Глава клана: <span class="abils">$login</span><br>
Описание:<div class="abils">$info</div>
<BR>
<button onclick="location.href='?regclan=$id'">Зарегистрировать</button>
<button onclick="location.href='?remclan=$id'">Отказать</button>
</fieldset>
</div>
UNREGCLANLIST;
}
unset($i);
}
public function allowRegister($id)
{
$this->db->execute('UPDATE clans SET status = 1 WHERE status = 0 AND owner_id = ?', $id);
}
public function disallowRegister($id)
{
$bank = new Bank($id);
$this->db->execute('DELETE FROM clans WHERE status = 0 AND owner_id = ?', $id);
$bank::setBankMoney($bank->getMoney() + Config::$clan_register_cost, $id);
}
};
$unregisteredClans->db = new DBPDO();
$unregisteredClans->getList();
if (isset($_GET['regclan'])) {
$unregisteredClans->allowRegister($_GET['regclan']);
header('Location:/admin/admin.php');
exit;
}
if (isset($_GET['remclan'])) {
$unregisteredClans->disallowRegister($_GET['remclan']);
header('Location:/admin/admin.php');
exit;
}
# Телеграф.
if (!empty($_POST['receiver']) && !empty($_POST['tgmsg'])) {
$receiver = DBPDO::INIT()->ofetch('SELECT id FROM users WHERE login= ?', $_POST['receiver']);
telegraph($receiver->id, $_POST['tgmsg']);
echo "Успешно.";
}
# Показывает невидимок.
$row = DBPDO::INIT()->ofetchAll('SELECT id,login FROM users LEFT JOIN users_effects ue on users.id = ue.owner_id WHERE type = 1022 ORDER BY `id` DESC');
$i = 0;
$invisList = '';
while ($i < count($row)) {
$invisList .= '<b>[id] = ' . $row[$i]->id . ', ' . $row[$i]->login . ' </b><br>';
$i++;
}
unset($i);
Template::header('ᐰdminка');
?>
<link rel=stylesheet href="/css/admin.css">
<span class="legend">Абилки. Работают только на себя. Надо дописать цель.</span><br>
<button onclick="location.href='?sleep'"><img src="../i/magic/sleep.gif" alt="sleep"> Молчать 15 мин</button>
<button disabled><img src="../i/magic/sleep.gif" alt="sleep"> Молчать 1 час</button>
<button disabled><img src="../i/magic/sleep.gif" alt="sleep"> Молчать 1 день</button>
<button disabled><img src="../i/magic/sleep.gif" alt="sleep"> Молчать очень долго</button>
<button disabled><img src="../i/magic/sleep_off.gif" alt="sleep_off"> Снять молчанку</button>
<br>
<button disabled><img src="../i/magic/sleepf.gif" alt="sleepf"> Молчать на фомуме 1 час</button>
<button disabled><img src="../i/magic/sleepf.gif" alt="sleepf"> Молчать на фомуме 1 день</button>
<button disabled><img src="../i/magic/sleepf.gif" alt="sleepf"> Молчать на фомуме очень долго</button>
<button disabled><img src="../i/magic/sleepf_off.gif" alt="sleepf_off"> Снять молчанку на фомуме</button>
<br>
<button disabled><img src="../i/magic/obezl.gif" alt="obezl"> Сокрыть инфу</button>
<button disabled><img src="../i/magic/obezl_off.gif" alt="obezl_off"> Снять сокрытие</button>
<button disabled><img src="../i/magic/death.gif" alt="death"> Заблокировать</button>
<button disabled><img src="../i/magic/death_off.gif" alt="death_off"> Разблокировать</button>
<br>
<button disabled><img src="../i/magic/ct_all.gif" alt="ct_all"> Снять все травмы</button>
<button disabled><img src="../i/magic/marry.gif" alt="marry"> Свадьба</button>
<button disabled><img src="../i/magic/unmarry.gif" alt="unmarry"> Развод</button>
<button disabled><img src="../i/magic/bexit.gif" alt="bexit"> Выйти из боя</button>
<button disabled><img src="../i/magic/check.gif" alt="check"> Проверка</button>
<form method='post'>
<legend>Добавить в «дело» игрока заметку о нарушении правил, прокрутке и пр.</legend>
<input name='ldnick' placeholder='Логин'> <input name='ldtext' size='50' placeholder='Сообщение'>
<input type='submit' value='Добавить'><br>
</form>
<form method='post'>
<legend>Отправить системное сообщение в чат</legend>
<input name='syschatmsg' size='74' placeholder='Введите сообщение'>
<input type='submit' value='Отправить'>
</form>
<form method='post'>
<legend>Телеграф</legend>
<input name='receiver' placeholder='Логин'>
<input name='tgmsg' size='50' placeholder='Сообщение'>
<input type='submit' value='Отправить'>
</form>
<form method='post'>
<legend>Поменять статус</legend>
<input name='login' placeholder='Логин'>
<input name='status' placeholder='Статус'>
<input type='submit' value='Изменить статус'>
</form>
<span class="legend">Невидимки</span><br>
<div class="abils" style="width: fit-content;"><?= $invisList ?></div>