Просмотр файла element_forum/element_subforum_other_create.php

Размер файла: 4.22Kb
<?php
	/// Общий форум
	
	if ($subforum['lost_dostype'] > 0) {
		if ($user['lost_privilege'] != 3 AND !in_array($user['lost_id'],$moderation)) {
			$title = 'Доступ закрыт';
			$error1 = 'Вы не можете смотреть этот раздел, так как руководство ограничило к нему доступ<br/><br/><a class="white" href="/forum">К списку разделов</a>';
			require_once 'element_error_page.php';
			exit;
		}
	}
	
	if ($subforum['lost_news'] > 0 AND $user['lost_privilege'] < 2) {
		$title = 'Доступ закрыт';
		$error1 = 'Вы не можете смотреть этот раздел, так как руководство ограничило к нему доступ<br/><br/><a class="white" href="/forum">К списку разделов</a>';
		require_once 'element_error_page.php';
		exit;
	}
	
	if ($user['lost_level'] < element_settings_game('lost_forum_create_topic') AND $user['lost_privilege'] < 2) {
		$title = 'Доступ закрыт';
		$error1 = 'Вы не можете смотреть этот раздел, так как руководство ограничило к нему доступ<br/><br/><a class="white" href="/forum">К списку разделов</a>';
		require_once 'element_error_page.php';
		exit;
	}
	$ban = BanUserCountActive($user['lost_id']);
	
	if ($ban > 0) {
		$title = 'Доступ закрыт';
		$error1 = 'Вы не можете смотреть этот раздел, так как руководство ограничило к нему доступ<br/><br/><a class="white" href="/forum">К списку разделов</a>';
		require_once 'element_error_page.php';
		exit;
	}
	
	$title = 'Новый топик';
	require_once './element_include/element_head.php';
	require_once './element_include/element_header_user_true.php';
	require_once './element_function/element_function_forum.php';
	
	if ($go == 'add') {
		$title1 = (isset($_POST['title']) AND !empty($_POST['title'])) ? htmlspecialchars(addslashes(trim($_POST['title']))) : false;
		$text = (isset($_POST['text']) AND !empty($_POST['text'])) ? htmlspecialchars(addslashes(trim($_POST['text']))) : false;
			
		if (!$title1) $error = 'Поле \'заголовок\' обязательно для ввода<br/>';
		if (!$text) $error .= 'Поле \'сообщение\' обязательно для ввода<br/>';
		if (mb_strlen($title1, 'utf-8') < 3 OR mb_strlen($title1, 'utf-8') > 50) $error .= 'Заголовок может содержать не меньше 3 и не больше 50 символов';
			
		if (!isset($error)) {
			if ($user['lost_privilege'] > 0) $text = AddBB($text);
		
			mysql_query("INSERT INTO `element_forum_topic_2` SET `lost_name` = '$title1',
															     `lost_text` = '$text',
															     `lost_user` = '$user[lost_id]',
															     `lost_time` = '".time()."',
															     `lost_time_comment` = '".time()."',
															     `lost_subforum` = '$id',
															     `lost_close` = '0',
															     `lost_pric` = '0'");
			$insert_topic = mysql_insert_id();
			header('Location: /forum/topic?id='.$insert_topic);
			exit;
		} else echo '<div class="nfl p5 mb5 cntr small red mlra">'.$error.'</div>';
	}	
	
	
	echo '<div class="nfl p5 mb5 mt5 small mlra">';
	echo '<div class="cntr"><img width="16" height="16" alt="" src="/images/icons/forum_new.png"/> <a href="/forum">Форум</a><span class="white"> / <a href="/forum/subforum?id='.$id.'">'.$subforum['lost_name'].'</a></span></div>';
	echo '<div class="hr mt5 mb5"></div>';

	echo '<div class="p5 cntr">
			<form method="post" action="/forum/create?id='.$id.'&go=add">
				<span class="small white">Заголовок</span><br/>
				<input class="fdark w96 mb5" type="text" size="20" maxlength="60" value="'.(($title1) ? $title1 : '').'" name="title"/><br/>
				<span class="small white">Сообщение</span><br/>
				<textarea class="w96 mb5 fdark" rows="5" name="text">'.(($text) ? $text : '').'</textarea><br/>
				<span class="button w50 mt5"><input type="submit" class="ttl" name="submit" value="Создать"/></span>
			</form>
		</div>';
	
	
	echo '</div>';

?>