<?
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_level(4);
$set['title']='Рефералы'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
if (isset($_GET['act']) && $_GET['act']=='clear')
{
mysql_query('TRUNCATE TABLE `referals`');

msg("Список очищен");
}
aut();


$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `referals`"),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";

}
$q=mysql_query("SELECT * FROM `referals` ORDER BY `count` DESC LIMIT $start, $set[p_str]");
while ($ref = mysql_fetch_array($q))
{
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "URL: <a target='_blank' href='http://$ref[url]'>$ref[url]</a><br />\n";
echo "  </td>\n";
echo "   </tr>\n";
echo "   <tr>\n";
echo "  <td class='p_m'>\n";
echo "Переходов: $ref[count]<br />\n";
echo "Последний: ".vremja($ref['time'])."<br />\n";

echo "  </td>\n";
echo "   </tr>\n";
}
echo "</table>\n";
if ($k_page>1)str("?",$k_page,$page); // Вывод страниц
if ($user['level']>=3){
echo "<div class='foot'>\n";
echo "&laquo;<a href='?act=clear'>Очистить список</a><br />\n";
echo "&laquo;<a href='/adm_panel/'>В админку</a><br />\n";
echo "</div>\n";
}
include_once '../sys/inc/tfoot.php';
?>