Файл: element_forum/element_subforum_town_create.php
Строк: 91
<?php
    // Городской форум
    
    $my_town_id = ($subforum['lost_town'] == $user['lost_town']) ? true : false;    // Проверяем, мой город или нет
    $cache_town = cache_town($subforum['lost_town']);                                // Кэш города
    $ban = BanUserCountActive($user['lost_id']);
    
    if ($my_town_id) {
        // Если мое звание меньше нужного, не впускаем
        if ($town_other[0] > $subforum['lost_town_ready'] AND $user['lost_privilege'] != 3) {
            $title = 'Доступ закрыт';
            $error1 = 'Вы не можете читать этот раздел. Руководство города ограничило к нему доступ<br/><br/><a class="button w50 white" href="/forum?go=town&id='.$id.'">К списку разделов</a>';
            require_once 'element_error_page.php';
            exit;
        }
    } else {
        // Если раздел настроен для чтение выше гостей, не впускаем
        if ($subforum['lost_town_ready'] != 8 AND $user['lost_privilege'] != 3) {
            $title = 'Доступ закрыт';
            $error1 = 'Вы не можете читать этот раздел. Руководство города ограничило к нему доступ<br/><br/><a class="button w50 white" href="/forum?go=town&id='.$id.'">К списку разделов</a>';
            require_once 'element_error_page.php';
            exit;
        }
    }
    
    if ($my_town_id) {
        if ($town_other[0] > $subforum['lost_town_topic'] AND $user['lost_privilege'] != 3) {
            $title = 'Доступ закрыт';
            $error1 = 'Вы не можете читать этот раздел. Руководство города ограничило к нему доступ<br/><br/><a class="button w50 white" href="/forum?go=town&id='.$id.'">К списку разделов</a>';
            require_once 'element_error_page.php';
            exit;
        }
    } else {
        if ($subforum['lost_town_topic'] != 8) {
            $title = 'Доступ закрыт';
            $error1 = 'Вы не можете читать этот раздел. Руководство города ограничило к нему доступ<br/><br/><a class="button w50 white" href="/forum?go=town&id='.$id.'">К списку разделов</a>';
            require_once 'element_error_page.php';
            exit;
        }
        
        if ($ban > 0) {
            $title = 'Доступ закрыт';
            $error1 = 'Вы не можете читать этот раздел. Руководство города ограничило к нему доступ<br/><br/><a class="button w50 white" href="/forum?go=town&id='.$id.'">К списку разделов</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'] > 1) $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?id='.$cache_town['lost_id'].'">Форум "'.$cache_town['lost_name'].'"</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>';
?>