Файл: sys/inc/news_main.php
Строк: 162
<?php
/* DCMS Special
* Дата последнего редактирования 12.12.2015
* Модифицировал densnet
*/
$q = mysql_query("SELECT * FROM `news` WHERE `main_time` > '" . TIME . "' ORDER BY `id` DESC LIMIT 1");
if (mysql_num_rows($q) == 1) {
$news = mysql_fetch_assoc($q);
$hide = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_hide` WHERE `nid` = '$news[id]' AND uid = '{$user['id']}'"), 0);
$like = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_like` WHERE `id_news` = '$news[id]'"), 0);
$kum = @mysql_result(mysql_query("SELECT id_user FROM `news_like` WHERE `id_news` = '$news[id]'"), 0);
$kom = @mysql_result(mysql_query("SELECT nick FROM `user` WHERE `id` = '$kum' LIMIT 1"), 0);
$kem = $like - 1;
$komm = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '$news[id]'"), 0);
#Лайк
if (isset($_GET['like']) && isset($user)) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `news_like` WHERE `id_news` = '" . intval($_GET['id']) . "' AND `id_user` = '$user[id]' LIMIT 1"), 0) != 0) {
} else {
mysql_query("INSERT INTO `news_like` (`id_user`, `id_news`) values('$user[id]', '" . intval($_GET['id']) . "')");
}
header("Location: /" . SID);
}
if (isset($_GET['unlike']) && isset($user)) {
mysql_query("DELETE FROM `news_like` WHERE `id_user` = '$user[id]' AND `id_news` = '" . intval($_GET['id']) . "' LIMIT 1");
header("Location: /" . SID);
}
#Сворачиваем новость
if (isset($_GET['hide']) && isset($user)) {
#Только для зарегистрированных
only_reg();
if (!isset($_GET['id']) && !is_numeric($_GET['id'])) {
header("Location: /index.php?" . SID);
exit;
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `news` WHERE `id` = '" . intval($_GET['id']) . "' LIMIT 1", $db), 0) == 0) {
header("Location: /index.php?" . SID);
exit;
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `news_hide` WHERE `nid` = '" . intval($_GET['id']) . "' AND `uid` = '$user[id]' LIMIT 1", $db), 0)) {
header("Location: /index.php?" . SID);
exit;
}
mysql_query("INSERT INTO `news_hide` (`nid`,`uid`) VALUES ('" . intval($_GET['id']) . "','$user[id]')");
header("Location: /index.php?" . SID);
exit;
}
if ($hide == 0) {
echo "<div class='card'>";
echo "<div class='card-header'><h5>";
if (isset($user)) {
echo "<span style='float:right' class='close'>";
echo "<a href='?id=$news[id]&hide' title='Отметить как прочитанное' data-toggle='tooltip' data-placement='left'><span class='fa fa-share-square-o'></span></a>";
echo "</span>";
}
echo "<a href='/modules/news/?news=$news[id]'>$news[title]</a>";
echo "</h5><small style='color: #9197a3;'><span class='fa fa-user fa-fw'></span> $news[avtor] · ";
echo "<span title='" . date::time($news['time']) . "'>" . date::times($news['time']) . "</span></small></div>";
$q = mysql_query("SELECT `id` FROM `user` WHERE `date_last` > '" . (TIME - 600) . "' ORDER BY `date_last` DESC LIMIT 7");
echo "<div class='card-block'>";
echo toOutput($news['msg']) . "<br />";
#Выводим изображение новости
if ($user['set_news'] == 1) {
if (is_file(H . 'modules/news/images/' . $news['id'] . '.png')) {
echo "<img src='/modules/news/images/$news[id].png' style='border: 1px solid #CCDDED; padding: 2px; border-radius: 5px; max-width: 200px;' /><br />";
}
} elseif (!isset($user)) {
if (is_file(H . 'modules/news/images/' . $news['id'] . '.png')) {
echo "<img src='/modules/news/images/$news[id].png' style='border: 1px solid #CCDDED; padding: 2px; border-radius: 5px; max-width: 200px;' /><br />";
}
}
if ($news['link'] != NULL) {
echo "<a href='" . htmlentities($news['link'], ENT_QUOTES, 'UTF-8') . "' title='Перейти, чтобы узнать подробности'><small style='color: #9197a3;'>" . htmlentities($news['link'], ENT_QUOTES, 'UTF-8') . "</small></a> ";
}
if (isset($user)) {
echo "<div class='hr'></div>";
#Просмотры
echo "<span title='Просмотрели " . sklon_text($news['prosm'], array('раз', 'раза', 'раз')) . "' style='float:right;'><span class='fa fa-eye fa-fw'></span> $news[prosm]</span>";
if ($like == 0) {
$l = null;
} else {
$l = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_like` WHERE `id_news` = '$news[id]'"), 0);
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `news_like` WHERE `id_news` = '$news[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0) == 0) {
echo "<a href = '?id=$news[id]&like'><span class='fa fa-heart-o fa-fw'></span> Нравится $l</a> ";
} else {
echo "<a href = '?id=$news[id]&unlike'><span class='fa fa-heart fa-fw'></span> Нравится $l</a> ";
}
$kom = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '$news[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0);
if ($kom == 0) {
$komms = null;
} else {
$komms = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '$news[id]' AND `id_user` = '$user[id]' LIMIT 1"), 0);
}
if ($kom == 0) {
echo "<a href='/modules/news/?news=$news[id]' title='Комментировать'><span class='fa fa-comments-o fa-fw'></span> Комментарии $komms ";
if ($news['close'] == 1) {
echo "<span class='fa fa-lock fa-fw'></span>";
}
echo "</a> ";
} else {
echo "<a href='/modules/news/?news=$news[id]' title='Комментировать'><span class='fa fa-comments fa-fw'></span> Комментарии $komms ";
if ($news['close'] == 1) {
echo "<span class='fa fa-lock fa-fw'></span>";
}
echo "</a> ";
}
$kum = @mysql_result(mysql_query("SELECT id_user FROM `news_like` WHERE `id_news` = '$news[id]'"), 0);
$kom = @mysql_result(mysql_query("SELECT nick FROM `user` WHERE `id` = '$kum' LIMIT 1"), 0);
$kem = $like - 1;
#Выводит тех, кому понравилась новость
if ($user['id'] == $kum) {
if ($like == 1) {
$vam = "Вам это нравится";
} elseif ($like >= 2) {
$vam = "Вам и еще <a href='/modules/news/?news=$news[id]&like_all'>" . sklon_text($kem, array('пользователю', 'пользователям', 'пользователям')) . "</a> это нравится";
}
} else {
$vam = "<a href='/modules/news/?news=$news[id]&like_all'>" . sklon_text($like, array('пользователю', 'пользователям', 'пользователям')) . "</a> это нравится";
}
if ($like == 1) {
echo "<div class='hr'></div>";
echo "<font color='#B2B2B2'><span class='fa fa-heart fa-fw'></span> $vam</font>";
} elseif ($like >= 2) {
echo "<div class='hr'></div>";
echo "<font color='#B2B2B2'><span class='fa fa-heart fa-fw'></span> $vam</font>";
}
}
echo "</div>";
echo "</div>";
}
}