<?php

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

require_once 'sys/inc/start.php';
require_once 'sys/inc/compress.php';
require_once 'sys/inc/sess.php';
require_once 'sys/inc/settings.php';
require_once 'sys/inc/db_connect.php';
require_once 'sys/inc/ipua.php';
require_once 'sys/inc/fnc.php';

$banpage = true;

require_once 'sys/inc/user.php';

only_reg();

$set['title'] = 'БАН';

require_once 'sys/inc/thead.php';

aut();
err();

if (!isset($user)) {
    header("Location: /index.php?" . SID);
    exit;
}

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `id_user` = '" . $user['id'] . "' AND (`time` > '$time' OR `view` = '0')"), 0) == 0) {
    header('Location: /index.php?' . SID);
    exit;
}

mysql_query("UPDATE `ban` SET `view` = '1' WHERE `id_user` = '" . $user['id'] . "'"); // увидел причину бана

echo "<div class='list-group-item'>";
echo "Вы забанены!";
echo "</div>";

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `id_user` = '" . $user['id'] . "'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];

$q = mysql_query("SELECT * FROM `ban` WHERE `id_user` = '" . $user['id'] . "' ORDER BY `time` DESC LIMIT $start, " . $set['p_str'] . "");
while ($post = mysql_fetch_assoc($q)) {
    $ank = get_user($post['id_ban']);

    echo "<table class='list-group-item'><tr><td class='icon14'>\n";
    avatar($ank['id'], '48', 'border-radius: 2px;');
    echo "</td><td class='null'>\n";
    echo "$ank[nick]: до " . date::time($post['time']) . "\n";

    echo "<br />";
    echo toOutput($post['prich']);
    echo "</td></tr></table>";
}

if ($k_page > 1) {
    echo "<div class='list-group-item'>";
    str('?', $k_page, $page);
    echo "</div>";
}

echo "<div class='list-group-item'>\n";
echo "Чтобы больше не возникало подобных ситуаций, рекомендуем Вам изучить <a href=\"/info/rules.php\">правила</a> нашего сайта<br />\n";
echo "</div>\n";

require_once 'sys/inc/tfoot.php';

