示例#1
0
function fatal_lang_error($error, $log = 'general', $sprintf = array())
{
    global $txt, $language, $modSettings, $user_info, $context;
    static $fatal_error_called = false;
    if ($error == 'loginWaitTime_broken' && is_int($sprintf[0])) {
        sleep($sprintf[0]);
        return;
    }
    // Try to load a theme if we don't have one.
    if (empty($context['theme_loaded']) && empty($fatal_error_called)) {
        $fatal_error_called = true;
        @loadTheme();
    }
    // If we have no theme stuff we can't have the lanuage file...
    if (empty($context['theme_loaded'])) {
        die($error);
    }
    $reload_lang_file = true;
    // Log the error in the forum's language, but don't waste the time if we aren't logging
    if ($log || !empty($modSettings['enableErrorLogging']) && $modSettings['enableErrorLogging'] == 2) {
        loadLanguage('Errors', $language);
        $reload_lang_file = $language != $user_info['language'];
        $error_message = empty($sprintf) ? $txt[$error] : vsprintf($txt[$error], $sprintf);
        log_error($error_message, $log);
    }
    // Load the language file, only if it needs to be reloaded
    if ($reload_lang_file) {
        loadLanguage('Errors');
        $error_message = empty($sprintf) ? $txt[$error] : vsprintf($txt[$error], $sprintf);
    }
    setup_fatal_error_context($error_message);
}
示例#2
0
<?php

/**
 * Created by PhpStorm.
 * User: laffu
 * Date: 07/03/2016
 * Time: 10:48
 */
include $_SERVER["DOCUMENT_ROOT"] . "/theWood/back/Models/M_theme.php";
if (isset($_POST['idDomaine'])) {
    $idDomaine = htmlentities(intval($_POST['idDomaine']));
    $themes = loadTheme($idDomaine);
    // envoi du résultat au success
    echo json_encode($themes);
}
示例#3
0
文件: index.php 项目: Ralkage/Elkarte
/**
 * The main dispatcher.
 * This delegates to each area.
 */
