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

Размер файла: 1.78Kb
<?php
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.org.ua  *
**********************************/
$locate	= 'in_downloads';
$file_id = abs(intval($_GET['id']));
if(!isset($file_id) && $db->query("SELECT * FROM `downloads_files` WHERE `id` = '$file_id'")->rowCount() == 0 || $user['level'] < 4)
	{
		header('location: /downloads/');
		exit;
	}
$filei = $db->query("SELECT * FROM `downloads_files` WHERE `id` = '". $file_id ."'")->fetch();
if(isset($_GET['act']) && $_GET['act'] == 'save')
	{
		$name = mb_substr(input($_POST['file_name']), 0, 100);
		$desc = input($_POST['file_desc']);
		if(!empty($name) && !empty($desc))
			{
				$db->query("UPDATE `downloads_files` SET `name` = '$name', `description` = '$desc' WHERE `id` = '$file_id'");
				header('location: /downloads/file/'.$file_id);
				exit;
			}
	}
$title = $lang->word('dl_edit_file').' | '.$lang->word('downloads');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('dl_add_file'));
echo '<div class="menu">
		<form action="/downloads/file_edit/'.$file_id.'?act=save" method="post">
		'.$lang->word('dl_file_name').':<br/>
		<input type="text" value="'.$filei['name'].'" name="file_name" /><br/>
		'.$lang->word('dl_file_desc').':<br/>
		<textarea name="file_desc" rows="5" cols="25">'.$filei['description'].'</textarea><br/>
		<input type="submit" value="'. $lang->word('save') .'" />
		</form>
	</div>';
$tpl->div('block', img('nav.png') . ' <a href="/downloads/file/'.$file_id.'">'. $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');
?>