require_once '../approot.inc.php'; require_once APPROOT . '/application/utils.inc.php'; require_once APPROOT . '/core/config.class.inc.php'; require_once APPROOT . '/setup/setuppage.class.inc.php'; require_once APPROOT . '/setup/wizardcontroller.class.inc.php'; require_once APPROOT . '/setup/wizardsteps.class.inc.php'; clearstatcache(); // Make sure we know what we are doing ! // Set a long (at least 4 minutes) execution time for the setup to avoid timeouts during this phase ini_set('max_execution_time', max(240, ini_get('max_execution_time'))); // While running the setup it is desirable to see any error that may happen ini_set('display_errors', true); ini_set('display_startup_errors', true); ///////////////////////////////////////////////////////////////////// // Fake functions to protect the first run of the installer // in case the PHP JSON module is not installed... if (!function_exists('json_encode')) { function json_encode($value, $options = null) { return '[]'; } } if (!function_exists('json_decode')) { function json_decode($json, $assoc = null) { return array(); } } ///////////////////////////////////////////////////////////////////// $oWizard = new WizardController('WizStepWelcome'); $oWizard->Run();
function upgrade_table_statistics_in_v3() { global $wpdb, $table_prefix; //check for column status $result = $wpdb->get_results("SHOW COLUMNS FROM {$table_prefix}sph_stats"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } foreach ($result as $column) { if ('status' == $column->Field) { $options['check_stats_table_column_status'] = 'true'; $this->config->update_admin_options($options); } } if ('true' == $options['check_stats_table_column_status']) { //set up sphinx for stats in widgest or not $wizard = new WizardController($this->config); $config_file_name = $this->config->get_option('sphinx_conf'); $config_file_content = $wizard->_generate_config_file_content(); $wizard->_save_config($config_file_name, $config_file_content); $sphinxService = new SphinxService($this->config); $ret = $sphinxService->reindex('stats'); } }
/** * Draw admin page * */ function print_admin_page() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $options = $this->config->get_admin_options(); $wizard = new WizardController($this->config); if (!empty($_POST['start_wizard']) || empty($options['sphinx_conf']) && 'false' == $options['wizard_done']) { $this->view->menu = 'wizard'; $wizard->start_action(); } if (!empty($_GET['menu'])) { switch ($_GET['menu']) { case 'terms_editor': $terms_editor = new TermsEditorController($this->config); $terms_editor->index_action(); $this->view->menu = 'terms_editor'; //return; break; case 'stats': $stats = new StatsController($this->config); $stats->index_action(); $this->view->menu = 'stats'; //return; break; case 'search_settings': $this->view->menu = 'search_settings'; break; } } $sphinxService = new SphinxService($this->config); $res = false; $error_message = $success_message = ''; if (!empty($_POST['reindex_sphinx'])) { $res = $sphinxService->reindex(); $success_message = 'Sphinx successfully reindexed.'; } else { if (!empty($_POST['start_sphinx'])) { $res = $sphinxService->start(); $success_message = 'Sphinx successfully started.'; } elseif (!empty($_POST['stop_sphinx'])) { $res = $sphinxService->stop(); $success_message = 'Sphinx successfully stopped.'; } elseif (isset($_POST['update_SphinxSearchSettings'])) { $this->update_options(); $success_message = 'Settings updated.'; } } if (is_array($res)) { $error_message = $res['err']; } $this->view->assign('index_modify_time', $sphinxService->get_index_modify_time()); if (!empty($error_message)) { $this->view->assign('error_message', $error_message); } if (!empty($success_message)) { $this->view->assign('success_message', $success_message); } $devOptions = $this->config->get_admin_options(); //update options $this->view->assign('devOptions', $devOptions); //load admin panel template $this->view->assign('header', 'Sphinx Search for Wordpress'); $this->view->assign('is_sphinx_path_secure', $this->_isSphinxPathSecure()); if ('true' != $devOptions['check_stats_table_column_status']) { global $table_prefix; $this->view->assign('error_message', "{$table_prefix}sph_stats table required an update.<br>\n Please run the following command in MySQL client to update the table: <br>\n alter table {$table_prefix}sph_stats add `status` tinyint(1) NOT NULL DEFAULT '0';\n <br><br>\n This update will allow to use Sphinx Search for Top/Related and Latest search terms widgets!"); } $this->view->render('admin/layout.phtml'); }
function generate_config_content($template_content) { global $wpdb, $table_prefix; $sql_sock = ''; if ('' != trim(ini_get('mysql.default_socket'))) { $sql_sock = 'sql_sock = ' . ini_get('mysql.default_socket'); } $wizard = new WizardController($this->config); /** * We have to rewrite following variables: * {sql_sock} to database socket * * {source} to Sphinx Index name * {sphinx_path} to Sphinx Server root dir * {searchd_port} to Sphinx search daemon port * {wp_posts} to Wordpress posts table * {wp_comments} to Wordpress comments table * {path_to_php} path to php executable file * {path_to_wp_config_php} path to wp-config.php - requiered by shebung syntax */ $search = array('{sql_sock}' => $sql_sock, '{prefix}' => $this->config->admin_options['sphinx_index'], '{sphinx_path}' => $this->config->admin_options['sphinx_path'], '{searchd_port}' => $this->config->admin_options['sphinx_port'], '{wp_posts}' => $wpdb->posts, '{wp_comments}' => $wpdb->comments, '{wp_term_relationships}' => $wpdb->term_relationships, '{wp_term_taxonomy}' => $wpdb->term_taxonomy, '{wp_terms}' => $wpdb->terms, '{path_to_php}' => $wizard->detect_program('php'), '{path_to_wp_config_php}' => dirname(dirname(dirname($this->plugin_sphinx_dir))), '{max_matches}' => $this->config->admin_options['sphinx_max_matches'], '{db_host}' => DB_HOST, '{db_user}' => DB_USER, '{db_pass}' => DB_PASSWORD, '{db_name}' => DB_NAME, '{table_prefix}' => $table_prefix); $rewrited_content = str_replace(array_keys($search), $search, $template_content); return $rewrited_content; }