/** * Get any reports / warnings / messages from the WPSearch server. * @return mized A string if a message was found, FALSE if not */ public static function getWPSearchMessage() { //self::setOption(WPSearch_Core::KEY_LAST_MESSAGE_DATE, time() - 60*60*13); $date = self::getOption(WPSearch_Core::KEY_LAST_MESSAGE_DATE); if ($date !== FALSE && $date + 12 * 60 * 60 > time()) { return self::getOption(WPSearch_Core::KEY_LAST_MESSAGE); } $driver = WPSearch_Config::get('driver'); $count = WPSearch_Model::getPublishedPostCount(); $url = "http://report.wpsearch2.com/messages?d={$driver}&c={$count}"; $content = file_get_contents($url); self::setOption(WPSearch_Core::KEY_LAST_MESSAGE, $content); self::setOption(WPSearch_Core::KEY_LAST_MESSAGE_DATE, time()); if (strlen($content) == 0 || $content == "0") { return FALSE; } return $content; }
/** * Run any checks the driver has to do in order to run properly. * @return array An array of error messages if errors exist. An empty array * if no errors exist */ public function runTests() { $errors = array(); if (!file_exists($this->_indexDirectory)) { $errors[] = "The index directory, {$this->_indexDirectory}, does not exist"; } if (!file_exists($this->_tmpPath)) { $errors[] = "The tmp directory, {$this->_tmpPath}, does not exist"; } if (!file_exists($this->_indexDirectory)) { $errors[] = "The index directory, {$this->_indexDirectory}, does not exist"; } if (!is_writable($this->_indexDirectory)) { $errors[] = "The index directory, {$this->_indexDirectory}, is not writable. You or your system admin can easily fix this."; } if (!is_writable($this->_tmpPath)) { $errors[] = "The tmp directory, {$this->_tmpPath}, is not writable. You or your system admin can easily fix this."; } $fast_cgi_error = "FastCGI is enabled on this server. You may have to extend" . " your FastCGI timout for WPSearch to index properly."; if (!function_exists('mb_strtolower')) { $errors[] = "Multibyte string support is not enabled in this instance of PHP. " . "The index build process needs this in order to add data " . "of different encodings to the index. Ask your administrator to compile PHP with --enable-mbstring."; } if (strstr(php_sapi_name(), 'fcgi')) { $errors[] = $fast_cgi_error; } elseif (function_exists('apache_get_modules') && in_array('mod_fastcgi', apache_get_modules())) { $errors[] = $fast_cgi_error; } # Safe mode is bad because you cannot set an infinite time limit, which # we need to do to build an index. if (ini_get('safe_mode')) { $errors[] = "This WPSearch driver cannot run in safe mode (" . __CLASS__ . ")"; } $inilimit = ini_get('memory_limit'); if ($inilimit && strstr($inilimit, 'M') !== FALSE) { $limit = intval(str_replace('M', '', $inilimit)); $post_count = WPSearch_Model::getPublishedPostCount(); $needed = round($post_count / 1000 * 2 + 10, 0); if ($post_count > 5000 || $limit < $needed) { $errors[] = "This Wordpress installation currently has {$post_count} published posts. " . "An index build will need approximately {$needed}M of memory to complete. " . "While WPSearch will try to allocate that space, it may not be able to go " . "above your configured default of {$inilimit}. If builds are unsuccessful, " . "please look into <a href=\"#\">WPSearch Premium</a> which can handle up to 1 million posts " . "with ease."; } } return $errors; }