View file pages/listfiles.php

File size: 3.07Kb
<?
if (!defined('SECURED'))
{
	die("Unknown Error!");
}

$id=intval($_GET['id']);
$uid=intval($_GET['uid']);
$dbuser=mysql_fetch_array(mysql_query("select * from users where id='".$uid."';"));

if(mysql_affected_rows()==0) 
{
	title('Ошибка!');
	div('Ошибка!','b');
	echo'Запрошенный пользователь не существует!';
	footer();
	exit;
}

title('Файлы ('.$dbuser['login'].')');
div('Файлы - '.$dbuser['login'],'b');

if(empty($id))
{
	include'includes/func_formatsize.php';
	echo'<img src="images/up.gif" alt="[UP]"/><a href="'.$_SERVER['PHP_SELF'].'?'.SID.'">На главную</a><br/>';
	echo $separator;
	echo'<b>Выберите категорию:</b><br/>';
	$q=mysql_query("select * from categorys where parent='0' order by position;");
	while($category=mysql_fetch_array($q))
	{
		$files=mysql_result(mysql_query("select count(id) from files where refcat='".$category['id']."' and author='".$dbuser['id']."|".$dbuser['login']."';"),0);
		$text='<img src="images/dir.gif" alt="[DIR]"/> ';
		$text.='<b><a href="'.$_SERVER['PHP_SELF'].'?mode=listfiles&amp;uid='.$uid.'&amp;id='.$category['id'].'&amp;'.SID.'">'.$category['name'].'</a></b>('.$files.')<br/>';
		echo $text;
	}
} else
{
	include'includes/func_pages.php';

	$base_url=$_SERVER['PHP_SELF']."?mode=listfiles&amp;uid=$uid&amp;id=$id";
	$num_items=mysql_result(mysql_query("select count(id) from files where refcat='$id' and author='".$user['id']."|".$user['login']."';"),0);
	$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'];
	
	echo'<img src="images/up.gif" alt="[UP]"/><a href="'.$_SERVER['PHP_SELF'].'?mode=listfiles&amp;uid='.$uid.'&amp;'.SID.'">Вверх</a><br/>';
	echo $separator;
	
	$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;
	
	list($cat_name)=mysql_fetch_array(mysql_query("select name from categorys where id='".$id."';"));
	echo'Файлы пользователя <b>'.$dbuser['login'].'</b> в категории <b>'.$cat_name.'</b>:<br/>';
	if($num_items==0) echo'Нет файлов в этой категории<br/>';
	$q=mysql_query("select * from files where refcat='$id' and author='".$dbuser['id']."|".$dbuser['login']."' order by uploaded desc limit $start,".$config['files_on_page'].";");
	while($file=mysql_fetch_array($q))
	{
		echo '&#8226; <a href="'.$_SERVER['PHP_SELF'].'?mode=file&amp;id='.$file['id'].'&amp;'.SID.'">'.basename($file['filename']).'</a> ('.$file['downloads'].' скачиваний)<br/>';
		echo '&#187; '.$file['desc'].'<br/>';
	}
	$page_links=pages($base_url, $pages, $page);
	if(!empty($page_links)) echo $separator.$page_links;
}	
	
echo $separator;	
echo $goback;
?>