-class SphinxSearch extends SearchEngine {
- private $sphinx;
- private $connected;
-
- function __construct($target, $table) {
- $fp = @fsockopen(common_config('sphinx', 'server'), common_config('sphinx', 'port'));
- if (!$fp) {
- $this->connected = false;
- return;
+class MySQLSearch extends SearchEngine
+{
+ function query($q)
+ {
+ if ('profile' === $this->table) {
+ $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
+ 'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
+ if (strtolower($q) != $q) {
+ $this->target->whereAdd('MATCH(nickname, fullname, location, bio, homepage) ' .
+ 'AGAINST (\''.addslashes(strtolower($q)).'\' IN BOOLEAN MODE)', 'OR');
+ }
+ return true;
+ } else if ('notice' === $this->table) {
+
+ // Don't show imported notices
+ $this->target->whereAdd('notice.is_local != ' . Notice::GATEWAY);
+
+ if (strtolower($q) != $q) {
+ $this->target->whereAdd("( MATCH(content) AGAINST ('" . addslashes($q) .
+ "' IN BOOLEAN MODE)) OR ( MATCH(content) " .
+ "AGAINST ('" . addslashes(strtolower($q)) .
+ "' IN BOOLEAN MODE))");
+ } else {
+ $this->target->whereAdd('MATCH(content) ' .
+ 'AGAINST (\''.addslashes($q).'\' IN BOOLEAN MODE)');
+ }
+
+ return true;
+ } else {
+ throw new ServerException('Unknown table: ' . $this->table);