View file modules/downloads/index.php

File size: 2.53Kb
<?php
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.org.ua  *
**********************************/
$locate	= 'in_downloads';
$dir_id = 0;
$title = $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` = '0'")->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` = '0' 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/>
				'.($downloads['type']== 0 && !empty($downloads['description']) ? '<span style="font-size: xx-small;">'. $downloads['description'] .'</span>' : ($downloads['type'] == 1 && !empty($downloads_file['description']) ? mb_substr($downloads_file['description'], 0, 100).'...' : NULL)).'
				</div>';
			}
		$pages->view('/downloads/?');
	}
$tpl->div('block', NAV .' <a href="/downloads/search">'. $lang->word('search') .'</a><br/> ' 
				. ($user['level'] >=4 ? NAV.' <a href="/downloads/add_file?">'. $lang->word('dl_add_file') .'</a><br/>'.
										NAV.' <a href="/downloads/add_dir?">'. $lang->word('dl_add_dir') .'</a><br/>' : NULL) 
				. HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
?>