<?php
define('NTLCMS', 1);
$module = 'reviews';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
$page_title = 'Страница отзывов - клик клуба ' . strtoupper($_SERVER['HTTP_HOST']);
include ('../system/head.php');
if ($set['reviews'] == '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;
}
echo '<div class="title"><b>'.razd.' Ваши отзывы</b></div>';
if ($active) echo '<div class="menu"><i class="fa fa-plus-circle fa-fw"></i> <a href="'.URL.'/responses_add">Добавить отзыв</a></div>';
$k_post = DB :: run() -> querySingle("select count(`id`) from `reviews`"); 
$k_page = k_page($k_post, $onpage); 
$page = page($k_page); 
$start = $onpage * $page - $onpage; 
$sql = DB :: run() -> query("select * from `reviews` where `id` order by `id` desc limit ".$start.", ".$onpage);
if ($k_post == 0){
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> Отзывов еще нет!</center></div>';
} else {
while ($row = $sql -> fetch(PDO::FETCH_OBJ)){
$type = ($row -> type == 1 ? '<i class="fa fa-thumbs-up fa-fw"></i>' : '<i class="fa fa-thumbs-down fa-fw"></i>');
echo '<div class="menu">'.ava($row -> login).' '.login($row -> login, 1).' '.online($row -> login).' ('.date('d.m.Y H:i', $row -> date).') '.$type.' ';
if ($_USER['admin'] == '1') echo '[<a href="'.URL.'/responses_delete'.ints($row -> id).'">D</a>]';
echo '<br/><i class="fa fa-bullhorn fa-fw"></i> '.outtext($row -> text, 1 ,1 ,1).'</div>';
echo '<script type="application/ld+json">';
echo json_encode([
"@context" => "https://schema.org",
"@type" => "Review",
"author" => $row->login,
"datePublished" => date('c', $row->date),
"reviewBody" => strip_tags($row->text),
"reviewRating" => [
"@type" => "Rating",
"ratingValue" => ($row->type == 1 ? 5 : 1),
"bestRating" => 5,
"worstRating" => 1
]
], JSON_UNESCAPED_UNICODE);
echo '</script>';
}
if ($k_page > 1) navigation(URL.'/responses?', $k_page, $page);
}
echo '<div class="block"><i class="fa fa-home fa-fw"></i> '.(isset($active) ? '<a href="'.URL.'/cabinet">В кабинет</a>' : '<a href="'.URL.'">На главную</a>').'</div>';
include ('../system/foot.php');
?>