@@ -133,14 +133,16 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | // x32, int |
136 | - if (is_int($v)) |
|
137 | - return pack("NN", $v < 0 ? -1 : 0, $v); |
|
136 | + if (is_int($v)) { |
|
137 | + return pack("NN", $v < 0 ? -1 : 0, $v); |
|
138 | + } |
|
138 | 139 | |
139 | 140 | // x32, bcmath |
140 | 141 | if (function_exists("bcmul")) |
141 | 142 | { |
142 | - if (bccomp($v, 0) == -1) |
|
143 | - $v = bcadd("18446744073709551616", $v); |
|
143 | + if (bccomp($v, 0) == -1) { |
|
144 | + $v = bcadd("18446744073709551616", $v); |
|
145 | + } |
|
144 | 146 | $h = bcdiv($v, "4294967296", 0); |
145 | 147 | $l = bcmod($v, "4294967296"); |
146 | 148 | return pack("NN", (float) $h, (float) $l); // conversion to float is intentional; int would lose 31st bit |
@@ -158,9 +160,9 @@ discard block |
||
158 | 160 | |
159 | 161 | if ($v < 0) |
160 | 162 | { |
161 | - if ($l == 0) |
|
162 | - $h = 4294967296.0 - $h; |
|
163 | - else |
|
163 | + if ($l == 0) { |
|
164 | + $h = 4294967296.0 - $h; |
|
165 | + } else |
|
164 | 166 | { |
165 | 167 | $h = 4294967295.0 - $h; |
166 | 168 | $l = 4294967296.0 - $l; |
@@ -180,8 +182,9 @@ discard block |
||
180 | 182 | assert($v >= 0); |
181 | 183 | |
182 | 184 | // x64, int |
183 | - if (is_int($v)) |
|
184 | - return pack("NN", $v >> 32, $v & 0xFFFFFFFF); |
|
185 | + if (is_int($v)) { |
|
186 | + return pack("NN", $v >> 32, $v & 0xFFFFFFFF); |
|
187 | + } |
|
185 | 188 | |
186 | 189 | // x64, bcmath |
187 | 190 | if (function_exists("bcmul")) |
@@ -204,8 +207,9 @@ discard block |
||
204 | 207 | } |
205 | 208 | |
206 | 209 | // x32, int |
207 | - if (is_int($v)) |
|
208 | - return pack("NN", 0, $v); |
|
210 | + if (is_int($v)) { |
|
211 | + return pack("NN", 0, $v); |
|
212 | + } |
|
209 | 213 | |
210 | 214 | // x32, bcmath |
211 | 215 | if (function_exists("bcmul")) |
@@ -235,16 +239,23 @@ discard block |
||
235 | 239 | |
236 | 240 | if (PHP_INT_SIZE >= 8) |
237 | 241 | { |
238 | - if ($hi < 0) $hi += (1 << 32); // because php 5.2.2 to 5.2.5 is totally fucked up again |
|
239 | - if ($lo < 0) $lo += (1 << 32); |
|
242 | + if ($hi < 0) { |
|
243 | + $hi += (1 << 32); |
|
244 | + } |
|
245 | + // because php 5.2.2 to 5.2.5 is totally fucked up again |
|
246 | + if ($lo < 0) { |
|
247 | + $lo += (1 << 32); |
|
248 | + } |
|
240 | 249 | |
241 | 250 | // x64, int |
242 | - if ($hi <= 2147483647) |
|
243 | - return ($hi << 32) + $lo; |
|
251 | + if ($hi <= 2147483647) { |
|
252 | + return ($hi << 32) + $lo; |
|
253 | + } |
|
244 | 254 | |
245 | 255 | // x64, bcmath |
246 | - if (function_exists("bcmul")) |
|
247 | - return bcadd($lo, bcmul($hi, "4294967296")); |
|
256 | + if (function_exists("bcmul")) { |
|
257 | + return bcadd($lo, bcmul($hi, "4294967296")); |
|
258 | + } |
|
248 | 259 | |
249 | 260 | // x64, no-bcmath |
250 | 261 | $C = 100000; |
@@ -256,16 +267,18 @@ discard block |
||
256 | 267 | $l = $l % $C; |
257 | 268 | } |
258 | 269 | |
259 | - if ($h == 0) |
|
260 | - return $l; |
|
270 | + if ($h == 0) { |
|
271 | + return $l; |
|
272 | + } |
|
261 | 273 | return sprintf("%d%05d", $h, $l); |
262 | 274 | } |
263 | 275 | |
264 | 276 | // x32, int |
265 | 277 | if ($hi == 0) |
266 | 278 | { |
267 | - if ($lo > 0) |
|
268 | - return $lo; |
|
279 | + if ($lo > 0) { |
|
280 | + return $lo; |
|
281 | + } |
|
269 | 282 | return sprintf("%u", $lo); |
270 | 283 | } |
271 | 284 | |
@@ -273,8 +286,9 @@ discard block |
||
273 | 286 | $lo = sprintf("%u", $lo); |
274 | 287 | |
275 | 288 | // x32, bcmath |
276 | - if (function_exists("bcmul")) |
|
277 | - return bcadd($lo, bcmul($hi, "4294967296")); |
|
289 | + if (function_exists("bcmul")) { |
|
290 | + return bcadd($lo, bcmul($hi, "4294967296")); |
|
291 | + } |
|
278 | 292 | |
279 | 293 | // x32, no-bcmath |
280 | 294 | $hi = (float) $hi; |
@@ -289,8 +303,9 @@ discard block |
||
289 | 303 | |
290 | 304 | $h = sprintf("%.0f", $h); |
291 | 305 | $l = sprintf("%07.0f", $l); |
292 | - if ($h == "0") |
|
293 | - return sprintf("%.0f", (float) $l); |
|
306 | + if ($h == "0") { |
|
307 | + return sprintf("%.0f", (float) $l); |
|
308 | + } |
|
294 | 309 | return $h.$l; |
295 | 310 | } |
296 | 311 | |
@@ -302,8 +317,13 @@ discard block |
||
302 | 317 | // x64 |
303 | 318 | if (PHP_INT_SIZE >= 8) |
304 | 319 | { |
305 | - if ($hi < 0) $hi += (1 << 32); // because php 5.2.2 to 5.2.5 is totally fucked up again |
|
306 | - if ($lo < 0) $lo += (1 << 32); |
|
320 | + if ($hi < 0) { |
|
321 | + $hi += (1 << 32); |
|
322 | + } |
|
323 | + // because php 5.2.2 to 5.2.5 is totally fucked up again |
|
324 | + if ($lo < 0) { |
|
325 | + $lo += (1 << 32); |
|
326 | + } |
|
307 | 327 | |
308 | 328 | return ($hi << 32) + $lo; |
309 | 329 | } |
@@ -311,15 +331,17 @@ discard block |
||
311 | 331 | // x32, int |
312 | 332 | if ($hi == 0) |
313 | 333 | { |
314 | - if ($lo > 0) |
|
315 | - return $lo; |
|
334 | + if ($lo > 0) { |
|
335 | + return $lo; |
|
336 | + } |
|
316 | 337 | return sprintf("%u", $lo); |
317 | 338 | } |
318 | 339 | // x32, int |
319 | 340 | elseif ($hi == -1) |
320 | 341 | { |
321 | - if ($lo < 0) |
|
322 | - return $lo; |
|
342 | + if ($lo < 0) { |
|
343 | + return $lo; |
|
344 | + } |
|
323 | 345 | return sprintf("%.0f", $lo - 4294967296.0); |
324 | 346 | } |
325 | 347 | |
@@ -337,8 +359,9 @@ discard block |
||
337 | 359 | $lo = sprintf("%u", $lo); |
338 | 360 | |
339 | 361 | // x32, bcmath |
340 | - if (function_exists("bcmul")) |
|
341 | - return $neg.bcadd(bcadd($lo, bcmul($hi, "4294967296")), $c); |
|
362 | + if (function_exists("bcmul")) { |
|
363 | + return $neg.bcadd(bcadd($lo, bcmul($hi, "4294967296")), $c); |
|
364 | + } |
|
342 | 365 | |
343 | 366 | // x32, no-bcmath |
344 | 367 | $hi = (float) $hi; |
@@ -358,8 +381,9 @@ discard block |
||
358 | 381 | |
359 | 382 | $h = sprintf("%.0f", $h); |
360 | 383 | $l = sprintf("%07.0f", $l); |
361 | - if ($h == "0") |
|
362 | - return $neg.sprintf("%.0f", (float) $l); |
|
384 | + if ($h == "0") { |
|
385 | + return $neg.sprintf("%.0f", (float) $l); |
|
386 | + } |
|
363 | 387 | return $neg.$h.$l; |
364 | 388 | } |
365 | 389 | |
@@ -369,10 +393,11 @@ discard block |
||
369 | 393 | if (PHP_INT_SIZE >= 8) |
370 | 394 | { |
371 | 395 | // x64 route, workaround broken unpack() in 5.2.2+ |
372 | - if ($value < 0) $value += (1 << 32); |
|
396 | + if ($value < 0) { |
|
397 | + $value += (1 << 32); |
|
398 | + } |
|
373 | 399 | return $value; |
374 | - } |
|
375 | - else |
|
400 | + } else |
|
376 | 401 | { |
377 | 402 | // x32 route, workaround php signed/unsigned braindamage |
378 | 403 | return sprintf("%u", $value); |
@@ -470,8 +495,9 @@ discard block |
||
470 | 495 | |
471 | 496 | public function __destruct() |
472 | 497 | { |
473 | - if ($this->_socket !== false) |
|
474 | - fclose($this->_socket); |
|
498 | + if ($this->_socket !== false) { |
|
499 | + fclose($this->_socket); |
|
500 | + } |
|
475 | 501 | } |
476 | 502 | |
477 | 503 | /// get last error message (string) |
@@ -577,24 +603,25 @@ discard block |
||
577 | 603 | { |
578 | 604 | $host = $this->_path; |
579 | 605 | $port = 0; |
580 | - } |
|
581 | - else |
|
606 | + } else |
|
582 | 607 | { |
583 | 608 | $host = $this->_host; |
584 | 609 | $port = $this->_port; |
585 | 610 | } |
586 | 611 | |
587 | - if ($this->_timeout <= 0) |
|
588 | - $fp = @fsockopen($host, $port, $errno, $errstr); |
|
589 | - else |
|
590 | - $fp = @fsockopen($host, $port, $errno, $errstr, $this->_timeout); |
|
612 | + if ($this->_timeout <= 0) { |
|
613 | + $fp = @fsockopen($host, $port, $errno, $errstr); |
|
614 | + } else { |
|
615 | + $fp = @fsockopen($host, $port, $errno, $errstr, $this->_timeout); |
|
616 | + } |
|
591 | 617 | |
592 | 618 | if (!$fp) |
593 | 619 | { |
594 | - if ($this->_path) |
|
595 | - $location = $this->_path; |
|
596 | - else |
|
597 | - $location = "{$this->_host}:{$this->_port}"; |
|
620 | + if ($this->_path) { |
|
621 | + $location = $this->_path; |
|
622 | + } else { |
|
623 | + $location = "{$this->_host}:{$this->_port}"; |
|
624 | + } |
|
598 | 625 | |
599 | 626 | $errstr = trim($errstr); |
600 | 627 | $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; |
@@ -647,8 +674,9 @@ discard block |
||
647 | 674 | } |
648 | 675 | } |
649 | 676 | } |
650 | - if ($this->_socket === false) |
|
651 | - fclose($fp); |
|
677 | + if ($this->_socket === false) { |
|
678 | + fclose($fp); |
|
679 | + } |
|
652 | 680 | |
653 | 681 | // check response |
654 | 682 | $read = strlen($response); |
@@ -708,10 +736,12 @@ discard block |
||
708 | 736 | assert($max >= 0); |
709 | 737 | $this->_offset = $offset; |
710 | 738 | $this->_limit = $limit; |
711 | - if ($max > 0) |
|
712 | - $this->_maxmatches = $max; |
|
713 | - if ($cutoff > 0) |
|
714 | - $this->_cutoff = $cutoff; |
|
739 | + if ($max > 0) { |
|
740 | + $this->_maxmatches = $max; |
|
741 | + } |
|
742 | + if ($cutoff > 0) { |
|
743 | + $this->_cutoff = $cutoff; |
|
744 | + } |
|
715 | 745 | } |
716 | 746 | |
717 | 747 | /// set maximum query time, in milliseconds, per-index |
@@ -765,8 +795,9 @@ discard block |
||
765 | 795 | public function SetWeights($weights) |
766 | 796 | { |
767 | 797 | assert(is_array($weights)); |
768 | - foreach ($weights as $weight) |
|
769 | - assert(is_int($weight)); |
|
798 | + foreach ($weights as $weight) { |
|
799 | + assert(is_int($weight)); |
|
800 | + } |
|
770 | 801 | |
771 | 802 | $this->_weights = $weights; |
772 | 803 | } |
@@ -816,8 +847,9 @@ discard block |
||
816 | 847 | |
817 | 848 | if (is_array($values) && count($values)) |
818 | 849 | { |
819 | - foreach ($values as $value) |
|
820 | - assert(is_numeric($value)); |
|
850 | + foreach ($values as $value) { |
|
851 | + assert(is_numeric($value)); |
|
852 | + } |
|
821 | 853 | |
822 | 854 | $this->_filters[] = array("type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values); |
823 | 855 | } |
@@ -1011,8 +1043,9 @@ discard block |
||
1011 | 1043 | { |
1012 | 1044 | case SPH_FILTER_VALUES: |
1013 | 1045 | $req .= pack ( "N", count($filter["values"]) ); |
1014 | - foreach ( $filter["values"] as $value ) |
|
1015 | - $req .= sphPackI64 ( $value ); |
|
1046 | + foreach ( $filter["values"] as $value ) { |
|
1047 | + $req .= sphPackI64 ( $value ); |
|
1048 | + } |
|
1016 | 1049 | break; |
1017 | 1050 | |
1018 | 1051 | case SPH_FILTER_RANGE: |
@@ -1208,8 +1241,7 @@ discard block |
||
1208 | 1241 | { |
1209 | 1242 | $doc = sphUnpackU64(substr($response, $p, 8)); $p += 8; |
1210 | 1243 | list(,$weight) = unpack("N*", substr($response, $p, 4)); $p += 4; |
1211 | - } |
|
1212 | - else |
|
1244 | + } else |
|
1213 | 1245 | { |
1214 | 1246 | list ($doc, $weight) = array_values(unpack("N*N*", |
1215 | 1247 | substr($response, $p, 8))); |
@@ -1219,10 +1251,11 @@ discard block |
||
1219 | 1251 | $weight = sprintf("%u", $weight); |
1220 | 1252 | |
1221 | 1253 | // create match entry |
1222 | - if ($this->_arrayresult) |
|
1223 | - $result["matches"][$idx] = array("id"=>$doc, "weight"=>$weight); |
|
1224 | - else |
|
1225 | - $result["matches"][$doc]["weight"] = $weight; |
|
1254 | + if ($this->_arrayresult) { |
|
1255 | + $result["matches"][$idx] = array("id"=>$doc, "weight"=>$weight); |
|
1256 | + } else { |
|
1257 | + $result["matches"][$doc]["weight"] = $weight; |
|
1258 | + } |
|
1226 | 1259 | |
1227 | 1260 | // parse and create attributes |
1228 | 1261 | $attrvals = array(); |
@@ -1265,10 +1298,11 @@ discard block |
||
1265 | 1298 | } |
1266 | 1299 | } |
1267 | 1300 | |
1268 | - if ($this->_arrayresult) |
|
1269 | - $result["matches"][$idx]["attrs"] = $attrvals; |
|
1270 | - else |
|
1271 | - $result["matches"][$doc]["attrs"] = $attrvals; |
|
1301 | + if ($this->_arrayresult) { |
|
1302 | + $result["matches"][$idx]["attrs"] = $attrvals; |
|
1303 | + } else { |
|
1304 | + $result["matches"][$doc]["attrs"] = $attrvals; |
|
1305 | + } |
|
1272 | 1306 | } |
1273 | 1307 | |
1274 | 1308 | list ($total, $total_found, $msecs, $words) = |
@@ -1319,25 +1353,63 @@ discard block |
||
1319 | 1353 | // fixup options |
1320 | 1354 | ///////////////// |
1321 | 1355 | |
1322 | - if (!isset($opts["before_match"])) $opts["before_match"] = "<b>"; |
|
1323 | - if (!isset($opts["after_match"])) $opts["after_match"] = "</b>"; |
|
1324 | - if (!isset($opts["chunk_separator"])) $opts["chunk_separator"] = " ... "; |
|
1325 | - if (!isset($opts["limit"])) $opts["limit"] = 256; |
|
1326 | - if (!isset($opts["limit_passages"])) $opts["limit_passages"] = 0; |
|
1327 | - if (!isset($opts["limit_words"])) $opts["limit_words"] = 0; |
|
1328 | - if (!isset($opts["around"])) $opts["around"] = 5; |
|
1329 | - if (!isset($opts["exact_phrase"])) $opts["exact_phrase"] = false; |
|
1330 | - if (!isset($opts["single_passage"])) $opts["single_passage"] = false; |
|
1331 | - if (!isset($opts["use_boundaries"])) $opts["use_boundaries"] = false; |
|
1332 | - if (!isset($opts["weight_order"])) $opts["weight_order"] = false; |
|
1333 | - if (!isset($opts["query_mode"])) $opts["query_mode"] = false; |
|
1334 | - if (!isset($opts["force_all_words"])) $opts["force_all_words"] = false; |
|
1335 | - if (!isset($opts["start_passage_id"])) $opts["start_passage_id"] = 1; |
|
1336 | - if (!isset($opts["load_files"])) $opts["load_files"] = false; |
|
1337 | - if (!isset($opts["html_strip_mode"])) $opts["html_strip_mode"] = "index"; |
|
1338 | - if (!isset($opts["allow_empty"])) $opts["allow_empty"] = false; |
|
1339 | - if (!isset($opts["passage_boundary"])) $opts["passage_boundary"] = "none"; |
|
1340 | - if (!isset($opts["emit_zones"])) $opts["emit_zones"] = false; |
|
1356 | + if (!isset($opts["before_match"])) { |
|
1357 | + $opts["before_match"] = "<b>"; |
|
1358 | + } |
|
1359 | + if (!isset($opts["after_match"])) { |
|
1360 | + $opts["after_match"] = "</b>"; |
|
1361 | + } |
|
1362 | + if (!isset($opts["chunk_separator"])) { |
|
1363 | + $opts["chunk_separator"] = " ... "; |
|
1364 | + } |
|
1365 | + if (!isset($opts["limit"])) { |
|
1366 | + $opts["limit"] = 256; |
|
1367 | + } |
|
1368 | + if (!isset($opts["limit_passages"])) { |
|
1369 | + $opts["limit_passages"] = 0; |
|
1370 | + } |
|
1371 | + if (!isset($opts["limit_words"])) { |
|
1372 | + $opts["limit_words"] = 0; |
|
1373 | + } |
|
1374 | + if (!isset($opts["around"])) { |
|
1375 | + $opts["around"] = 5; |
|
1376 | + } |
|
1377 | + if (!isset($opts["exact_phrase"])) { |
|
1378 | + $opts["exact_phrase"] = false; |
|
1379 | + } |
|
1380 | + if (!isset($opts["single_passage"])) { |
|
1381 | + $opts["single_passage"] = false; |
|
1382 | + } |
|
1383 | + if (!isset($opts["use_boundaries"])) { |
|
1384 | + $opts["use_boundaries"] = false; |
|
1385 | + } |
|
1386 | + if (!isset($opts["weight_order"])) { |
|
1387 | + $opts["weight_order"] = false; |
|
1388 | + } |
|
1389 | + if (!isset($opts["query_mode"])) { |
|
1390 | + $opts["query_mode"] = false; |
|
1391 | + } |
|
1392 | + if (!isset($opts["force_all_words"])) { |
|
1393 | + $opts["force_all_words"] = false; |
|
1394 | + } |
|
1395 | + if (!isset($opts["start_passage_id"])) { |
|
1396 | + $opts["start_passage_id"] = 1; |
|
1397 | + } |
|
1398 | + if (!isset($opts["load_files"])) { |
|
1399 | + $opts["load_files"] = false; |
|
1400 | + } |
|
1401 | + if (!isset($opts["html_strip_mode"])) { |
|
1402 | + $opts["html_strip_mode"] = "index"; |
|
1403 | + } |
|
1404 | + if (!isset($opts["allow_empty"])) { |
|
1405 | + $opts["allow_empty"] = false; |
|
1406 | + } |
|
1407 | + if (!isset($opts["passage_boundary"])) { |
|
1408 | + $opts["passage_boundary"] = "none"; |
|
1409 | + } |
|
1410 | + if (!isset($opts["emit_zones"])) { |
|
1411 | + $opts["emit_zones"] = false; |
|
1412 | + } |
|
1341 | 1413 | |
1342 | 1414 | ///////////////// |
1343 | 1415 | // build request |
@@ -1345,15 +1417,33 @@ discard block |
||
1345 | 1417 | |
1346 | 1418 | // v.1.2 req |
1347 | 1419 | $flags = 1; // remove spaces |
1348 | - if ($opts["exact_phrase"]) $flags |= 2; |
|
1349 | - if ($opts["single_passage"]) $flags |= 4; |
|
1350 | - if ($opts["use_boundaries"]) $flags |= 8; |
|
1351 | - if ($opts["weight_order"]) $flags |= 16; |
|
1352 | - if ($opts["query_mode"]) $flags |= 32; |
|
1353 | - if ($opts["force_all_words"]) $flags |= 64; |
|
1354 | - if ($opts["load_files"]) $flags |= 128; |
|
1355 | - if ($opts["allow_empty"]) $flags |= 256; |
|
1356 | - if ($opts["emit_zones"]) $flags |= 512; |
|
1420 | + if ($opts["exact_phrase"]) { |
|
1421 | + $flags |= 2; |
|
1422 | + } |
|
1423 | + if ($opts["single_passage"]) { |
|
1424 | + $flags |= 4; |
|
1425 | + } |
|
1426 | + if ($opts["use_boundaries"]) { |
|
1427 | + $flags |= 8; |
|
1428 | + } |
|
1429 | + if ($opts["weight_order"]) { |
|
1430 | + $flags |= 16; |
|
1431 | + } |
|
1432 | + if ($opts["query_mode"]) { |
|
1433 | + $flags |= 32; |
|
1434 | + } |
|
1435 | + if ($opts["force_all_words"]) { |
|
1436 | + $flags |= 64; |
|
1437 | + } |
|
1438 | + if ($opts["load_files"]) { |
|
1439 | + $flags |= 128; |
|
1440 | + } |
|
1441 | + if ($opts["allow_empty"]) { |
|
1442 | + $flags |= 256; |
|
1443 | + } |
|
1444 | + if ($opts["emit_zones"]) { |
|
1445 | + $flags |= 512; |
|
1446 | + } |
|
1357 | 1447 | $req = pack("NN", 0, $flags); // mode=0, flags=$flags |
1358 | 1448 | $req .= pack("N", strlen($index)).$index; // req index |
1359 | 1449 | $req .= pack("N", strlen($words)).$words; // req words |
@@ -1520,8 +1610,9 @@ discard block |
||
1520 | 1610 | assert(is_bool($mva)); |
1521 | 1611 | |
1522 | 1612 | assert(is_array($attrs)); |
1523 | - foreach ($attrs as $attr) |
|
1524 | - assert(is_string($attr)); |
|
1613 | + foreach ($attrs as $attr) { |
|
1614 | + assert(is_string($attr)); |
|
1615 | + } |
|
1525 | 1616 | |
1526 | 1617 | assert(is_array($values)); |
1527 | 1618 | foreach ($values as $id=>$entry) |
@@ -1534,10 +1625,12 @@ discard block |
||
1534 | 1625 | if ($mva) |
1535 | 1626 | { |
1536 | 1627 | assert(is_array($v)); |
1537 | - foreach ($v as $vv) |
|
1538 | - assert(is_int($vv)); |
|
1539 | - } else |
|
1540 | - assert(is_int($v)); |
|
1628 | + foreach ($v as $vv) { |
|
1629 | + assert(is_int($vv)); |
|
1630 | + } |
|
1631 | + } else { |
|
1632 | + assert(is_int($v)); |
|
1633 | + } |
|
1541 | 1634 | } |
1542 | 1635 | } |
1543 | 1636 | |
@@ -1559,9 +1652,10 @@ discard block |
||
1559 | 1652 | foreach ($entry as $v) |
1560 | 1653 | { |
1561 | 1654 | $req .= pack("N", $mva ? count($v) : $v); |
1562 | - if ($mva) |
|
1563 | - foreach ($v as $vv) |
|
1655 | + if ($mva) { |
|
1656 | + foreach ($v as $vv) |
|
1564 | 1657 | $req .= pack("N", $vv); |
1658 | + } |
|
1565 | 1659 | } |
1566 | 1660 | } |
1567 | 1661 | |
@@ -1603,13 +1697,15 @@ discard block |
||
1603 | 1697 | $this->_error = 'already connected'; |
1604 | 1698 | return false; |
1605 | 1699 | } |
1606 | - if (!$fp = $this->_Connect()) |
|
1607 | - return false; |
|
1700 | + if (!$fp = $this->_Connect()) { |
|
1701 | + return false; |
|
1702 | + } |
|
1608 | 1703 | |
1609 | 1704 | // command, command version = 0, body length = 4, body = 1 |
1610 | 1705 | $req = pack("nnNN", SEARCHD_COMMAND_PERSIST, 0, 4, 1); |
1611 | - if (!$this->_Send($fp, $req, 12)) |
|
1612 | - return false; |
|
1706 | + if (!$this->_Send($fp, $req, 12)) { |
|
1707 | + return false; |
|
1708 | + } |
|
1613 | 1709 | |
1614 | 1710 | $this->_socket = $fp; |
1615 | 1711 | return true; |
@@ -1655,8 +1751,10 @@ discard block |
||
1655 | 1751 | list ($rows, $cols) = array_values(unpack("N*N*", substr($response, $p, 8))); $p += 8; |
1656 | 1752 | |
1657 | 1753 | $res = array(); |
1658 | - for ($i = 0; $i < $rows; $i++) |
|
1659 | - for ($j = 0; $j < $cols; $j++) |
|
1754 | + for ($i = 0; $i < $rows; $i++) { |
|
1755 | + for ($j = 0; |
|
1756 | + } |
|
1757 | + $j < $cols; $j++) |
|
1660 | 1758 | { |
1661 | 1759 | list(,$len) = unpack("N*", substr($response, $p, 4)); $p += 4; |
1662 | 1760 | $res[$i][] = substr($response, $p, $len); $p += $len; |
@@ -1688,10 +1786,11 @@ discard block |
||
1688 | 1786 | } |
1689 | 1787 | |
1690 | 1788 | $tag = -1; |
1691 | - if (strlen($response) == 4) |
|
1692 | - list(,$tag) = unpack("N*", $response); |
|
1693 | - else |
|
1694 | - $this->_error = "unexpected response length"; |
|
1789 | + if (strlen($response) == 4) { |
|
1790 | + list(,$tag) = unpack("N*", $response); |
|
1791 | + } else { |
|
1792 | + $this->_error = "unexpected response length"; |
|
1793 | + } |
|
1695 | 1794 | |
1696 | 1795 | $this->_MBPop(); |
1697 | 1796 | return $tag; |
@@ -498,7 +498,8 @@ |
||
498 | 498 | PluginHost::getInstance()->run_commands($options); |
499 | 499 | |
500 | 500 | if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) { |
501 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
502 | - fclose($lock_handle); |
|
501 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
502 | + fclose($lock_handle); |
|
503 | + } |
|
503 | 504 | } |
504 | 505 | unlink(LOCK_DIRECTORY . "/$lock_filename"); |
@@ -38,7 +38,9 @@ |
||
38 | 38 | // fallback on HTTP parameters |
39 | 39 | if ($input) { |
40 | 40 | $input = json_decode($input, true); |
41 | - if ($input) $_REQUEST = $input; |
|
41 | + if ($input) { |
|
42 | + $_REQUEST = $input; |
|
43 | + } |
|
42 | 44 | } |
43 | 45 | } else { |
44 | 46 | // Accept JSON only |