Sphinx version

This commit is contained in:
Michael RICOIS 2017-01-27 15:29:40 +01:00
parent 445b032338
commit 768e646e23
7 changed files with 135 additions and 3774 deletions

View File

@ -813,33 +813,28 @@ function clientSphinx(&$formR)
case 'ent':
$host = SPHINX_ENT_HOST;
$port = SPHINX_ENT_PORT;
$version = defined('SPHINX_ENT_VERSION') ? SPHINX_ENT_VERSION : 1;
$version = SPHINX_ENT_VERSION;
break;
case 'dir':
$version = defined('SPHINX_DIR_VERSION') ? SPHINX_DIR_VERSION : 1;
$version = SPHINX_DIR_VERSION;
$host = SPHINX_DIR_HOST;
$port = SPHINX_DIR_PORT;
break;
case 'histo':
$version = defined('SPHINX_HISTO_VERSION') ? SPHINX_HISTO_VERSION : 1;
$version = SPHINX_HISTO_VERSION;
$host = SPHINX_HISTO_HOST;
$port = SPHINX_HISTO_PORT;
break;
case 'act':
$version = defined('SPHINX_ACT_VERSION') ? SPHINX_ACT_VERSION : 1;
$version = SPHINX_ACT_VERSION;
$host = SPHINX_ACT_HOST;
$port = SPHINX_ACT_PORT;
break;
}
switch ($version) {
case 1:
require_once 'SphinxSearch/sphinxapi-0.9.9.php';
break;
case 2:
require_once 'SphinxSearch/sphinxapi-2.2.9.php';
break;
}
$sphinxapiPath = 'SphinxSearch';
$sphinxapiFile = 'sphinxapi-'.$version.'.php';
require_once $sphinxapiPath.'/'.$sphinxapiFile;
// Client Sphinx
$sphinx = new SphinxClient();

File diff suppressed because it is too large Load Diff

View File

