<?php

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

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

$id = isset($_GET['id']) ? abs((int) $_GET['id']) : NULL;
$inf = mysql_fetch_assoc(mysql_query("SELECT id,nick FROM `user` WHERE `id` = '$id' LIMIT 1"));

if (empty($inf['id'])) {
    header('location: /');
    die();
}
$set['title'] = 'История логинов ' . $inf['nick'];

require H . 'sys/inc/thead.php';

aut();

#Навигация
echo "<div class='list-group-item-null list-group-item-grey'><small>";
echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
echo "<a href='/id$inf[id]'>" . $inf['nick'] . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
echo lang('История логинов');
echo "</small></div><br />";

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `history_nick` WHERE `user_id` = '$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();
}
$sql = mysql_query("SELECT * FROM `history_nick` WHERE `user_id` = '$id' ORDER BY `id` DESC LIMIT $start,$set[p_str]");
while ($a = mysql_fetch_assoc($sql)) {
    echo "<div class='list-group-item-null' style='margin: 2px;'>";
    echo "<b class='btn btn-secondary btn-sm'>$a[nick_last] <i class='fa fa-chevron-right fa-fw'></i> $a[nick_new]</b><br />";
    echo user($a['who']) . " <small style='float: right;color: grey;'>" . date::times($a['time']) . "</small>";
    echo "</div>";
    echo "<div class='hr'></div>";
}
if ($k_page > 1) {
    str('?', $k_page, $page);
}
require_once H . 'sys/inc/tfoot.php';
