<?

if (isset($user) && isset($_GET['status'])){
if ($user['id'] == $ank['id']){
echo '<div class="main">Статус [512 символов]</div>';
echo "<form action='/info.php?id=" . $ank['id'] . "' method=\"post\">";
echo "$tPanel<textarea type=\"text\" style='' name=\"status\" value=\"\"/></textarea><br /> \n";
echo "<input class=\"submit\" style='' type=\"submit\" value=\"Установить\" />\n";
echo " <a href='/info.php?id=$ank[id]'>Отмена</a><br />\n";
echo "</form>";
include_once 'sys/inc/tfoot.php';
exit;
}
}





echo "<div class='mess'>";
echo group($ank['id']) . " $ank[nick] ";
echo medal($ank['id']) . " " . online($ank['id']) . " ";



if ((user_access('user_ban_set') || user_access('user_ban_set_h') || user_access('user_ban_unset')) && $ank['id']!=$user['id'])
echo "<a href='/adm_panel/ban.php?id=$ank[id]'><font color=red>[Бан]</font></a>\n";
echo "</div>";



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


if (isset($user) && isset($_GET['like']) && $user['id']!=$ank['id'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `status_like` WHERE `id_status` = '$status[id]' AND `id_user` = '$user[id]' LIMIT 1"),0)==0){
mysql_query("INSERT INTO `status_like` (`id_user`, `id_status`) values('$user[id]', '$status[id]')");
}

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

echo "<div class='st_2'>";
if ($status['id']){
echo output_text($status['msg']) . ' <br><font style="font-size:11px; color:gray;">' . vremja($status['time']) . '</font>';
if ($ank['id']==$user['id'])echo " [<a href='?id=$ank[id]&amp;status'><img src='/style/icons/edit.gif' alt='*'> нов</a>]";
echo '<br />';
}
else if ($ank['id']==$user['id']){
echo "Ваш статус [<a href='?id=$ank[id]&status'><img src='/style/icons/edit.gif' alt='*'> ред</a>]";
}




 // Если статус установлен



if ($status['id']){
	echo " <a href='/user/status/komm.php?id=$status[id]'><img src='/style/icons/bbl4.png' alt=''/> " . mysql_result(mysql_query("SELECT COUNT(*) FROM `status_komm` WHERE `id_status` = '$status[id]'"),0) . " </a> ";
	$l=mysql_result(mysql_query("SELECT COUNT(*) FROM `status_like` WHERE `id_status` = '$status[id]'"),0);
if (isset($user) && $user['id']!=$ank['id'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `status_like` WHERE `id_status` = '$status[id]' AND `id_user` = '$user[id]' LIMIT 1"),0)==0){
	echo " <a href='/info.php?id=$ank[id]&amp;like'><img src='/style/icons/like.gif' alt='*'/> Класс!</a> • ";
	$like = $l;
}
else if(isset($user) && $user['id']!=$ank['id']){
	echo " <img src='/style/icons/like.gif' alt=''/> Вы и ";
	$like = $l-1;
}else{
	echo " <img src='/style/icons/like.gif' alt=''/> ";
	$like = $l;
} 
	echo "<a href='/user/status/like.php?id=$status[id]'> $like чел. </a>";
}



 /* Общее колличество статусов */



$st = mysql_result(mysql_query("SELECT COUNT(*) FROM `status` WHERE `id_user` = '$ank[id]'"),0);
if ($st > 0){
	echo "<img src='/style/icons/status.png'> <a href='/user/status/index.php?id=$ank[id]'>Все статусы</a> (" . $st . ")\n";
}
echo '</div>';
}






avatar_ank($ank['id']);
echo "</div>";


/*
========================================
Анкета
========================================
*/
echo '<div class="main_menu">';
echo "<img src='/style/icons/anketa.gif' alt='*' /> <a href='/user/info/anketa.php?id=$ank[id]'>Анкета</a> ";
if (isset($user) && $user['id']==$ank['id']){
echo "[<img src='/style/icons/edit.gif' alt='*' /> <a href='/user/info/edit.php'>ред</a>]";
}
echo '</div>';


/*
========================================
Друзья
========================================
*/

echo '<div class="main_menu">';
$k_f = mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `to` = '$ank[id]' LIMIT 1"), 0);
$k_fr = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);
$res = mysql_query("select `frend` from `frends` WHERE `user` = '$ank[id]' AND `i` = '1'");
echo "<img src='/style/icons/druzya.png' alt='*' /> ";
echo '<a href="/user/frends/?id='.$ank['id'].'">Друзья</a> ('.$k_fr.'</b>/';$i =0;
while ($k_fr = mysql_fetch_array($res)){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$k_fr[frend]' && `date_last` > '".(time()-600)."'"),0) != 0) $i++;
}
echo "<span style='color:green'><a href='/user/frends/online.php?id=".$ank['id']."'>$i</a></span>)";
if ($k_f>0 && $ank['id']==$user['id'])echo " <a href='/user/frends/new.php'><font color='red'>+$k_f</font></a>";

echo '</div>';



