示例#1
0
文件: Admin.php 项目: norv/EosAlpha
function AdminMain()
{
    global $txt, $context, $scripturl, $modSettings, $settings, $sourcedir, $options, $boarddir, $backend_subdir;
    // Load the language and templates....
    loadLanguage('Admin');
    loadAdminTemplate('Admin');
    $context['robot_no_index'] = true;
    require_once $sourcedir . '/lib/Subs-Menu.php';
    // Some preferences.
    $context['admin_preferences'] = !empty($options['admin_preferences']) ? unserialize($options['admin_preferences']) : array();
    // Define all the menu structure - see Subs-Menu.php for details!
    $admin_areas = array('forum' => array('title' => $txt['admin_main'], 'permission' => array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'), 'areas' => array('index' => array('label' => $txt['admin_center'], 'function' => 'AdminHome', 'icon' => 'administration.gif'), 'credits' => array('label' => $txt['support_credits_title'], 'function' => 'AdminHome', 'icon' => 'support.gif'), 'news' => array('label' => $txt['news_title'], 'file' => $backend_subdir . '/ManageNews.php', 'function' => 'ManageNews', 'icon' => 'news.gif', 'permission' => array('edit_news', 'send_mail', 'admin_forum'), 'subsections' => array('editnews' => array($txt['admin_edit_news'], 'edit_news'), 'mailingmembers' => array($txt['admin_newsletters'], 'send_mail'), 'settings' => array($txt['settings'], 'admin_forum'))), 'packages' => array('label' => $txt['package'], 'file' => $backend_subdir . '/Packages.php', 'function' => 'Packages', 'permission' => array('admin_forum'), 'icon' => 'packages.gif', 'subsections' => array('browse' => array($txt['browse_packages']), 'packageget' => array($txt['download_packages'], 'url' => $scripturl . '?action=admin;area=packages;sa=packageget;get'), 'installed' => array($txt['installed_packages']), 'perms' => array($txt['package_file_perms']), 'options' => array($txt['package_settings']))), 'plugins' => array('label' => $txt['plugins_title'], 'file' => $backend_subdir . '/Plugins.php', 'function' => 'PluginsMain', 'permission' => array('admin_forum'), 'icon' => 'packages.gif', 'subsections' => array('browse' => array($txt['browse_plugins']), 'hooks' => array($txt['browse_hooks']))), 'search' => array('function' => 'AdminSearch', 'permission' => array('admin_forum'), 'select' => 'index'))), 'config' => array('title' => $txt['admin_config'], 'permission' => array('admin_forum'), 'areas' => array('corefeatures' => array('label' => $txt['core_settings_title'], 'file' => $backend_subdir . '/ManageSettings.php', 'function' => 'ModifyCoreFeatures', 'icon' => 'corefeatures.gif'), 'featuresettings' => array('label' => $txt['modSettings_title'], 'file' => $backend_subdir . '/ManageSettings.php', 'function' => 'ModifyFeatureSettings', 'icon' => 'features.gif', 'subsections' => array('basic' => array($txt['mods_cat_features']), 'layout' => array($txt['mods_cat_layout']), 'sig' => array($txt['signature_settings_short']), 'profile' => array($txt['custom_profile_shorttitle'], 'enabled' => in_array('cp', $context['admin_features'])))), 'securitysettings' => array('label' => $txt['admin_security_moderation'], 'file' => $backend_subdir . '/ManageSettings.php', 'function' => 'ModifySecuritySettings', 'icon' => 'security.gif', 'subsections' => array('general' => array($txt['mods_cat_security_general']), 'spam' => array($txt['antispam_title']), 'moderation' => array($txt['moderation_settings_short'], 'enabled' => substr($modSettings['warning_settings'], 0, 1) == 1))), 'languages' => array('label' => $txt['language_configuration'], 'file' => $backend_subdir . '/ManageServer.php', 'function' => 'ManageLanguages', 'icon' => 'languages.gif', 'subsections' => array('edit' => array($txt['language_edit']), 'add' => array($txt['language_add']), 'settings' => array($txt['language_settings']))), 'serversettings' => array('label' => $txt['admin_server_settings'], 'file' => $backend_subdir . '/ManageServer.php', 'function' => 'ModifySettings', 'icon' => 'server.gif', 'subsections' => array('general' => array($txt['general_settings']), 'database' => array($txt['database_paths_settings']), 'cookie' => array($txt['cookies_sessions_settings']), 'cache' => array($txt['caching_settings']), 'loads' => array($txt['load_balancing_settings']))), 'relatedtopics' => array('label' => $txt['admin_related_topic'], 'file' => $backend_subdir . '/RelatedTopics.php', 'function' => 'RelatedTopicsAdmin', 'subsections' => array('settings' => array($txt['admin_related_topics_settings']), 'methods' => array($txt['admin_related_topics_methods']))), 'current_theme' => array('label' => $txt['theme_current_settings'], 'file' => $backend_subdir . '/Themes.php', 'function' => 'ThemesMain', 'custom_url' => $scripturl . '?action=admin;area=theme;sa=settings;th=' . $settings['theme_id'], 'icon' => 'current_theme.gif'), 'theme' => array('label' => $txt['theme_admin'], 'file' => $backend_subdir . '/Themes.php', 'function' => 'ThemesMain', 'custom_url' => $scripturl . '?action=admin;area=theme;sa=admin', 'icon' => 'themes.gif', 'subsections' => array('admin' => array($txt['themeadmin_admin_title']), 'list' => array($txt['themeadmin_list_title']), 'reset' => array($txt['themeadmin_reset_title']), 'edit' => array($txt['themeadmin_edit_title']))), 'modsettings' => array('label' => $txt['admin_modifications'], 'file' => $backend_subdir . '/ManageSettings.php', 'function' => 'ModifyModSettings', 'icon' => 'modifications.gif', 'related' => array($txt['admin_related_topic']), 'subsections' => array('general' => array($txt['mods_cat_modifications_misc']))), 'socialsettings' => array('label' => $txt['admin_social'], 'file' => $backend_subdir . '/ManageSettings.php', 'function' => 'ModifySocialSettings', 'subsections' => array('general' => array($txt['socialsettings_general']), 'astream' => array($txt['socialsettings_astream']))))), 'layout' => array('title' => $txt['layout_controls'], 'permission' => array('manage_boards', 'admin_forum', 'manage_smileys', 'manage_attachments', 'moderate_forum'), 'areas' => array('manageboards' => array('label' => $txt['admin_boards'], 'file' => $backend_subdir . '/ManageBoards.php', 'function' => 'ManageBoards', 'icon' => 'boards.gif', 'permission' => array('manage_boards'), 'subsections' => array('main' => array($txt['boardsEdit']), 'newcat' => array($txt['mboards_new_cat']), 'settings' => array($txt['settings'], 'admin_forum'))), 'postsettings' => array('label' => $txt['manageposts'], 'file' => $backend_subdir . '/ManagePosts.php', 'function' => 'ManagePostSettings', 'permission' => array('admin_forum'), 'icon' => 'posts.gif', 'subsections' => array('posts' => array($txt['manageposts_settings']), 'bbc' => array($txt['manageposts_bbc_settings']), 'censor' => array($txt['admin_censored_words']), 'topics' => array($txt['manageposts_topic_settings']), 'prefixes' => array($txt['manageposts_prefix_settings']), 'tags' => array($txt['manageposts_tag_settings']), 'ratings' => array($txt['karma']))), 'managecalendar' => array('label' => $txt['manage_calendar'], 'file' => $backend_subdir . '/ManageCalendar.php', 'function' => 'ManageCalendar', 'icon' => 'calendar.gif', 'permission' => array('admin_forum'), 'enabled' => in_array('cd', $context['admin_features']), 'subsections' => array('holidays' => array($txt['manage_holidays'], 'admin_forum', 'enabled' => !empty($modSettings['cal_enabled'])), 'settings' => array($txt['calendar_settings'], 'admin_forum'))), 'managesearch' => array('label' => $txt['manage_search'], 'file' => $backend_subdir . '/ManageSearch.php', 'function' => 'ManageSearch', 'icon' => 'search.gif', 'permission' => array('admin_forum'), 'subsections' => array('weights' => array($txt['search_weights']), 'method' => array($txt['search_method']), 'settings' => array($txt['settings']), 'managesphinx' => array($txt['search_managesphinx']))), 'smileys' => array('label' => $txt['smileys_manage'], 'file' => $backend_subdir . '/ManageSmileys.php', 'function' => 'ManageSmileys', 'icon' => 'smiley.gif', 'permission' => array('manage_smileys'), 'subsections' => array('editsets' => array($txt['smiley_sets']), 'addsmiley' => array($txt['smileys_add'], 'enabled' => !empty($modSettings['smiley_enable'])), 'editsmileys' => array($txt['smileys_edit'], 'enabled' => !empty($modSettings['smiley_enable'])), 'setorder' => array($txt['smileys_set_order'], 'enabled' => !empty($modSettings['smiley_enable'])), 'editicons' => array($txt['icons_edit_message_icons'], 'enabled' => !empty($modSettings['messageIcons_enable'])), 'settings' => array($txt['settings']))), 'manageattachments' => array('label' => $txt['attachments_avatars'], 'file' => $backend_subdir . '/ManageAttachments.php', 'function' => 'ManageAttachments', 'icon' => 'attachment.gif', 'permission' => array('manage_attachments'), 'subsections' => array('browse' => array($txt['attachment_manager_browse']), 'attachments' => array($txt['attachment_manager_settings']), 'avatars' => array($txt['attachment_manager_avatar_settings']), 'maintenance' => array($txt['attachment_manager_maintenance']))))), 'members' => array('title' => $txt['admin_manage_members'], 'permission' => array('moderate_forum', 'manage_membergroups', 'manage_bans', 'manage_permissions', 'admin_forum'), 'areas' => array('viewmembers' => array('label' => $txt['admin_users'], 'file' => $backend_subdir . '/ManageMembers.php', 'function' => 'ViewMembers', 'icon' => 'members.gif', 'permission' => array('moderate_forum'), 'subsections' => array('all' => array($txt['view_all_members']), 'search' => array($txt['mlist_search']))), 'membergroups' => array('label' => $txt['admin_groups'], 'file' => $backend_subdir . '/ManageMembergroups.php', 'function' => 'ModifyMembergroups', 'icon' => 'membergroups.gif', 'permission' => array('manage_membergroups'), 'subsections' => array('index' => array($txt['membergroups_edit_groups'], 'manage_membergroups'), 'add' => array($txt['membergroups_new_group'], 'manage_membergroups'), 'settings' => array($txt['settings'], 'admin_forum'))), 'permissions' => array('label' => $txt['edit_permissions'], 'file' => $backend_subdir . '/ManagePermissions.php', 'function' => 'ModifyPermissions', 'icon' => 'permissions.gif', 'permission' => array('manage_permissions'), 'subsections' => array('index' => array($txt['permissions_groups'], 'manage_permissions'), 'board' => array($txt['permissions_boards'], 'manage_permissions'), 'profiles' => array($txt['permissions_profiles'], 'manage_permissions'), 'postmod' => array($txt['permissions_post_moderation'], 'manage_permissions', 'enabled' => $modSettings['postmod_active']), 'settings' => array($txt['settings'], 'admin_forum'))), 'regcenter' => array('label' => $txt['registration_center'], 'file' => $backend_subdir . '/ManageRegistration.php', 'function' => 'RegCenter', 'icon' => 'regcenter.gif', 'permission' => array('admin_forum', 'moderate_forum'), 'subsections' => array('register' => array($txt['admin_browse_register_new'], 'moderate_forum'), 'agreement' => array($txt['registration_agreement'], 'admin_forum'), 'reservednames' => array($txt['admin_reserved_set'], 'admin_forum'), 'settings' => array($txt['settings'], 'admin_forum'))), 'ban' => array('label' => $txt['ban_title'], 'file' => $backend_subdir . '/ManageBans.php', 'function' => 'Ban', 'icon' => 'ban.gif', 'permission' => 'manage_bans', 'subsections' => array('list' => array($txt['ban_edit_list']), 'add' => array($txt['ban_add_new']), 'browse' => array($txt['ban_trigger_browse']), 'log' => array($txt['ban_log']))), 'paidsubscribe' => array('label' => $txt['paid_subscriptions'], 'enabled' => in_array('ps', $context['admin_features']), 'file' => $backend_subdir . '/ManagePaid.php', 'icon' => 'paid.gif', 'function' => 'ManagePaidSubscriptions', 'permission' => 'admin_forum', 'subsections' => array('view' => array($txt['paid_subs_view']), 'settings' => array($txt['settings']))), 'sengines' => array('label' => $txt['search_engines'], 'enabled' => in_array('sp', $context['admin_features']), 'file' => $backend_subdir . '/ManageSearchEngines.php', 'icon' => 'engines.gif', 'function' => 'SearchEngines', 'permission' => 'admin_forum', 'subsections' => array('stats' => array($txt['spider_stats']), 'logs' => array($txt['spider_logs']), 'spiders' => array($txt['spiders']), 'settings' => array($txt['settings']))))), 'maintenance' => array('title' => $txt['admin_maintenance'], 'permission' => array('admin_forum'), 'areas' => array('maintain' => array('label' => $txt['maintain_title'], 'file' => $backend_subdir . '/ManageMaintenance.php', 'icon' => 'maintain.gif', 'function' => 'ManageMaintenance', 'subsections' => array('routine' => array($txt['maintain_sub_routine'], 'admin_forum'), 'database' => array($txt['maintain_sub_database'], 'admin_forum'), 'members' => array($txt['maintain_sub_members'], 'admin_forum'), 'topics' => array($txt['maintain_sub_topics'], 'admin_forum'))), 'scheduledtasks' => array('label' => $txt['maintain_tasks'], 'file' => $backend_subdir . '/ManageScheduledTasks.php', 'icon' => 'scheduled.gif', 'function' => 'ManageScheduledTasks', 'subsections' => array('tasks' => array($txt['maintain_tasks'], 'admin_forum'), 'tasklog' => array($txt['scheduled_log'], 'admin_forum'))), 'mailqueue' => array('label' => $txt['mailqueue_title'], 'file' => $backend_subdir . '/ManageMail.php', 'function' => 'ManageMail', 'icon' => 'mail.gif', 'subsections' => array('browse' => array($txt['mailqueue_browse'], 'admin_forum'), 'settings' => array($txt['mailqueue_settings'], 'admin_forum'))), 'reports' => array('enabled' => in_array('rg', $context['admin_features']), 'label' => $txt['generate_reports'], 'file' => 'Reports.php', 'function' => 'ReportsMain', 'icon' => 'reports.gif'), 'logs' => array('label' => $txt['logs'], 'function' => 'AdminLogs', 'icon' => 'logs.gif', 'subsections' => array('errorlog' => array($txt['errlog'], 'admin_forum', 'enabled' => !empty($modSettings['enableErrorLogging']), 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc'), 'adminlog' => array($txt['admin_log'], 'admin_forum', 'enabled' => in_array('ml', $context['admin_features'])), 'modlog' => array($txt['moderation_log'], 'admin_forum', 'enabled' => in_array('ml', $context['admin_features'])), 'banlog' => array($txt['ban_log'], 'manage_bans'), 'spiderlog' => array($txt['spider_logs'], 'admin_forum', 'enabled' => in_array('sp', $context['admin_features'])), 'tasklog' => array($txt['scheduled_log'], 'admin_forum'), 'pruning' => array($txt['pruning_title'], 'admin_forum'))), 'repairboards' => array('label' => $txt['admin_repair'], 'file' => $backend_subdir . '/RepairBoards.php', 'function' => 'RepairBoards', 'select' => 'maintain', 'hidden' => true))));
    if (!$modSettings['tags_active']) {
        unset($admin_areas['layout']['areas']['postsettings']['subsections']['tags']);
    }
    if (empty($modSettings['karmaMode'])) {
        unset($admin_areas['layout']['areas']['postsettings']['subsections']['ratings']);
    }
    // Any files to include for administration?
    if (!empty($modSettings['integrate_admin_include'])) {
        $admin_includes = explode(',', $modSettings['integrate_admin_include']);
        foreach ($admin_includes as $include) {
            $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
            if (file_exists($include)) {
                require_once $include;
            }
        }
    }
    // Let them modify admin areas easily.
    HookAPI::callHook('integrate_admin_areas', array(&$admin_areas));
    SimpleSEF::adminAreas($admin_areas);
    // Make sure the administrator has a valid session...
    validateSession();
    // Actually create the menu!
    $admin_include_data = createMenu($admin_areas);
    unset($admin_areas);
    // Nothing valid?
    if ($admin_include_data == false) {
        fatal_lang_error('no_access', false);
    }
    // Build the link tree.
    $context['linktree'][] = array('url' => $scripturl . '?action=admin', 'name' => $txt['admin_center']);
    if (isset($admin_include_data['current_area']) && $admin_include_data['current_area'] != 'index') {
        $context['linktree'][] = array('url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'name' => $admin_include_data['label']);
    }
    if (!empty($admin_include_data['current_subsection']) && $admin_include_data['subsections'][$admin_include_data['current_subsection']][0] != $admin_include_data['label']) {
        $context['linktree'][] = array('url' => $scripturl . '?action=admin;area=' . $admin_include_data['current_area'] . ';sa=' . $admin_include_data['current_subsection'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'name' => $admin_include_data['subsections'][$admin_include_data['current_subsection']][0]);
    }
    // Make a note of the Unique ID for this menu.
    $context['admin_menu_id'] = $context['max_menu_id'];
    $context['admin_menu_name'] = 'menu_data_' . $context['admin_menu_id'];
    // Why on the admin are we?
    $context['admin_area'] = $admin_include_data['current_area'];
    // Now - finally - call the right place!
    if (isset($admin_include_data['file'])) {
        require_once $sourcedir . '/' . $admin_include_data['file'];
    }
    $admin_include_data['function']();
}
示例#2
0
文件: Load.php 项目: norv/EosAlpha
function reloadSettings()
{
    global $modSettings, $sourcedir, $boardurl, $cachedir;
    $no_hooks = isset($GLOBALS['g_disable_all_hooks']) && $GLOBALS['g_disable_all_hooks'] === true;
    CacheAPI::init($GLOBALS['db_cache_api'], md5($boardurl . filemtime($sourcedir . '/Load.php')) . '-SMF-', $GLOBALS['db_cache_memcached'], $cachedir);
    // Most database systems have not set UTF-8 as their default input charset.
    smf_db_query('
		SET NAMES utf8', array());
    // Try to load it from the cache first; it'll never get cached if the setting is off.
    if (($modSettings = CacheAPI::getCache('modSettings', 600)) == null) {
        $request = smf_db_query('
			SELECT variable, value
			FROM {db_prefix}settings', array());
        $modSettings = array();
        if (!$request) {
            db_fatal_error();
        }
        while ($row = mysql_fetch_row($request)) {
            $modSettings[$row[0]] = $row[1];
        }
        mysql_free_result($request);
        // Do a few things to protect against missing settings or settings with invalid values...
        if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) {
            $modSettings['defaultMaxTopics'] = 20;
        }
        if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) {
            $modSettings['defaultMaxMessages'] = 15;
        }
        if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) {
            $modSettings['defaultMaxMembers'] = 30;
        }
        if (empty($modSettings['max_messageLength'])) {
            $modSettings['max_messageLength'] = 1024 * 1024;
        }
        // hard post length limit, 1M *should* be more than ever needed
        if (isset($modSettings['admin_features'])) {
            $_f = explode(',', $modSettings['admin_features']);
            $modSettings['postmod_active'] = in_array('pm', $_f);
            $modSettings['astream_active'] = in_array('as', $_f);
            $modSettings['tags_active'] = in_array('ts', $_f);
        } else {
            $modSettings['tags_active'] = $modSettings['postmod_active'] = $modSettings['astream_active'] = false;
        }
        $modSettings['hidden_content_no_view_msg'] = @unserialize($modSettings['hidden_content_no_view']);
        $modSettings['online_today'] = @unserialize($modSettings['log_online_today']);
        if (!empty($modSettings['cache_enable'])) {
            CacheAPI::putCache('modSettings', $modSettings, 600);
        }
    }
    if (empty($modSettings['cache_enable'])) {
        CacheAPI::disable();
    }
    if ($no_hooks) {
        $modSettings['integration_hooks'] = '';
    }
    HookAPI::setHooks($modSettings['integration_hooks']);
    // Setting the timezone is a requirement for some functions in PHP >= 5.1.
    date_default_timezone_set(isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : 'UTC');
    // Check the load averages?
    if (!empty($modSettings['loadavg_enable'])) {
        if (($modSettings['load_average'] = CacheAPI::getCache('loadavg', 90)) == null) {
            $modSettings['load_average'] = @file_get_contents('/proc/loadavg');
            if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) {
                $modSettings['load_average'] = (double) $matches[1];
            } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\\d+\\.\\d+), (\\d+\\.\\d+), (\\d+\\.\\d+)~i', $modSettings['load_average'], $matches) != 0) {
                $modSettings['load_average'] = (double) $matches[1];
            } else {
                unset($modSettings['load_average']);
            }
            if (!empty($modSettings['load_average'])) {
                CacheAPI::putCache('loadavg', $modSettings['load_average'], 90);
            }
        }
        if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) {
            db_fatal_error(true);
        }
    }
    require_once $sourcedir . '/SimpleSEF.php';
    URL::init($boardurl);
    // Call pre load integration functions.
    HookAPI::callHook('pre_load');
    SimpleSEF::convertQueryString();
}
示例#3
0
function sendmail($to, $subject, $message, $from = null, $message_id = null, $send_html = false, $priority = 3, $hotmail_fix = null, $is_private = false)
{
    global $webmaster_email, $context, $modSettings, $txt, $scripturl;
    // Use sendmail if it's set or if no SMTP server is set.
    $use_sendmail = empty($modSettings['mail_type']) || $modSettings['smtp_host'] == '';
    // Line breaks need to be \r\n only in windows or for SMTP.
    $line_break = $context['server']['is_windows'] || !$use_sendmail ? "\r\n" : "\n";
    // So far so good.
    $mail_result = true;
    // If the recipient list isn't an array, make it one.
    $to_array = is_array($to) ? $to : array($to);
    // Once upon a time, Hotmail could not interpret non-ASCII mails.
    // In honour of those days, it's still called the 'hotmail fix'.
    if ($hotmail_fix === null) {
        $hotmail_to = array();
        foreach ($to_array as $i => $to_address) {
            if (preg_match('~@(att|comcast|bellsouth)\\.[a-zA-Z\\.]{2,6}$~i', $to_address) === 1) {
                $hotmail_to[] = $to_address;
                $to_array = array_diff($to_array, array($to_address));
            }
        }
        // Call this function recursively for the hotmail addresses.
        if (!empty($hotmail_to)) {
            $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true);
        }
        // The remaining addresses no longer need the fix.
        $hotmail_fix = false;
        // No other addresses left? Return instantly.
        if (empty($to_array)) {
            return $mail_result;
        }
    }
    // Get rid of entities.
    $subject = un_htmlspecialchars($subject);
    // Make the message use the proper line breaks.
    $message = str_replace(array("\r", "\n"), array('', $line_break), $message);
    // Make sure hotmail mails are sent as HTML so that HTML entities work.
    if ($hotmail_fix && !$send_html) {
        $send_html = true;
        $message = strtr($message, array($line_break => '<br />' . $line_break));
        $message = preg_replace('~(' . preg_quote($scripturl, '~') . '(?:[?/][\\w\\-_%\\.,\\?&;=#]+)?)~', '<a href="$1">$1</a>', $message);
    }
    list(, $from_name) = mimespecialchars(addcslashes($from !== null ? $from : $context['forum_name'], '<>()\'\\"'), true, $hotmail_fix, $line_break);
    list(, $subject) = mimespecialchars($subject, true, $hotmail_fix, $line_break);
    // Construct the mail headers...
    $headers = 'From: "' . $from_name . '" <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>' . $line_break;
    $headers .= $from !== null ? 'Reply-To: <' . $from . '>' . $line_break : '';
    $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break;
    $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break;
    if ($message_id !== null && empty($modSettings['mail_no_message_id'])) {
        $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break;
    }
    $headers .= 'X-Mailer: SMF' . $line_break;
    if (!empty($modSettings['simplesef_enable'])) {
        SimpleSEF::fixEmailOutput($subject, $message, $headers);
    }
    // Pass this to the integration before we start modifying the output -- it'll make it easier later.
    if (in_array(false, HookAPI::callHook('integrate_outgoing_email', array(&$subject, &$message, &$headers)), true)) {
        return false;
    }
    // Save the original message...
    $orig_message = $message;
    // The mime boundary separates the different alternative versions.
    $mime_boundary = 'SMF-' . md5($message . time());
    // Using mime, as it allows to send a plain unencoded alternative.
    $headers .= 'Mime-Version: 1.0' . $line_break;
    $headers .= 'Content-Type: multipart/alternative; boundary="' . $mime_boundary . '"' . $line_break;
    $headers .= 'Content-Transfer-Encoding: 7bit' . $line_break;
    // Sending HTML?  Let's plop in some basic stuff, then.
    if ($send_html) {
        $no_html_message = un_htmlspecialchars(strip_tags(strtr($orig_message, array('</title>' => $line_break))));
        // But, then, dump it and use a plain one for dinosaur clients.
        list(, $plain_message) = mimespecialchars($no_html_message, false, true, $line_break);
        $message = $plain_message . $line_break . '--' . $mime_boundary . $line_break;
        // This is the plain text version.  Even if no one sees it, we need it for spam checkers.
        list($charset, $plain_charset_message, $encoding) = mimespecialchars($no_html_message, false, false, $line_break);
        $message .= 'Content-Type: text/plain; charset=' . $charset . $line_break;
        $message .= 'Content-Transfer-Encoding: ' . $encoding . $line_break . $line_break;
        $message .= $plain_charset_message . $line_break . '--' . $mime_boundary . $line_break;
        // This is the actual HTML message, prim and proper.  If we wanted images, they could be inlined here (with multipart/related, etc.)
        list($charset, $html_message, $encoding) = mimespecialchars($orig_message, false, $hotmail_fix, $line_break);
        $message .= 'Content-Type: text/html; charset=' . $charset . $line_break;
        $message .= 'Content-Transfer-Encoding: ' . ($encoding == '' ? '7bit' : $encoding) . $line_break . $line_break;
        $message .= $html_message . $line_break . '--' . $mime_boundary . '--';
    } else {
        // Send a plain message first, for the older web clients.
        list(, $plain_message) = mimespecialchars($orig_message, false, true, $line_break);
        $message = $plain_message . $line_break . '--' . $mime_boundary . $line_break;
        // Now add an encoded message using the forum's character set.
        list($charset, $encoded_message, $encoding) = mimespecialchars($orig_message, false, false, $line_break);
        $message .= 'Content-Type: text/plain; charset=' . $charset . $line_break;
        $message .= 'Content-Transfer-Encoding: ' . $encoding . $line_break . $line_break;
        $message .= $encoded_message . $line_break . '--' . $mime_boundary . '--';
    }
    // Are we using the mail queue, if so this is where we butt in...
    if (!empty($modSettings['mail_queue']) && $priority != 0) {
        return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private);
    } elseif (!empty($modSettings['mail_queue']) && !empty($modSettings['mail_limit'])) {
        list($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']);
        if (empty($mails_this_minute) || time() > $last_mail_time + 60) {
            $new_queue_stat = time() . '|' . 1;
        } else {
            $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1);
        }
        updateSettings(array('mail_recent' => $new_queue_stat));
    }
    // SMTP or sendmail?
    if ($use_sendmail) {
        $subject = strtr($subject, array("\r" => '', "\n" => ''));
        if (!empty($modSettings['mail_strip_carriage'])) {
            $message = strtr($message, array("\r" => ''));
            $headers = strtr($headers, array("\r" => ''));
        }
        foreach ($to_array as $to) {
            if (!mail(strtr($to, array("\r" => '', "\n" => '')), $subject, $message, $headers)) {
                log_error(sprintf($txt['mail_send_unable'], $to));
                $mail_result = false;
            }
            // Wait, wait, I'm still sending here!
            @set_time_limit(300);
            if (function_exists('apache_reset_timeout')) {
                @apache_reset_timeout();
            }
        }
    } else {
        $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers);
    }
    // Everything go smoothly?
    return $mail_result;
}
示例#4
0
 public static function obExit($header = null, $do_footer = null, $from_index = false, $from_fatal_error = false)
 {
     global $context, $modSettings;
     static $header_done = false, $footer_done = false, $level = 0, $has_fatal_error = false;
     // Attempt to prevent a recursive loop.
     ++$level;
     if ($level > 1 && !$from_fatal_error && !$has_fatal_error) {
         exit;
     }
     if ($from_fatal_error) {
         $has_fatal_error = true;
     }
     // Clear out the stat cache.
     trackStats();
     // If we have mail to send, send it.
     if (!empty($context['flush_mail'])) {
         AddMailQueue(true);
     }
     $do_header = $header === null ? !$header_done : $header;
     if ($do_footer === null) {
         $do_footer = $do_header;
     }
     // Has the template/header been done yet?
     if ($do_header) {
         // Was the page title set last minute? Also update the HTML safe one.
         if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) {
             $context['page_title_html_safe'] = $context['forum_name_html_safe'] . ' - ' . commonAPI::htmlspecialchars(un_htmlspecialchars($context['page_title']));
         }
         // Start up the session URL fixer.
         ob_start('ob_sessrewrite');
         HookAPI::integrateOB();
         //if(!empty($modSettings['simplesef_enable']))
         //	ob_start('SimpleSEF::ob_simplesef');
         // Display the screen in the logical order.
         self::template_header();
         $header_done = true;
     }
     if ($do_footer) {
         if (WIRELESS && !isset($context['sub_template'])) {
             fatal_lang_error('wireless_error_notyet', false);
         }
         self::Display();
         // Just so we don't get caught in an endless loop of errors from the footer...
         if (!$footer_done) {
             $footer_done = true;
             // (since this is just debugging... it's okay that it's after </html>.)
             if (!isset($_REQUEST['xml'])) {
                 db_debug_junk();
             }
         }
     }
     // Remember this URL in case someone doesn't like sending HTTP_REFERER.
     if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) {
         $_SESSION['old_url'] = $_SERVER['REQUEST_URL'];
     }
     // For session check verfication.... don't switch browsers...
     $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
     // Hand off the output to the portal, etc. we're integrated with.
     HookAPI::callHook('integrate_exit', array($do_footer));
     if (!empty($modSettings['simplesef_enable'])) {
         SimpleSEF::fixXMLOutput($do_footer);
     }
     // Don't exit if we're coming from index.php; that will pass through normally.
     if (!$from_index) {
         exit;
     }
 }
