View file forum/message.php

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


   $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)
    {
      echo'<div class="errors">Вы зашли неправильно</div>';
      header('Refresh: 1; url=/forum');
	  include_once'../template/foot.php';
      exit();
    }
      if($title_them['close'] != 1)
	  {
  if($user_id)
  {
    if($brodilka == "web")
    {
	$text_list->text_lister();
	}

      echo '<form action="?id='.$id.'" method="post" name="form">';
      echo 'Текст: <textarea name="text"></textarea>';
      echo '<input type="submit" name="submit">';
    if($resting['trans'] == 1)
	{
      echo '<br/>Транслит:<br/><select name="tran">
            <option value="0">Без транслита</option>
            <option value="1">с ENG на RUS</option>
            <option value="2">с RUS на ENG</option>
            </select><br/>';
	}
  }
        }
  if($_POST['submit'])
  {
    $submit = $_POST['submit'];
  }
        if(isset($submit))
        {
  if($_POST['text'])
  {
    $message = $_POST['text'];
  }
  if($_POST['tran'] == 1)
  {
    $message = $translits->translit_rus($message);
  }
  elseif($_POST['tran'] == 2)
  {
    $message = $translits->translit_eng($message);
  }

    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(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','$message','$time_date','$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>';
      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
  {
      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">'.processing($mysql_mess['message']).'';

    if($title_them['id'] == $user_id || $user4['team'] == 6)
    {
	echo '<span style="float:right">
	      <a href="/forum/delete.mess.php?id='.$id.'&id_del='.$mysql_mess['id'].'">Удалить</a>
		  </span>';
    }
      echo '</div>';
  } 
  while($mysql_mess = mysql_fetch_array($msy));
      echo '<div class="pages">';
      echo $newlist->pagination("id=$id");
      echo '</div>';
    }

      echo '<div class="posts"><a href="javascript:history.back()">Назад</a></div>';
    if($users_nav['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>';
	}
	
	include_once'../template/foot.php';
?>