@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | ////////////////////// |
12 | 12 | |
13 | 13 | // for very old PHP versions, like at my home test server |
14 | -if ( is_array($argv) && !isset($_SERVER["argv"]) ) |
|
14 | +if ( is_array($argv) && !isset($_SERVER["argv"]) ) { |
|
15 | 15 | $_SERVER["argv"] = $argv; |
16 | +} |
|
16 | 17 | unset ( $_SERVER["argv"][0] ); |
17 | 18 | |
18 | 19 | // build query |
@@ -41,8 +42,9 @@ discard block |
||
41 | 42 | } |
42 | 43 | |
43 | 44 | $args = array(); |
44 | -foreach ( $_SERVER["argv"] as $arg ) |
|
45 | +foreach ( $_SERVER["argv"] as $arg ) { |
|
45 | 46 | $args[] = $arg; |
47 | +} |
|
46 | 48 | |
47 | 49 | $cl = new SphinxClient (); |
48 | 50 | |
@@ -66,36 +68,60 @@ discard block |
||
66 | 68 | { |
67 | 69 | $arg = $args[$i]; |
68 | 70 | |
69 | - if ( $arg=="-h" || $arg=="--host" ) $host = $args[++$i]; |
|
70 | - else if ( $arg=="-p" || $arg=="--port" ) $port = (int)$args[++$i]; |
|
71 | - else if ( $arg=="-i" || $arg=="--index" ) $index = $args[++$i]; |
|
72 | - else if ( $arg=="-s" || $arg=="--sortby" ) { $sortby = $args[++$i]; $sortexpr = ""; } |
|
73 | - else if ( $arg=="-S" || $arg=="--sortexpr" ) { $sortexpr = $args[++$i]; $sortby = ""; } |
|
74 | - else if ( $arg=="-a" || $arg=="--any" ) $mode = SPH_MATCH_ANY; |
|
75 | - else if ( $arg=="-b" || $arg=="--boolean" ) $mode = SPH_MATCH_BOOLEAN; |
|
76 | - else if ( $arg=="-e" || $arg=="--extended" ) $mode = SPH_MATCH_EXTENDED; |
|
77 | - else if ( $arg=="-e2" ) $mode = SPH_MATCH_EXTENDED2; |
|
78 | - else if ( $arg=="-ph"|| $arg=="--phrase" ) $mode = SPH_MATCH_PHRASE; |
|
79 | - else if ( $arg=="-f" || $arg=="--filter" ) $filter = $args[++$i]; |
|
80 | - else if ( $arg=="-v" || $arg=="--value" ) $filtervals[] = $args[++$i]; |
|
81 | - else if ( $arg=="-g" || $arg=="--groupby" ) $groupby = $args[++$i]; |
|
82 | - else if ( $arg=="-gs"|| $arg=="--groupsort" ) $groupsort = $args[++$i]; |
|
83 | - else if ( $arg=="-d" || $arg=="--distinct" ) $distinct = $args[++$i]; |
|
84 | - else if ( $arg=="-l" || $arg=="--limit" ) $limit = (int)$args[++$i]; |
|
85 | - else if ( $arg=="--select" ) $select = $args[++$i]; |
|
86 | - else if ( $arg=="-fr"|| $arg=="--filterrange" ) $cl->SetFilterRange ( $args[++$i], $args[++$i], $args[++$i] ); |
|
87 | - else if ( $arg=="-r" ) |
|
71 | + if ( $arg=="-h" || $arg=="--host" ) { |
|
72 | + $host = $args[++$i]; |
|
73 | + } else if ( $arg=="-p" || $arg=="--port" ) { |
|
74 | + $port = (int)$args[++$i]; |
|
75 | + } else if ( $arg=="-i" || $arg=="--index" ) { |
|
76 | + $index = $args[++$i]; |
|
77 | + } else if ( $arg=="-s" || $arg=="--sortby" ) { $sortby = $args[++$i]; $sortexpr = ""; } else if ( $arg=="-S" || $arg=="--sortexpr" ) { $sortexpr = $args[++$i]; $sortby = ""; } else if ( $arg=="-a" || $arg=="--any" ) { |
|
78 | + $mode = SPH_MATCH_ANY; |
|
79 | + } else if ( $arg=="-b" || $arg=="--boolean" ) { |
|
80 | + $mode = SPH_MATCH_BOOLEAN; |
|
81 | + } else if ( $arg=="-e" || $arg=="--extended" ) { |
|
82 | + $mode = SPH_MATCH_EXTENDED; |
|
83 | + } else if ( $arg=="-e2" ) { |
|
84 | + $mode = SPH_MATCH_EXTENDED2; |
|
85 | + } else if ( $arg=="-ph"|| $arg=="--phrase" ) { |
|
86 | + $mode = SPH_MATCH_PHRASE; |
|
87 | + } else if ( $arg=="-f" || $arg=="--filter" ) { |
|
88 | + $filter = $args[++$i]; |
|
89 | + } else if ( $arg=="-v" || $arg=="--value" ) { |
|
90 | + $filtervals[] = $args[++$i]; |
|
91 | + } else if ( $arg=="-g" || $arg=="--groupby" ) { |
|
92 | + $groupby = $args[++$i]; |
|
93 | + } else if ( $arg=="-gs"|| $arg=="--groupsort" ) { |
|
94 | + $groupsort = $args[++$i]; |
|
95 | + } else if ( $arg=="-d" || $arg=="--distinct" ) { |
|
96 | + $distinct = $args[++$i]; |
|
97 | + } else if ( $arg=="-l" || $arg=="--limit" ) { |
|
98 | + $limit = (int)$args[++$i]; |
|
99 | + } else if ( $arg=="--select" ) { |
|
100 | + $select = $args[++$i]; |
|
101 | + } else if ( $arg=="-fr"|| $arg=="--filterrange" ) { |
|
102 | + $cl->SetFilterRange ( $args[++$i], $args[++$i], $args[++$i] ); |
|
103 | + } else if ( $arg=="-r" ) |
|
88 | 104 | { |
89 | 105 | $arg = strtolower($args[++$i]); |
90 | - if ( $arg=="bm25" ) $ranker = SPH_RANK_BM25; |
|
91 | - if ( $arg=="none" ) $ranker = SPH_RANK_NONE; |
|
92 | - if ( $arg=="wordcount" )$ranker = SPH_RANK_WORDCOUNT; |
|
93 | - if ( $arg=="fieldmask" )$ranker = SPH_RANK_FIELDMASK; |
|
94 | - if ( $arg=="sph04" ) $ranker = SPH_RANK_SPH04; |
|
106 | + if ( $arg=="bm25" ) { |
|
107 | + $ranker = SPH_RANK_BM25; |
|
108 | + } |
|
109 | + if ( $arg=="none" ) { |
|
110 | + $ranker = SPH_RANK_NONE; |
|
111 | + } |
|
112 | + if ( $arg=="wordcount" ) { |
|
113 | + $ranker = SPH_RANK_WORDCOUNT; |
|
114 | + } |
|
115 | + if ( $arg=="fieldmask" ) { |
|
116 | + $ranker = SPH_RANK_FIELDMASK; |
|
117 | + } |
|
118 | + if ( $arg=="sph04" ) { |
|
119 | + $ranker = SPH_RANK_SPH04; |
|
120 | + } |
|
121 | + } else { |
|
122 | + $q .= $args[$i] . " "; |
|
123 | + } |
|
95 | 124 | } |
96 | - else |
|
97 | - $q .= $args[$i] . " "; |
|
98 | -} |
|
99 | 125 | |
100 | 126 | //////////// |
101 | 127 | // do query |
@@ -105,13 +131,27 @@ discard block |
||
105 | 131 | $cl->SetConnectTimeout ( 1 ); |
106 | 132 | $cl->SetArrayResult ( true ); |
107 | 133 | $cl->SetMatchMode ( $mode ); |
108 | -if ( count($filtervals) ) $cl->SetFilter ( $filter, $filtervals ); |
|
109 | -if ( $groupby ) $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort ); |
|
110 | -if ( $sortby ) $cl->SetSortMode ( SPH_SORT_EXTENDED, $sortby ); |
|
111 | -if ( $sortexpr ) $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr ); |
|
112 | -if ( $distinct ) $cl->SetGroupDistinct ( $distinct ); |
|
113 | -if ( $select ) $cl->SetSelect ( $select ); |
|
114 | -if ( $limit ) $cl->SetLimits ( 0, $limit, ( $limit>1000 ) ? $limit : 1000 ); |
|
134 | +if ( count($filtervals) ) { |
|
135 | + $cl->SetFilter ( $filter, $filtervals ); |
|
136 | +} |
|
137 | +if ( $groupby ) { |
|
138 | + $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort ); |
|
139 | +} |
|
140 | +if ( $sortby ) { |
|
141 | + $cl->SetSortMode ( SPH_SORT_EXTENDED, $sortby ); |
|
142 | +} |
|
143 | +if ( $sortexpr ) { |
|
144 | + $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr ); |
|
145 | +} |
|
146 | +if ( $distinct ) { |
|
147 | + $cl->SetGroupDistinct ( $distinct ); |
|
148 | +} |
|
149 | +if ( $select ) { |
|
150 | + $cl->SetSelect ( $select ); |
|
151 | +} |
|
152 | +if ( $limit ) { |
|
153 | + $cl->SetLimits ( 0, $limit, ( $limit>1000 ) ? $limit : 1000 ); |
|
154 | +} |
|
115 | 155 | $cl->SetRankingMode ( $ranker ); |
116 | 156 | $res = $cl->Query ( $q, $index ); |
117 | 157 | |
@@ -125,14 +165,16 @@ discard block |
||
125 | 165 | |
126 | 166 | } else |
127 | 167 | { |
128 | - if ( $cl->GetLastWarning() ) |
|
129 | - print "WARNING: " . $cl->GetLastWarning() . "\n\n"; |
|
168 | + if ( $cl->GetLastWarning() ) { |
|
169 | + print "WARNING: " . $cl->GetLastWarning() . "\n\n"; |
|
170 | + } |
|
130 | 171 | |
131 | 172 | print "Query '$q' retrieved $res[total] of $res[total_found] matches in $res[time] sec.\n"; |
132 | 173 | print "Query stats:\n"; |
133 | - if ( is_array($res["words"]) ) |
|
134 | - foreach ( $res["words"] as $word => $info ) |
|
174 | + if ( is_array($res["words"]) ) { |
|
175 | + foreach ( $res["words"] as $word => $info ) |
|
135 | 176 | print " '$word' found $info[hits] times in $info[docs] documents\n"; |
177 | + } |
|
136 | 178 | print "\n"; |
137 | 179 | |
138 | 180 | if ( is_array($res["matches"]) ) |
@@ -150,8 +192,9 @@ discard block |
||
150 | 192 | $value = "(" . join ( ",", $value ) .")"; |
151 | 193 | } else |
152 | 194 | { |
153 | - if ( $attrtype==SPH_ATTR_TIMESTAMP ) |
|
154 | - $value = date ( "Y-m-d H:i:s", $value ); |
|
195 | + if ( $attrtype==SPH_ATTR_TIMESTAMP ) { |
|
196 | + $value = date ( "Y-m-d H:i:s", $value ); |
|
197 | + } |
|
155 | 198 | } |
156 | 199 | print ", $attrname=$value"; |
157 | 200 | } |
@@ -150,14 +150,16 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | // x32, int |
153 | - if ( is_int($v) ) |
|
154 | - return pack ( "NN", $v < 0 ? -1 : 0, $v ); |
|
153 | + if ( is_int($v) ) { |
|
154 | + return pack ( "NN", $v < 0 ? -1 : 0, $v ); |
|
155 | + } |
|
155 | 156 | |
156 | 157 | // x32, bcmath |
157 | 158 | if ( function_exists("bcmul") ) |
158 | 159 | { |
159 | - if ( bccomp ( $v, 0 ) == -1 ) |
|
160 | - $v = bcadd ( "18446744073709551616", $v ); |
|
160 | + if ( bccomp ( $v, 0 ) == -1 ) { |
|
161 | + $v = bcadd ( "18446744073709551616", $v ); |
|
162 | + } |
|
161 | 163 | $h = bcdiv ( $v, "4294967296", 0 ); |
162 | 164 | $l = bcmod ( $v, "4294967296" ); |
163 | 165 | return pack ( "NN", (float)$h, (float)$l ); // conversion to float is intentional; int would lose 31st bit |
@@ -175,9 +177,9 @@ discard block |
||
175 | 177 | |
176 | 178 | if ( $v<0 ) |
177 | 179 | { |
178 | - if ( $l==0 ) |
|
179 | - $h = 4294967296.0 - $h; |
|
180 | - else |
|
180 | + if ( $l==0 ) { |
|
181 | + $h = 4294967296.0 - $h; |
|
182 | + } else |
|
181 | 183 | { |
182 | 184 | $h = 4294967295.0 - $h; |
183 | 185 | $l = 4294967296.0 - $l; |
@@ -197,8 +199,9 @@ discard block |
||
197 | 199 | assert ( $v>=0 ); |
198 | 200 | |
199 | 201 | // x64, int |
200 | - if ( is_int($v) ) |
|
201 | - return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); |
|
202 | + if ( is_int($v) ) { |
|
203 | + return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); |
|
204 | + } |
|
202 | 205 | |
203 | 206 | // x64, bcmath |
204 | 207 | if ( function_exists("bcmul") ) |
@@ -221,8 +224,9 @@ discard block |
||
221 | 224 | } |
222 | 225 | |
223 | 226 | // x32, int |
224 | - if ( is_int($v) ) |
|
225 | - return pack ( "NN", 0, $v ); |
|
227 | + if ( is_int($v) ) { |
|
228 | + return pack ( "NN", 0, $v ); |
|
229 | + } |
|
226 | 230 | |
227 | 231 | // x32, bcmath |
228 | 232 | if ( function_exists("bcmul") ) |
@@ -252,16 +256,23 @@ discard block |
||
252 | 256 | |
253 | 257 | if ( PHP_INT_SIZE>=8 ) |
254 | 258 | { |
255 | - if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again |
|
256 | - if ( $lo<0 ) $lo += (1<<32); |
|
259 | + if ( $hi<0 ) { |
|
260 | + $hi += (1<<32); |
|
261 | + } |
|
262 | + // because php 5.2.2 to 5.2.5 is totally fucked up again |
|
263 | + if ( $lo<0 ) { |
|
264 | + $lo += (1<<32); |
|
265 | + } |
|
257 | 266 | |
258 | 267 | // x64, int |
259 | - if ( $hi<=2147483647 ) |
|
260 | - return ($hi<<32) + $lo; |
|
268 | + if ( $hi<=2147483647 ) { |
|
269 | + return ($hi<<32) + $lo; |
|
270 | + } |
|
261 | 271 | |
262 | 272 | // x64, bcmath |
263 | - if ( function_exists("bcmul") ) |
|
264 | - return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); |
|
273 | + if ( function_exists("bcmul") ) { |
|
274 | + return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); |
|
275 | + } |
|
265 | 276 | |
266 | 277 | // x64, no-bcmath |
267 | 278 | $C = 100000; |
@@ -273,16 +284,18 @@ discard block |
||
273 | 284 | $l = $l % $C; |
274 | 285 | } |
275 | 286 | |
276 | - if ( $h==0 ) |
|
277 | - return $l; |
|
287 | + if ( $h==0 ) { |
|
288 | + return $l; |
|
289 | + } |
|
278 | 290 | return sprintf ( "%d%05d", $h, $l ); |
279 | 291 | } |
280 | 292 | |
281 | 293 | // x32, int |
282 | 294 | if ( $hi==0 ) |
283 | 295 | { |
284 | - if ( $lo>0 ) |
|
285 | - return $lo; |
|
296 | + if ( $lo>0 ) { |
|
297 | + return $lo; |
|
298 | + } |
|
286 | 299 | return sprintf ( "%u", $lo ); |
287 | 300 | } |
288 | 301 | |
@@ -290,8 +303,9 @@ discard block |
||
290 | 303 | $lo = sprintf ( "%u", $lo ); |
291 | 304 | |
292 | 305 | // x32, bcmath |
293 | - if ( function_exists("bcmul") ) |
|
294 | - return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); |
|
306 | + if ( function_exists("bcmul") ) { |
|
307 | + return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); |
|
308 | + } |
|
295 | 309 | |
296 | 310 | // x32, no-bcmath |
297 | 311 | $hi = (float)$hi; |
@@ -306,8 +320,9 @@ discard block |
||
306 | 320 | |
307 | 321 | $h = sprintf ( "%.0f", $h ); |
308 | 322 | $l = sprintf ( "%07.0f", $l ); |
309 | - if ( $h=="0" ) |
|
310 | - return sprintf( "%.0f", (float)$l ); |
|
323 | + if ( $h=="0" ) { |
|
324 | + return sprintf( "%.0f", (float)$l ); |
|
325 | + } |
|
311 | 326 | return $h . $l; |
312 | 327 | } |
313 | 328 | |
@@ -319,8 +334,13 @@ discard block |
||
319 | 334 | // x64 |
320 | 335 | if ( PHP_INT_SIZE>=8 ) |
321 | 336 | { |
322 | - if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again |
|
323 | - if ( $lo<0 ) $lo += (1<<32); |
|
337 | + if ( $hi<0 ) { |
|
338 | + $hi += (1<<32); |
|
339 | + } |
|
340 | + // because php 5.2.2 to 5.2.5 is totally fucked up again |
|
341 | + if ( $lo<0 ) { |
|
342 | + $lo += (1<<32); |
|
343 | + } |
|
324 | 344 | |
325 | 345 | return ($hi<<32) + $lo; |
326 | 346 | } |
@@ -328,15 +348,17 @@ discard block |
||
328 | 348 | // x32, int |
329 | 349 | if ( $hi==0 ) |
330 | 350 | { |
331 | - if ( $lo>0 ) |
|
332 | - return $lo; |
|
351 | + if ( $lo>0 ) { |
|
352 | + return $lo; |
|
353 | + } |
|
333 | 354 | return sprintf ( "%u", $lo ); |
334 | 355 | } |
335 | 356 | // x32, int |
336 | 357 | elseif ( $hi==-1 ) |
337 | 358 | { |
338 | - if ( $lo<0 ) |
|
339 | - return $lo; |
|
359 | + if ( $lo<0 ) { |
|
360 | + return $lo; |
|
361 | + } |
|
340 | 362 | return sprintf ( "%.0f", $lo - 4294967296.0 ); |
341 | 363 | } |
342 | 364 | |
@@ -354,8 +376,9 @@ discard block |
||
354 | 376 | $lo = sprintf ( "%u", $lo ); |
355 | 377 | |
356 | 378 | // x32, bcmath |
357 | - if ( function_exists("bcmul") ) |
|
358 | - return $neg . bcadd ( bcadd ( $lo, bcmul ( $hi, "4294967296" ) ), $c ); |
|
379 | + if ( function_exists("bcmul") ) { |
|
380 | + return $neg . bcadd ( bcadd ( $lo, bcmul ( $hi, "4294967296" ) ), $c ); |
|
381 | + } |
|
359 | 382 | |
360 | 383 | // x32, no-bcmath |
361 | 384 | $hi = (float)$hi; |
@@ -375,8 +398,9 @@ discard block |
||
375 | 398 | |
376 | 399 | $h = sprintf ( "%.0f", $h ); |
377 | 400 | $l = sprintf ( "%07.0f", $l ); |
378 | - if ( $h=="0" ) |
|
379 | - return $neg . sprintf( "%.0f", (float)$l ); |
|
401 | + if ( $h=="0" ) { |
|
402 | + return $neg . sprintf( "%.0f", (float)$l ); |
|
403 | + } |
|
380 | 404 | return $neg . $h . $l; |
381 | 405 | } |
382 | 406 | |
@@ -386,10 +410,11 @@ discard block |
||
386 | 410 | if ( PHP_INT_SIZE>=8 ) |
387 | 411 | { |
388 | 412 | // x64 route, workaround broken unpack() in 5.2.2+ |
389 | - if ( $value<0 ) $value += (1<<32); |
|
413 | + if ( $value<0 ) { |
|
414 | + $value += (1<<32); |
|
415 | + } |
|
390 | 416 | return $value; |
391 | - } |
|
392 | - else |
|
417 | + } else |
|
393 | 418 | { |
394 | 419 | // x32 route, workaround php signed/unsigned braindamage |
395 | 420 | return sprintf ( "%u", $value ); |
@@ -514,8 +539,9 @@ discard block |
||
514 | 539 | |
515 | 540 | function __destruct() |
516 | 541 | { |
517 | - if ( $this->_socket !== false ) |
|
518 | - fclose ( $this->_socket ); |
|
542 | + if ( $this->_socket !== false ) { |
|
543 | + fclose ( $this->_socket ); |
|
544 | + } |
|
519 | 545 | } |
520 | 546 | |
521 | 547 | /// get last error message (string) |
@@ -593,8 +619,9 @@ discard block |
||
593 | 619 | /// leave mbstring workaround mode |
594 | 620 | function _MBPop () |
595 | 621 | { |
596 | - if ( $this->_mbenc ) |
|
597 | - mb_internal_encoding ( $this->_mbenc ); |
|
622 | + if ( $this->_mbenc ) { |
|
623 | + mb_internal_encoding ( $this->_mbenc ); |
|
624 | + } |
|
598 | 625 | } |
599 | 626 | |
600 | 627 | /// connect to searchd server |
@@ -604,8 +631,9 @@ discard block |
||
604 | 631 | { |
605 | 632 | // we are in persistent connection mode, so we have a socket |
606 | 633 | // however, need to check whether it's still alive |
607 | - if ( !@feof ( $this->_socket ) ) |
|
608 | - return $this->_socket; |
|
634 | + if ( !@feof ( $this->_socket ) ) { |
|
635 | + return $this->_socket; |
|
636 | + } |
|
609 | 637 | |
610 | 638 | // force reopen |
611 | 639 | $this->_socket = false; |
@@ -619,24 +647,25 @@ discard block |
||
619 | 647 | { |
620 | 648 | $host = $this->_path; |
621 | 649 | $port = 0; |
622 | - } |
|
623 | - else |
|
650 | + } else |
|
624 | 651 | { |
625 | 652 | $host = $this->_host; |
626 | 653 | $port = $this->_port; |
627 | 654 | } |
628 | 655 | |
629 | - if ( $this->_timeout<=0 ) |
|
630 | - $fp = @fsockopen ( $host, $port, $errno, $errstr ); |
|
631 | - else |
|
632 | - $fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout ); |
|
656 | + if ( $this->_timeout<=0 ) { |
|
657 | + $fp = @fsockopen ( $host, $port, $errno, $errstr ); |
|
658 | + } else { |
|
659 | + $fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout ); |
|
660 | + } |
|
633 | 661 | |
634 | 662 | if ( !$fp ) |
635 | 663 | { |
636 | - if ( $this->_path ) |
|
637 | - $location = $this->_path; |
|
638 | - else |
|
639 | - $location = "{$this->_host}:{$this->_port}"; |
|
664 | + if ( $this->_path ) { |
|
665 | + $location = $this->_path; |
|
666 | + } else { |
|
667 | + $location = "{$this->_host}:{$this->_port}"; |
|
668 | + } |
|
640 | 669 | |
641 | 670 | $errstr = trim ( $errstr ); |
642 | 671 | $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; |
@@ -689,8 +718,9 @@ discard block |
||
689 | 718 | } |
690 | 719 | } |
691 | 720 | } |
692 | - if ( $this->_socket === false ) |
|
693 | - fclose ( $fp ); |
|
721 | + if ( $this->_socket === false ) { |
|
722 | + fclose ( $fp ); |
|
723 | + } |
|
694 | 724 | |
695 | 725 | // check response |
696 | 726 | $read = strlen ( $response ); |
@@ -750,10 +780,12 @@ discard block |
||
750 | 780 | assert ( $max>=0 ); |
751 | 781 | $this->_offset = $offset; |
752 | 782 | $this->_limit = $limit; |
753 | - if ( $max>0 ) |
|
754 | - $this->_maxmatches = $max; |
|
755 | - if ( $cutoff>0 ) |
|
756 | - $this->_cutoff = $cutoff; |
|
783 | + if ( $max>0 ) { |
|
784 | + $this->_maxmatches = $max; |
|
785 | + } |
|
786 | + if ( $cutoff>0 ) { |
|
787 | + $this->_cutoff = $cutoff; |
|
788 | + } |
|
757 | 789 | } |
758 | 790 | |
759 | 791 | /// set maximum query time, in milliseconds, per-index |
@@ -857,8 +889,9 @@ discard block |
||
857 | 889 | |
858 | 890 | if ( is_array($values) && count($values) ) |
859 | 891 | { |
860 | - foreach ( $values as $value ) |
|
861 | - assert ( is_numeric($value) ); |
|
892 | + foreach ( $values as $value ) { |
|
893 | + assert ( is_numeric($value) ); |
|
894 | + } |
|
862 | 895 | |
863 | 896 | $this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values ); |
864 | 897 | } |
@@ -987,18 +1020,32 @@ discard block |
||
987 | 1020 | assert ( isset ( $flag_name, $known_names ) ); |
988 | 1021 | assert ( in_array( $flag_value, $flags[$flag_name], true ) || ( $flag_name=="max_predicted_time" && is_int ( $flag_value ) && $flag_value>=0 ) ); |
989 | 1022 | |
990 | - if ( $flag_name=="reverse_scan" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 0, $flag_value==1 ); |
|
991 | - if ( $flag_name=="sort_method" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 1, $flag_value=="kbuffer" ); |
|
1023 | + if ( $flag_name=="reverse_scan" ) { |
|
1024 | + $this->_query_flags = sphSetBit ( $this->_query_flags, 0, $flag_value==1 ); |
|
1025 | + } |
|
1026 | + if ( $flag_name=="sort_method" ) { |
|
1027 | + $this->_query_flags = sphSetBit ( $this->_query_flags, 1, $flag_value=="kbuffer" ); |
|
1028 | + } |
|
992 | 1029 | if ( $flag_name=="max_predicted_time" ) |
993 | 1030 | { |
994 | 1031 | $this->_query_flags = sphSetBit ( $this->_query_flags, 2, $flag_value>0 ); |
995 | 1032 | $this->_predictedtime = (int)$flag_value; |
996 | 1033 | } |
997 | - if ( $flag_name=="boolean_simplify" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 3, $flag_value ); |
|
998 | - if ( $flag_name=="idf" && ( $flag_value=="normalized" || $flag_value=="plain" ) ) $this->_query_flags = sphSetBit ( $this->_query_flags, 4, $flag_value=="plain" ); |
|
999 | - if ( $flag_name=="global_idf" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 5, $flag_value ); |
|
1000 | - if ( $flag_name=="idf" && ( $flag_value=="tfidf_normalized" || $flag_value=="tfidf_unnormalized" ) ) $this->_query_flags = sphSetBit ( $this->_query_flags, 6, $flag_value=="tfidf_normalized" ); |
|
1001 | - if ( $flag_name=="low_priority" ) $this->_query_flags = sphSetBit ( $this->_query_flags, 8, $flag_value ); |
|
1034 | + if ( $flag_name=="boolean_simplify" ) { |
|
1035 | + $this->_query_flags = sphSetBit ( $this->_query_flags, 3, $flag_value ); |
|
1036 | + } |
|
1037 | + if ( $flag_name=="idf" && ( $flag_value=="normalized" || $flag_value=="plain" ) ) { |
|
1038 | + $this->_query_flags = sphSetBit ( $this->_query_flags, 4, $flag_value=="plain" ); |
|
1039 | + } |
|
1040 | + if ( $flag_name=="global_idf" ) { |
|
1041 | + $this->_query_flags = sphSetBit ( $this->_query_flags, 5, $flag_value ); |
|
1042 | + } |
|
1043 | + if ( $flag_name=="idf" && ( $flag_value=="tfidf_normalized" || $flag_value=="tfidf_unnormalized" ) ) { |
|
1044 | + $this->_query_flags = sphSetBit ( $this->_query_flags, 6, $flag_value=="tfidf_normalized" ); |
|
1045 | + } |
|
1046 | + if ( $flag_name=="low_priority" ) { |
|
1047 | + $this->_query_flags = sphSetBit ( $this->_query_flags, 8, $flag_value ); |
|
1048 | + } |
|
1002 | 1049 | } |
1003 | 1050 | |
1004 | 1051 | /// set outer order by parameters |
@@ -1067,15 +1114,18 @@ discard block |
||
1067 | 1114 | $results = $this->RunQueries (); |
1068 | 1115 | $this->_reqs = array (); // just in case it failed too early |
1069 | 1116 | |
1070 | - if ( !is_array($results) ) |
|
1071 | - return false; // probably network error; error message should be already filled |
|
1117 | + if ( !is_array($results) ) { |
|
1118 | + return false; |
|
1119 | + } |
|
1120 | + // probably network error; error message should be already filled |
|
1072 | 1121 | |
1073 | 1122 | $this->_error = $results[0]["error"]; |
1074 | 1123 | $this->_warning = $results[0]["warning"]; |
1075 | - if ( $results[0]["status"]==SEARCHD_ERROR ) |
|
1076 | - return false; |
|
1077 | - else |
|
1078 | - return $results[0]; |
|
1124 | + if ( $results[0]["status"]==SEARCHD_ERROR ) { |
|
1125 | + return false; |
|
1126 | + } else { |
|
1127 | + return $results[0]; |
|
1128 | + } |
|
1079 | 1129 | } |
1080 | 1130 | |
1081 | 1131 | /// helper to pack floats in network byte order |
@@ -1095,14 +1145,16 @@ discard block |
||
1095 | 1145 | |
1096 | 1146 | // build request |
1097 | 1147 | $req = pack ( "NNNNN", $this->_query_flags, $this->_offset, $this->_limit, $this->_mode, $this->_ranker ); |
1098 | - if ( $this->_ranker==SPH_RANK_EXPR ) |
|
1099 | - $req .= pack ( "N", strlen($this->_rankexpr) ) . $this->_rankexpr; |
|
1148 | + if ( $this->_ranker==SPH_RANK_EXPR ) { |
|
1149 | + $req .= pack ( "N", strlen($this->_rankexpr) ) . $this->_rankexpr; |
|
1150 | + } |
|
1100 | 1151 | $req .= pack ( "N", $this->_sort ); // (deprecated) sort mode |
1101 | 1152 | $req .= pack ( "N", strlen($this->_sortby) ) . $this->_sortby; |
1102 | 1153 | $req .= pack ( "N", strlen($query) ) . $query; // query itself |
1103 | 1154 | $req .= pack ( "N", count($this->_weights) ); // weights |
1104 | - foreach ( $this->_weights as $weight ) |
|
1105 | - $req .= pack ( "N", (int)$weight ); |
|
1155 | + foreach ( $this->_weights as $weight ) { |
|
1156 | + $req .= pack ( "N", (int)$weight ); |
|
1157 | + } |
|
1106 | 1158 | $req .= pack ( "N", strlen($index) ) . $index; // indexes |
1107 | 1159 | $req .= pack ( "N", 1 ); // id64 range marker |
1108 | 1160 | $req .= sphPackU64 ( $this->_min_id ) . sphPackU64 ( $this->_max_id ); // id64 range |
@@ -1117,8 +1169,9 @@ discard block |
||
1117 | 1169 | { |
1118 | 1170 | case SPH_FILTER_VALUES: |
1119 | 1171 | $req .= pack ( "N", count($filter["values"]) ); |
1120 | - foreach ( $filter["values"] as $value ) |
|
1121 | - $req .= sphPackI64 ( $value ); |
|
1172 | + foreach ( $filter["values"] as $value ) { |
|
1173 | + $req .= sphPackI64 ( $value ); |
|
1174 | + } |
|
1122 | 1175 | break; |
1123 | 1176 | |
1124 | 1177 | case SPH_FILTER_RANGE: |
@@ -1161,16 +1214,18 @@ discard block |
||
1161 | 1214 | |
1162 | 1215 | // per-index weights |
1163 | 1216 | $req .= pack ( "N", count($this->_indexweights) ); |
1164 | - foreach ( $this->_indexweights as $idx=>$weight ) |
|
1165 | - $req .= pack ( "N", strlen($idx) ) . $idx . pack ( "N", $weight ); |
|
1217 | + foreach ( $this->_indexweights as $idx=>$weight ) { |
|
1218 | + $req .= pack ( "N", strlen($idx) ) . $idx . pack ( "N", $weight ); |
|
1219 | + } |
|
1166 | 1220 | |
1167 | 1221 | // max query time |
1168 | 1222 | $req .= pack ( "N", $this->_maxquerytime ); |
1169 | 1223 | |
1170 | 1224 | // per-field weights |
1171 | 1225 | $req .= pack ( "N", count($this->_fieldweights) ); |
1172 | - foreach ( $this->_fieldweights as $field=>$weight ) |
|
1173 | - $req .= pack ( "N", strlen($field) ) . $field . pack ( "N", $weight ); |
|
1226 | + foreach ( $this->_fieldweights as $field=>$weight ) { |
|
1227 | + $req .= pack ( "N", strlen($field) ) . $field . pack ( "N", $weight ); |
|
1228 | + } |
|
1174 | 1229 | |
1175 | 1230 | // comment |
1176 | 1231 | $req .= pack ( "N", strlen($comment) ) . $comment; |
@@ -1200,15 +1255,17 @@ discard block |
||
1200 | 1255 | $req .= pack ( "N", strlen($this->_select) ) . $this->_select; |
1201 | 1256 | |
1202 | 1257 | // max_predicted_time |
1203 | - if ( $this->_predictedtime>0 ) |
|
1204 | - $req .= pack ( "N", (int)$this->_predictedtime ); |
|
1258 | + if ( $this->_predictedtime>0 ) { |
|
1259 | + $req .= pack ( "N", (int)$this->_predictedtime ); |
|
1260 | + } |
|
1205 | 1261 | |
1206 | 1262 | $req .= pack ( "N", strlen($this->_outerorderby) ) . $this->_outerorderby; |
1207 | 1263 | $req .= pack ( "NN", $this->_outeroffset, $this->_outerlimit ); |
1208 | - if ( $this->_hasouter ) |
|
1209 | - $req .= pack ( "N", 1 ); |
|
1210 | - else |
|
1211 | - $req .= pack ( "N", 0 ); |
|
1264 | + if ( $this->_hasouter ) { |
|
1265 | + $req .= pack ( "N", 1 ); |
|
1266 | + } else { |
|
1267 | + $req .= pack ( "N", 0 ); |
|
1268 | + } |
|
1212 | 1269 | |
1213 | 1270 | // mbstring workaround |
1214 | 1271 | $this->_MBPop (); |
@@ -1327,8 +1384,7 @@ discard block |
||
1327 | 1384 | { |
1328 | 1385 | $doc = sphUnpackU64 ( substr ( $response, $p, 8 ) ); $p += 8; |
1329 | 1386 | list(,$weight) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; |
1330 | - } |
|
1331 | - else |
|
1387 | + } else |
|
1332 | 1388 | { |
1333 | 1389 | list ( $doc, $weight ) = array_values ( unpack ( "N*N*", |
1334 | 1390 | substr ( $response, $p, 8 ) ) ); |
@@ -1338,10 +1394,11 @@ discard block |
||
1338 | 1394 | $weight = sprintf ( "%u", $weight ); |
1339 | 1395 | |
1340 | 1396 | // create match entry |
1341 | - if ( $this->_arrayresult ) |
|
1342 | - $result["matches"][$idx] = array ( "id"=>$doc, "weight"=>$weight ); |
|
1343 | - else |
|
1344 | - $result["matches"][$doc]["weight"] = $weight; |
|
1397 | + if ( $this->_arrayresult ) { |
|
1398 | + $result["matches"][$idx] = array ( "id"=>$doc, "weight"=>$weight ); |
|
1399 | + } else { |
|
1400 | + $result["matches"][$doc]["weight"] = $weight; |
|
1401 | + } |
|
1345 | 1402 | |
1346 | 1403 | // parse and create attributes |
1347 | 1404 | $attrvals = array (); |
@@ -1397,10 +1454,11 @@ discard block |
||
1397 | 1454 | } |
1398 | 1455 | } |
1399 | 1456 | |
1400 | - if ( $this->_arrayresult ) |
|
1401 | - $result["matches"][$idx]["attrs"] = $attrvals; |
|
1402 | - else |
|
1403 | - $result["matches"][$doc]["attrs"] = $attrvals; |
|
1457 | + if ( $this->_arrayresult ) { |
|
1458 | + $result["matches"][$idx]["attrs"] = $attrvals; |
|
1459 | + } else { |
|
1460 | + $result["matches"][$doc]["attrs"] = $attrvals; |
|
1461 | + } |
|
1404 | 1462 | } |
1405 | 1463 | |
1406 | 1464 | list ( $total, $total_found, $msecs, $words ) = |
@@ -1451,26 +1509,66 @@ discard block |
||
1451 | 1509 | // fixup options |
1452 | 1510 | ///////////////// |
1453 | 1511 | |
1454 | - if ( !isset($opts["before_match"]) ) $opts["before_match"] = "<b>"; |
|
1455 | - if ( !isset($opts["after_match"]) ) $opts["after_match"] = "</b>"; |
|
1456 | - if ( !isset($opts["chunk_separator"]) ) $opts["chunk_separator"] = " ... "; |
|
1457 | - if ( !isset($opts["limit"]) ) $opts["limit"] = 256; |
|
1458 | - if ( !isset($opts["limit_passages"]) ) $opts["limit_passages"] = 0; |
|
1459 | - if ( !isset($opts["limit_words"]) ) $opts["limit_words"] = 0; |
|
1460 | - if ( !isset($opts["around"]) ) $opts["around"] = 5; |
|
1461 | - if ( !isset($opts["exact_phrase"]) ) $opts["exact_phrase"] = false; |
|
1462 | - if ( !isset($opts["single_passage"]) ) $opts["single_passage"] = false; |
|
1463 | - if ( !isset($opts["use_boundaries"]) ) $opts["use_boundaries"] = false; |
|
1464 | - if ( !isset($opts["weight_order"]) ) $opts["weight_order"] = false; |
|
1465 | - if ( !isset($opts["query_mode"]) ) $opts["query_mode"] = false; |
|
1466 | - if ( !isset($opts["force_all_words"]) ) $opts["force_all_words"] = false; |
|
1467 | - if ( !isset($opts["start_passage_id"]) ) $opts["start_passage_id"] = 1; |
|
1468 | - if ( !isset($opts["load_files"]) ) $opts["load_files"] = false; |
|
1469 | - if ( !isset($opts["html_strip_mode"]) ) $opts["html_strip_mode"] = "index"; |
|
1470 | - if ( !isset($opts["allow_empty"]) ) $opts["allow_empty"] = false; |
|
1471 | - if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none"; |
|
1472 | - if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false; |
|
1473 | - if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false; |
|
1512 | + if ( !isset($opts["before_match"]) ) { |
|
1513 | + $opts["before_match"] = "<b>"; |
|
1514 | + } |
|
1515 | + if ( !isset($opts["after_match"]) ) { |
|
1516 | + $opts["after_match"] = "</b>"; |
|
1517 | + } |
|
1518 | + if ( !isset($opts["chunk_separator"]) ) { |
|
1519 | + $opts["chunk_separator"] = " ... "; |
|
1520 | + } |
|
1521 | + if ( !isset($opts["limit"]) ) { |
|
1522 | + $opts["limit"] = 256; |
|
1523 | + } |
|
1524 | + if ( !isset($opts["limit_passages"]) ) { |
|
1525 | + $opts["limit_passages"] = 0; |
|
1526 | + } |
|
1527 | + if ( !isset($opts["limit_words"]) ) { |
|
1528 | + $opts["limit_words"] = 0; |
|
1529 | + } |
|
1530 | + if ( !isset($opts["around"]) ) { |
|
1531 | + $opts["around"] = 5; |
|
1532 | + } |
|
1533 | + if ( !isset($opts["exact_phrase"]) ) { |
|
1534 | + $opts["exact_phrase"] = false; |
|
1535 | + } |
|
1536 | + if ( !isset($opts["single_passage"]) ) { |
|
1537 | + $opts["single_passage"] = false; |
|
1538 | + } |
|
1539 | + if ( !isset($opts["use_boundaries"]) ) { |
|
1540 | + $opts["use_boundaries"] = false; |
|
1541 | + } |
|
1542 | + if ( !isset($opts["weight_order"]) ) { |
|
1543 | + $opts["weight_order"] = false; |
|
1544 | + } |
|
1545 | + if ( !isset($opts["query_mode"]) ) { |
|
1546 | + $opts["query_mode"] = false; |
|
1547 | + } |
|
1548 | + if ( !isset($opts["force_all_words"]) ) { |
|
1549 | + $opts["force_all_words"] = false; |
|
1550 | + } |
|
1551 | + if ( !isset($opts["start_passage_id"]) ) { |
|
1552 | + $opts["start_passage_id"] = 1; |
|
1553 | + } |
|
1554 | + if ( !isset($opts["load_files"]) ) { |
|
1555 | + $opts["load_files"] = false; |
|
1556 | + } |
|
1557 | + if ( !isset($opts["html_strip_mode"]) ) { |
|
1558 | + $opts["html_strip_mode"] = "index"; |
|
1559 | + } |
|
1560 | + if ( !isset($opts["allow_empty"]) ) { |
|
1561 | + $opts["allow_empty"] = false; |
|
1562 | + } |
|
1563 | + if ( !isset($opts["passage_boundary"]) ) { |
|
1564 | + $opts["passage_boundary"] = "none"; |
|
1565 | + } |
|
1566 | + if ( !isset($opts["emit_zones"]) ) { |
|
1567 | + $opts["emit_zones"] = false; |
|
1568 | + } |
|
1569 | + if ( !isset($opts["load_files_scattered"]) ) { |
|
1570 | + $opts["load_files_scattered"] = false; |
|
1571 | + } |
|
1474 | 1572 | |
1475 | 1573 | |
1476 | 1574 | ///////////////// |
@@ -1479,16 +1577,36 @@ discard block |
||
1479 | 1577 | |
1480 | 1578 | // v.1.2 req |
1481 | 1579 | $flags = 1; // remove spaces |
1482 | - if ( $opts["exact_phrase"] ) $flags |= 2; |
|
1483 | - if ( $opts["single_passage"] ) $flags |= 4; |
|
1484 | - if ( $opts["use_boundaries"] ) $flags |= 8; |
|
1485 | - if ( $opts["weight_order"] ) $flags |= 16; |
|
1486 | - if ( $opts["query_mode"] ) $flags |= 32; |
|
1487 | - if ( $opts["force_all_words"] ) $flags |= 64; |
|
1488 | - if ( $opts["load_files"] ) $flags |= 128; |
|
1489 | - if ( $opts["allow_empty"] ) $flags |= 256; |
|
1490 | - if ( $opts["emit_zones"] ) $flags |= 512; |
|
1491 | - if ( $opts["load_files_scattered"] ) $flags |= 1024; |
|
1580 | + if ( $opts["exact_phrase"] ) { |
|
1581 | + $flags |= 2; |
|
1582 | + } |
|
1583 | + if ( $opts["single_passage"] ) { |
|
1584 | + $flags |= 4; |
|
1585 | + } |
|
1586 | + if ( $opts["use_boundaries"] ) { |
|
1587 | + $flags |= 8; |
|
1588 | + } |
|
1589 | + if ( $opts["weight_order"] ) { |
|
1590 | + $flags |= 16; |
|
1591 | + } |
|
1592 | + if ( $opts["query_mode"] ) { |
|
1593 | + $flags |= 32; |
|
1594 | + } |
|
1595 | + if ( $opts["force_all_words"] ) { |
|
1596 | + $flags |= 64; |
|
1597 | + } |
|
1598 | + if ( $opts["load_files"] ) { |
|
1599 | + $flags |= 128; |
|
1600 | + } |
|
1601 | + if ( $opts["allow_empty"] ) { |
|
1602 | + $flags |= 256; |
|
1603 | + } |
|
1604 | + if ( $opts["emit_zones"] ) { |
|
1605 | + $flags |= 512; |
|
1606 | + } |
|
1607 | + if ( $opts["load_files_scattered"] ) { |
|
1608 | + $flags |= 1024; |
|
1609 | + } |
|
1492 | 1610 | $req = pack ( "NN", 0, $flags ); // mode=0, flags=$flags |
1493 | 1611 | $req .= pack ( "N", strlen($index) ) . $index; // req index |
1494 | 1612 | $req .= pack ( "N", strlen($words) ) . $words; // req words |
@@ -1656,8 +1774,9 @@ discard block |
||
1656 | 1774 | assert ( is_bool($ignorenonexistent) ); |
1657 | 1775 | |
1658 | 1776 | assert ( is_array($attrs) ); |
1659 | - foreach ( $attrs as $attr ) |
|
1660 | - assert ( is_string($attr) ); |
|
1777 | + foreach ( $attrs as $attr ) { |
|
1778 | + assert ( is_string($attr) ); |
|
1779 | + } |
|
1661 | 1780 | |
1662 | 1781 | assert ( is_array($values) ); |
1663 | 1782 | foreach ( $values as $id=>$entry ) |
@@ -1670,10 +1789,12 @@ discard block |
||
1670 | 1789 | if ( $mva ) |
1671 | 1790 | { |
1672 | 1791 | assert ( is_array($v) ); |
1673 | - foreach ( $v as $vv ) |
|
1674 | - assert ( is_int($vv) ); |
|
1675 | - } else |
|
1676 | - assert ( is_int($v) ); |
|
1792 | + foreach ( $v as $vv ) { |
|
1793 | + assert ( is_int($vv) ); |
|
1794 | + } |
|
1795 | + } else { |
|
1796 | + assert ( is_int($v) ); |
|
1797 | + } |
|
1677 | 1798 | } |
1678 | 1799 | } |
1679 | 1800 | |
@@ -1696,9 +1817,10 @@ discard block |
||
1696 | 1817 | foreach ( $entry as $v ) |
1697 | 1818 | { |
1698 | 1819 | $req .= pack ( "N", $mva ? count($v) : $v ); |
1699 | - if ( $mva ) |
|
1700 | - foreach ( $v as $vv ) |
|
1820 | + if ( $mva ) { |
|
1821 | + foreach ( $v as $vv ) |
|
1701 | 1822 | $req .= pack ( "N", $vv ); |
1823 | + } |
|
1702 | 1824 | } |
1703 | 1825 | } |
1704 | 1826 | |
@@ -1740,13 +1862,15 @@ discard block |
||
1740 | 1862 | $this->_error = 'already connected'; |
1741 | 1863 | return false; |
1742 | 1864 | } |
1743 | - if ( !$fp = $this->_Connect() ) |
|
1744 | - return false; |
|
1865 | + if ( !$fp = $this->_Connect() ) { |
|
1866 | + return false; |
|
1867 | + } |
|
1745 | 1868 | |
1746 | 1869 | // command, command version = 0, body length = 4, body = 1 |
1747 | 1870 | $req = pack ( "nnNN", SEARCHD_COMMAND_PERSIST, 0, 4, 1 ); |
1748 | - if ( !$this->_Send ( $fp, $req, 12 ) ) |
|
1749 | - return false; |
|
1871 | + if ( !$this->_Send ( $fp, $req, 12 ) ) { |
|
1872 | + return false; |
|
1873 | + } |
|
1750 | 1874 | |
1751 | 1875 | $this->_socket = $fp; |
1752 | 1876 | return true; |
@@ -1794,8 +1918,10 @@ discard block |
||
1794 | 1918 | list ( $rows, $cols ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8; |
1795 | 1919 | |
1796 | 1920 | $res = array(); |
1797 | - for ( $i=0; $i<$rows; $i++ ) |
|
1798 | - for ( $j=0; $j<$cols; $j++ ) |
|
1921 | + for ( $i=0; $i<$rows; $i++ ) { |
|
1922 | + for ( $j=0; |
|
1923 | + } |
|
1924 | + $j<$cols; $j++ ) |
|
1799 | 1925 | { |
1800 | 1926 | list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; |
1801 | 1927 | $res[$i][] = substr ( $response, $p, $len ); $p += $len; |
@@ -1827,10 +1953,11 @@ discard block |
||
1827 | 1953 | } |
1828 | 1954 | |
1829 | 1955 | $tag = -1; |
1830 | - if ( strlen($response)==4 ) |
|
1831 | - list(,$tag) = unpack ( "N*", $response ); |
|
1832 | - else |
|
1833 | - $this->_error = "unexpected response length"; |
|
1956 | + if ( strlen($response)==4 ) { |
|
1957 | + list(,$tag) = unpack ( "N*", $response ); |
|
1958 | + } else { |
|
1959 | + $this->_error = "unexpected response length"; |
|
1960 | + } |
|
1834 | 1961 | |
1835 | 1962 | $this->_MBPop (); |
1836 | 1963 | return $tag; |