<?
//antispaces! Зделано корпрацмею Breaking, а точнее делал yahan911//
//Косим под spaces.ru на зло//

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

only_reg();

$set['title'] = 'Antispaces/Друзья';
include_once 'sys/inc/thead.php';
title();
aut();


$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` > '".(time()-2500)."'"), 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 `user` WHERE `date_last` > '".(time()-2500)."' ORDER BY `date_last` DESC LIMIT $start, $set[p_str]");


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


if (isset($_GET['add']))msg('Заявка отправлена');
if ($ank['id']==$user['id'])
{
	echo '<div class="main"><div class="title"><b>Друзья</b><br/>';
}
else echo '<div class="p_t">Список друзей '.$ank['nick'].'</div>';

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);

echo '<div class="p_m">'.( ($k_post==0) ? 'Нет друзей =(' : '<span style="font-size: small">(Всего друзей: '.$k_post ).')</span></div></div>';


$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"));

	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 class="icon14">';
	echo '  </td>';
	}
	echo '  <td class="p_t">';
	echo '<a href="/info.php?id='.$a['id'].'"><span style="color:#79358c"><b>'.$a['nick'].'</b></span></a>'.online($a['id'])."\n";

		if ($a['balls']>=1000 && $a['balls']<=4999){echo "<img src='/img/medal_bronze.gif' alt=''/>";
}else
if ($a['balls']>=5000 && $a['balls']<=9999){echo "<img src='/img/medal_bronze.gif' alt=''/> <img src='/img/medal_silver.gif' alt=''/>";
}else{
if ($a['balls']>=10000)echo "<img src='/img/medal_bronze.gif' alt=''/> <img src='/img/medal_silver.gif' alt=''/> <img src='/img/medal_gold.gif' alt=''/>";}

	echo ' <a href="/ok.php?id='.$a[id].'">[i]</a>';
	echo ' <a href="/mail2/index.php?id='.$a[id].'"><img src="/images/mail.gif"/></a></a>';
	if ($ank['id']==$user['id'])echo ' <a href="frend_new.php?no='.$a['id'].'"><font color=red><b>x</b></font></a>';

    echo ' <span style="color:#209143;font-size:small">('.vremja($f['time']).')';




	echo '  </td>';
	echo '   </tr>';
	echo '   <tr>';

}


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

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


echo "<div class='main'><div class='row4'>Поиск юзера:<br/>\n";
echo "<form method=\"post\" action=\"/users.php?go\">";
echo '<input name="usearch" type="text" size="12"/><input type="submit" value="Go!"/>';
echo "<br/>\n";
echo '---------------</a>';
echo '<br /> <a href="/info.php">Домой</a>';

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