Просмотр файла modules/downloads/dir.php

Размер файла: 3.11Kb
<?php
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.org.ua  *
**********************************/
$locate	= 'in_downloads';
$dir_id = abs(intval($_GET['id']));
if($db->query("SELECT * FROM `downloads` WHERE `id` = '". $dir_id ."' AND `type` = '0'")->rowCount() == 0)
	{
		header('location: /downloads/');
		exit;
	}
$ref_id = $db->query("SELECT dir_id FROM `downloads` WHERE `id` = '". $dir_id ."'")->fetchColumn();
$dir_name = $db->query("SELECT name FROM `downloads` WHERE `id` = '". $dir_id ."'")->fetchColumn();
$title = $dir_name.' | '.$lang->word('downloads');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('downloads'));
$downloads_r = $db->query("SELECT * FROM `downloads` WHERE `dir_id` = '$dir_id'")->rowCount();
$pages = new Paginator($downloads_r, $ames);
if($downloads_r == 0)
	{
		$tpl->div('menu', $lang->word('dl_dir_empty'));
	}
else
	{
		$downloads_q = $db->query("SELECT * FROM `downloads` WHERE `dir_id` = '$dir_id' ORDER BY `type` ASC, `name` DESC LIMIT $start, $ames");
		while($downloads = $downloads_q->fetch())
			{
				$downloads_file = $db->query("SELECT * FROM `downloads_files` WHERE `ref_id` = '$dir_id' AND `from_id` = '". $downloads['id'] ."'")->fetch();
				echo '<div class="post">
				'.($downloads['type'] == 0 ? img('folder.png') : dlext($downloads_file['ext'])).' <a href="/downloads/'.($downloads['type'] == 0 ? 'dir/'.$downloads['id'] : 'file/'.$downloads_file['id']).'">'.($downloads['type'] == 0 ? $downloads['name'] : $downloads_file['name'].' ('.$downloads_file['ext'].')').'</a>'.($downloads['type'] == 0 ? null : ' ['.size($downloads_file['size']).']').'
				'.($downloads['type'] == 0 ? '('.$db->query("SELECT * FROM `downloads` WHERE `dir_id` = '".$downloads['id']."' AND `type` = '0'")->rowCount().'/'.$db->query("SELECT * FROM `downloads` WHERE `dir_id` = '".$downloads['id']."' AND `type` = '1'")->rowCount().')' : NULL).'
				'.($downloads['type'] == 0 && $user['level'] >=4 ? '[ <a href="/downloads/edit_dir/'.$downloads['id'].'">'.img('edit.png').'</a> | <a href="/downloads/delete_dir/'.$downloads['id'].'">'.img('delete.png').'</a> ]' : NULL).'
				<br/>
				'.(!empty($downloads['description']) ? '<span style="font-size: xx-small;">'. $downloads['description'] .'</span>' : NULL).'
				</div>';
			}
		$pages->view('/downloads/dir/'.$dir_id.'?');
	}
$tpl->div('block', ($ref_id != 0 ? img('folder.png') .' <a href="/downloads/dir/'. $ref_id.'">'.$db->query("SELECT name FROM `downloads` WHERE `dir_id` = '". $ref_id ."'")->fetchColumn().'</a><br/>' : img('folder.png') . ' <a href="/downloads/">'. $lang->word('back') .'</a><br/>').' ' 
				. ($user['level'] >=4 ? NAV.' <a href="/downloads/add_file?dir_id='.$dir_id.'">'. $lang->word('dl_add_file') .'</a><br/>'.
										NAV.' <a href="/downloads/add_dir?dir_id='.$dir_id.'">'. $lang->word('dl_add_dir') .'</a><br/>' : NULL) 
				. img('download.png') . ' <a href="/downloads/">'. $lang->word('downloads') .'</a><br/>'
				. HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
?>