<?

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; 2girls.su'; // заголовок страницы



$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']."'");

$set['title'] = $ank['nick'].' &amp; '.$_SERVER['HTTP_HOST'];



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($_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/>

Каждое ваше сообщение, или иное действие во всех разделах сайта принесут вам баллы');

}



aut();

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

{

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

echo "<span class='ank_n'>ID:</span> <span class='ank_d'>$ank[id]</span><br />\n";

if ($ank['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'])." <span style=\"color:$ank[ncolor]\">$ank[nick]</span></a>".adm($ank['id'])."<br />\n";

if ($ank['privet']!=NULL)echo esc(trim(br(bbcode(links(stripcslashes(htmlspecialchars($ank['privet'])))))))."\n";

else

echo "Всем привет\n";

echo "</span>\n";

echo "<br/>\n";

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



avatar($ank['id']);



echo "<br/>\n";



if($ank['rating']>=0 && $ank['rating']<=20)echo "<img src='/rating/rank1.gif'></img><br />"; 

if($ank['rating']>=21 && $ank['rating']<=40)echo "<img src='/rating/rank2.gif'></img><br />";

if($ank['rating']>=41 && $ank['rating']<=60)echo "<img src='/rating/rank3.gif'></img><br />";

if($ank['rating']>=61 && $ank['rating']<=80)echo "<img src='/rating/rank4.gif'></img><br />";

if($ank['rating']>=81 && $ank['rating']<=100)echo "<img src='/rating/rank5.gif'></img><br />";

if($ank['rating']>=101 && $ank['rating']<=120)echo "<img src='/rating/rank6.gif'></img><br />";

if($ank['rating']>=121 && $ank['rating']<=140)echo "<img src='/rating/rank7.gif'></img><br />";

if($ank['rating']>=141 && $ank['rating']<=160)echo "<img src='/rating/rank8.gif'></img><br />";

if($ank['rating']>=161 && $ank['rating']<=180)echo "<img src='/rating/rank9.gif'></img><br />";

if($ank['rating']>=181 && $ank['rating']<=200)echo "<img src='/rating/rank10.gif'></img><br />";



echo "<br/>\n";



echo "<img src=\"/sys/img/info.gif\" alt=\"\"/> <a href='/ank.php?id=$ank[id]'>Анкета</a>\n";



echo "<br/>\n";

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

echo "<img src=\"/sys/img/my_guest.gif\" alt=\"\"/> <a href=\"my_guest.php\" title=\"Мои гости\">Мои гости</a><br/>\n";

}

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 />';

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



$k_fr = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);



$comm = mysql_num_rows(mysql_query("SELECT `id` FROM `community_user_incomm` WHERE `uid` = '$ank[id]'"));



$opdirbase=@opendir(H.'sys/add/info');

while ($filebase=@readdir($opdirbase))

if (eregi('\.php$',$filebase))

include_once(H.'sys/add/info/'.$filebase);



$opdirbase=@opendir(H.'sys/add/info1');

while ($filebase=@readdir($opdirbase))

if (eregi('\.php$',$filebase))

include_once(H.'sys/add/info1/'.$filebase);



echo "<img src='/sys/img/file.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>\n";

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

{

$jn=mysql_result(mysql_query("SELECT COUNT(*) FROM `jurnal` WHERE `id_kont` = '$user[id]' AND `read` = '0'"), 0);

}

echo "<img src=\"/sys/img/soo.gif\" alt=\"\"/> <a href=\"comm/user.php?id=$ank[id]\">Сообщества</a><br />";

////////вывод подарков ujdag.ru/tagirkent.ru

echo"<table class='post'>";

echo"<td class='p_t'>";

echo "<small>Подарки/<a href=\"gifts.php?id=$ank[id]\" title=\"Все\">Все</a></small>\n";

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

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



