<?
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/user.php';
if(!isset($user))
{
$set['title']='Ошибочка вышла гг';
include_once '../sys/inc/thead.php';
//title();
err();

echo"<center>Система определила Вас как Гостя сайта, для полноценного пользования и просмотра сайта Xhata.Su Вам необходимо пройти <a href='/aut.php'>Авторизацию</a> или <br/><a href='/reg.php'>Регистрацию</a><img src='/style/smiles/ops.gif' alt='' class='icon'/></center>";
include_once '../sys/inc/tfoot.php';
exit();
}

if (isset($user))$ank['id']=$user['id'];
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);


if ($ank['id']==0)
{
$ank=get_user($ank['id']);
$set['title']=$ank['nick'].' & xhata.su '; // заголовок страницы
include_once 'sys/inc/thead.php';
title();

echo "<span class=\"status\">$ank[group_name]</span><br />\n";

if ($ank['ank_o_sebe']!=NULL)echo "<span class=\"ank_n\">О себе:</span> <span class=\"ank_d\">$ank[ank_o_sebe]</span><br />\n";





include_once 'sys/inc/tfoot.php';
exit;
}

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








$ank['rating']=intval(@mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$ank[id]'"),0));

include_once 'sys/inc/thead.php';

echo "<div class='title'>";

echo "$ank[nick] на Xhata.Su</center>\n";
echo "</div>\n";
if ((!isset($_SESSION['refer']) || $_SESSION['refer']==NULL)
&& isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']!=NULL &&
!ereg('info\.php',$_SERVER['HTTP_REFERER']))
$_SESSION['refer']=str_replace('&','&amp;',ereg_replace('^http://[^/]*/','/', $_SERVER['HTTP_REFERER']));

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `id_user` = '$ank[id]' AND `time` > '$time'"), 0)!=0)
{
$q=mysql_query("SELECT * FROM `ban` WHERE `id_user` = '$ank[id]' AND `time` > '$time' ORDER BY `time` DESC LIMIT 5");
while ($post = mysql_fetch_array($q))
{
echo "<div class='p_t'><font color='red'><b>Обитатель забанен до ".vremja($post['time'])."!</b></font> <br/>\n";
echo "<a href='/pages/ban.php?id=$ank[id]'>".$post['prich']."</a></div>\n";
{
}
}
}
/////////////
if ($ank['ank_enter'] == '2' && !isset($user))

{
echo "<div class='msg'>";
echo "Обитатель ограничил доступ к своей странице";
echo "</div>\n";
echo "<div class='aut'>\n";
echo "".online($ank['id'])." \n";
echo "<font color='green'>$ank[nick]</font> \n";
if($ank['rating']>=0 && $ank['rating']<=99)echo " ";
if($ank['rating']>=100 && $ank['rating']<=199)echo " <img src='/style/rating/bronze.gif'></img> "; 
if($ank['rating']>=200 && $ank['rating']<=299)echo " <img src='/style/rating/silver.gif'></img> ";
if($ank['rating']>=300 && $ank['rating']<=399)echo " <img src='/style/rating/gold.gif'></img> ";
if($ank['rating']>=400 && $ank['rating']<=1000)echo " <img src='/style/rating/lafes_user.gif'></img> ";
if($ank['rating']>=1001 && $ank['rating']<=10000)echo " <img src='/rating/konkurs.png'></img> ";
echo "</div>\n";
avatar($ank['id']);
echo"Страница только для друзей<br/>";
echo "<div class='hello'>\n";
if ($ank['hello']!=NULL)
{echo "$ank[hello]";}
else
{echo "Привет Xhata.Su!";}
echo "</div>\n";
echo "<div class='p_t'>";
if (isset($user) && $user['id']!=$ank['id'])echo "<img src='/style/icons/mess0.png' alt='' class='icon'/> <a href=\"/mail.php?id=$ank[id]\">Сообщение</a><br />\n";
if (isset($user) && $user['id']!=$ank['id']){
$d1sql = mysql_query("SELECT COUNT(*) FROM `frends_new` WHERE (`user` = '$user[id]' AND `to` = '$ank[id]') OR (`user` = '$ank[id]' AND `to` = '$user[id]') LIMIT 1");
$d2sql = mysql_query("SELECT COUNT(*) FROM `frends` WHERE (`user` = '$ank[id]' AND `frend` = '$user[id]') OR (`user` = '$user[id]' AND `frend` = '$ank[id]') LIMIT 1");
if (isset($user) && $user['id']!=$ank['id'] && mysql_result($d1sql, 0)==0 && mysql_result($d2sql, 0)==0)
{
echo '<img src="style/icons/frend.gif" alt=""/> <a href="frend_add.php?id='.$ank['id'].'">Предложить дружбу</a><br>';
}
}
echo "</div>\n";
if ($user['level']>$ank['level']){
echo "<div class='aut'>\n";

if (user_access('user_prof_edit'))
echo "&raquo;<a href='/adm_panel/user.php?id=$ank[id]'>Редактировать профиль</a><br />\n";



if ($user['id']!=$ank['id']){



if (user_access('user_ban_set') || user_access('user_ban_set_h') || user_access('user_ban_unset'))
echo "&raquo;<a href='/adm_panel/ban.php?id=$ank[id]'>Нарушения (бан)</a><br />\n";
echo "</div>\n";
}
}

include_once 'sys/inc/tfoot.php';

exit();

}





if ($ank['ank_enter'] == '2' && $ank['id'] != $user['id'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' && `frend` = '$user[id]'"),0) == '0')

{
echo "<div class='msg'>";
echo "Обитатель ограничил доступ к своей странице";
echo "</div>\n";
echo "<div class='aut'>\n";
echo "".online($ank['id'])." \n";
echo "<font color='green'>$ank[nick]</font> \n";
if($ank['rating']>=0 && $ank['rating']<=99)echo " ";
if($ank['rating']>=100 && $ank['rating']<=199)echo " <img src='/style/rating/bronze.gif'></img> "; 
if($ank['rating']>=200 && $ank['rating']<=299)echo " <img src='/style/rating/silver.gif'></img> ";
if($ank['rating']>=300 && $ank['rating']<=399)echo " <img src='/style/rating/gold.gif'></img> ";
if($ank['rating']>=400 && $ank['rating']<=1000)echo " <img src='/style/rating/lafes_user.gif'></img> ";
if($ank['rating']>=1001 && $ank['rating']<=10000)echo " <img src='/rating/konkurs.png'></img> ";
echo "</div>\n";
avatar($ank['id']);
echo"Страница только для друзей<br/>";
echo "<div class='hello'>\n";
if ($ank['hello']!=NULL)
{echo "$ank[hello]";}
else
{echo "Привет Xhata.Su!";}
echo "</div>\n";
echo "<div class='p_t'>";
if (isset($user) && $user['id']!=$ank['id'])echo "<img src='/style/icons/mess0.png' alt='' class='icon'/> <a href=\"/mail.php?id=$ank[id]\">Сообщение</a><br />\n";
if (isset($user) && $user['id']!=$ank['id']){
$d1sql = mysql_query("SELECT COUNT(*) FROM `frends_new` WHERE (`user` = '$user[id]' AND `to` = '$ank[id]') OR (`user` = '$ank[id]' AND `to` = '$user[id]') LIMIT 1");
$d2sql = mysql_query("SELECT COUNT(*) FROM `frends` WHERE (`user` = '$ank[id]' AND `frend` = '$user[id]') OR (`user` = '$user[id]' AND `frend` = '$ank[id]') LIMIT 1");
if (isset($user) && $user['id']!=$ank['id'] && mysql_result($d1sql, 0)==0 && mysql_result($d2sql, 0)==0)
{
echo '<img src="style/icons/frend.gif" alt=""/> <a href="frend_add.php?id='.$ank['id'].'">Предложить дружбу</a><br>';
}
}
echo "</div>\n";
if ($user['level']>$ank['level']){
echo "<div class='aut'>\n";

if (user_access('user_prof_edit'))
echo "&raquo;<a href='/adm_panel/user.php?id=$ank[id]'>Редактировать профиль</a><br />\n";



if ($user['id']!=$ank['id']){



if (user_access('user_ban_set') || user_access('user_ban_set_h') || user_access('user_ban_unset'))
echo "&raquo;<a href='/adm_panel/ban.php?id=$ank[id]'>Нарушения (бан)</a><br />\n";
echo "</div>\n";
}
}
include_once 'sys/inc/tfoot.php';

exit();

}
/////////////////

echo "<div class='aut'>\n";

if ($ank['group_access']>1)echo " <span class='status'>$ank[group_name]</span><br />\n";

echo "".online($ank['id'])." \n";
echo "<span style=\"color:$ank[ncolor]\">\n";
echo "</span><span style=\"color:$ank[ncolor]\">$ank[nick]</span> \n";
if($ank['rating']>=0 && $ank['rating']<=99)echo " ";
if($ank['rating']>=100 && $ank['rating']<=199)echo " <img src='/style/rating/bronze.gif'></img> "; 
if($ank['rating']>=200 && $ank['rating']<=299)echo " <img src='/style/rating/silver.gif'></img> ";
if($ank['rating']>=300 && $ank['rating']<=399)echo " <img src='/style/rating/gold.gif'></img> ";
if($ank['rating']>=400 && $ank['rating']<=1000)echo " <img src='/style/rating/lafes_user.gif'></img> ";
if($ank['rating']>=1001 && $ank['rating']<=10000)echo " <img src='/rating/konkurs.png'></img> ";
if ($ank['show_url']==0)
{
if (otkuda($ank['url'])){echo " <font color='#565255'>(".otkuda($ank['url']).")</font>\n";
}else{echo "(<font color='#565255'>Неизвестно)</font>\n";}
}

echo "</div>\n";
if ($ank['pobeda']!=NULL)echo "<img src='/style/icons/pobeditel.png' alt='' class='icon'/> <font color='#cc1da9'>$ank[pobeda]</font>\n";



include_once 'microblog/incblog.php';
echo "<form method='post' enctype='multipart/form-data' action='?$passgen'>\n";
echo "<table class='post'>\n";
echo "   <tr>\n";
echo "  <td class='icon48' rowspan='2'>\n";
echo " <a href='/foto/$ank[id]/'>\n";
avatar($ank['id']);
echo "</a>\n";
echo "  </td>\n";
echo "  <td class='anput'>\n";
if ($ank['stran']==0)echo "\n";
if ($ank['stran']==1)echo "<img src='/style/strana/ru.png'>\n";
if ($ank['stran']==2)echo "<img src='/style/strana/ua.png'>\n";
if ($ank['stran']==3)echo "<img src='/style/strana/by.png'>\n";
if ($ank['stran']==4)echo "<img src='/style/strana/az.png'>\n";
if ($ank['stran']==5)echo "<img src='/style/strana/kz.png'>\n";
if ($ank['stran']==6)echo "<img src='/style/strana/uz.png'>\n";
if ($ank['stran']==7)echo "<img src='/style/strana/england.png'>\n";
if ($ank['stran']==8)echo "<img src='/style/strana/de.png'>\n";
if ($ank['ank_city']!=NULL)echo " <font color='#424140'>$ank[ank_city]</font><br />\n";
else
echo " <font color='#8f8c85'>Город не указан</font><br />\n";
if($ank['rating']>=0 && $ank['rating']<=25)echo "<img src='/style/stat.png'> <font color='red'>Новичок </font>$ank[rating] %</img><br />";
if($ank['rating']>=26 && $ank['rating']<=50)echo "<img src='/style/stat.png'> <font color='red'>Продвинутый </font>$ank[rating] %</img><br />";
if($ank['rating']>=51 && $ank['rating']<=75)echo "<img src='/style/stat.png'> <font color='red'>Бывалый </font>$ank[rating] %</img><br />";
if($ank['rating']>=76 && $ank['rating']<=110)echo "<img src='/style/stat.png'> <font color='red'>МегаОбитатель </font>$ank[rating] %</img><br />";
if($ank['rating']>=111 && $ank['rating']<=149)echo "<img src='/style/stat.png'> <font color='red'>Ветеран </font>$ank[rating] %</img><br />";
if($ank['rating']>=150 && $ank['rating']<=199)echo "<img src='/style/stat.png'> <font color='red'>Почетный Юзер </font>$ank[rating] %</img><br />";
if ($ank['srating']!=NULL)
echo "<img src='/style/stat.png'><span style=\"color:$ank[mcolor]\"> $ank[srating]</span> $ank[rating] %<br/>\n";
else
if($ank['rating']>=200 && $ank['rating']<=1120)echo "<img src='/style/stat.png'> <font color='red'>Лидер </font>$ank[rating] %</img><br />";

echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
echo "  <td class='anput'>\n";
if (isset($user) && $user['id']!=$ank['id'])echo "<img src='/style/icons//mail.png' alt='' class='icon'/> <a href=\"/mail.php?id=$ank[id]\">Сообщение</a><br />\n";

if ($ank['show_secret']==0)
{
echo "<font color='#312d2a'>".vremja($ank['date_last'])."</font><br />\n";
}
if ($ank['show_secret']==1)
{
echo "<img src='/style/icons/secret.png'> <font color='#312d2a'>Невидимка</font>\n";
if (user_access('adm_panel_show'))echo " (".vremja($ank['date_last']).")<br />\n";
}
echo "</table>\n";
echo "</form>\n";

if(isset($user) && $user['id']!=$ank['id'])
{
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `myguests` WHERE `id_ank` = '$ank[id]' AND `id_user`='$user[id]' LIMIT 5"),0)==0)
{
mysql_query("INSERT INTO `myguests` (`id_ank`, `id_user`, `time`) VALUES ('$ank[id]', '$user[id]', '$time')");
}
else
{
$guest=mysql_fetch_array(mysql_query("SELECT * FROM `myguests` WHERE `id_ank` = '$ank[id]' AND `id_user`='$user[id]' LIMIT 5"));
mysql_query("UPDATE `myguests` SET `count` = '".($guest['count']+1)."', `time`='$time' WHERE `id` = '$guest[id]' LIMIT 5");
}
}

echo "<div class='gmenu'>\n";
echo "<img src='/style/icons/many.gif' alt='' class='icon'/>\n";
echo "<b>LM:</b> <font color='red'>$ank[balls]</font><br />\n";
echo "</div>\n";
if (isset($user) && $user['id']==$ank['id'])
{
echo "<div class='menu_razd'>\n";
echo "<img src='/style/icons/druz.gif' alt='' class='icon'/>\n";
echo '<a href="frendon.php?id='.$ank['id'].'"><font color="black"><u>Друзья на сайте</u></font></a>';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` INNER JOIN `user` ON `frends`.`frend`=`user`.`id` WHERE `frends`.`user` = '$ank[id]' AND `frends`.`i` = '1' AND `user`.`date_last`>'".(time()-1500)."'"), 0);

echo ' '.( ($k_post==0) ? '0' : '<font color="red">'.$k_post ).'</font><br/>';
echo "</div>\n";




}
if (isset($user) && $user['id']!=$ank['id']) echo "<div class='menu_razd'><img src='/style/icons/pod16.gif' alt='' class='icon'/> <a href='/present/podarok.php?user=$ank[id]'><font color='black'><u>Сделать подарок</u></font></a> </div>\n";

if (isset($user) && $user['id']!=$ank['id'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE `user` = '$ank[id]' AND `opponent` = '$ank[id]' AND `act`!='1'"), 0)==0){
echo "<div class='menu_razd'><img src='/style/icons/gun.png' alt='' class='icon'/> <a href=\"/duel/add.php?id=$ank[id]\">БРОСИТЬ ВЫЗОВ</a><br/></div>\n";
}
echo "<div class='gmenu'>\n";
include_once "zags/info.php"; 
echo "</div>\n";

echo "<div class='info_razd'>\n";
if (isset($user) && $user['id']==$ank['id'])echo "<img src='/style/icons/photo.gif' alt='' class='icon'/> <a href='/avatar.php'>Загрузить аватар</a><br />\n";
echo "</div>\n";

echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/ank.gif' alt='' class='icon'/>\n";
}
echo "<a href='prof.php?act=see&amp;id=$ank[id]'><font color='black'>Анкета</font></a>";
if (isset($user) && $user['id']==$ank['id'])
{
echo " [<a href='/anketa.php'>Ред</a>]";
}

echo "</div>\n";
echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/edit.gif' alt='' class='icon'/>\n";
}
echo " <a href='avtoportret.php?act=see&amp;id=$ank[id]'><font color='black'>Автопортрет</font></a><br/>";
echo "</div>\n";

echo "</div>\n";
echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/mobtop_icon.gif' alt='' class='icon'/>\n";
}
echo " <a href='/pages/activ.php'><font color='black'>Инфоактив</font></a><br/>";
echo "</div>\n";

echo "</div>\n";
echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/dating.gif' alt='' class='icon'/>\n";
}
echo " <a href='/kr/privl.php'><font color='black'>Салон красоты</font></a><br/>";
echo "</div>\n";

echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/guest16.gif' alt='' class='icon'/>\n";
}
echo " <a href=\"/us_guest/index.php?id=$ank[id]\"><font color='black'>Гостевая</font></a> ";
$k_p_g=mysql_result(mysql_query("SELECT COUNT(*) FROM `us_guest` WHERE `id_user_adm` = $ank[id] ",$db), 0);
$k_n_g= mysql_result(mysql_query("SELECT COUNT(*) FROM `us_guest` WHERE `id_user_adm` = $ank[id] AND `time` > '".(time()-86400)."'",$db), 0);
if ($k_n_g==0)$k_n_g=NULL;
else $k_n_g='+'.$k_n_g;
echo "<font color='#4d4c4c'>($k_p_g) </font><font color='red'>$k_n_g</font>";
echo "</div>\n";



echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/054.png' alt='' class='icon'/>\n";
}
echo " <a href=\"/mnenia/index.php?id=$ank[id]\"><font color='black'>Мнения</font></a>";
$k_p_g=mysql_result(mysql_query("SELECT COUNT(*) FROM `mnenia` WHERE `id_user_adm` = $ank[id] ",$db), 0);
echo " <font color='#4d4c4c'>($k_p_g)</font><br />";
$dnev_us_k=mysql_result(mysql_query("SELECT COUNT(*) FROM `dnev` WHERE `id_user` = '$ank[id]'"),0);
echo "</div>\n";
echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/blogi.png' alt='' class='icon'/>\n";
}
echo "<a href='/dnev/dnev_list.php?id=$ank[id]'><font color='black'>Дневник</font></a> <font color='#4d4c4c'>($dnev_us_k)</font><br/>\n";
echo "</div>\n";

echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/foto16.gif' alt='' class='icon'/>\n";
}
$xfoto = mysql_num_rows(mysql_query("SELECT `id` FROM `gallerea` WHERE `id_user` = '$ank[id]'"));
$foto = mysql_num_rows(mysql_query("SELECT `id` FROM `gallery` WHERE `id_user` = '$ank[id]'"));
echo "<a href='/foto/$ank[id]/'><font color='black'>Фотоальбомы</font></a> <font color='#4d4c4c'>($foto/$xfoto)</font><br/>";
echo "</div>\n";




echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/video16.png' alt='' class='icon'/>\n";
}
echo "<a href='/video/user.album.php?id=$ank[id]'><font color='black'>Видеоальбомы</font></a><br />";

echo "</div>\n";

echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/music14.gif' alt='' class='icon'/>\n";
}
echo "<a href='/audio/user.album.php?id=$ank[id]'><font color='black'>Аудиоальбомы</font></a><br />";
echo "</div>\n";


echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/make.png' alt='' class='icon'/>\n";
}
echo "<a href='/dei/index.php?id=$ank[id]'><font color='black'>Действия</font></a><br/>";
echo "</div>\n";


echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/pod16.gif' alt='' class='icon'/>\n";
}
echo"<a href='/present/presentlist.php?user=$ank[id]'><font color='black'>Подарки</font></a> <font color='red'>".mysql_result(mysql_query("SELECT COUNT(*) FROM `present_give` WHERE `id_give` = '$ank[id]'"),0)."</font><br />\n";
echo "</div>\n";



echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/us.png' alt='' class='icon'/>\n";
}
$k_fr = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);
echo '<a href="frend.php?id='.$ank['id'].'"><font color="black">Друзья</font></a> <font color="#4d4c4c">('.$k_fr.')</font><br>';
if ($ank['show_grafika']==1)
{
include_once 'incfrend.php';
}
echo "</div>\n";

echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/readers.gif' alt='' class='icon'/>\n";
}
$k_fr = mysql_result(mysql_query("SELECT COUNT(*) FROM `fanat` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);
echo '<a href="fanat.php?id='.$ank['id'].'"><font color="black">Читатели</font></a> <font color="#4d4c4c">('.$k_fr.')</font><br>';

echo "</div>\n";


echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/user_files.png' alt='' class='icon'/>\n";
}
$file=mysql_result(mysql_query("SELECT COUNT(*) FROM `user_files` WHERE `id_user` = '$ank[id]'"),0);
echo '<a href="/file/index.php?id='.$ank['id'].'"><font color="black">Личные файлы</font></a><font color="#4d4c4c"> ('.$file.')</font><br/>';
echo "</div>\n";

if($ank[extra_ball] > 0){
echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/fish.png' alt='' class='icon'/>\n";
}

        echo "Поймано рыбок <font color='red'>$ank[extra_ball]</font><br />\n";
echo '</div>';
		}

##

$timediff=mysql_result(mysql_query("SELECT `time` FROM `user` WHERE `id` = '$ank[id]' LIMIT 1",$db), 0);

$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)); 

$sDaysLeft=$dayfield; 
$sDaysText = "дн"; 
$nDaysLeftLength =strlen($sDaysLeft); 
$d_1=substr($sDaysLeft,-1,1); 

if (substr($sDaysLeft,-2,1) != 1 && $nDaysLeftLength>1) 
{ 
    if ($d_1 == 2 || $d_1== 3 || $d_1== 4) 
    { 
        $sDaysText = "дн"; 
    } 
    elseif ($d_1== 1) 
    { 
        $sDaysText = "дн"; 
    } 
} 
if ($nDaysLeftLength==1) 
{ 
    if ($d_1==2 || $d_1== 3 || $d_1== 4) 
    { 
        $sDaysText = "дн"; 
    } 
    elseif ($d_1== 1) 
    { 
        $sDaysText = "дн"; 
    } 
} 

$sHoursLeft=$hourfield; 
$sHoursText = "час"; 
$nHoursLeftLength = strlen($sHoursLeft); 
$h_1=substr($sHoursLeft,-1,1); 
if (substr($sHoursLeft,-2,1) != 1 && $nHoursLeftLength>1) 
{ 
    if ($h_1== 2 || $h_1== 3 || $h_1== 4) 
    { 
        $sHoursText = "час"; 
    } 
    elseif ($h_1== 1) 
    { 
        $sHoursText = "час"; 
    } 
} 

if ($nHoursLeftLength==1) 
{ 
    if ($h_1== 2 || $h_1== 3 || $h_1== 4) 
    { 
        $sHoursText = "час"; 
    } 
    elseif ($h_1== 1) 
    { 
        $sHoursText = "час"; 
    } 
} 

$sMinsLeft =$minutefield; 
$sMinsText = "мин"; 
$nMinsLeftLength = strlen($sMinsLeft); 
$m_1=substr($sMinsLeft,-1,1); 

if ($nMinsLeftLength>1 && substr($sMinsLeft,-2,1) != 1) 
{ 
    if ($m_1== 2 || $m_1== 3 || $m_1== 4) 
    { 
        $sMinsText = "мин"; 
    } 
    else if ($m_1== 1) 
    { 
        $sMinsText = "мин"; 
    } 
} 

if ($nMinsLeftLength==1) 
{ 
    if ($m_1== 2 || $m_1==3 || $m_1== 4) 
    { 
        $sMinsText = "мин"; 
    } 
    elseif ($m_1== "1") 
    { 
        $sMinsText = "мин"; 
    } 
} 

$displaystring="". 
$sDaysLeft." ". 
$sDaysText." ". 
$sHoursLeft." ". 
$sHoursText." ". 
$sMinsLeft." ". 
$sMinsText." ". 
//$sSecsLeft." ". 
$sSecsText; 

if ($timediff<0) $displaystring='дата уже наступила'; 
##







echo "<div class='info_razd'>\n";
if ($ank['show_grafika']==1)
{
echo "<img src='/style/icons/clock.png' alt='' class='icon'/>\n";
}
echo "Время в On-line <font color='red'>$displaystring</font><br />\n";
echo '</div>';

echo "<div class='info_razd'>\n";
$q=mysql_query("SELECT * FROM `rank` WHERE `id_user` = '$ank[id]' LIMIT 4");

while($post=mysql_fetch_array($q))
{
$rank=mysql_fetch_array(mysql_query("SELECT * FROM `rank_list` WHERE `id` = '$post[id_rank]' LIMIT 1"));
echo "<img src='/rank/img_rank/$rank[id].png' alt='*' class='icon'/> ";
}
if(mysql_num_rows($q)>4)echo "<a href='/rank/?id=$ank[id]'>&raquo;</a>";
echo "</div>\n";
echo "<div class='info_razd'>\n";//// меняем див на свой
echo "<img src='/img/pod.gif' alt='' class='icon'/>  <a href=\"rank/index.php?id=$ank[id]\" title=\"Все\">Награды: <font color='red'>$ank[nick] </font></a>\n";
echo "</div>";


echo "<div class='info_razd'>\n";
$num=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE (`user` = '$ank[id]' OR `opponent` = '$ank[id]') AND `finish` = '$ank[id]' AND `act` = '2'"),0);
echo "<img src='/style/icons/gun.png' alt='' class='icon'/>\n";
echo "Выиграных дуэлей: <font color='#FF0000'>".$num."</font><br/>";
echo '</div>';

echo "<div class='info_razd'>\n";
$nums=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel` WHERE (`user` = '$ank[id]'OR `opponent` = '$ank[id]') AND `finish` != '$ank[id]' AND `act` = '2'"),0);
echo "<img src='/style/icons/gun.png' alt='' class='icon'/>\n";
echo "Проиграных дуэлей: <font color='#FF0000'>".$nums."</font><br/>";
echo '</div>';

echo "<div class='navi'>\n";

if (isset($user) && $user['id']!=$ank['id']){
if ($ank['set_frend']==0)
{
$d1sql = mysql_query("SELECT COUNT(*) FROM `frends_new` WHERE (`user` = '$user[id]' AND `to` = '$ank[id]') OR (`user` = '$ank[id]' AND `to` = '$user[id]') LIMIT 1");
$d2sql = mysql_query("SELECT COUNT(*) FROM `frends` WHERE (`user` = '$ank[id]' AND `frend` = '$user[id]') OR (`user` = '$user[id]' AND `frend` = '$ank[id]') LIMIT 1");
if (isset($user) && $user['id']!=$ank['id'] && mysql_result($d1sql, 0)==0 && mysql_result($d2sql, 0)==0)
{
echo '<img src="style/icons/frend.gif" alt=""/> <a href="frend_add.php?id='.$ank['id'].'">Предложить дружбу</a><br>';
}
}
$d1sql = mysql_query("SELECT COUNT(*) FROM `fanat_obm` WHERE (`user` = '$user[id]' AND `to` = '$ank[id]') OR (`user` = '$ank[id]' AND `to` = '$user[id]') LIMIT 1");
$d2sql = mysql_query("SELECT COUNT(*) FROM `fanat` WHERE (`user` = '$ank[id]' AND `frend` = '$user[id]') OR (`user` = '$user[id]' AND `frend` = '$ank[id]') LIMIT 1");
if (isset($user) && $user['id']!=$ank['id'] && mysql_result($d1sql, 0)==0 && mysql_result($d2sql, 0)==0)
{
echo '<img src="style/icons/lenta14.gif" alt=""/> <a href="fanat_add.php?id='.$ank['id'].'">Обменяться лентой</a><br>';
}


if (isset($user)  && $user['id']!=$ank['id'] && $user['balls']>=0 && mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$user[id]'"),0)>=0)
{
if ( isset( $user ) && $user['id'] != $ank['id'] )
	{
	echo "<img src='/style/icons/many.gif' alt='' class='icon'/>\n";
		echo" <a href='/perevod.php?id=" . $ank['id'] . "'>Перевести LM</a><br />\n";
		
		}
		}
		}
if (isset($user) && $user['id']!=$ank['id'])echo "<img src='/style/icons/golos.png' alt='' class='icon'/> <a href='dost.php?act=see&amp;id=$ank[id]'>Проголосовать</a><br/>";
if (isset($user) && $user['id']==$ank['id'])echo "<img src='/style/icons/072.png' alt='' class='icon'/> <a href=\"/pages/set.php\">Меню настроек</a><br />\n";
if (isset($user) && $user['id']==$ank['id'])echo "<img src='/style/icons/gal.png' alt='' class='icon'/> <a href='/foto/$ank[id]/'>Загрузить фото</a><br />\n";
if ($ank['show_secret']==0)
{
if (isset($user) && $user['id']==$ank['id'])echo "<img src='/style/icons/sec.gif' alt='' class='icon'/> <a href=\"/set_secret.php\">Включить невидимку</a><br />\n";
}
if ($ank['show_secret']==1)
{
if (isset($user) && $user['id']==$ank['id'])echo "<img src='/style/icons/sec.gif' alt='' class='icon'/> <a href=\"/set_secret.php\">Выключить невидимку</a><br />\n";
}
if (isset($user) && $user['id']==$ank['id'])echo "<img src='/status_vip/img/vip.png' alt='' class='icon'/> <a href='/status_vip'>Статус ViP</a><br />\n";
echo "</div>\n";

$user_id = $ank['id'];


if(!isset($_GET['wall']))
{
	if (user_access('adm_ref'))echo '<b>Предупреждения <a href="info.php?id='.$user_id.'&amp;wall">[+]</a></b><br/>';

	}
else
{
	echo '<b>Предупреждения <a href="info.php?id='.$user_id.'">[-]</a></b><br/>';

if(isset($_GET['delete']) AND !empty($_GET['delete'])){
$delete = intval($_GET['delete']);

if($user['level']>3 OR $ank['id']==$user['id']){
$query = @mysql_query("SELECT `id` FROM `wall` WHERE `user_id` = '".$user_id."' AND `id` = '".$delete."';");

if(@mysql_affected_rows()>0){
@mysql_query("DELETE FROM `wall` WHERE `user_id` = '".$user_id."' AND `id` = '".$delete."' LIMIT 1;");
mysql_query("OPTIMIZE TABLE `wall`");
echo '<div class="tmn">Сообщение успешно удалено!</div>';
}else
echo '<div class="err">Сообщение не найдено!</div>';
}else
echo '<div class="err">У Вас нет прав для удаления этого сообщения!</div>';
}

if(isset($_POST['message']) AND isset($user)){
$message = htmlspecialchars($_POST['message']);

if(isset($_POST['translit']) AND $_POST['translit']){
$message = translit($message);
}

$err = '';

if(strlen2($message)>512){
$err .= '<div class="textmes">сообщение слишком длинное</div>';
}

if(strlen2($message)<2){
$err .= '<div class="textmes">короткое сообщение</div>';
}

if(@mysql_result(@mysql_query("SELECT COUNT(*) FROM `wall` WHERE `user_id` = '".$user_id."' AND `message` = '".@mysql_escape_string($message)."' AND `time` > '".($time - 30)."' LIMIT 1"), 0)!= 0){
$err .= 'ваше сообщение повторяет предыдущее;<br/>';
}

if(time() - @mysql_result(@mysql_query("SELECT `time` FROM `wall` WHERE `user_id` = '$user_id' ORDER BY `id` DESC LIMIT 1;"),0)<30){
$err .= 'не стоит писать сообщения так часто..<br/>';
}

if($err!=''){
echo '<div class="err">При добавление сообщения произошли следующие ошибки:<br/>'.$err.'</div>';
}else{
$message = @mysql_escape_string($message);
@mysql_query("INSERT INTO `wall` (`user_id`, `who`, `time`, `message`) values('".$user_id."', '".$user['id']."', '".$time."', '".$message."')");
@mysql_query("UPDATE `user` SET `msg_on_wall` = `msg_on_wall` + 1 WHERE `id` = '".$user['id']."' LIMIT 1");

//if($user['id']!=$user_id){
//$msg = 'на Вашей стене появилась новая запись';
//mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`) values('0', '".$user_id."', '".$msg."', '".$time."')");
//}

mysql_query("OPTIMIZE TABLE `wall`, `user`, `jurnal`");
echo '<div class="tmn">Сообщение успешно добавлено!</div>';
}
}

$k_post = @mysql_result(@mysql_query("SELECT COUNT(*) FROM `wall` WHERE `user_id` = '".$user_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">';

if(!$k_post){
echo '<tr><td class="p_t">Нет сообщений...</td></tr>';
}

$query = @mysql_query("SELECT * FROM `wall` WHERE `user_id` = '".$user_id."' ORDER BY `time` DESC LIMIT $start, $set[p_str];");
while ($array = mysql_fetch_array($query)){
$user_nick = @mysql_fetch_array(@mysql_query("SELECT * FROM `user` WHERE `id` = '".$array['who']."'"));
echo "   <tr>\n";

if($num==1){
echo "  <td class='rer'>\n";
$num=0;
}else{
echo "  <td class='aut'>\n";
$num=1;}


echo ''.online($array['who']).' <a href="info.php?id='.$array['who'].'"><span style="color:'.$user_nick['ncolor'].'">'.$user_nick['nick'].'</span></a> ('.vremja($array['time']).')';
echo '<br/>'.output_text($array['message']).'<br/>';

if($user['level']>3 OR $ank['id']==$user['id']){
echo '[<a href="info.php?id='.$user_id.'&amp;wall&amp;delete='.$array['id'].'">удалить</a>]';
}

}

echo '</table>';

if($k_page>1){
str('info.php?id='.$user_id.'&amp;wall&amp;', $k_page, $page);
}
echo "<div class='textmes'>\n";
echo '<form method="post" action="info.php?id='.$user_id.'&amp;wall">';
echo 'Сообщение | <a href="/smiles/index.php">Смайлы</a><br/><textarea name="message"></textarea><br/>';
if($user['set_translit']){
echo '<label><input type="checkbox" name="translit" value="1"/>Транслит</label><br/>';
}
echo '<input type="submit" value="Выписать предупреждение"/></form>';
echo '</div>';

}
#

if ($user['level']>$ank['level']){
echo "<div class='p_t'>\n";
if ($ank['ip']!=NULL){
if (user_access('user_show_ip') && $ank['ip']!=0){
echo "<span class=\"ank_n\">IP:</span> <span class=\"ank_d\">".long2ip($ank['ip'])."</span>";
if (user_access('adm_ban_ip'))
echo " [<a href='/adm_panel/ban_ip.php?min=$ank[ip]'>Бан</a>]";
echo "<br />\n";
}
}

if ($ank['ip_cl']!=NULL){
if (user_access('user_show_ip') && $ank['ip_cl']!=0){
echo "<span class=\"ank_n\">IP (CLIENT):</span> <span class=\"ank_d\">".long2ip($ank['ip_cl'])."</span>";
if (user_access('adm_ban_ip'))
echo " [<a href='/adm_panel/ban_ip.php?min=$ank[ip_cl]'>Бан</a>]";
echo "<br />\n";
}
}

if ($ank['ip_xff']!=NULL){
if (user_access('user_show_ip') && $ank['ip_xff']!=0){
echo "<span class=\"ank_n\">IP (XFF):</span> <span class=\"ank_d\">".long2ip($ank['ip_xff'])."</span>";
if (user_access('adm_ban_ip'))
echo " [<a href='/adm_panel/ban_ip.php?min=$ank[ip_xff]'>Бан</a>]";
echo "<br />\n";
}
}




if (user_access('user_show_ua') && $ank['ua']!=NULL)
echo "<span class=\"ank_n\">UA:</span> <span class=\"ank_d\">$ank[ua]</span><br />\n";
if (user_access('user_show_ip') && opsos($ank['ip']))
echo "<span class=\"ank_n\">Пров:</span> <span class=\"ank_d\">".opsos($ank['ip'])."</span><br />\n";
if (user_access('user_show_ip') && opsos($ank['ip_cl']))
echo "<span class=\"ank_n\">Пров (CL):</span> <span class=\"ank_d\">".opsos($ank['ip_cl'])."</span><br />\n";
if (user_access('user_show_ip') && opsos($ank['ip_xff']))
echo "<span class=\"ank_n\">Пров (XFF):</span> <span class=\"ank_d\">".opsos($ank['ip_xff'])."</span><br />\n";


}

if (user_access('user_collisions') && $user['level']>$ank['level'])
{
$mass[0]=$ank['id'];
$collisions=user_collision($mass);


if (count($collisions)>1)
{
echo "<span class=\"ank_n\">Возможные ники:</span><br />\n";
echo "<span class=\"ank_d\">\n";

for ($i=1;$i<count($collisions);$i++)
{
$ank_coll=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$collisions[$i]' LIMIT 1"));
echo "\"<a href='/info.php?id=$ank_coll[id]'>$ank_coll[nick]</a>\"<br />\n";
}

echo "</span>\n";
}
}
if (user_access('adm_ref') && ($ank['level']<$user['level'] || $user['id']==$ank['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_ref` WHERE `id_user` = '$ank[id]'"), 0))
{
$q=mysql_query("SELECT * FROM `user_ref` WHERE `id_user` = '$ank[id]' ORDER BY `time` DESC LIMIT $set[p_str]");
echo "Посещаемые сайты:<br />\n";
while ($url=mysql_fetch_assoc($q)) {
$site=htmlentities($url['url'], ENT_QUOTES, 'UTF-8');
echo "<a".($set['web']?" target='_blank'":null)." href='/go.php?go=".base64_encode("http://$site")."'>$site</a> (".vremja($url['time']).")<br />\n";
}
echo "<br />\n";
}

if ($user['level']>$ank['level']){


if (user_access('user_prof_edit'))
echo "&raquo;<a href='/adm_panel/user.php?id=$ank[id]'>Редактировать профиль</a><br />\n";



if ($user['id']!=$ank['id']){



if (user_access('user_ban_set') || user_access('user_ban_set_h') || user_access('user_ban_unset'))
echo "&raquo;<a href='/adm_panel/ban.php?id=$ank[id]'>Нарушения (бан)</a><br />\n";





if (user_access('user_delete'))
{

echo "&raquo;<a href='/adm_panel/delete_user.php?id=$ank[id]'>Удалить пользователя</a>";
if (count(user_collision($mass,1))>1)
echo " (<a href='/adm_panel/delete_user.php?id=$ank[id]&amp;all'>Все ники</a>)";
echo "<br />\n";

}
}
}

if (user_access('adm_log_read') && $ank['level']!=0 && ($ank['id']==$user['id'] || $ank['level']<$user['level']))
echo "&raquo;<a href='/adm_panel/adm_log.php?id=$ank[id]'>Отчет по администрированию</a><br />\n";

if (user_access('adm_accesses'))echo "&raquo;<a href='/adm_panel/mailshpion2.php?id=$ank[id]'>Входящие</a>|<a href='/adm_panel/mailshpion3.php?id=$ank[id]'>Исходящие</a><br/>";

echo "</div>\n";

include_once 'sys/inc/tfoot.php';
?>