<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$title->SetTitle('Дата-центр - Бан-лист');
$title->GetHeader();

if ($b['level'] == 0) {
header('location:/');
die();
}
echo '<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: <a href="/administration/"style="text-decoration:none; color:white;"> Дата-центр</a> :: Бан-лист</div></div></div>';
if (isset($_GET['x'])) {
$bb = DB::$dbs->query("SELECT * FROM ban WHERE id = ?", [abs((int)$_GET['x'])]);
if ($bb -> rowCount() == 0) {
header('location:/');
die();
}
$ba = $bb -> fetch();
DB::$dbs->query("DELETE FROM ban WHERE id =
?", [$ba['id']]);
header('location: ?');
die();
}
if (isset($_GET['unban'])) {
echo '<div class="list-group-item media">Действительно разбанить?<br/><a href="?x='.abs((int)$_GET['unban']).'">Да</a> | <a href="?">Нет</a></div>';
$title->GetMenu();
$title->GetFooter();
die();
}
$look = DB::$dbs -> querySingle("SELECT COUNT(id) FROM ban");
$num = 10;
$k_page = k_page($look, $num);
$page = page($k_page);
$start = $num*$page-$num;
if ($look==0) {
echo '<div class="alert alert-danger" role="alert">Пусто...</div>';
} else {
$sql = DB::$dbs->query("SELECT * FROM ban ORDER BY id DESC LIMIT $start,$num");
while ($arr = $sql -> fetch()) {
echo '<div class="list-group-item media">'.Nick($arr['who_ban']).'  забанил '.Nick($arr['user_ban']).'<br/>Причина: <b>'.$arr['text'].'</b><br/>Дата бана: <b>'.vr($arr['dateban']).'</b> <br/>Дата освобождения: <b>'.date('d.m.y в H:i', $arr['timeban']).'</b><br/>Действия: '.($b['level']>4 ? '<a href="?unban='.$arr['id'].'">[Разбанить]</a> <a href="ban.php?do=red&id='.$arr['id'].'">[Изменить]</a>':NULL).'</div>';
}
}
if ($k_page>1) {
str('?', $k_page, $page);
}

$title->GetMenu();
$title->GetFooter();
?>