function searchwp_get_indexer_progress() { $progress = searchwp_get_option('progress'); echo !empty($progress) ? floatval($progress) : '100'; die; }
/** * Upgrade routines * * @since 1.0 */ private function upgrade() { global $wpdb, $searchwp; if (version_compare($this->last_version, '1.3.1', '<')) { // clean up misuse of cron schedule wp_clear_scheduled_hook('swp_cron_indexer'); } if (version_compare($this->last_version, '1.6.7', '<')) { // truncate logs table $prefix = $wpdb->prefix . SEARCHWP_DBPREFIX; $tableName = $prefix . 'log'; $wpdb->query("TRUNCATE TABLE {$tableName}"); } if (version_compare($this->last_version, '1.8', '<')) { // fix a possible issue with settings storage resulting in MySQL errors after update $settings = get_option(SEARCHWP_PREFIX . 'settings'); if (is_array($settings)) { // make sure additional array keys are present and defined foreach ($settings['engines'] as $engine_key => $engine_setting) { foreach ($settings['engines'][$engine_key] as $post_type => $post_type_settings) { if (is_array($settings['engines'][$engine_key][$post_type]) && isset($settings['engines'][$engine_key][$post_type]['options']) && !is_array($settings['engines'][$engine_key][$post_type]['options'])) { $settings['engines'][$engine_key][$post_type]['options'] = array('exclude' => false, 'attribute_to' => false, 'stem' => false); } } } } searchwp_update_option('settings', $settings); } // index cleanup and optimization if (version_compare($this->last_version, '1.9', '<')) { $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_terms` WHERE Key_name = 'termindex'", ARRAY_N); if (!empty($index_exists)) { $wpdb->query("ALTER TABLE {$wpdb->prefix}swp_terms DROP INDEX termindex;"); } $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_terms` WHERE Key_name = 'stemindex'", ARRAY_N); if (!empty($index_exists)) { $wpdb->query("ALTER TABLE {$wpdb->prefix}swp_terms DROP INDEX stemindex;"); } $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_terms` WHERE Key_name = 'id'", ARRAY_N); if (!empty($index_exists)) { $wpdb->query("ALTER TABLE {$wpdb->prefix}swp_terms DROP INDEX id;"); } $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_index` WHERE Key_name = 'id'", ARRAY_N); if (!empty($index_exists)) { $wpdb->query("ALTER TABLE {$wpdb->prefix}swp_index DROP INDEX id;"); } $wpdb->query("CREATE INDEX termindex ON {$wpdb->prefix}swp_terms(term(2));"); $wpdb->query("CREATE INDEX stemindex ON {$wpdb->prefix}swp_terms(stem(2));"); } // consolidate settings into one database record if (version_compare($this->last_version, '1.9.1', '<')) { $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_terms` WHERE Key_name = 'termindex'", ARRAY_N); if (empty($index_exists)) { $wpdb->query("CREATE INDEX termindex ON {$wpdb->prefix}swp_terms(term(2));"); } $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_terms` WHERE Key_name = 'stemindex'", ARRAY_N); if (empty($index_exists)) { $wpdb->query("CREATE INDEX stemindex ON {$wpdb->prefix}swp_terms(term(2));"); } $old_settings = searchwp_get_option('settings'); $engines = isset($old_settings['engines']) ? $old_settings['engines'] : array(); // clear out the old settings because we're using the same key searchwp_delete_option('settings'); // in with the new searchwp_generate_settings($engines); // delete the old options searchwp_delete_option('activated'); searchwp_delete_option('license_nag'); searchwp_delete_option('dismissed'); searchwp_delete_option('ignored_queries'); searchwp_delete_option('indexer_nag'); searchwp_delete_option('valid_db_environment'); searchwp_delete_option('running'); searchwp_delete_option('total'); searchwp_delete_option('remaining'); searchwp_delete_option('done'); searchwp_delete_option('in_process'); searchwp_delete_option('initial'); searchwp_delete_option('initial_notified'); searchwp_delete_option('purgeQueue'); searchwp_delete_option('processingPurgeQueue'); searchwp_delete_option('mysql_version_nag'); searchwp_delete_option('remote'); searchwp_delete_option('remote_meta'); searchwp_delete_option('paused'); searchwp_delete_option('nuke_on_delete'); searchwp_delete_option('indexnonce'); } if (version_compare($this->last_version, '1.9.2.2', '<')) { searchwp_add_option('progress', -1); } if (version_compare($this->last_version, '1.9.4', '<')) { // clean up a potential useless settings save $live_settings = searchwp_get_option('settings'); $update_settings_record = false; if (is_array($live_settings)) { foreach ($live_settings as $live_setting_key => $live_setting_value) { // none of our keys should be numeric (specifically going after a rogue 'running' setting that // may have been inadvertently set in 1.9.2, we just don't want it in there at all if (is_numeric($live_setting_key)) { unset($live_settings[$live_setting_key]); $update_settings_record = true; } // also update 'nuke_on_delete' to be a boolean if necessary if ('nuke_on_delete' === $live_setting_key) { $live_settings['nuke_on_delete'] = empty($live_setting_value) ? false : true; $update_settings_record = true; } } } if ($update_settings_record) { // save the cleaned up settings array searchwp_update_option('settings', $live_settings); $searchwp->settings = $live_settings; } } if (version_compare($this->last_version, '1.9.5', '<')) { // move indexer-specific settings to their own record as they're being constantly updated $live_settings = searchwp_get_option('settings'); $indexer_settings = array(); // whether the initial index has been built if (isset($live_settings['initial_index_built'])) { $indexer_settings['initial_index_built'] = (bool) $live_settings['initial_index_built']; unset($live_settings['initial_index_built']); } else { $indexer_settings['initial_index_built'] = false; } // all of the stats if (isset($live_settings['stats'])) { $indexer_settings['stats'] = $live_settings['stats']; unset($live_settings['stats']); } else { $indexer_settings['stats'] = array(); } // whether the indexer is running if (isset($live_settings['running'])) { $indexer_settings['running'] = (bool) $live_settings['running']; unset($live_settings['running']); } else { $indexer_settings['running'] = false; } // whether the indexer is paused (disabled) if (isset($live_settings['paused'])) { $indexer_settings['paused'] = (bool) $live_settings['paused']; unset($live_settings['paused']); } else { $indexer_settings['paused'] = false; } // whether the indexer is processing the purge queue if (isset($live_settings['processing_purge_queue'])) { $indexer_settings['processing_purge_queue'] = (bool) $live_settings['processing_purge_queue']; unset($live_settings['processing_purge_queue']); } else { $indexer_settings['processing_purge_queue'] = false; } // the purge queue will be moved to it's own option to avoid conflict if (isset($live_settings['purge_queue'])) { searchwp_add_option('purge_queue', $live_settings['purge_queue']); unset($live_settings['purge_queue']); } searchwp_update_option('settings', $live_settings); searchwp_add_option('indexer', $indexer_settings); } if (version_compare($this->last_version, '1.9.6', '<')) { // wake up the indexer if necessary $running = searchwp_get_setting('running'); if (empty($running)) { searchwp_set_setting('running', false); } } // make ignored queries for search stats per-user if (version_compare($this->last_version, '2.0.2', '<')) { $user_id = get_current_user_id(); if ($user_id) { $ignored_queries = searchwp_get_setting('ignored_queries'); update_user_meta($user_id, SEARCHWP_PREFIX . 'ignored_queries', $ignored_queries); } } // add 'busy' option if (version_compare($this->last_version, '2.1.5', '<')) { searchwp_add_option('busy', false); searchwp_add_option('doing_delta', false); } // force a wakeup if (version_compare($this->last_version, '2.2.1', '<')) { if (function_exists('searchwp_wake_up_indexer')) { searchwp_wake_up_indexer(); } } // add new 'waiting' flag, prep for possible new custom endpoint, clear out redundant post meta if (version_compare($this->last_version, '2.3', '<')) { searchwp_add_option('waiting', false); searchwp_set_setting('endpoint', ''); // now using last_index instead of indexed, we don't need separate records $wpdb->delete($wpdb->prefix . 'postmeta', array('meta_key' => '_' . SEARCHWP_PREFIX . 'indexed')); } if (version_compare($this->last_version, '2.4.5', '<')) { // implement our settings backup $live_settings = searchwp_get_option('settings'); $settings_backups = array(); $settings_backups[current_time('timestamp')] = $live_settings; searchwp_add_option('settings_backup', $settings_backups); // there was a bug triggered by a custom post type name of 'label' that caused issues // so we need to update all of the supplemental engine label keys to searchwp_engine_label // which will not trigger the issue because it is 21 characters in length and WordPress // requires post type names to be 20 characters or less if (isset($live_settings['engines'])) { foreach ($live_settings['engines'] as $live_settings_engine_key => $live_settings_engine_values) { if (isset($live_settings_engine_values['label'])) { $engine_label = $live_settings_engine_values['label']; unset($live_settings['engines'][$live_settings_engine_key]['label']); $live_settings['engines'][$live_settings_engine_key]['searchwp_engine_label'] = $engine_label; } } } searchwp_update_option('settings', $live_settings); } /** * The upgrade routine for 2.5.7 was designed to implement support for utf8mb4 as per WordPress 4.2, it even * used the same code to do so. Unfortunately the index key changes and charset changes can take a very (very) * long time depending on the power of the server and the size of the database tables. Unfortunately SearchWP's * tables are quite large, and the update routine took *way* too long on some test machines. While the update * was running, performance on the front end was erratic at best, primarily because the table updates caused * MySQL to utilize ~100% CPU, thus preventing other traffic from reaching the server. As a result, existing * installations of SearchWP will not be converted to utf8mb4, only fresh installations. The indexer and search * algorithm will actively strip out problematic characters (e.g. emoji) if the tables are not prepared for them. * if ( version_compare( $this->last_version, '2.5.7', '<' ) ) { require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); SWP()->indexer_pause(); // utf8mb4 index length limit is 191 @link https://make.wordpress.org/core/2015/04/02/the-utf8mb4-upgrade/ $wpdb->query( "ALTER TABLE {$wpdb->prefix}swp_cf DROP INDEX metakey, ADD INDEX metakey(metakey(191));" ); $wpdb->query( "ALTER TABLE {$wpdb->prefix}swp_log DROP INDEX queryindex, ADD INDEX queryindex(query(191));" ); $wpdb->query( "ALTER TABLE {$wpdb->prefix}swp_log DROP INDEX engineindex, ADD INDEX engineindex(engine(191));" ); // loop through tables and upgrade them to utf8mb4 $tables = array( $wpdb->prefix . 'swp_cf', $wpdb->prefix . 'swp_index', $wpdb->prefix . 'swp_log', $wpdb->prefix . 'swp_tax', $wpdb->prefix . 'swp_terms', ); $successful = true; foreach ( $tables as $table ) { // WordPress 4.2 added maybe_convert_table_to_utf8mb4() but // we don't necessarily have access to it (e.g. user is running <4.2) // but we also don't want to have to keep track of what WP version // is in play and have to continually compare that to whether this // upgrade routine has run so the function has been copied verbatim // for use here because utf8mb4 is fully backwards compatible so we're // going for the full upgrade by using a copy of that function $result = searchwp_maybe_convert_table_to_utf8mb4( $table ); if ( ( is_wp_error( $result ) || false === $result ) ) { // there was a problem $successful = false; } } if ( ! $successful ) { // there was a problem with the utf8mb4 upgrade but that doesn't necessarily // mean there is a show-stopping issue, just that the table is still utf8 // so log that the upgrade failed and indicate it in System Info searchwp_add_option( 'utf8mb4_upgrade_failed', true ); } SWP()->indexer_unpause(); } */ }
/** * Programmatically set engine configurations * * @since 2.4.5 * * @param $settings_json string JSON-encoded string of engine settings */ function import_settings($settings_json) { // back up existing settings before import $settings_backups = searchwp_get_option('settings_backup'); $settings_backups[current_time('timestamp')] = $this->settings; searchwp_update_option('settings_backup', $settings_backups); // parse the import $settings_to_import = json_decode((string) $settings_json); if (false === $settings_to_import) { wp_die(__('Invalid settings.', 'searchwp')); } $settings_to_import = $this->object_to_array($settings_to_import); $settings_to_import = $this->validate_settings(array('engines' => $settings_to_import)); $settings_to_import = $settings_to_import['engines']; foreach ($this->settings['engines'] as $engine_key => $engine_config) { if (array_key_exists($engine_key, $settings_to_import)) { // overwrite engine config $this->settings['engines'][$engine_key] = $settings_to_import[$engine_key]; unset($settings_to_import[$engine_key]); } } // if there are any imported engines left over, append them if (count($settings_to_import)) { $this->settings['engines'] = array_merge($this->settings['engines'], $settings_to_import); } // persist the settings update_option('searchwp_settings', $this->settings); }
<?php if ( ! defined( 'ABSPATH' ) ) { die(); } $parent = SWP(); $parent->define_keys(); $lazy_settings = apply_filters( 'searchwp_lazy_settings', false ); // progress of indexer $remainingPostsToIndex = searchwp_get_setting( 'remaining', 'stats' ); $progress = searchwp_get_option( 'progress' ); if ( ! $parent->is_using_alternate_indexer() && ( ! is_bool( $remainingPostsToIndex ) || ( is_numeric( $progress ) && $progress > 0 && $progress < 100 ) ) ) { $remainingPostsToIndex = absint( $remainingPostsToIndex ); ?> <div class="updated settings-error swp-in-progress<?php if ( 0 === $remainingPostsToIndex ) : ?> swp-in-progress-done<?php endif; ?>"> <div class="swp-progress-wrapper"> <p class="swp-label"><?php _e( 'Indexing is', 'searchwp' ); ?> <span><?php _e( 'almost', 'searchwp' ); ?></span> <?php _e( 'complete', 'searchwp' ); ?> <a class="swp-tooltip" href="#swp-tooltip-progress">?</a></p> <div class="swp-tooltip-content" id="swp-tooltip-progress"> <?php _e( 'This process is running in the background. You can leave this page and the index will continue to be built until completion.', 'searchwp' ); ?> </div> <div class="swp-progress-track"> <div class="swp-progress-bar"></div> </div> <p class="description"><?php echo sprintf( __( 'The indexer has been <strong>temporarily scaled back</strong> to reduce server load. This is monitored automatically. <a href="%s">More information »</a>', 'searchwp' ), 'http://searchwp.com/?p=11818' ); ?></p> </div>
function searchwp_check_for_stalled_indexer($threshold = 180) { $last_activity = searchwp_get_setting('last_activity', 'stats'); $running = searchwp_get_setting('running'); $doing_delta = searchwp_get_option('doing_delta'); $busy = searchwp_get_option('busy'); if (!is_null($last_activity) && false !== $last_activity) { if (current_time('timestamp') > $last_activity + absint($threshold) && ($running || $doing_delta || $busy)) { // stalled do_action('searchwp_log', '---------- Indexer has stalled, jumpstarting'); searchwp_wake_up_indexer(); } } else { // prior to version 2.2.2 the last activity was set to false once indexing was done // so if that timestamp is false but there is still a purge queue, we're going to // wake up the indexer by force $purge_queue = searchwp_get_option('purge_queue'); if (!empty($purge_queue)) { searchwp_wake_up_indexer(); } else { if (current_time('timestamp') > $last_activity + absint($threshold) && ($running || $doing_delta || $busy)) { // stalled do_action('searchwp_log', '---------- Indexer has stalled [alt], jumpstarting'); searchwp_wake_up_indexer(); } } } }
/** * Constructor * * @param string $hash The key used to validate instantiation * @since 1.0 */ public function __construct($hash = '') { global $searchwp; // make sure we've got a valid request to index if (get_transient('searchwp') !== $hash) { do_action('searchwp_log', 'Invalid index request ' . $hash); } else { do_action('searchwp_indexer_pre'); // init $this->common = $searchwp->common; $this->leinant_accents = apply_filters('searchwp_leinant_accents', $this->leinant_accents); // dynamically decide whether we're going to index Attachments based on whether Media is enabled for any search engine $index_attachments_from_settings = false; if (isset($searchwp->settings['engines']) && is_array($searchwp->settings['engines'])) { foreach ($searchwp->settings['engines'] as $engine) { if (isset($engine['attachment']) && isset($engine['attachment']['enabled']) && true == $engine['attachment']['enabled']) { $index_attachments_from_settings = true; break; } } } // allow dev to completely disable indexing of Attachments to save indexing time $this->indexAttachments = apply_filters('searchwp_index_attachments', $index_attachments_from_settings); if (!is_bool($this->indexAttachments)) { $this->indexAttachments = false; } // allow dev to customize post statuses are included $this->post_statuses = (array) apply_filters('searchwp_post_statuses', $this->post_statuses, null); foreach ($this->post_statuses as $post_status_key => $post_status_value) { $this->post_statuses[$post_status_key] = sanitize_key($post_status_value); } // allow dev to forcefully omit posts from being indexed $this->excludeFromIndex = apply_filters('searchwp_prevent_indexing', array()); if (!is_array($this->excludeFromIndex)) { $this->excludeFromIndex = array(); } $this->excludeFromIndex = array_map('absint', $this->excludeFromIndex); // allow dev to forcefully omit post types that would normally be indexed $this->postTypesToIndex = apply_filters('searchwp_indexed_post_types', $this->postTypesToIndex); // attachments cannot be included here, to omit attachments use the searchwp_index_attachments filter // so we have to check to make sure attachments were not included if (is_array($this->postTypesToIndex)) { foreach ($this->postTypesToIndex as $key => $postType) { if (strtolower($postType) == 'attachment') { unset($this->postTypesToIndex[$key]); } } } elseif (strtolower($this->postTypesToIndex) == 'attachment') { $this->postTypesToIndex = 'any'; } /** * Allow for some catch-up from the last request */ // auto-throttle based on load $waitTime = 1; if (apply_filters('searchwp_indexer_load_monitoring', true) && function_exists('sys_getloadavg')) { $load = sys_getloadavg(); $loadThreshold = abs(apply_filters('searchwp_load_maximum', 2)); // if the load has breached the threshold, scale the wait time if ($load[0] > $loadThreshold) { $waitTime = 4 * floor($load[0]); do_action('searchwp_log', 'Load threshold (' . $loadThreshold . ') has been breached! Current load: ' . $load[0] . '. Automatically injecting a wait time of ' . $waitTime); } } // allow developers to throttle the indexer $waitTime = absint(apply_filters('searchwp_indexer_throttle', $waitTime)); $iniMaxExecutionTime = absint(ini_get('max_execution_time')) - 5; if ($iniMaxExecutionTime < 10) { $iniMaxExecutionTime = 10; } if ($waitTime > $iniMaxExecutionTime) { do_action('searchwp_log', 'Requested throttle of ' . $waitTime . 's exceeds max execution time, forcing ' . $iniMaxExecutionTime . 's'); $waitTime = $iniMaxExecutionTime; } $memoryUse = size_format(memory_get_usage()); do_action('searchwp_log', 'Memory usage: ' . $memoryUse . ' - sleeping for ' . $waitTime . 's'); if (1 == $waitTime) { // wait time was not adjusted, so we're just going to usleep because 1 second is an eternity usleep(750000); } else { sleep($waitTime); } // see if the indexer has stalled $this->checkIfStalled(); // check to see if indexer is already running $running = searchwp_get_setting('running'); if (empty($running)) { do_action('searchwp_log', 'Indexer NOW RUNNING'); searchwp_set_setting('last_activity', current_time('timestamp'), 'stats'); searchwp_set_setting('running', true); do_action('searchwp_indexer_running'); $this->updateRunningCounts(); if ($this->findUnindexedPosts() !== false) { do_action('searchwp_indexer_posts'); $start_time = time(); // index this chunk of posts $this->index(); $index_time = time() - $start_time; // clean up do_action('searchwp_log', 'Indexing chunk complete: ' . $index_time . 's'); searchwp_set_setting('running', false); searchwp_set_setting('in_process', false, 'stats'); searchwp_update_option('busy', false); // reset the transient delete_transient('searchwp'); $hash = sprintf('%.22F', microtime(true)); // inspired by $doing_wp_cron set_transient('searchwp', $hash); do_action('searchwp_log', 'Request index (internal loopback) ' . trailingslashit(site_url()) . '?swpnonce=' . $hash); $timeout = abs(apply_filters('searchwp_timeout', 0.02)); // recursive trigger $args = array('body' => array('swpnonce' => $hash), 'blocking' => false, 'user-agent' => 'SearchWP', 'timeout' => $timeout, 'sslverify' => false); $args = apply_filters('searchwp_indexer_loopback_args', $args); do_action('searchwp_indexer_loopback', $args); wp_remote_post(trailingslashit(site_url()) . '?swpnonce=' . $hash, $args); } else { do_action('searchwp_log', 'Nothing left to index'); do_action('searchwp_index_up_to_date'); $initial = searchwp_get_setting('initial_index_built'); if (empty($initial)) { wp_clear_scheduled_hook('swp_indexer'); // clear out the pre-initial-index cron event do_action('searchwp_log', 'Initial index complete'); searchwp_set_setting('initial_index_built', true); do_action('searchwp_index_initial_complete'); } searchwp_set_setting('running', false); searchwp_set_setting('in_process', false, 'stats'); searchwp_update_option('busy', false); // delta updates may have been triggered, so now that the initial index has been built we can process them $purge_queue = searchwp_get_option('purge_queue'); if (!empty($purge_queue)) { $timeout = abs(apply_filters('searchwp_timeout', 0.02)); // recursive trigger $args = array('body' => array('swpdeltas' => 'swpdeltas'), 'blocking' => false, 'user-agent' => 'SearchWP', 'timeout' => $timeout, 'sslverify' => false); $args = apply_filters('searchwp_indexer_loopback_args', $args); do_action('searchwp_indexer_loopback', $args); wp_remote_post(trailingslashit(site_url()) . '?swpdeltas=swpdeltas', $args); } } // done indexing searchwp_set_setting('last_activity', false, 'stats'); } else { do_action('searchwp_log', 'SHORT CIRCUIT: Indexer already running'); } } }
/** * SearchWP by default does not index Media for the following reasons: * - minimal number of users enable it * - it bloats the index quite a bit * As a result searching for Media in the WordPress admin will not work properly unless it's enabled */ function media_note() { if (class_exists('WP_Screen')) { $current_screen = get_current_screen(); if ($current_screen instanceof WP_Screen) { if (isset($current_screen->id)) { if (is_search() && 'upload' == $current_screen->id) { // we're on the search results of the Media page in the WP admin, as a result of that the // search engine settings have been hijacked and limited to Media only, so we need to retrieve // the engine settings from the database (which are unaltered) because we need to check to see // whether Media may not be indexed at all $live_engine_settings = searchwp_get_option('settings'); $index_attachments_from_settings = false; if (isset($live_engine_settings['engines']) && is_array($live_engine_settings['engines'])) { foreach ($live_engine_settings['engines'] as $engine) { if (isset($engine['attachment']) && isset($engine['attachment']['enabled']) && true == $engine['attachment']['enabled']) { $index_attachments_from_settings = true; break; } } } $maybe_index_attachments = apply_filters('searchwp_index_attachments', $index_attachments_from_settings); $maybe_search_in_admin = apply_filters('searchwp_in_admin', false); // if Media isn't explicity indexed and searching in the admin is enabled and we're on // the search results screen for Media, tell the user that results might be incomplete if (!$maybe_index_attachments && $maybe_search_in_admin) { ?> <div class="updated"> <p><?php _e('<strong>Potentially incomplete results:</strong> Since you <em>do not have Media enabled</em> for any search engine, you should implement the <code>searchwp_index_attachments</code> hook to ensure Media is properly indexed by SearchWP. Once attachment indexing has been enabled, ensure there is no progress bar on the SearchWP Settings screen, confirming all Media is indexed.', 'searchwp'); ?> </p> </div> <?php } } } } } }
/** * Upgrade routines * * @since 1.0 */ private function upgrade() { global $wpdb, $searchwp; if (version_compare($this->last_version, '1.3.1', '<')) { // clean up misuse of cron schedule wp_clear_scheduled_hook('swp_cron_indexer'); } if (version_compare($this->last_version, '1.6.7', '<')) { // truncate logs table $prefix = $wpdb->prefix . SEARCHWP_DBPREFIX; $tableName = $prefix . 'log'; $wpdb->query("TRUNCATE TABLE {$tableName}"); } if (version_compare($this->last_version, '1.8', '<')) { // fix a possible issue with settings storage resulting in MySQL errors after update $settings = get_option(SEARCHWP_PREFIX . 'settings'); if (is_array($settings)) { // make sure additional array keys are present and defined foreach ($settings['engines'] as $engine_key => $engine_setting) { foreach ($settings['engines'][$engine_key] as $post_type => $post_type_settings) { if (is_array($settings['engines'][$engine_key][$post_type]) && !is_array($settings['engines'][$engine_key][$post_type]['options'])) { $settings['engines'][$engine_key][$post_type]['options'] = array('exclude' => false, 'attribute_to' => false, 'stem' => false); } } } } searchwp_update_option('settings', $settings); } // index cleanup and optimization if (version_compare($this->last_version, '1.9', '<')) { $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_terms` WHERE Key_name = 'termindex'", ARRAY_N); if (!empty($index_exists)) { $wpdb->query("ALTER TABLE {$wpdb->prefix}swp_terms DROP INDEX termindex;"); } $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_terms` WHERE Key_name = 'stemindex'", ARRAY_N); if (!empty($index_exists)) { $wpdb->query("ALTER TABLE {$wpdb->prefix}swp_terms DROP INDEX stemindex;"); } $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_terms` WHERE Key_name = 'id'", ARRAY_N); if (!empty($index_exists)) { $wpdb->query("ALTER TABLE {$wpdb->prefix}swp_terms DROP INDEX id;"); } $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_index` WHERE Key_name = 'id'", ARRAY_N); if (!empty($index_exists)) { $wpdb->query("ALTER TABLE {$wpdb->prefix}swp_index DROP INDEX id;"); } $wpdb->query("CREATE INDEX termindex ON {$wpdb->prefix}swp_terms(term(2));"); $wpdb->query("CREATE INDEX stemindex ON {$wpdb->prefix}swp_terms(stem(2));"); } // consolidate settings into one database record if (version_compare($this->last_version, '1.9.1', '<')) { $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_terms` WHERE Key_name = 'termindex'", ARRAY_N); if (empty($index_exists)) { $wpdb->query("CREATE INDEX termindex ON {$wpdb->prefix}swp_terms(term(2));"); } $index_exists = $wpdb->get_results("SHOW INDEX FROM `{$wpdb->prefix}swp_terms` WHERE Key_name = 'stemindex'", ARRAY_N); if (empty($index_exists)) { $wpdb->query("CREATE INDEX stemindex ON {$wpdb->prefix}swp_terms(term(2));"); } $old_settings = searchwp_get_option('settings'); $engines = isset($old_settings['engines']) ? $old_settings['engines'] : array(); // clear out the old settings because we're using the same key searchwp_delete_option('settings'); // in with the new searchwp_generate_settings($engines); // delete the old options searchwp_delete_option('activated'); searchwp_delete_option('license_nag'); searchwp_delete_option('dismissed'); searchwp_delete_option('ignored_queries'); searchwp_delete_option('indexer_nag'); searchwp_delete_option('valid_db_environment'); searchwp_delete_option('running'); searchwp_delete_option('total'); searchwp_delete_option('remaining'); searchwp_delete_option('done'); searchwp_delete_option('in_process'); searchwp_delete_option('initial'); searchwp_delete_option('initial_notified'); searchwp_delete_option('purgeQueue'); searchwp_delete_option('processingPurgeQueue'); searchwp_delete_option('mysql_version_nag'); searchwp_delete_option('remote'); searchwp_delete_option('remote_meta'); searchwp_delete_option('paused'); searchwp_delete_option('nuke_on_delete'); searchwp_delete_option('indexnonce'); } if (version_compare($this->last_version, '1.9.2.2', '<')) { searchwp_add_option('progress', -1); } if (version_compare($this->last_version, '1.9.4', '<')) { // clean up a potential useless settings save $live_settings = searchwp_get_option('settings'); $update_settings_record = false; if (is_array($live_settings)) { foreach ($live_settings as $live_setting_key => $live_setting_value) { // none of our keys should be numeric (specifically going after a rogue 'running' setting that // may have been inadvertently set in 1.9.2, we just don't want it in there at all if (is_numeric($live_setting_key)) { unset($live_settings[$live_setting_key]); $update_settings_record = true; } // also update 'nuke_on_delete' to be a boolean if necessary if ('nuke_on_delete' === $live_setting_key) { $live_settings['nuke_on_delete'] = empty($live_setting_value) ? false : true; $update_settings_record = true; } } } if ($update_settings_record) { // save the cleaned up settings array searchwp_update_option('settings', $live_settings); $searchwp->settings = $live_settings; } } if (version_compare($this->last_version, '1.9.5', '<')) { // move indexer-specific settings to their own record as they're being constantly updated $live_settings = searchwp_get_option('settings'); $indexer_settings = array(); // whether the initial index has been built if (isset($live_settings['initial_index_built'])) { $indexer_settings['initial_index_built'] = (bool) $live_settings['initial_index_built']; unset($live_settings['initial_index_built']); } else { $indexer_settings['initial_index_built'] = false; } // all of the stats if (isset($live_settings['stats'])) { $indexer_settings['stats'] = $live_settings['stats']; unset($live_settings['stats']); } else { $indexer_settings['stats'] = array(); } // whether the indexer is running if (isset($live_settings['running'])) { $indexer_settings['running'] = (bool) $live_settings['running']; unset($live_settings['running']); } else { $indexer_settings['running'] = false; } // whether the indexer is paused (disabled) if (isset($live_settings['paused'])) { $indexer_settings['paused'] = (bool) $live_settings['paused']; unset($live_settings['paused']); } else { $indexer_settings['paused'] = false; } // whether the indexer is processing the purge queue if (isset($live_settings['processing_purge_queue'])) { $indexer_settings['processing_purge_queue'] = (bool) $live_settings['processing_purge_queue']; unset($live_settings['processing_purge_queue']); } else { $indexer_settings['processing_purge_queue'] = false; } // the purge queue will be moved to it's own option to avoid conflict if (isset($live_settings['purge_queue'])) { searchwp_add_option('purge_queue', $live_settings['purge_queue']); unset($live_settings['purge_queue']); } searchwp_update_option('settings', $live_settings); searchwp_add_option('indexer', $indexer_settings); } if (version_compare($this->last_version, '1.9.6', '<')) { // wake up the indexer if necessary $running = searchwp_get_setting('running'); if (empty($running)) { searchwp_set_setting('running', false); } } // make ignored queries for search stats per-user if (version_compare($this->last_version, '2.0.2', '<')) { $user_id = get_current_user_id(); if ($user_id) { $ignored_queries = searchwp_get_setting('ignored_queries'); update_user_meta($user_id, SEARCHWP_PREFIX . 'ignored_queries', $ignored_queries); } } // add 'busy' option if (version_compare($this->last_version, '2.1.5', '<')) { searchwp_add_option('busy', false); searchwp_add_option('doing_delta', false); } // force a wakeup if (version_compare($this->last_version, '2.2.1', '<')) { if (function_exists('searchwp_wake_up_indexer')) { searchwp_wake_up_indexer(); } } }
/** * Callback for Toggle Indexer action */ function indexer_toggle() { if ( ! $this->is_valid_action_request( 'indexer_toggle' ) ) { return; } $paused = searchwp_get_option( 'paused' ); $paused = empty( $paused ) ? false : true; // we have to output custom messaging here because these functions fire too late to reflect a proper status if ( $paused ) { SWP()->indexer_unpause(); ?><style type="text/css">.swp-notices .updated { display:none !important; }</style><?php } else { SWP()->indexer_pause(); ?><div class="updated notice"><p><?php echo wp_kses_post( __( 'The SearchWP indexer is currently <strong>disabled</strong>', 'searchwp' ) ); ?></p></div><?php } }
/** * Callback for our implementation of add_options_page. Displays our options screen. * * @uses wpdb * @uses get_option to get saved SearchWP settings * @since 1.0 */ function optionsPage() { global $wpdb; // check to see if we need to display an extension settings page if (!empty($this->extensions) && isset($_GET['nonce']) && isset($_GET['extension'])) { if (wp_verify_nonce($_GET['nonce'], 'swp_extension_' . $_GET['extension'])) { foreach ($this->extensions as $extension => $attributes) { // find out which extension we're working with if (isset($attributes->slug) && $attributes->slug === $_GET['extension']) { if (method_exists($this->extensions[$extension], 'view')) { ?> <div class="wrap" id="searchwp-<?php echo $attributes->slug; ?> -wrapper"> <div id="icon-options-general" class="icon32"><br /></div> <div class="<?php echo $attributes->slug; ?> -container"> <h2><?php _e('SearchWP', 'searchwp'); ?> <?php echo $attributes->name; ?> </h2> <?php $this->extensions[$extension]->view(); ?> </div> <p class="searchwp-extension-back"> <a href="options-general.php?page=searchwp"><?php _e('Back to SearchWP Settings', 'searchwp'); ?> </a> </p> </div> <?php } break; } } } return; } // check to see if we should show advanced settings if (isset($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'swpadvanced') && current_user_can($this->settings_cap)) { $this->advancedSettings(); return; } // check to see if we should show posts that failed indexing if (isset($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'swperroneous') && current_user_can($this->settings_cap)) { $this->showErroneousPosts(); return; } // check to see if we should show license management if (isset($_REQUEST['activate']) && wp_verify_nonce($_REQUEST['activate'], 'swpactivate')) { $this->licenseSettings(); return; } $licenseNonceUrl = 'options-general.php?page=searchwp&activate=' . wp_create_nonce('swpactivate'); // progress of indexer $remainingPostsToIndex = searchwp_get_setting('remaining', 'stats'); $progress = searchwp_get_option('progress'); if (!is_bool($remainingPostsToIndex) || is_numeric($progress) && $progress > 0 && $progress < 100) { $remainingPostsToIndex = absint($remainingPostsToIndex); ?> <div class="updated settings-error swp-in-progress<?php if ($remainingPostsToIndex === 0) { ?> swp-in-progress-done<?php } ?> "> <div class="swp-progress-wrapper"> <p class="swp-label"><?php _e('Indexing is', 'searchwp'); ?> <span><?php _e('almost', 'searchwp'); ?> </span> <?php _e('complete', 'searchwp'); ?> <a class="swp-tooltip" href="#swp-tooltip-progress">?</a></p> <div class="swp-tooltip-content" id="swp-tooltip-progress"> <?php _e('This process is running in the background. You can leave this page and the index will continue to be built until completion.', 'searchwp'); ?> </div> <div class="swp-progress-track"> <div class="swp-progress-bar"></div> </div> </div> </div> <?php } ?> <?php if (isset($_REQUEST['inonce']) && wp_verify_nonce($_REQUEST['inonce'], 'swpindexernag') && current_user_can($this->settings_cap)) { $dismissed = searchwp_get_setting('dismissed'); if (is_array($dismissed)) { if (isset($dismissed['nags']) && is_array($dismissed['nags'])) { $dismissed['nags'][] = 'indexer'; } else { $dismissed['nags'] = array('indexer'); } } else { $dismissed = array('nags' => array('indexer')); } searchwp_set_setting('dismissed', $dismissed); } $nags = searchwp_get_setting('nags', 'dismissed'); $indexer_nag_dismissed = is_array($nags) && in_array('indexer', $nags); if (false && !$indexer_nag_dismissed) { ?> <div class="updated swp-progress-notes"> <p class="description"><?php echo sprintf(__('The SearchWP indexer runs as fast as it can without overloading your server; there are filters to customize it\'s aggressiveness. <a href="%s">Find out more »</a> <a class="swp-dismiss" href="options-general.php?page=searchwp&inonce=%s">Dismiss</a>', 'searchwp'), 'http://searchwp.com/?p=11818', wp_create_nonce("swpindexernag")); ?> </p> </div> <?php } ?> <div class="wrap"> <div id="icon-searchwp" class="icon32"> <img src="<?php echo trailingslashit($this->url); ?> assets/images/searchwp@2x.png" alt="SearchWP" width="21" height="32" /> </div> <h2> <?php echo $this->pluginName . ' ' . __('Settings'); ?> <?php if (false == $this->license) { ?> <a class="button button-primary swp-activate-license" href="<?php echo $licenseNonceUrl; ?> "><?php _e('Activate License', 'searchwp'); ?> </a> <?php } else { ?> <a class="button swp-manage-license" href="<?php echo $licenseNonceUrl; ?> "><?php _e('Manage License', 'searchwp'); ?> </a> <?php } ?> <?php if (!empty($this->extensions)) { ?> <div class="swp-menu-extensions swp-btn-group"> <a class="button swp-btn swp-dropdown-toggle" data-toggle="dropdown" href="#"> <?php _e('Extensions', 'searchwp'); ?> <span class="swp-caret"></span> </a> <ul class="swp-dropdown-menu"> <?php foreach ($this->extensions as $extension) { ?> <?php if (!empty($extension->public) && isset($extension->slug) && isset($extension->name)) { ?> <?php $nonce = wp_create_nonce('swp_extension_' . $extension->slug); ?> <li><a href="options-general.php?page=searchwp&extension=<?php echo $extension->slug; ?> &nonce=<?php echo $nonce; ?> "><?php echo $extension->name; ?> </a></li> <?php } ?> <?php } ?> </ul> </div> <?php } ?> </h2> <?php /** * LICENSE CHECK */ if ($this->license !== false && $this->license !== '' && $this->status !== 'valid') { ?> <div id="setting-error-settings_updated" class="error settings-error"> <p><?php _e('A license key was found, but it is <strong>inactive</strong>. Automatic updates <em>will not be available</em> until your license is activated.', 'searchwp'); ?> <a href="<?php echo $licenseNonceUrl; ?> "><?php _e('Manage License', 'searchwp'); ?> </a></p> </div> <?php } ?> <?php $notices = searchwp_get_setting('notices'); $initial_notified = is_array($notices) && in_array('initial', $notices) ? true : false; if (searchwp_get_setting('initial_index_built') && !$initial_notified) { ?> <div class="updated"> <p><?php _e('Initial index has been built', 'searchwp'); ?> </p> </div> <?php if (is_array($notices)) { $notices[] = 'initial'; } else { $notices = array('initial'); } searchwp_set_setting('notices', $notices); ?> <?php } ?> <?php if (isset($_REQUEST['nnonce']) && wp_verify_nonce($_REQUEST['nnonce'], 'swplicensenag') && current_user_can($this->settings_cap)) { $dismissed = searchwp_get_setting('dismissed'); if (is_array($dismissed)) { if (isset($dismissed['nags']) && is_array($dismissed['nags'])) { $dismissed['nags'][] = 'license'; } else { $dismissed['nags'] = array('license'); } } else { $dismissed = array('nags' => array('license')); } searchwp_set_setting('dismissed', $dismissed); } $nags = searchwp_get_setting('nags', 'dismissed'); $license_nag_dismissed = is_array($nags) && in_array('license', $nags); if ($initial_notified && $this->license == false && !$license_nag_dismissed && apply_filters('searchwp_initial_license_nag', true)) { ?> <div id="setting-error-settings_updated" class="updated settings-error swp-license-nag"> <p><?php _e('In order to receive updates and support, you must have an active license.', 'searchwp'); ?> <a href="<?php echo $licenseNonceUrl; ?> "><?php _e('Manage License', 'searchwp'); ?> </a> <a href="<?php echo EDD_SEARCHWP_STORE_URL; ?> "><?php _e('Purchase License', 'searchwp'); ?> </a> <a href="options-general.php?page=searchwp&nnonce=<?php echo wp_create_nonce('swplicensenag'); ?> "><?php _e('Dismiss', 'searchwp'); ?> </a></p> </div> <?php } ?> <?php /** * MYSQL CHECK */ if (isset($_REQUEST['vnonce']) && wp_verify_nonce($_REQUEST['vnonce'], 'swpmysqlnag') && current_user_can($this->settings_cap)) { $dismissed = searchwp_get_setting('dismissed'); if (is_array($dismissed)) { if (isset($dismissed['nags']) && is_array($dismissed['nags'])) { $dismissed['nags'][] = 'mysql_version'; } else { $dismissed['nags'] = array('mysql_version'); } } else { $dismissed = array('nags' => array('mysql_version')); } searchwp_set_setting('dismissed', $dismissed); } $nags = searchwp_get_setting('nags', 'dismissed'); $mysql_version_nag_dismissed = is_array($nags) && in_array('mysql_version', $nags); if (!version_compare('5.1', $wpdb->db_version(), '<') && !$mysql_version_nag_dismissed) { ?> <div class="updated settings-error"> <p><?php echo sprintf(__('Your server is running MySQL version %1$s which may prevent search results from appearing due to <a href="http://bugs.mysql.com/bug.php?id=41156">bug 41156</a>. Please update MySQL to a more recent version (at least 5.1).', 'searchwp'), $wpdb->db_version()); ?> <a href="options-general.php?page=searchwp&vnonce=<?php echo wp_create_nonce('swpmysqlnag'); ?> "><?php _e('Dismiss', 'searchwp'); ?> </a></p> </div> <?php } include dirname(__FILE__) . '/admin/settings.php'; if (!$this->indexing && isset($_GET['page']) && $_GET['page'] == 'searchwp' && false == searchwp_get_setting('running')) { $this->indexing = true; $this->triggerIndex(); } do_action('searchwp_log', 'Shutting down after displaying settings screen'); $this->shutdown(); }
function output() { global $wpdb; $theme_data = wp_get_theme(); /** @noinspection PhpUndefinedFieldInspection */ $theme = $theme_data->Name . ' ' . $theme_data->Version; // Try to identifty the hosting provider $host = false; if (defined('WPE_APIKEY')) { $host = 'WP Engine'; } elseif (defined('PAGELYBIN')) { $host = 'Pagely'; } $utf8mb4_failed_upgrade = false; if (searchwp_get_option('utf8mb4_upgrade_failed')) { $utf8mb4_failed_upgrade = true; } ?> <form action="" method="post" dir="ltr"> <textarea readonly="readonly" onclick="this.focus();this.select()" class="searchwp-system-info-textarea" name="searchwp-sysinfo" title="<?php _e('To copy the system info, click below then press CTRL + C (PC) or CMD + C (Mac).', 'searchwp'); ?> "> ### Begin System Info ### ## Please include this information when posting support requests ## <?php if ($utf8mb4_failed_upgrade) { ?> Failed utf8mb4 upgrade: Yes <?php } ?> Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n"; ?> SITE_URL: <?php echo esc_url(site_url()) . "\n"; ?> HOME_URL: <?php echo esc_url(home_url()) . "\n"; ?> SearchWP Version: <?php echo esc_textarea($this->searchwp->version) . "\n"; ?> WordPress Version: <?php echo esc_textarea(get_bloginfo('version')) . "\n"; ?> Permalink Structure: <?php echo esc_textarea(get_option('permalink_structure')) . "\n"; ?> Active Theme: <?php echo esc_textarea($theme) . "\n"; if ($host) { ?> Host: <?php echo esc_textarea($host) . "\n"; } ?> Registered Post Stati: <?php echo esc_textarea(implode(', ', get_post_stati())) . "\n\n"; ?> PHP Version: <?php echo esc_textarea(PHP_VERSION) . "\n"; ?> MySQL Version: <?php echo esc_textarea($wpdb->db_version()) . "\n"; ?> Web Server Info: <?php echo esc_textarea($_SERVER['SERVER_SOFTWARE']) . "\n"; ?> WordPress Memory Limit: <?php echo esc_textarea(WP_MEMORY_LIMIT); echo "\n"; ?> PHP Safe Mode: <?php echo ini_get('safe_mode') ? 'Yes' : 'No'; echo "\n"; ?> PHP Memory Limit: <?php echo esc_textarea(ini_get('memory_limit')) . "\n"; ?> PHP Upload Max Size: <?php echo esc_textarea(ini_get('upload_max_filesize')) . "\n"; ?> PHP Post Max Size: <?php echo esc_textarea(ini_get('post_max_size')) . "\n"; ?> PHP Upload Max Filesize: <?php echo esc_textarea(ini_get('upload_max_filesize')) . "\n"; ?> PHP Time Limit: <?php echo esc_textarea(ini_get('max_execution_time')) . "\n"; ?> PHP Max Input Vars: <?php echo esc_textarea(ini_get('max_input_vars')) . "\n"; ?> PHP Arg Separator: <?php echo esc_textarea(ini_get('arg_separator.output')) . "\n"; ?> PHP Allow URL File Open: <?php echo ini_get('allow_url_fopen') ? 'Yes' : 'No'; echo "\n"; ?> WP_DEBUG: <?php echo defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n"; ?> WP Table Prefix: <?php echo 'Length: ' . strlen($wpdb->prefix); echo ' Status:'; if (strlen($wpdb->prefix) > 16) { echo ' ERROR: Too Long'; } else { echo ' Acceptable'; } echo "\n"; ?> Show On Front: <?php echo esc_textarea(get_option('show_on_front')) . "\n"; ?> Page On Front: <?php $id = get_option('page_on_front'); echo esc_textarea(get_the_title($id) . ' (#' . $id . ')') . "\n"; ?> Page For Posts: <?php $id = get_option('page_for_posts'); echo esc_textarea(get_the_title($id) . ' (#' . $id . ')') . "\n"; ?> <?php $request['cmd'] = '_notify-validate'; $params = array('sslverify' => false, 'timeout' => 60, 'user-agent' => 'SearchWP', 'body' => $request); $response = wp_remote_post('https://searchwp.com/', $params); if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { $WP_REMOTE_POST = 'wp_remote_post() works' . "\n"; } else { $WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n"; } ?> WP Remote Post: <?php echo esc_textarea($WP_REMOTE_POST); ?> Session: <?php echo isset($_SESSION) ? 'Enabled' : 'Disabled'; echo "\n"; ?> Session Name: <?php echo esc_html(ini_get('session.name')); echo "\n"; ?> Cookie Path: <?php echo esc_html(ini_get('session.cookie_path')); echo "\n"; ?> Save Path: <?php echo esc_html(ini_get('session.save_path')); echo "\n"; ?> Use Cookies: <?php echo ini_get('session.use_cookies') ? 'On' : 'Off'; echo "\n"; ?> Use Only Cookies: <?php echo ini_get('session.use_only_cookies') ? 'On' : 'Off'; echo "\n"; ?> DISPLAY ERRORS: <?php echo ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A'; echo "\n"; ?> FSOCKOPEN: <?php echo function_exists('fsockopen') ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; echo "\n"; ?> cURL: <?php echo function_exists('curl_init') ? 'Your server supports cURL.' : 'Your server does not support cURL.'; echo "\n"; ?> SOAP Client: <?php echo class_exists('SoapClient') ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.'; echo "\n"; ?> SUHOSIN: <?php echo extension_loaded('suhosin') ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; echo "\n"; ?> TEMPLATES: search.php <?php echo file_exists(get_stylesheet_directory() . '/search.php') ? 'Yes' : 'No'; ?> POTENTIAL TEMPLATE CONFLICTS: <?php $conflicts = new SearchWP_Conflicts(); if (!empty($conflicts->search_template_conflicts)) { foreach ($conflicts->search_template_conflicts as $line_number => $the_conflicts) { echo esc_textarea('Line ' . absint($line_number) . ': ' . implode(', ', $the_conflicts)) . "\n"; } } else { echo "NONE\n"; } ?> POTENTIAL FILTER CONFLICTS <?php if (!empty($conflicts->filter_conflicts)) { foreach ($conflicts->filter_conflicts as $filter_name => $potential_conflict) { foreach ($potential_conflict as $conflict) { echo esc_textarea($filter_name . ' => ' . $conflict) . "\n"; } } } else { echo "NONE\n"; } ?> ACTIVE PLUGINS: <?php $plugins = get_plugins(); $active_plugins = get_option('active_plugins', array()); foreach ($plugins as $plugin_path => $plugin) { // if the plugin isn't active, don't show it. if (!in_array($plugin_path, $active_plugins)) { continue; } echo esc_textarea($plugin['Name'] . ': ' . $plugin['Version']) . "\n"; } if (is_multisite()) { ?> NETWORK ACTIVE PLUGINS: <?php $plugins = wp_get_active_network_plugins(); $active_plugins = get_site_option('active_sitewide_plugins', array()); foreach ($plugins as $plugin_path) { $plugin_base = plugin_basename($plugin_path); // If the plugin isn't active, don't show it. if (!array_key_exists($plugin_base, $active_plugins)) { continue; } $plugin = get_plugin_data($plugin_path); echo esc_textarea($plugin['Name'] . ' :' . $plugin['Version']) . "\n"; } } ?> STATS: <?php if (isset($this->searchwp->settings['stats'])) { if (!empty($this->searchwp->settings['stats']['last_activity'])) { $this->searchwp->settings['stats']['last_activity'] = human_time_diff($this->searchwp->settings['stats']['last_activity'], current_time('timestamp')) . ' ago'; } echo esc_textarea(print_r($this->searchwp->settings['stats'], true)); echo "\n"; } else { echo esc_textarea(print_r(get_option(SEARCHWP_PREFIX . 'settings'), true)); echo "\n"; } $indexer = new SearchWPIndexer(); $row_count = $indexer->get_main_table_row_count(); echo 'Main table row count: '; echo absint($row_count); echo "\n"; if (isset($this->searchwp->settings['running'])) { echo 'Running: '; echo !empty($this->searchwp->settings['running']) ? 'Yes' : 'No'; echo "\n"; } if (isset($this->searchwp->settings['busy'])) { echo 'Busy: '; echo !empty($this->searchwp->settings['busy']) ? 'Yes' : 'No'; echo "\n"; } if (isset($this->searchwp->settings['doing_delta'])) { echo 'Doing Delta: '; echo !empty($this->searchwp->settings['running']) ? 'Yes' : 'No'; echo "\n"; } if (isset($this->searchwp->settings['processing_purge_queue'])) { echo 'Processing Purge Queue: '; echo !empty($this->searchwp->settings['processing_purge_queue']) ? 'Yes' : 'No'; echo "\n"; } if (isset($this->searchwp->settings['paused'])) { echo 'Paused: '; echo !empty($this->searchwp->settings['paused']) ? 'Yes' : 'No'; echo "\n"; } ?> SETTINGS: <?php if (isset($this->searchwp->settings['engines'])) { echo esc_textarea(print_r($this->searchwp->settings['engines'], true)); } ?> PURGE QUEUE: <?php echo isset($this->searchwp->settings['purgeQueue']) ? esc_textarea(print_r($this->searchwp->settings['purgeQueue'], true)) : '[Empty]'; ?> ### End System Info ###</textarea></form> <?php }