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

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

$ank = mysql_fetch_array($q);

$set['title'] = 'Список друзей '.$ank['nick'].'';
include_once 'sys/inc/thead.php';
title();




if (isset($_GET['add']))msg('Заявка на дружбу успешно отправлена!');
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);
echo '<center></img><div class="tmn"><img src="/style/icons/frends14.gif"></img> '.( ($k_post==0) ? 'Нет друзей =(' : 'Всего друзей: '.$k_post ).'</center></div>';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);

if ($k_post==0)
{
echo 'У обитателя '.$ank['nick'].' нет друзей';
}


$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'>\n";

$q = mysql_query("SELECT * FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1' ORDER BY time DESC LIMIT $start, $set[p_str]");
while ($f = mysql_fetch_array($q))
{
	$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[frend]' LIMIT 1"));


echo '<tr><td class="icon14">';
avatar3($a['id']);
if($num==1){
echo "  <td class='aut'>\n";
$num=0;
}else{
echo "  <td class='tf'>\n";
$num=1;}

echo "".online($a['id'])." \n";
echo '<a href="/info.php?id='.$a['id'].'"><span style=\"color:$ank[ncolor]\">'.$a['nick'].'</span></a>';
echo ' <a href="/mail.php?id='.$a['id'].'"><img src="/img/mail.gif"></img></a> ';
if ($a['show_url']==0)
{
    	if (otkuda($a['url'])){echo " (".otkuda($a['url']).")<br />\n";
}else{echo "(Неизвестно)<br />\n";}
		}
	if ($ank['id']==$user['id'])echo ' <a href="/frend_new.php?del='.$a['id'].'">[Удалить]</img></a>';
echo '</td></tr>';
	
}

echo "</table>";

if ($k_page>1)str('?id='.$ank['id'].'&amp;',$k_page,$page); // Вывод страниц
include_once 'sys/inc/tfoot.php';
?>