<?php
define('NTLCMS', 1);
$module = 'review';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
$page_title = 'Страница новости - клик клуба ' . strtoupper($_SERVER['HTTP_HOST']);
include ('../system/head.php');
if ($set['news'] == '1' && $_USER['admin'] != '1'){
echo '<div class="title"><b>'.razd.' Новости клуба</b></div>';
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Модуль закрыт администратором!</center></div>';
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a></div>';
include ('../system/foot.php');
exit;
}
$id = isset($_GET['id']) ? filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT) : '0';
if (!DB :: run() -> querySingle("select count(`id`) from `news` where `id` = ?", array($id))){
$_SESSION['fail'] = 'Новость не существует!';
header('Location: '.URL.'/feed');
exit;
} else {
$room = DB :: run() -> query("select * from `news` where `id` = ?", array($id)) -> fetch(PDO::FETCH_OBJ);
$newsTitle = checkout($room->name);
$plainText = strip_tags(outtext($room->text, 1, 0, 0));
$description = mb_substr($plainText, 0, 160);
if (mb_strlen($plainText) > 160) $description .= '...';
$datePublished = date('c', $room->date);
echo '
<article class="post" style="padding: 0;" itemscope itemtype="https://schema.org/NewsArticle">
<div class="title">
<b><i class="fa fa-angle-double-right fa-fw"></i> 
<h5 itemprop="headline" style="display:inline;">'.$newsTitle.'</h5></b>
</div>
<meta itemprop="datePublished" content="'.$datePublished.'">
<meta itemprop="author" content="'.checkout($room->author).'">
<meta itemprop="description" content="'.$description.'">
<meta name="description" content="'.$description.'">
';
$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` + 1 where `id` = ?", array($room->id));
} else {
DB :: run() -> query("update `news` set `like` = `like` - 1 where `id` = ?", array($room->id));
}
DB :: run() -> query("insert into `like` (`login`, `news`) values (?, ?)", array($ulogin, $room->id));
header('Location: '.URL.'/feed_review'.$room->id);
exit;
}
}
$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" itemprop="articleBody">'.outtext($room->text, 1, 1, 1).'</div>
<div class="menu meta">
<i class="fa fa-user fa-fw"></i> Добавил: '.login($room->author, 1).'<br/>
<i class="fa fa-eye fa-fw"></i> Просмотров: '.$views.'<br/>
<i class="fa fa-star-o fa-fw"></i> Рейтинг новости: '.$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.'" title="Поставить лайк"><i class="fa fa-thumbs-up fa-fw"></i></a>
<a href="'.URL.'/like_minus'.$room->id.'" title="Поставить дизлайк"><i class="fa fa-thumbs-down fa-fw"></i></a>
';
}
echo '
<br/><i class="fa fa-comment-o fa-fw"></i> 
<a href="'.URL.'/feed_comment'.ints($room->id).'">Комментарии</a> ('.$comment.')
</div>
</article>
';
}
echo '<div class="block"><i class="fa fa-home fa-fw"></i> '
.(isset($active) ? '<a href="'.URL.'/cabinet">В кабинет</a>' : '<a href="'.URL.'">На главную</a>')
.' | <a href="'.URL.'/feed">Новости клуба</a></div>';
include ('../system/foot.php');
?>