<?

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';
$set['title'] = 'Друзья на сайте';


include_once '../../sys/inc/thead.php';
title();
aut();



if(!isset($user)){
echo '<div class="err">Для гостей доступ к сайту закрыт, поэтому зарегистрируйтесь, или войдите под своим логином и паролем</div>';
}else{


only_reg();


$anks['id'] = $user['id'];
if (isset($_GET['id']))$anks['id'] = intval($_GET['id']);



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

$anks = mysql_fetch_array($q);
if ($anks['id']==$user['id'])
{
$k_po = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$anks[id]' AND `i` = '1'"), 0);
$k_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` INNER JOIN `user` ON `frends`.`frend`=`user`.`id` WHERE `frends`.`user` = '$anks[id]' AND `frends`.`i` = '1' AND `user`.`date_last`>'".(time()-600)."'"), 0);
$k_f = mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `to` = '$anks[id]' LIMIT 1"), 0);
echo '<div class="foot"><a href="/user/frends/frend.php">Друзья</a> ('.$k_po.') | <b>На сайте</b> ('.$k_p.') | <a href="/user/frends/frend_new.php">Приглашения дружить</a> ('.$k_f.')</div>';
}

$k_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$anks[id]' AND `i` = '1'"), 0);
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` INNER JOIN `user` ON `frends`.`frend`=`user`.`id` WHERE `frends`.`user` = '$anks[id]' AND `frends`.`i` = '1' AND `user`.`date_last`>'".(time()-600)."'"), 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">'."\n";
if ($k_post==0)
{
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Ваших друзей сейчас нет на сайте\n";
echo "  </td>\n";
echo "   </tr>\n";
echo '</table>'."\n";
}
$q = mysql_query("SELECT * FROM `frends` INNER JOIN `user` ON `frends`.`frend`=`user`.`id` WHERE `frends`.`user` = '$anks[id]' AND `frends`.`i` = '1' AND `user`.`date_last`>'".(time()-600)."' ORDER BY `user`.`date_last` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_assoc($q))
{
//$ank=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
$ank=get_user($post['frend']);

echo "   <tr>\n";
echo "<table>";
if ($set['set_show_icon']==2){
echo "  <td class='icon48'>\n";
avatar($ank['id']);
echo "  </td>\n";
}
elseif ($set['set_show_icon']==1)
{
echo "  <td class='icon14'>\n";
echo "".status($ank['id'])."";
echo "  </td>\n";
}
echo "  <td class='p_t'>\n";
echo'<a href="/info.php?id='.$ank['id'].'">'.$ank['nick']. '</a>'.medal($ank['id']).' '.online($ank['id']).' ('.(($ank['pol']==1)?'М':'Ж').')';
if (user_access('user_ban_set') || user_access('user_ban_set_h') || user_access('user_ban_unset')){
echo " <a href='/adm_panel/v_otsos.php?id=$ank[id]'><b><font color=\"#ff0000\">[ai]</font></b></a> ";}
if ($anks['id']==$user['id'])echo ' <a href="frend_new.php?del='.$ank['id'].'"><img src="/style/icons/delete.gif" alt="*" /></a>';

echo "  </td>\n";
echo "   </tr>\n";
echo "</table>";

echo '<table class="post">'."\n";
echo "   <tr>\n";

echo "  <td class='p_m'>\n";
echo " <a href=\"/mail.php?id=$ank[id]\"><img src='/style/icons/pochta.gif' alt='*' /> Написать сообщение</a> \n";
echo'('.vremja($post['time']).')';
echo "  </td>\n";
echo "   </tr>\n";

}

if ($k_page>1)str("?id=$ank[id]&",$k_page,$page); // Вывод страниц

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