Ejemplo n.º 1
0
$mybb->cache =& $cache;
$mybb->asset_url = $mybb->get_asset_url();
if ($mybb->use_shutdown == true) {
    register_shutdown_function('run_shutdown');
}
// Did we just upgrade to a new version and haven't run the upgrade scripts yet?
$version = $cache->read("version");
if (!defined("IN_INSTALL") && !defined("IN_UPGRADE") && $version['version_code'] < $mybb->version_code) {
    $version_history = $cache->read("version_history");
    if (empty($version_history) || file_exists(MYBB_ROOT . "install/resources/upgrade" . (int) (end($version_history) + 1) . ".php")) {
        $mybb->trigger_generic_error("board_not_upgraded");
    }
}
// Load plugins
if (!defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1)) {
    $plugins->load();
}
// Set up any shutdown functions we need to run globally
add_shutdown('send_mail_queue');
/* URL Definitions */
if ($mybb->settings['seourls'] == "yes" || $mybb->settings['seourls'] == "auto" && isset($_SERVER['SEO_SUPPORT']) && $_SERVER['SEO_SUPPORT'] == 1) {
    $mybb->seo_support = true;
    define('FORUM_URL', "forum-{fid}.html");
    define('FORUM_URL_PAGED', "forum-{fid}-page-{page}.html");
    define('THREAD_URL', "thread-{tid}.html");
    define('THREAD_URL_PAGED', "thread-{tid}-page-{page}.html");
    define('THREAD_URL_ACTION', 'thread-{tid}-{action}.html');
    define('THREAD_URL_POST', 'thread-{tid}-post-{pid}.html');
    define('POST_URL', "post-{pid}.html");
    define('PROFILE_URL', "user-{uid}.html");
    define('ANNOUNCEMENT_URL', "announcement-{aid}.html");
Ejemplo n.º 2
0
/**
 * Runs the shutdown items after the page has been sent to the browser.
 *
 */
function run_shutdown()
{
    global $config, $db, $cache, $plugins, $error_handler, $shutdown_functions, $shutdown_queries, $done_shutdown, $mybb;
    if ($done_shutdown == true || !$config || $error_handler->has_errors) {
        return;
    }
    // Missing the core? Build
    if (!is_object($mybb)) {
        require_once MYBB_ROOT . "inc/class_core.php";
        $mybb = new MyBB();
        // Load the settings
        require MYBB_ROOT . "inc/settings.php";
        $mybb->settings =& $settings;
    }
    // If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
    if (!is_object($db)) {
        if (!isset($config) || empty($config['database']['type'])) {
            require MYBB_ROOT . "inc/config.php";
        }
        if (isset($config)) {
            require_once MYBB_ROOT . "inc/db_" . $config['database']['type'] . ".php";
            switch ($config['database']['type']) {
                case "sqlite":
                    $db = new DB_SQLite();
                    break;
                case "pgsql":
                    $db = new DB_PgSQL();
                    break;
                case "mysqli":
                    $db = new DB_MySQLi();
                    break;
                default:
                    $db = new DB_MySQL();
            }
            $db->connect($config['database']);
            define("TABLE_PREFIX", $config['database']['table_prefix']);
            $db->set_table_prefix(TABLE_PREFIX);
        }
    }
    // Cache object deconstructed? reconstruct
    if (!is_object($cache)) {
        require_once MYBB_ROOT . "inc/class_datacache.php";
        $cache = new datacache();
        $cache->cache();
    }
    // And finally.. plugins
    if (!is_object($plugins) && !defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1)) {
        require_once MYBB_ROOT . "inc/class_plugins.php";
        $plugins = new pluginSystem();
        $plugins->load();
    }
    // We have some shutdown queries needing to be run
    if (is_array($shutdown_queries)) {
        // Loop through and run them all
        foreach ($shutdown_queries as $query) {
            $db->query($query);
        }
    }
    // Run any shutdown functions if we have them
    if (is_array($shutdown_functions)) {
        foreach ($shutdown_functions as $function) {
            call_user_func_array($function['function'], $function['arguments']);
        }
    }
    $done_shutdown = true;
}