<?php
include ('inc/base.php');
include ('inc/functions.php');
include ('inc/user.php');
$title = 'Администрация';
include ('inc/header.php');
if(!$user) {
header('location: /');
exit();
}
if($user['banned'] >= '1') {
echo '<div class="main center">Доступ закрыт!</div>';
include ('inc/footer.php');
exit();
}
if($_GET['exit'] == 'ok' and $user['access'] == '1') {
$text = 'покинул(а) состав!';
mysql_query('INSERT INTO `administration_logs` (`text`, `user`, `time`) VALUEs ("'.$text.'", "'.$user['id'].'", "'.time().'")');
mysql_query("update `accounts` set `access` = '0' where `id` = '".$user['id']."'");
echo '<div class="main center">Вы покинули состав!</div>';
echo '<a href="?" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
if($user['access'] != '0' and $user['banned'] >= '1') {
mysql_query("update `accounts` set `access` = '0' where `id` = '".$user['id']."'");
echo '<div class="main center">Сюда закрыт доступ из-за нарушения правил!</div>';
echo '<a href="?" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
if($user['access'] == '0') {
if($_GET['send'] == 'ok') {
if($user['rating'] < '100000') {
echo '<div class="main center">Не хватает '.(100000- $user['rating']).' рейтинга!</div>';
echo '<a href="?" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
$text = 'вошел(а) в состав!';
mysql_query('INSERT INTO `administration_logs` (`text`, `user`, `time`) VALUEs ("'.$text.'", "'.$user['id'].'", "'.time().'")');
mysql_query("update `accounts` set `access` = '1' where `id` = '".$user['id']."'");
echo '<div class="main center">Вступление в состав!</div>';
echo '<a href="?" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
echo '<div class="main center">Вошедший в состав получает зарплату 5000 <img src="/style/src/cash.png" height="14"> к основному ежедневному подарку!</div><a href="?send=ok" class="link center">Войти в состав</a>';
echo '<div class="main"><small>Администрация - это "Модераторы", они следят за игрой. Нарушителей правил - наказывают!</small></div>';
include ('inc/footer.php');
exit();
}
if($_GET['delete'] == 'logs' and $user['id'] == '1' and $user['access'] == '1') {
mysql_query("delete from `administration_logs`");
echo '<div class="main center">Логи очищены!</div>';
echo '<a href="?" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
if($_GET['delete'] == 'chat') {
mysql_query("delete from `chat` where `room` = 'no_banned_users'");
$text = 'очистил(а) чат';
mysql_query('INSERT INTO `administration_logs` (`text`, `user`, `time`) VALUEs ("'.$text.'", "'.$user['id'].'", "'.time().'")');
echo '<div class="main center">Чат очищен!</div>';
echo '<a href="?" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
if($_GET['add'] == 'banned') {
$name = text($_POST['nick']);
$reason = text($_POST['reason']);
if($name) {
$account = mysql_fetch_array(mysql_query('SELECT * FROM `accounts` WHERE `name` = "'.$name.'" LIMIT 1'));
mysql_free_result($account);
if(!$account or $account['id'] == $user['id'] or $account['id'] == '1') {
echo '<div class="main center">Ничего не найдено!</div>';
echo '<a href="?add=banned" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
if(!$reason) {
echo '<div class="main center">Заполните все поля!</div>';
echo '<a href="?add=banned" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
if($account['banned_time'] > time()) {
echo '<div class="main center">Этот игрок был забанен ранее!</div>';
echo '<a href="?add=banned" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
if(strlen($name) < 2 or strlen($name) > 16) {
echo '<div class="main center">Допустимая длина ника 2-16 символов!</div>';
echo '<a href="?add=banned" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
if(strlen($reason) < 3 or strlen($reason) > 25) {
echo '<div class="main center">Допустимая длина причины 3-25 символов!</div>';
echo '<a href="?add=banned" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
$banned_time = ''.(1 + $us['banned'] + time() + 3600).'';
mysql_query("update `accounts` set `banned` = `banned` + '1', `banned_time` = '".$banned_time."' where `id` = '".$us['id']."'");
$text = 'забанил(а) игрока '.$account['name'].' по причине: '.$reason.'';
mysql_query('INSERT INTO `administration_logs` (`text`, `user`, `time`) VALUEs ("'.$text.'", "'.$user['id'].'", "'.time().'")');
mysql_query("delete from `chat` where `user` = '".$account['id']."'");
echo '<div class="main center">Игрок забанен!</div>';
echo '<a href="?" class="link center">Продолжить</a>';
include ('inc/footer.php');
exit();
}
echo '<form action="?add=banned" class="main center" method="POST"> Ник игрока <br> <input type="text" name="nick"><br>Причина<br><input type="text" name="reason"><br><input type="submit" name="send" class="input_send" value="Забанить"></form><form action="?" class="main center" method="GET"><input type="submit" class="input_back" value="Назад"></form><div class="main center"><small>* Время бана определяется автоматически в зависимости от количества наказаний.</small></div>';
include ('inc/footer.php');
exit();
}
$max = text(num($_GET['max']));
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `administration_logs`"),0);
mysql_free_result($k_post);
if($max and $max >= '11') {
$sql = mysql_query("SELECT * FROM `administration_logs` ORDER BY `id` DESC LIMIT 0, $max");
}else{
$sql = mysql_query("SELECT * FROM `administration_logs` ORDER BY `id` DESC LIMIT 0, 10");
}
while($log = mysql_fetch_assoc($sql)) {
$acc = mysql_fetch_array(mysql_query('SELECT * FROM `accounts` WHERE `id` = "'.$log['user'].'" LIMIT 1'));
mysql_free_result($acc);
echo '<div class="main"><a href="/private.php?id='.$acc['id'].'" class="none"><img src="/style/src/arrow.png"></a>'.$acc['name'].' <span style="float: right"><small>» Логи '.vremja($log['time']).'</small></span><br> <font color="#517878">'.text($log['text']).'</font></div>';
mysql_free_result($log);
}
if($k_post > '10' and !$max) {
echo '<div class="new-line"></div><a href="?max='.$k_post.'" class="link center">Показать все</a>';
}
if($k_post > '10' and $max) {
echo '<div class="new-line"></div><a href="?" class="link center">Скрыть все</a>';
}
if($k_post != '0' and $user['id'] == '1') {
echo '<div class="new-line"></div><a href="?delete=logs" class="link center">Очистить логи</a>';
}
if($k_post < '1') {
echo '<div class="main center">В логах ничего нет!</div>';
}
echo '<a href="?add=banned" class="link center">Выдать бан</a><a href="?delete=chat" class="link center">Очистить чат</a><a href="?exit=ok" class="link center">Покинуть состав</a>';
include ('inc/footer.php');
?>