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 yourls_is_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)) { yourls_update_option('active_plugins', $ydb->plugins); $message = yourls_n('Could not find and deactivated plugin :', 'Could not find and deactivated plugins :', count($active_plugins)); $missing = '<strong>' . join('</strong>, <strong>', $active_plugins) . '</strong>'; yourls_add_notice($message . ' ' . $missing); } }
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'); }
/** * Check for maintenance mode. If yes, die. See yourls_maintenance_mode(). Stolen from WP. * */ function yourls_check_maintenance_mode() { $file = YOURLS_ABSPATH . '/.maintenance'; if (!file_exists($file) || yourls_is_upgrading() || yourls_is_installing()) { return; } global $maintenance_start; include_once $file; // If the $maintenance_start timestamp is older than 10 minutes, don't die. if (time() - $maintenance_start >= 600) { return; } // Use any /user/maintenance.php file if (file_exists(YOURLS_USERDIR . '/maintenance.php')) { include_once YOURLS_USERDIR . '/maintenance.php'; die; } // https://www.youtube.com/watch?v=Xw-m4jEY-Ns $title = yourls__('Service temporarily unavailable'); $message = yourls__('Our service is currently undergoing scheduled maintenance.') . "</p>\n<p>" . yourls__('Things should not last very long, thank you for your patience and please excuse the inconvenience'); yourls_die($message, $title, 503); }