yourls_db_connect(); } // Allow early inclusion of a cache layer if (file_exists(YOURLS_USERDIR . '/cache.php')) { require_once YOURLS_USERDIR . '/cache.php'; } // Read options right from start yourls_get_all_options(); // Register shutdown function register_shutdown_function('yourls_shutdown'); // Core now loaded yourls_do_action('init'); // plugins can't see this, not loaded yet // Check if need to redirect to install procedure if (!yourls_is_installed() && !yourls_is_installing()) { yourls_redirect(yourls_admin_url('install.php'), 302); } // Check if upgrade is needed (bypassed if upgrading or installing) if (!yourls_is_upgrading() && !yourls_is_installing()) { if (yourls_upgrade_is_needed()) { yourls_redirect(YOURLS_SITE . '/admin/upgrade.php', 302); } } // Init all plugins yourls_load_plugins(); yourls_do_action('plugins_loaded'); // Is there a new version of YOURLS ? yourls_new_core_version_notice(); if (yourls_is_admin()) { yourls_do_action('admin_init'); }
function yourls_load_plugins() { global $ydb; $ydb->plugins = array(); $active_plugins = yourls_get_option('active_plugins'); // Don't load plugins when installing or updating if (!$active_plugins or defined('YOURLS_INSTALLING') and YOURLS_INSTALLING or yourls_upgrade_is_needed()) { return; } foreach ((array) $active_plugins as $key => $plugin) { if (yourls_validate_plugin_file(YOURLS_PLUGINDIR . '/' . $plugin)) { include_once YOURLS_PLUGINDIR . '/' . $plugin; $ydb->plugins[] = $plugin; unset($active_plugins[$key]); } } // $active_plugins should be empty now, if not, a plugin could not be find: remove it if (count($active_plugins)) { $missing = '<strong>' . join('</strong>, <strong>', $active_plugins) . '</strong>'; yourls_update_option('active_plugins', $ydb->plugins); $message = 'Could not find and deactivated ' . yourls_plural('plugin', count($active_plugins)) . ' ' . $missing; yourls_add_notice($message); } }