Файл: modules/news/comments.php
Строк: 83
<?php
if(isset($user)) {
$locate = 'in_news';
$news_id = abs(intval($_GET['news_id']));
$id = abs(intval($_GET['id']));
$news_t = $db->query("SELECT * FROM `news` WHERE `id` = '". $news_id ."'")->fetch();
if(isset($_GET['act']) && $_GET['act'] == 'edit') {
if(isset($_POST['edit'])) {
if(!empty($_POST['text'])) {
$text = substr(input($_POST['text']), 0, 5000);
$db->query("UPDATE `news_comms` SET `text` = '". $text ."' WHERE `id` = '".abs(intval($_GET['id']))."'");
}
header('location: /news/'.$news_id.'/comments/');
exit;
}
$news_c = $db->query("SELECT * FROM `news_comms` WHERE `id` = '". $id ."'")->fetch();
if(($_GET['id'] != 0 || !empty($_GET['id'])) && $user['level'] >= 5 or $news_c['user_id'] == $user['id']) {
$title = $lang->word('comments') .' | '. $news_t['name'] .' | '.$lang->word('news');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('comments') .' | '. $news_t['name']);
echo '<form action="" method="post">
<div class="menu">
<b>'. $lang->word('message') .'</b>:<br/>
<textarea name="text" rows="5" cols="26">'.$news_c['text'].'</textarea><br/>
<input name="edit" type="submit" value="'. $lang->word('edit') .'" /><br/>
</div>
</form>';
$tpl->div('block', img('reply_11.png') .'<a href="/news/'.$news_id.'/comments/">'. $lang->word('back') .'</a><br/>' . HICO .'<a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');
exit;
} else {$tpl->div('error', $lang->word('chat_not_g')); }
}
$title = $lang->word('comments') .' | '. $news_t['name'] .' | '.$lang->word('news');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('comments') .' | '. $news_t['name']);
//if(isset($user))
//{
//$tpl->div('menu', '<a href="/news/add_comment/?news_id='. $news_id .'">'. $lang->word('add_comment') .'</a>');
//}
$comments = new Comments('news', $news_id);
$comments->view();
$tpl->div('block', NEWS_ICON .' <a href="/news/">'. $lang->word('news') .'</a><br/>' . HICO .' <a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');
} else {
$title = 'Новости';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Новости');
$tpl->div('menu', '<center>Новости доступны только зарегистрированным пользователям!</center>');
$tpl->div('block',HICO .'<a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');
}
?>