Файл: modules/blog/note.php
Строк: 61
<?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_blogs';
$id = num($_GET['id']);
if(!isset($_GET['id']) || $db->query("SELECT * FROM `blogs` WHERE `id` = '$id'")->rowCount() == 0)
{
redirect('/blog');
}
$note = $db->query("SELECT * FROM `blogs` WHERE `id` = '$id'")->fetch();
if(isset($_GET['_like_']))
{
$like = new Like('blogs', $id);
$like->change();
if($note['user_id'] != User::Id() && $_GET['_like_'] == 'like')
{
$db->query("INSERT INTO `notify` SET `user_id` = '". $note['user_id'] ."', `from_id` = '". User::Id() ."', `request_id` = '/blog/note/".$id."', `type` = 'liked your post', `read` = '0', `time` = '". time() ."'");
}
else
{
$db->query("DELETE FROM `notify` SET `user_id` = '". $note['user_id'] ."' AND `from_id` = '". User::Id() ."' AND `request_id` = '/blog/note/".$id."' AND `type` = 'liked your post'");
}
redirect('/blog/note/'.$id);
}
$title = $note['name'].' | '._t('blogs');
include_header($title);
Template::div('title', $title);
Template::div('post', nick($note['user_id'], rtime($note['time'])).output($note['text']));
echo '<div class="menu">';
echo '<b>'._t('blog_tags').'</b>: ';
$tags = explode(',', $note['tags']);
foreach($tags as $tag)
{
$lastTag = $tags[count($tags)-1];
if($tag == $lastTag)
{
echo '<a href="/blog/tag?id='.trim($tag).'">'.trim($tag).'</a>';
}
else
{
echo '<a href="/blog/tag?id='.trim($tag).'">'.trim($tag).'</a>, ';
}
}
$like = new Like('blogs', $id);
echo '<br/> '.$like->show().'
</div>';
Template::div('block',
NAV.' <a href="/blog/comments/'.$id.'">'._t('comments').'</a> ['.$db->query("SELECT * FROM `blog_comms` WHERE `blog_id` = '".$id."'")->rowCount().']<br/>'
.(User::Id() == $note['user_id'] || User::level() >= 5 ? NAV.' <a href="/blog/edit/'.$id.'">'._t('edit').'</a><br/>' : null) .
(User::Id() == $note['user_id'] || User::level() >= 5 ? NAV.' <a href="/blog/delete/'.$id.'">'._t('delete').'</a><br/>' : null)
.NAV.' <a href="/blog/user/'.$note['user_id'].'">'._t('blog_of_user').' '.tnick($note['user_id']).'</a><br/>'
.NAV.' <a href="/blog/">'._t('blogs').'</a><br/>'
.HICO.' <a href="/">'._t('home').'</a>');
include_footer();