Файл: 4mast/profmas.ru/data/forum/forum.msg.php
Строк: 135
<?php
require_once('../../includes/Headers.php');
require_once('../../includes/PDO_func.php');
if($us == false) {
header('location: /login/auth');
exit;
}
$forum = 'forum';
$thema = DB::$dbs->queryFetch("SELECT `id`,`name`,`type`,`id_pr`,`id_r` FROM `forum_t` where `id` = ? limit 1",array($id));
if($thema['name'] == null){header('location:/forum');}
if($thema['type']==2 AND $us['level']<=2)
{
H('Ошибка!', '<a href="/forum/index" style="color:white;">Форум</a>');
echo'<div class="lst">Эта тема была удалена!</div>';
F();
exit;
}
$podrazd = DB::$dbs->queryFetch("SELECT `id`,`name` FROM `forum_pr` where `id` = ? limit 1",array(abs(intval($thema['id_pr']))));
$razd = DB::$dbs->queryFetch("SELECT id FROM `forum_r` where `id` = ? limit 1",array(abs(intval($thema['id_r']))));
if(DB::$dbs->querySingle("SELECT count(id) from `forum_visit` where `id_t` = ? and `us` = ?",array($thema['id'],$us['id'])) == 0)
{
DB::$dbs->query("INSERT INTO `forum_visit` (`id_t`,`us`,`time`) VALUES (?,?,?)",array($thema['id'],$us['id'],time()));
}
else
{
DB::$dbs->query("UPDATE `forum_visit` set `time` = ? where `id_t` = ? and `us` = ? limit 1",array(time(),$thema['id'],$us['id']));
}
$cp = DB::$dbs->querySingle("SELECT count(id) from `forum_p` where `id_t` = ?",array($thema['id']));
$uid = (isset($us['id'])?$us['id']:189);
H ($thema['name'], ' <a href="/forums/' . $razd['id'] . '/' . $podrazd['id'] . '" style="color:white;">' . $podrazd['name'] . '</a> | ' .$thema['name']);
if($thema['type'] == 2)
{
echo'<div class="error"><b>Тема удалена!</b></div>';
}
elseif($thema['type'] == 0)
{
echo'<div class="error"> <b>Тема закрыта!</b></div>';
}
// The post
if($do == 'post'){
$message = (isset($_POST['message']) AND !empty($_POST['message'])) ? addslashes(htmlspecialchars($_POST['message'])) : false;
if(DB::$dbs->querySingle("SELECT count(id) from `forum_p` where `id_t` = ? AND `us` = ? and `text` = ?",array($thema['id'],$us['id'],$message))>=1){
echo '<div class="error">Вы уже писали подобное</div>';
$error = true;
}
if(!$message){
echo '<div class="error">Пустое сообщение!</div>';
$error = true;
}
if(@file_exists($_FILES['filename']['tmp_name']))
{
if(!$_FILES['filename']['size'] != 0 and $_FILES['filename']['size'] > 1024000) {
echo '<div class="error">Слишком большой файл!</div>';
$error = true;
}
$filetype = array ( 'jpg', 'gif', 'png', 'jpeg', 'bmp', 'zip', 'rar', '7z', 'txt', 'mp3', 'avi', 'mp4', '3gp' );
$upfiletype = substr($_FILES['filename']['name'], strrpos( $_FILES['filename']['name'], "." )+1);
if(!in_array($upfiletype,$filetype)){
echo '<div class="error">Вы пытаетесь загрузить недопустимый формат файла...</div>';
$error = true;
}
}
if($error == false){
DB::$dbs->query("INSERT INTO `forum_p` (`id_r`,`id_pr`,`id_t`,`us`,`text`,`time`) VALUES (?,?,?,?,?,?)",array($thema['id_r'],$thema['id_pr'],$thema['id'],$us['id'],$message,time()));
$post_id = DB::$dbs->lastInsertId();
if($thema['id'] == 555) {
@require_once ''.$_SERVER['DOCUMENT_ROOT'].'/includes/SUPPORT.php';
$m = support($us['nick'],$message);
if ($m !=NULL){
$mes = '[b]'.$us['nick'].'[/b], '.$m;
DB::$dbs->query("INSERT INTO `forum_p` (`id_r`,`id_pr`,`id_t`,`us`,`text`,`time`) VALUES (?,?,?,?,?,?)",array($thema['id_r'],$thema['id_pr'],$thema['id'],189,$mes,time()+0));
}
}
DB::$dbs->query("UPDATE `forum_t` set `time` = ?,`last` = ? where `id` = ? limit 1",array(time(),$us['id'],$thema['id']));
if(@file_exists($_FILES['filename']['tmp_name'])){
$fgn = '4MAST'.$uid.'_'.rand(1234,5678).'.'.$upfiletype;
copy ($_FILES['filename']['tmp_name'], FILES . '/forum/' . $fgn);
DB::$dbs->query("INSERT INTO `forum_f` (`id_t`,`id_p`,`name`) VALUES (?,?,?)",array($thema['id'],$post_id,$fgn));
}
$rss = DB::$dbs->query("SELECT * FROM `forum_podp` where `id_t` = ? and `us` != ? ",array($thema['id'],$us['id']));
while($_rss = $rss -> fetch()){
$value = '<a href="/us'.$us['id'].'"/>'.Nick($us['id']).'</a> написал в теме <a href="/forums/thema'.$thema['id'].'/page'.$page.'">'.$thema['name'].'</a>!';
DB::$dbs->query("INSERT INTO `action` set `value` = ?, `t` = ?, `us` = ?, `see` = ?, `razd` = ?",array($value,time(),$_rss['us'],1,$forum));
}
header('location:/forums/thema'.$thema['id'].'/page'.ceil(($cp+1)/10));
}
}
//The end
//The otv
elseif($do == 'otv'){
$message = (isset($_POST['message']) AND !empty($_POST['message'])) ? addslashes(htmlspecialchars($_POST['message'])) : false;
$otvid = $_POST['otv_id'];
$otvnick = $_POST['otv_nick'];
if(DB::$dbs->querySingle("SELECT count(id) from `forum_p` where `id_t` = ? AND `us` = ? and `text` = ?",array($thema['id'],$us['id'],$message))>=1){
echo '<div class="error">Вы уже писали подобное</div>';
$error = true;
}
if(!$message){
echo '<div class="error">Пустое сообщение!</div>';
$error = true;
}
if(@file_exists($_FILES['filename']['tmp_name']))
{
if(!$_FILES['filename']['size'] != 0 and $_FILES['filename']['size'] > 1024000) {
echo '<div class="error">Слишком большой файл!</div>';
$error = true;
}
$filetype = array ( 'jpg', 'gif', 'png', 'jpeg', 'bmp', 'zip', 'rar', '7z', 'txt', 'mp3', 'avi', 'mp4', '3gp' );
$upfiletype = substr($_FILES['filename']['name'], strrpos( $_FILES['filename']['name'], "." )+1);
if(!in_array($upfiletype,$filetype)){
echo '<div class="error">Вы пытаетесь загрузить недопустимый формат файла...</div>';
$error = true;
}
}
if($error == false){
$_message = '[b]'.$otvnick.'[/b], '.$message;
DB::$dbs->query("INSERT INTO `forum_p` (`id_r`,`id_pr`,`id_t`,`us`,`text`,`time`) VALUES (?,?,?,?,?,?)",array($thema['id_r'],$thema['id_pr'],$thema['id'],$uid,$_message,time()));
$post_id = DB::$dbs->lastInsertId();
if($thema['id'] == 53){
@require_once ''.$_SERVER['DOCUMENT_ROOT'].'/data/Plugins/SUPPORT.php';
$m = support($us['nick'],$message);
if ($m!= NULL){
$mes = '[b]'.$us['nick'].'[/b], '.$m;
DB::$dbs->query("INSERT INTO `forum_p` (`id_r`,`id_pr`,`id_t`,`us`,`text`,`time`) VALUES (?,?,?,?,?,?)",array($thema['id_r'],$thema['id_pr'],$thema['id'],189,$mes,time()+1));
}
}
DB::$dbs->query("UPDATE `forum_t` set `time` = ?,`last` = ? where `id` = ? limit 1",array(time(),$us['id'],$thema['id']));
if(@file_exists($_FILES['filename']['tmp_name'])){
$fgn = '4MAST'.$uid.'_'.rand(1234,5678).'.'.$upfiletype;
copy ($_FILES['filename']['tmp_name'], FILES . '/forum/' . $fgn);
DB::$dbs->query("INSERT INTO `forum_f` (`id_t`,`id_p`,`name`) VALUES (?,?,?)",array($thema['id'],$post_id,$fgn));
}
$value = '<a href="/us'.$us['id'].'"/>'.Nick($us['id']).'</a> ответил вам в теме <a href="/forums/thema'.$thema['id'].'/page'.ceil($cp/10).'">'.$thema['name'].'</a>!';
DB::$dbs->query("INSERT INTO `action` set `value` = ?, `t` = ?, `us` = ?, `see` = ?, `razd` = ?",array($value,time(),$otvid,1,$forum));
$rss = DB::$dbs->query("SELECT * FROM `forum_podp` where `id_t` = ? and `us` != ? and `us` != ?",array($thema['id'],$us['id'],$otvid));
while($_rss = $rss -> fetch()){
$value = '<a href="/us'.$us['id'].'"/>'.Nick($us['id']).'</a> написал в теме <a href="/forum/thema'.$thema['id'].'/page'.$page.'">'.$thema['name'].'</a>!';
DB::$dbs->query("INSERT INTO `action` set `value` = ?, `t` = ?, `us` = ?, `see` = ?, `razd` = ?",array($value,time(),$_rss['us'],1,$forum));
}
header('location:/forums/thema'.$thema['id'].'/page'.ceil(($cp+1)/10));
}
}
//The end
//The cit
elseif($do == 'cit'){
$message = (isset($_POST['message']) AND !empty($_POST['message'])) ? addslashes(htmlspecialchars($_POST['message'])) : false;
$citid = $_POST['cit_id'];
$cittext = $_POST['cit_text'];
$citpost = $_POST['cit_post'];
if(DB::$dbs->querySingle("SELECT count(id) from `forum_p` where `id_t` = ? AND `us` = ? and `text` = ?",array($thema['id'],$us['id'],$message))>=1){
echo '<div class="error">Вы уже писали подобное</div>';
$error = true;
}
if(!$message){
echo '<div class="error">Пустое сообщение!</div>';
$error = true;
}
if(@file_exists($_FILES['filename']['tmp_name']))
{
if(!$_FILES['filename']['size'] != 0 and $_FILES['filename']['size'] > 1024000) {
echo '<div class="error">Слишком большой файл!</div>';
$error = true;
}
$filetype = array ( 'jpg', 'gif', 'png', 'jpeg', 'bmp', 'zip', 'rar', '7z', 'txt', 'mp3', 'avi', 'mp4', '3gp' );
$upfiletype = substr($_FILES['filename']['name'], strrpos( $_FILES['filename']['name'], "." )+1);
if(!in_array($upfiletype,$filetype)){
echo '<div class="error">Вы пытаетесь загрузить недопустимый формат файла...</div>';
$error = true;
}
}
if($error == false){
DB::$dbs->query("INSERT INTO `forum_p` (`id_r`,`id_pr`,`id_t`,`us`,`text`,`time`,`cit`) VALUES (?,?,?,?,?,?,?)",array($thema['id_r'],$thema['id_pr'],$thema['id'],$us['id'],$message,time(),$citpost));
$post_id = DB::$dbs->lastInsertId();
if($thema['id'] == 53) {
@require_once ''.$_SERVER['DOCUMENT_ROOT'].'/data/Plugins/SUPPORT.php';
$m = support($us['nick'],$message);
if ($m!= NULL){
$mes = '[b]'.$us['nick'].'[/b], '.$m;
DB::$dbs->query("INSERT INTO `forum_p` (`id_r`,`id_pr`,`id_t`,`us`,`text`,`time`) VALUES (?,?,?,?,?,?)",array($thema['id_r'],$thema['id_pr'],$thema['id'],189,$mes,time()+1));
}
}
DB::$dbs->query("UPDATE `forum_t` set `time` = ?,`last` = ? where `id` = ? limit 1",array(time(),$us['id'],$thema['id']));
if(@file_exists($_FILES['filename']['tmp_name'])){
$fgn = '4MAST'.$uid.'_'.rand(1234,5678).'.'.$upfiletype;
copy ($_FILES['filename']['tmp_name'], FILES . '/forum/' . $fgn);
DB::$dbs->query("INSERT INTO `forum_f` (`id_t`,`id_p`,`name`) VALUES (?,?,?)",array($thema['id'],$post_id,$fgn));
}
$value = '<a href="/us'.$us['id'].'"/> '.Nick($us['id']).' </a> процитировал ваш пост "'.substr($cittext,0,100).'" в теме <a href="/forums/thema'.$thema['id'].'/page'.ceil($cp/10).'">'.$thema['name'].'</a>!';
DB::$dbs->query("INSERT INTO `action` set `value` = ?, `t` = ?, `us` = ?, `see` = ?, `razd` = ?",array($value,time(),$citid,1,$forum));
$rss = DB::$dbs->query("SELECT * FROM `forum_podp` where `id_t` = ? and `us` != ? and `us` != ?",array($thema['id'],$us['id'],$citid));
while($_rss = $rss -> fetch()){
$value = '<a href="/us'.$us['id'].'"/>'.Nick($us['id']).'</a> написал в теме <a href="/forums/thema'.$thema['id'].'/page'.$page.'">'.$thema['name'].'</a>!';
DB::$dbs->query("INSERT INTO `action` set `value` = ?, `t` = ?, `us` = ?, `see` = ?, `razd` = ?",array($value,time(),$_rss['us'],1,$forum));
}
header('location:/forums/thema'.$thema['id'].'/page'.ceil(($cp+1)/10));
}
}
//The end
require_once('../../includes/Footers.php');
?>