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

Размер файла: 7.29Kb
<?
/*
=============================================
Движок:  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'"));
$shcmsengine['title'] = "Тема $title_forum[name]";
include_once'../template/head.php';

$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);
   $id_text = mysql_fetch_array(mysql_query("SELECT * FROM `forum_them` WHERE `id_them`= '$id'"));
   $id_cat = mysql_fetch_array(mysql_query("SELECT * FROM `forum_them` WHERE `id_them`= '$id' "));
   $yels = mysql_fetch_array(mysql_query("SELECT * FROM `forum_them` WHERE `id`= '$id'"));
    if(!$id)
    {
      errors("Такой темы не существует");
      header('Refresh: 1; url=/forum');
	  include_once'../template/foot.php';
      exit();
    }
      if($title_forum['close'] != 1)
	  {
  if($user_id)
  {
  echo '<div class="maintext">';

		$form = new form("?id=$id");
		$form->textarea('<strong>Текст комментария:</strong>','text','',true);
		$form->input(false,'filenew','checkbox','1',true,false,false,'Прикрепить файл');
		$form->submit('Отправить','submit');
	    $form->submit('Обновить','resfresh');
		$form->finish();
echo '</div>';
  }
        }
		else
		{
		errors('Тема закрыта для обсуждений');
		}
  if($_POST['submit'])
  {
    $submit = $_POST['submit'];
  }
        if(isset($submit))
        {
  if($_POST['text'])
  {
    $message = $_POST['text'];
  }

    if(empty($message))
    {
      echo'<div class="errors">Введите описание</div>';
      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)
    {
      echo'<div class="errors">Описание должен быть не больше 3000 символов</div>';
      exit();
    }
	
  if(isset($message))
  {
      $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')");
      $balls = $user4['ball'] +1;
        mysql_query("UPDATE `users` SET `ball`='$balls' WHERE `id`='$user_id'");
    if($messag == true)
    {
      echo '<div class="actshcms">Сообщение добавлено</div>';
	  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
    {
      echo '<div class="errors">Сообщение не добавлено</div>';
      header('Refresh: 1; url=?id='.$id.'&' . $conservation . '&' );
	  include_once'../template/foot.php';
      exit();
    }
  }
        }		
		
    if($mysql_mess == null)
	{
	echo '<div class="posts">В теме нет сообщений</div>';
	}
    else
    {

  do
  {
$files_mysql = mysql_query("SELECT * FROM `forum_files` WHERE `them_id` = '$id' and `post_id` = '$mysql_mess[id]'");
      echo '<div class="maintitle">&nbsp;';
      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>';
    }
      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.'">Параметры темы</a></div>';
      echo '<div class="posts"><a href="/forum/delete.them.php?id='.$id.'">Удаление темы</a></div>';
	}
	echo '</div>';
	
	include_once'../template/foot.php';
?>