function elk_main()
{
    global $modSettings, $user_info, $topic, $board_info, $context;
    // Special case: session keep-alive, output a transparent pixel.
    if (isset($_GET['action']) && $_GET['action'] == 'keepalive') {
        header('Content-Type: image/gif');
        die("GIF89a€!ù,D;");
    }
    // We should set our security headers now.
    frameOptionsHeader();
    securityOptionsHeader();
    // Load the user's cookie (or set as guest) and load their settings.
    loadUserSettings();
    // Load the current board's information.
    loadBoard();
    // Load the current user's permissions.
    loadPermissions();
    // Load BadBehavior before we go much further
    loadBadBehavior();
    // Attachments don't require the entire theme to be loaded.
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest'])) {
        detectBrowser();
    } else {
        loadTheme();
    }
    // Check if the user should be disallowed access.
    is_not_banned();
    // If we are in a topic and don't have permission to approve it then duck out now.
    if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
        fatal_lang_error('not_a_topic', false);
    }
    $no_stat_actions = array('dlattach', 'findmember', 'jsoption', 'requestmembers', 'jslocale', 'xmlpreview', 'suggest', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewadminfile');
    call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions));
    // Do some logging, unless this is an attachment, avatar, toggle of editor buttons, theme option, XML feed etc.
    if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], $no_stat_actions)) {
        // I see you!
        writeLog();
        // Track forum statistics and hits...?
        if (!empty($modSettings['hitStats'])) {
            trackStats(array('hits' => '+'));
        }
    }
    unset($no_stat_actions);
    // What shall we do?
    require_once SOURCEDIR . '/SiteDispatcher.class.php';
    $dispatcher = new Site_Dispatcher();
    // Show where we came from, and go
    $context['site_action'] = $dispatcher->site_action();
    $context['site_action'] = !empty($context['site_action']) ? $context['site_action'] : (isset($_REQUEST['action']) ? $_REQUEST['action'] : '');
    $dispatcher->dispatch();
}
示例#4
0
文件: Themes.php 项目: Kheros/MMOver
function SetThemeSettings()
{
    global $txt, $context, $settings, $modSettings, $sourcedir, $smcFunc;
    if (empty($_GET['th']) && empty($_GET['id'])) {
        return ThemeAdmin();
    }
    $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
    // Select the best fitting tab.
    $context[$context['admin_menu_name']]['current_subsection'] = 'list';
    loadLanguage('Admin');
    isAllowedTo('admin_forum');
    // Validate inputs/user.
    if (empty($_GET['th'])) {
        fatal_lang_error('no_theme', false);
    }
    // Fetch the smiley sets...
    $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
    $set_names = explode("\n", $txt['smileys_none'] . "\n" . $modSettings['smiley_sets_names']);
    $context['smiley_sets'] = array('' => $txt['smileys_no_default']);
    foreach ($sets as $i => $set) {
        $context['smiley_sets'][$set] = htmlspecialchars($set_names[$i]);
    }
    $old_id = $settings['theme_id'];
    $old_settings = $settings;
    loadTheme($_GET['th'], false);
    // Sadly we really do need to init the template.
    loadSubTemplate('init', 'ignore');
    // Also load the actual themes language file - in case of special settings.
    loadLanguage('Settings', '', true, true);
    // Let the theme take care of the settings.
    loadTemplate('Settings');
    loadSubTemplate('settings');
    // Submitting!
    if (isset($_POST['submit'])) {
        checkSession();
        if (empty($_POST['options'])) {
            $_POST['options'] = array();
        }
        if (empty($_POST['default_options'])) {
            $_POST['default_options'] = array();
        }
        // Make sure items are cast correctly.
        foreach ($context['theme_settings'] as $item) {
            // Disregard this item if this is just a separator.
            if (!is_array($item)) {
                continue;
            }
            foreach (array('options', 'default_options') as $option) {
                if (!isset($_POST[$option][$item['id']])) {
                    continue;
                } elseif (empty($item['type'])) {
                    $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
                } elseif ($item['type'] == 'number') {
                    $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
                }
            }
        }
        // Set up the sql query.
        $inserts = array();
        foreach ($_POST['options'] as $opt => $val) {
            $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val);
        }
        foreach ($_POST['default_options'] as $opt => $val) {
            $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val);
        }
        // If we're actually inserting something..
        if (!empty($inserts)) {
            $smcFunc['db_insert']('replace', '{db_prefix}themes', array('id_member' => 'int', 'id_theme' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), $inserts, array('id_member', 'id_theme', 'variable'));
        }
        cache_put_data('theme_settings-' . $_GET['th'], null, 90);
        cache_put_data('theme_settings-1', null, 90);
        // Invalidate the cache.
        updateSettings(array('settings_updated' => time()));
        redirectexit('action=admin;area=theme;sa=settings;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id']);
    }
    $context['sub_template'] = 'set_settings';
    $context['page_title'] = $txt['theme_settings'];
    foreach ($settings as $setting => $dummy) {
        if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) {
            $settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
        }
    }
    $context['settings'] = $context['theme_settings'];
    $context['theme_settings'] = $settings;
    foreach ($context['settings'] as $i => $setting) {
        // Separators are dummies, so leave them alone.
        if (!is_array($setting)) {
            continue;
        }
        if (!isset($setting['type']) || $setting['type'] == 'bool') {
            $context['settings'][$i]['type'] = 'checkbox';
        } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
            $context['settings'][$i]['type'] = 'number';
        } elseif ($setting['type'] == 'string') {
            $context['settings'][$i]['type'] = 'text';
        }
        if (isset($setting['options'])) {
            $context['settings'][$i]['type'] = 'list';
        }
        $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
    }
    // Do we support variants?
    if (!empty($settings['theme_variants'])) {
        $context['theme_variants'] = array();
        foreach ($settings['theme_variants'] as $variant) {
            // Have any text, old chap?
            $context['theme_variants'][$variant] = array('label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, 'thumbnail' => !file_exists($settings['theme_dir'] . '/images/thumbnail.gif') || file_exists($settings['theme_dir'] . '/images/thumbnail_' . $variant . '.gif') ? $settings['images_url'] . '/thumbnail_' . $variant . '.gif' : $settings['images_url'] . '/thumbnail.gif');
        }
        $context['default_variant'] = !empty($settings['default_variant']) && isset($context['theme_variants'][$settings['default_variant']]) ? $settings['default_variant'] : $settings['theme_variants'][0];
    }
    // Restore the current theme.
    loadTheme($old_id, false);
    // Reinit just incase.
    loadSubTemplate('init', 'ignore');
    $settings = $old_settings;
    loadTemplate('Themes');
}
示例#5
0
文件: Errors.php 项目: norv/EosAlpha
function setup_fatal_error_context($error_message)
{
    global $context, $txt, $ssi_on_error_method;
    static $level = 0;
    // Attempt to prevent a recursive loop.
    ++$level;
    if ($level > 1) {
        return false;
    }
    // Maybe they came from dlattach or similar?
    if (SMF != 'SSI' && empty($context['theme_loaded'])) {
        loadTheme();
    }
    // Don't bother indexing errors mate...
    $context['robot_no_index'] = true;
    if (!isset($context['error_title'])) {
        $context['error_title'] = $txt['error_occured'];
    }
    $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message;
    if (empty($context['page_title'])) {
        $context['page_title'] = $context['error_title'];
    }
    EoS_Smarty::resetTemplates();
    // discard all templates loaded so far. We don't need them any longer
    EoS_Smarty::loadTemplate('errors');
    // If this is SSI, what do they want us to do?
    if (SMF == 'SSI') {
        if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) {
            call_user_func($ssi_on_error_method);
        } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
            loadSubTemplate('fatal_error');
        }
        // No layers?
        if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
            exit;
        }
    }
    // We want whatever for the header, and a footer. (footer includes sub template!)
    obExit(null, true, false, true);
    /* DO NOT IGNORE:
    		If you are creating a bridge to SMF or modifying this function, you MUST
    		make ABSOLUTELY SURE that this function quits and DOES NOT RETURN TO NORMAL
    		PROGRAM FLOW.  Otherwise, security error messages will not be shown, and
    		your forum will be in a very easily hackable state.
    	*/
    trigger_error('Hacking attempt...', E_USER_ERROR);
}
示例#6
0
文件: SSI.php 项目: scripple/Elkarte
    }
    $sc = $_SESSION['session_value'];
}
// Get rid of $board and $topic... do stuff loadBoard would do.
unset($board, $topic);
$user_info['is_mod'] = false;
$context['user']['is_mod'] =& $user_info['is_mod'];
$context['linktree'] = array();
// Load the user and their cookie, as well as their settings.
loadUserSettings();
// Load the current user's permissions....
loadPermissions();
// Load BadBehavior functions
loadBadBehavior();
// Load the current or SSI theme. (just use $ssi_theme = id_theme;)
loadTheme(isset($ssi_theme) ? (int) $ssi_theme : 0);
// @todo: probably not the best place, but somewhere it should be set...
if (!headers_sent()) {
    header('Content-Type: text/html; charset=UTF-8');
}
// Take care of any banning that needs to be done.
if (isset($_REQUEST['ssi_ban']) || isset($ssi_ban) && $ssi_ban === true) {
    is_not_banned();
}
// Do we allow guests in here?
if (empty($ssi_guest_access) && empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && basename($_SERVER['PHP_SELF']) != 'SSI.php') {
    require_once CONTROLLERDIR . '/Auth.controller.php';
    $controller = new Auth_Controller();
    $controller->action_kickguest();
    obExit(null, true);
}
示例#7
0
文件: Themes.php 项目: alencarmo/OCF
function SetThemeSettings()
{
    global $txt, $sc, $context, $settings, $db_prefix, $modSettings;
    if (empty($_GET['th']) && empty($_GET['id'])) {
        return ThemeAdmin();
    }
    $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
    // Select the best fitting tab.
    $context['admin_tabs']['tabs']['list']['is_selected'] = true;
    loadLanguage('Admin');
    isAllowedTo('admin_forum');
    // Just for navigation, show some nice bar on the left.
    adminIndex($settings['theme_id'] == $_GET['th'] ? 'edit_theme_settings' : 'manage_themes');
    // Validate inputs/user.
    if (empty($_GET['th'])) {
        fatal_lang_error('theme3', false);
    }
    // Submitting!
    if (isset($_POST['submit'])) {
        checkSession();
        if (empty($_POST['options'])) {
            $_POST['options'] = array();
        }
        if (empty($_POST['default_options'])) {
            $_POST['default_options'] = array();
        }
        // Set up the sql query.
        $setString = '';
        foreach ($_POST['options'] as $opt => $val) {
            $setString .= "\n\t\t\t\t(0, {$_GET['th']}, SUBSTRING('{$opt}', 1, 255), SUBSTRING('" . (is_array($val) ? implode(',', $val) : $val) . "', 1, 65534)),";
        }
        foreach ($_POST['default_options'] as $opt => $val) {
            $setString .= "\n\t\t\t\t(0, 1, SUBSTRING('{$opt}', 1, 255), SUBSTRING('" . (is_array($val) ? implode(',', $val) : $val) . "', 1, 65534)),";
        }
        // If we're actually inserting something..
        if ($setString != '') {
            // Get rid of the last comma.
            $setString = substr($setString, 0, -1);
            db_query("\n\t\t\t\tREPLACE INTO {$db_prefix}themes\n\t\t\t\t\t(ID_MEMBER, ID_THEME, variable, value)\n\t\t\t\tVALUES {$setString}", __FILE__, __LINE__);
        }
        cache_put_data('theme_settings-' . $_GET['th'], null, 90);
        cache_put_data('theme_settings-1', null, 90);
        redirectexit('action=theme;sa=settings;th=' . $_GET['th'] . ';sesc=' . $sc);
    }
    checkSession('get');
    // Fetch the smiley sets...
    $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
    $set_names = explode("\n", $txt['smileys_none'] . "\n" . $modSettings['smiley_sets_names']);
    $context['smiley_sets'] = array('' => $txt['smileys_no_default']);
    foreach ($sets as $i => $set) {
        $context['smiley_sets'][$set] = $set_names[$i];
    }
    $old_id = $settings['theme_id'];
    $old_settings = $settings;
    loadTheme($_GET['th'], false);
    // Let the theme take care of the settings.
    loadTemplate('Settings');
    loadSubTemplate('settings');
    $context['sub_template'] = 'set_settings';
    $context['page_title'] = $txt['theme4'];
    foreach ($settings as $setting => $dummy) {
        if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url'))) {
            $settings[$setting] = htmlspecialchars($settings[$setting]);
        }
    }
    $context['settings'] = $context['theme_settings'];
    $context['theme_settings'] = $settings;
    foreach ($context['settings'] as $i => $setting) {
        if (!isset($setting['type']) || $setting['type'] == 'bool') {
            $context['settings'][$i]['type'] = 'checkbox';
        } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
            $context['settings'][$i]['type'] = 'number';
        } elseif ($setting['type'] == 'string') {
            $context['settings'][$i]['type'] = 'text';
        }
        if (isset($setting['options'])) {
            $context['settings'][$i]['type'] = 'list';
        }
        $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
    }
    // Restore the current theme.
    loadTheme($old_id, false);
    $settings = $old_settings;
    loadTemplate('Themes');
}
示例#8
0
文件: Load.php 项目: norv/EosAlpha
function getLanguages($use_cache = true, $favor_utf8 = true)
{
    global $context, $settings, $modSettings;
    // Either we don't use the cache, or its expired.
    if (!$use_cache || ($context['languages'] = CacheAPI::getCache('known_languages' . ($favor_utf8 ? '' : '_all'), !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) {
        // If we don't have our theme information yet, lets get it.
        if (empty($settings['default_theme_dir'])) {
            loadTheme(0, false);
        } else {
            $settings['actual_theme_url'] = $settings['theme_url'];
            $settings['actual_images_url'] = $settings['images_url'];
            $settings['actual_theme_dir'] = $settings['theme_dir'];
        }
        // Default language directories to try.
        $language_directories = array($settings['default_theme_dir'] . '/languages', $settings['actual_theme_dir'] . '/languages');
        // We possibly have a base theme directory.
        if (!empty($settings['base_theme_dir'])) {
            $language_directories[] = $settings['base_theme_dir'] . '/languages';
        }
        // Remove any duplicates.
        $language_directories = array_unique($language_directories);
        foreach ($language_directories as $language_dir) {
            // Can't look in here... doesn't exist!
            if (!file_exists($language_dir)) {
                continue;
            }
            $dir = dir($language_dir);
            while ($entry = $dir->read()) {
                // Look for the index language file....
                if (!preg_match('~^index\\.(.+)\\.php$~', $entry, $matches)) {
                    continue;
                }
                $context['languages'][$matches[1]] = array('name' => commonAPI::ucwords(strtr($matches[1], array('_' => ' '))), 'selected' => false, 'filename' => $matches[1], 'location' => $language_dir . '/index.' . $matches[1] . '.php');
            }
            $dir->close();
        }
        // Favoring UTF8? Then prevent us from selecting non-UTF8 versions.
        if ($favor_utf8) {
            foreach ($context['languages'] as $lang) {
                if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8'])) {
                    unset($context['languages'][$lang['filename']]);
                }
            }
        }
        // Lets cash in on this deal.
        if (!empty($modSettings['cache_enable'])) {
            CacheAPI::putCache('known_languages' . ($favor_utf8 ? '' : '_all'), $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
        }
    }
    return $context['languages'];
}
示例#9
0
文件: index.php 项目: alencarmo/OCF
function smf_main()
{
    global $modSettings, $settings, $user_info, $board, $topic, $maintenance, $sourcedir;
    // Special case: session keep-alive.
    if (isset($_GET['action']) && $_GET['action'] == 'keepalive') {
        die;
    }
    // Load the user's cookie (or set as guest) and load their settings.
    loadUserSettings();
    // Load the current board's information.
    loadBoard();
    // Load the current theme.  (note that ?theme=1 will also work, may be used for guest theming.)
    loadTheme();
    // Check if the user should be disallowed access.
    //	is_not_banned();
    // Load the current user's permissions.
    loadPermissions();
    // Do some logging, unless this is an attachment, avatar, theme option or XML feed.
    if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], array('dlattach', 'jsoption', '.xml'))) {
        // Log this user as online.
        writeLog();
        // Track forum statistics and hits...?
        if (!empty($modSettings['hitStats'])) {
            trackStats(array('hits' => '+'));
        }
    }
    // Is the forum in maintenance mode? (doesn't apply to administrators.)
    if (!empty($maintenance) && !allowedTo('admin_forum')) {
        // You can only login.... otherwise, you're getting the "maintenance mode" display.
        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'login2' || $_REQUEST['action'] == 'logout')) {
            require_once $sourcedir . '/LogInOut.php';
            return $_REQUEST['action'] == 'login2' ? 'Login2' : 'Logout';
        } else {
            require_once $sourcedir . '/Subs-Auth.php';
            return 'InMaintenance';
        }
    } elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'register', 'register2', 'reminder', 'activate', 'smstats', 'help', 'verificationcode')))) {
        require_once $sourcedir . '/Subs-Auth.php';
        return 'KickGuest';
    } elseif (empty($_REQUEST['action'])) {
        // Action and board are both empty... BoardIndex!
        if (empty($board) && empty($topic)) {
            require_once $sourcedir . '/BoardIndex.php';
            return 'BoardIndex';
        } elseif (empty($topic)) {
            require_once $sourcedir . '/MessageIndex.php';
            return 'MessageIndex';
        } else {
            require_once $sourcedir . '/Display.php';
            return 'Display';
        }
    }
    // Here's the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function).
    $actionArray = array('activate' => array('Register.php', 'Activate'), 'admin' => array('Admin.php', 'Admin'), 'announce' => array('Post.php', 'AnnounceTopic'), 'ban' => array('ManageBans.php', 'Ban'), 'boardrecount' => array('Admin.php', 'AdminBoardRecount'), 'buddy' => array('Subs-Members.php', 'BuddyListToggle'), 'calendar' => array('Calendar.php', 'CalendarMain'), 'cleanperms' => array('Admin.php', 'CleanupPermissions'), 'collapse' => array('Subs-Boards.php', 'CollapseCategory'), 'convertentities' => array('Admin.php', 'ConvertEntities'), 'convertutf8' => array('Admin.php', 'ConvertUtf8'), 'coppa' => array('Register.php', 'CoppaForm'), 'deletemsg' => array('RemoveTopic.php', 'DeleteMessage'), 'detailedversion' => array('Admin.php', 'VersionDetail'), 'display' => array('Display.php', 'Display'), 'dlattach' => array('Display.php', 'Download'), 'dumpdb' => array('DumpDatabase.php', 'DumpDatabase2'), 'editpoll' => array('Poll.php', 'EditPoll'), 'editpoll2' => array('Poll.php', 'EditPoll2'), 'featuresettings' => array('ModSettings.php', 'ModifyFeatureSettings'), 'featuresettings2' => array('ModSettings.php', 'ModifyFeatureSettings2'), 'findmember' => array('Subs-Auth.php', 'JSMembers'), 'help' => array('Help.php', 'ShowHelp'), 'helpadmin' => array('Help.php', 'ShowAdminHelp'), 'im' => array('PersonalMessage.php', 'MessageMain'), 'jsoption' => array('Themes.php', 'SetJavaScript'), 'jsmodify' => array('Post.php', 'JavaScriptModify'), 'lock' => array('LockTopic.php', 'LockTopic'), 'lockVoting' => array('Poll.php', 'LockVoting'), 'login' => array('LogInOut.php', 'Login'), 'login2' => array('LogInOut.php', 'Login2'), 'logout' => array('LogInOut.php', 'Logout'), 'maintain' => array('Admin.php', 'Maintenance'), 'manageattachments' => array('ManageAttachments.php', 'ManageAttachments'), 'manageboards' => array('ManageBoards.php', 'ManageBoards'), 'managecalendar' => array('ManageCalendar.php', 'ManageCalendar'), 'managesearch' => array('ManageSearch.php', 'ManageSearch'), 'markasread' => array('Subs-Boards.php', 'MarkRead'), 'membergroups' => array('ManageMembergroups.php', 'ModifyMembergroups'), 'mergetopics' => array('SplitTopics.php', 'MergeTopics'), 'mlist' => array('Memberlist.php', 'Memberlist'), 'modifycat' => array('ManageBoards.php', 'ModifyCat'), 'modifykarma' => array('Karma.php', 'ModifyKarma'), 'modlog' => array('Modlog.php', 'ViewModlog'), 'movetopic' => array('MoveTopic.php', 'MoveTopic'), 'movetopic2' => array('MoveTopic.php', 'MoveTopic2'), 'news' => array('ManageNews.php', 'ManageNews'), 'notify' => array('Notify.php', 'Notify'), 'notifyboard' => array('Notify.php', 'BoardNotify'), 'optimizetables' => array('Admin.php', 'OptimizeTables'), 'packageget' => array('PackageGet.php', 'PackageGet'), 'packages' => array('Packages.php', 'Packages'), 'permissions' => array('ManagePermissions.php', 'ModifyPermissions'), 'pgdownload' => array('PackageGet.php', 'PackageGet'), 'pm' => array('PersonalMessage.php', 'MessageMain'), 'post' => array('Post.php', 'Post'), 'post2' => array('Post.php', 'Post2'), 'postsettings' => array('ManagePosts.php', 'ManagePostSettings'), 'printpage' => array('Printpage.php', 'PrintTopic'), 'profile' => array('Profile.php', 'ModifyProfile'), 'profile2' => array('Profile.php', 'ModifyProfile2'), 'quotefast' => array('Post.php', 'QuoteFast'), 'quickmod' => array('Subs-Boards.php', 'QuickModeration'), 'quickmod2' => array('Subs-Boards.php', 'QuickModeration2'), 'recent' => array('Recent.php', 'RecentPosts'), 'regcenter' => array('ManageRegistration.php', 'RegCenter'), 'register' => array('Register.php', 'Register'), 'register2' => array('Register.php', 'Register2'), 'reminder' => array('Reminder.php', 'RemindMe'), 'removetopic2' => array('RemoveTopic.php', 'RemoveTopic2'), 'removeoldtopics2' => array('RemoveTopic.php', 'RemoveOldTopics2'), 'removepoll' => array('Poll.php', 'RemovePoll'), 'repairboards' => array('RepairBoards.php', 'RepairBoards'), 'reporttm' => array('SendTopic.php', 'ReportToModerator'), 'reports' => array('Reports.php', 'ReportsMain'), 'requestmembers' => array('Subs-Auth.php', 'RequestMembers'), 'search' => array('Search.php', 'PlushSearch1'), 'search2' => array('Search.php', 'PlushSearch2'), 'sendtopic' => array('SendTopic.php', 'SendTopic'), 'serversettings' => array('ManageServer.php', 'ModifySettings'), 'serversettings2' => array('ManageServer.php', 'ModifySettings2'), 'smileys' => array('ManageSmileys.php', 'ManageSmileys'), 'smstats' => array('Stats.php', 'SMStats'), 'spellcheck' => array('Subs-Post.php', 'SpellCheck'), 'splittopics' => array('SplitTopics.php', 'SplitTopics'), 'stats' => array('Stats.php', 'DisplayStats'), 'sticky' => array('LockTopic.php', 'Sticky'), 'theme' => array('Themes.php', 'ThemesMain'), 'trackip' => array('Profile.php', 'trackIP'), 'about:mozilla' => array('Karma.php', 'BookOfUnknown'), 'about:unknown' => array('Karma.php', 'BookOfUnknown'), 'unread' => array('Recent.php', 'UnreadTopics'), 'unreadreplies' => array('Recent.php', 'UnreadTopics'), 'viewErrorLog' => array('ManageErrors.php', 'ViewErrorLog'), 'viewmembers' => array('ManageMembers.php', 'ViewMembers'), 'viewprofile' => array('Profile.php', 'ModifyProfile'), 'verificationcode' => array('Register.php', 'VerificationCode'), 'vote' => array('Poll.php', 'Vote'), 'viewquery' => array('ViewQuery.php', 'ViewQuery'), 'who' => array('Who.php', 'Who'), '.xml' => array('News.php', 'ShowXmlFeed'));
    // Get the function and file to include - if it's not there, do the board index.
    if (!isset($_REQUEST['action']) || !isset($actionArray[$_REQUEST['action']])) {
        // Catch the action with the theme?
        if (!empty($settings['catch_action'])) {
            require_once $sourcedir . '/Themes.php';
            return 'WrapAction';
        }
        // Fall through to the board index then...
        require_once $sourcedir . '/BoardIndex.php';
        return 'BoardIndex';
    }
    // Otherwise, it was set - so let's go to that action.
    require_once $sourcedir . '/' . $actionArray[$_REQUEST['action']][0];
    return $actionArray[$_REQUEST['action']][1];
}
示例#10
0
文件: Errors.php 项目: KeiroD/Elkarte
/**
 * It is called by fatal_error() and fatal_lang_error().
 *
 * @uses Errors template, fatal_error sub template
 * @param string $error_message
 * @param string $error_code string or int code
 */