/*
========================================
Фото
========================================
*/
echo '<div class="main_menu">';
echo "<img src='/style/icons/foto.png' alt='*' /> ";
echo "<a href='/foto/$ank[id]/'>Фотографии</a> ";
echo "(" . mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_user` = '$ank[id]'"),0) . ")<br />";
echo '</div>';

/*
========================================
Блоги 
========================================
*/

echo '<div class="main_menu">';
$kol_dnev=mysql_result(mysql_query("SELECT COUNT(*) FROM `blog` WHERE `id_user` = '".$ank['id']."'"),0);
echo "<img src='/style/icons/zametki.gif' alt='*' /> ";
echo "<a href='/plugins/blog/user.php?id=$ank[id]'>Блог ".$ank["nick"]."</a> ($kol_dnev)<br />\n"; 
echo '</div>';


/*
========================================
Закладки
========================================
*/
echo '<div class="main_menu">';
$people=mysql_result(mysql_query("SELECT COUNT(id_user) FROM `mark_people` WHERE `id_user` = '" . $ank['id'] . "'"),0);
$foto = mysql_result(mysql_query("SELECT COUNT(id_user) FROM `mark_foto` WHERE `id_user` = '" . $ank['id'] . "'"),0);
$blog = mysql_result(mysql_query("SELECT COUNT(id_user) FROM `mark_notes` WHERE `id_user` = '" . $ank['id'] . "'"),0);
$zakladki = $people + $foto + $blog;

echo "<img src='/style/icons/fav.gif' alt='*' /> ";
echo "<a href='/user/bookmark/index.php?id=$ank[id]'>Закладки</a> ($zakladki)<br />\n";
echo '</div>';




/*
========================================
Сообщение
========================================
*/


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

/*
========================================
В друзья
========================================
*/
echo '<div class="main_menu">';
if ($frend_new==0 && $frend==0){
echo "<img src='/style/icons/druzya.png' alt='*'/> <a href='/user/frends/create.php?add=".$ank['id']."'>Добавить в друзья</a><br />\n";
}elseif ($frend_new==1){
echo "<img src='/style/icons/druzya.png' alt='*'/> <a href='/user/frends/create.php?otm=$ank[id]'>Отклонить заявку</a><br />\n";
}elseif ($frend==2){
echo "<img src='/style/icons/druzya.png' alt='*'/> <a href='/user/frends/create.php?del=$ank[id]'>Удалить из друзей</a><br />\n";
}
echo '</div>';


/*
========================================
В закладки
========================================
*/
echo '<div class="main_menu">';
	echo '<img src="/style/icons/fav.gif" alt="*" /> ';
	if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `mark_people` WHERE `id_user` = '" . $user['id'] . "' AND `id_people` = '" . $ank['id'] . "' LIMIT 1"),0) == 0)
		echo '<a href="?id=' . $ank['id'] . '&amp;fav=1">В закладки</a><br />';
	else
		echo '<a href="?id=' . $ank['id'] . '&amp;fav=0">Удалить из закладок</a><br />';
echo '</div>';
}



/*
========================================
Настройки
========================================
*/


if (isset($user) && $ank['id']==$user['id']){
echo '<div class="main_menu">';
echo "<img src='/style/icons/settings.png' alt='*' /> <a href=\"/user/info/settings.php\">Мои настройки</a>\n";
echo '</div>';
}




$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `blog` "),0);
$q=mysql_query("SELECT * FROM `blog` WHERE `id_user` = '$ank[id]' ORDER BY `time` DESC LIMIT 3");
if ($k_post==0)
{
echo "  <div class='mess'>\n";
echo "Нет записей\n";
echo "  </div>\n";
}


while ($post = mysql_fetch_assoc($q)){
$k_n= mysql_result(mysql_query("SELECT COUNT(*) FROM `blog` WHERE `id` = $post[id] AND `time` > '$ftime'",$db), 0);
$likes = mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_like` WHERE `like` = '1' AND `id_notes` = '".$post['id']."' LIMIT 1"),0);
$dir = mysql_fetch_assoc(mysql_query("SELECT * FROM `blog_dir` WHERE `id` = '".$post['id_dir']."' "));

echo "<div class='blog_name'><img src='/style/icons/dnev.png' alt='*'> ";
echo '<a href="/plugins/blog/list.php?id='.$post['id'].'">'.htmlspecialchars($post['name']).'</a></div>';

if($post['block'] == 1){
echo '<div class="err">Статья заблокирована</div>';
echo '<div class="mess">';
}else{
echo '<div class="mess">';
echo rez_text(htmlspecialchars($post['msg']))." <a href='/plugins/blog/list.php?id=$post[id]'>Читать далее...</a><br />"; 
}

if($post['mod'] == '0')echo '<br><font color=red>На модерации</font>';
echo "<br>".vremja($post['time'])."";
echo '<br>Раздел: <a href="/plugins/blog/dir.php?id='.$post['id_dir'].'">'.$dir['name'].'</a>';
echo '<span style="float:right"><img src="/style/icons/bbl5.png" alt="*"/> '.mysql_result(mysql_query("SELECT COUNT(*) FROM `blog_komm` WHERE `id_notes` = '$post[id]'"),0).' <img src="/style/icons/eye.png"/> '.$post['count'].' <img src="/style/icons/like.gif" alt="*" /> '.$likes.'</span></div>';

}



?>