<?

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($_GET['id']))$sid = intval($_GET['id']);

else $sid = $user['id'];

$ank = get_user($sid);



$set['title']="Друзья онлайн $ank[nick]"; // заголовок страницы

include_once '../../sys/inc/thead.php';

title();

aut();

echo "<div id='comments' class='menus'>";

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

echo "<a href='index.php?id=$ank[id]'>Все (".mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0).")</a>";

echo "</div>"; 



echo "<div class='webmenu last'>";

echo "<a href='online.php?id=$ank[id]' class='activ'>Онлайн (".mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` INNER JOIN `user` ON `frends`.`frend`=`user`.`id` WHERE `frends`.`user` = '$ank[id]' AND `frends`.`i` = '1' AND `user`.`date_last`>'".(time()-600)."'"), 0).")</a>";

echo "</div>"; 

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

{

echo "<div class='webmenu last'>";

echo "<a href='new.php'>Заявки (".mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `to` = '$ank[id]' LIMIT 1"), 0).")</a>";

echo "</div>"; 

}

echo "</div>";



$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` INNER JOIN `user` ON `frends`.`frend`=`user`.`id` WHERE `frends`.`user` = '$ank[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'];

$q = mysql_query("SELECT * FROM `frends` INNER JOIN `user` ON `frends`.`frend`=`user`.`id` WHERE `frends`.`user` = '$ank[id]' AND `frends`.`i` = '1' AND `user`.`date_last`>'".(time()-600)."' ORDER BY `user`.`date_last` DESC LIMIT $start, $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";

}

while ($frend = mysql_fetch_assoc($q))

{

$frend=get_user($frend['frend']);

echo "   <tr>\n";



if ($set['set_show_icon']==2){

echo "  <td class='icon48' rowspan='2'>\n";

avatar($frend['id']);

echo "  </td>\n";

}

elseif ($set['set_show_icon']==1)

{

echo "  <td class='icon14'>\n";

echo "".status($frend['id'])."";

echo "  </td>\n";

}

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

echo " ".group($frend['id'])." <a href='/info.php?id=$frend[id]'>$frend[nick]</a>\n";

echo "".medal($frend['id'])." ".online($frend['id'])." ";

echo "  </td>\n";

echo "   </tr>\n";

echo "   <tr>\n";

if ($set['set_show_icon']==1)echo "  <td class='p_m' colspan='2'>\n"; else echo "  <td class='p_m'>\n";

echo " <a href=\"/mail.php?id=$frend[id]\"><img src='/style/icons/pochta.gif' alt='*' /> Сообщение</a>\n";

echo "  </td>\n";

echo "   </tr>\n";

}

echo "</table>\n";



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



include_once '../../sys/inc/tfoot.php';

?>