<?
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) && !isset($_GET['id'])){header("Location: /index.php?".SID);exit;}
if (isset($user))$ank['id']=$user['id'];
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' LIMIT 1"),0)==0){header("Location: /index.php?".SID);exit;}
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));
$set['title']=$ank['nick'].' &amp; Mykz.NeT'; // заголовок страницы
include_once 'sys/inc/thead.php';
title();


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 (isset($access['user_voice']) && $user['id']!=$ank['id'] && $user['balls']>=50 && $user['rating']>=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_voice` WHERE `id_user` = '$user[id]' AND `id_kont` = '$ank[id]'"), 0)==0)
{
if (isset($_GET['rating']) && $_GET['rating']=='1'){
$msgrat1="[b]$user[nick][/b] Проголосовал за вашу страничку! Оценка на +1";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `konts` WHERE `id_user` = '$ank[id]' AND `id_kont` = '0'"), 0)==0)
{
mysql_query("INSERT INTO `konts` (`id_kont`, `id_user`, `time`) values('0', '$ank[id]', '$time')");
}
mysql_query("UPDATE `konts` SET `time` = '$time' WHERE `id_user` = '0' AND `id_kont` = '$ank[id]' OR `id_user` = '$ank[id]' AND `id_kont` = '0'");
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$msgrat1', '$time')");

mysql_query("UPDATE `user` SET `rating` = '".($ank['rating']+1)."' WHERE `id` = '$ank[id]' LIMIT 1",$db);
mysql_query("INSERT INTO `user_voice` (`id_user`, `id_kont`) values('$user[id]', '$ank[id]')",$db);
msg ('Ваш отзыв принят');
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));}


if (isset($_GET['rating']) && $_GET['rating']=='2'){
$msgrat2="[b]$user[nick][/b] Проголосовал за вашу страничку! Оценка на +2";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `konts` WHERE `id_user` = '$ank[id]' AND `id_kont` = '0'"), 0)==0)
{
mysql_query("INSERT INTO `konts` (`id_kont`, `id_user`, `time`) values('0', '$ank[id]', '$time')");
}
mysql_query("UPDATE `konts` SET `time` = '$time' WHERE `id_user` = '0' AND `id_kont` = '$ank[id]' OR `id_user` = '$ank[id]' AND `id_kont` = '0'");
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$msgrat2', '$time')");

mysql_query("UPDATE `user` SET `rating` = '".($ank['rating']+2)."' WHERE `id` = '$ank[id]' LIMIT 1",$db);
mysql_query("INSERT INTO `user_voice` (`id_user`, `id_kont`) values('$user[id]', '$ank[id]')",$db);
msg ('Ваш отзыв принят');
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));}


if (isset($_GET['rating']) && $_GET['rating']=='3'){
$msgrat3="[b]$user[nick][/b] Проголосовал за вашу страничку! Оценка на +3";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `konts` WHERE `id_user` = '$ank[id]' AND `id_kont` = '0'"), 0)==0)
{
mysql_query("INSERT INTO `konts` (`id_kont`, `id_user`, `time`) values('0', '$ank[id]', '$time')");
}
mysql_query("UPDATE `konts` SET `time` = '$time' WHERE `id_user` = '0' AND `id_kont` = '$ank[id]' OR `id_user` = '$ank[id]' AND `id_kont` = '0'");
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$msgrat3', '$time')");
mysql_query("UPDATE `user` SET `rating` = '".($ank['rating']+3)."' WHERE `id` = '$ank[id]' LIMIT 1",$db);
mysql_query("INSERT INTO `user_voice` (`id_user`, `id_kont`) values('$user[id]', '$ank[id]')",$db);
msg ('Ваш отзыв принят');
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));}



if (isset($_GET['rating']) && $_GET['rating']=='4'){
$msgrat4="[b]$user[nick][/b] Проголосовал за вашу страничку! Оценка на +4";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `konts` WHERE `id_user` = '$ank[id]' AND `id_kont` = '0'"), 0)==0)
{
mysql_query("INSERT INTO `konts` (`id_kont`, `id_user`, `time`) values('0', '$ank[id]', '$time')");
}
mysql_query("UPDATE `konts` SET `time` = '$time' WHERE `id_user` = '0' AND `id_kont` = '$ank[id]' OR `id_user` = '$ank[id]' AND `id_kont` = '0'");
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$msgrat4', '$time')");
mysql_query("UPDATE `user` SET `rating` = '".($ank['rating']+4)."' WHERE `id` = '$ank[id]' LIMIT 1",$db);
mysql_query("INSERT INTO `user_voice` (`id_user`, `id_kont`) values('$user[id]', '$ank[id]')",$db);
msg ('Ваш отзыв принят');
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));}


if (isset($_GET['rating']) && $_GET['rating']=='5'){
$msgrat5="[b]$user[nick][/b] Проголосовал за вашу страничку! Оценка на +5";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `konts` WHERE `id_user` = '$ank[id]' AND `id_kont` = '0'"), 0)==0)
{
mysql_query("INSERT INTO `konts` (`id_kont`, `id_user`, `time`) values('0', '$ank[id]', '$time')");
}
mysql_query("UPDATE `konts` SET `time` = '$time' WHERE `id_user` = '0' AND `id_kont` = '$ank[id]' OR `id_user` = '$ank[id]' AND `id_kont` = '0'");
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$msgrat5', '$time')");
mysql_query("UPDATE `user` SET `rating` = '".($ank['rating']+5)."' WHERE `id` = '$ank[id]' LIMIT 1",$db);
mysql_query("INSERT INTO `user_voice` (`id_user`, `id_kont`) values('$user[id]', '$ank[id]')",$db);
msg ('Ваш отзыв принят');
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));}
}


if (isset($_GET['info']) && $_GET['info']=='balls'){
msg ('Баллы, это валюта нашего сайт...<br/>
Каждое ваше сообщение, или иное действие во всех разделах сайта принесут вам баллы');
}

aut();

if ($ank['ban']>$time){echo "<span class=\"status\">Обитатель $ank[nick] Забанен</span><br />\n";
echo "<span class=\"ank_n\">Причина бана:</span> <span class=\"ank_d\">$ank[ban_pr]</span><br />\n";
}
else
{

if (isset($user) && $user['id']==$ank['id'])
{
echo "<div class='niz_menu'>\n";
echo "<a href=\"/mail.php\">Моя почта</a><br />\n";
echo "<a href='/settings.php'>Настройки</a><br/>\n";
echo "</div>\n";
}

if (isset($user) && $user['id']==$ank['id']){
}else{
echo "".online($ank['id'])." \n";
echo "$ank[nick]\n";
echo "".adm($ank['id'])."<br/>";
}

if (isset($user) && $user['id']==$ank['id'])echo "Приветствие:\n";
echo "<span class=\"privet\">\n";
if (isset($user) && $user['id']==$ank['id'])echo "<a href='/privet.php'>\n";
if ($ank['privet']!=NULL)echo esc(trim(br(bbcode(links(stripcslashes(htmlspecialchars($ank['privet'])))))))."\n";
else
echo "Всем привет\n";
if (isset($user) && $user['id']==$ank['id'])echo "<img src=\"/sys/img/pen.gif\" alt=\"\"/></a>\n";
echo "</span>\n";

echo "<br/>\n";
avatar($ank['id']);
if (isset($user) && $user['id']==$ank['id'])echo "<br/><a href='/avatar.php'>Настроить логотип</a>\n";


echo "<br/>\n";

if (isset($user) && $user['id']==$ank['id'])echo "<img src=\"/sys/img/info.gif\" alt=\"\"/> <a href='/meinfo.php'>Анкета\n";
else echo "<img src=\"/sys/img/info.gif\" alt=\"\"/> <a href='/ank.php?id=$ank[id]'>Анкета</a>\n";
if (isset($user) && $user['id']==$ank['id'])echo "<img src=\"/sys/img/pen.gif\" alt=\"\"/></a>\n";
echo "<br/>\n";

$k_fr = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);
echo '<img src="sys/img/friends.gif" alt=""/> <a href="frend.php?id='.$ank['id'].'">Друзья</a> ('.$k_fr.')<br>';

$comm = mysql_num_rows(mysql_query("SELECT `id` FROM `community_user_incomm` WHERE `uid` = '$ank[id]'"));
echo '<img src="sys/img/soo.gif" alt="" class="icon"/> <a href="comm/user.php?id='.$ank['id'].'">Сообщества</a> ('.$comm.')<br/>';

$opdirbase=@opendir(H.'sys/add/info');
while ($filebase=@readdir($opdirbase))
if (eregi('\.php$',$filebase))
include_once(H.'sys/add/info/'.$filebase);

if (isset($user) && $user['id']==$ank['id']){
if(mysql_result(mysql_query("select count(`id`) from `blogs_title` where `uid`='".$_SESSION['id_user']."';"),'count')==0){if(isset($user)) echo "<img src='/sys/img/blogs.gif' alt=''/> <a href=\"blogs.php?act=addblog\">Создать дневник</a><br>";}
else{
echo "<img src='/sys/img/blogs.gif' alt=''/> <a href=\"blogs.php?act=see&amp;id=$ank[id]\">Дневник</a>";
echo " (".mysql_result(mysql_query("select count(`id`) from `blogs` where `uid`='".$ank['id']."';"),'count');
echo ")</b><br/>";
}}

if (isset($user) && $user['id']!=$ank['id']){
echo "<img src='/sys/img/blogs.gif' alt=''/> <a href=\"blogs.php?act=see&amp;id=$ank[id]\">Дневник</a>";
echo " (".mysql_result(mysql_query("select count(`id`) from `blogs` where `uid`='".$ank['id']."';"),'count');
echo ")</b><br/>";}

echo "<img src=\"/sys/img/guest.gif\" alt=\"\"/> <a href=\"us_guest/?id=$ank[id]\">Гостевая</a>";
echo ' (';@include H.'us_guest/count.php';echo ')<br />';



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="sys/img/friendship.gif" alt=""/> <a href="frend_add.php?id='.$ank['id'].'">Предложить дружбу</a><br>';
}
if (isset($user) && $user['id']!=$ank['id'])echo "<img src=\"/sys/img/privat.gif\" alt=\"\"/> <a href=\"/mail.php?id=$ank[id]\">Написать в приват</a><br />\n";
}


echo "<img src=\"/sys/img/rating.gif\" alt=\"r\"/> <a href=\"/users.php?sort=rating\">Рейтинг:</a> ";
echo "$ank[rating]<br/>";
if (isset($user) && isset($access['user_voice']) && $user['id']!=$ank['id'] && $user['balls']>=50 && $user['rating']>=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `user_voice` WHERE `id_user` = '$user[id]' AND `id_kont` = '$ank[id]'"), 0)==0)
{
echo "<a href=\"/info.php?id=$ank[id]&amp;rating=1\" title=\"+1\">+1</a>|";
echo "<a href=\"/info.php?id=$ank[id]&amp;rating=2\" title=\"+2\">+2</a>|";
echo "<a href=\"/info.php?id=$ank[id]&amp;rating=3\" title=\"+3\">+3</a>|";
echo "<a href=\"/info.php?id=$ank[id]&amp;rating=4\" title=\"+4\">+4</a>|";
echo "<a href=\"/info.php?id=$ank[id]&amp;rating=5\" title=\"+5\">+5</a><br>";
}


if (isset($user) && $user['id']==$ank['id'])
{
echo "<div class='niz_menu'>\n";
echo "Мои баллы: $ank[balls] <a href='?info=balls'>[?]</a><br />\n";
echo "<a href='/accesses.php?id=$ank[id]'>Мои привилегии</a><br />";
echo "<a href='/pages/secure.php'>Сменить пароль</a><br/>";
echo "</div>\n";
}
else
{
echo "<div class='niz_menu'>\n";
//echo "Страничка просмотрена: $ank[k_s_info] раз(а)<br />\n";
echo "Посл. посещение: ".vremja($ank['date_last'])."<br />\n";
echo "Регистрация: ".vremja($ank['date_reg'])."<br />\n";
echo "</div>\n";
}}

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