Файл: modules/news/edit_news.php
Строк: 69
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
$locate = 'in_news';
if($user['level'] < 6) { go('/'); }
if(isset($_GET['news_id'])) {
$news_id = abs(intval($_GET['news_id']));
if(isset($_POST['edit']) && $_GET['act'] == 'edit') {
$name = substr(input($_POST['name']), 0, 100);
$text = substr(input($_POST['text']), 0, 10000);
$db->query("UPDATE `news` SET `name` = '".$name."', `text` = '". $text ."' WHERE `id` = '".$news_id."'");
// print_r($db->errorInfo());
go('/news/article/'.$news_id.'/');
}
$title = _t('edit_news');
include_header($title);
$tpl->div('title', _t('edit_news'));
$news_e = $db->query("SELECT * FROM `news` WHERE `id` = '".$news_id."'")->fetch();
echo '<form action="/news/edit_news?act=edit&news_id='.$news_id.'" method="post">
<div class="menu">
<b>'. _t('name') .'</b>:<br/>
<input name="name" type="text" value="'. $news_e['name'] .'" /><br/>
<b>'. _t('message') .'</b>:<br/>
<textarea name="text" rows="5" cols="26">'. $news_e['text'] .'</textarea><br/>
<input name="edit" type="submit" value="'. _t('save') .'" /><br/>
</div>
</form>';
$tpl->div('block', NAV .'<a href="/news/">'. _t('news') .'</a><br/>' . HICO .'<a href="/">'. _t('home').'</a>');
include_footer();
} else { go('/news/'); }
?>