View file forum/new.them.php

File size: 3.11Kb
<?
/*
=============================================
Движок:  SHCMS Engine
=============================================
Название файла: Форум
=============================================
Official website: http://shcms.ru
=============================================
*/
define('SHCMS', true);
if($_GET['id']){$id = $_GET['id'];}
include_once'../system/inc/system_core.php';
$themes = mysql_fetch_array(mysql_query("SELECT * FROM `forum_razd` WHERE id=$id"));
$shcmsengine['title'] = Lang::get('Создать новую тему в разделе %s',$themes['name']);
include_once'../template/head.php';
engine::available();


if($_POST['prosmotr'])
{$prosmotr = $_POST['prosmotr'];}

if(isset($prosmotr))
{

if($_POST['text'])
{$text = $_POST['text'];}

if(empty($text))
{
engine::errors(Lang::get('Вы не ввели текст'));
	include_once'../template/foot.php';
exit;
}

echo '<div class="maintitle">';
echo ''.users_profile($user_id).'</div>';

echo '<div class="maintext">'.$_POST['text'].'</div>';

	include_once'../template/foot.php';
exit;
}




$q = mysql_query("SELECT * FROM `forum_razd` WHERE `id` = '$id'");
if (!mysql_num_rows($q)) {
    header('Refresh: 1; url=./');
    errros(Lang::get('В данном разделе нельзя создавать темы'));
    include_once'../template/foot.php';
    exit();
	}

if($_POST['submit']) {
    $submit = $_POST['submit'];
	}

if(isset($submit)) {

if($_POST['name']) {
    $name = $_POST['name'];
	}
if($_POST['text']) {
    $text = $_POST['text'];
	}

	
if(isset($name) && isset($text)) {

$themesdb = mysql_query("INSERT INTO `forum_them` (`id_razd`,`id_cat`,`name`,`time`,`user_id`) VALUES ('$id',$themes[id_cat],'$name','$time_date','$user_id')");
$unid = mysql_fetch_array(mysql_query("SELECT * FROM `forum_them` WHERE `id_razd` = '$id' ORDER BY `id` DESC"));
mysql_query("INSERT INTO `forum_mess` (`id_cat`,`id_razd`,`id_them`,`id_user`,`message`,`time`) VALUE ('$themes[id_cat]','$id','$unid[id]','$user_id','$text','".time()."')");


if($themesdb == true) {
    engine::correct(Lang::get('Тема успешно создана'));
    header('Refresh: 1; url=message.php?id='.$unid['id'].'&' . $conservation . '&' );
    include_once'../template/foot.php';
    exit();
    } else {
    engine::errors(Lang::get('Ошибка создании нового раздела'));
    header('Refresh: 1; url=them.php?id='.$id.'&' . $conservation . '&' );
	include_once'../template/foot.php';
    exit; }}

    }

echo '<form action="?id='.$id.'" method="post">';
echo Lang::get('Название темы:').'<br/><input type="text" name="name"><br/>';
echo Lang::get('Сообщение:').'<br/><textarea id="text" name="text"></textarea><br/>';
echo '<br/><input type="submit" name="submit" value="'.Lang::get('Создать тему').'">
<input type="submit" name="prosmotr" value="'.Lang::get('Предпросмотр').'"></form>';


echo '<div class="posts"><a href="them.php?id='.$id.'">'.Lang::get('Назад').'</a></div>';
	include_once'../template/foot.php';
?>