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

Размер файла: 2.38Kb
<?php
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.org.ua  *
**********************************/
$locate	= 'in_downloads';
$dir_id = (isset($_GET['dir_id']) ? abs(intval($_GET['dir_id'])) : 0);
if($dir_id != 0 && $db->query("SELECT * FROM `downloads` WHERE `id` = '$dir_id'")->rowCount() == 0 || $user['level'] < 4)
	{
		header('location: /downloads/');
		exit;
	}
if(isset($_GET['act']) && $_GET['act'] == 'add')
	{
		$err = false;
		$name = input($_POST['dir_name']);
		$desc = input($_POST['dir_desc']);
		$trans_name = cyrlat(input($_POST['dir_path']));
		if($db->query("SELECT * FROM `downloads` WHERE `server_path` = '$trans_name' AND 'type' = '0'")->rowCount() > 0)
			{
				$err = 'Direcotry already exists';
			}
		if(file_exists(ROOT.'/files/downloads/'.$trans_name)) $err = 'Can\'t create directory';
		if($err == false && !empty($name) && !empty($trans_name))
			{
				$db->query("INSERT INTO `downloads` SET `name` = '$name', `server_path` = '$trans_name', `description` = '$desc', `type` = '0', `dir_id` = '$dir_id'");
				mkdir(ROOT.'/files/downloads/'.$trans_name);
				header('location: /downloads/dir/'.$dir_id);
				exit;
			}
		else
			{
				echo $err;
			}
	}
$title = $lang->word('dl_add_dir').' | '.$lang->word('downloads');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('dl_add_dir'));
echo '<div class="menu">
		<form action="/downloads/add_dir?act=add'.($dir_id != 0 ? '&amp;dir_id='.$dir_id : NULL).'" method="post">
		'.$lang->word('dl_dir_name').':<br/>
		<input type="text" name="dir_name" /><br/>
		'.$lang->word('dl_serv_name').':<br/>
		<input type="text" name="dir_path" /><br/>
		'.$lang->word('dl_dir_desc').':<br/>
		<textarea name="dir_desc" rows="5" cols="25"></textarea><br/>
		<input type="submit" value="'. $lang->word('add') .'" />
		</form>
	</div>';
$tpl->div('block', ($dir_id != 0 ? img('folder.png') .' <a href="/downloads/dir/'. $dir_id.'">'.$db->query("SELECT name FROM `downloads` WHERE `id` = '". $dir_id ."'")->fetchColumn().'</a><br/>' : img('folder.png') . ' <a href="/downloads/">'. $lang->word('back') .'</a><br/>').' 
				'. img('download.png') . ' <a href="/downloads/">'. $lang->word('downloads') .'</a><br/>'
				. HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
?>