Development

Changeset 17698

You must first sign up to be able to contribute.

Changeset 17698

Show
Ignore:
Timestamp:
04/28/09 08:32:15 (4 years ago)
Author:
garak
Message:

added SPH_MATCH_EXTENDED2 mode. Fixed some nasty tabs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfSphinxPlugin/trunk/lib/sfSphinxClient.class.php

    r15512 r17698  
    4040 
    4141  // known match modes 
    42   const SPH_MATCH_ALL      = 0; 
    43   const SPH_MATCH_ANY      = 1; 
    44   const SPH_MATCH_PHRASE   = 2; 
    45   const SPH_MATCH_BOOLEAN  = 3; 
    46   const SPH_MATCH_EXTENDED = 4; 
    47   const SPH_MATCH_FULLSCAN = 5; 
     42  const SPH_MATCH_ALL       = 0; 
     43  const SPH_MATCH_ANY       = 1; 
     44  const SPH_MATCH_PHRASE    = 2; 
     45  const SPH_MATCH_BOOLEAN   = 3; 
     46  const SPH_MATCH_EXTENDED  = 4; 
     47  const SPH_MATCH_FULLSCAN  = 5; 
     48  const SPH_MATCH_EXTENDED2 = 6;  // extended engine V2 (temporary) 
    4849 
    4950  // known ranking modes (ext2 only) 
     
    287288  private function EscapeString($string) 
    288289  { 
    289    $from = array('(', ')', '|', '-', '!', '@', '~', '"', '&', '/' ); 
    290    $to   = array('\(', '\)', '\|', '\-', '\!', '\@', '\~', '\"', '\&', '\/'); 
     290    $from = array('(', ')', '|', '-', '!', '@', '~', '"', '&', '/' ); 
     291    $to   = array('\(', '\)', '\|', '\-', '\!', '\@', '\~', '\"', '\&', '\/'); 
    291292    return str_replace($from, $to, $string); 
    292293  } 
     
    337338  protected function Connect() 
    338339  { 
    339    $errno = 0; 
    340    $errstr = ''; 
    341    if ($this->timeout <= 0) 
    342    
    343      $fp = @fsockopen($this->host, $this->port, $errno, $errstr); 
    344    
    345    else 
    346    
    347      $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout); 
    348     } 
    349    if (!$fp) 
    350    
    351      $errstr = trim($errstr); 
    352      $this->error = "Sphinx connection to {$this->host}:{$this->port} failed (errno=$errno, msg=$errstr)"; 
    353       throw new Exception($this->error); 
    354    
    355  
    356    // check version 
    357    list(, $v) = unpack("N*", fread($fp, 4)); 
    358    $v = (int) $v; 
    359    if ($v < 1) 
    360    
    361      fclose($fp); 
    362      $this->error = "expected searchd protocol version 1+, got version '$v'"; 
    363       throw new Exception($this->error); 
    364    
    365  
    366    // all ok, send my version 
    367    fwrite($fp, pack("N", 1)); 
    368    return $fp; 
     340    $errno = 0; 
     341    $errstr = ''; 
     342    if ($this->timeout <= 0) 
     343   
     344      $fp = @fsockopen($this->host, $this->port, $errno, $errstr); 
     345   
     346    else 
     347   
     348      $fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout); 
     349    } 
     350    if (!$fp) 
     351   
     352      $errstr = trim($errstr); 
     353      $this->error = "Sphinx connection to {$this->host}:{$this->port} failed (errno=$errno, msg=$errstr)"; 
     354      throw new Exception($this->error); 
     355   
     356 
     357    // check version 
     358    list(, $v) = unpack("N*", fread($fp, 4)); 
     359    $v = (int) $v; 
     360    if ($v < 1) 
     361   
     362      fclose($fp); 
     363      $this->error = "expected searchd protocol version 1+, got version '$v'"; 
     364      throw new Exception($this->error); 
     365   
     366 
     367    // all ok, send my version 
     368    fwrite($fp, pack("N", 1)); 
     369    return $fp; 
    369370  } 
    370371