@ -141,7 +141,7 @@ define ( "SPH_GROUPBY_ATTRPAIR", 5 );
function sphPackI64 ( $v )
{
assert ( is_numeric($v) );
// x64
if ( PHP_INT_SIZE>=8 )
{
@ -153,7 +153,7 @@ function sphPackI64 ( $v )
if ( is_int($v) )
return pack ( "NN", $v < 0 ? -1 : 0, $v );
// x32, bcmath
// x32, bcmath
if ( function_exists("bcmul") )
{
if ( bccomp ( $v, 0 ) == -1 )
@ -190,16 +190,16 @@ function sphPackI64 ( $v )
function sphPackU64 ( $v )
{
assert ( is_numeric($v) );
// x64
if ( PHP_INT_SIZE>=8 )
{
assert ( $v>=0 );
// x64, int
if ( is_int($v) )
return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
// x64, bcmath
if ( function_exists("bcmul") )
{
@ -207,12 +207,12 @@ function sphPackU64 ( $v )
$l = bcmod ( $v, 4294967296 );
return pack ( "NN", $h, $l );
}
// x64, no-bcmath
$p = max ( 0, strlen($v) - 13 );
$lo = (int)substr ( $v, $p );
$hi = (int)substr ( $v, 0, $p );
$m = $lo + $hi*1316134912;
$l = $m % 4294967296;
$h = $hi*2328 + (int)($m/4294967296);
@ -223,7 +223,7 @@ function sphPackU64 ( $v )
// x32, int
if ( is_int($v) )
return pack ( "NN", 0, $v );
// x32, bcmath
if ( function_exists("bcmul") )
{
@ -236,7 +236,7 @@ function sphPackU64 ( $v )
$p = max(0, strlen($v) - 13);
$lo = (float)substr($v, $p);
$hi = (float)substr($v, 0, $p);
$m = $lo + $hi*1316134912.0;
$q = floor($m / 4294967296.0);
$l = $m - ($q * 4294967296.0);
@ -292,11 +292,11 @@ function sphUnpackU64 ( $v )
// x32, bcmath
if ( function_exists("bcmul") )
return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;
$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
@ -339,7 +339,7 @@ function sphUnpackI64 ( $v )
return $lo;
return sprintf ( "%.0f", $lo - 4294967296.0 );
}
$neg = "";
$c = 0;
if ( $hi<0 )
@ -348,7 +348,7 @@ function sphUnpackI64 ( $v )
$lo = ~$lo;
$c = 1;
$neg = "-";
}
}
$hi = sprintf ( "%u", $hi );
$lo = sprintf ( "%u", $lo );
@ -360,7 +360,7 @@ function sphUnpackI64 ( $v )
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;
$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
@ -550,7 +550,7 @@ class SphinxClient
$this->_path = $host;
return;
}
$this->_host = $host;
$port = intval($port);
assert ( 0<=$port && $port<65536 );
@ -630,14 +630,14 @@ class SphinxClient
$fp = @fsockopen ( $host, $port, $errno, $errstr );
else
$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
if ( !$fp )
{
if ( $this->_path )
$location = $this->_path;
else
$location = "{$this->_host}:{$this->_port}";
$errstr = trim ( $errstr );
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
$this->_connerror = true;
@ -768,7 +768,7 @@ class SphinxClient
/// set matching mode
function SetMatchMode ( $mode )
{
trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
//trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
assert ( $mode==SPH_MATCH_ALL
|| $mode==SPH_MATCH_ANY
|| $mode==SPH_MATCH_PHRASE
@ -863,7 +863,7 @@ class SphinxClient
$this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values );
}
}
/// set string filter
/// only match records where $attribute value is equal
function SetFilterString ( $attribute, $value, $exclude=false )
@ -871,7 +871,7 @@ class SphinxClient
assert ( is_string($attribute) );
assert ( is_string($value) );
$this->_filters[] = array ( "type"=>SPH_FILTER_STRING, "attr"=>$attribute, "exclude"=>$exclude, "value"=>$value );
}
}
/// set range filter
/// only match records if $attribute value is beetwen $min and $max (inclusive)
@ -970,7 +970,7 @@ class SphinxClient
assert ( is_string ( $select ) );
$this->_select = $select;
}
function SetQueryFlag ( $flag_name, $flag_value )
{
$known_names = array ( "reverse_scan", "sort_method", "max_predicted_time", "boolean_simplify", "idf", "global_idf" );
@ -982,10 +982,10 @@ class SphinxClient
"idf" => array ("normalized", "plain", "tfidf_normalized", "tfidf_unnormalized" ),
"global_idf" => array ( true, false ),
);
assert ( isset ( $flag_name, $known_names ) );
assert ( in_array( $flag_value, $flags[$flag_name], true ) || ( $flag_name=="max_predicted_time" && is_int ( $flag_value ) && $flag_value>=0 ) );
if ( $flag_name=="reverse_scan" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 0, $flag_value==1 );
if ( $flag_name=="sort_method" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 1, $flag_value=="kbuffer" );
if ( $flag_name=="max_predicted_time" )
@ -998,7 +998,7 @@ class SphinxClient
if ( $flag_name=="global_idf" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 5, $flag_value );
if ( $flag_name=="idf" && ( $flag_value=="tfidf_normalized" || $flag_value=="tfidf_unnormalized" ) ) $this->_query_flags = sphSetBit ( $this->_query_flags, 6, $flag_value=="tfidf_normalized" );
}
/// set outer order by parameters
function SetOuterSelect ( $orderby, $offset, $limit )
{
@ -1014,7 +1014,7 @@ class SphinxClient
$this->_hasouter = true;
}
//////////////////////////////////////////////////////////////////////////////
/// clear all filters (for multi-queries)
@ -1038,7 +1038,7 @@ class SphinxClient
{
$this->_overrides = array ();
}
function ResetQueryFlag ()
{
$this->_query_flags = sphSetBit ( 0, 6, true ); // default idf=tfidf_normalized
@ -1126,7 +1126,7 @@ class SphinxClient
case SPH_FILTER_FLOATRANGE:
$req .= $this->_PackFloat ( $filter["min"] ) . $this->_PackFloat ( $filter["max"] );
break;
case SPH_FILTER_STRING:
$req .= pack ( "N", strlen($filter["value"]) ) . $filter["value"];
break;
@ -1196,11 +1196,11 @@ class SphinxClient
// select-list
$req .= pack ( "N", strlen($this->_select) ) . $this->_select;
// max_predicted_time
if ( $this->_predictedtime>0 )
$req .= pack ( "N", (int)$this->_predictedtime );
$req .= pack ( "N", strlen($this->_outerorderby) ) . $this->_outerorderby;
$req .= pack ( "NN", $this->_outeroffset, $this->_outerlimit );
if ( $this->_hasouter )
@ -1356,7 +1356,7 @@ class SphinxClient
if ( $type==SPH_ATTR_FLOAT )
{
list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
$attrvals[$attr] = $fval;
continue;
}
@ -1384,11 +1384,11 @@ class SphinxClient
} else if ( $type==SPH_ATTR_STRING )
{
$attrvals[$attr] = substr ( $response, $p, $val );
$p += $val;
$p += $val;
} else if ( $type==SPH_ATTR_FACTORS )
{
$attrvals[$attr] = substr ( $response, $p, $val-4 );
$p += $val-4;
$p += $val-4;
} else
{
$attrvals[$attr] = sphFixUint($val);
@ -1469,7 +1469,7 @@ class SphinxClient
if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none";
if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false;
if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false;
/////////////////
// build request
@ -1760,7 +1760,7 @@ class SphinxClient
fclose ( $this->_socket );
$this->_socket = false;
return true;
}