function setup_fatal_error_context($error_message, $error_code)
{
    global $context, $txt, $ssi_on_error_method;
    static $level = 0;
    // Attempt to prevent a recursive loop.
    ++$level;
    if ($level > 1) {
        return false;
    }
    // Maybe they came from dlattach or similar?
    if (ELK != 'SSI' && empty($context['theme_loaded'])) {
        loadTheme();
    }
    // Don't bother indexing errors mate...
    $context['robot_no_index'] = true;
    if (!isset($context['error_title'])) {
        $context['error_title'] = $txt['error_occurred'];
    }
    $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message;
    $context['error_code'] = isset($error_code) ? 'id="' . htmlspecialchars($error_code) . '" ' : '';
    if (empty($context['page_title'])) {
        $context['page_title'] = $context['error_title'];
    }
    // Load the template and set the sub template.
    loadTemplate('Errors');
    $context['sub_template'] = 'fatal_error';
    // If this is SSI, what do they want us to do?
    if (ELK == 'SSI') {
        if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) {
            $ssi_on_error_method();
        } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
            loadSubTemplate('fatal_error');
        }
        // No layers?
        if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) {
            exit;
        }
    }
    // We want whatever for the header, and a footer. (footer includes sub template!)
    obExit(null, true, false, true);
    /* DO NOT IGNORE:
    		If you are creating a bridge or modifying this function, you MUST
    		make ABSOLUTELY SURE that this function quits and DOES NOT RETURN TO NORMAL
    		PROGRAM FLOW.  Otherwise, security error messages will not be shown, and
    		your forum will be in a very easily hackable state.
    	*/
    trigger_error('Hacking attempt...', E_USER_ERROR);
}
 /**
  * Administrative global settings.
  *
  * What it does:
  * - Saves and requests global theme settings. ($settings)
  * - Loads the Admin language file.
  * - Calls action_admin() if no theme is specified. (the theme center.)
  * - Requires admin_forum permission.
  * - Accessed with ?action=admin;area=theme;sa=list&th=xx.
  */
 public function action_setthemesettings()
 {
     global $txt, $context, $settings, $modSettings;
     require_once SUBSDIR . '/Themes.subs.php';
     // Nothing chosen, back to the start you go
     if (empty($_GET['th']) && empty($_GET['id'])) {
         return $this->action_admin();
     }
     // The theme's ID is needed
     $theme = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
     // Validate inputs/user.
     if (empty($theme)) {
         fatal_lang_error('no_theme', false);
     }
     // Select the best fitting tab.
     $context[$context['admin_menu_name']]['current_subsection'] = 'list';
     loadLanguage('Admin');
     // Fetch the smiley sets...
     $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']);
     $set_names = explode("\n", $txt['smileys_none'] . "\n" . $modSettings['smiley_sets_names']);
     $context['smiley_sets'] = array('' => $txt['smileys_no_default']);
     foreach ($sets as $i => $set) {
         $context['smiley_sets'][$set] = htmlspecialchars($set_names[$i], ENT_COMPAT, 'UTF-8');
     }
     $old_id = $settings['theme_id'];
     $old_settings = $settings;
     loadTheme($theme, false);
     // Also load the actual themes language file - in case of special settings.
     loadLanguage('Settings', '', true, true);
     // And the custom language strings...
     loadLanguage('ThemeStrings', '', false, true);
     // Let the theme take care of the settings.
     loadTemplate('Settings');
     loadSubTemplate('settings');
     // Load the variants separately...
     $settings['theme_variants'] = array();
     if (file_exists($settings['theme_dir'] . '/index.template.php')) {
         $file_contents = implode("\n", file($settings['theme_dir'] . '/index.template.php'));
         if (preg_match('~\'theme_variants\'\\s*=>(.+?\\)),$~sm', $file_contents, $matches)) {
             eval('global $settings; $settings[\'theme_variants\'] = ' . $matches[1] . ';');
         }
         call_integration_hook('integrate_init_theme', array($theme, &$settings));
     }
     // Submitting!
     if (isset($_POST['save'])) {
         // Allowed?
         checkSession();
         validateToken('admin-sts');
         if (empty($_POST['options'])) {
             $_POST['options'] = array();
         }
         if (empty($_POST['default_options'])) {
             $_POST['default_options'] = array();
         }
         // Make sure items are cast correctly.
         foreach ($context['theme_settings'] as $item) {
             // Unwatch this item if this is just a separator.
             if (!is_array($item)) {
                 continue;
             }
             // Clean them up for the database
             foreach (array('options', 'default_options') as $option) {
                 if (!isset($_POST[$option][$item['id']])) {
                     continue;
                 } elseif (empty($item['type'])) {
                     $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0;
                 } elseif ($item['type'] == 'number') {
                     $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']];
                 }
             }
         }
         // Set up the sql query.
         $inserts = array();
         foreach ($_POST['options'] as $opt => $val) {
             $inserts[] = array($theme, 0, $opt, is_array($val) ? implode(',', $val) : $val);
         }
         foreach ($_POST['default_options'] as $opt => $val) {
             $inserts[] = array(1, 0, $opt, is_array($val) ? implode(',', $val) : $val);
         }
         // If we're actually inserting something..
         if (!empty($inserts)) {
             updateThemeOptions($inserts);
         }
         // Clear and Invalidate the cache.
         cache_put_data('theme_settings-' . $theme, null, 90);
         cache_put_data('theme_settings-1', null, 90);
         updateSettings(array('settings_updated' => time()));
         redirectexit('action=admin;area=theme;sa=list;th=' . $theme . ';' . $context['session_var'] . '=' . $context['session_id']);
     }
     $context['sub_template'] = 'set_settings';
     $context['page_title'] = $txt['theme_settings'];
     foreach ($settings as $setting => $dummy) {
         if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) {
             $settings[$setting] = htmlspecialchars__recursive($settings[$setting]);
         }
     }
     $context['settings'] = $context['theme_settings'];
     $context['theme_settings'] = $settings;
     foreach ($context['settings'] as $i => $setting) {
         // Separators are dummies, so leave them alone.
         if (!is_array($setting)) {
             continue;
         }
         // Create the right input fields for the data
         if (!isset($setting['type']) || $setting['type'] == 'bool') {
             $context['settings'][$i]['type'] = 'checkbox';
         } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') {
             $context['settings'][$i]['type'] = 'number';
         } elseif ($setting['type'] == 'string') {
             $context['settings'][$i]['type'] = 'text';
         }
         if (isset($setting['options'])) {
             $context['settings'][$i]['type'] = 'list';
         }
         $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']];
     }
     // Do we support variants?
     if (!empty($settings['theme_variants'])) {
         $context['theme_variants'] = array();
         foreach ($settings['theme_variants'] as $variant) {
             // Have any text, old chap?
             $context['theme_variants'][$variant] = array('label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, 'thumbnail' => !file_exists($settings['theme_dir'] . '/images/thumbnail.png') || file_exists($settings['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $settings['images_url'] . '/thumbnail_' . $variant . '.png' : $settings['images_url'] . '/thumbnail.png');
         }
         $context['default_variant'] = !empty($settings['default_variant']) && isset($context['theme_variants'][$settings['default_variant']]) ? $settings['default_variant'] : $settings['theme_variants'][0];
     }
     // Restore the current theme.
     loadTheme($old_id, false);
     $settings = $old_settings;
     // Reinit just incase.
     if (function_exists('template_init')) {
         $settings += template_init();
     }
     loadTemplate('ManageThemes');
     // We like Kenny better than Token.
     createToken('admin-sts');
 }
