File size: 5.89Kb
<?
if (!defined('SECURED'))
{
die("Unknown Error!");
}
include'includes/func_pages.php';
include'includes/func_formatsize.php';
$id = intval($_GET['id']);
$for = ($_GET['for']=='files' ? 'files' : 'users');
$type = (in_array($_GET['type'], array(1,2,3,4,5)) ? $_GET['type'] : 1);
if($for=='files')
{
title('ТОП-100 файлов по разделам');
div('ТОП-100 файлов по разделам','b');
echo'<img src="images/up.gif" alt="[UP]"/><a href="'.$_SERVER['PHP_SELF'].'?'.SID.'">На главную</a><br/>';
echo $separator;
$q=mysql_query("select * from categorys where parent='0' order by position;");
while($category=mysql_fetch_array($q))
{
$text='<img src="images/dir.gif" alt="[DIR]"/> ';
$text.='<a href="'.$_SERVER['PHP_SELF'].'?mode=top&for='.$for.'&id='.$category['id'].'&'.SID.'">'.$category['name'].'</a><br/>';
if($category['id']==$id) $text="<b>$text</b>";
echo $text;
}
if(!empty($id))
{
echo $separator;
$base_url=$_SERVER['PHP_SELF']."?mode=top&for=$for&id=$id";
$num_items=mysql_result(mysql_query("select count(id) from files where refcat='$id';"),0);
if($num_items>100) $num_items=100;
$pages = ceil($num_items/$config['files_on_page']);
if(!empty($_REQUEST['page']))
{
$page = intval($_REQUEST['page']);
if($page<=0) $page=1;
if($page>=$pages) $page=$pages;
} else
{
$page = 1;
}
$start = $page * $config['files_on_page'] - $config['files_on_page'];
$max=$start+$config['files_on_page'];
if($max>$num_items) $max=$num_items;
$total_files = $start + 1;
if($num_items==0) $total_files=0;
echo '<b>Файлы '.$total_files.'-'.$max.' из '.$num_items.'</b><br/>';
echo $separator;
$q=mysql_query("select * from files where refcat='$id' order by downloads desc limit $start,".$config['files_on_page'].";");
while($file=mysql_fetch_array($q))
{
echo '• <a href="'.$_SERVER['PHP_SELF'].'?mode=file&id='.$file['id'].'&'.SID.'">'.basename($file['filename']).'</a> ('.$file['downloads'].' скачиваний)<br/>';
echo '» '.$file['desc'].'<br/>';
}
$page_links=pages($base_url, $pages, $page);
if(!empty($page_links)) echo $separator.$page_links;
}
} else
{
title('ТОП-100 юзеров');
div('ТОП-100 юзеров','b');
echo'<img src="images/up.gif" alt="[UP]"/><a href="'.$_SERVER['PHP_SELF'].'?'.SID.'">На главную</a><br/>';
echo $separator;
$sort_modes = array(1=>'Залили больше всего файлов', 2=>'Скачали больше всего файлов', 3=>'Залили больше всего мегабайт', 4=>'Скачали больше всего мегабайт', 5=>'Больше всего комментариев');
foreach($sort_modes as $sort_id=>$sort_name)
{
$link='<img src="images/co.gif" alt="[CO]"/> ';
$link.='<a href="'.$_SERVER['PHP_SELF'].'?mode=top&for='.$for.'&type='.$sort_id.'&'.SID.'">'.$sort_name.'</a><br/>';
if($sort_id==$type) $link="<b>$link</b>";
echo $link;
}
echo $separator;
$base_url=$_SERVER['PHP_SELF']."?mode=top&for=$for&type=$type";
$num_items=mysql_result(mysql_query("select count(id) from users;"),0);
if($num_items>100) $num_items=100;
$pages = ceil($num_items/$config['users_on_page']);
if(!empty($_REQUEST['page']))
{
$page = intval($_REQUEST['page']);
if($page<=0) $page=1;
if($page>=$pages) $page=$pages;
} else
{
$page = 1;
}
$start = $page * $config['users_on_page'] - $config['users_on_page'];
$max=$start + $config['users_on_page'];
if($max>$num_items) $max=$num_items;
$total_users = $start + 1;
if($num_items==0) $total_files=0;
echo '<b>Юзеры '.$total_users.'-'.$max.' из '.$num_items.'</b><br/>';
echo $separator;
switch($type)
{
case 1:
$q=mysql_query("select id,login,sex,upl_files from users order by upl_files desc;");
while($dbuser=mysql_fetch_array($q))
{
echo'• <a href="'.$_SERVER['PHP_SELF'].'?mode=user&id='.$dbuser['id'].'&'.SID.'">'.$dbuser['login'].'</a> ('.($dbuser['sex']==2 ? 'залила' : 'залил').' '.$dbuser['upl_files'].' файлов)<br/>';
}
break;
case 2:
$q=mysql_query("select id,login,sex,dwl_files from users order by dwl_files desc;");
while($dbuser=mysql_fetch_array($q))
{
echo'• <a href="'.$_SERVER['PHP_SELF'].'?mode=user&id='.$dbuser['id'].'&'.SID.'">'.$dbuser['login'].'</a> ('.($dbuser['sex']==2 ? 'скачала' : 'скачал').' '.$dbuser['dwl_files'].' файлов)<br/>';
}
break;
case 3:
$q=mysql_query("select id,login,sex,upl_files_size from users order by upl_files_size desc;");
while($dbuser=mysql_fetch_array($q))
{
echo'• <a href="'.$_SERVER['PHP_SELF'].'?mode=user&id='.$dbuser['id'].'&'.SID.'">'.$dbuser['login'].'</a> ('.($dbuser['sex']==2 ? 'залила' : 'залил').' '.formatsize($dbuser['upl_files_size']).')<br/>';
}
break;
case 4:
$q=mysql_query("select id,login,sex,dwl_files_size from users order by dwl_files_size desc;");
while($dbuser=mysql_fetch_array($q))
{
echo'• <a href="'.$_SERVER['PHP_SELF'].'?mode=user&id='.$dbuser['id'].'&'.SID.'">'.$dbuser['login'].'</a> ('.($dbuser['sex']==2 ? 'скачала' : 'скачал').' '.formatsize($dbuser['dwl_files_size']).')<br/>';
}
break;
case 5:
$q=mysql_query("select id,login,sex,comments from users order by comments desc;");
while($dbuser=mysql_fetch_array($q))
{
echo'• <a href="'.$_SERVER['PHP_SELF'].'?mode=user&id='.$dbuser['id'].'&'.SID.'">'.$dbuser['login'].'</a> ('.($dbuser['sex']==2 ? 'оставила' : 'оставил').' '.$dbuser['comments'].' комментариев)<br/>';
}
break;
}
$page_links=pages($base_url, $pages, $page);
if(!empty($page_links)) echo $separator.$page_links;
}
echo $separator;
echo $goback;
?>