示例#5
0
    /**
     * Loads all board names from the forum into a variable and cache (if possible)
     * This helps reduce the number of queries needed for SimpleSEF to run
     *
     * @global array $smcFunc
     * @global string $language
     * @param boolean $force Forces a reload of board names
     */
    private static function loadBoardNames($force = FALSE)
    {
        global $language;
        if ($force || (self::$boardNames = CacheAPI::getCache('simplesef_board_list', 3600)) == NULL) {
            loadLanguage('index', $language, false);
            $request = smf_db_query('
				SELECT id_board, name
				FROM {db_prefix}boards', array());
            $boards = array();
            while ($row = mysql_fetch_assoc($request)) {
                // A bit extra overhead to account for duplicate board names
                $temp_name = self::encode($row['name']);
                $i = 0;
                while (!empty($boards[$temp_name . (!empty($i) ? $i + 1 : '')])) {
                    $i++;
                }
                //$boards[$temp_name . (!empty($i) ? $i + 1 : '')] = $row['id_board'];
                $boards[$temp_name . '.' . trim($row['id_board'])] = $row['id_board'];
            }
            mysql_free_result($request);
            self::$boardNames = array_flip($boards);
            // Add one to the query cound and put the data into the cache
            self::$queryCount++;
            CacheAPI::putCache('simplesef_board_list', self::$boardNames, 3600);
            //self::log('Cache hit failed, reloading board names');
        }
    }
示例#6
0
function ob_sessrewrite($buffer)
{
    global $scripturl, $modSettings, $context, $user_info, $txt, $time_start, $db_count;
    /*
     * tidy support as a debugging option to generate prettified output 
     * and only do it for the admin when 'tidyup' is set in the request string (tidy can be slow) 
     * pretty HTML output might help with debugging templates
     */
    if (isset($_REQUEST['tidyup']) && !isset($_REQUEST['xml']) && class_exists('Tidy') && $user_info['is_admin']) {
        $tidy = new Tidy();
        $tidy_config = array('indent' => true, 'output-html' => true, 'wrap' => 0, 'merge-divs' => false, 'merge-spans' => false);
        $tidy->parseString($buffer, $tidy_config, 'utf8');
        $buffer = $tidy;
    }
    // If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
    if ($scripturl == '' || !defined('SID')) {
        return $buffer;
    }
    // rewrite urls with PHPSESSID, but only if the session isn't cookied and NOT for spiders
    if (empty($_COOKIE) && SID != '' && empty($context['browser']['possibly_robot'])) {
        $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '(?!\\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&amp;', $buffer);
    } elseif (isset($_GET['debug'])) {
        $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer);
    }
    $now = microtime();
    $context['load_time'] = round(array_sum(explode(' ', $now)) - array_sum(explode(' ', $time_start)), 3);
    $context['load_queries'] = $db_count;
    $context['template_benchmark_time'] = round(array_sum(explode(' ', $now)) - array_sum(explode(' ', $context['template_benchmark'])), 3);
    if (!empty($modSettings['simplesef_enable'])) {
        $buffer = isset($context['sef_full_rewrite']) ? SimpleSEF::ob_simplesef($buffer) : SimpleSEF::ob_simplesef_light($buffer);
        //$buffer .= SimpleSEF::$debug_info;
    }
    $_t = EoS_Smarty::isActive() ? 's template-smarty), ' : 's template), ';
    $buffer = str_replace('@%%__loadtime__%%@', $user_info['is_admin'] ? $context['load_time'] . 's CPU (' . $context['template_benchmark_time'] . $_t . $context['load_queries'] . ' ' . $txt['queries'] . SimpleSEF::getPerfData() : '', $buffer);
    if (isset($_REQUEST['xml'])) {
        $buffer = ltrim($buffer);
    }
    return $buffer;
}
示例#7
0
function determineActions($urls, $preferred_prefix = false)
{
    global $txt, $user_info, $modSettings, $smcFunc, $context;
    if (!allowedTo('who_view')) {
        return array();
    }
    loadLanguage('Who');
    // Actions that require a specific permission level.
    $allowedActions = array('admin' => array('moderate_forum', 'manage_membergroups', 'manage_bans', 'admin_forum', 'manage_permissions', 'send_mail', 'manage_attachments', 'manage_smileys', 'manage_boards', 'edit_news'), 'ban' => array('manage_bans'), 'boardrecount' => array('admin_forum'), 'calendar' => array('calendar_view'), 'editnews' => array('edit_news'), 'mailing' => array('send_mail'), 'maintain' => array('admin_forum'), 'manageattachments' => array('manage_attachments'), 'manageboards' => array('manage_boards'), 'mlist' => array('view_mlist'), 'moderate' => array('access_mod_center', 'moderate_forum', 'manage_membergroups'), 'optimizetables' => array('admin_forum'), 'repairboards' => array('admin_forum'), 'search' => array('search_posts'), 'search2' => array('search_posts'), 'setcensor' => array('moderate_forum'), 'setreserve' => array('moderate_forum'), 'stats' => array('view_stats'), 'viewErrorLog' => array('admin_forum'), 'viewmembers' => array('moderate_forum'));
    if (!is_array($urls)) {
        $url_list = array(array($urls, $user_info['id']));
    } else {
        $url_list = $urls;
    }
    // These are done to later query these in large chunks. (instead of one by one.)
    $topic_ids = array();
    $profile_ids = array();
    $board_ids = array();
    $data = array();
    foreach ($url_list as $k => $url) {
        // Get the request parameters..
        $actions = @unserialize($url[0]);
        if ($actions === false) {
            continue;
        }
        // If it's the admin or moderation center, and there is an area set, use that instead.
        if (isset($actions['action']) && ($actions['action'] == 'admin' || $actions['action'] == 'moderate') && isset($actions['area'])) {
            $actions['action'] = $actions['area'];
        }
        // Check if there was no action or the action is display.
        if (!isset($actions['action']) || $actions['action'] == 'display') {
            // It's a topic!  Must be!
            if (isset($actions['topic'])) {
                // Assume they can't view it, and queue it up for later.
                $data[$k] = $txt['who_hidden'];
                $topic_ids[(int) $actions['topic']][$k] = $txt['who_topic'];
            } elseif (isset($actions['board'])) {
                // Hide first, show later.
                $data[$k] = $txt['who_hidden'];
                $board_ids[$actions['board']][$k] = $txt['who_board'];
            } else {
                $data[$k] = $txt['who_index'];
            }
        } elseif ($actions['action'] == '') {
            $data[$k] = $txt['who_index'];
        } else {
            // Viewing/editing a profile.
            if ($actions['action'] == 'profile') {
                // Whose?  Their own?
                if (empty($actions['u'])) {
                    $actions['u'] = $url[1];
                }
                $data[$k] = $txt['who_hidden'];
                $profile_ids[(int) $actions['u']][$k] = $actions['action'] == 'profile' ? $txt['who_viewprofile'] : $txt['who_profile'];
            } elseif (($actions['action'] == 'post' || $actions['action'] == 'post2') && empty($actions['topic']) && isset($actions['board'])) {
                $data[$k] = $txt['who_hidden'];
                $board_ids[(int) $actions['board']][$k] = isset($actions['poll']) ? $txt['who_poll'] : $txt['who_post'];
            } elseif (isset($actions['sa']) && isset($txt['whoall_' . $actions['action'] . '_' . $actions['sa']])) {
                $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']]) ? $txt[$preferred_prefix . $actions['action'] . '_' . $actions['sa']] : $txt['whoall_' . $actions['action'] . '_' . $actions['sa']];
            } elseif (isset($txt['whoall_' . $actions['action']])) {
                $data[$k] = $preferred_prefix && isset($txt[$preferred_prefix . $actions['action']]) ? $txt[$preferred_prefix . $actions['action']] : $txt['whoall_' . $actions['action']];
            } elseif (isset($txt['whotopic_' . $actions['action']])) {
                // Find out what topic they are accessing.
                $topic = (int) (isset($actions['topic']) ? $actions['topic'] : (isset($actions['from']) ? $actions['from'] : 0));
                $data[$k] = $txt['who_hidden'];
                $topic_ids[$topic][$k] = $txt['whotopic_' . $actions['action']];
            } elseif (isset($txt['whopost_' . $actions['action']])) {
                // Find out what message they are accessing.
                $msgid = (int) (isset($actions['msg']) ? $actions['msg'] : (isset($actions['quote']) ? $actions['quote'] : 0));
                $result = smf_db_query('
					SELECT m.id_topic, m.subject
					FROM {db_prefix}messages AS m
						INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
						INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic' . ($modSettings['postmod_active'] ? ' AND t.approved = {int:is_approved}' : '') . ')
					WHERE m.id_msg = {int:id_msg}
						AND {query_see_board}' . ($modSettings['postmod_active'] ? '
						AND m.approved = {int:is_approved}' : '') . '
					LIMIT 1', array('is_approved' => 1, 'id_msg' => $msgid));
                list($id_topic, $subject) = mysql_fetch_row($result);
                $data[$k] = sprintf($txt['whopost_' . $actions['action']], $id_topic, $subject);
                mysql_free_result($result);
                if (empty($id_topic)) {
                    $data[$k] = $txt['who_hidden'];
                }
            } elseif (allowedTo('moderate_forum') && isset($txt['whoadmin_' . $actions['action']])) {
                $data[$k] = $txt['whoadmin_' . $actions['action']];
            } elseif (isset($allowedActions[$actions['action']])) {
                if (allowedTo($allowedActions[$actions['action']])) {
                    $data[$k] = $txt['whoallow_' . $actions['action']];
                } else {
                    $data[$k] = $txt['who_hidden'];
                }
            } else {
                $data[$k] = $txt['who_unknown'];
            }
        }
        // Maybe the action is integrated into another system?
        if (count($integrate_actions = HookAPI::callHook('integrate_whos_online', array($actions))) > 0) {
            foreach ($integrate_actions as $integrate_action) {
                if (!empty($integrate_action)) {
                    $data[$k] = $integrate_action;
                    break;
                }
            }
        }
        if (!empty($modSettings['simplesef_enable'])) {
            SimpleSEF::actionArray($actions);
        }
    }
    // Load topic names.
    if (!empty($topic_ids)) {
        $result = smf_db_query('
			SELECT t.id_topic, m.subject
			FROM {db_prefix}topics AS t
				INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
				INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
			WHERE {query_see_board}
				AND t.id_topic IN ({array_int:topic_list})' . ($modSettings['postmod_active'] ? '
				AND t.approved = {int:is_approved}' : '') . '
			LIMIT {int:limit}', array('topic_list' => array_keys($topic_ids), 'is_approved' => 1, 'limit' => count($topic_ids)));
        while ($row = mysql_fetch_assoc($result)) {
            // Show the topic's subject for each of the actions.
            foreach ($topic_ids[$row['id_topic']] as $k => $session_text) {
                $data[$k] = sprintf($session_text, $row['id_topic'], censorText($row['subject']));
            }
        }
        mysql_free_result($result);
    }
    // Load board names.
    if (!empty($board_ids)) {
        $result = smf_db_query('
			SELECT b.id_board, b.name
			FROM {db_prefix}boards AS b
			WHERE {query_see_board}
				AND b.id_board IN ({array_int:board_list})
			LIMIT ' . count($board_ids), array('board_list' => array_keys($board_ids)));
        while ($row = mysql_fetch_assoc($result)) {
            // Put the board name into the string for each member...
            foreach ($board_ids[$row['id_board']] as $k => $session_text) {
                $data[$k] = sprintf($session_text, $row['id_board'], $row['name']);
            }
        }
        mysql_free_result($result);
    }
    // Load member names for the profile.
    if (!empty($profile_ids) && (allowedTo('profile_view_any') || allowedTo('profile_view_own'))) {
        $result = smf_db_query('
			SELECT id_member, real_name
			FROM {db_prefix}members
			WHERE id_member IN ({array_int:member_list})
			LIMIT ' . count($profile_ids), array('member_list' => array_keys($profile_ids)));
        while ($row = mysql_fetch_assoc($result)) {
            // If they aren't allowed to view this person's profile, skip it.
            if (!allowedTo('profile_view_any') && $user_info['id'] != $row['id_member']) {
                continue;
            }
            // Set their action on each - session/text to sprintf.
            foreach ($profile_ids[$row['id_member']] as $k => $session_text) {
                $data[$k] = sprintf($session_text, $row['id_member'], $row['real_name']);
            }
        }
        mysql_free_result($result);
    }
    if (!is_array($urls)) {
        return isset($data[0]) ? $data[0] : false;
    } else {
        return $data;
    }
}