Beispiel #1
0
function AutoTask()
{
    global $time_start, $modSettings, $smcFunc;
    // Special case for doing the mail queue.
    if (isset($_GET['scheduled']) && $_GET['scheduled'] == 'mailq') {
        ReduceMailQueue();
    } else {
        // Select the next task to do.
        $request = smf_db_query('
			SELECT id_task, task, next_time, time_offset, time_regularity, time_unit
			FROM {db_prefix}scheduled_tasks
			WHERE disabled = {int:not_disabled}
				AND next_time <= {int:current_time}
			ORDER BY next_time ASC
			LIMIT 1', array('not_disabled' => 0, 'current_time' => time()));
        if (mysql_num_rows($request) != 0) {
            // The two important things really...
            $row = mysql_fetch_assoc($request);
            // When should this next be run?
            $next_time = next_time($row['time_regularity'], $row['time_unit'], $row['time_offset']);
            // How long in seconds it the gap?
            $duration = $row['time_regularity'];
            if ($row['time_unit'] == 'm') {
                $duration *= 60;
            } elseif ($row['time_unit'] == 'h') {
                $duration *= 3600;
            } elseif ($row['time_unit'] == 'd') {
                $duration *= 86400;
            } elseif ($row['time_unit'] == 'w') {
                $duration *= 604800;
            }
            // If we were really late running this task actually skip the next one.
            if (time() + $duration / 2 > $next_time) {
                $next_time += $duration;
            }
            // Update it now, so no others run this!
            smf_db_query('
				UPDATE {db_prefix}scheduled_tasks
				SET next_time = {int:next_time}
				WHERE id_task = {int:id_task}
					AND next_time = {int:current_next_time}', array('next_time' => $next_time, 'id_task' => $row['id_task'], 'current_next_time' => $row['next_time']));
            $affected_rows = smf_db_affected_rows();
            // The function must exist or we are wasting our time, plus do some timestamp checking, and database check!
            if (function_exists('scheduled_' . $row['task']) && (!isset($_GET['ts']) || $_GET['ts'] == $row['next_time']) && $affected_rows) {
                ignore_user_abort(true);
                // Do the task...
                $completed = call_user_func('scheduled_' . $row['task']);
                // Log that we did it ;)
                if ($completed) {
                    $total_time = round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 3);
                    smf_db_insert('', '{db_prefix}log_scheduled_tasks', array('id_task' => 'int', 'time_run' => 'int', 'time_taken' => 'float'), array($row['id_task'], time(), (int) $total_time), array());
                }
            }
        }
        mysql_free_result($request);
        // Get the next timestamp right.
        $request = smf_db_query('
			SELECT next_time
			FROM {db_prefix}scheduled_tasks
			WHERE disabled = {int:not_disabled}
			ORDER BY next_time ASC
			LIMIT 1', array('not_disabled' => 0));
        // No new task scheduled yet?
        if (mysql_num_rows($request) === 0) {
            $nextEvent = time() + 86400;
        } else {
            list($nextEvent) = mysql_fetch_row($request);
        }
        mysql_free_result($request);
        updateSettings(array('next_task_time' => $nextEvent));
    }
    // Shall we return?
    if (!isset($_GET['scheduled'])) {
        return true;
    }
    // Finally, send some stuff...
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Type: image/gif');
    die("GIF89a€!ù,D;");
}
Beispiel #2
0
function loadTheme($id_theme = 0, $initialize = true)
{
    global $user_info, $user_settings, $board_info, $boarddir, $db_show_debug;
    global $txt, $boardurl, $scripturl, $mbname, $modSettings;
    global $context, $settings, $options, $sourcedir, $ssi_theme;
    // The theme was specified by parameter.
    if (!empty($id_theme)) {
        $id_theme = (int) $id_theme;
    } elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
        $id_theme = (int) $_REQUEST['theme'];
        $_SESSION['id_theme'] = $id_theme;
    } elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
        $id_theme = (int) $_SESSION['id_theme'];
    } elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) {
        $id_theme = $user_info['theme'];
    } elseif (!empty($board_info['theme'])) {
        $id_theme = $board_info['theme'];
    } else {
        $id_theme = $modSettings['theme_guests'];
    }
    // Verify the id_theme... no foul play.
    // Always allow the board specific theme, if they are overriding.
    if (!empty($board_info['theme']) && $board_info['override_theme']) {
        $id_theme = $board_info['theme'];
    } elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) {
        $id_theme = (int) $id_theme;
    } elseif (!empty($modSettings['knownThemes']) && !allowedTo('admin_forum')) {
        $themes = explode(',', $modSettings['knownThemes']);
        if (!in_array($id_theme, $themes)) {
            $id_theme = $modSettings['theme_guests'];
        } else {
            $id_theme = (int) $id_theme;
        }
    } else {
        $id_theme = (int) $id_theme;
    }
    $member = empty($user_info['id']) ? -1 : $user_info['id'];
    if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = CacheAPI::getCache('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) {
        $themeData = $temp;
        $flag = true;
    } elseif (($temp = CacheAPI::getCache('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) {
        $themeData = $temp + array($member => array());
    } else {
        $themeData = array(-1 => array(), 0 => array(), $member => array());
    }
    if (empty($flag)) {
        // Load variables from the current or default theme, global or this user's.
        $result = smf_db_query('
			SELECT variable, value, id_member, id_theme
			FROM {db_prefix}themes
			WHERE id_member' . (empty($themeData[0]) ? ' IN (-1, 0, {int:id_member})' : ' = {int:id_member}') . '
				AND id_theme' . ($id_theme == 1 ? ' = {int:id_theme}' : ' IN ({int:id_theme}, 1)'), array('id_theme' => $id_theme, 'id_member' => $member));
        // Pick between $settings and $options depending on whose data it is.
        while ($row = mysql_fetch_assoc($result)) {
            // There are just things we shouldn't be able to change as members.
            if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) {
                continue;
            }
            // If this is the theme_dir of the default theme, store it.
            if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) {
                $themeData[0]['default_' . $row['variable']] = $row['value'];
            }
            // If this isn't set yet, is a theme option, or is not the default theme..
            if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') {
                $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value'];
            }
        }
        mysql_free_result($result);
        if (!empty($themeData[-1])) {
            foreach ($themeData[-1] as $k => $v) {
                if (!isset($themeData[$member][$k])) {
                    $themeData[$member][$k] = $v;
                }
            }
        }
        if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
            CacheAPI::putCache('theme_settings-' . $id_theme . ':' . $member, $themeData, 60);
        } elseif (!isset($temp)) {
            CacheAPI::putCache('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90);
        }
    }
    $settings = $themeData[0];
    $options = $themeData[$member];
    $member_tracking_optin = $user_info['is_guest'] || (empty($options['disable_analytics']) ? 1 : !$options['disable_analytics']);
    if (isset($modSettings['embed_GA']) && $modSettings['embed_GA'] && !empty($modSettings['GA_tracker_id']) && !empty($modSettings['GA_domain_name']) && $member_tracking_optin) {
        $context['want_GA_embedded'] = true;
    }
    if (isset($modSettings['embed_piwik']) && $modSettings['embed_piwik'] && !empty($modSettings['piwik_uri']) && !empty($modSettings['piwik_tracker_id']) && $member_tracking_optin) {
        $context['want_piwik_embedded'] = true;
        $modSettings['piwik_uri'] = rtrim($modSettings['piwik_uri'], '/\\ ');
    }
    $settings['theme_id'] = $id_theme;
    $settings['actual_theme_url'] = $settings['theme_url'];
    $settings['actual_images_url'] = $settings['images_url'];
    $settings['actual_theme_dir'] = $settings['theme_dir'];
    $settings['posticons_url'] = $settings['images_url'] . '/post/';
    $settings['template_dirs'] = array();
    // This theme first.
    $settings['template_dirs'][] = $settings['theme_dir'];
    // Based on theme (if there is one).
    if (!empty($settings['base_theme_dir'])) {
        $settings['template_dirs'][] = $settings['base_theme_dir'];
    }
    // Lastly the default theme.
    if ($settings['theme_dir'] != $settings['default_theme_dir']) {
        $settings['template_dirs'][] = $settings['default_theme_dir'];
    }
    if (!$initialize) {
        return;
    }
    // Check to see if they're accessing it from the wrong place.
    if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) {
        $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://';
        $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
        $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
        if ($temp != '/') {
            $detected_url .= $temp;
        }
    }
    if (isset($detected_url) && $detected_url != $boardurl) {
        // Try #1 - check if it's in a list of alias addresses.
        if (!empty($modSettings['forum_alias_urls'])) {
            $aliases = explode(',', $modSettings['forum_alias_urls']);
            foreach ($aliases as $alias) {
                // Rip off all the boring parts, spaces, etc.
                if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) {
                    $do_fix = true;
                }
            }
        }
        // Hmm... check #2 - is it just different by a www?  Send them to the correct place!!
        if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') {
            // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;).
            if (empty($_GET)) {
                redirectexit('wwwRedirect');
            } else {
                list($k, $v) = each($_GET);
                if ($k != 'wwwRedirect') {
                    redirectexit('wwwRedirect;' . $k . '=' . $v);
                }
            }
        }
        // #3 is just a check for SSL...
        if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) {
            $do_fix = true;
        }
        // Okay, #4 - perhaps it's an IP address?  We're gonna want to use that one, then. (assuming it's the IP or something...)
        if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\\d\\.:]+|\\[[\\d:]+\\](?::\\d+)?)(?:$|/)~', $detected_url) == 1) {
            // Caching is good ;).
            $oldurl = $boardurl;
            // Fix $boardurl and $scripturl.
            $boardurl = $detected_url;
            $scripturl = strtr($scripturl, array($oldurl => $boardurl));
            $_SERVER['REQUEST_URL'] = strtr($_SERVER['REQUEST_URL'], array($oldurl => $boardurl));
            // Fix the theme urls...
            $settings['theme_url'] = strtr($settings['theme_url'], array($oldurl => $boardurl));
            $settings['default_theme_url'] = strtr($settings['default_theme_url'], array($oldurl => $boardurl));
            $settings['actual_theme_url'] = strtr($settings['actual_theme_url'], array($oldurl => $boardurl));
            $settings['images_url'] = strtr($settings['images_url'], array($oldurl => $boardurl));
            $settings['default_images_url'] = strtr($settings['default_images_url'], array($oldurl => $boardurl));
            $settings['actual_images_url'] = strtr($settings['actual_images_url'], array($oldurl => $boardurl));
            // And just a few mod settings :).
            $modSettings['smileys_url'] = strtr($modSettings['smileys_url'], array($oldurl => $boardurl));
            $modSettings['avatar_url'] = strtr($modSettings['avatar_url'], array($oldurl => $boardurl));
            // Clean up after loadBoard().
            if (isset($board_info['moderators'])) {
                foreach ($board_info['moderators'] as $k => $dummy) {
                    $board_info['moderators'][$k]['href'] = strtr($dummy['href'], array($oldurl => $boardurl));
                    $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl));
                }
            }
            foreach ($context['linktree'] as $k => $dummy) {
                $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl));
            }
        }
    }
    // Set up the contextual user array.
    $context['user'] = array('id' => $user_info['id'], 'is_logged' => !$user_info['is_guest'], 'is_guest' => &$user_info['is_guest'], 'is_admin' => &$user_info['is_admin'], 'is_mod' => &$user_info['is_mod'], 'can_mod' => allowedTo('access_mod_center') || !$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])), 'username' => $user_info['username'], 'language' => $user_info['language'], 'email' => $user_info['email'], 'ignoreusers' => $user_info['ignoreusers']);
    if (!$context['user']['is_guest']) {
        $context['user']['name'] = $user_info['name'];
    } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) {
        $context['user']['name'] = $txt['guest_title'];
    }
    // Determine the current smiley set and map it to a numeric id (parsed post cache needs this, because
    // we don't want to left join with string matching
    $smiley_sets = explode(',', $modSettings['smiley_sets_known']);
    $user_info['smiley_set'] = !in_array($user_info['smiley_set'], $smiley_sets) && $user_info['smiley_set'] != 'none' || empty($modSettings['smiley_sets_enable']) ? !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'] : $user_info['smiley_set'];
    if ($user_info['smiley_set'] == 'none') {
        $user_info['smiley_set_id'] = 0;
    } else {
        $user_info['smiley_set_id'] = array_search($user_info['smiley_set'], $smiley_sets) + 1;
    }
    $context['user']['smiley_set'] = $user_info['smiley_set'];
    // Some basic information...
    if (!isset($context['html_headers'])) {
        $context['html_headers'] = '';
    }
    $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | ';
    $context['session_var'] = $_SESSION['session_var'];
    $context['session_id'] = $_SESSION['session_value'];
    $context['forum_name'] = $mbname;
    $context['forum_name_html_safe'] = commonAPI::htmlspecialchars($context['forum_name']);
    $context['header_logo_url_html_safe'] = empty($settings['header_logo_url']) ? '' : commonAPI::htmlspecialchars($settings['header_logo_url']);
    $context['current_action'] = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null;
    if (isset($modSettings['load_average'])) {
        $context['load_average'] = $modSettings['load_average'];
    }
    // Set some permission related settings.
    $context['show_login_bar'] = $user_info['is_guest'] && !empty($modSettings['enableVBStyleLogin']);
    // This determines the server... not used in many places, except for login fixing.
    $context['server'] = array('is_iis' => isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false, 'is_apache' => isset($_SERVER['SERVER_SOFTWARE']) && (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false), 'is_lighttpd' => isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') !== false, 'is_nginx' => isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false, 'is_cgi' => isset($_SERVER['SERVER_SOFTWARE']) && strpos(php_sapi_name(), 'cgi') !== false, 'is_windows' => strpos(PHP_OS, 'WIN') === 0, 'iso_case_folding' => ord(strtolower(chr(138))) === 154, 'complex_preg_chars' => 1);
    // A bug in some versions of IIS under CGI (older ones) makes cookie setting not work with Location: headers.
    $context['server']['needs_login_fix'] = $context['server']['is_cgi'] && $context['server']['is_iis'];
    // Detect the browser. This is separated out because it's also used in attachment downloads
    detectBrowser();
    // Set the top level linktree up.
    /*
    array_unshift($context['linktree'], array(
    	'url' => URL::home(),
    	'name' => $context['forum_name_html_safe']
    ));
    */
    // This allows sticking some HTML on the page output - useful for controls.
    if (!isset($txt)) {
        $txt = array();
    }
    $simpleActions = array('findmember', 'helpadmin', 'printpage', 'quotefast');
    if (isset($_REQUEST['xml'])) {
        loadLanguage('index+Modifications');
        loadTemplate('Xml');
        $context['template_layers'] = array();
    } elseif (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], $simpleActions)) {
        loadLanguage('index+Modifications');
        $context['template_layers'] = array();
    } else {
        loadLanguage('index+Modifications');
        // Custom templates to load, or just default?
        $is_admin = isset($_REQUEST['action']) && $_REQUEST['action'] === 'admin';
        $templates = array('index');
        // Load each template...
        foreach ($templates as $template) {
            if (!$is_admin) {
                loadTemplate($template);
            } else {
                loadAdminTemplate($template);
            }
        }
        $context['template_layers'] = array('html', 'body');
    }
    if (isset($db_show_debug) && !empty($db_show_debug)) {
        loadLanguage('Debug');
    }
    if (file_exists($settings['theme_dir'] . '/theme_support.php')) {
        @(require_once $settings['theme_dir'] . '/theme_support.php');
    } else {
        @(require_once $settings['default_theme_dir'] . '/theme_support.php');
    }
    // Guests may still need a name.
    if ($context['user']['is_guest'] && empty($context['user']['name'])) {
        $context['user']['name'] = $txt['guest_title'];
    }
    // Any theme-related strings that need to be loaded?
    if (!empty($settings['require_theme_strings'])) {
        loadLanguage('ThemeStrings', '', false);
    }
    // We allow theme variants, because we're cool.
    $context['theme_variant'] = '';
    $context['theme_variant_url'] = '';
    if (empty($settings['theme_variants'])) {
        $settings['theme_variants'] = array('default');
    }
    // Overriding - for previews and that ilk.
    if (!empty($_REQUEST['variant'])) {
        $_SESSION['id_variant'] = $_REQUEST['variant'];
    }
    // User selection?
    if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) {
        $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : '');
    }
    // If not a user variant, select the default.
    if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) {
        $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0];
    }
    if (!in_array($context['theme_variant'], $settings['theme_variants'])) {
        $context['theme_variant'] = 'default';
    }
    // Do this to keep things easier in the templates.
    $context['theme_variant'] = '_' . $context['theme_variant'];
    $context['theme_variant_url'] = $context['theme_variant'] . '/';
    /*
    	if(!empty($context['theme_variant']) && $context['theme_variant'] != '_default') {
    		if(!empty($settings['base_theme_dir']))
    			$settings['template_dirs'][] = $settings['base_theme_dir'] . '/variants/' . $context['theme_variant'];
    		else
    			$settings['template_dirs'][] = $settings['default_theme_dir'] . '/variants/' . $context['theme_variant'];
    	}
    */
    // Allow overriding the board wide time/number formats.
    if (empty($user_settings['time_format']) && !empty($txt['time_format'])) {
        $user_info['time_format'] = $txt['time_format'];
    }
    $txt['number_format'] = empty($txt['number_format']) ? empty($modSettings['number_format']) ? '' : $modSettings['number_format'] : $txt['number_format'];
    if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'always') {
        $settings['theme_url'] = $settings['default_theme_url'];
        $settings['images_url'] = $settings['default_images_url'];
        $settings['theme_dir'] = $settings['default_theme_dir'];
    }
    // Make a special URL for the language.
    $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']);
    // Set the character set from the template.
    $context['character_set'] = 'UTF-8';
    $context['utf8'] = true;
    $context['right_to_left'] = !empty($txt['lang_rtl']);
    $context['tabindex'] = 1;
    // Compatibility.
    if (!isset($settings['theme_version'])) {
        $modSettings['memberCount'] = $modSettings['totalMembers'];
    }
    // This allows us to change the way things look for the admin.
    $context['admin_features'] = isset($modSettings['admin_features']) ? explode(',', $modSettings['admin_features']) : array('cd,cp,k,w,rg,ml,pm');
    // If we think we have mail to send, let's offer up some possibilities... robots get pain (Now with scheduled task support!)
    if (!empty($modSettings['mail_next_send']) && $modSettings['mail_next_send'] < time() && empty($modSettings['mail_queue_use_cron']) || empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) {
        if ($context['browser']['possibly_robot']) {
            //!!! Maybe move this somewhere better?!
            require_once $sourcedir . '/ScheduledTasks.php';
            // What to do, what to do?!
            if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) {
                AutoTask();
            } else {
                ReduceMailQueue();
            }
        } else {
            $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq';
            $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time'];
            $context['html_headers'] .= '
	<script type="text/javascript">
		function smfAutoTask()
		{
			var tempImage = new Image();
			tempImage.src = "' . $scripturl . '?scheduled=' . $type . ';ts=' . $ts . '";
		}
		window.setTimeout("smfAutoTask();", 1);
	</script>';
        }
    }
    // Any files to include at this point?
    if (!empty($modSettings['integrate_theme_include'])) {
        $theme_includes = explode(',', $modSettings['integrate_theme_include']);
        foreach ($theme_includes as $include) {
            $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir']));
            if (file_exists($include)) {
                require_once $include;
            }
        }
    }
    $settings['primary_css'] = $settings['theme_url'] . MOBILE_SUBDIR . '/css/' . CSS_PRIMARY_BASE . $context['theme_variant'];
    $context['theme_scripts'] = array();
    $context['inline_footer_script'] = '';
    $context['news_item_count'] = 0;
    $context['hot_topic_message'] = sprintf($txt['hot_topics'], $modSettings['hotTopicPosts']);
    $context['very_hot_topic_message'] = sprintf($txt['very_hot_topics'], $modSettings['hotTopicVeryPosts']);
    $context['old_topic_message'] = sprintf($txt['old_topic_message'], $modSettings['oldTopicDays']);
    // Call load theme integration functions.
    HookAPI::callHook('integrate_load_theme');
    // We are ready to go.
    $context['theme_loaded'] = true;
}
Beispiel #3
0
/**
 * This function clears the mail queue of all emails, and at the end redirects to browse.
 */
function ClearMailQueue()
{
    global $sourcedir, $smcFunc;
    checkSession('get');
    // This is certainly needed!
    require_once $sourcedir . '/ScheduledTasks.php';
    // If we don't yet have the total to clear, find it.
    if (!isset($_GET['te'])) {
        // How many items do we have?
        $request = $smcFunc['db_query']('', '
			SELECT COUNT(*) AS queue_size
			FROM {db_prefix}mail_queue', array());
        list($_GET['te']) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);
    } else {
        $_GET['te'] = (int) $_GET['te'];
    }
    $_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0;
    // Send 50 at a time, then go for a break...
    while (ReduceMailQueue(50, true, true) === true) {
        // Sent another 50.
        $_GET['sent'] += 50;
        pauseMailQueueClear();
    }
    return BrowseMailQueue();
}