<?
# МОД ДРУЖБЫ ДЛЯ DCMS 6.x
# SimiX aka iNFERNO
# 4759229

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();


$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;}
$set['title'] = 'Друзья онлайн '.$ank['nick'].'';

$ank = mysql_fetch_array($q);

echo '<div class="p_t"><a href="/frend.php"> [Все друзья]</a></div>';

if (isset($_GET['add']))msg('Заявка отправлена');

$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` 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]");
while ($f = mysql_fetch_array($q))
{

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

if ($set['set_show_icon']==2){
echo '  <td class="icon48" rowspan="2">';
avatar($a['id']);
echo '  </td>';
}
elseif ($set['set_show_icon']==1)
{
echo '  </td>';
}


if($num==1){ 
echo "<div class='rowdown'>"; 
$num=0;
}else{ 
echo "<div class='rowup'>"; 
$num=1;}
echo "".online($a['id'])."<a href='/info.php?id=$a[id]'><span style=\"color:$a[color]\">$a[nick]</span></b></a><br>\n"; 






echo '<span class="ank_n">Посл. посещение:</span> <span class="ank_d">'.vremja($a['date_last']).'</span><br />'."\n";echo "</div>";

if ($ank['show_url']==1)
{
if (otkuda($ank['url']))echo "<span class=\"ank_n\">Находится:</span> <span class=\"ank_d\"><a href='$ank[url]'>".otkuda($ank['url'])."</a></span><br />\n";
}
echo '  </td>'."\n";
echo '   </tr>'."\n";
}

echo "</div>";

echo '</table>'."\n";

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

echo ' Заявок: '.mysql_result(mysql_query("SELECT COUNT(id) FROM `frends_new` WHERE `to` = '$ank[id]'"), 0);

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