示例#12
0
function smf_main()
{
    global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir, $request_name, $txt, $user_settings, $mobiquo_config, $topic_per_page, $limit_num;
    // Load the user's cookie (or set as guest) and load their settings.
    loadUserSettings();
    // Load the current board's information.
    loadBoard();
    // Load the current user's permissions.
    loadPermissions();
    // Attachments don't require the entire theme to be loaded.
    loadTheme();
    header('Mobiquo_is_login:'******'context']['user']['is_logged'] ? 'true' : 'false'));
    // Check if the user should be disallowed access.
    if (!in_array($request_name, array('get_config', 'login'))) {
        is_not_banned();
    }
    // If we are in a topic and don't have permission to approve it then duck out now.
    if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
        //fatal_lang_error('not_a_topic', false);
        get_error('The topic is not approved');
    }
    // Do some logging, unless this is an attachment, avatar, toggle of editor buttons, theme option, XML feed etc.
    if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], array('dlattach', 'findmember', 'jseditor', 'jsoption', 'requestmembers', 'smstats', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'))) {
        // Log this user as online.
        writeLog();
        // Track forum statistics and hits...?
        if (!empty($modSettings['hitStats'])) {
            trackStats(array('hits' => '+'));
        }
    }
    // Is the forum in maintenance mode? (doesn't apply to administrators.)
    if (!empty($maintenance) && !allowedTo('admin_forum')) {
        if ($request_name != 'get_config' && $request_name != 'login') {
            get_error($txt['maintain_mode_on']);
        }
    } elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('push_content_check', 'user_subscription', 'set_api_key', 'reset_push_slug', 'prefetch_account', 'update_password', 'forget_password', 'sign_in', 'coppa', 'login', 'login2', 'register', 'register2', 'reminder', 'activate', 'help', 'smstats', 'mailq', 'verificationcode', 'openidreturn')))) {
        if ($request_name != 'get_config' && $request_name != 'prefetch_account') {
            loadLanguage('Login');
            get_error($txt['only_members_can_access']);
            //require_once($sourcedir . '/Subs-Auth.php');
            //return 'KickGuest';
        }
    }
    //-------------transform input data to local character set if needed
    utf8_to_local();
    //-------------change some setting for tapatalk display
    $settings['message_index_preview'] = 1;
    $modSettings['todayMod_bak'] = $modSettings['todayMod'];
    $modSettings['todayMod'] = 0;
    $user_settings['pm_prefs'] = 0;
    $user_info['user_time_format'] = $user_info['time_format'];
    $user_info['time_format'] = '%Y%m%dT%H:%M:%S+00:00';
    $modSettings['disableCustomPerPage'] = 1;
    $modSettings['disableCheckUA'] = 1;
    $modSettings['defaultMaxMessages'] = isset($limit_num) ? $limit_num : 20;
    $modSettings['defaultMaxMembers'] = 100;
    $modSettings['search_results_per_page'] = isset($topic_per_page) && $topic_per_page > 0 ? $topic_per_page : 20;
    $modSettings['defaultMaxTopics'] = isset($topic_per_page) && $topic_per_page > 0 ? $topic_per_page : 20;
    $modSettings['disable_pm_verification'] = $mobiquo_config['disable_pm_verification'];
    //-------------do something before action--------------
    if (function_exists('before_action_' . $request_name)) {
        call_user_func('before_action_' . $request_name);
    }
    if (empty($_REQUEST['action']) && !empty($board)) {
        if (empty($topic)) {
            require_once 'include/MessageIndex.php';
            return 'MessageIndex';
        } else {
            require_once 'include/Display.php';
            return 'Display';
        }
    }
    // Here's the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function).
    $actionArray = array('activate' => array('Register.php', 'Activate'), 'admin' => array('Admin.php', 'AdminMain'), 'announce' => array('Post.php', 'AnnounceTopic'), 'attachapprove' => array('ManageAttachments.php', 'ApproveAttach'), 'buddy' => array('Subs-Members.php', 'BuddyListToggle'), 'calendar' => array('Calendar.php', 'CalendarMain'), 'clock' => array('Calendar.php', 'clock'), 'collapse' => array('BoardIndex.php', 'CollapseCategory'), 'coppa' => array('Register.php', 'CoppaForm'), 'credits' => array('Who.php', 'Credits'), 'deletemsg' => array('RemoveTopic.php', 'DeleteMessage'), 'display' => array('Display.php', 'Display'), 'dlattach' => array('Display.php', 'Download'), 'editpoll' => array('Poll.php', 'EditPoll'), 'editpoll2' => array('Poll.php', 'EditPoll2'), 'emailuser' => array('SendTopic.php', 'EmailUser'), 'findmember' => array('Subs-Auth.php', 'JSMembers'), 'groups' => array('Groups.php', 'Groups'), 'help' => array('Help.php', 'ShowHelp'), 'helpadmin' => array('Help.php', 'ShowAdminHelp'), 'im' => array('PersonalMessage.php', 'MessageMain'), 'jseditor' => array('Subs-Editor.php', 'EditorMain'), 'jsmodify' => array('Post.php', 'JavaScriptModify'), 'jsoption' => array('Themes.php', 'SetJavaScript'), 'lock' => array('LockTopic.php', 'LockTopic'), 'lockvoting' => array('Poll.php', 'LockVoting'), 'login' => array('LogInOut.php', 'Login'), 'login2' => array('LogInOut.php', 'Login2'), 'logout' => array('LogInOut.php', 'Logout'), 'markasread' => array('Subs-Boards.php', 'MarkRead'), 'mergetopics' => array('SplitTopics.php', 'MergeTopics'), 'mlist' => array('Memberlist.php', 'Memberlist'), 'moderate' => array('ModerationCenter.php', 'ModerationMain'), 'modifycat' => array('ManageBoards.php', 'ModifyCat'), 'modifykarma' => array('Karma.php', 'ModifyKarma'), 'movetopic' => array('MoveTopic.php', 'MoveTopic'), 'movetopic2' => array('MoveTopic.php', 'MoveTopic2'), 'notify' => array('Notify.php', 'Notify'), 'notifyboard' => array('Notify.php', 'BoardNotify'), 'openidreturn' => array('Subs-OpenID.php', 'smf_openID_return'), 'pm' => array('PersonalMessage.php', 'MessageMain'), 'post' => array('Post.php', 'Post'), 'post2' => array('Post.php', 'Post2'), 'printpage' => array('Printpage.php', 'PrintTopic'), 'profile' => array('Profile.php', 'ModifyProfile'), 'quotefast' => array('Post.php', 'QuoteFast'), 'quickmod' => array('MessageIndex.php', 'QuickModeration'), 'quickmod2' => array('Display.php', 'QuickInTopicModeration'), 'recent' => array('Recent.php', 'RecentPosts'), 'register' => array('Register.php', 'Register'), 'register2' => array('Register.php', 'Register2'), 'reminder' => array('Reminder.php', 'RemindMe'), 'removepoll' => array('Poll.php', 'RemovePoll'), 'removetopic2' => array('RemoveTopic.php', 'RemoveTopic2'), 'reporttm' => array('SendTopic.php', 'ReportToModerator'), 'requestmembers' => array('Subs-Auth.php', 'RequestMembers'), 'restoretopic' => array('RemoveTopic.php', 'RestoreTopic'), 'search' => array('Search.php', 'PlushSearch1'), 'search2' => array('Search.php', 'PlushSearch2'), 'sendtopic' => array('SendTopic.php', 'EmailUser'), 'smstats' => array('Stats.php', 'SMStats'), 'suggest' => array('Subs-Editor.php', 'AutoSuggestHandler'), 'spellcheck' => array('Subs-Post.php', 'SpellCheck'), 'splittopics' => array('SplitTopics.php', 'SplitTopics'), 'stats' => array('Stats.php', 'DisplayStats'), 'sticky' => array('LockTopic.php', 'Sticky'), 'theme' => array('Themes.php', 'ThemesMain'), 'trackip' => array('Profile-View.php', 'trackIP'), 'about:mozilla' => array('Karma.php', 'BookOfUnknown'), 'about:unknown' => array('Karma.php', 'BookOfUnknown'), 'unread' => array('Recent.php', 'UnreadTopics'), 'unreadreplies' => array('Recent.php', 'UnreadTopics'), 'verificationcode' => array('Register.php', 'VerificationCode'), 'viewprofile' => array('Profile.php', 'ModifyProfile'), 'vote' => array('Poll.php', 'Vote'), 'viewquery' => array('ViewQuery.php', 'ViewQuery'), 'viewsmfile' => array('Admin.php', 'DisplayAdminFile'), 'who' => array('Who.php', 'Who'), '.xml' => array('News.php', 'ShowXmlFeed'), 'xmlhttp' => array('Xml.php', 'XMLhttpMain'));
    // Allow modifying $actionArray easily.
    call_integration_hook('integrate_actions', array(&$actionArray));
    //error_log($request_name.'-'.$_REQUEST['action']);   //for debugging
    // Get the function and file to include - if it's not there, do the board index.
    if (!isset($_REQUEST['action']) || !isset($actionArray[$_REQUEST['action']])) {
        if (function_exists('action_' . $request_name)) {
            return 'action_' . $request_name;
        } else {
            get_error('Invalid action');
        }
    }
    $local_action = array('login2', 'post', 'post2', 'who', 'profile', 'notify', 'notifyboard', 'markasread', 'unread', 'search2', 'pm', 'logout');
    // Otherwise, it was set - so let's go to that action.
    if (in_array($_REQUEST['action'], $local_action)) {
        if (file_exists(TT_ROOT . 'include/' . $actionArray[$_REQUEST['action']][0])) {
            require_once TT_ROOT . 'include/' . $actionArray[$_REQUEST['action']][0];
        } else {
            if (file_exists($sourcedir . '/' . $actionArray[$_REQUEST['action']][0])) {
                require_once $sourcedir . '/' . $actionArray[$_REQUEST['action']][0];
            }
        }
    } else {
        if (file_exists($sourcedir . '/' . $actionArray[$_REQUEST['action']][0])) {
            require_once $sourcedir . '/' . $actionArray[$_REQUEST['action']][0];
        }
    }
    return $actionArray[$_REQUEST['action']][1];
}
示例#13
0
function is_not_guest($message = '')
{
    global $user_info, $txt, $context, $scripturl;
    // Luckily, this person isn't a guest.
    if (!$user_info['is_guest']) {
        return;
    }
    // People always worry when they see people doing things they aren't actually doing...
    $_GET['action'] = '';
    $_GET['board'] = '';
    $_GET['topic'] = '';
    writeLog(true);
    // Just die.
    if (isset($_REQUEST['xml'])) {
        obExit(false);
    }
    // Attempt to detect if they came from dlattach.
    if (SMF != 'SSI' && empty($context['theme_loaded'])) {
        loadTheme();
    }
    // Never redirect to an attachment
    if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) {
        $_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
    }
    // Load the Login template and language file.
    loadLanguage('Login');
    // Apparently we're not in a position to handle this now. Let's go to a safer location for now.
    if (empty($context['template_layers'])) {
        $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING'];
        redirectexit('action=login');
    } else {
        EoS_Smarty::resetTemplates();
        EoS_Smarty::loadTemplate('generic_skeleton');
        EoS_Smarty::getConfigInstance()->registerHookTemplate('generic_content_area', 'loginout/login');
        $context['is_kick_guest'] = true;
        $context['robot_no_index'] = true;
    }
    // Use the kick_guest sub template...
    $context['kick_message'] = $message;
    $context['page_title'] = $txt['login'];
    obExit();
    // We should never get to this point, but if we did we wouldn't know the user isn't a guest.
    trigger_error('Hacking attempt...', E_USER_ERROR);
}
示例#14
0
/**
 * Require a user who is logged in. (not a guest.)
 *
 * What it does:
 * - Checks if the user is currently a guest, and if so asks them to login with a message telling them why.
 * - Message is what to tell them when asking them to login.
 *
 * @param string $message = ''
 * @param boolean $is_fatal = true
 */
