File size: 2.73Kb
<?
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';
// Только для пользователей
if (!isset($user))header("location: /index.php?");
define ('id', isset( $_GET['id'] ) ? abs(intval($_GET['id'])) : 0);
define ('page', isset( $_GET['page'] ) ? abs(intval($_GET['page'])) : 0);
$act = mysql_fetch_assoc(mysql_query("SELECT * FROM `news` WHERE `id` = '".id."' LIMIT 1"));
// проверяем существует новость
if (!empty($act)) {
if (isset($_POST['save']) && isset($user))
{
$msg = htmlspecialchars($_POST['msg']);
$mat = antimat($msg);
if ($mat){
$_SESSION['message'] = 'В тексте сообщения обнаружен мат: '.$mat;
header('Location: /news/news/?id=' . $act['id'] . '&page=' . page .'');
exit;
}
if (strlen2($msg)>1024){
$_SESSION['message'] = 'Сообщение слишком длинное';
header('Location: /news/news/?id=' . $act['id'] . '&page=' . page .'');
exit;
}
if (strlen2($msg)<2){
$_SESSION['message'] = 'Короткое сообщение';
header('Location: /news/news/?id=' . $act['id'] . '&page=' . page .'');
exit;
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `news_komm` WHERE `id_news` = '" . $act['id'] . "' AND `id_user` = '$user[id]' AND `msg` = '" . my_esc($msg) . "' LIMIT 1"),0) != 0){
$_SESSION['message'] = 'Ваше сообщение повторяет предыдущее';
header('Location: /news/news/?id=' . $act['id'] . '&page=' . page .'');
exit;
}
mysql_query("INSERT INTO `news_komm` (`id_user`, `time`, `msg`, `id_news`) values('$user[id]', '$time', '" . my_esc($msg) . "', '" . $act['id'] . "')");
include_once H.'sys/add/user.active.php';
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]', '$act[id]', 'news_komm', '$time')");
}
}
$_SESSION['message'] = 'Ваш комментарий добавлен';
header('Location: /news/news/?id=' . $act['id'] . '&page=' . page .'');
exit;
}
}else{$_SESSION['message'] = 'Ошибка запись не найдена';header("location: /news/");}
?>