Просмотр файла modules/share/edit_file.php

Размер файла: 1.62Kb
<?php
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.pp.ua	  *
**********************************/
$locate = 'in_share';
if($user['level'] < '6' || !isset($_GET['id'])) { go('/'); }
if($db->query("SELECT * FROM `share_files` WHERE `id` = '". abs(intval($_GET['id'])) ."'")->rowCount() == 0) {
go('/share/');
}
$edit_topic = $db->query("SELECT * FROM `share_files` WHERE `id` = '". abs(intval($_GET['id'])) ."'")->fetch();
if(isset($_POST['edit']) && $_GET['act'] == 'edit') {
$name = substr(input($_POST['name']), 0, 55);
$text = substr(input($_POST['text']), 0, 5000);

$db->query("UPDATE `share_files` SET `name` = '".$name."', `text` = '". $text ."' WHERE `id` = '". abs(intval($_GET['id'])) ."'");
go('/share/file/'. abs(intval(abs(intval($_GET['id'])))));
// print_r($db->errorInfo());
}
$title = $lang->word('edit');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('edit'));
echo '<form action="/share/edit_file/'. abs(intval($_GET['id'])) .'/?act=edit" method="post">
		<div class="menu">
			<b>'. $lang->word('name') .'</b>:<br/>
			<input name="name" type="text" value="'. $edit_topic['name'] .'" /><br/>
			<b>'. $lang->word('about') .'</b>:<br/>
			<textarea name="text" rows="5" cols="26">'. $edit_topic['text'] .'</textarea><br/>
			<input name="edit" type="submit" value="'. $lang->word('edit') .'" /><br/>
		</div>
		</form>';
		
$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');
?>