<?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;
}


if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' LIMIT 1"), 0) == 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']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `id_user` = '$ank[id]' AND `id` = '" . intval($_GET['unset']) . "'"), 0) && user_access('user_ban_unset')) {
    $ban_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `ban` WHERE `id_user` = '$ank[id]' AND `id` = '" . intval($_GET['unset']) . "'"));
    $ank2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$ban_info[id_ban]' LIMIT 1"));
}
aut();
err();

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `id_user` = '$ank[id]'"), 0);
$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 = mysql_query("SELECT * FROM `ban` WHERE `id_user` = '$ank[id]' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q)) {

    $ank2 = mysql_fetch_assoc(mysql_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';