$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gifts` WHERE `id_user` = '$ank[id]' LIMIT 1"), 0);



if ($k_post==0)

{

echo '<sub>нет подарков</sub>';

}



$q = mysql_query("SELECT * FROM `gifts` WHERE `id_user` = '$ank[id]' ORDER BY time DESC LIMIT 4");

while ($f = mysql_fetch_array($q))

{

$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[ot_id]' LIMIT 1"));

echo"<img src='/gifts/".$f['id_gifts'].".gif' width='32' height='32'  alt='' class='icon'/></hr>";

}

echo'  </td>

   </tr>

</table>';

/////////ujdag.ru/tagirkent.ru



/////////ujdag.ru/tagirkent.ru

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

echo "<img src='sys/img/gifts.gif' alt='' class='icon'/><a href=\"podarki/gifts.php?id=$ank[id]&pod=1\">Подарить подарок</a><br />";

/////////

echo"<table class='post'>";

echo"<td class='p_t'>";

echo "<small>Награды/<a href=\"rank.php?id=$ank[id]\" title=\"Все\">Все награды</a></small>\n";

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

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



$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `rank` WHERE `id_user` = '$ank[id]' LIMIT 1"), 0);



if ($k_post==0)

{

echo '<sub> Oбитатель '.$ank['nick'].' не награждался</sub>';

}



$q = mysql_query("SELECT * FROM `rank` WHERE `id_user` = '$ank[id]' ORDER BY time DESC LIMIT 4");

while ($f = mysql_fetch_array($q))

{

$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[ot_id]' LIMIT 1"));

echo"<img src='/rank/".$f['id_rank'].".gif' width='20' height='32'  alt='' class='icon'/></hr>";

}

echo'  </td>

   </tr>

</table>';

/////////

/////////

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

echo "<img src='sys/img/medal.gif' alt='' class='icon'/><a href=\"medals/rank.php?id=$ank[id]&pod=1\">Наградить юзера</a><br />";}

////////

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

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




if ($k_new!=0 && $k_new_fav==0)

echo "<b><a href='/new_mess.php'>Нов".($k_new==1?'о':'ы')."е сообщени".($k_new==1?'е':"я ($k_new)")."</a></b> <img src='/style/icons/mess0.png' /><br />\n";

if ($k_new_fav!=0)

echo "<b><a href='/new_mess.php'>Сообщени".($k_new_fav==1?'е':'я')."</a></b> <img src='/style/icons/mess_fav.png' alt='$k_new_fav' /><br />\n";

if (isset($user) && $user['id']==$ank['id'])echo "<img src=\"/sys/img/privat.gif\" alt=\"\"/> <a href='/konts.php'>Моя почта</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `users_konts` WHERE `id_user` = '$user[id]' AND (`type` = 'common' OR `type` = 'favorite')"), 0).")<br />\n";



echo "<img src='sys/img/jurnal.gif' alt='' class='icon'/> <a href=\"/jurnal.php\" title=\"Журнал\">Журнал</a>\n";   if ($jn>0) echo "(+$jn)\n";   echo "<br/>\n";


//========================
if($user[id]==$ank[id]) {
 echo "<img src='sys/img/onl.gif' alt='' class='icon'/><a href='/lenta.php'>Лента друзей</a> ";
$lenta = mysql_result(mysql_query("SELECT COUNT(*) FROM `lenta` WHERE `id_kont` = '$user[id]' AND `read` = '0' "),0);
if($lenta>0) { echo "<b>+$lenta</b>"; }
echo "<br/>";
}
//=========================



echo '<img src="sys/img/friends.gif" alt=""/> <a href="frend.php?id='.$ank['id'].'">Друзья</a> ('.$k_fr.')<br>';



if (isset($user) && $user['id']==$ank['id'])echo "<img src=\"/sys/img/settings.gif\" alt=\"\"/> <a href='/settings.php'>Настройки</a><br/>\n";

# ---------------------------------------------------------------------------------- Стена:



# 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['wall']))

{

	echo '<div class="menu"><b><a href="info.php?id='.$user_id.'&amp;wall">[+] Стена</a></b></div>';

}

else

{

	echo '<div class="menu"><b><a href="info.php?id='.$user_id.'">[-] Стена</a></b></div>';



	# Удаление сообщений:

	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 .= '&nbsp;&nbsp;сообщение слишком длинное;<br/>';

		if(strlen2($message) < 2) $err .= '&nbsp;&nbsp;короткое сообщение;<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 .= '&nbsp;&nbsp;ваше сообщение повторяет предыдущее;<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 .= '&nbsp;&nbsp;не стоит писать сообщения так часто..<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 class="p_t">

					<a href="info.php?id='.$array['who'].'">'.$user_nick.'</a> '.online($array['who']).' ('.vremja($array['time']).')

				</td>

			</tr>

			<tr>

				<td class="p_m" colspan="2">

					'.esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($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

		'

				</td>

			</tr>

		';

	}



	echo '</table>';



	if($k_page > 1) str('info.php?id='.$user_id.'&amp;wall&amp;'.rand(1000, 9999).'&amp;', $k_page, $page);



	echo '<div>';



	echo

	'

		<form method="post" action="info.php?id='.$user_id.'&amp;wall">

			Сообщение?<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>';

	echo '</div>';



	echo '<div class="menu"><b><a href="info.php?id='.$user_id.'">[-] Стена</a></b></div>';



	echo '<!-- (C)oded by i0n1x -->';

}

# ---------------------------------------------------------------------------------- ;





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 '<b>Страничка просмотрена</b>: '.$ank['k_s_info'].' раз(а)<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>";

///////

echo "<a href=\"/info.php?id=$ank[id]&amp;rating=-1\" title=\"-1\"><font color='red'>-1</font></a>|";

echo "<a href=\"/info.php?id=$ank[id]&amp;rating=-2\" title=\"-2\"><font color='red'>-2</font></a>|";

echo "<a href=\"/info.php?id=$ank[id]&amp;rating=-3\" title=\"-3\"><font color='red'>-3</font></a>|";

echo "<a href=\"/info.php?id=$ank[id]&amp;rating=-4\" title=\"-4\"><font color='red'>-4</font></a>|";

echo "<a href=\"/info.php?id=$ank[id]&amp;rating=-5\" title=\"-5\"><font color='red'>-5</font></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 "</div>\n";

}

else

{

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





echo "</div>\n";

}}



include_once 'sys/inc/tfoot.php';

?>

