Файл: DARK WARS/dark_war/dpanel/ban_player.php
Строк: 69
<?php
include_once '../start.php';
$doc = new document();
$doc->title('Бан');
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
$doc->err('Ошибка, не выбран игрок');
exit();
}
$id = (int)$_GET['id'];
if (!$player->admin) {
$doc->err('Вы не администратор');
exit;
}
if (isset($_GET['uns_ban'])) {
mysql_query("DELETE FROM `dark_war_ban` WHERE `id_player` = '$id' LIMIT 1");
header("Location: /dark_war/profil.php?id=$id");
exit;
}
$ban = mysql_fetch_assoc(mysql_query("SELECT * FROM `dark_war_ban` WHERE `id_player` = '$id' LIMIT 1"));
if ($ban) {
$doc->err('Этот игрок уже в бане');
exit();
}
if (isset($_POST['save'])) {
$time_1 = abs((int) @$_POST ['time']);
$because = $_POST['because'];
switch (@$_POST['timem']) {
case 'm' :
$time_ban_end = $time_1 * 60 + TIME;
break;
case 'h' :
$time_ban_end = $time_1 * 3600 + TIME;
break;
case 'd' :
$time_ban_end = $time_1 * 86400 + TIME;
break;
case 'md' :
$time_ban_end = $time_1 * 2592000 + TIME;
break;
}
mysql_query("INSERT INTO `dark_war_ban` (`id_player`, `because`, `time_start`, `time_end`)
VALUES ('$id', '$because', '".TIME."', '$time_ban_end') ");
$ank = new player($id);
is_log::logs('Бана', "Выдал бан игроку {$ank->nick} причина $because");
$doc->msg('Бан выдан');
}
$pages = new pages;
$pages->posts = mysql_result(mysql_query("SELECT COUNT(*) FROM `dark_war_ban`"), 0);
$pages->this_page(); // получаем текущую страницу
$q=mysql_query("SELECT * FROM `dark_war_ban` LIMIT {$pages->my_start()}, {$pages->items_per_page}");
while ($post = mysql_fetch_array($q)) {
$action = array();
$ank = new player($post['id_player']);
$list = $ank->name;
$link = "/dark_war/profil.php?id=" . $post['id_player'] . "";
$descrip = "Бан выдан " . misc::vremja($post['time_start']) . "<br />";
$descrip .= "Забанен до " . misc::vremja($post['time_end']);
$descrip .= "<br />" . $post['because'];
$action[] = array('link' => '?id='.$ank->id.'&uns_ban', 'name' => 'Разбанить');
$dispatch[] = array ('title' => $list, 'link' => $link, 'descrip' => $descrip, 'action' => $action);
}
$doc->assign('post', $dispatch);
$doc->display('view_list_plus_img.tpl');
$pages->listing("?"); // вывод страниц
echo "<br />";
$dispatch = array();
$doc->assign('method', 'post');
$doc->assign('action', null);
$dispatch[] = array('type' => 'textarea', 'name' => 'because', 'title' => 'Причина', 'br' => 1);
$dispatch[] = array('type' => 'text', 'name' => 'time', 'title' => 'Срок бана', 'br' => 1);
$options[] = array('m', 'Минуты');
$options[] = array('h', 'Часы');
$options[] = array('d', 'Дни');
$options[] = array('md', 'Месяцы');
$dispatch[] = array('type' => 'select', 'name' => 'timem', 'br' => 1, 'options' => $options);
$dispatch[] = array('type' => 'submit', 'name' => 'save', 'value' => 'Отправить', 'br' => 0);
$doc->assign('dis', $dispatch);
$doc->display('form.tpl');
?>