View File

@ -1,24 +1,32 @@
<?php
//
// $Id: sphinxapi.php 4522 2014-01-30 11:00:18Z tomat $
// $Id$
//
//
// Copyright (c) 2001-2014, Andrew Aksyonoff
// Copyright (c) 2008-2014, Sphinx Technologies Inc
// Copyright (c) 2001-2016, Andrew Aksyonoff
// Copyright (c) 2008-2016, Sphinx Technologies Inc
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License. You should have
// received a copy of the GPL license along with this program; if you
// it under the terms of the GNU Library General Public License. You should
// have received a copy of the LGPL license along with this program; if you
// did not, you can find it at http://www.gnu.org/
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// WARNING
// We strongly recommend you to use SphinxQL instead of the API
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// WARNING!!!
//
// As of 2015, we strongly recommend to use either SphinxQL or REST APIs
// rather than the native SphinxAPI.
//
// While both the native SphinxAPI protocol and the existing APIs will
// continue to exist, and perhaps should not even break (too much), exposing
// all the new features via multiple different native API implementations
// is too much of a support complication for us.
//
// That said, you're welcome to overtake the maintenance of any given
// official API, and remove this warning ;)
//
/////////////////////////////////////////////////////////////////////////////
// PHP version of Sphinx searchd client (PHP API)
@ -133,7 +141,7 @@ define ( "SPH_GROUPBY_ATTRPAIR", 5 );
function sphPackI64 ( $v )
{
assert ( is_numeric($v) );
// x64
if ( PHP_INT_SIZE>=8 )
{
@ -145,7 +153,7 @@ function sphPackI64 ( $v )
if ( is_int($v) )
return pack ( "NN", $v < 0 ? -1 : 0, $v );
// x32, bcmath
// x32, bcmath
if ( function_exists("bcmul") )
{
if ( bccomp ( $v, 0 ) == -1 )
@ -182,16 +190,16 @@ function sphPackI64 ( $v )
function sphPackU64 ( $v )
{
assert ( is_numeric($v) );
// x64
if ( PHP_INT_SIZE>=8 )
{
assert ( $v>=0 );
// x64, int
if ( is_int($v) )
return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
// x64, bcmath
if ( function_exists("bcmul") )
{
@ -199,12 +207,12 @@ function sphPackU64 ( $v )
$l = bcmod ( $v, 4294967296 );
return pack ( "NN", $h, $l );
}
// x64, no-bcmath
$p = max ( 0, strlen($v) - 13 );
$lo = (int)substr ( $v, $p );
$hi = (int)substr ( $v, 0, $p );
$m = $lo + $hi*1316134912;
$l = $m % 4294967296;
$h = $hi*2328 + (int)($m/4294967296);
@ -215,7 +223,7 @@ function sphPackU64 ( $v )
// x32, int
if ( is_int($v) )
return pack ( "NN", 0, $v );
// x32, bcmath
if ( function_exists("bcmul") )
{
@ -228,7 +236,7 @@ function sphPackU64 ( $v )
$p = max(0, strlen($v) - 13);
$lo = (float)substr($v, $p);
$hi = (float)substr($v, 0, $p);
$m = $lo + $hi*1316134912.0;
$q = floor($m / 4294967296.0);
$l = $m - ($q * 4294967296.0);
@ -284,11 +292,11 @@ function sphUnpackU64 ( $v )
// x32, bcmath
if ( function_exists("bcmul") )
return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;
$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
@ -331,7 +339,7 @@ function sphUnpackI64 ( $v )
return $lo;
return sprintf ( "%.0f", $lo - 4294967296.0 );
}
$neg = "";
$c = 0;
if ( $hi<0 )
@ -340,7 +348,7 @@ function sphUnpackI64 ( $v )
$lo = ~$lo;
$c = 1;
$neg = "-";
}
}
$hi = sprintf ( "%u", $hi );
$lo = sprintf ( "%u", $lo );
@ -352,7 +360,7 @@ function sphUnpackI64 ( $v )
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;
$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
@ -542,7 +550,7 @@ class SphinxClient
$this->_path = $host;
return;
}
$this->_host = $host;
$port = intval($port);
assert ( 0<=$port && $port<65536 );
@ -622,14 +630,14 @@ class SphinxClient
$fp = @fsockopen ( $host, $port, $errno, $errstr );
else
$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
if ( !$fp )
{
if ( $this->_path )
$location = $this->_path;
else
$location = "{$this->_host}:{$this->_port}";
$errstr = trim ( $errstr );
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
$this->_connerror = true;
@ -760,7 +768,7 @@ class SphinxClient
/// set matching mode
function SetMatchMode ( $mode )
{
trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
//trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
assert ( $mode==SPH_MATCH_ALL
|| $mode==SPH_MATCH_ANY
|| $mode==SPH_MATCH_PHRASE
@ -855,7 +863,7 @@ class SphinxClient
$this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values );
}
}
/// set string filter
/// only match records where $attribute value is equal
function SetFilterString ( $attribute, $value, $exclude=false )
@ -863,7 +871,7 @@ class SphinxClient
assert ( is_string($attribute) );
assert ( is_string($value) );
$this->_filters[] = array ( "type"=>SPH_FILTER_STRING, "attr"=>$attribute, "exclude"=>$exclude, "value"=>$value );
}
}
/// set range filter
/// only match records if $attribute value is beetwen $min and $max (inclusive)
@ -962,7 +970,7 @@ class SphinxClient
assert ( is_string ( $select ) );
$this->_select = $select;
}
function SetQueryFlag ( $flag_name, $flag_value )
{
$known_names = array ( "reverse_scan", "sort_method", "max_predicted_time", "boolean_simplify", "idf", "global_idf" );
@ -974,10 +982,10 @@ class SphinxClient
"idf" => array ("normalized", "plain", "tfidf_normalized", "tfidf_unnormalized" ),
"global_idf" => array ( true, false ),
);
assert ( isset ( $flag_name, $known_names ) );
assert ( in_array( $flag_value, $flags[$flag_name], true ) || ( $flag_name=="max_predicted_time" && is_int ( $flag_value ) && $flag_value>=0 ) );
if ( $flag_name=="reverse_scan" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 0, $flag_value==1 );
if ( $flag_name=="sort_method" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 1, $flag_value=="kbuffer" );
if ( $flag_name=="max_predicted_time" )
@ -990,7 +998,7 @@ class SphinxClient
if ( $flag_name=="global_idf" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 5, $flag_value );
if ( $flag_name=="idf" && ( $flag_value=="tfidf_normalized" || $flag_value=="tfidf_unnormalized" ) ) $this->_query_flags = sphSetBit ( $this->_query_flags, 6, $flag_value=="tfidf_normalized" );
}
/// set outer order by parameters
function SetOuterSelect ( $orderby, $offset, $limit )
{
@ -1006,7 +1014,7 @@ class SphinxClient
$this->_hasouter = true;
}
//////////////////////////////////////////////////////////////////////////////
/// clear all filters (for multi-queries)
@ -1030,7 +1038,7 @@ class SphinxClient
{
$this->_overrides = array ();
}
function ResetQueryFlag ()
{
$this->_query_flags = sphSetBit ( 0, 6, true ); // default idf=tfidf_normalized
@ -1118,7 +1126,7 @@ class SphinxClient
case SPH_FILTER_FLOATRANGE:
$req .= $this->_PackFloat ( $filter["min"] ) . $this->_PackFloat ( $filter["max"] );
break;
case SPH_FILTER_STRING:
$req .= pack ( "N", strlen($filter["value"]) ) . $filter["value"];
break;
@ -1188,11 +1196,11 @@ class SphinxClient
// select-list
$req .= pack ( "N", strlen($this->_select) ) . $this->_select;
// max_predicted_time
if ( $this->_predictedtime>0 )
$req .= pack ( "N", (int)$this->_predictedtime );
$req .= pack ( "N", strlen($this->_outerorderby) ) . $this->_outerorderby;
$req .= pack ( "NN", $this->_outeroffset, $this->_outerlimit );
if ( $this->_hasouter )
@ -1348,7 +1356,7 @@ class SphinxClient
if ( $type==SPH_ATTR_FLOAT )
{
list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
$attrvals[$attr] = $fval;
continue;
}
@ -1376,11 +1384,11 @@ class SphinxClient
} else if ( $type==SPH_ATTR_STRING )
{
$attrvals[$attr] = substr ( $response, $p, $val );
$p += $val;
$p += $val;
} else if ( $type==SPH_ATTR_FACTORS )
{
$attrvals[$attr] = substr ( $response, $p, $val-4 );
$p += $val-4;
$p += $val-4;
} else
{
$attrvals[$attr] = sphFixUint($val);
@ -1461,7 +1469,7 @@ class SphinxClient
if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none";
if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false;
if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false;
/////////////////
// build request
@ -1752,7 +1760,7 @@ class SphinxClient
fclose ( $this->_socket );
$this->_socket = false;
return true;
}
@ -1828,5 +1836,5 @@ class SphinxClient
}
//
// $Id: sphinxapi.php 4522 2014-01-30 11:00:18Z tomat $
// $Id$
//

