Файл: modules/blog/edit.php
Строк: 60
<?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
*/
if(!User::logged()) redirect('/');
$locate = 'in_blogs';
$id = num($_GET['id']);
if(!isset($_GET['id']) || $db->query("SELECT * FROM `blogs` WHERE `id` = '$id'")->rowCount() == 0 || ($db->query("SELECT user_id FROM `blogs` WHERE `id` = '$id'")->fetchColumn() != User::Id() && User::level() < 5))
{
redirect('/blog/note/'.$id);
}
$note = $db->query("SELECT * FROM `blogs` WHERE `id` = '$id'")->fetch();
if(isset($_GET['edit']))
{
$text = input($_POST['text']);
$name = input($_POST['name']);
$tags = input($_POST['tags']);
if(!empty($text) && !empty($name) && !empty($tags))
{
$db->query("UPDATE `blogs` SET `name` = '$name', `text` = '$text', `tags` = '$tags', `user_id` = '".$note['user_id']."' WHERE `id` = '$id'");
// print_r($db->errorInfo());
redirect('/blog/note/'.$id);
}
}
$title = _t('edit_note').' | '._t('blogs');
include_header($title);
Template::div('title', $title);
echo '<div class="post">
<form action="/blog/edit/'.$id.'?edit" method="post">
'. _t('name').':<br/>
<input type="text" value="'.$note['name'].'" name="name" /><br/>
'. _t('message').':<br/>
<textarea name="text" rows="5" cols="26">'.$note['text'].'</textarea><br/>
'. _t('blog_tags') .':<br/>
<input type="text" value="'.$note['tags'].'" name="tags" /><br/>
<input type="submit" value="'. _t('save') .'" />
</form></div>';
echo '<div class="block">'
.HICO.' <a href="/blog/note/'.$id.'">'. _t('back').'</a><br/>'
. HICO.' <a href="/blog">'. _t('blogs').'</a><br/>'
.HICO.' <a href="/">'._t('home').'</a>
</div>';
include_footer();
?>