<?
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 (isset($user))$ank['id']=$user['id'];if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
else{
if (isset($_GET['u']))$arr['nick']=$_GET['u'];
$nick=mysql_real_escape_string($arr['nick']);
$res=mysql_query("SELECT id FROM user WHERE nick='$nick';");
if($row=mysql_fetch_assoc($res))$ank['id']=$row['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']=Dues/$ank['nick'].''; // заголовок страницы
$set['title']='Dues.H2M.Ru/'.$ank[nick].'';
if (isset($_GET['frend']) && $_GET['frend']=='del')

{if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' LIMIT 1"),0)==0){header("Location: index.php?");exit;}

mysql_query("DELETE FROM `frends` WHERE `user` = '$user[id]' AND `frend` = '$ank[id]' LIMIT 1");


mysql_query("DELETE FROM `frends` WHERE `user` = '$ank[id]' AND `frend` = '$user[id]' LIMIT 1");

mysql_query("DELETE FROM `frends_new` WHERE `user` = '$ank[id]' AND `to` = '$user[id]' LIMIT 1");

mysql_query("DELETE FROM `frends_new` WHERE `user` = '$user[id]' AND `to` = '$ank[id]' LIMIT 1");

mysql_query("OPTIMIZE TABLE `frends`");

mysql_query("OPTIMIZE TABLE `frends_new`");

$msg2="К сожалению, обитатель [b]$user[nick][/b] удалил вас из списка друзей!";

mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$msg2', '$time')");

msg ('Обитатель успешно удален из списка ваших друзей');
}

if (isset($_GET['frend']) && $_GET['frend']=='add'){

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' LIMIT 1"),0)==0){header("Location: index.php?".SID);exit;}

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE (`user` = '$user[id]' AND `frend` = '$ank[id]') OR (`user` = '$ank[id]' AND `frend` = '$user[id]') LIMIT 1"),0)==1){header("Location: index.php?".SID);exit;}

if (mysql_result(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"),0)==1){header("Location: index.php?".SID);exit;}

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

mysql_query("INSERT INTO `frends_new` (`user`, `to`, `time`) values('$user[id]', '$ank[id]', '$time')");

mysql_query("OPTIMIZE TABLE `frends_new`");


msg ('Ваше предложение дружбы отправлено обитателю '.$ank['nick'].'');
}
$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");



$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '".$ank['id']."' LIMIT 1"));
mysql_query("UPDATE `user` SET `k_s_info` = '".($ank['k_s_info']+1)."' WHERE `id` = '".$ank['id']."'");

include_once 'sys/inc/thead.php';



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('&','&',ereg_replace('^http://[^/]*/','/', $_SERVER['HTTP_REFERER']));



if (isset($_POST['rating']) && isset($user)  && $user['id']!=$ank['id'] && $user['balls']>=50 && mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$user[id]'"),0)>=0)
{
$new_r=min(max(@intval($_POST['rating']),-2),2);
mysql_query("DELETE FROM `user_voice2` WHERE `id_user` = '$user[id]' AND `id_kont` = '$ank[id]' LIMIT 1");
mysql_query("INSERT INTO `user_voice2` (`rating`, `id_user`, `id_kont`) VALUES ('$new_r','$user[id]','$ank[id]')");
$ank['rating']=intval(mysql_result(mysql_query("SELECT SUM(`rating`) FROM `user_voice2` WHERE `id_kont` = '$ank[id]'"),0));
mysql_query("UPDATE `user` SET `rating` = '$ank[rating]' WHERE `id` = '$ank[id]' LIMIT 1");
msg('Ваше мнение о пользователе успешно изменено');
}

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


if (isset($user) && $user['id']!=$ank['id'])
echo "</div>\n";
{
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `my_guest` WHERE `id_user` = '$ank[id]' AND `id_guest` = '$user[id]'"), 0)==0)
{
mysql_query("INSERT INTO `my_guest` (`id_user`, `id_guest`, `time`) values('$ank[id]', '$user[id]', '$time')",$db);
}
mysql_query("UPDATE `my_guest` SET `time` = '$time' WHERE `id_user` = '$ank[id]' AND `id_guest` = '$user[id]'");
}
////////ujdag.ru/tagirkent.ru
aut();
//header("Refresh: 1; url=/info.php?id=$ank[id]".SID);


if ($user['ban']>$time){echo "<span class=\"status\">Обитатель $ank[nick]</span><br />\n";
echo "Этот аккаунт был заблокирован за нарушение</span> <a href='/rules.php'>условий использования сервиса<a><div/>\n";
}
else
{
if (isset($user) && $user['id']==$ank['id']){
}else{
}

echo "".online($ank['id'])." <font color='#79358c'>$ank[nick]</font>\n";

if($ank['balls']>=3000 && $ank['balls']<=6000)echo "<img src='/img/medal_bronze.gif' alt='' class='icon'</a>";if($ank['balls']>=6000 && $ank['balls']<=9000)echo "<img src='/img/medal_silver.gif' alt='' class='icon'</a>";if($ank['balls']>=9000 && $ank['balls']<=900000)echo "<img src='/img/medal_gold.gif' alt='' class='icon'</a>";

if (otkuda($ank['url'])){echo "(".otkuda($ank['url'])."</a>)\n";}else{echo "\n";}
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_assoc($q))echo "<font color='red'><br>Этот аккаунт временно заблокирован за нарушения правил</font><br>Забанен до ".vremja($post['time'])." </font>\n";echo "<span class='ank_d'>".output_text($post['prich'])."</span><br>\n";echo "<img src='/img/ank.gif' alt='' class='icon'/>\n";echo "<a href='/ank.php?id=$ank[id]'>Анкета</a><br/>\n";}}else{{
echo "<br>$ank[ank_naz]<br>";

echo "</span>\n";


echo "<div class='status border3all'>";




echo "<span style='color:green'>";
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 "</span>";
echo "</div><div class='status-img'></div></span>\n";


echo "<br />";
if ($set['set_show_icon']==1){
}
elseif ($set['set_show_icon']==1)
echo "  </td>\n";
{
echo " <a href='/ava/?id=$ank[id]'>";

if(is_file("sys/avatar/$ank[id].gif")){
echo "<img src='/sys/avatar/$ank[id].gif''>\n";
}else if(is_file("sys/avatar/$ank[id].jpg")){
echo "<img src='/sys/avatar/$ank[id].jpg''>\n";
}else if(is_file("sys/avatar/$ank[id].png")){
echo "<img src='/sys/avatar/$ank[id].png''>\n";
}else{
echo '<img src="/sys/avatar/0.png" >';}
}
echo "</a><br/>\n";
echo"<table class='post'>";
echo"<td class='p_t'>";


include_once 'present/priz.php';

if ($k_post==0){
echo '<sub></sub>';
}
else {echo "<a href=\"/present/presentlist.php?user=$ank[id]\" title=\"подарки\">>></a>";}
echo "</td></table>";

if (isset($user) && $user['id']!=$ank['id'])
if (isset($user) && $user['id']==$ank['id']){
}}
echo "<img src='/img/ank.gif' alt='' class='icon'/>\n";
echo "<a href='/ank.php?id=$ank[id]'>Анкета</a><br/>\n";
echo "<img src='/img/us_guest.gif' alt='' class='icon'/>\n";
echo "<a href=\"/us_guest/index.php?id=$ank[id]\">Гостевая</a>";
$k_p_g=mysql_result(mysql_query("SELECT COUNT(*) FROM `us_guest` WHERE `id_user_adm` = $ank[id] ",$db), 0);

echo " ($k_p_g)<br/>";

$dnev=mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_list` WHERE `id_user` = $ank[id] ",$db), 0);
echo "<img src='/img/diary.gif' alt='' class='icon'/>\n";
echo "<a href='/blog/user.php?id=$ank[id]'>Дневник</a>";
echo " ($dnev)";

$zakl=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_zakl` WHERE `id_user` = $ank[id] ",$db), 0);
if (isset($user) &&$user['id']==$ank['id'])
{





$zakl=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_zakl` WHERE `id_user` = $ank[id] ",$db), 0);


echo "<br />";
echo '<img src="/i/star_fav.gif" alt=""/> ';
echo '<a href="/zakl.php?id='.$ank['id'].'">Закладки</a>';
echo "($zakl)";
}
echo "<br />";
$k_fr = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);
echo '<img src="/i/friends.gif" alt=""/> ';

echo '<a href="/frend.php?id='.$ank['id'].'">Друзья</a>('.$k_fr.'</b>/';$i =0;
$res = mysql_query("select `frend` from `frends` WHERE `user` = '$ank[id]' AND `i` = '1'");
while ($k_fr = mysql_fetch_array($res)){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$k_fr[frend]' && `date_last` > '".(time()-800)."'"),0) != 0) $i++;
}
echo "<span style='color:green'>$i</span>)<br />";

$comm = mysql_num_rows(mysql_query("SELECT `id` FROM `community_user_incomm` WHERE `uid` = '$ank[id]'"));
echo "<img src='/img/soo.gif' alt='' class='icon'/>\n";
echo '<a href="/comm/user.php?id='.$ank['id'].'">Сообщества</a> ('.$comm.')<br/>';
if (isset($user) &&$user['id']==$ank['id'])
{
echo "<img src='/i/Swords_Icon.gif' alt='' /> <a href='/igra.php'>Мои Игры</a> \n";
echo "(2)<br />";
}
echo "<div class='blueline'>";

$foto = mysql_num_rows(mysql_query("SELECT `id` FROM `gallery` WHERE `id_user` = '$ank[id]'"));

echo "<img src='/img/foto.gif' alt='' class='icon'/>\n";

echo "<a href='/foto/$ank[id]/'>Фото</a> ($foto)<br/>";


echo "<img src='/i/file_mp3.gif' alt='' /> <a href='/music/'>Музыка</a> \n";
echo "(82410)<br /> ";
echo "<img src='/img/film.gif' alt='' /> <a href='/my/files.php?id=$ank[id]'>Файлы</a> \n";

echo "(".mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `id_user` = '$ank[id]'"),0).")<br/>";

echo "</div>";


echo"<img src=\"/i/sendgift.gif\" alt=\"\"/> <a href='/present/presentlist.php?user=$ank[id]'>Мои подарки</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `present_give` WHERE `id_give` = '$ank[id]'"),0).")</span><br />\n";






















}



















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

$my_guest=mysql_result(mysql_query("SELECT COUNT(*) FROM `my_guest` WHERE `id_user` = $ank[id] ",$db), 0);
echo "<img src='/img/my_guest.gif' alt='' class='icon'/>\n";

echo "<a href=\"/myguest.php\" title=\"Мои читатели\">Мои читатели</a>\n";

echo "($my_guest)<br>";

}

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




echo "<div class=foot>";
echo "<img src='/img/settings.gif'></img>";

echo "<a href='/umenu.php'>Мои настройки</a>";
}

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


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

echo "<img src='/i/sendgift.gif' alt='' class='icon'/><a href=\"/present/present.php?user=$ank[id]\">Cделать подарок</a><br />";



}
if(isset($user)){}

if (isset($user) && $user['id']!=$ank['id'] && mysql_result($d1sql, 0)==0 && mysql_result($d2sql, 0)==0){
if (isset($user) && $user['id']!=$ank['id']) echo '<img src="/img/friendship.gif" alt="" class="icon"/><a href="/info.php?id='.$ank['id'].'&frend=add">Предложить дружбу</a>';

echo "</div>";
}else{

}
if (isset($user) && ($user['level']>$ank['level'] || $user['level']==4))



echo "</div>";
echo "</font>";

}if($user['level']>1){

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

if ($ank_ban['time']>$time){

echo '<br><img src="/img/star.gif" alt="" class="icon"/><a href="/adm_panel/ban.php?id='.$ank['id'].'&act=del">Снять бан</a><br/>';

}else{



}}}

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' AND `date_last` > '".(time()-3000)."' LIMIT 1"),0)==1){}

# SQL запросы в базу данных для создания нужных таблиц:
@mysql_query("CREATE TABLE IF NOT EXISTS `wall` (`id` INT( 6 ) NOT NULL AUTO_INCREMENT , `user_id` INT( 6 ) NOT NULL , `who` INT( 6 ) NOT NULL , `time` INT( 11 ) NOT NULL , `message` TEXT NOT NULL , PRIMARY KEY ( `id` ) , INDEX ( `user_id` ));");
@mysql_query("ALTER TABLE `user` ADD `msg_on_wall` INT( 6 ) DEFAULT '0' NOT NULL ;");

$user_id = $ank['id'];

if(!isset($_GET['walllllllll']))
{
}
else
{

# Удаление сообщений:
if(isset($_GET['delete']) AND !empty($_GET['delete']))
{
$delete = (int)$_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;");

echo '<div class="news">Сообщение успешно удалено!</div>';
}
else
echo '<div class="news">Сообщение не найдено!</div>';
}
else
echo '<div class="news">У Вас нет прав для удаления этого сообщения!</div>';
}

# Добавление сообщений:
if(isset($_POST['message']) AND isset($user))
{
$message = $_POST['message'];

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

$err = '';

if(strlen2($message) > 512) $err .= 'ffсообщение слишком длинное;<br/>';
if(strlen2($message) < 2) $err .= 'ffкороткое сообщение;<br/>';
if(@mysql_result(@mysql_query("SELECT COUNT(*) FROM `wall` WHERE `user_id` = '$user_id' AND `message` = '".@mysql_escape_string($message)."' AND `time` > '".($time - 300)."' LIMIT 1"), 0) != 0) $err .= 'ffваше сообщение повторяет предыдущее;<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 .= 'ffне стоит писать сообщения так часто..<br/>';

if($err != '')
{
echo '<div class="news">При добавление сообщения произошли следующие ошибки:<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."')");
}
echo '<div class="news">Сообщение успешно добавлено!</div>';
}
}

# Вывод сообщений:
echo '<div class="rekl_main">';

$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>';
}

function getAvatar($id)
{
global $set;

if(is_file(H."sys/avatar/$id.gif"))
return "<img src='/sys/avatar/$id.gif' alt='' />\n";
elseif (is_file(H."sys/avatar/$id.jpg"))
return "<img src='/sys/avatar/$id.jpg' alt='' />\n";
elseif (is_file(H."sys/avatar/$id.png"))
return "<img src='/sys/avatar/$id.png' alt='' />\n";
else
return "<img src='/style/themes/$set[set_them]/user.png' alt='' />\n";
}


//$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_result(@mysql_query("SELECT `nick` FROM `user` WHERE `id` = '".$array['who']."';"), 0);

echo '<tr>';

if($set['set_show_icon'] == 2)
{
//echo '<td class="icon48" rowspan="2">'.getAvatar($array['who']).'</td>';
}
if($set['set_show_icon'] == 1)
{
//echo '<td class="icon14"><img src="/style/themes/'.$set['set_them'].'/user/'.$ank['pol'].'.png" alt=""/></td>';
}

echo
'
</td>
</tr>
<tr>
';

{
}

echo
'
</td>
</tr>
';
}

echo '</table>';


echo '<div>';

echo
'
';


echo
'
</form>
';

echo '</div>';
echo '</div>';


}
# ---------------------------------------------------------------------------------- ;






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