1
1
<?php
2
2
3
3
//
4
- // $Id: sphinxapi.php 2376 2010-06-29 14:08:19Z shodan $
4
+ // $Id: sphinxapi.php 2758 2011-04-04 11:10:44Z kevg $
5
5
//
6
6
7
7
//
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
10
10
// All rights reserved
11
11
//
12
12
// This program is free software; you can redistribute it and/or modify
26
26
define ( "SEARCHD_COMMAND_KEYWORDS " , 3 );
27
27
define ( "SEARCHD_COMMAND_PERSIST " , 4 );
28
28
define ( "SEARCHD_COMMAND_STATUS " , 5 );
29
- define ( "SEARCHD_COMMAND_QUERY " , 6 );
30
29
define ( "SEARCHD_COMMAND_FLUSHATTRS " , 7 );
31
30
32
31
/// 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 );
35
34
define ( "VER_COMMAND_UPDATE " , 0x102 );
36
35
define ( "VER_COMMAND_KEYWORDS " , 0x100 );
37
36
define ( "VER_COMMAND_STATUS " , 0x100 );
@@ -638,7 +637,7 @@ function _GetResponse ( $fp, $client_ver )
638
637
$ left = $ len ;
639
638
while ( $ left >0 && !feof ($ fp ) )
640
639
{
641
- $ chunk = fread ( $ fp , $ left );
640
+ $ chunk = fread ( $ fp , min ( 8192 , $ left ) );
642
641
if ( $ chunk )
643
642
{
644
643
$ response .= $ chunk ;
@@ -1109,8 +1108,8 @@ function RunQueries ()
1109
1108
// send query, get response
1110
1109
$ nreqs = count ($ this ->_reqs );
1111
1110
$ 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
1114
1113
1115
1114
if ( !( $ this ->_Send ( $ fp , $ req , $ len +8 ) ) ||
1116
1115
!( $ response = $ this ->_GetResponse ( $ fp , VER_COMMAND_SEARCH ) ) )
@@ -1325,6 +1324,8 @@ function BuildExcerpts ( $docs, $index, $words, $opts=array() )
1325
1324
if ( !isset ($ opts ["load_files " ]) ) $ opts ["load_files " ] = false ;
1326
1325
if ( !isset ($ opts ["html_strip_mode " ]) ) $ opts ["html_strip_mode " ] = "index " ;
1327
1326
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 ;
1328
1329
1329
1330
/////////////////
1330
1331
// build request
@@ -1340,6 +1341,7 @@ function BuildExcerpts ( $docs, $index, $words, $opts=array() )
1340
1341
if ( $ opts ["force_all_words " ] ) $ flags |= 64 ;
1341
1342
if ( $ opts ["load_files " ] ) $ flags |= 128 ;
1342
1343
if ( $ opts ["allow_empty " ] ) $ flags |= 256 ;
1344
+ if ( $ opts ["emit_zones " ] ) $ flags |= 512 ;
1343
1345
$ req = pack ( "NN " , 0 , $ flags ); // mode=0, flags=$flags
1344
1346
$ req .= pack ( "N " , strlen ($ index ) ) . $ index ; // req index
1345
1347
$ req .= pack ( "N " , strlen ($ words ) ) . $ words ; // req words
@@ -1351,6 +1353,7 @@ function BuildExcerpts ( $docs, $index, $words, $opts=array() )
1351
1353
$ req .= pack ( "NN " , (int )$ opts ["limit " ], (int )$ opts ["around " ] );
1352
1354
$ req .= pack ( "NNN " , (int )$ opts ["limit_passages " ], (int )$ opts ["limit_words " ], (int )$ opts ["start_passage_id " ] ); // v.1.2
1353
1355
$ req .= pack ( "N " , strlen ($ opts ["html_strip_mode " ]) ) . $ opts ["html_strip_mode " ];
1356
+ $ req .= pack ( "N " , strlen ($ opts ["passage_boundary " ]) ) . $ opts ["passage_boundary " ];
1354
1357
1355
1358
// documents
1356
1359
$ req .= pack ( "N " , count ($ docs ) );
@@ -1684,5 +1687,5 @@ function FlushAttributes ()
1684
1687
}
1685
1688
1686
1689
//
1687
- // $Id: sphinxapi.php 2376 2010-06-29 14:08:19Z shodan $
1690
+ // $Id: sphinxapi.php 2758 2011-04-04 11:10:44Z kevg $
1688
1691
//
0 commit comments