File diff suppressed because it is too large Load Diff

View File

@ -133,7 +133,7 @@ define ( "SPH_GROUPBY_ATTRPAIR", 5 );
function sphPackI64 ( $v )
{
assert ( is_numeric($v) );
// x64
if ( PHP_INT_SIZE>=8 )
{
@ -145,7 +145,7 @@ function sphPackI64 ( $v )
if ( is_int($v) )
return pack ( "NN", $v < 0 ? -1 : 0, $v );
// x32, bcmath
// x32, bcmath
if ( function_exists("bcmul") )
{
if ( bccomp ( $v, 0 ) == -1 )
@ -182,16 +182,16 @@ function sphPackI64 ( $v )
function sphPackU64 ( $v )
{
assert ( is_numeric($v) );
// x64
if ( PHP_INT_SIZE>=8 )
{
assert ( $v>=0 );
// x64, int
if ( is_int($v) )
return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
// x64, bcmath
if ( function_exists("bcmul") )
{
@ -199,12 +199,12 @@ function sphPackU64 ( $v )
$l = bcmod ( $v, 4294967296 );
return pack ( "NN", $h, $l );
}
// x64, no-bcmath
$p = max ( 0, strlen($v) - 13 );
$lo = (int)substr ( $v, $p );
$hi = (int)substr ( $v, 0, $p );
$m = $lo + $hi*1316134912;
$l = $m % 4294967296;
$h = $hi*2328 + (int)($m/4294967296);
@ -215,7 +215,7 @@ function sphPackU64 ( $v )
// x32, int
if ( is_int($v) )
return pack ( "NN", 0, $v );
// x32, bcmath
if ( function_exists("bcmul") )
{
@ -228,7 +228,7 @@ function sphPackU64 ( $v )
$p = max(0, strlen($v) - 13);
$lo = (float)substr($v, $p);
$hi = (float)substr($v, 0, $p);
$m = $lo + $hi*1316134912.0;
$q = floor($m / 4294967296.0);
$l = $m - ($q * 4294967296.0);
@ -284,11 +284,11 @@ function sphUnpackU64 ( $v )
// x32, bcmath
if ( function_exists("bcmul") )
return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;
$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
@ -331,7 +331,7 @@ function sphUnpackI64 ( $v )
return $lo;
return sprintf ( "%.0f", $lo - 4294967296.0 );
}
$neg = "";
$c = 0;
if ( $hi<0 )
@ -340,7 +340,7 @@ function sphUnpackI64 ( $v )
$lo = ~$lo;
$c = 1;
$neg = "-";
}
}
$hi = sprintf ( "%u", $hi );
$lo = sprintf ( "%u", $lo );
@ -352,7 +352,7 @@ function sphUnpackI64 ( $v )
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;
$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
@ -542,7 +542,7 @@ class SphinxClient
$this->_path = $host;
return;
}
$this->_host = $host;
$port = intval($port);
assert ( 0<=$port && $port<65536 );
@ -622,14 +622,14 @@ class SphinxClient
$fp = @fsockopen ( $host, $port, $errno, $errstr );
else
$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
if ( !$fp )
{
if ( $this->_path )
$location = $this->_path;
else
$location = "{$this->_host}:{$this->_port}";
$errstr = trim ( $errstr );
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
$this->_connerror = true;
@ -760,7 +760,7 @@ class SphinxClient
/// set matching mode
function SetMatchMode ( $mode )
{
trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
//trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
assert ( $mode==SPH_MATCH_ALL
|| $mode==SPH_MATCH_ANY
|| $mode==SPH_MATCH_PHRASE
@ -855,7 +855,7 @@ class SphinxClient
$this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values );
}
}
/// set string filter
/// only match records where $attribute value is equal
function SetFilterString ( $attribute, $value, $exclude=false )
@ -863,7 +863,7 @@ class SphinxClient
assert ( is_string($attribute) );
assert ( is_string($value) );
$this->_filters[] = array ( "type"=>SPH_FILTER_STRING, "attr"=>$attribute, "exclude"=>$exclude, "value"=>$value );
}
}
/// set range filter
/// only match records if $attribute value is beetwen $min and $max (inclusive)
@ -962,7 +962,7 @@ class SphinxClient
assert ( is_string ( $select ) );
$this->_select = $select;
}
function SetQueryFlag ( $flag_name, $flag_value )
{
$known_names = array ( "reverse_scan", "sort_method", "max_predicted_time", "boolean_simplify", "idf", "global_idf" );
@ -974,10 +974,10 @@ class SphinxClient
"idf" => array ("normalized", "plain", "tfidf_normalized", "tfidf_unnormalized" ),
"global_idf" => array ( true, false ),
);
assert ( isset ( $flag_name, $known_names ) );
assert ( in_array( $flag_value, $flags[$flag_name], true ) || ( $flag_name=="max_predicted_time" && is_int ( $flag_value ) && $flag_value>=0 ) );
if ( $flag_name=="reverse_scan" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 0, $flag_value==1 );
if ( $flag_name=="sort_method" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 1, $flag_value=="kbuffer" );
if ( $flag_name=="max_predicted_time" )
@ -990,7 +990,7 @@ class SphinxClient
if ( $flag_name=="global_idf" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 5, $flag_value );
if ( $flag_name=="idf" && ( $flag_value=="tfidf_normalized" || $flag_value=="tfidf_unnormalized" ) ) $this->_query_flags = sphSetBit ( $this->_query_flags, 6, $flag_value=="tfidf_normalized" );
}
/// set outer order by parameters
function SetOuterSelect ( $orderby, $offset, $limit )
{
@ -1006,7 +1006,7 @@ class SphinxClient
$this->_hasouter = true;
}
//////////////////////////////////////////////////////////////////////////////
/// clear all filters (for multi-queries)
@ -1030,7 +1030,7 @@ class SphinxClient
{
$this->_overrides = array ();
}
function ResetQueryFlag ()
{
$this->_query_flags = sphSetBit ( 0, 6, true ); // default idf=tfidf_normalized
@ -1118,7 +1118,7 @@ class SphinxClient
case SPH_FILTER_FLOATRANGE:
$req .= $this->_PackFloat ( $filter["min"] ) . $this->_PackFloat ( $filter["max"] );
break;
case SPH_FILTER_STRING:
$req .= pack ( "N", strlen($filter["value"]) ) . $filter["value"];
break;
@ -1188,11 +1188,11 @@ class SphinxClient
// select-list
$req .= pack ( "N", strlen($this->_select) ) . $this->_select;
// max_predicted_time
if ( $this->_predictedtime>0 )
$req .= pack ( "N", (int)$this->_predictedtime );
$req .= pack ( "N", strlen($this->_outerorderby) ) . $this->_outerorderby;
$req .= pack ( "NN", $this->_outeroffset, $this->_outerlimit );
if ( $this->_hasouter )
@ -1348,7 +1348,7 @@ class SphinxClient
if ( $type==SPH_ATTR_FLOAT )
{
list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
$attrvals[$attr] = $fval;
continue;
}
@ -1376,11 +1376,11 @@ class SphinxClient
} else if ( $type==SPH_ATTR_STRING )
{
$attrvals[$attr] = substr ( $response, $p, $val );
$p += $val;
$p += $val;
} else if ( $type==SPH_ATTR_FACTORS )
{
$attrvals[$attr] = substr ( $response, $p, $val-4 );
$p += $val-4;
$p += $val-4;
} else
{
$attrvals[$attr] = sphFixUint($val);
@ -1461,7 +1461,7 @@ class SphinxClient
if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none";
if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false;
if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false;
/////////////////
// build request
@ -1752,7 +1752,7 @@ class SphinxClient
fclose ( $this->_socket );
$this->_socket = false;
return true;
}

View File

@ -1099,15 +1099,15 @@ class Interne extends Scores_Ws_Server
$tabFiltres = array();
if ($annee<>'' && $annee*1>=1953 && $annee*1<=date('Y')*1)
$tabFiltres = array('annee1'=>$annee);
if (SPHINX_HISTO_VERSION == 1){
require_once 'SphinxSearch/sphinxapi-0.9.9.php';
} elseif (SPHINX_HISTO_VERSION == 2){
require_once 'SphinxSearch/sphinxapi-2.2.9.php';
if ($annee != '' && $annee*1 >= 1953 && $annee*1 <= date('Y')*1) {
$tabFiltres = array('annee1' => $annee);
}
$version = SPHINX_HISTO_VERSION;
$sphinxapiPath = 'SphinxSearch';
$sphinxapiFile = 'sphinxapi-'.$version.'.php';
require_once $sphinxapiPath.'/'.$sphinxapiFile;
$cl = new SphinxClient();
$cl->SetServer (SPHINX_HISTO_HOST, SPHINX_HISTO_PORT);
$cl->SetConnectTimeout(1);