<?php
if (isset($_GET['close_news']) && intval($_GET['news_id']) && DB:: $pdo -> querySingle("SELECT COUNT(*) FROM `subscribe_posts` WHERE `id` = '". intval($_GET['news_id']) ."'")==1 && DB:: $pdo ->querySingle("SELECT COUNT(*) FROM `subscribe_posts_close` WHERE `id_user` = '$user[id]' AND `id_news` = '". intval($_GET['news_id']) ."'")==0) {
DB :: $pdo ->query("INSERT INTO `subscribe_posts_close` (`id_user`, `id_news`) values('".$user['id']."', '".intval($_GET['news_id'])."')");
system :: redirect("Новость успешно скрыта", "?");
exit;
}
$s_postsQ = DB :: $pdo ->query("SELECT * FROM `subscribe_posts` ORDER BY `id` DESC LIMIT 1");
while ($s_posts = $s_postsQ -> Fetch()) {
if (DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `subscribe_posts_close` WHERE `id_user` = '".$user['id']."' AND `id_news` = '".$s_posts['id']."'")==0){
echo '<div class="list">';
echo '<span style="float:right"><a href="?close_news&news_id='.$s_posts['id'].'" style="text-decoration:none;text-decoration: none;
background: #dcefff;
border-radius: 3px;
padding: 4px;
color: #8c9090;" >Скрыть</a></span>';
echo "<b>".$s_posts['name']."</b><br>";
echo "".$s_posts['msg']."";
if ($s_posts['url'] != NULL) {
echo '<br> <a href="'.$s_posts['url'].'" style="text-decoration:none;"><span style="color:#96999c;">Подробнее →</span></a>';
}
echo '</div>';
}
}
?>