Файл: modules/blog/add_comment.php
Строк: 62
<?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_blog';
if(!User::logged() || !isset($_GET['blog_id'])) { go('/'); }
if(isset($_POST['create']) && $_GET['act'] == 'create')
{
if(isset($_GET['reply_to']))
{
$_user_id = num($_GET['reply_to']);
if($_user_id !== User::Id())
{
$db->query("INSERT INTO `notify` SET `user_id` = '". $_user_id ."', `from_id` = '". User::Id() ."', `request_id` = '/blog/comments/".abs(intval($_GET['blog_id']))."', `type` = 'notify_comments_reply', `read` = '0', `time` = '". time() ."'");
// print_r($db->errorInfo());
}
}
$blog = $db->query("SELECT * FROM `blogs` WHERE `id` = '". num($_GET['blog_id']) ."'")->fetch();
if($blog['user_id'] !== User::Id() && !isset($_GET['reply_to']))
{
$db->query("INSERT INTO `notify` SET `user_id` = '{$blog['user_id']}', `from_id` = '". User::Id() ."', `request_id` = '/blog/comments/{$blog['id']}', `type` = 'notify_blog_reply', `read` = '0', `time` = '". time() ."'");
}
$comments = new Comments('blog', num($_GET['blog_id']), '', 'blog', 'blogs');
$comments->add($_POST['text']);
redirect('/blog/comments/'.num($_GET['blog_id']));
}
$title = _t('add_comment');
include_header($title);
$tpl->div('title', _t('add_comment'));
echo '<form action="/blog/add_comment?act=create&blog_id='.abs(intval($_GET['blog_id'])) .(isset($_GET['reply_to']) ? '&reply_to='.num($_GET['reply_to']) : null).'" method="post">
<div class="menu">
<b>'. _t('message') .'</b>:<br/>
<textarea name="text" rows="5" cols="26">'.(isset($_GET['reply_to']) ? '[b]'.tnick(num($_GET['reply_to'])).'[/b], ' : NULL).'</textarea><br/>
<input name="create" type="submit" value="'. _t('create') .'" /><br/>
</div>
</form>';
$tpl->div('block', NAV .'<a href="/blog/comments/'. abs(intval($_GET['blog_id'])) .'">'. _t('back') .'</a><br/>' .
NAV .'<a href="/blog/">'. _t('blogs') .'</a><br/>' .
HICO .'<a href="/">'. _t('home').'</a>');
include_footer();
?>