View file ä󿪫¬/modules/groups/forum/comm.php

File size: 1.97Kb
<?php
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
    require_once "../../../sys/inc/$inc.php";
}


if (isset($_POST['msg']) && isset($user))
{
$msg = htmlspecialchars($_POST['msg']);
if (utf8_strlen($msg)>1024){$err='Сообщение слишком длинное';}

elseif (utf8_strlen($msg)<2){$err='Короткое сообщение';}

elseif ($pdo->query(("SELECT COUNT(*) FROM `soo_forum_comm` WHERE `id_post` = '".intval($_GET['id_them'])."' AND `id_user` = '$user[id]' AND `msg` = '".htmlspecialchars($msg)."' LIMIT 1"),0)->fetchColumn()!=0){$err='Ваше сообщение повторяет предыдущее';}
$pdo->query("INSERT INTO `soo_forum_comm` (`id_user`, `time`, `msg`, `id_post`) values('$user[id]', '$time', '".$msg."', '".intval($_GET['id_them'])."')");

$them = $pdo->query(("SELECT * FROM `soo_forum_thems` WHERE `id` = '".intval($_GET['id_them'])."' AND `id_forum` = '".intval($_GET['id_forum'])."' AND `id_soo` = '".intval($_GET['id'])."' LIMIT 1"))->fetch(PDO::FETCH_ASSOC);


$avtor=get_user($them['id_user']);
///////////////////////////журнал///////////////



if ($them['id_user']!=$user['id']){
if ($avtor['jurnal_forum_soo_comm']==1){	
$name2="$user[nick] прокомментировал(а) вашу тему в группе $soo[name]";
$msg2="[url=/modules/groups/forum/index.php?id=".intval($_GET['id'])."&id_forum=".intval($_GET['id_forum'])."&id_them=".intval($_GET['id_them'])."]$them[name][/url]";
$pdo->query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `name`, `type`, `time`) values('0', '$them[id_user]', '".mysql_real_escape_string($msg2)."', '".htmlspecialchars($name2)."', 'snews_komm', '$time')");
}
}
//////////////////////////////////////////////





$_SESSION['message'] = 'Комментарий успешно добавлен';
header("Location: index.php?id=".intval($_GET['id'])."&id_forum=".intval($_GET['id_forum'])."&id_them=".intval($_GET['id_them'])."");
exit;

}
?>