/** * Get a open and ready instance of the logging class. * @param string $logDirectory Optionally specify a directory to log to * @return WPSearch_Log */ public static function instance($logDirectory = FALSE) { # Didn't set a priority? Well, I suppose you'll see everything $priority = WPSearch_Config::get('log.level'); # Directory doesn't exist? Created that directory (and all # directories on the way) if ($logDirectory === FALSE) { $logDirectory = WPSearch_Config::get('log.directory'); } # Do we already have an instance of a logger for this directory? # Grab it! If not, whip up a new one. if (in_array($logDirectory, self::$instances)) { return self::$instances[$logDirectory]; } self::$instances[$logDirectory] = new self($logDirectory, $priority); # Return the logger return self::$instances[$logDirectory]; }
/** * The Search library's constructor * @param string $cdriver Allow specification of the driver to be used. If * this is omitted, the driver will be pulled from the config. */ public function __construct($cdriver = FALSE) { if (!$cdriver) { $cdriver = WPSearch_Config::get('driver'); } $driver = ucfirst(strtolower($cdriver)); if (WPSearch_Config::get("driver-configs.{$cdriver}") === FALSE) { throw new WPSearch_Exception("Driver '{$cdriver}' chosen, but there is no config available."); } $driver_file = dirname(__FILE__) . '/Drivers/Search/' . $driver . '.php'; if (!file_exists($driver_file)) { WPSearch_Log::add('fatal', "Cannot find search driver named '{$driver}'"); throw new WPSearch_Exception("Driver '{$driver}' does not exist"); } require_once $driver_file; $driver = 'WPSearch_Drivers_Search_' . $driver; if (!class_exists($driver)) { WPSearch_Log::add('fatal', "Driver file was loaded, but class '{$driver}' wasn't found"); throw new WPSearch_Exception("Class '{$driver}' does not exist"); } $this->_driver = new $driver(); WPSearch_Log::add('info', "Driver '{$driver}' successfully loaded"); }
/** * 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; }
/** * Return the instance of this class * @return WPSearch_Config */ private static function _getInstance() { if (self::$_instance === NULL) { self::$_instance = new self(); } return self::$_instance; }
/** * Set the last time the index was built and store it in a file * @param int $time UNIX timestamp */ private function _setRebuildTime($time = FALSE) { if ($time === FALSE) { $time = time(); } $file = WPSearch_Config::get('driver-configs.phplucene.tmp-path') . 'rebuild-time.nfo'; $success = @file_put_contents($file, $time); if (!$success) { WPSearch_Log::add('error', "Could not write to temp file: {$file}"); } }
?> <div class="about"> <?php echo $about; ?> </div> </div> <div class="right_column"> <a href="http://oconf.org" target="_blank"> <img class="oconf_logo" src="<?php echo WPSearch_Utility::getImageBaseURL(); ?> oconf.jpg" alt="" /> </a> <?php if (WPSearch_Config::get('driver') == 'phplucene') { ?> <?php if ($message = WPSearch_Utility::getWPSearchMessage()) { echo $message; } ?> <h3>Your Search Can Be Even Better</h3> <p> <strong> You're using WPSearch Free, the second-best Wordpress search plugin of all time! </strong> </p> <p> When your site grows to the point where WPSearch Free starts to