<?php
/*
- NTLCMS v 18.1 19.08.2017 г
- Автор скрипта Александр (NTL)
- Скрипт клик клуба v 18.1
- Оф.сайт http://clicks24.ru
- Контакты ntl-jt@mail.ru
- Все права принадлежат разработчику
- Вы не имеете право вносить изменения в код скрипта
- Данный скрипт запрещено распространять
*/
define('NTLCMS', 1);
$module = 'review';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
include ('../system/head.php');
################################################################################
if ($set['news'] == '1' && $_USER['admin'] != '1'){
echo '<div class="title"><center>Новости системы</center></div>';
echo '<div class="post"><center>'.image('fail.png','16|16').' Модуль закрыт администратором!</center></div>';
echo '<div class="block">'.image('home.png','18|18').' <a href="'.URL.'/cabinet">В кабинет</a></div>';
include ('../system/foot.php');
exit;
}
################################################################################
if (empty($_GET['id']) || !ctype_digit($_GET['id'])) header('Location: '.URL.'/feed');
$id = isset($_GET['id']) ? filter_int($_GET['id']) : '0';
if (!DB :: run() -> querySingle("select count(`id`) from `news` where `id` = ?", array($id))){
$_SESSION['fail'] = 'Новость не существует!';
header('Location: '.URL.'/feed');
} else {
$room = DB :: run() -> query("select * from `news` where `id` = ?", array($id)) -> fetch(PDO::FETCH_OBJ);
################################################################################
echo '<div class="title"><center>Новости системы - '.filter_out($room -> name).'</center></div>';
################################################################################
/* Кто смотрел новость */
$uswho = DB :: run() -> querySingle("select count(`id`) from `views` where `login` = ? and `news` = ?", array($ulogin, $room -> id));
if (isset($active) && !empty($uswho)){
DB :: run() -> query("update `views` set `time` = ? where `login` = ? and `news` = ?", array(TIME, $ilogin, $room -> id));
} else {
DB :: run() -> query("insert into `views` (`login`, `time`, `news`) values (?, ?, ?)", array($ilogin, TIME, $room -> id));
}
/* Лайки на новость */
if (isset($active) && isset($_GET['like'])){
if (DB :: run() -> querySingle("select * from `like` where `login` = ? and `news` = ?", array($ulogin, $room -> id))){
echo '<div class="error"><center>Вы уже ставили лайк на данную новость!</center></div>';
} else {
if ($_GET['like'] == 'plus') {
DB :: run() -> query("update `news` set `like` = `like` + ? where `id` = ?", array(1, $room -> id));
} else {
DB :: run() -> query("update `news` set `like` = `like` - ? where `id` = ?", array(1, $room -> id));
}
DB :: run() -> query("insert into `like` (`login`, `news`) values (?, ?)", array($ulogin, $room -> id));
header('Location: '.URL.'/feed_review'.$room -> id);
}
}
$comment = DB :: run() -> querySingle("select count(`id`) from `comment` where `pid` = ?", array($room -> id));
$views = DB :: run() -> querySingle("select count(`id`) from `views` where `news` = ?", array($room -> id));
$count = DB :: run() -> query("select (`like`) from `news` where `id` = ?", array($room -> id)) -> fetch(PDO::FETCH_OBJ);
echo '<div class="menu">'.image('rss.png','16|16').' '.outtext($room -> text, 1, 1, 1).'<br/> ';
echo image('usadmin.png','16|16').' Добавил: '.login($room -> author, 1).'<br/>';
echo image('eyeopen.png','16|16').' Просмотров: '.$views.'<br/>';
echo image('star.png','16|16').' Рейтинг новости: '.$count -> like.' ';
if (isset($active) && !DB :: run() -> querySingle("select * from `like` where `login` = ? and `news` = ?", array($ulogin, $room -> id))){
echo '<a href="'.URL.'/like_plus'.$room -> id.'">'.image('oklike.png','16|16').'</a>
<a href="'.URL.'/like_minus'.$room -> id.'">'.image('nolike.png','16|16').'</a>';
}
echo '<br/>'.image('comment.png','16|16').' <a href="'.URL.'/feed_comment'.((int) $room -> id).'">Комментарии</a> ['.$comment.']</div>';
}
echo '<div class="block">'.image('home.png','18|18').' '.(isset($active) ? '<a href="'.URL.'/cabinet">В кабинет</a>' : '<a href="'.URL.'">На главную</a>').' | <a href="'.URL.'/feed">Новости системы</a></div>';
include ('../system/foot.php');
?>