Файл: news/news.php
Строк: 186
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
// Если нет id шлем на главную
if (!isset($_GET['id']) && !is_numeric($_GET['id'])){header("Location: index.php?".SID);exit;}
// Cуществование новости
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;
}
// Определение записи новости
$news = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `id` = '" . intval($_GET['id']) . "' LIMIT 1"));
// Автор новости
$author = get_user($news['id_user']);
// Отмечаем уведомления
if (isset($user))
mysql_query("UPDATE `notification` SET `read` = '1' WHERE `type` = 'news_komm' AND `id_user` = '$user[id]' AND `id_object` = '$news[id]'");
/*------------------------Мне нравится------------------------*/
if (isset($user) && isset($_GET['like']) && ($_GET['like'] == 1 || $_GET['like'] == 0)
&& mysql_result(mysql_query("SELECT COUNT(*) FROM `like_object` WHERE `id_object` = '$news[id]' AND `type` = 'news' AND `id_user` = '$user[id]'"),0) == 0)
{
mysql_query("INSERT INTO `like_object` (`id_user`, `id_object`, `type`, `like`) VALUES ('$user[id]', '$news[id]', 'news', '" . abs(intval($_GET['like'])) . "')");
//Начисление рейтинга и монет за активность
mysql_query("UPDATE `user` SET `money` = '" . ($user['money'] + 1) . "', `rating` = '" . ($user['rating'] + 1) . "' WHERE `id` = '$user[id]' LIMIT 1");
}
/*------------------------------------------------------------*/
// Комментарий
if (isset($_POST['msg']) && isset($user))
{
$msg = $_POST['msg'];
$mat = antimat($msg);
if ($mat)$err[] = 'В тексте сообщения обнаружен мат: '.$mat;
if (strlen2($msg)>1024){$err = 'Сообщение слишком длинное';}
elseif (strlen2($msg)<2){$err = 'Короткое сообщение';}
elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '" . intval($_GET['id']) . "' AND `id_user` = '$user[id]' AND `msg` = '" . my_esc($msg) . "' LIMIT 1"),0) != 0){$err = 'Ваше сообщение повторяет предыдущее';}
elseif(!isset($err))
{
mysql_query("INSERT INTO `news_komm` (`id_user`, `time`, `msg`, `id_news`) values('$user[id]', '$time', '" . my_esc($msg) . "', '" . intval($_GET['id']) . "')");
//Начисление рейтинга и монет за активность
mysql_query("UPDATE `user` SET `money` = '" . ($user['money'] + 2) . "', `rating_tmp` = '" . ($user['rating_tmp'] + 0) . "' WHERE `id` = '$user[id]' LIMIT 1");
/*
==========================
Уведомления об ответах
==========================
*/
if (isset($ank_reply['id']))
{
$notifiacation = mysql_fetch_assoc(mysql_query("SELECT * FROM `notification_set` WHERE `id_user` = '" . $ank_reply['id'] . "' LIMIT 1"));
if ($notifiacation['komm'] == 1 && $ank_reply['id'] != $user['id'])
mysql_query("INSERT INTO `notification` (`avtor`, `id_user`, `id_object`, `type`, `time`) VALUES ('$user[id]', '$ank_reply[id]', '$news[id]', 'news_komm', '$time')");
}
$_SESSION['message'] = 'Ваш комментарий успешно принят';
header('Location: ?id=' . intval($_GET['id']) . '&page=' . intval($_GET['page']));
exit;
}
}
$set['title'] = '' . text($news['title']);
include_once '../sys/inc/thead.php';
title();
aut();
err();
//Содержимое
echo '<table style="border-bottom:none;" class="mess">';
echo '<td width="3%">';
echo ''. avatar($author['id']);
echo '</td>';
echo '<td>';
echo ''. group($author['id'])
. user::nick($author['id'])
. medal($author['id'])
. online($author['id']);
echo '</br>Добавлено '. vremja($news['time']);
echo '</td>';
echo '</table>';
echo '<div class="mess">';
echo '' . text($news['title']);
echo '</br></br>';
//Текст новости
echo output_text($news['msg']);
echo '</div>';
//Панелька управления
if (user_access('adm_news')){
echo '<table style="text-align:center;" cellspacing="0" cellpadding="0">';
echo '<td><a style="border-right:none;" class="link" href="edit.php?id=' . $news['id'] . '">Изменить</a></td>';
echo '<td><a class="link" href="delete.php?news_id=' . $news['id'] . '">Удалить</a></td>';
echo '</table>';
}
echo '<div class="hr"></div>';
/*----------------------листинг-------------------
$listr = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `id` < '$news[id]' ORDER BY `id` DESC LIMIT 1"));
$list = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `id` > '$news[id]' ORDER BY `id` ASC LIMIT 1"));
echo '<div class="c2" style="text-align: center;">';
echo '<span class="page">' . ($list['id'] ? '<a href="?id=' . $list['id'].'">« Пред.</a> ':'« Пред. ') . '</span>';
$k_1 = mysql_result(mysql_query("SELECT COUNT(*) FROM `news` WHERE `id` > '$news[id]'"),0)+1;
$k_2 = mysql_result(mysql_query("SELECT COUNT(*) FROM `news`"),0);
echo ' (' . $k_1 . ' из ' . $k_2 . ') ';
echo '<span class="page">' . ($listr['id'] ? '<a href="?id=' . $listr['id'] . '">След. »</a>' : ' След. »') . '</span>';
echo '</div>';
/*----------------------alex-borisi---------------*/
// Колличество комментариев
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '".intval($_GET['id'])."' "),0);
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
// Выборка постов
$q = mysql_query("SELECT * FROM `news_komm` WHERE `id_news` = '" . intval($_GET['id']) . "' ORDER BY `id` $sort LIMIT $start, $set[p_str]");
echo '<table class="post">';
if ($k_post == 0)
{
echo '<div class="gmenu" id="no_object">';
echo 'Комментариев нет';
echo '</div>';
}
else
{
/*------------сортировка по времени--------------
if (isset($user))
{
echo '<div id="comments" class="menus">';
echo '<div class="webmenu">';
echo '<a href="?id=' . $news['id'] . '&page=' . $page . '&sort=1" class="' . ($user['sort'] == 1 ? 'activ' : null) . '">Внизу</a>';
echo '</div>';
echo '<div class="webmenu">';
echo '<a href="?id=' . $news['id'] . '&page=' . $page . '&sort=0" class="' . ($user['sort'] == 0 ? 'activ' : null) . '">Вверху</a>';
echo '</div>';
echo '</div>';
}
/*---------------alex-borisi---------------------*/
}
while ($post = mysql_fetch_assoc($q))
{
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = $post[id_user] LIMIT 1"));
$num++;
echo '<table class="mess">';
echo '<td style="vertical-align: top;" width="3%">';
if (isset($user) && $user['id'] != $ank['id'])
echo '<a href="?id=' . $news['id'] . '&page=' . $page . '&response=' . $ank['id'] . '">';
echo ''. avatar($ank['id']) . '</a>';
echo '</td><td>' . group($ank['id']) . user::nick($ank['id']);
echo medal($ank['id']) . online($ank['id']) . ' <span style="float:right;font-size: .7em;">' . vremja($post['time']) . '</span><br>';
echo output_text($post['msg']) . '';
echo '</td></table>';
if (isset($user)) {
if (isset($user) && ($user['level'] > $ank['level'] || $user['level'] != 0 && $user['id'] == $ank['id']))
echo '<span style="float: right; margin: -20px 10px 0px 0px; font-size: 12px;"><a href="delete.php?id=' . $post['id'] . '"><i class="fas fa-times-circle"></i></a></span>';
}
}
echo '</table>';
// Вывод страниц
if ($k_page>1)str("news.php?id=" . intval($_GET['id']) . '&', $k_page,$page);
// Форма для комментариев
if (isset($user))
{
echo '<div class="hr"></div>';
echo '<div class="mess">';
echo '<form method="post" name="message" action="?id=' . intval($_GET['id']) . '&page=' . $page . REPLY . '">';
if (is_file(H.'style/themes/' . $set['set_them'] . '/altername_post_form.php'))
include_once H.'style/themes/' . $set['set_them'] . '/altername_post_form.php';
else
echo $tPanel . '<textarea placeholder="Введите сообщение..." name="msg">' . $insert . '</textarea><br />';
echo '<table>';
echo '<td><input value="Отправить" type="submit" /></td>';
?><td width="1"><a href="#" onclick="$('.smile').toggle();return false;"><i style="color: #757577; font-size: 18px;" class="far fa-smile"></i></a></td><?
echo '</table>';
echo '</form>';
echo '</div>';
include '../ajax/smile.php';
}
echo '<a class="link" href="index.php"><i class="fas fa-angle-left"></i> Все новости</a>';
include_once '../sys/inc/tfoot.php';
?>