/** * Handles GET requests for the import page. */ public function get_import() { // First check for troublesome plugins $bad_features = array( 'ping', 'pingback', 'spamcheck', ); $troublemakers = array(); $plugins = Plugins::list_active(); foreach( $plugins as $plugin ) { $info = Plugins::load_info( $plugin ); $provides = array(); if( isset($info->provides ) ) { foreach( $info->provides->feature as $feature ) { $provides[] = $feature; } } $has_bad = array_intersect( $bad_features, $provides ); if( count( $has_bad ) ) { $troublemakers[] = $info->name; } } if( count( $troublemakers ) ) { $troublemakers = implode( ', ', $troublemakers ); $msg = _t( 'Plugins that conflict with importing are active. To prevent undesirable consequences, please de-activate the following plugins until the import is finished: ' ) . '<br>'; $msg .= $troublemakers; $this->theme->conflicting_plugins = $msg; Session::error( $msg ); } // Now get on with creating the page $importer = isset( $_POST['importer'] ) ? $_POST['importer'] : ''; $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : '1'; $step = isset( $_POST['step'] ) ? $_POST['step'] : '1'; $this->theme->enctype = Plugins::filter( 'import_form_enctype', 'application/x-www-form-urlencoded', $importer, $stage, $step ); // filter to get registered importers $importers = Plugins::filter( 'import_names', array() ); // fitler to get the output of the current importer, if one is running if ( $importer != '' ) { $output = Plugins::filter( 'import_stage', '', $importer, $stage, $step ); } else { $output = ''; } $this->theme->importer = $importer; $this->theme->stage = $stage; $this->theme->step = $step; $this->theme->importers = $importers; $this->theme->output = $output; $this->display( 'import' ); }
} // Send the Content-Type HTTP header. // @todo Find a better place to put this. header('Content-Type: text/html;charset=utf-8'); /** * Include all the active plugins. * By loading them here they'll have global scope. * * We loop through them twice so we can cache all plugin classes on the first load() call. * This gives about 60% improvement. */ foreach (Plugins::list_active() as $file) { include_once $file; } // Call the plugin's load procedure. foreach (Plugins::list_active() as $file) { Plugins::load($file); } // All plugins loaded, tell the plugins. Plugins::act('plugins_loaded'); // Start the session. Session::init(); // Replace the $_COOKIE superglobal with an object representation SuperGlobal::process_c(); // Initiating request handling, tell the plugins. Plugins::act('init'); // Parse and handle the request. Controller::parse_request(); // Run the cron jobs asyncronously. CronTab::run_cron(true); // Dispatch the request (action) to the matched handler.
private function upgrade_db_post_4291() { // get all plugins so the legacy ones can be deactivated. $active_plugins = Plugins::list_active(); $all_plugins = Installhandler::get_plugins(); $legacy_plugins = array(); foreach ($all_plugins as $plugin) { if (!isset($plugin['info'])) { $key = array_search($plugin['file'], $active_plugins); $legacy_plugins[$key] = $plugin['file']; } } $valid_plugins = array_diff_key(Options::get('active_plugins'), $legacy_plugins); // valid_plugins contains only working plugins, but the classnames are missing. The following was previously upgrade_db_post_3484() $new_plugins = array(); if (is_array($valid_plugins)) { foreach ($valid_plugins as $filename) { if (!file_exists($filename)) { // try adding base path to stored path $filename = HABARI_PATH . $filename; } if (file_exists($filename)) { // it is now safe to do this since plugins with info() functions are not in $valid_plugins require_once $filename; $class = Plugins::class_from_filename($filename); $short_file = substr($filename, strlen(HABARI_PATH)); if ($class) { $new_plugins[$class] = $short_file; } } } } // replace option with only the usuable plugins Options::set('active_plugins', $new_plugins); }