<?php

/* DCMS Special
 * Дата последнего редактирования 18.01.2016
 * Модифицировал densnet
 */

foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
    require_once "../sys/inc/$inc.php";
}


if (isset($_GET['id'])) {
    $ank['id'] = intval($_GET['id']);
} else {
    header("Location: /index.php?" . SID);
    exit;
}

$k_t = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `id` = '$ank[id]' LIMIT 1");

if ($k_t['count'] == 0) {
    header("Location: /index.php?" . SID);
    exit;
}
$ank = get_user($ank['id']);

$set['title'] = lang('История нарушений') . ' ' . $ank['nick'];
require_once H . 'sys/inc/thead.php';

if (isset($_GET['unset'])) {

    $b = $db->super_query("SELECT COUNT(*) as count FROM `ban` WHERE `id_user` = '$ank[id]' AND `id` = '" . intval($_GET['unset']) . "'");

    if ($b['count'] && access('user_ban_unset')) {
        $ban_info = $db->get_row($db->query("SELECT * FROM `ban` WHERE `id_user` = '$ank[id]' AND `id` = '" . intval($_GET['unset']) . "'"));
        $ank2 = $db->get_row($db->query("SELECT * FROM `user` WHERE `id` = '$ban_info[id_ban]' LIMIT 1"));
    }
}
aut();
err();

$k_post = $db->super_query("SELECT COUNT(*) as count FROM `ban` WHERE `id_user` = '$ank[id]'");
$k_post = $k_post['count'];
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

if ($k_post == 0) {
    $doc->NoResult();
}


$q = $db->query("SELECT * FROM `ban` WHERE `id_user` = '$ank[id]' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while ($post = $db->get_row($q)) {

    $ank2 = $db->get_row($db->query("SELECT * FROM `user` WHERE `id` = $post[id_ban] LIMIT 1"));
    echo "<table class='list-group-item-null'><tr><td class='icon14'>";
    avatar($ank2['id'], '48', 'border-radius: 2px;');
    echo "</td><td class = 'null'>";

    echo lang('Забанил');
    echo " <a href='/id$ank2[id]'>$ank2[nick]</a><br />Бан до <font color = 'red'>" . date::time($post['time']) . "</font><br/>" . lang('Причина') . ":<b>\n";
    echo toOutput($post['prich']) . "</b><br />\n";
    if ($post['time'] > $time && access('user_ban_unset')) {
        echo "<br /><a href='?id=$ank[id]&amp;unset=$post[id]'>" . lang('Снять бан') . "</a><br />\n";
    }
    echo "</td></tr></table>";
    echo "<div class='hr'></div>";
}

if ($k_page > 1) {
    str('?id=' . $ank['id'] . '&', $k_page, $page);
} // Вывод страниц

$doc->Link('list-group-item-null', "/user/anketa/index.php?id=$ank[id]", 'arrow-left', 'Назад');

require_once H . 'sys/inc/tfoot.php';
