<?php
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/adm_check.php';
include_once '../sys/inc/user.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']='Нарушения '.$ank['nick'];
include_once '../sys/inc/thead.php';
title();
err();
aut();



function wtime($timediff){

$oneMinute=60;
$oneHour=60*60;
$oneDay=60*60*24;
$dayfield=floor($timediff/$oneDay);
$hourfield=floor(($timediff-$dayfield*$oneDay)/$oneHour);
$minutefield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour)/$oneMinute);
$secondfield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour-$minutefield*$oneMinute));
$time_1=" $dayfield д. $hourfield ч. $minutefield м. $secondfield c. ";
return $time_1;
}

################################################################################
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"));
}
################################################################################
$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'];
################################################################################
echo "<table class='post'>\n";
if ($k_post==0)
{echo "   <tr>\n";
echo "  <td class='p_t'>\n";	
echo "Нет нарушений!<br/>\n";
echo "  </td>\n";
echo "   </tr>\n";}
################################################################################
$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 "   <tr>\n";
if ($set['set_show_icon']==2){
echo "  <td class='icon48' rowspan='2'>\n";
avatar($ank2['id']);
echo "  </td>\n";
}
elseif ($set['set_show_icon']==1)
{
echo "  <td class='icon14'>\n";
echo "".status($ank2['id'])."";
echo "  </td>\n";
}
echo "  <td class='p_t'>\n";
echo "Выписал [BAN]\n";
echo " <a href='/info.php?id=$ank2[id]'>$ank2[nick]</a> ".online($ank2['id'])." <br/>Арест до (".vremja($post['time']).")<br />".wtime(time()-$post['time'])."<br />\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
if ($set['set_show_icon']==1)echo "  <td class='p_m' colspan='2'>\n"; else echo "  <td class='p_m'>\n";
echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['prich']))))))))."</b><br />\n";
echo "  </td>\n";
echo "   </tr>\n";
}
echo "</table>\n";
################################################################################
if ($k_page>1)str('?id='.$ank['id'].'&amp;',$k_page,$page);
################################################################################
echo "<table class='post'><tr><td class='p_t'><a href=\"/info.php?id=$ank[id]\">Назад на страничку</a><br /></td></tr></table>";
################################################################################
include_once '../sys/inc/tfoot.php';
?>