Просмотр файла forum/message.php

Размер файла: 11Kb
<?
/*
=============================================
Движок:  SHCMS Engine
=============================================
Название файла: Форум
=============================================
Official website: http://shcms.ru
=============================================
*/
define('SHCMS', true);
include_once'../system/inc/basic_settings.php';
    if($_GET['id']){ $id = $_GET['id'];}
$title_forum = mysql_fetch_array(mysql_query("SELECT * FROM `forum_them` WHERE `id`='$id'"));
$desc_forum = mysql_fetch_array(mysql_query("SELECT * FROM `forum_mess` WHERE `id_them`='$title_forum[id]'"));
$shcmsengine['title'] = Lang::get('Тема %s',$title_forum['name']);

    //META информацию (description, keywords)
        $shcmsengine['keywords'] = $title_forum['name'];
        $shcmsengine['description'] = $desc_forum['message'];

	include_once'../template/head.php';

    //Обновляем счетчик просмотров
        mysql_query("UPDATE `forum_them` SET `count` = '".($title_forum['count']+1)."' WHERE `id` = '$id'");
    //

    //Счетчик постов
        $count_posts = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_mess` WHERE `id_them` = '$id'"),0);
    //

	$categorie = mysql_fetch_array(mysql_query("SELECT * FROM `forum_cat` WHERE `id`='$title_forum[id_cat]'"));
    $razdel = mysql_fetch_array(mysql_query("SELECT * FROM `forum_razd` WHERE `id`='$title_forum[id_razd]'"));
        echo '<div class="maintext"><a href="razd.php?id='.$title_forum['id_cat'].'">'.$categorie['name'].'</a> | 
            <a href="them.php?id='.$title_forum['id_razd'].'">'.$razdel['name'].'</a> | <strong>'.$title_forum['name'].'</strong></div>';
       $allfield = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_mess` WHERE `id_them`='$id'"),0);
       $newlist = new Navigation($allfield, 10, true); 
       $msy = mysql_query("SELECT * FROM `forum_mess` WHERE `id_them`='$id' ORDER BY `id` DESC  ". $newlist->limit()."");
       $mysql_mess = mysql_fetch_array($msy);
       $yels = mysql_fetch_array(mysql_query("SELECT * FROM `forum_them` WHERE `id`= '$id'"));
            if(!$id) {
                errors(Lang::get("Такой темы не существует"));
                header('Refresh: 1; url=/forum');
	            include_once'../template/foot.php';
                exit();
            }
            if($title_forum['close'] == 1){
                if($user_id){
                    echo '<div class="maintitle mainrazd">'.Lang::get('Текст комментария:').'</div>';
                    echo '<div class="maintext">';
		            $form = new form("?id=$id");
		            $form->textarea(false,'text','',true);
					    if($title_forum['upload'] == 1) {
		                    $form->input(false,'filenew','checkbox','1',true,false,false,Lang::get('Прикрепить файл'));
					    }
					    if($count_posts > $title_forum['max_post']) {
					        $form->error(Lang::get('Превышен лимит постов в данной теме'),'info.png');
					    }else {
		                    $form->submit(Lang::get('Отправить'),'submit');
	                        $form->submit(Lang::get('Обновить'),'resfresh');
					    }
		                    $form->finish();
                    echo '</div>';
                }else {
	                echo '<div class="maintitle mainrazd"><img src="../template/icon/info.png">&nbsp;'.Lang::get('Информация').'</div>';
	                echo '<div class="maintext">'.Lang::get('<b>Не авторизованные</b> посетители, не могут оставлять комментарии в форуме').'</div>';
	            }
            }
		    //else{
		        //errors(Lang::get('Тема закрыта для обсуждений'));
		    //}
        if($_POST['submit']){
            $submit = $_POST['submit'];
        }
        if(isset($submit)) {
            if($_POST['text']){
                $message = $_POST['text'];
            }		
            if(empty($message)){
                errors(Lang::get('Введите описание'));
                header('Refresh: 1; url=?id='.$id.'&' . $conservation . '&' );
	            include_once'../template/foot.php';
                exit();
            }

	    $message = stripslashes($message);
        $message = htmlspecialchars($message);
	  
	  	if($settings_shcms['antilink'] == true) {
	        $message = system_function::antilink($message);
	    }
	    if($settings_shcms['antimat'] == true) {
            $message = system_function::antimat($message);
	    }
        if(strlen($message)< 0 ||  strlen($message) >3000){
            errors(Lang::get('Описание должен быть не больше 3000 символов'));
            exit();
        }
	
            if(isset($message)) { 
  			    if($count_posts > $title_forum['max_post']) {
				    echo '<img src="../template/icon/info.png">&nbsp;'.Lang::get('Превышен лимит постов в данной теме');
			    }else {
                        $messag = mysql_query("INSERT INTO `forum_mess` (`id_cat`,`id_razd`,`id_them`,`message`,`time`,`id_user`) VALUES ('$yels[id_cat]','$yels[id_razd]','$id','".my_esc($message)."','".time()."','$user_id')");
                    mysql_query("UPDATE `forum_them` SET `time_last` = '".time()."' WHERE `id` = '$desc_forum[id_them]'");
	                    $balls = $user4['ball'] +1;
                    mysql_query("UPDATE `users` SET `ball`='$balls' WHERE `id`='$user_id'");
                        if($messag == true) {
                            messag(Lang::get('Сообщение добавлено'));
	                            if($_POST['filenew'] == 1) {
	                                header('Location: files.php?id='.$id);
	                            }else {
                                    header('Refresh: 1; url=?id='.$id.'&' . $conservation . '&' );
	                            }
	                        include_once'../template/foot.php';
                            exit();
                        }
                        else{
                            errors(Lang::get('Сообщение не добавлено'));
                            header('Refresh: 1; url=?id='.$id.'&' . $conservation . '&' );
	                        include_once'../template/foot.php';
                            exit();
                        }
                }
            }
        }			
        if($mysql_mess == null){
	        echo '<div class="posts">'.Lang::get('В теме нет сообщений').'</div>';
	    }
        else {
            do{
                $files_mysql = mysql_query("SELECT * FROM `forum_files` WHERE `them_id` = '$id' and `post_id` = '$mysql_mess[id]'");
                $files_count = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_files` WHERE `them_id` = '$id' and `post_id` = '$mysql_mess[id]'"),0);
                //После закрытия темы
				if($mysql_mess['id_user'] == 0) {
	                echo '<div style="color:red;" class="maintitle mainrazd"><img src="../template/icon/info.png">&nbsp;Система форума';
                    echo '<span class="maintime">'.$timedate->times($mysql_mess['time']).' </span></div>';	  
	            //Открытая тема
				}else {
	                echo '<div class="maintitle">';
                    users_profile($mysql_mess['id_user']);
                    echo '<span class="maintime">'.$timedate->times($mysql_mess['time']).' </span></div>';
	            }
	                echo '<div class="maintext">';
                        if($title_forum['id'] == $user_id || $user4['team'] == 6)  {
	                        echo '<span style="float:right">
	                            <a href="/forum/delete.mess.php?id='.$id.'&id_del='.$mysql_mess['id'].'"><img src="../template/icon/delete.png"></a></span>';
                        }
	                if(mysql_num_rows($files_mysql) >0) {
		                echo '<div class="mainrazd">'.processing($mysql_mess['message']).'</div><br/>';
	  	                echo '<div class="maintitle mainrazd">'.Lang::get('Прикрепленные файлы:').$files_count.'</div>';
					}else {
		                echo processing($mysql_mess['message']);
		            }
	        while($forum_files = mysql_fetch_array($files_mysql)) {
			
	            if($forum_files['type'] == 'zip' or $forum_files['type'] == 'rar' ) {
                    echo '<div class="posts"><img src="../download/icons/zip.png"> ' .$forum_files['text'].' <span class="mainforum">'.size($forum_files['size']).'</span></div>';
                }elseif($forum_files['type'] == 'gif') {
                    echo '<div class="posts"><img src="../download/icons/gif.png"> ' .$forum_files['text'].' <span class="mainforum">'.size($forum_files['size']).'</span></div>';
                }elseif($forum_files['type'] == 'png') {
                    echo '<div class="posts"><img src="../download/icons/png.png"> ' .$forum_files['text'].' <span class="mainforum">'.size($forum_files['size']).'</span></div>';
                }elseif($forum_files['type'] == 'jpg') {
                    echo '<div class="posts"><img src="../download/icons/jpg.png"> ' .$forum_files['text'].' <span class="mainforum">'.size($forum_files['size']).'</span></div>';
                }elseif($forum_files['type'] == 'mp3' or $forum_files['type'] == 'midi' or $forum_files['type'] == 'wav' or $forum_files['type'] == 'wma') {
                    echo '<div class="posts"><img src="../download/icons/mp3.png"> ' .$forum_files['text'].'  <span class="mainforum">'.size($forum_files['size']).'</span></div>';
                }elseif($forum_files['type'] == 'mp4' or $forum_files['type'] == 'flv' or $forum_files['type'] == 'avi' or $forum_files['type'] == '3gp' or $forum_files['type'] == 'mpg') {
                    echo '<div class="posts"><img src="../download/icons/mp4.png"> ' .$forum_files['text'].' <span class="mainforum">'.size($forum_files['size']).'</div>';
                }elseif($forum_files['type'] == 'php') {
                    echo '<div class="posts"><img src="../download/icons/php.png"> ' .$forum_files['text'].' <span class="mainforum">'.size($forum_files['size']).'</span></div>';
                }else {
                    echo '<div class="posts"> ' .$forum_files['text'].' <span class="mainforum">'.size($forum_files['size']).'</span></div>';
                }
            }
        echo '</div>';
    } 
  while($mysql_mess = mysql_fetch_array($msy));
        echo '<div class="pages">';
        echo $newlist->pagination("id=$id");
        echo '</div>';
        }

        if($user4['team'] == 6){
            echo '<div class="posts"><a href="/forum/edit.them.php?id='.$id.'">'.Lang::get('Параметры темы').'</a></div>';
            echo '<div class="posts"><a href="/forum/delete.them.php?id='.$id.'">'.Lang::get('Удаление темы').'</a></div>';
	    }
	echo '</div>';
	
	
	include_once'../template/foot.php';
?>