function is_not_guest($message = '', $is_fatal = true)
{
    global $user_info, $txt, $context, $scripturl;
    // Luckily, this person isn't a guest.
    if (isset($user_info['is_guest']) && !$user_info['is_guest']) {
        return true;
    }
    // People always worry when they see people doing things they aren't actually doing...
    $_GET['action'] = '';
    $_GET['board'] = '';
    $_GET['topic'] = '';
    writeLog(true);
    // Just die.
    if (isset($_REQUEST['xml']) || !$is_fatal) {
        obExit(false);
    }
    // Attempt to detect if they came from dlattach.
    if (ELK != 'SSI' && empty($context['theme_loaded'])) {
        loadTheme();
    }
    // Never redirect to an attachment
    if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) {
        $_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
    }
    // Load the Login template and language file.
    loadLanguage('Login');
    // Apparently we're not in a position to handle this now. Let's go to a safer location for now.
    if (!Template_Layers::getInstance()->hasLayers()) {
        $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING'];
        redirectexit('action=login');
    } elseif (isset($_GET['api'])) {
        return false;
    } else {
        loadTemplate('Login');
        loadJavascriptFile('sha256.js', array('defer' => true));
        $context['sub_template'] = 'kick_guest';
        $context['robot_no_index'] = true;
    }
    // Use the kick_guest sub template...
    $context['kick_message'] = $message;
    $context['page_title'] = $txt['login'];
    obExit();
    // We should never get to this point, but if we did we wouldn't know the user isn't a guest.
    trigger_error('Hacking attempt...', E_USER_ERROR);
}
示例#15
0
function is_not_guest($message = '')
{
    global $user_info, $txt, $context, $scripturl;
    // Luckily, this person isn't a guest.
    if (!$user_info['is_guest']) {
        return;
    }
    // People always worry when they see people doing things they aren't actually doing...
    $_GET['action'] = '';
    $_GET['board'] = '';
    $_GET['topic'] = '';
    writeLog(true);
    // Just die.
    if (isset($_REQUEST['xml'])) {
        obExit(false);
    }
    // Attempt to detect if they came from dlattach.
    if (!WIRELESS && SMF != 'SSI' && empty($context['theme_loaded'])) {
        loadTheme();
    }
    // Never redirect to an attachment
    if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) {
        $_SESSION['login_url'] = $_SERVER['REQUEST_URL'];
    }
    // Load the Login template and language file.
    loadLanguage('Login');
    // Are we in wireless mode?
    if (WIRELESS) {
        $context['login_error'] = $message ? $message : $txt['only_members_can_access'];
        $context['sub_template'] = WIRELESS_PROTOCOL . '_login';
    } elseif (empty($context['template_layers'])) {
        $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING'];
        redirectexit('action=login');
    } else {
        loadTemplate('Login');
        $context['sub_template'] = 'kick_guest';
        $context['robot_no_index'] = true;
    }
    // Use the kick_guest sub template...
    $context['kick_message'] = $message;
    $context['page_title'] = $txt['login'];
    obExit();
    // We should never get to this point, but if we did we wouldn't know the user isn't a guest.
    trigger_error('Hacking attempt...', E_USER_ERROR);
}
示例#16
0
function smf_main()
{
    global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir;
    // Special case: session keep-alive, output a transparent pixel.
    if (isset($_GET['action']) && $_GET['action'] == 'keepalive') {
        header('Content-Type: image/gif');
        die("GIF89a€!ù,D;");
    }
    // Load the user's cookie (or set as guest) and load their settings.
    loadUserSettings();
    // Load the current board's information.
    loadBoard();
    // Load the current user's permissions.
    loadPermissions();
    // Attachments don't require the entire theme to be loaded.
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && (!empty($modSettings['allow_guestAccess']) && $user_info['is_guest'])) {
        detectBrowser();
    } else {
        loadTheme();
    }
    // Check if the user should be disallowed access.
    is_not_banned();
    // If we are in a topic and don't have permission to approve it then duck out now.
    if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) {
        fatal_lang_error('not_a_topic', false);
    }
    // Do some logging, unless this is an attachment, avatar, toggle of editor buttons, theme option, XML feed etc.
    if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], array('dlattach', 'findmember', 'jseditor', 'jsoption', 'requestmembers', 'smstats', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'))) {
        // Log this user as online.
        writeLog();
        // Don't track stats of portal xml actions.
        if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'portal' || !isset($_GET['xml'])) {
            // Track forum statistics and hits...?
            if (!empty($modSettings['hitStats'])) {
                trackStats(array('hits' => '+'));
            }
        }
    }
    // Load SimplePortal.
    sportal_init();
    // Is the forum in maintenance mode? (doesn't apply to administrators.)
    if (!empty($maintenance) && !allowedTo('admin_forum')) {
        // You can only login.... otherwise, you're getting the "maintenance mode" display.
        if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'login2' || $_REQUEST['action'] == 'logout')) {
            require_once $sourcedir . '/LogInOut.php';
            return $_REQUEST['action'] == 'login2' ? 'Login2' : 'Logout';
        } else {
            require_once $sourcedir . '/Subs-Auth.php';
            return 'InMaintenance';
        }
    } elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'register', 'register2', 'reminder', 'activate', 'help', 'smstats', 'mailq', 'verificationcode', 'openidreturn')))) {
        require_once $sourcedir . '/Subs-Auth.php';
        return 'KickGuest';
    } elseif (empty($_REQUEST['action'])) {
        // Go catch it boy! Catch it!
        $sp_action = sportal_catch_action();
        if ($sp_action) {
            return $sp_action;
        }
        // Action and board are both empty... BoardIndex!
        if (empty($board) && empty($topic)) {
            require_once $sourcedir . '/BoardIndex.php';
            return 'BoardIndex';
        } elseif (empty($topic)) {
            require_once $sourcedir . '/MessageIndex.php';
            return 'MessageIndex';
        } else {
            require_once $sourcedir . '/Display.php';
            return 'Display';
        }
    }
    // Here's the monstrous $_REQUEST['action'] array - $_REQUEST['action'] => array($file, $function).
    $actionArray = array('activate' => array('Register.php', 'Activate'), 'admin' => array('Admin.php', 'AdminMain'), 'announce' => array('Post.php', 'AnnounceTopic'), 'attachapprove' => array('ManageAttachments.php', 'ApproveAttach'), 'buddy' => array('Subs-Members.php', 'BuddyListToggle'), 'calendar' => array('Calendar.php', 'CalendarMain'), 'clock' => array('Calendar.php', 'clock'), 'collapse' => array('BoardIndex.php', 'CollapseCategory'), 'coppa' => array('Register.php', 'CoppaForm'), 'credits' => array('Who.php', 'Credits'), 'deletemsg' => array('RemoveTopic.php', 'DeleteMessage'), 'display' => array('Display.php', 'Display'), 'dlattach' => array('Display.php', 'Download'), 'editpoll' => array('Poll.php', 'EditPoll'), 'editpoll2' => array('Poll.php', 'EditPoll2'), 'emailuser' => array('SendTopic.php', 'EmailUser'), 'findmember' => array('Subs-Auth.php', 'JSMembers'), 'forum' => array('BoardIndex.php', 'BoardIndex'), 'portal' => array('PortalMain.php', 'sportal_main'), 'groups' => array('Groups.php', 'Groups'), 'help' => array('Help.php', 'ShowHelp'), 'helpadmin' => array('Help.php', 'ShowAdminHelp'), 'im' => array('PersonalMessage.php', 'MessageMain'), 'jseditor' => array('Subs-Editor.php', 'EditorMain'), 'jsmodify' => array('Post.php', 'JavaScriptModify'), 'jsoption' => array('Themes.php', 'SetJavaScript'), 'lock' => array('LockTopic.php', 'LockTopic'), 'lockvoting' => array('Poll.php', 'LockVoting'), 'login' => array('LogInOut.php', 'Login'), 'login2' => array('LogInOut.php', 'Login2'), 'logout' => array('LogInOut.php', 'Logout'), 'markasread' => array('Subs-Boards.php', 'MarkRead'), 'mergetopics' => array('SplitTopics.php', 'MergeTopics'), 'mlist' => array('Memberlist.php', 'Memberlist'), 'moderate' => array('ModerationCenter.php', 'ModerationMain'), 'modifycat' => array('ManageBoards.php', 'ModifyCat'), 'modifykarma' => array('Karma.php', 'ModifyKarma'), 'movetopic' => array('MoveTopic.php', 'MoveTopic'), 'movetopic2' => array('MoveTopic.php', 'MoveTopic2'), 'notify' => array('Notify.php', 'Notify'), 'notifyboard' => array('Notify.php', 'BoardNotify'), 'openidreturn' => array('Subs-OpenID.php', 'smf_openID_return'), 'pm' => array('PersonalMessage.php', 'MessageMain'), 'post' => array('Post.php', 'Post'), 'post2' => array('Post.php', 'Post2'), 'printpage' => array('Printpage.php', 'PrintTopic'), 'profile' => array('Profile.php', 'ModifyProfile'), 'quotefast' => array('Post.php', 'QuoteFast'), 'quickmod' => array('MessageIndex.php', 'QuickModeration'), 'quickmod2' => array('Display.php', 'QuickInTopicModeration'), 'recent' => array('Recent.php', 'RecentPosts'), 'register' => array('Register.php', 'Register'), 'register2' => array('Register.php', 'Register2'), 'reminder' => array('Reminder.php', 'RemindMe'), 'removepoll' => array('Poll.php', 'RemovePoll'), 'removetopic2' => array('RemoveTopic.php', 'RemoveTopic2'), 'reporttm' => array('SendTopic.php', 'ReportToModerator'), 'requestmembers' => array('Subs-Auth.php', 'RequestMembers'), 'restoretopic' => array('RemoveTopic.php', 'RestoreTopic'), 'search' => array('Search.php', 'PlushSearch1'), 'search2' => array('Search.php', 'PlushSearch2'), 'sendtopic' => array('SendTopic.php', 'EmailUser'), 'smstats' => array('Stats.php', 'SMStats'), 'suggest' => array('Subs-Editor.php', 'AutoSuggestHandler'), 'spellcheck' => array('Subs-Post.php', 'SpellCheck'), 'splittopics' => array('SplitTopics.php', 'SplitTopics'), 'stats' => array('Stats.php', 'DisplayStats'), 'sticky' => array('LockTopic.php', 'Sticky'), 'theme' => array('Themes.php', 'ThemesMain'), 'trackip' => array('Profile-View.php', 'trackIP'), 'about:mozilla' => array('Karma.php', 'BookOfUnknown'), 'about:unknown' => array('Karma.php', 'BookOfUnknown'), 'unread' => array('Recent.php', 'UnreadTopics'), 'unreadreplies' => array('Recent.php', 'UnreadTopics'), 'verificationcode' => array('Register.php', 'VerificationCode'), 'viewprofile' => array('Profile.php', 'ModifyProfile'), 'vote' => array('Poll.php', 'Vote'), 'viewquery' => array('ViewQuery.php', 'ViewQuery'), 'viewsmfile' => array('Admin.php', 'DisplayAdminFile'), 'who' => array('Who.php', 'Who'), '.xml' => array('News.php', 'ShowXmlFeed'), 'xmlhttp' => array('Xml.php', 'XMLhttpMain'));
    // Allow modifying $actionArray easily.
    call_integration_hook('integrate_actions', array(&$actionArray));
    if (!empty($context['disable_sp'])) {
        unset($actionArray['portal'], $actionArray['forum']);
    }
    // Get the function and file to include - if it's not there, do the board index.
    if (!isset($_REQUEST['action']) || !isset($actionArray[$_REQUEST['action']])) {
        // Catch the action with the theme?
        if (!empty($settings['catch_action'])) {
            require_once $sourcedir . '/Themes.php';
            return 'WrapAction';
        }
        // Fall through to the board index then...
        require_once $sourcedir . '/BoardIndex.php';
        return 'BoardIndex';
    }
    // Otherwise, it was set - so let's go to that action.
    require_once $sourcedir . '/' . $actionArray[$_REQUEST['action']][0];
    return $actionArray[$_REQUEST['action']][1];
}
示例#17
0
文件: Load.php 项目: KeiroD/Elkarte
/**
 * Attempt to reload our known languages.
 *
 * @param bool $use_cache = true
 */
