11<?php
22
33//
4- // $Id: sphinxapi.php 2376 2010-06-29 14:08:19Z shodan $
4+ // $Id: sphinxapi.php 2758 2011-04-04 11:10:44Z kevg $
55//
66
77//
8- // Copyright (c) 2001-2010 , Andrew Aksyonoff
9- // Copyright (c) 2008-2010 , Sphinx Technologies Inc
8+ // Copyright (c) 2001-2011 , Andrew Aksyonoff
9+ // Copyright (c) 2008-2011 , Sphinx Technologies Inc
1010// All rights reserved
1111//
1212// This program is free software; you can redistribute it and/or modify
2626define ( "SEARCHD_COMMAND_KEYWORDS " , 3 );
2727define ( "SEARCHD_COMMAND_PERSIST " , 4 );
2828define ( "SEARCHD_COMMAND_STATUS " , 5 );
29- define ( "SEARCHD_COMMAND_QUERY " , 6 );
3029define ( "SEARCHD_COMMAND_FLUSHATTRS " , 7 );
3130
3231/// current client-side command implementation versions
33- define ( "VER_COMMAND_SEARCH " , 0x117 );
34- define ( "VER_COMMAND_EXCERPT " , 0x102 );
32+ define ( "VER_COMMAND_SEARCH " , 0x118 );
33+ define ( "VER_COMMAND_EXCERPT " , 0x103 );
3534define ( "VER_COMMAND_UPDATE " , 0x102 );
3635define ( "VER_COMMAND_KEYWORDS " , 0x100 );
3736define ( "VER_COMMAND_STATUS " , 0x100 );
@@ -638,7 +637,7 @@ function _GetResponse ( $fp, $client_ver )
638637 $ left = $ len ;
639638 while ( $ left >0 && !feof ($ fp ) )
640639 {
641- $ chunk = fread ( $ fp , $ left );
640+ $ chunk = fread ( $ fp , min ( 8192 , $ left ) );
642641 if ( $ chunk )
643642 {
644643 $ response .= $ chunk ;
@@ -1109,8 +1108,8 @@ function RunQueries ()
11091108 // send query, get response
11101109 $ nreqs = count ($ this ->_reqs );
11111110 $ req = join ( "" , $ this ->_reqs );
1112- $ len = 4 +strlen ($ req );
1113- $ req = pack ( "nnNN " , SEARCHD_COMMAND_SEARCH , VER_COMMAND_SEARCH , $ len , $ nreqs ) . $ req ; // add header
1111+ $ len = 8 +strlen ($ req );
1112+ $ req = pack ( "nnNNN " , SEARCHD_COMMAND_SEARCH , VER_COMMAND_SEARCH , $ len, 0 , $ nreqs ) . $ req ; // add header
11141113
11151114 if ( !( $ this ->_Send ( $ fp , $ req , $ len +8 ) ) ||
11161115 !( $ response = $ this ->_GetResponse ( $ fp , VER_COMMAND_SEARCH ) ) )
@@ -1325,6 +1324,8 @@ function BuildExcerpts ( $docs, $index, $words, $opts=array() )
13251324 if ( !isset ($ opts ["load_files " ]) ) $ opts ["load_files " ] = false ;
13261325 if ( !isset ($ opts ["html_strip_mode " ]) ) $ opts ["html_strip_mode " ] = "index " ;
13271326 if ( !isset ($ opts ["allow_empty " ]) ) $ opts ["allow_empty " ] = false ;
1327+ if ( !isset ($ opts ["passage_boundary " ]) ) $ opts ["passage_boundary " ] = "none " ;
1328+ if ( !isset ($ opts ["emit_zones " ]) ) $ opts ["emit_zones " ] = false ;
13281329
13291330 /////////////////
13301331 // build request
@@ -1340,6 +1341,7 @@ function BuildExcerpts ( $docs, $index, $words, $opts=array() )
13401341 if ( $ opts ["force_all_words " ] ) $ flags |= 64 ;
13411342 if ( $ opts ["load_files " ] ) $ flags |= 128 ;
13421343 if ( $ opts ["allow_empty " ] ) $ flags |= 256 ;
1344+ if ( $ opts ["emit_zones " ] ) $ flags |= 512 ;
13431345 $ req = pack ( "NN " , 0 , $ flags ); // mode=0, flags=$flags
13441346 $ req .= pack ( "N " , strlen ($ index ) ) . $ index ; // req index
13451347 $ req .= pack ( "N " , strlen ($ words ) ) . $ words ; // req words
@@ -1351,6 +1353,7 @@ function BuildExcerpts ( $docs, $index, $words, $opts=array() )
13511353 $ req .= pack ( "NN " , (int )$ opts ["limit " ], (int )$ opts ["around " ] );
13521354 $ req .= pack ( "NNN " , (int )$ opts ["limit_passages " ], (int )$ opts ["limit_words " ], (int )$ opts ["start_passage_id " ] ); // v.1.2
13531355 $ req .= pack ( "N " , strlen ($ opts ["html_strip_mode " ]) ) . $ opts ["html_strip_mode " ];
1356+ $ req .= pack ( "N " , strlen ($ opts ["passage_boundary " ]) ) . $ opts ["passage_boundary " ];
13541357
13551358 // documents
13561359 $ req .= pack ( "N " , count ($ docs ) );
@@ -1684,5 +1687,5 @@ function FlushAttributes ()
16841687}
16851688
16861689//
1687- // $Id: sphinxapi.php 2376 2010-06-29 14:08:19Z shodan $
1690+ // $Id: sphinxapi.php 2758 2011-04-04 11:10:44Z kevg $
16881691//
0 commit comments