@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | while ($line = $sth->fetch()) { |
112 | 112 | |
113 | 113 | for ($i = 0; $i < $nest_level; $i++) { |
114 | - $line["title"] = " - " . $line["title"]; |
|
114 | + $line["title"] = " - ".$line["title"]; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | if ($line["num_children"] > 0) { |
123 | 123 | print_feed_multi_select($id, $default_ids, $attributes, |
124 | - $include_all_feeds, $line["id"], $nest_level+1); |
|
124 | + $include_all_feeds, $line["id"], $nest_level + 1); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | while ($fline = $f_sth->fetch()) { |
133 | 133 | $is_selected = (in_array($fline["id"], $default_ids)) ? "selected=\"1\"" : ""; |
134 | 134 | |
135 | - $fline["title"] = " + " . $fline["title"]; |
|
135 | + $fline["title"] = " + ".$fline["title"]; |
|
136 | 136 | |
137 | 137 | for ($i = 0; $i < $nest_level; $i++) { |
138 | - $fline["title"] = " - " . $fline["title"]; |
|
138 | + $fline["title"] = " - ".$fline["title"]; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | printf("<option $is_selected value='%d'>%s</option>", |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | while ($fline = $f_sth->fetch()) { |
157 | 157 | $is_selected = in_array($fline["id"], $default_ids) ? "selected=\"1\"" : ""; |
158 | 158 | |
159 | - $fline["title"] = " + " . $fline["title"]; |
|
159 | + $fline["title"] = " + ".$fline["title"]; |
|
160 | 160 | |
161 | 161 | for ($i = 0; $i < $nest_level; $i++) { |
162 | - $fline["title"] = " - " . $fline["title"]; |
|
162 | + $fline["title"] = " - ".$fline["title"]; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | printf("<option $is_selected value='%d'>%s</option>", |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | } |
220 | 220 | |
221 | 221 | for ($i = 0; $i < $nest_level; $i++) { |
222 | - $line["title"] = " - " . $line["title"]; |
|
222 | + $line["title"] = " - ".$line["title"]; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | if ($line["title"]) { |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | if ($line["num_children"] > 0) { |
231 | 231 | print_feed_cat_select($id, $default_id, $attributes, |
232 | - $include_all_cats, $line["id"], $nest_level+1); |
|
232 | + $include_all_cats, $line["id"], $nest_level + 1); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | if ($entry) { |
323 | 323 | $entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\" |
324 | - href=\"$url\">" . basename($url) . "</a>"; |
|
324 | + href=\"$url\">".basename($url)."</a>"; |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | $entry .= "</div>"; |
@@ -1003,22 +1003,22 @@ discard block |
||
1003 | 1003 | $req .= pack("N", $filter["type"]); |
1004 | 1004 | switch ($filter["type"]) |
1005 | 1005 | { |
1006 | - case SPH_FILTER_VALUES: |
|
1007 | - $req .= pack("N", count($filter["values"])); |
|
1008 | - foreach ($filter["values"] as $value) |
|
1009 | - $req .= sphPackI64($value); |
|
1010 | - break; |
|
1011 | - |
|
1012 | - case SPH_FILTER_RANGE: |
|
1013 | - $req .= sphPackI64($filter["min"]).sphPackI64($filter["max"]); |
|
1014 | - break; |
|
1015 | - |
|
1016 | - case SPH_FILTER_FLOATRANGE: |
|
1017 | - $req .= $this->_PackFloat($filter["min"]).$this->_PackFloat($filter["max"]); |
|
1018 | - break; |
|
1019 | - |
|
1020 | - default: |
|
1021 | - assert(0 && "internal error: unhandled filter type"); |
|
1006 | + case SPH_FILTER_VALUES: |
|
1007 | + $req .= pack("N", count($filter["values"])); |
|
1008 | + foreach ($filter["values"] as $value) |
|
1009 | + $req .= sphPackI64($value); |
|
1010 | + break; |
|
1011 | + |
|
1012 | + case SPH_FILTER_RANGE: |
|
1013 | + $req .= sphPackI64($filter["min"]).sphPackI64($filter["max"]); |
|
1014 | + break; |
|
1015 | + |
|
1016 | + case SPH_FILTER_FLOATRANGE: |
|
1017 | + $req .= $this->_PackFloat($filter["min"]).$this->_PackFloat($filter["max"]); |
|
1018 | + break; |
|
1019 | + |
|
1020 | + default: |
|
1021 | + assert(0 && "internal error: unhandled filter type"); |
|
1022 | 1022 | } |
1023 | 1023 | $req .= pack("N", $filter["exclude"]); |
1024 | 1024 | } |
@@ -1073,9 +1073,9 @@ discard block |
||
1073 | 1073 | $req .= sphPackU64($id); |
1074 | 1074 | switch ($entry["type"]) |
1075 | 1075 | { |
1076 | - case SPH_ATTR_FLOAT: $req .= $this->_PackFloat($val); break; |
|
1077 | - case SPH_ATTR_BIGINT: $req .= sphPackI64($val); break; |
|
1078 | - default: $req .= pack("N", $val); break; |
|
1076 | + case SPH_ATTR_FLOAT: $req .= $this->_PackFloat($val); break; |
|
1077 | + case SPH_ATTR_BIGINT: $req .= sphPackI64($val); break; |
|
1078 | + default: $req .= pack("N", $val); break; |
|
1079 | 1079 | } |
1080 | 1080 | } |
1081 | 1081 | } |
@@ -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) |
@@ -549,8 +575,9 @@ discard block |
||
549 | 575 | /// leave mbstring workaround mode |
550 | 576 | public function _MBPop() |
551 | 577 | { |
552 | - if ($this->_mbenc) |
|
553 | - mb_internal_encoding($this->_mbenc); |
|
578 | + if ($this->_mbenc) { |
|
579 | + mb_internal_encoding($this->_mbenc); |
|
580 | + } |
|
554 | 581 | } |
555 | 582 | |
556 | 583 | /// connect to searchd server |
@@ -560,8 +587,9 @@ discard block |
||
560 | 587 | { |
561 | 588 | // we are in persistent connection mode, so we have a socket |
562 | 589 | // however, need to check whether it's still alive |
563 | - if (!@feof($this->_socket)) |
|
564 | - return $this->_socket; |
|
590 | + if (!@feof($this->_socket)) { |
|
591 | + return $this->_socket; |
|
592 | + } |
|
565 | 593 | |
566 | 594 | // force reopen |
567 | 595 | $this->_socket = false; |
@@ -575,24 +603,25 @@ discard block |
||
575 | 603 | { |
576 | 604 | $host = $this->_path; |
577 | 605 | $port = 0; |
578 | - } |
|
579 | - else |
|
606 | + } else |
|
580 | 607 | { |
581 | 608 | $host = $this->_host; |
582 | 609 | $port = $this->_port; |
583 | 610 | } |
584 | 611 | |
585 | - if ($this->_timeout <= 0) |
|
586 | - $fp = @fsockopen($host, $port, $errno, $errstr); |
|
587 | - else |
|
588 | - $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 | + } |
|
589 | 617 | |
590 | 618 | if (!$fp) |
591 | 619 | { |
592 | - if ($this->_path) |
|
593 | - $location = $this->_path; |
|
594 | - else |
|
595 | - $location = "{$this->_host}:{$this->_port}"; |
|
620 | + if ($this->_path) { |
|
621 | + $location = $this->_path; |
|
622 | + } else { |
|
623 | + $location = "{$this->_host}:{$this->_port}"; |
|
624 | + } |
|
596 | 625 | |
597 | 626 | $errstr = trim($errstr); |
598 | 627 | $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; |
@@ -645,8 +674,9 @@ discard block |
||
645 | 674 | } |
646 | 675 | } |
647 | 676 | } |
648 | - if ($this->_socket === false) |
|
649 | - fclose($fp); |
|
677 | + if ($this->_socket === false) { |
|
678 | + fclose($fp); |
|
679 | + } |
|
650 | 680 | |
651 | 681 | // check response |
652 | 682 | $read = strlen($response); |
@@ -706,10 +736,12 @@ discard block |
||
706 | 736 | assert($max >= 0); |
707 | 737 | $this->_offset = $offset; |
708 | 738 | $this->_limit = $limit; |
709 | - if ($max > 0) |
|
710 | - $this->_maxmatches = $max; |
|
711 | - if ($cutoff > 0) |
|
712 | - $this->_cutoff = $cutoff; |
|
739 | + if ($max > 0) { |
|
740 | + $this->_maxmatches = $max; |
|
741 | + } |
|
742 | + if ($cutoff > 0) { |
|
743 | + $this->_cutoff = $cutoff; |
|
744 | + } |
|
713 | 745 | } |
714 | 746 | |
715 | 747 | /// set maximum query time, in milliseconds, per-index |
@@ -763,8 +795,9 @@ discard block |
||
763 | 795 | public function SetWeights($weights) |
764 | 796 | { |
765 | 797 | assert(is_array($weights)); |
766 | - foreach ($weights as $weight) |
|
767 | - assert(is_int($weight)); |
|
798 | + foreach ($weights as $weight) { |
|
799 | + assert(is_int($weight)); |
|
800 | + } |
|
768 | 801 | |
769 | 802 | $this->_weights = $weights; |
770 | 803 | } |
@@ -814,8 +847,9 @@ discard block |
||
814 | 847 | |
815 | 848 | if (is_array($values) && count($values)) |
816 | 849 | { |
817 | - foreach ($values as $value) |
|
818 | - assert(is_numeric($value)); |
|
850 | + foreach ($values as $value) { |
|
851 | + assert(is_numeric($value)); |
|
852 | + } |
|
819 | 853 | |
820 | 854 | $this->_filters[] = array("type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values); |
821 | 855 | } |
@@ -954,15 +988,18 @@ discard block |
||
954 | 988 | $results = $this->RunQueries(); |
955 | 989 | $this->_reqs = array(); // just in case it failed too early |
956 | 990 | |
957 | - if (!is_array($results)) |
|
958 | - return false; // probably network error; error message should be already filled |
|
991 | + if (!is_array($results)) { |
|
992 | + return false; |
|
993 | + } |
|
994 | + // probably network error; error message should be already filled |
|
959 | 995 | |
960 | 996 | $this->_error = $results[0]["error"]; |
961 | 997 | $this->_warning = $results[0]["warning"]; |
962 | - if ($results[0]["status"] == SEARCHD_ERROR) |
|
963 | - return false; |
|
964 | - else |
|
965 | - return $results[0]; |
|
998 | + if ($results[0]["status"] == SEARCHD_ERROR) { |
|
999 | + return false; |
|
1000 | + } else { |
|
1001 | + return $results[0]; |
|
1002 | + } |
|
966 | 1003 | } |
967 | 1004 | |
968 | 1005 | /// helper to pack floats in network byte order |
@@ -989,8 +1026,9 @@ discard block |
||
989 | 1026 | $req .= pack("N", strlen($this->_sortby)).$this->_sortby; |
990 | 1027 | $req .= pack("N", strlen($query)).$query; // query itself |
991 | 1028 | $req .= pack("N", count($this->_weights)); // weights |
992 | - foreach ($this->_weights as $weight) |
|
993 | - $req .= pack("N", (int) $weight); |
|
1029 | + foreach ($this->_weights as $weight) { |
|
1030 | + $req .= pack("N", (int) $weight); |
|
1031 | + } |
|
994 | 1032 | $req .= pack("N", strlen($index)).$index; // indexes |
995 | 1033 | $req .= pack("N", 1); // id64 range marker |
996 | 1034 | $req .= sphPackU64($this->_min_id).sphPackU64($this->_max_id); // id64 range |
@@ -1005,8 +1043,9 @@ discard block |
||
1005 | 1043 | { |
1006 | 1044 | case SPH_FILTER_VALUES: |
1007 | 1045 | $req .= pack("N", count($filter["values"])); |
1008 | - foreach ($filter["values"] as $value) |
|
1009 | - $req .= sphPackI64($value); |
|
1046 | + foreach ($filter["values"] as $value) { |
|
1047 | + $req .= sphPackI64($value); |
|
1048 | + } |
|
1010 | 1049 | break; |
1011 | 1050 | |
1012 | 1051 | case SPH_FILTER_RANGE: |
@@ -1045,16 +1084,18 @@ discard block |
||
1045 | 1084 | |
1046 | 1085 | // per-index weights |
1047 | 1086 | $req .= pack("N", count($this->_indexweights)); |
1048 | - foreach ($this->_indexweights as $idx=>$weight) |
|
1049 | - $req .= pack("N", strlen($idx)).$idx.pack("N", $weight); |
|
1087 | + foreach ($this->_indexweights as $idx=>$weight) { |
|
1088 | + $req .= pack("N", strlen($idx)).$idx.pack("N", $weight); |
|
1089 | + } |
|
1050 | 1090 | |
1051 | 1091 | // max query time |
1052 | 1092 | $req .= pack("N", $this->_maxquerytime); |
1053 | 1093 | |
1054 | 1094 | // per-field weights |
1055 | 1095 | $req .= pack("N", count($this->_fieldweights)); |
1056 | - foreach ($this->_fieldweights as $field=>$weight) |
|
1057 | - $req .= pack("N", strlen($field)).$field.pack("N", $weight); |
|
1096 | + foreach ($this->_fieldweights as $field=>$weight) { |
|
1097 | + $req .= pack("N", strlen($field)).$field.pack("N", $weight); |
|
1098 | + } |
|
1058 | 1099 | |
1059 | 1100 | // comment |
1060 | 1101 | $req .= pack("N", strlen($comment)).$comment; |
@@ -1200,8 +1241,7 @@ discard block |
||
1200 | 1241 | { |
1201 | 1242 | $doc = sphUnpackU64(substr($response, $p, 8)); $p += 8; |
1202 | 1243 | list(,$weight) = unpack("N*", substr($response, $p, 4)); $p += 4; |
1203 | - } |
|
1204 | - else |
|
1244 | + } else |
|
1205 | 1245 | { |
1206 | 1246 | list ($doc, $weight) = array_values(unpack("N*N*", |
1207 | 1247 | substr($response, $p, 8))); |
@@ -1211,10 +1251,11 @@ discard block |
||
1211 | 1251 | $weight = sprintf("%u", $weight); |
1212 | 1252 | |
1213 | 1253 | // create match entry |
1214 | - if ($this->_arrayresult) |
|
1215 | - $result["matches"][$idx] = array("id"=>$doc, "weight"=>$weight); |
|
1216 | - else |
|
1217 | - $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 | + } |
|
1218 | 1259 | |
1219 | 1260 | // parse and create attributes |
1220 | 1261 | $attrvals = array(); |
@@ -1257,10 +1298,11 @@ discard block |
||
1257 | 1298 | } |
1258 | 1299 | } |
1259 | 1300 | |
1260 | - if ($this->_arrayresult) |
|
1261 | - $result["matches"][$idx]["attrs"] = $attrvals; |
|
1262 | - else |
|
1263 | - $result["matches"][$doc]["attrs"] = $attrvals; |
|
1301 | + if ($this->_arrayresult) { |
|
1302 | + $result["matches"][$idx]["attrs"] = $attrvals; |
|
1303 | + } else { |
|
1304 | + $result["matches"][$doc]["attrs"] = $attrvals; |
|
1305 | + } |
|
1264 | 1306 | } |
1265 | 1307 | |
1266 | 1308 | list ($total, $total_found, $msecs, $words) = |
@@ -1311,25 +1353,63 @@ discard block |
||
1311 | 1353 | // fixup options |
1312 | 1354 | ///////////////// |
1313 | 1355 | |
1314 | - if (!isset($opts["before_match"])) $opts["before_match"] = "<b>"; |
|
1315 | - if (!isset($opts["after_match"])) $opts["after_match"] = "</b>"; |
|
1316 | - if (!isset($opts["chunk_separator"])) $opts["chunk_separator"] = " ... "; |
|
1317 | - if (!isset($opts["limit"])) $opts["limit"] = 256; |
|
1318 | - if (!isset($opts["limit_passages"])) $opts["limit_passages"] = 0; |
|
1319 | - if (!isset($opts["limit_words"])) $opts["limit_words"] = 0; |
|
1320 | - if (!isset($opts["around"])) $opts["around"] = 5; |
|
1321 | - if (!isset($opts["exact_phrase"])) $opts["exact_phrase"] = false; |
|
1322 | - if (!isset($opts["single_passage"])) $opts["single_passage"] = false; |
|
1323 | - if (!isset($opts["use_boundaries"])) $opts["use_boundaries"] = false; |
|
1324 | - if (!isset($opts["weight_order"])) $opts["weight_order"] = false; |
|
1325 | - if (!isset($opts["query_mode"])) $opts["query_mode"] = false; |
|
1326 | - if (!isset($opts["force_all_words"])) $opts["force_all_words"] = false; |
|
1327 | - if (!isset($opts["start_passage_id"])) $opts["start_passage_id"] = 1; |
|
1328 | - if (!isset($opts["load_files"])) $opts["load_files"] = false; |
|
1329 | - if (!isset($opts["html_strip_mode"])) $opts["html_strip_mode"] = "index"; |
|
1330 | - if (!isset($opts["allow_empty"])) $opts["allow_empty"] = false; |
|
1331 | - if (!isset($opts["passage_boundary"])) $opts["passage_boundary"] = "none"; |
|
1332 | - 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 | + } |
|
1333 | 1413 | |
1334 | 1414 | ///////////////// |
1335 | 1415 | // build request |
@@ -1337,15 +1417,33 @@ discard block |
||
1337 | 1417 | |
1338 | 1418 | // v.1.2 req |
1339 | 1419 | $flags = 1; // remove spaces |
1340 | - if ($opts["exact_phrase"]) $flags |= 2; |
|
1341 | - if ($opts["single_passage"]) $flags |= 4; |
|
1342 | - if ($opts["use_boundaries"]) $flags |= 8; |
|
1343 | - if ($opts["weight_order"]) $flags |= 16; |
|
1344 | - if ($opts["query_mode"]) $flags |= 32; |
|
1345 | - if ($opts["force_all_words"]) $flags |= 64; |
|
1346 | - if ($opts["load_files"]) $flags |= 128; |
|
1347 | - if ($opts["allow_empty"]) $flags |= 256; |
|
1348 | - 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 | + } |
|
1349 | 1447 | $req = pack("NN", 0, $flags); // mode=0, flags=$flags |
1350 | 1448 | $req .= pack("N", strlen($index)).$index; // req index |
1351 | 1449 | $req .= pack("N", strlen($words)).$words; // req words |
@@ -1512,8 +1610,9 @@ discard block |
||
1512 | 1610 | assert(is_bool($mva)); |
1513 | 1611 | |
1514 | 1612 | assert(is_array($attrs)); |
1515 | - foreach ($attrs as $attr) |
|
1516 | - assert(is_string($attr)); |
|
1613 | + foreach ($attrs as $attr) { |
|
1614 | + assert(is_string($attr)); |
|
1615 | + } |
|
1517 | 1616 | |
1518 | 1617 | assert(is_array($values)); |
1519 | 1618 | foreach ($values as $id=>$entry) |
@@ -1526,10 +1625,12 @@ discard block |
||
1526 | 1625 | if ($mva) |
1527 | 1626 | { |
1528 | 1627 | assert(is_array($v)); |
1529 | - foreach ($v as $vv) |
|
1530 | - assert(is_int($vv)); |
|
1531 | - } else |
|
1532 | - assert(is_int($v)); |
|
1628 | + foreach ($v as $vv) { |
|
1629 | + assert(is_int($vv)); |
|
1630 | + } |
|
1631 | + } else { |
|
1632 | + assert(is_int($v)); |
|
1633 | + } |
|
1533 | 1634 | } |
1534 | 1635 | } |
1535 | 1636 | |
@@ -1551,9 +1652,10 @@ discard block |
||
1551 | 1652 | foreach ($entry as $v) |
1552 | 1653 | { |
1553 | 1654 | $req .= pack("N", $mva ? count($v) : $v); |
1554 | - if ($mva) |
|
1555 | - foreach ($v as $vv) |
|
1655 | + if ($mva) { |
|
1656 | + foreach ($v as $vv) |
|
1556 | 1657 | $req .= pack("N", $vv); |
1658 | + } |
|
1557 | 1659 | } |
1558 | 1660 | } |
1559 | 1661 | |
@@ -1595,13 +1697,15 @@ discard block |
||
1595 | 1697 | $this->_error = 'already connected'; |
1596 | 1698 | return false; |
1597 | 1699 | } |
1598 | - if (!$fp = $this->_Connect()) |
|
1599 | - return false; |
|
1700 | + if (!$fp = $this->_Connect()) { |
|
1701 | + return false; |
|
1702 | + } |
|
1600 | 1703 | |
1601 | 1704 | // command, command version = 0, body length = 4, body = 1 |
1602 | 1705 | $req = pack("nnNN", SEARCHD_COMMAND_PERSIST, 0, 4, 1); |
1603 | - if (!$this->_Send($fp, $req, 12)) |
|
1604 | - return false; |
|
1706 | + if (!$this->_Send($fp, $req, 12)) { |
|
1707 | + return false; |
|
1708 | + } |
|
1605 | 1709 | |
1606 | 1710 | $this->_socket = $fp; |
1607 | 1711 | return true; |
@@ -1647,8 +1751,10 @@ discard block |
||
1647 | 1751 | list ($rows, $cols) = array_values(unpack("N*N*", substr($response, $p, 8))); $p += 8; |
1648 | 1752 | |
1649 | 1753 | $res = array(); |
1650 | - for ($i = 0; $i < $rows; $i++) |
|
1651 | - for ($j = 0; $j < $cols; $j++) |
|
1754 | + for ($i = 0; $i < $rows; $i++) { |
|
1755 | + for ($j = 0; |
|
1756 | + } |
|
1757 | + $j < $cols; $j++) |
|
1652 | 1758 | { |
1653 | 1759 | list(,$len) = unpack("N*", substr($response, $p, 4)); $p += 4; |
1654 | 1760 | $res[$i][] = substr($response, $p, $len); $p += $len; |
@@ -1680,10 +1786,11 @@ discard block |
||
1680 | 1786 | } |
1681 | 1787 | |
1682 | 1788 | $tag = -1; |
1683 | - if (strlen($response) == 4) |
|
1684 | - list(,$tag) = unpack("N*", $response); |
|
1685 | - else |
|
1686 | - $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 | + } |
|
1687 | 1794 | |
1688 | 1795 | $this->_MBPop(); |
1689 | 1796 | return $tag; |
@@ -1,96 +1,96 @@ |
||
1 | 1 | <?php |
2 | 2 | class MailTo extends Plugin { |
3 | - private $host; |
|
3 | + private $host; |
|
4 | 4 | |
5 | - public function about() { |
|
6 | - return array(1.0, |
|
7 | - "Share article via email (using mailto: links, invoking your mail client)", |
|
8 | - "fox"); |
|
9 | - } |
|
5 | + public function about() { |
|
6 | + return array(1.0, |
|
7 | + "Share article via email (using mailto: links, invoking your mail client)", |
|
8 | + "fox"); |
|
9 | + } |
|
10 | 10 | |
11 | - public function init($host) { |
|
12 | - $this->host = $host; |
|
11 | + public function init($host) { |
|
12 | + $this->host = $host; |
|
13 | 13 | |
14 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
15 | - } |
|
14 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
15 | + } |
|
16 | 16 | |
17 | - public function get_js() { |
|
18 | - return file_get_contents(dirname(__FILE__)."/init.js"); |
|
19 | - } |
|
17 | + public function get_js() { |
|
18 | + return file_get_contents(dirname(__FILE__)."/init.js"); |
|
19 | + } |
|
20 | 20 | |
21 | - public function hook_article_button($line) { |
|
22 | - return "<i class='material-icons' style=\"cursor : pointer\" |
|
21 | + public function hook_article_button($line) { |
|
22 | + return "<i class='material-icons' style=\"cursor : pointer\" |
|
23 | 23 | onclick=\"Plugins.Mailto.send(".$line["id"].")\" |
24 | 24 | title='".__('Forward by email')."'>mail_outline</i>"; |
25 | - } |
|
25 | + } |
|
26 | 26 | |
27 | - public function emailArticle() { |
|
27 | + public function emailArticle() { |
|
28 | 28 | |
29 | - $ids = explode(",", $_REQUEST['param']); |
|
30 | - $ids_qmarks = arr_qmarks($ids); |
|
29 | + $ids = explode(",", $_REQUEST['param']); |
|
30 | + $ids_qmarks = arr_qmarks($ids); |
|
31 | 31 | |
32 | - require_once "lib/MiniTemplator.class.php"; |
|
32 | + require_once "lib/MiniTemplator.class.php"; |
|
33 | 33 | |
34 | - $tpl = new MiniTemplator; |
|
34 | + $tpl = new MiniTemplator; |
|
35 | 35 | |
36 | - $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
36 | + $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
37 | 37 | |
38 | - $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
39 | - //$tpl->setVariable('USER_EMAIL', $user_email, true); |
|
40 | - $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
38 | + $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
39 | + //$tpl->setVariable('USER_EMAIL', $user_email, true); |
|
40 | + $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
41 | 41 | |
42 | 42 | |
43 | - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
|
43 | + $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
|
44 | 44 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
45 | 45 | id IN ($ids_qmarks) AND owner_uid = ?"); |
46 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
46 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
47 | 47 | |
48 | - if (count($ids) > 1) { |
|
49 | - $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
50 | - } else { |
|
51 | - $subject = ""; |
|
52 | - } |
|
48 | + if (count($ids) > 1) { |
|
49 | + $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
50 | + } else { |
|
51 | + $subject = ""; |
|
52 | + } |
|
53 | 53 | |
54 | - while ($line = $sth->fetch()) { |
|
54 | + while ($line = $sth->fetch()) { |
|
55 | 55 | |
56 | - if (!$subject) { |
|
57 | - $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
58 | - } |
|
56 | + if (!$subject) { |
|
57 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
58 | + } |
|
59 | 59 | |
60 | - $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
61 | - $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
60 | + $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
61 | + $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
62 | 62 | |
63 | - $tpl->addBlock('article'); |
|
64 | - } |
|
63 | + $tpl->addBlock('article'); |
|
64 | + } |
|
65 | 65 | |
66 | - $tpl->addBlock('email'); |
|
66 | + $tpl->addBlock('email'); |
|
67 | 67 | |
68 | - $content = ""; |
|
69 | - $tpl->generateOutputToString($content); |
|
68 | + $content = ""; |
|
69 | + $tpl->generateOutputToString($content); |
|
70 | 70 | |
71 | - $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
|
72 | - "&body=".rawurlencode($content)); |
|
71 | + $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
|
72 | + "&body=".rawurlencode($content)); |
|
73 | 73 | |
74 | - print __("Clicking the following link to invoke your mail client:"); |
|
74 | + print __("Clicking the following link to invoke your mail client:"); |
|
75 | 75 | |
76 | - print "<div class='panel text-center'>"; |
|
77 | - print "<a target=\"_blank\" href=\"$mailto_link\">". |
|
78 | - __("Forward selected article(s) by email.")."</a>"; |
|
79 | - print "</div>"; |
|
76 | + print "<div class='panel text-center'>"; |
|
77 | + print "<a target=\"_blank\" href=\"$mailto_link\">". |
|
78 | + __("Forward selected article(s) by email.")."</a>"; |
|
79 | + print "</div>"; |
|
80 | 80 | |
81 | - print __("You should be able to edit the message before sending in your mail client."); |
|
81 | + print __("You should be able to edit the message before sending in your mail client."); |
|
82 | 82 | |
83 | - print "<p>"; |
|
83 | + print "<p>"; |
|
84 | 84 | |
85 | - print "<footer class='text-center'>"; |
|
86 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; |
|
87 | - print "</footer>"; |
|
85 | + print "<footer class='text-center'>"; |
|
86 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; |
|
87 | + print "</footer>"; |
|
88 | 88 | |
89 | - //return; |
|
90 | - } |
|
89 | + //return; |
|
90 | + } |
|
91 | 91 | |
92 | - public function api_version() { |
|
93 | - return 2; |
|
94 | - } |
|
92 | + public function api_version() { |
|
93 | + return 2; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | } |
@@ -55,141 +55,141 @@ |
||
55 | 55 | } |
56 | 56 | </script>"; |
57 | 57 | |
58 | - print_hidden("op", "pluginhandler"); |
|
59 | - print_hidden("method", "save"); |
|
60 | - print_hidden("plugin", "mail"); |
|
58 | + print_hidden("op", "pluginhandler"); |
|
59 | + print_hidden("method", "save"); |
|
60 | + print_hidden("plugin", "mail"); |
|
61 | 61 | |
62 | - $addresslist = $this->host->get($this, "addresslist"); |
|
62 | + $addresslist = $this->host->get($this, "addresslist"); |
|
63 | 63 | |
64 | - print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\" |
|
64 | + print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\" |
|
65 | 65 | name='addresslist'>$addresslist</textarea>"; |
66 | 66 | |
67 | - print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
|
68 | - __("Save")."</button>"; |
|
67 | + print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
|
68 | + __("Save")."</button>"; |
|
69 | 69 | |
70 | - print "</form>"; |
|
70 | + print "</form>"; |
|
71 | 71 | |
72 | - print "</div>"; |
|
73 | - } |
|
72 | + print "</div>"; |
|
73 | + } |
|
74 | 74 | |
75 | - public function hook_article_button($line) { |
|
76 | - return "<i class='material-icons' style=\"cursor : pointer\" |
|
75 | + public function hook_article_button($line) { |
|
76 | + return "<i class='material-icons' style=\"cursor : pointer\" |
|
77 | 77 | onclick=\"Plugins.Mail.send(".$line["id"].")\" |
78 | 78 | title='".__('Forward by email')."'>mail</i>"; |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - public function emailArticle() { |
|
81 | + public function emailArticle() { |
|
82 | 82 | |
83 | - $ids = explode(",", $_REQUEST['param']); |
|
84 | - $ids_qmarks = arr_qmarks($ids); |
|
83 | + $ids = explode(",", $_REQUEST['param']); |
|
84 | + $ids_qmarks = arr_qmarks($ids); |
|
85 | 85 | |
86 | - print_hidden("op", "pluginhandler"); |
|
87 | - print_hidden("plugin", "mail"); |
|
88 | - print_hidden("method", "sendEmail"); |
|
86 | + print_hidden("op", "pluginhandler"); |
|
87 | + print_hidden("plugin", "mail"); |
|
88 | + print_hidden("method", "sendEmail"); |
|
89 | 89 | |
90 | - $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE |
|
90 | + $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE |
|
91 | 91 | id = ?"); |
92 | - $sth->execute([$_SESSION['uid']]); |
|
92 | + $sth->execute([$_SESSION['uid']]); |
|
93 | 93 | |
94 | - if ($row = $sth->fetch()) { |
|
95 | - $user_email = htmlspecialchars($row['email']); |
|
96 | - $user_name = htmlspecialchars($row['full_name']); |
|
97 | - } |
|
94 | + if ($row = $sth->fetch()) { |
|
95 | + $user_email = htmlspecialchars($row['email']); |
|
96 | + $user_name = htmlspecialchars($row['full_name']); |
|
97 | + } |
|
98 | 98 | |
99 | - if (!$user_name) { |
|
100 | - $user_name = $_SESSION['name']; |
|
101 | - } |
|
99 | + if (!$user_name) { |
|
100 | + $user_name = $_SESSION['name']; |
|
101 | + } |
|
102 | 102 | |
103 | - print_hidden("from_email", "$user_email"); |
|
104 | - print_hidden("from_name", "$user_name"); |
|
103 | + print_hidden("from_email", "$user_email"); |
|
104 | + print_hidden("from_name", "$user_name"); |
|
105 | 105 | |
106 | - require_once "lib/MiniTemplator.class.php"; |
|
106 | + require_once "lib/MiniTemplator.class.php"; |
|
107 | 107 | |
108 | - $tpl = new MiniTemplator; |
|
108 | + $tpl = new MiniTemplator; |
|
109 | 109 | |
110 | - $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
110 | + $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
111 | 111 | |
112 | - $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
113 | - $tpl->setVariable('USER_EMAIL', $user_email, true); |
|
114 | - $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
112 | + $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
113 | + $tpl->setVariable('USER_EMAIL', $user_email, true); |
|
114 | + $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
115 | 115 | |
116 | - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note |
|
116 | + $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note |
|
117 | 117 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
118 | 118 | id IN ($ids_qmarks) AND owner_uid = ?"); |
119 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
119 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
120 | 120 | |
121 | - if (count($ids) > 1) { |
|
122 | - $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
123 | - } |
|
121 | + if (count($ids) > 1) { |
|
122 | + $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
123 | + } |
|
124 | 124 | |
125 | - while ($line = $sth->fetch()) { |
|
125 | + while ($line = $sth->fetch()) { |
|
126 | 126 | |
127 | - if (!$subject) { |
|
128 | - $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
129 | - } |
|
127 | + if (!$subject) { |
|
128 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
129 | + } |
|
130 | 130 | |
131 | - $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
132 | - $tnote = strip_tags($line["note"]); |
|
133 | - if ($tnote != '') { |
|
134 | - $tpl->setVariable('ARTICLE_NOTE', $tnote, true); |
|
135 | - $tpl->addBlock('note'); |
|
136 | - } |
|
137 | - $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
131 | + $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
132 | + $tnote = strip_tags($line["note"]); |
|
133 | + if ($tnote != '') { |
|
134 | + $tpl->setVariable('ARTICLE_NOTE', $tnote, true); |
|
135 | + $tpl->addBlock('note'); |
|
136 | + } |
|
137 | + $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
138 | 138 | |
139 | - $tpl->addBlock('article'); |
|
140 | - } |
|
139 | + $tpl->addBlock('article'); |
|
140 | + } |
|
141 | 141 | |
142 | - $tpl->addBlock('email'); |
|
142 | + $tpl->addBlock('email'); |
|
143 | 143 | |
144 | - $content = ""; |
|
145 | - $tpl->generateOutputToString($content); |
|
144 | + $content = ""; |
|
145 | + $tpl->generateOutputToString($content); |
|
146 | 146 | |
147 | - print "<table width='100%'><tr><td>"; |
|
147 | + print "<table width='100%'><tr><td>"; |
|
148 | 148 | |
149 | - $addresslist = explode(",", $this->host->get($this, "addresslist")); |
|
149 | + $addresslist = explode(",", $this->host->get($this, "addresslist")); |
|
150 | 150 | |
151 | - print __('To:'); |
|
151 | + print __('To:'); |
|
152 | 152 | |
153 | - print "</td><td>"; |
|
153 | + print "</td><td>"; |
|
154 | 154 | |
155 | 155 | /* print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\" |
156 | 156 | style=\"width : 30em;\" |
157 | 157 | name=\"destination\" id=\"emailArticleDlg_destination\">"; */ |
158 | 158 | |
159 | - print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); |
|
159 | + print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); |
|
160 | 160 | |
161 | 161 | /* print "<div class=\"autocomplete\" id=\"emailArticleDlg_dst_choices\" |
162 | 162 | style=\"z-index: 30; display : none\"></div>"; */ |
163 | 163 | |
164 | - print "</td></tr><tr><td>"; |
|
164 | + print "</td></tr><tr><td>"; |
|
165 | 165 | |
166 | - print __('Subject:'); |
|
166 | + print __('Subject:'); |
|
167 | 167 | |
168 | - print "</td><td>"; |
|
168 | + print "</td><td>"; |
|
169 | 169 | |
170 | - print "<input dojoType='dijit.form.ValidationTextBox' required='true' |
|
170 | + print "<input dojoType='dijit.form.ValidationTextBox' required='true' |
|
171 | 171 | style='width : 30em;' name='subject' value=\"$subject\" id='subject'>"; |
172 | 172 | |
173 | - print "</td></tr>"; |
|
173 | + print "</td></tr>"; |
|
174 | 174 | |
175 | - print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea' |
|
175 | + print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea' |
|
176 | 176 | style='height : 200px; font-size : 12px; width : 98%' rows=\"20\" |
177 | 177 | name='content'>$content</textarea>"; |
178 | 178 | |
179 | - print "</td></tr></table>"; |
|
179 | + print "</td></tr></table>"; |
|
180 | 180 | |
181 | - print "<footer>"; |
|
182 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> "; |
|
183 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>"; |
|
184 | - print "</footer>"; |
|
181 | + print "<footer>"; |
|
182 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> "; |
|
183 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>"; |
|
184 | + print "</footer>"; |
|
185 | 185 | |
186 | - //return; |
|
187 | - } |
|
186 | + //return; |
|
187 | + } |
|
188 | 188 | |
189 | - public function sendEmail() { |
|
190 | - $reply = array(); |
|
189 | + public function sendEmail() { |
|
190 | + $reply = array(); |
|
191 | 191 | |
192 | - /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']), |
|
192 | + /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']), |
|
193 | 193 | strip_tags($_REQUEST['from_name'])); |
194 | 194 | //$mail->AddAddress($_REQUEST['destination']); |
195 | 195 | $addresses = explode(';', $_REQUEST['destination']); |
@@ -497,7 +497,8 @@ |
||
497 | 497 | |
498 | 498 | PluginHost::getInstance()->run_commands($options); |
499 | 499 | |
500 | - if (file_exists(LOCK_DIRECTORY."/$lock_filename")) |
|
501 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
500 | + if (file_exists(LOCK_DIRECTORY."/$lock_filename")) { |
|
501 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
502 | 502 | fclose($lock_handle); |
503 | + } |
|
503 | 504 | unlink(LOCK_DIRECTORY."/$lock_filename"); |
@@ -1071,70 +1071,70 @@ |
||
1071 | 1071 | $qpart = ""; |
1072 | 1072 | |
1073 | 1073 | switch ($k) { |
1074 | - case "title": |
|
1075 | - $qpart = "title = ".$this->pdo->quote($feed_title); |
|
1076 | - break; |
|
1077 | - |
|
1078 | - case "feed_url": |
|
1079 | - $qpart = "feed_url = ".$this->pdo->quote($feed_url); |
|
1080 | - break; |
|
1081 | - |
|
1082 | - case "update_interval": |
|
1083 | - $qpart = "update_interval = ".$this->pdo->quote($upd_intl); |
|
1084 | - break; |
|
1085 | - |
|
1086 | - case "purge_interval": |
|
1087 | - $qpart = "purge_interval =".$this->pdo->quote($purge_intl); |
|
1088 | - break; |
|
1089 | - |
|
1090 | - case "auth_login": |
|
1091 | - $qpart = "auth_login = ".$this->pdo->quote($auth_login); |
|
1092 | - break; |
|
1093 | - |
|
1094 | - case "auth_pass": |
|
1095 | - $qpart = "auth_pass =".$this->pdo->quote($auth_pass).", auth_pass_encrypted = false"; |
|
1096 | - break; |
|
1097 | - |
|
1098 | - case "private": |
|
1099 | - $qpart = "private = ".$this->pdo->quote($private); |
|
1100 | - break; |
|
1101 | - |
|
1102 | - case "include_in_digest": |
|
1103 | - $qpart = "include_in_digest = ".$this->pdo->quote($include_in_digest); |
|
1104 | - break; |
|
1105 | - |
|
1106 | - case "always_display_enclosures": |
|
1107 | - $qpart = "always_display_enclosures = ".$this->pdo->quote($always_display_enclosures); |
|
1108 | - break; |
|
1109 | - |
|
1110 | - case "mark_unread_on_update": |
|
1111 | - $qpart = "mark_unread_on_update = ".$this->pdo->quote($mark_unread_on_update); |
|
1112 | - break; |
|
1113 | - |
|
1114 | - case "cache_images": |
|
1115 | - $qpart = "cache_images = ".$this->pdo->quote($cache_images); |
|
1116 | - break; |
|
1117 | - |
|
1118 | - case "hide_images": |
|
1119 | - $qpart = "hide_images = ".$this->pdo->quote($hide_images); |
|
1120 | - break; |
|
1121 | - |
|
1122 | - case "cat_id": |
|
1123 | - if (get_pref('ENABLE_FEED_CATS')) { |
|
1124 | - if ($cat_id) { |
|
1125 | - $qpart = "cat_id = ".$this->pdo->quote($cat_id); |
|
1126 | - } else { |
|
1127 | - $qpart = 'cat_id = NULL'; |
|
1128 | - } |
|
1074 | + case "title": |
|
1075 | + $qpart = "title = ".$this->pdo->quote($feed_title); |
|
1076 | + break; |
|
1077 | + |
|
1078 | + case "feed_url": |
|
1079 | + $qpart = "feed_url = ".$this->pdo->quote($feed_url); |
|
1080 | + break; |
|
1081 | + |
|
1082 | + case "update_interval": |
|
1083 | + $qpart = "update_interval = ".$this->pdo->quote($upd_intl); |
|
1084 | + break; |
|
1085 | + |
|
1086 | + case "purge_interval": |
|
1087 | + $qpart = "purge_interval =".$this->pdo->quote($purge_intl); |
|
1088 | + break; |
|
1089 | + |
|
1090 | + case "auth_login": |
|
1091 | + $qpart = "auth_login = ".$this->pdo->quote($auth_login); |
|
1092 | + break; |
|
1093 | + |
|
1094 | + case "auth_pass": |
|
1095 | + $qpart = "auth_pass =".$this->pdo->quote($auth_pass).", auth_pass_encrypted = false"; |
|
1096 | + break; |
|
1097 | + |
|
1098 | + case "private": |
|
1099 | + $qpart = "private = ".$this->pdo->quote($private); |
|
1100 | + break; |
|
1101 | + |
|
1102 | + case "include_in_digest": |
|
1103 | + $qpart = "include_in_digest = ".$this->pdo->quote($include_in_digest); |
|
1104 | + break; |
|
1105 | + |
|
1106 | + case "always_display_enclosures": |
|
1107 | + $qpart = "always_display_enclosures = ".$this->pdo->quote($always_display_enclosures); |
|
1108 | + break; |
|
1109 | + |
|
1110 | + case "mark_unread_on_update": |
|
1111 | + $qpart = "mark_unread_on_update = ".$this->pdo->quote($mark_unread_on_update); |
|
1112 | + break; |
|
1113 | + |
|
1114 | + case "cache_images": |
|
1115 | + $qpart = "cache_images = ".$this->pdo->quote($cache_images); |
|
1116 | + break; |
|
1117 | + |
|
1118 | + case "hide_images": |
|
1119 | + $qpart = "hide_images = ".$this->pdo->quote($hide_images); |
|
1120 | + break; |
|
1121 | + |
|
1122 | + case "cat_id": |
|
1123 | + if (get_pref('ENABLE_FEED_CATS')) { |
|
1124 | + if ($cat_id) { |
|
1125 | + $qpart = "cat_id = ".$this->pdo->quote($cat_id); |
|
1129 | 1126 | } else { |
1130 | - $qpart = ""; |
|
1127 | + $qpart = 'cat_id = NULL'; |
|
1131 | 1128 | } |
1129 | + } else { |
|
1130 | + $qpart = ""; |
|
1131 | + } |
|
1132 | 1132 | |
1133 | - break; |
|
1133 | + break; |
|
1134 | 1134 | |
1135 | - case "feed_language": |
|
1136 | - $qpart = "feed_language = ".$this->pdo->quote($feed_language); |
|
1137 | - break; |
|
1135 | + case "feed_language": |
|
1136 | + $qpart = "feed_language = ".$this->pdo->quote($feed_language); |
|
1137 | + break; |
|
1138 | 1138 | |
1139 | 1139 | } |
1140 | 1140 |
@@ -99,12 +99,16 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - if (count($scope_qparts) == 0) $scope_qparts = ["true"]; |
|
102 | + if (count($scope_qparts) == 0) { |
|
103 | + $scope_qparts = ["true"]; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | $glue = $filter['match_any_rule'] ? " OR " : " AND "; |
105 | 107 | $scope_qpart = join($glue, $scope_qparts); |
106 | 108 | |
107 | - if (!$scope_qpart) $scope_qpart = "true"; |
|
109 | + if (!$scope_qpart) { |
|
110 | + $scope_qpart = "true"; |
|
111 | + } |
|
108 | 112 | |
109 | 113 | $rv = array(); |
110 | 114 | |
@@ -583,8 +587,9 @@ discard block |
||
583 | 587 | $title = __($row["description"]); |
584 | 588 | |
585 | 589 | if ($action["action_id"] == 4 || $action["action_id"] == 6 || |
586 | - $action["action_id"] == 7) |
|
587 | - $title .= ": ".$action["action_param"]; |
|
590 | + $action["action_id"] == 7) { |
|
591 | + $title .= ": ".$action["action_param"]; |
|
592 | + } |
|
588 | 593 | |
589 | 594 | if ($action["action_id"] == 9) { |
590 | 595 | list ($pfclass, $pfaction) = explode(":", $action["action_param"]); |
@@ -1169,11 +1174,16 @@ discard block |
||
1169 | 1174 | $num_actions -= 1; |
1170 | 1175 | } |
1171 | 1176 | |
1172 | - if ($match_any_rule) $title .= " (".__("matches any rule").")"; |
|
1173 | - if ($inverse) $title .= " (".__("inverse").")"; |
|
1177 | + if ($match_any_rule) { |
|
1178 | + $title .= " (".__("matches any rule").")"; |
|
1179 | + } |
|
1180 | + if ($inverse) { |
|
1181 | + $title .= " (".__("inverse").")"; |
|
1182 | + } |
|
1174 | 1183 | |
1175 | - if ($num_actions > 0) |
|
1176 | - $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions); |
|
1184 | + if ($num_actions > 0) { |
|
1185 | + $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions); |
|
1186 | + } |
|
1177 | 1187 | |
1178 | 1188 | return [$title, $actions]; |
1179 | 1189 | } |
@@ -172,26 +172,26 @@ |
||
172 | 172 | $value = $_POST[$pref_name]; |
173 | 173 | |
174 | 174 | switch ($pref_name) { |
175 | - case 'DIGEST_PREFERRED_TIME': |
|
176 | - if (get_pref('DIGEST_PREFERRED_TIME') != $value) { |
|
175 | + case 'DIGEST_PREFERRED_TIME': |
|
176 | + if (get_pref('DIGEST_PREFERRED_TIME') != $value) { |
|
177 | 177 | |
178 | - $sth = $this->pdo->prepare("UPDATE ttrss_users SET |
|
178 | + $sth = $this->pdo->prepare("UPDATE ttrss_users SET |
|
179 | 179 | last_digest_sent = NULL WHERE id = ?"); |
180 | - $sth->execute([$_SESSION['uid']]); |
|
180 | + $sth->execute([$_SESSION['uid']]); |
|
181 | 181 | |
182 | - } |
|
183 | - break; |
|
184 | - case 'USER_LANGUAGE': |
|
185 | - if (!$need_reload) { |
|
186 | - $need_reload = $_SESSION["language"] != $value; |
|
187 | - } |
|
188 | - break; |
|
182 | + } |
|
183 | + break; |
|
184 | + case 'USER_LANGUAGE': |
|
185 | + if (!$need_reload) { |
|
186 | + $need_reload = $_SESSION["language"] != $value; |
|
187 | + } |
|
188 | + break; |
|
189 | 189 | |
190 | - case 'USER_CSS_THEME': |
|
191 | - if (!$need_reload) { |
|
192 | - $need_reload = get_pref($pref_name) != $value; |
|
193 | - } |
|
194 | - break; |
|
190 | + case 'USER_CSS_THEME': |
|
191 | + if (!$need_reload) { |
|
192 | + $need_reload = get_pref($pref_name) != $value; |
|
193 | + } |
|
194 | + break; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | set_pref($pref_name, $value); |
@@ -1,48 +1,48 @@ |
||
1 | 1 | <?php |
2 | 2 | class Logger_SQL { |
3 | 3 | |
4 | - private $pdo; |
|
4 | + private $pdo; |
|
5 | 5 | |
6 | - public function log_error($errno, $errstr, $file, $line, $context) { |
|
6 | + public function log_error($errno, $errstr, $file, $line, $context) { |
|
7 | 7 | |
8 | - // separate PDO connection object is used for logging |
|
9 | - if (!$this->pdo) { |
|
10 | - $this->pdo = Db::instance()->pdo_connect(); |
|
11 | - } |
|
8 | + // separate PDO connection object is used for logging |
|
9 | + if (!$this->pdo) { |
|
10 | + $this->pdo = Db::instance()->pdo_connect(); |
|
11 | + } |
|
12 | 12 | |
13 | - if ($this->pdo && get_schema_version() > 117) { |
|
13 | + if ($this->pdo && get_schema_version() > 117) { |
|
14 | 14 | |
15 | - $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null; |
|
15 | + $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null; |
|
16 | 16 | |
17 | - // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge |
|
18 | - $context = mb_substr($context, 0, 8192); |
|
17 | + // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge |
|
18 | + $context = mb_substr($context, 0, 8192); |
|
19 | 19 | |
20 | - $server_params = [ |
|
21 | - "IP" => "REMOTE_ADDR", |
|
22 | - "Request URI" => "REQUEST_URI", |
|
23 | - "User agent" => "HTTP_USER_AGENT", |
|
24 | - ]; |
|
20 | + $server_params = [ |
|
21 | + "IP" => "REMOTE_ADDR", |
|
22 | + "Request URI" => "REQUEST_URI", |
|
23 | + "User agent" => "HTTP_USER_AGENT", |
|
24 | + ]; |
|
25 | 25 | |
26 | - foreach ($server_params as $n => $p) { |
|
27 | - if (isset($_SERVER[$p])) { |
|
28 | - $context .= "\n$n: ".$_SERVER[$p]; |
|
29 | - } |
|
30 | - } |
|
26 | + foreach ($server_params as $n => $p) { |
|
27 | + if (isset($_SERVER[$p])) { |
|
28 | + $context .= "\n$n: ".$_SERVER[$p]; |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | - // passed error message may contain invalid unicode characters, failing to insert an error here |
|
33 | - // would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc |
|
34 | - $errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8'); |
|
35 | - $context = UConverter::transcode($context, 'UTF-8', 'UTF-8'); |
|
32 | + // passed error message may contain invalid unicode characters, failing to insert an error here |
|
33 | + // would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc |
|
34 | + $errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8'); |
|
35 | + $context = UConverter::transcode($context, 'UTF-8', 'UTF-8'); |
|
36 | 36 | |
37 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log |
|
37 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log |
|
38 | 38 | (errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES |
39 | 39 | (?, ?, ?, ?, ?, ?, NOW())"); |
40 | - $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]); |
|
40 | + $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]); |
|
41 | 41 | |
42 | - return $sth->rowCount(); |
|
43 | - } |
|
42 | + return $sth->rowCount(); |
|
43 | + } |
|
44 | 44 | |
45 | - return false; |
|
46 | - } |
|
45 | + return false; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |