View file modules/share/folder.php

File size: 2.95Kb
<?php
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.ru	  *
**********************************/
$locate	= 'in_share';
if(!isset($_GET['cat_id'])) { go('/share/'); }
$cat_id = abs(intval($_GET['cat_id']));
if($db->query("SELECT * FROM `share_c` WHERE `id` = '". $cat_id ."'")->rowCount() == 0) {
	$title = $lang->word('share');
	require_once(SYS.'/view/header.php');
	$tpl->div('menu', $lang->word('dir_not_exists'));
	$tpl->div('block', NAV.' <a href="/share/">'. $lang->word('share') .'</a><br/>' . HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
exit;
}
$filesc = $db->query("SELECT * FROM `share_c` WHERE `id` = '". $cat_id ."'")->fetch();
$title = $filesc['name'] .' | '.$lang->word('share');
require_once(SYS.'/view/header.php');
$tpl->div('title', $filesc['name'] .' | '.$lang->word('share'));
$files_r = $db->query("SELECT * FROM `share_files` WHERE `cat_id` = '". $cat_id ."'")->rowCount();
$pages = new Paginator($files_r, $ames);
if($files_r == 0) {
	echo $tpl->div('menu', $lang->word('no_files'));
} 
else {
		$files_q = $db->query("SELECT * FROM `share_files` WHERE `cat_id` = '". $cat_id ."' ORDER BY name LIMIT $start, $ames");
		while($files = $files_q->fetch()) {
			echo '<div class="menu">
				'.(preg_match('/jpeg|jpg|gif|png|bmp/i', $files['ext']) ? img('image.png') : NULL).'
				'.(preg_match('/jar|sis|sisx|jad|apk/i', $files['ext']) ? img('application.png') : NULL).'
				'.(preg_match('/mp4|3gp|avi|flv/i', $files['ext']) ? img('video.png') : NULL).'
				'.(preg_match('/mp3|aac|amr|wav|midi|mid/i', $files['ext']) ? img('music.png') : NULL).'
				'.(preg_match('/zip|rar|tar.gz|7z/i', $files['ext']) ? img('box.png') : NULL).'
				 <a href="/share/file/'. $files['id'] .'/">'. $files['name'] .'</a> ('.strtoupper($files['ext']).')<br/>
				 '. substr($files['text'], 0, 60).'...
				</div>';
		}
	$pages->view('/share/folder/'. $cat_id .'/?');
}
$fid = $db->query("SELECT rid FROM `share_c` WHERE `id` = '". $cat_id ."'")->fetchColumn();
$tpl->div('block', ($filesc['who_upload'] == 2 && isset($user) ? img('upload.png'). '<a href="/share/add_file/'. $_GET['cat_id'] .'/?type=import">'.$lang->word('import').'</a><br/>'. img('upload.png').' <a href="/share/add_file/'. $cat_id .'/">'. $lang->word('add_file') .'</a><br/>' : ($filesc['who_upload'] == 1 && ($user['level'] == 4 || $user['level'] >=6) ? img('upload.png'). '<a href="/share/add_file/'. $_GET['cat_id'] .'/?type=import">'.$lang->word('import').'</a><br/>'. img('upload.png').' <a href="/share/add_file/'. $cat_id .'/">'. $lang->word('add_file') .'</a><br/>' : NULL)) . NAV . ' <a href="/share/'. $fid .'/">'. $db->query("SELECT name FROM `share` WHERE `id` = '". $fid ."'")->fetchColumn().'</a><br/>' . NAV . ' <a href="/share/">'. $lang->word('share') .'</a><br/>' . HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
?>