function getLanguages($use_cache = true)
{
    global $settings, $modSettings;
    // Either we don't use the cache, or its expired.
    if (!$use_cache || ($languages = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) {
        // If we don't have our theme information yet, lets get it.
        if (empty($settings['default_theme_dir'])) {
            loadTheme(0, false);
        }
        // Default language directories to try.
        $language_directories = array($settings['default_theme_dir'] . '/languages', $settings['actual_theme_dir'] . '/languages');
        // We possibly have a base theme directory.
        if (!empty($settings['base_theme_dir'])) {
            $language_directories[] = $settings['base_theme_dir'] . '/languages';
        }
        // Remove any duplicates.
        $language_directories = array_unique($language_directories);
        foreach ($language_directories as $language_dir) {
            // Can't look in here... doesn't exist!
            if (!file_exists($language_dir)) {
                continue;
            }
            $dir = dir($language_dir);
            while ($entry = $dir->read()) {
                // Only directories are interesting
                if ($entry == '..' || !is_dir($dir->path . '/' . $entry)) {
                    continue;
                }
                // @todo at some point we may want to simplify that stuff (I mean scanning all the files just for index)
                $file_dir = dir($dir->path . '/' . $entry);
                while ($file_entry = $file_dir->read()) {
                    // Look for the index language file....
                    if (!preg_match('~^index\\.(.+)\\.php$~', $file_entry, $matches)) {
                        continue;
                    }
                    $languages[$matches[1]] = array('name' => Util::ucwords(strtr($matches[1], array('_' => ' '))), 'selected' => false, 'filename' => $matches[1], 'location' => $language_dir . '/' . $entry . '/index.' . $matches[1] . '.php');
                }
                $file_dir->close();
            }
            $dir->close();
        }
        // Lets cash in on this deal.
        if (!empty($modSettings['cache_enable'])) {
            cache_put_data('known_languages', $languages, !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600);
        }
    }
    return $languages;
}
示例#18
0
文件: Load.php 项目: alencarmo/OCF
function loadBoard()
{
    global $txt, $db_prefix, $scripturl, $context, $modSettings;
    global $board_info, $board, $topic, $ID_MEMBER, $user_info;
    // Assume they are not a moderator.
    $user_info['is_mod'] = false;
    $context['user']['is_mod'] =& $user_info['is_mod'];
    // Start the linktree off empty..
    $context['linktree'] = array();
    // Load this board only if the it is specified.
    if (empty($board) && empty($topic)) {
        $board_info = array('moderators' => array());
        return;
    }
    if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] == 3)) {
        // !!! SLOW?
        if (!empty($topic)) {
            $temp = cache_get_data('topic_board-' . $topic, 120);
        } else {
            $temp = cache_get_data('board-' . $board, 120);
        }
        if (!empty($temp)) {
            $board_info = $temp;
            $board = $board_info['id'];
        }
    }
    if (empty($temp)) {
        $request = db_query("\n\t\t\tSELECT\n\t\t\t\tc.ID_CAT, b.name AS bname, b.description, b.numTopics, b.memberGroups,\n\t\t\t\tb.ID_PARENT, c.name AS cname, IFNULL(mem.ID_MEMBER, 0) AS ID_MODERATOR,\n\t\t\t\tmem.realName" . (!empty($topic) ? ", b.ID_BOARD" : '') . ", b.childLevel,\n\t\t\t\tb.ID_THEME, b.override_theme, b.permission_mode, b.countPosts\n\t\t\tFROM ({$db_prefix}boards AS b" . (!empty($topic) ? ", {$db_prefix}topics AS t" : '') . ")\n\t\t\t\tLEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)\n\t\t\t\tLEFT JOIN {$db_prefix}moderators AS mods ON (mods.ID_BOARD = " . (empty($topic) ? $board : 't.ID_BOARD') . ")\n\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = mods.ID_MEMBER)\n\t\t\tWHERE b.ID_BOARD = " . (empty($topic) ? $board : "t.ID_BOARD\n\t\t\t\tAND t.ID_TOPIC = {$topic}"), __FILE__, __LINE__);
        // If there aren't any, skip.
        if (mysql_num_rows($request) > 0) {
            $row = mysql_fetch_assoc($request);
            // Set the current board.
            if (!empty($row['ID_BOARD'])) {
                $board = $row['ID_BOARD'];
            }
            // Basic operating information. (globals... :/)
            $board_info = array('id' => $board, 'moderators' => array(), 'cat' => array('id' => $row['ID_CAT'], 'name' => $row['cname']), 'name' => $row['bname'], 'description' => $row['description'], 'num_topics' => $row['numTopics'], 'parent_boards' => getBoardParents($row['ID_PARENT']), 'parent' => $row['ID_PARENT'], 'child_level' => $row['childLevel'], 'theme' => $row['ID_THEME'], 'override_theme' => !empty($row['override_theme']), 'use_local_permissions' => !empty($modSettings['permission_enable_by_board']) && $row['permission_mode'] == 1, 'permission_mode' => empty($modSettings['permission_enable_by_board']) ? empty($row['permission_mode']) ? 'normal' : ($row['permission_mode'] == 2 ? 'no_polls' : ($row['permission_mode'] == 3 ? 'reply_only' : 'read_only')) : 'normal', 'posts_count' => empty($row['countPosts']));
            // Load the membergroups allowed, and check permissions.
            $board_info['groups'] = $row['memberGroups'] == '' ? array() : explode(',', $row['memberGroups']);
            do {
                if (!empty($row['ID_MODERATOR'])) {
                    $board_info['moderators'][$row['ID_MODERATOR']] = array('id' => $row['ID_MODERATOR'], 'name' => $row['realName'], 'href' => $scripturl . '?action=profile;u=' . $row['ID_MODERATOR'], 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MODERATOR'] . '" title="' . $txt[62] . '">' . $row['realName'] . '</a>');
                }
            } while ($row = mysql_fetch_assoc($request));
            if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] == 3)) {
                // !!! SLOW?
                if (!empty($topic)) {
                    cache_put_data('topic_board-' . $topic, $board_info, 120);
                }
                cache_put_data('board-' . $board, $board_info, 120);
            }
        } else {
            // Otherwise the topic is invalid, there are no moderators, etc.
            $board_info = array('moderators' => array(), 'error' => 'exist');
            $topic = null;
            $board = 0;
        }
        mysql_free_result($request);
    }
    if (!empty($topic)) {
        $_GET['board'] = (int) $board;
    }
    if (!empty($board)) {
        // Now check if the user is a moderator.
        $user_info['is_mod'] = isset($board_info['moderators'][$ID_MEMBER]);
        if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) {
            $board_info['error'] = 'access';
        }
        // Build up the linktree.
        $context['linktree'] = array_merge($context['linktree'], array(array('url' => $scripturl . '#' . $board_info['cat']['id'], 'name' => $board_info['cat']['name'])), array_reverse($board_info['parent_boards']), array(array('url' => $scripturl . '?board=' . $board . '.0', 'name' => $board_info['name'])));
    }
    // Set the template contextual information.
    $context['user']['is_mod'] =& $user_info['is_mod'];
    $context['current_topic'] = $topic;
    $context['current_board'] = $board;
    // Hacker... you can't see this topic, I'll tell you that. (but moderators can!)
    if (!empty($board_info['error']) && ($board_info['error'] != 'access' || !$user_info['is_mod'])) {
        // The permissions and theme need loading, just to make sure everything goes smoothly.
        loadPermissions();
        loadTheme();
        $_GET['board'] = '';
        $_GET['topic'] = '';
        // If it's a prefetching agent, just make clear they're not allowed.
        if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
            ob_end_clean();
            header('HTTP/1.1 403 Forbidden');
            die;
        } elseif ($user_info['is_guest']) {
            loadLanguage('Errors');
            is_not_guest($txt['topic_gone']);
        } else {
            fatal_lang_error('topic_gone', false);
        }
    }
    if ($user_info['is_mod']) {
        $user_info['groups'][] = 3;
    }
}
示例#19
0
/**
 *	Initialises key values for SimpleDesk.
 *
 *	This function initialises certain key constructs for SimpleDesk, such as constants, that are used throughout
 *	SimpleDesk. It should be called first right up in Load.php anyway.
 *
 *	Calling multiple times is not significantly detrimental to performance; the function is aware if it has been
 *	called previously.
 *
 *	@since 2.0
*/
function shd_init()
{
    global $modSettings, $sourcedir, $user_info, $context, $smcFunc;
    static $called = null;
    if (!empty($called)) {
        return;
    }
    $called = true;
    $context['shd_home'] = 'action=helpdesk;sa=main';
    // What SD version are we on? It's now here!
    define('SHD_VERSION', 'SimpleDesk 2.0 Anatidae');
    // This isn't the SMF way. But for something like this, it's way way more logical and readable.
    define('TICKET_STATUS_NEW', 0);
    define('TICKET_STATUS_PENDING_STAFF', 1);
    define('TICKET_STATUS_PENDING_USER', 2);
    define('TICKET_STATUS_CLOSED', 3);
    define('TICKET_STATUS_WITH_SUPERVISOR', 4);
    define('TICKET_STATUS_ESCALATED', 5);
    define('TICKET_STATUS_DELETED', 6);
    define('TICKET_URGENCY_LOW', 0);
    define('TICKET_URGENCY_MEDIUM', 1);
    define('TICKET_URGENCY_HIGH', 2);
    define('TICKET_URGENCY_VHIGH', 3);
    define('TICKET_URGENCY_SEVERE', 4);
    define('TICKET_URGENCY_CRITICAL', 5);
    define('MSG_STATUS_NORMAL', 0);
    define('MSG_STATUS_DELETED', 1);
    // Relationship types
    define('RELATIONSHIP_LINKED', 0);
    define('RELATIONSHIP_DUPLICATED', 1);
    define('RELATIONSHIP_ISPARENT', 2);
    define('RELATIONSHIP_ISCHILD', 3);
    // Custom fields, their types, positions, content type
    define('CFIELD_TICKET', 1);
    define('CFIELD_REPLY', 2);
    define('CFIELD_PLACE_DETAILS', 1);
    define('CFIELD_PLACE_INFO', 2);
    define('CFIELD_PLACE_PREFIX', 3);
    define('CFIELD_PLACE_PREFIXFILTER', 4);
    define('CFIELD_TYPE_TEXT', 1);
    define('CFIELD_TYPE_LARGETEXT', 2);
    define('CFIELD_TYPE_INT', 3);
    define('CFIELD_TYPE_FLOAT', 4);
    define('CFIELD_TYPE_SELECT', 5);
    define('CFIELD_TYPE_CHECKBOX', 6);
    define('CFIELD_TYPE_RADIO', 7);
    define('CFIELD_TYPE_MULTI', 8);
    // Ticket notification options
    define('NOTIFY_PREFS', 0);
    define('NOTIFY_ALWAYS', 1);
    define('NOTIFY_NEVER', 2);
    // Roles and permissions
    define('ROLE_USER', 1);
    define('ROLE_STAFF', 2);
    //define('ROLE_SUPERVISOR', 3);
    define('ROLE_ADMIN', 4);
    define('ROLEPERM_DISALLOW', 0);
    define('ROLEPERM_ALLOW', 1);
    define('ROLEPERM_DENY', 2);
    // How many digits should we show for ticket numbers? Normally we pad to 5 digits, e.g. 00001 - this is how we set that width.
    if (empty($modSettings['shd_zerofill']) || $modSettings['shd_zerofill'] < 0) {
        $modSettings['shd_zerofill'] = 0;
    }
    // Load some stuff
    shd_load_language('sd_language/SimpleDesk');
    require_once $sourcedir . '/sd_source/Subs-SimpleDeskPermissions.php';
    // Set up defaults
    $defaults = array('shd_attachments_mode' => 'ticket', 'shd_ticketnav_style' => 'sd', 'shd_staff_badge' => 'nobadge', 'shd_privacy_display' => 'smart');
    foreach ($defaults as $var => $val) {
        if (empty($modSettings[$var])) {
            $modSettings[$var] = $val;
        }
    }
    $modSettings['helpdesk_active'] = isset($modSettings['admin_features']) ? in_array('shd', explode(',', $modSettings['admin_features'])) : false;
    if ($modSettings['helpdesk_active']) {
        shd_load_plugin_files('init');
        shd_load_plugin_langfiles('init');
    }
    shd_load_user_perms();
    if (!empty($modSettings['shd_maintenance_mode'])) {
        if (!empty($modSettings['shd_helpdesk_only']) && !$user_info['is_admin'] && !shd_allowed_to('admin_helpdesk', 0)) {
            // You can only login.... otherwise, you're getting the "maintenance mode" display. Except we have to boot up a decent amount of SMF.
            if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'login2' && $_REQUEST['action'] != 'logout') {
                $_GET['action'] = '';
                $_REQUEST['action'] = '';
                $context['shd_maintenance_mode'] = true;
                loadBoard();
                loadPermissions();
                loadTheme();
                is_not_banned();
                require_once $sourcedir . '/Subs-Auth.php';
                InMaintenance();
                obExit(null, null, false);
            }
        } else {
            $modSettings['helpdesk_active'] &= $user_info['is_admin'] || shd_allowed_to('admin_helpdesk', 0);
        }
    }
    // Last minute stuff
    if ($modSettings['helpdesk_active']) {
        // Are they actually going into the helpdesk? If they are, do we need to deal with their theme?
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'helpdesk') {
            // First figure out what department they're in.
            $this_dept = 0;
            $depts = shd_allowed_to('access_helpdesk', false);
            // Do they only have one dept? If so, that's the one.
            if (count($depts) == 1) {
                $this_dept = $depts[0];
            } elseif (isset($_REQUEST['dept'])) {
                $_REQUEST['dept'] = (int) $_REQUEST['dept'];
                if (in_array($_REQUEST['dept'], $depts)) {
                    $this_dept = $_REQUEST['dept'];
                }
            } elseif (isset($_REQUEST['newdept'])) {
                $_REQUEST['newdept'] = (int) $_REQUEST['newdept'];
                if (in_array($_REQUEST['newdept'], $depts)) {
                    $this_dept = $_REQUEST['newdept'];
                }
            } elseif (isset($_REQUEST['ticket'])) {
                $ticket = (int) $_REQUEST['ticket'];
                if (!empty($ticket)) {
                    $query = shd_db_query('', '
						SELECT hdt.id_dept, dept_name, dept_theme
						FROM {db_prefix}helpdesk_tickets AS hdt
							INNER JOIN {db_prefix}helpdesk_depts AS hdd ON (hdt.id_dept = hdd.id_dept)
						WHERE id_ticket = {int:ticket}
							AND {query_see_ticket}', array('ticket' => $ticket));
                    if ($row = $smcFunc['db_fetch_row']($query)) {
                        if (in_array($row[0], $depts)) {
                            list($this_dept, $context['shd_dept_name'], $theme) = $row;
                        }
                    }
                    $smcFunc['db_free_result']($query);
                }
            }
            if (!empty($this_dept) && !isset($theme)) {
                $context['queried_dept'] = $this_dept;
                $query = $smcFunc['db_query']('', '
					SELECT dept_theme
					FROM {db_prefix}helpdesk_depts
					WHERE id_dept = {int:dept}', array('dept' => $this_dept));
                if ($row = $smcFunc['db_fetch_row']($query)) {
                    $theme = $row[0];
                }
                $smcFunc['db_free_result']($query);
            }
            // If for whatever reason we didn't establish a theme, see if there's a forum default one.
            if (empty($theme) && !empty($modSettings['shd_theme'])) {
                $theme = $modSettings['shd_theme'];
            }
            // Action.
            if (!empty($theme)) {
                // This is ever so slightly hacky. But as this function is called sufficiently early we can get away with it.
                unset($_REQUEST['theme'], $modSettings['theme_allow']);
                $modSettings['theme_guests'] = $theme;
            }
        }
    }
    $context['shd_plugins'] = empty($modSettings['shd_enabled_plugins']) || empty($modSettings['helpdesk_active']) ? array() : explode(',', $modSettings['shd_enabled_plugins']);
    call_integration_hook('shd_hook_init');
}