@@ -121,14 +121,18 @@ discard block |
||
121 | 121 | { |
122 | 122 | |
123 | 123 | $URI_PARTS = parse_url($URI); |
124 | - if (!empty($URI_PARTS["user"])) |
|
125 | - $this->user = $URI_PARTS["user"]; |
|
126 | - if (!empty($URI_PARTS["pass"])) |
|
127 | - $this->pass = $URI_PARTS["pass"]; |
|
128 | - if (empty($URI_PARTS["query"])) |
|
129 | - $URI_PARTS["query"] = ''; |
|
130 | - if (empty($URI_PARTS["path"])) |
|
131 | - $URI_PARTS["path"] = ''; |
|
124 | + if (!empty($URI_PARTS["user"])) { |
|
125 | + $this->user = $URI_PARTS["user"]; |
|
126 | + } |
|
127 | + if (!empty($URI_PARTS["pass"])) { |
|
128 | + $this->pass = $URI_PARTS["pass"]; |
|
129 | + } |
|
130 | + if (empty($URI_PARTS["query"])) { |
|
131 | + $URI_PARTS["query"] = ''; |
|
132 | + } |
|
133 | + if (empty($URI_PARTS["path"])) { |
|
134 | + $URI_PARTS["path"] = ''; |
|
135 | + } |
|
132 | 136 | |
133 | 137 | $fp = null; |
134 | 138 | |
@@ -142,8 +146,9 @@ discard block |
||
142 | 146 | case "http": |
143 | 147 | $this->scheme = strtolower($URI_PARTS["scheme"]); |
144 | 148 | $this->host = $URI_PARTS["host"]; |
145 | - if (!empty($URI_PARTS["port"])) |
|
146 | - $this->port = $URI_PARTS["port"]; |
|
149 | + if (!empty($URI_PARTS["port"])) { |
|
150 | + $this->port = $URI_PARTS["port"]; |
|
151 | + } |
|
147 | 152 | if ($this->_connect($fp)) { |
148 | 153 | if ($this->_isproxy) { |
149 | 154 | // using proxy, send entire URI |
@@ -177,8 +182,9 @@ discard block |
||
177 | 182 | if ($this->_framedepth < $this->maxframes) { |
178 | 183 | $this->fetch($frameurl); |
179 | 184 | $this->_framedepth++; |
180 | - } else |
|
181 | - break; |
|
185 | + } else { |
|
186 | + break; |
|
187 | + } |
|
182 | 188 | } |
183 | 189 | } |
184 | 190 | } else { |
@@ -213,14 +219,18 @@ discard block |
||
213 | 219 | $postdata = $this->_prepare_post_body($formvars, $formfiles); |
214 | 220 | |
215 | 221 | $URI_PARTS = parse_url($URI); |
216 | - if (!empty($URI_PARTS["user"])) |
|
217 | - $this->user = $URI_PARTS["user"]; |
|
218 | - if (!empty($URI_PARTS["pass"])) |
|
219 | - $this->pass = $URI_PARTS["pass"]; |
|
220 | - if (empty($URI_PARTS["query"])) |
|
221 | - $URI_PARTS["query"] = ''; |
|
222 | - if (empty($URI_PARTS["path"])) |
|
223 | - $URI_PARTS["path"] = ''; |
|
222 | + if (!empty($URI_PARTS["user"])) { |
|
223 | + $this->user = $URI_PARTS["user"]; |
|
224 | + } |
|
225 | + if (!empty($URI_PARTS["pass"])) { |
|
226 | + $this->pass = $URI_PARTS["pass"]; |
|
227 | + } |
|
228 | + if (empty($URI_PARTS["query"])) { |
|
229 | + $URI_PARTS["query"] = ''; |
|
230 | + } |
|
231 | + if (empty($URI_PARTS["path"])) { |
|
232 | + $URI_PARTS["path"] = ''; |
|
233 | + } |
|
224 | 234 | |
225 | 235 | switch (strtolower($URI_PARTS["scheme"])) { |
226 | 236 | case "https": |
@@ -232,8 +242,9 @@ discard block |
||
232 | 242 | case "http": |
233 | 243 | $this->scheme = strtolower($URI_PARTS["scheme"]); |
234 | 244 | $this->host = $URI_PARTS["host"]; |
235 | - if (!empty($URI_PARTS["port"])) |
|
236 | - $this->port = $URI_PARTS["port"]; |
|
245 | + if (!empty($URI_PARTS["port"])) { |
|
246 | + $this->port = $URI_PARTS["port"]; |
|
247 | + } |
|
237 | 248 | if ($this->_connect($fp)) { |
238 | 249 | if ($this->_isproxy) { |
239 | 250 | // using proxy, send entire URI |
@@ -249,18 +260,22 @@ discard block |
||
249 | 260 | if ($this->_redirectaddr) { |
250 | 261 | /* url was redirected, check if we've hit the max depth */ |
251 | 262 | if ($this->maxredirs > $this->_redirectdepth) { |
252 | - if (!preg_match("|^" . $URI_PARTS["scheme"] . "://|", $this->_redirectaddr)) |
|
253 | - $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"] . "://" . $URI_PARTS["host"]); |
|
263 | + if (!preg_match("|^" . $URI_PARTS["scheme"] . "://|", $this->_redirectaddr)) { |
|
264 | + $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr, $URI_PARTS["scheme"] . "://" . $URI_PARTS["host"]); |
|
265 | + } |
|
254 | 266 | |
255 | 267 | // only follow redirect if it's on this site, or offsiteok is true |
256 | 268 | if (preg_match("|^https?://" . preg_quote($this->host) . "|i", $this->_redirectaddr) || $this->offsiteok) { |
257 | 269 | /* follow the redirect */ |
258 | 270 | $this->_redirectdepth++; |
259 | 271 | $this->lastredirectaddr = $this->_redirectaddr; |
260 | - if (strpos($this->_redirectaddr, "?") > 0) |
|
261 | - $this->fetch($this->_redirectaddr); // the redirect has changed the request method from post to get |
|
262 | - else |
|
263 | - $this->submit($this->_redirectaddr, $formvars, $formfiles); |
|
272 | + if (strpos($this->_redirectaddr, "?") > 0) { |
|
273 | + $this->fetch($this->_redirectaddr); |
|
274 | + } |
|
275 | + // the redirect has changed the request method from post to get |
|
276 | + else { |
|
277 | + $this->submit($this->_redirectaddr, $formvars, $formfiles); |
|
278 | + } |
|
264 | 279 | } |
265 | 280 | } |
266 | 281 | } |
@@ -273,8 +288,9 @@ discard block |
||
273 | 288 | if ($this->_framedepth < $this->maxframes) { |
274 | 289 | $this->fetch($frameurl); |
275 | 290 | $this->_framedepth++; |
276 | - } else |
|
277 | - break; |
|
291 | + } else { |
|
292 | + break; |
|
293 | + } |
|
278 | 294 | } |
279 | 295 | } |
280 | 296 | |
@@ -302,19 +318,24 @@ discard block |
||
302 | 318 | function fetchlinks($URI) |
303 | 319 | { |
304 | 320 | if ($this->fetch($URI) !== false) { |
305 | - if ($this->lastredirectaddr) |
|
306 | - $URI = $this->lastredirectaddr; |
|
321 | + if ($this->lastredirectaddr) { |
|
322 | + $URI = $this->lastredirectaddr; |
|
323 | + } |
|
307 | 324 | if (is_array($this->results)) { |
308 | - for ($x = 0; $x < count($this->results); $x++) |
|
309 | - $this->results[$x] = $this->_striplinks($this->results[$x]); |
|
310 | - } else |
|
311 | - $this->results = $this->_striplinks($this->results); |
|
325 | + for ($x = 0; $x < count($this->results); $x++) { |
|
326 | + $this->results[$x] = $this->_striplinks($this->results[$x]); |
|
327 | + } |
|
328 | + } else { |
|
329 | + $this->results = $this->_striplinks($this->results); |
|
330 | + } |
|
312 | 331 | |
313 | - if ($this->expandlinks) |
|
314 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
332 | + if ($this->expandlinks) { |
|
333 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
334 | + } |
|
315 | 335 | return $this; |
316 | - } else |
|
317 | - return false; |
|
336 | + } else { |
|
337 | + return false; |
|
338 | + } |
|
318 | 339 | } |
319 | 340 | |
320 | 341 | /*======================================================================*\ |
@@ -330,14 +351,17 @@ discard block |
||
330 | 351 | if ($this->fetch($URI) !== false) { |
331 | 352 | |
332 | 353 | if (is_array($this->results)) { |
333 | - for ($x = 0; $x < count($this->results); $x++) |
|
334 | - $this->results[$x] = $this->_stripform($this->results[$x]); |
|
335 | - } else |
|
336 | - $this->results = $this->_stripform($this->results); |
|
354 | + for ($x = 0; $x < count($this->results); $x++) { |
|
355 | + $this->results[$x] = $this->_stripform($this->results[$x]); |
|
356 | + } |
|
357 | + } else { |
|
358 | + $this->results = $this->_stripform($this->results); |
|
359 | + } |
|
337 | 360 | |
338 | 361 | return $this; |
339 | - } else |
|
340 | - return false; |
|
362 | + } else { |
|
363 | + return false; |
|
364 | + } |
|
341 | 365 | } |
342 | 366 | |
343 | 367 | |
@@ -352,13 +376,16 @@ discard block |
||
352 | 376 | { |
353 | 377 | if ($this->fetch($URI) !== false) { |
354 | 378 | if (is_array($this->results)) { |
355 | - for ($x = 0; $x < count($this->results); $x++) |
|
356 | - $this->results[$x] = $this->_striptext($this->results[$x]); |
|
357 | - } else |
|
358 | - $this->results = $this->_striptext($this->results); |
|
379 | + for ($x = 0; $x < count($this->results); $x++) { |
|
380 | + $this->results[$x] = $this->_striptext($this->results[$x]); |
|
381 | + } |
|
382 | + } else { |
|
383 | + $this->results = $this->_striptext($this->results); |
|
384 | + } |
|
359 | 385 | return $this; |
360 | - } else |
|
361 | - return false; |
|
386 | + } else { |
|
387 | + return false; |
|
388 | + } |
|
362 | 389 | } |
363 | 390 | |
364 | 391 | /*======================================================================*\ |
@@ -371,22 +398,26 @@ discard block |
||
371 | 398 | function submitlinks($URI, $formvars = "", $formfiles = "") |
372 | 399 | { |
373 | 400 | if ($this->submit($URI, $formvars, $formfiles) !== false) { |
374 | - if ($this->lastredirectaddr) |
|
375 | - $URI = $this->lastredirectaddr; |
|
401 | + if ($this->lastredirectaddr) { |
|
402 | + $URI = $this->lastredirectaddr; |
|
403 | + } |
|
376 | 404 | if (is_array($this->results)) { |
377 | 405 | for ($x = 0; $x < count($this->results); $x++) { |
378 | 406 | $this->results[$x] = $this->_striplinks($this->results[$x]); |
379 | - if ($this->expandlinks) |
|
380 | - $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
407 | + if ($this->expandlinks) { |
|
408 | + $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
409 | + } |
|
381 | 410 | } |
382 | 411 | } else { |
383 | 412 | $this->results = $this->_striplinks($this->results); |
384 | - if ($this->expandlinks) |
|
385 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
413 | + if ($this->expandlinks) { |
|
414 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
415 | + } |
|
386 | 416 | } |
387 | 417 | return $this; |
388 | - } else |
|
389 | - return false; |
|
418 | + } else { |
|
419 | + return false; |
|
420 | + } |
|
390 | 421 | } |
391 | 422 | |
392 | 423 | /*======================================================================*\ |
@@ -399,22 +430,26 @@ discard block |
||
399 | 430 | function submittext($URI, $formvars = "", $formfiles = "") |
400 | 431 | { |
401 | 432 | if ($this->submit($URI, $formvars, $formfiles) !== false) { |
402 | - if ($this->lastredirectaddr) |
|
403 | - $URI = $this->lastredirectaddr; |
|
433 | + if ($this->lastredirectaddr) { |
|
434 | + $URI = $this->lastredirectaddr; |
|
435 | + } |
|
404 | 436 | if (is_array($this->results)) { |
405 | 437 | for ($x = 0; $x < count($this->results); $x++) { |
406 | 438 | $this->results[$x] = $this->_striptext($this->results[$x]); |
407 | - if ($this->expandlinks) |
|
408 | - $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
439 | + if ($this->expandlinks) { |
|
440 | + $this->results[$x] = $this->_expandlinks($this->results[$x], $URI); |
|
441 | + } |
|
409 | 442 | } |
410 | 443 | } else { |
411 | 444 | $this->results = $this->_striptext($this->results); |
412 | - if ($this->expandlinks) |
|
413 | - $this->results = $this->_expandlinks($this->results, $URI); |
|
445 | + if ($this->expandlinks) { |
|
446 | + $this->results = $this->_expandlinks($this->results, $URI); |
|
447 | + } |
|
414 | 448 | } |
415 | 449 | return $this; |
416 | - } else |
|
417 | - return false; |
|
450 | + } else { |
|
451 | + return false; |
|
452 | + } |
|
418 | 453 | } |
419 | 454 | |
420 | 455 | |
@@ -468,13 +503,15 @@ discard block |
||
468 | 503 | // catenate the non-empty matches from the conditional subpattern |
469 | 504 | |
470 | 505 | while (list($key, $val) = each($links[2])) { |
471 | - if (!empty($val)) |
|
472 | - $match[] = $val; |
|
506 | + if (!empty($val)) { |
|
507 | + $match[] = $val; |
|
508 | + } |
|
473 | 509 | } |
474 | 510 | |
475 | 511 | while (list($key, $val) = each($links[3])) { |
476 | - if (!empty($val)) |
|
477 | - $match[] = $val; |
|
512 | + if (!empty($val)) { |
|
513 | + $match[] = $val; |
|
514 | + } |
|
478 | 515 | } |
479 | 516 | |
480 | 517 | // return the links |
@@ -619,23 +656,28 @@ discard block |
||
619 | 656 | function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "") |
620 | 657 | { |
621 | 658 | $cookie_headers = ''; |
622 | - if ($this->passcookies && $this->_redirectaddr) |
|
623 | - $this->setcookies(); |
|
659 | + if ($this->passcookies && $this->_redirectaddr) { |
|
660 | + $this->setcookies(); |
|
661 | + } |
|
624 | 662 | |
625 | 663 | $URI_PARTS = parse_url($URI); |
626 | - if (empty($url)) |
|
627 | - $url = "/"; |
|
664 | + if (empty($url)) { |
|
665 | + $url = "/"; |
|
666 | + } |
|
628 | 667 | $headers = $http_method . " " . $url . " " . $this->_httpversion . "\r\n"; |
629 | 668 | if (!empty($this->host) && !isset($this->rawheaders['Host'])) { |
630 | 669 | $headers .= "Host: " . $this->host; |
631 | - if (!empty($this->port) && $this->port != '80') |
|
632 | - $headers .= ":" . $this->port; |
|
670 | + if (!empty($this->port) && $this->port != '80') { |
|
671 | + $headers .= ":" . $this->port; |
|
672 | + } |
|
633 | 673 | $headers .= "\r\n"; |
634 | 674 | } |
635 | - if (!empty($this->agent)) |
|
636 | - $headers .= "User-Agent: " . $this->agent . "\r\n"; |
|
637 | - if (!empty($this->accept)) |
|
638 | - $headers .= "Accept: " . $this->accept . "\r\n"; |
|
675 | + if (!empty($this->agent)) { |
|
676 | + $headers .= "User-Agent: " . $this->agent . "\r\n"; |
|
677 | + } |
|
678 | + if (!empty($this->accept)) { |
|
679 | + $headers .= "Accept: " . $this->accept . "\r\n"; |
|
680 | + } |
|
639 | 681 | if ($this->use_gzip) { |
640 | 682 | // make sure PHP was built with --with-zlib |
641 | 683 | // and we can handle gzipp'ed data |
@@ -648,11 +690,13 @@ discard block |
||
648 | 690 | E_USER_NOTICE); |
649 | 691 | } |
650 | 692 | } |
651 | - if (!empty($this->referer)) |
|
652 | - $headers .= "Referer: " . $this->referer . "\r\n"; |
|
693 | + if (!empty($this->referer)) { |
|
694 | + $headers .= "Referer: " . $this->referer . "\r\n"; |
|
695 | + } |
|
653 | 696 | if (!empty($this->cookies)) { |
654 | - if (!is_array($this->cookies)) |
|
655 | - $this->cookies = (array)$this->cookies; |
|
697 | + if (!is_array($this->cookies)) { |
|
698 | + $this->cookies = (array)$this->cookies; |
|
699 | + } |
|
656 | 700 | |
657 | 701 | reset($this->cookies); |
658 | 702 | if (count($this->cookies) > 0) { |
@@ -664,32 +708,39 @@ discard block |
||
664 | 708 | } |
665 | 709 | } |
666 | 710 | if (!empty($this->rawheaders)) { |
667 | - if (!is_array($this->rawheaders)) |
|
668 | - $this->rawheaders = (array)$this->rawheaders; |
|
669 | - while (list($headerKey, $headerVal) = each($this->rawheaders)) |
|
670 | - $headers .= $headerKey . ": " . $headerVal . "\r\n"; |
|
711 | + if (!is_array($this->rawheaders)) { |
|
712 | + $this->rawheaders = (array)$this->rawheaders; |
|
713 | + } |
|
714 | + while (list($headerKey, $headerVal) = each($this->rawheaders)) { |
|
715 | + $headers .= $headerKey . ": " . $headerVal . "\r\n"; |
|
716 | + } |
|
671 | 717 | } |
672 | 718 | if (!empty($content_type)) { |
673 | 719 | $headers .= "Content-type: $content_type"; |
674 | - if ($content_type == "multipart/form-data") |
|
675 | - $headers .= "; boundary=" . $this->_mime_boundary; |
|
720 | + if ($content_type == "multipart/form-data") { |
|
721 | + $headers .= "; boundary=" . $this->_mime_boundary; |
|
722 | + } |
|
676 | 723 | $headers .= "\r\n"; |
677 | 724 | } |
678 | - if (!empty($body)) |
|
679 | - $headers .= "Content-length: " . strlen($body) . "\r\n"; |
|
680 | - if (!empty($this->user) || !empty($this->pass)) |
|
681 | - $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n"; |
|
725 | + if (!empty($body)) { |
|
726 | + $headers .= "Content-length: " . strlen($body) . "\r\n"; |
|
727 | + } |
|
728 | + if (!empty($this->user) || !empty($this->pass)) { |
|
729 | + $headers .= "Authorization: Basic " . base64_encode($this->user . ":" . $this->pass) . "\r\n"; |
|
730 | + } |
|
682 | 731 | |
683 | 732 | //add proxy auth headers |
684 | - if (!empty($this->proxy_user)) |
|
685 | - $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n"; |
|
733 | + if (!empty($this->proxy_user)) { |
|
734 | + $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass) . "\r\n"; |
|
735 | + } |
|
686 | 736 | |
687 | 737 | |
688 | 738 | $headers .= "\r\n"; |
689 | 739 | |
690 | 740 | // set the read timeout if needed |
691 | - if ($this->read_timeout > 0) |
|
692 | - socket_set_timeout($fp, $this->read_timeout); |
|
741 | + if ($this->read_timeout > 0) { |
|
742 | + socket_set_timeout($fp, $this->read_timeout); |
|
743 | + } |
|
693 | 744 | $this->timed_out = false; |
694 | 745 | |
695 | 746 | fwrite($fp, $headers . $body, strlen($headers . $body)); |
@@ -706,8 +757,9 @@ discard block |
||
706 | 757 | return false; |
707 | 758 | } |
708 | 759 | |
709 | - if ($currentHeader == "\r\n") |
|
710 | - break; |
|
760 | + if ($currentHeader == "\r\n") { |
|
761 | + break; |
|
762 | + } |
|
711 | 763 | |
712 | 764 | // if a header begins with Location: or URI:, set the redirect |
713 | 765 | if (preg_match("/^(Location:|URI:)/i", $currentHeader)) { |
@@ -718,12 +770,14 @@ discard block |
||
718 | 770 | // no host in the path, so prepend |
719 | 771 | $this->_redirectaddr = $URI_PARTS["scheme"] . "://" . $this->host . ":" . $this->port; |
720 | 772 | // eliminate double slash |
721 | - if (!preg_match("|^/|", $matches[2])) |
|
722 | - $this->_redirectaddr .= "/" . $matches[2]; |
|
723 | - else |
|
724 | - $this->_redirectaddr .= $matches[2]; |
|
725 | - } else |
|
726 | - $this->_redirectaddr = $matches[2]; |
|
773 | + if (!preg_match("|^/|", $matches[2])) { |
|
774 | + $this->_redirectaddr .= "/" . $matches[2]; |
|
775 | + } else { |
|
776 | + $this->_redirectaddr .= $matches[2]; |
|
777 | + } |
|
778 | + } else { |
|
779 | + $this->_redirectaddr = $matches[2]; |
|
780 | + } |
|
727 | 781 | } |
728 | 782 | |
729 | 783 | if (preg_match("|^HTTP/|", $currentHeader)) { |
@@ -770,14 +824,17 @@ discard block |
||
770 | 824 | // have we hit our frame depth and is there frame src to fetch? |
771 | 825 | if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match)) { |
772 | 826 | $this->results[] = $results; |
773 | - for ($x = 0; $x < count($match[1]); $x++) |
|
774 | - $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host); |
|
827 | + for ($x = 0; $x < count($match[1]); $x++) { |
|
828 | + $this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"] . "://" . $this->host); |
|
829 | + } |
|
775 | 830 | } // have we already fetched framed content? |
776 | - elseif (is_array($this->results)) |
|
777 | - $this->results[] = $results; |
|
831 | + elseif (is_array($this->results)) { |
|
832 | + $this->results[] = $results; |
|
833 | + } |
|
778 | 834 | // no framed content |
779 | - else |
|
780 | - $this->results = $results; |
|
835 | + else { |
|
836 | + $this->results = $results; |
|
837 | + } |
|
781 | 838 | |
782 | 839 | return $this; |
783 | 840 | } |
@@ -790,8 +847,9 @@ discard block |
||
790 | 847 | function setcookies() |
791 | 848 | { |
792 | 849 | for ($x = 0; $x < count($this->headers); $x++) { |
793 | - if (preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x], $match)) |
|
794 | - $this->cookies[$match[1]] = urldecode($match[2]); |
|
850 | + if (preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $this->headers[$x], $match)) { |
|
851 | + $this->cookies[$match[1]] = urldecode($match[2]); |
|
852 | + } |
|
795 | 853 | } |
796 | 854 | return $this; |
797 | 855 | } |
@@ -852,10 +910,12 @@ discard block |
||
852 | 910 | 'disable_compression' => true, |
853 | 911 | ); |
854 | 912 | |
855 | - if (isset($this->cafile)) |
|
856 | - $context_opts['ssl']['cafile'] = $this->cafile; |
|
857 | - if (isset($this->capath)) |
|
858 | - $context_opts['ssl']['capath'] = $this->capath; |
|
913 | + if (isset($this->cafile)) { |
|
914 | + $context_opts['ssl']['cafile'] = $this->cafile; |
|
915 | + } |
|
916 | + if (isset($this->capath)) { |
|
917 | + $context_opts['ssl']['capath'] = $this->capath; |
|
918 | + } |
|
859 | 919 | } |
860 | 920 | |
861 | 921 | $host = 'ssl://' . $host; |
@@ -864,8 +924,9 @@ discard block |
||
864 | 924 | $context = stream_context_create($context_opts); |
865 | 925 | |
866 | 926 | if (version_compare(PHP_VERSION, '5.0.0', '>')) { |
867 | - if($this->scheme == 'http') |
|
868 | - $host = "tcp://" . $host; |
|
927 | + if($this->scheme == 'http') { |
|
928 | + $host = "tcp://" . $host; |
|
929 | + } |
|
869 | 930 | $fp = stream_socket_client( |
870 | 931 | "$host:$port", |
871 | 932 | $errno, |
@@ -929,8 +990,9 @@ discard block |
||
929 | 990 | settype($formfiles, "array"); |
930 | 991 | $postdata = ''; |
931 | 992 | |
932 | - if (count($formvars) == 0 && count($formfiles) == 0) |
|
933 | - return; |
|
993 | + if (count($formvars) == 0 && count($formfiles) == 0) { |
|
994 | + return; |
|
995 | + } |
|
934 | 996 | |
935 | 997 | switch ($this->_submit_type) { |
936 | 998 | case "application/x-www-form-urlencoded": |
@@ -940,8 +1002,9 @@ discard block |
||
940 | 1002 | while (list($cur_key, $cur_val) = each($val)) { |
941 | 1003 | $postdata .= urlencode($key) . "[]=" . urlencode($cur_val) . "&"; |
942 | 1004 | } |
943 | - } else |
|
944 | - $postdata .= urlencode($key) . "=" . urlencode($val) . "&"; |
|
1005 | + } else { |
|
1006 | + $postdata .= urlencode($key) . "=" . urlencode($val) . "&"; |
|
1007 | + } |
|
945 | 1008 | } |
946 | 1009 | break; |
947 | 1010 | |
@@ -967,7 +1030,9 @@ discard block |
||
967 | 1030 | while (list($field_name, $file_names) = each($formfiles)) { |
968 | 1031 | settype($file_names, "array"); |
969 | 1032 | while (list(, $file_name) = each($file_names)) { |
970 | - if (!is_readable($file_name)) continue; |
|
1033 | + if (!is_readable($file_name)) { |
|
1034 | + continue; |
|
1035 | + } |
|
971 | 1036 | |
972 | 1037 | $fp = fopen($file_name, "r"); |
973 | 1038 | $file_content = fread($fp, filesize($file_name)); |
@@ -65,21 +65,37 @@ |
||
65 | 65 | $_['macintosh'] = 'Western European (Mac) - macintosh'; |
66 | 66 | $_['Windows-1252'] = 'Western European (Windows) - Windows-1252'; |
67 | 67 | |
68 | -if($modx_charset == 'euc-jp') $_['euc-jp'] = 'Japanese (EUC) - euc-jp'; |
|
69 | -elseif($modx_charset == 'shift_jis') $_['shift_jis'] = 'Japanese (Shift-JIS) - shift_jis'; |
|
70 | -elseif($modx_charset == 'iso-2022-jp') $_['iso-2022-jp'] = 'Japanese (JIS-Allow 1 byte Kana - SO/SI) - iso-2022-jp'; |
|
71 | -elseif($modx_charset == 'csISO2022JP') $_['csISO2022JP'] = 'Japanese (JIS-Allow 1 byte Kana) - csISO2022JP'; |
|
72 | -elseif($modx_charset == 'EUC-CN') $_['EUC-CN'] = 'Chinese Simplified (EUC) - EUC-CN'; |
|
73 | -elseif($modx_charset == 'hz-gb-2312') $_['hz-gb-2312'] = 'Chinese Simplified (HZ) - hz-gb-2312'; |
|
74 | -elseif($modx_charset == 'x-mac-chinesesimp') $_['x-mac-chinesesimp'] = 'Chinese Simplified (Mac) - x-mac-chinesesimp'; |
|
75 | -elseif($modx_charset == 'x-Chinese-CNS') $_['x-Chinese-CNS'] = 'Chinese Traditional (CNS) - x-Chinese-CNS'; |
|
76 | -elseif($modx_charset == 'x-Chinese-Eten') $_['x-Chinese-Eten'] = 'Chinese Traditional (Eten) - x-Chinese-Eten'; |
|
77 | -elseif($modx_charset == 'x-mac-chinesetrad') $_['x-mac-chinesetrad'] = 'Chinese Traditional (Mac) - x-mac-chinesetrad'; |
|
78 | -elseif($modx_charset == 'ks_c_5601-1987') $_['ks_c_5601-1987'] = 'Korean - ks_c_5601-1987'; |
|
79 | -elseif($modx_charset == 'euc-kr') $_['euc-kr'] = 'Korean (EUC) - euc-kr'; |
|
80 | -elseif($modx_charset == 'iso-2022-kr') $_['iso-2022-kr'] = 'Korean (ISO) - iso-2022-kr'; |
|
81 | -elseif($modx_charset == 'Johab') $_['Johab'] = 'Korean (Johab) - Johab'; |
|
82 | -elseif($modx_charset == 'x-mac-korean') $_['x-mac-korean'] = 'Korean (Mac) - x-mac-korean'; |
|
68 | +if($modx_charset == 'euc-jp') { |
|
69 | + $_['euc-jp'] = 'Japanese (EUC) - euc-jp'; |
|
70 | +} elseif($modx_charset == 'shift_jis') { |
|
71 | + $_['shift_jis'] = 'Japanese (Shift-JIS) - shift_jis'; |
|
72 | +} elseif($modx_charset == 'iso-2022-jp') { |
|
73 | + $_['iso-2022-jp'] = 'Japanese (JIS-Allow 1 byte Kana - SO/SI) - iso-2022-jp'; |
|
74 | +} elseif($modx_charset == 'csISO2022JP') { |
|
75 | + $_['csISO2022JP'] = 'Japanese (JIS-Allow 1 byte Kana) - csISO2022JP'; |
|
76 | +} elseif($modx_charset == 'EUC-CN') { |
|
77 | + $_['EUC-CN'] = 'Chinese Simplified (EUC) - EUC-CN'; |
|
78 | +} elseif($modx_charset == 'hz-gb-2312') { |
|
79 | + $_['hz-gb-2312'] = 'Chinese Simplified (HZ) - hz-gb-2312'; |
|
80 | +} elseif($modx_charset == 'x-mac-chinesesimp') { |
|
81 | + $_['x-mac-chinesesimp'] = 'Chinese Simplified (Mac) - x-mac-chinesesimp'; |
|
82 | +} elseif($modx_charset == 'x-Chinese-CNS') { |
|
83 | + $_['x-Chinese-CNS'] = 'Chinese Traditional (CNS) - x-Chinese-CNS'; |
|
84 | +} elseif($modx_charset == 'x-Chinese-Eten') { |
|
85 | + $_['x-Chinese-Eten'] = 'Chinese Traditional (Eten) - x-Chinese-Eten'; |
|
86 | +} elseif($modx_charset == 'x-mac-chinesetrad') { |
|
87 | + $_['x-mac-chinesetrad'] = 'Chinese Traditional (Mac) - x-mac-chinesetrad'; |
|
88 | +} elseif($modx_charset == 'ks_c_5601-1987') { |
|
89 | + $_['ks_c_5601-1987'] = 'Korean - ks_c_5601-1987'; |
|
90 | +} elseif($modx_charset == 'euc-kr') { |
|
91 | + $_['euc-kr'] = 'Korean (EUC) - euc-kr'; |
|
92 | +} elseif($modx_charset == 'iso-2022-kr') { |
|
93 | + $_['iso-2022-kr'] = 'Korean (ISO) - iso-2022-kr'; |
|
94 | +} elseif($modx_charset == 'Johab') { |
|
95 | + $_['Johab'] = 'Korean (Johab) - Johab'; |
|
96 | +} elseif($modx_charset == 'x-mac-korean') { |
|
97 | + $_['x-mac-korean'] = 'Korean (Mac) - x-mac-korean'; |
|
98 | +} |
|
83 | 99 | |
84 | 100 | $tpl = '<option value="%s" %s>%s</option>'; |
85 | 101 | $options = array(); |
@@ -344,7 +344,8 @@ |
||
344 | 344 | protected function sendString($string) |
345 | 345 | { |
346 | 346 | if ($this->pop_conn) { |
347 | - if ($this->do_debug >= 2) { //Show client messages when debug >= 2 |
|
347 | + if ($this->do_debug >= 2) { |
|
348 | +//Show client messages when debug >= 2 |
|
348 | 349 | echo 'Client -> Server: ', $string; |
349 | 350 | } |
350 | 351 |
@@ -2059,7 +2059,8 @@ discard block |
||
2059 | 2059 | */ |
2060 | 2060 | public function addrFormat($addr) |
2061 | 2061 | { |
2062 | - if (empty($addr[1])) { // No name provided |
|
2062 | + if (empty($addr[1])) { |
|
2063 | +// No name provided |
|
2063 | 2064 | return $this->secureHeader($addr[0]); |
2064 | 2065 | } |
2065 | 2066 | |
@@ -3425,7 +3426,7 @@ discard block |
||
3425 | 3426 | { |
3426 | 3427 | $this->RecipientsQueue = array_filter( |
3427 | 3428 | $this->RecipientsQueue, |
3428 | - function ($params) use ($kind) { |
|
3429 | + function ($params) use ($kind){ |
|
3429 | 3430 | return $params[0] != $kind; |
3430 | 3431 | } |
3431 | 3432 | ); |
@@ -1,16 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | $pattern = '/<img[\s\n]+.*src=[\s\n]*"([^"]+\.(jpg|jpeg|png|gif))"[^>]+>/i'; |
3 | 3 | preg_match_all($pattern , $value , $images); |
4 | -if($opt==='') |
|
5 | -{ |
|
6 | - if($images[1][0]) return $images[1][0]; |
|
7 | - else return ''; |
|
8 | -} |
|
9 | -else |
|
10 | -{ |
|
11 | - foreach($images[0] as $i=>$image) |
|
12 | - { |
|
13 | - if(strpos($image,$opt)!==false) return $images[1][$i]; |
|
4 | +if($opt==='') { |
|
5 | + if($images[1][0]) { |
|
6 | + return $images[1][0]; |
|
7 | + } else { |
|
8 | + return ''; |
|
9 | + } |
|
10 | + } else { |
|
11 | + foreach($images[0] as $i=>$image) { |
|
12 | + if(strpos($image,$opt)!==false) { |
|
13 | + return $images[1][$i]; |
|
14 | + } |
|
14 | 15 | } |
15 | 16 | } |
16 | 17 |
@@ -9,14 +9,15 @@ |
||
9 | 9 | $blockElms = explode(',', $blockElms); |
10 | 10 | $lines = explode("\n",$text); |
11 | 11 | $c = count($lines); |
12 | -foreach($lines as $i=>$line) |
|
13 | -{ |
|
12 | +foreach($lines as $i=>$line) { |
|
14 | 13 | $line = rtrim($line); |
15 | - if($i===$c-1) break; |
|
16 | - foreach($blockElms as $block) |
|
17 | - { |
|
18 | - if(preg_match("@</?{$block}" . '[^>]*>$@',$line)) |
|
19 | - continue 2; |
|
14 | + if($i===$c-1) { |
|
15 | + break; |
|
16 | + } |
|
17 | + foreach($blockElms as $block) { |
|
18 | + if(preg_match("@</?{$block}" . '[^>]*>$@',$line)) { |
|
19 | + continue 2; |
|
20 | + } |
|
20 | 21 | } |
21 | 22 | $lines[$i] = "{$line}<br />"; |
22 | 23 | } |
@@ -5,11 +5,14 @@ discard block |
||
5 | 5 | $groupNames = ($this->strlen($opt) > 0 ) ? explode(',',$opt) : array(); |
6 | 6 | |
7 | 7 | // if $groupNames is not an array return false |
8 | -if(!is_array($groupNames)) return 0; |
|
8 | +if(!is_array($groupNames)) { |
|
9 | + return 0; |
|
10 | +} |
|
9 | 11 | |
10 | 12 | // Creates an array with all webgroups the user id is in |
11 | -if (isset($modx->filter->cache['mo'][$userID])) $grpNames = $modx->filter->cache['mo'][$userID]; |
|
12 | -else { |
|
13 | +if (isset($modx->filter->cache['mo'][$userID])) { |
|
14 | + $grpNames = $modx->filter->cache['mo'][$userID]; |
|
15 | +} else { |
|
13 | 16 | $from = sprintf("[+prefix+]webgroup_names wgn INNER JOIN [+prefix+]web_groups wg ON wg.webgroup=wgn.id AND wg.webuser='%s'",$userID); |
14 | 17 | $rs = $modx->db->select('wgn.name',$from); |
15 | 18 | $modx->filter->cache['mo'][$userID] = $grpNames = $modx->db->getColumn('name',$rs); |
@@ -17,8 +20,10 @@ discard block |
||
17 | 20 | |
18 | 21 | // Check if a supplied group matches a webgroup from the array we just created |
19 | 22 | foreach($groupNames as $k=>$v) { |
20 | - if(in_array(trim($v),$grpNames)) return 1; |
|
21 | -} |
|
23 | + if(in_array(trim($v),$grpNames)) { |
|
24 | + return 1; |
|
25 | + } |
|
26 | + } |
|
22 | 27 | |
23 | 28 | // If we get here the above logic did not find a match, so return false |
24 | 29 | return 0; |
@@ -1,19 +1,22 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! function_exists('f_owc')){ |
|
2 | +if( ! function_exists('f_owc')) { |
|
3 | 3 | /** |
4 | 4 | * @param $path |
5 | 5 | * @param $data |
6 | 6 | * @param null|int $mode |
7 | 7 | */ |
8 | - function f_owc($path, $data, $mode = null){ |
|
8 | + function f_owc($path, $data, $mode = null) |
|
9 | + { |
|
9 | 10 | try { |
10 | 11 | // make an attempt to create the file |
11 | 12 | $hnd = fopen($path, 'w'); |
12 | 13 | fwrite($hnd, $data); |
13 | 14 | fclose($hnd); |
14 | 15 | |
15 | - if(null !== $mode) chmod($path, $mode); |
|
16 | - }catch(Exception $e){ |
|
16 | + if(null !== $mode) { |
|
17 | + chmod($path, $mode); |
|
18 | + } |
|
19 | + } catch(Exception $e) { |
|
17 | 20 | // Nothing, this is NOT normal |
18 | 21 | unset($e); |
19 | 22 | } |
@@ -21,7 +24,9 @@ discard block |
||
21 | 24 | } |
22 | 25 | |
23 | 26 | $installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0; |
24 | -if( ! isset($_lang)) $_lang = array(); |
|
27 | +if( ! isset($_lang)) { |
|
28 | + $_lang = array(); |
|
29 | +} |
|
25 | 30 | |
26 | 31 | echo '<div class="stepcontainer"> |
27 | 32 | <ul class="progressbar"> |
@@ -57,7 +62,7 @@ discard block |
||
57 | 62 | // check if iconv is available |
58 | 63 | echo '<p>' . $_lang['checking_iconv']; |
59 | 64 | $iconv = (int) function_exists('iconv'); |
60 | -if ($iconv == '0'){ |
|
65 | +if ($iconv == '0') { |
|
61 | 66 | echo '<span class="notok">' . $_lang['failed'].'</span></p><p><strong>'.$_lang['checking_iconv_note'].'</strong></p>'; |
62 | 67 | $errors++; |
63 | 68 | } else { |
@@ -119,7 +124,7 @@ discard block |
||
119 | 124 | |
120 | 125 | // File Browser directories exists? |
121 | 126 | echo '<p>'.$_lang['checking_if_images_exist']; |
122 | -switch(true){ |
|
127 | +switch(true) { |
|
123 | 128 | case !file_exists("../assets/images"): |
124 | 129 | case !file_exists("../assets/files"): |
125 | 130 | case !file_exists("../assets/backup"): |
@@ -134,7 +139,7 @@ discard block |
||
134 | 139 | |
135 | 140 | // File Browser directories writable? |
136 | 141 | echo '<p>'.$_lang['checking_if_images_writable']; |
137 | -switch(true){ |
|
142 | +switch(true) { |
|
138 | 143 | case !is_writable("../assets/images"): |
139 | 144 | case !is_writable("../assets/files"): |
140 | 145 | case !is_writable("../assets/backup"): |
@@ -268,7 +273,7 @@ discard block |
||
268 | 273 | if ($conn) { |
269 | 274 | echo '<p>'. $_lang['checking_mysql_strict_mode']; |
270 | 275 | $mysqlmode = mysqli_query($conn, "SELECT @@global.sql_mode"); |
271 | - if (mysqli_num_rows($mysqlmode) > 0){ |
|
276 | + if (mysqli_num_rows($mysqlmode) > 0) { |
|
272 | 277 | $modes = mysqli_fetch_array($mysqlmode, MYSQLI_NUM); |
273 | 278 | //$modes = array("STRICT_TRANS_TABLES"); // for testing |
274 | 279 | // print_r($modes); |
@@ -305,9 +310,9 @@ discard block |
||
305 | 310 | echo '<p>'; |
306 | 311 | echo $_lang['setup_cannot_continue'] . ' '; |
307 | 312 | |
308 | - if($errors > 1){ |
|
313 | + if($errors > 1) { |
|
309 | 314 | echo $errors . " " . $_lang['errors'] . $_lang['please_correct_errors'] . $_lang['and_try_again_plural']; |
310 | - }else{ |
|
315 | + } else { |
|
311 | 316 | echo $_lang['error'] . $_lang['please_correct_error'] . $_lang['and_try_again']; |
312 | 317 | } |
313 | 318 | |
@@ -343,23 +348,35 @@ discard block |
||
343 | 348 | <input type="hidden" value="<?php echo $_POST['installdata'] ?>" name="installdata" /> |
344 | 349 | <?php |
345 | 350 | $templates = isset ($_POST['template']) ? $_POST['template'] : array (); |
346 | - foreach ($templates as $i => $template) echo '<input type="hidden" name="template[]" value="'.$template.'" />'; |
|
351 | + foreach ($templates as $i => $template) { |
|
352 | + echo '<input type="hidden" name="template[]" value="'.$template.'" />'; |
|
353 | + } |
|
347 | 354 | |
348 | 355 | $tvs = isset ($_POST['tv']) ? $_POST['tv'] : array (); |
349 | - foreach ($tvs as $i => $tv) echo '<input type="hidden" name="tv[]" value="'.$tv.'" />'; |
|
356 | + foreach ($tvs as $i => $tv) { |
|
357 | + echo '<input type="hidden" name="tv[]" value="'.$tv.'" />'; |
|
358 | + } |
|
350 | 359 | |
351 | 360 | $chunks = isset ($_POST['chunk']) ? $_POST['chunk'] : array (); |
352 | - foreach ($chunks as $i => $chunk) echo '<input type="hidden" name="chunk[]" value="'.$chunk.'" />'; |
|
361 | + foreach ($chunks as $i => $chunk) { |
|
362 | + echo '<input type="hidden" name="chunk[]" value="'.$chunk.'" />'; |
|
363 | + } |
|
353 | 364 | |
354 | 365 | $snippets = isset ($_POST['snippet']) ? $_POST['snippet'] : array (); |
355 | - foreach ($snippets as $i => $snippet) echo '<input type="hidden" name="snippet[]" value="'.$snippet.'" />'; |
|
366 | + foreach ($snippets as $i => $snippet) { |
|
367 | + echo '<input type="hidden" name="snippet[]" value="'.$snippet.'" />'; |
|
368 | + } |
|
356 | 369 | |
357 | 370 | $plugins = isset ($_POST['plugin']) ? $_POST['plugin'] : array (); |
358 | - foreach ($plugins as $i => $plugin) echo '<input type="hidden" name="plugin[]" value="'.$plugin.'" />'; |
|
371 | + foreach ($plugins as $i => $plugin) { |
|
372 | + echo '<input type="hidden" name="plugin[]" value="'.$plugin.'" />'; |
|
373 | + } |
|
359 | 374 | |
360 | 375 | $modules = isset ($_POST['module']) ? $_POST['module'] : array (); |
361 | - foreach ($modules as $i => $module) echo '<input type="hidden" name="module[]" value="'.$module.'" />'; |
|
362 | -?> |
|
376 | + foreach ($modules as $i => $module) { |
|
377 | + echo '<input type="hidden" name="module[]" value="'.$module.'" />'; |
|
378 | + } |
|
379 | + ?> |
|
363 | 380 | </div> |
364 | 381 | |
365 | 382 | <h2><?php echo $_lang['agree_to_terms'];?></h2> |
@@ -89,7 +89,8 @@ discard block |
||
89 | 89 | |
90 | 90 | $MAGPIE_ERROR = ""; |
91 | 91 | |
92 | -function fetch_rss ($url) { |
|
92 | +function fetch_rss ($url) |
|
93 | +{ |
|
93 | 94 | // initialize constants |
94 | 95 | init(); |
95 | 96 | |
@@ -104,8 +105,7 @@ discard block |
||
104 | 105 | $resp = _fetch_remote_file( $url ); |
105 | 106 | if ( is_success( $resp->status ) ) { |
106 | 107 | return _response_to_rss( $resp ); |
107 | - } |
|
108 | - else { |
|
108 | + } else { |
|
109 | 109 | error("Failed to fetch $url and cache is off"); |
110 | 110 | return false; |
111 | 111 | } |
@@ -174,8 +174,7 @@ discard block |
||
174 | 174 | // reset cache on 304 (at minutillo insistent prodding) |
175 | 175 | $cache->set($cache_key, $rss); |
176 | 176 | return $rss; |
177 | - } |
|
178 | - elseif ( is_success( $resp->status ) ) { |
|
177 | + } elseif ( is_success( $resp->status ) ) { |
|
179 | 178 | $rss = _response_to_rss( $resp ); |
180 | 179 | if ( $rss ) { |
181 | 180 | if (MAGPIE_DEBUG > 1) { |
@@ -185,24 +184,20 @@ discard block |
||
185 | 184 | $cache->set( $cache_key, $rss ); |
186 | 185 | return $rss; |
187 | 186 | } |
188 | - } |
|
189 | - else { |
|
187 | + } else { |
|
190 | 188 | $errormsg = "Failed to fetch $url "; |
191 | 189 | if ( $resp->status == '-100' ) { |
192 | 190 | $errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)"; |
193 | - } |
|
194 | - elseif ( $resp->error ) { |
|
191 | + } elseif ( $resp->error ) { |
|
195 | 192 | # compensate for Snoopy's annoying habbit to tacking |
196 | 193 | # on '\n' |
197 | 194 | $http_error = substr($resp->error, 0, -2); |
198 | 195 | $errormsg .= "(HTTP Error: $http_error)"; |
199 | - } |
|
200 | - else { |
|
196 | + } else { |
|
201 | 197 | $errormsg .= "(HTTP Response: " . $resp->response_code .')'; |
202 | 198 | } |
203 | 199 | } |
204 | - } |
|
205 | - else { |
|
200 | + } else { |
|
206 | 201 | $errormsg = "Unable to retrieve RSS file for unknown reasons."; |
207 | 202 | } |
208 | 203 | |
@@ -229,7 +224,8 @@ discard block |
||
229 | 224 | Purpose: set MAGPIE_ERROR, and trigger error |
230 | 225 | \*=======================================================================*/ |
231 | 226 | |
232 | -function error ($errormsg, $lvl=E_USER_WARNING) { |
|
227 | +function error ($errormsg, $lvl=E_USER_WARNING) |
|
228 | +{ |
|
233 | 229 | global $MAGPIE_ERROR; |
234 | 230 | |
235 | 231 | // append PHP's error message if track_errors enabled |
@@ -243,7 +239,8 @@ discard block |
||
243 | 239 | } |
244 | 240 | } |
245 | 241 | |
246 | -function debug ($debugmsg, $lvl=E_USER_NOTICE) { |
|
242 | +function debug ($debugmsg, $lvl=E_USER_NOTICE) |
|
243 | +{ |
|
247 | 244 | trigger_error("MagpieRSS [debug] $debugmsg", $lvl); |
248 | 245 | } |
249 | 246 | |
@@ -251,7 +248,8 @@ discard block |
||
251 | 248 | Function: magpie_error |
252 | 249 | Purpose: accessor for the magpie error variable |
253 | 250 | \*=======================================================================*/ |
254 | -function magpie_error ($errormsg="") { |
|
251 | +function magpie_error ($errormsg="") |
|
252 | +{ |
|
255 | 253 | global $MAGPIE_ERROR; |
256 | 254 | |
257 | 255 | if ( isset($errormsg) and $errormsg ) { |
@@ -268,7 +266,8 @@ discard block |
||
268 | 266 | headers to send along with the request (optional) |
269 | 267 | Output: an HTTP response object (see Snoopy.class.inc) |
270 | 268 | \*=======================================================================*/ |
271 | -function _fetch_remote_file ($url, $headers = "" ) { |
|
269 | +function _fetch_remote_file ($url, $headers = "" ) |
|
270 | +{ |
|
272 | 271 | // Snoopy is an HTTP client in PHP |
273 | 272 | $client = new Snoopy(); |
274 | 273 | $client->agent = MAGPIE_USER_AGENT; |
@@ -289,7 +288,8 @@ discard block |
||
289 | 288 | Input: an HTTP response object (see Snoopy) |
290 | 289 | Output: parsed RSS object (see rss_parse) |
291 | 290 | \*=======================================================================*/ |
292 | -function _response_to_rss ($resp) { |
|
291 | +function _response_to_rss ($resp) |
|
292 | +{ |
|
293 | 293 | $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING ); |
294 | 294 | |
295 | 295 | // if RSS parsed successfully |
@@ -300,8 +300,7 @@ discard block |
||
300 | 300 | // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1" |
301 | 301 | if (strpos($h, ": ")) { |
302 | 302 | list($field, $val) = explode(": ", $h, 2); |
303 | - } |
|
304 | - else { |
|
303 | + } else { |
|
305 | 304 | $field = $h; |
306 | 305 | $val = ""; |
307 | 306 | } |
@@ -334,11 +333,11 @@ discard block |
||
334 | 333 | Purpose: setup constants with default values |
335 | 334 | check for user overrides |
336 | 335 | \*=======================================================================*/ |
337 | -function init () { |
|
336 | +function init () |
|
337 | +{ |
|
338 | 338 | if ( defined('MAGPIE_INITALIZED') ) { |
339 | 339 | return; |
340 | - } |
|
341 | - else { |
|
340 | + } else { |
|
342 | 341 | define('MAGPIE_INITALIZED', true); |
343 | 342 | } |
344 | 343 | |
@@ -360,7 +359,9 @@ discard block |
||
360 | 359 | |
361 | 360 | if ( !defined('MAGPIE_OUTPUT_ENCODING') ) { |
362 | 361 | global $modx_manager_charset; |
363 | - if(empty($modx_manager_charset)) $modx_manager_charset = 'ISO-8859-1'; |
|
362 | + if(empty($modx_manager_charset)) { |
|
363 | + $modx_manager_charset = 'ISO-8859-1'; |
|
364 | + } |
|
364 | 365 | define('MAGPIE_OUTPUT_ENCODING', $modx_manager_charset); |
365 | 366 | } |
366 | 367 | |
@@ -381,8 +382,7 @@ discard block |
||
381 | 382 | |
382 | 383 | if ( MAGPIE_CACHE_ON ) { |
383 | 384 | $ua = $ua . ')'; |
384 | - } |
|
385 | - else { |
|
385 | + } else { |
|
386 | 386 | $ua = $ua . '; No cache)'; |
387 | 387 | } |
388 | 388 | |
@@ -417,7 +417,8 @@ discard block |
||
417 | 417 | Function: is_info |
418 | 418 | Purpose: return true if Informational status code |
419 | 419 | \*=======================================================================*/ |
420 | -function is_info ($sc) { |
|
420 | +function is_info ($sc) |
|
421 | +{ |
|
421 | 422 | return $sc >= 100 && $sc < 200; |
422 | 423 | } |
423 | 424 | |
@@ -425,7 +426,8 @@ discard block |
||
425 | 426 | Function: is_success |
426 | 427 | Purpose: return true if Successful status code |
427 | 428 | \*=======================================================================*/ |
428 | -function is_success ($sc) { |
|
429 | +function is_success ($sc) |
|
430 | +{ |
|
429 | 431 | return $sc >= 200 && $sc < 300; |
430 | 432 | } |
431 | 433 | |
@@ -433,7 +435,8 @@ discard block |
||
433 | 435 | Function: is_redirect |
434 | 436 | Purpose: return true if Redirection status code |
435 | 437 | \*=======================================================================*/ |
436 | -function is_redirect ($sc) { |
|
438 | +function is_redirect ($sc) |
|
439 | +{ |
|
437 | 440 | return $sc >= 300 && $sc < 400; |
438 | 441 | } |
439 | 442 | |
@@ -441,7 +444,8 @@ discard block |
||
441 | 444 | Function: is_error |
442 | 445 | Purpose: return true if Error status code |
443 | 446 | \*=======================================================================*/ |
444 | -function is_error ($sc) { |
|
447 | +function is_error ($sc) |
|
448 | +{ |
|
445 | 449 | return $sc >= 400 && $sc < 600; |
446 | 450 | } |
447 | 451 | |
@@ -449,7 +453,8 @@ discard block |
||
449 | 453 | Function: is_client_error |
450 | 454 | Purpose: return true if Error status code, and its a client error |
451 | 455 | \*=======================================================================*/ |
452 | -function is_client_error ($sc) { |
|
456 | +function is_client_error ($sc) |
|
457 | +{ |
|
453 | 458 | return $sc >= 400 && $sc < 500; |
454 | 459 | } |
455 | 460 | |
@@ -457,6 +462,7 @@ discard block |
||
457 | 462 | Function: is_client_error |
458 | 463 | Purpose: return true if Error status code, and its a server error |
459 | 464 | \*=======================================================================*/ |
460 | -function is_server_error ($sc) { |
|
465 | +function is_server_error ($sc) |
|
466 | +{ |
|
461 | 467 | return $sc >= 500 && $sc < 600; |
462 | 468 | } |