Completed
Push — develop ( a67439...00fbcc )
by
unknown
06:22
created
manager/media/rss/rss_utils.inc 1 patch
Braces   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,7 +22,8 @@  discard block
 block discarded – undo
22 22
     NOTE: http://www.w3.org/TR/NOTE-datetime
23 23
 \*======================================================================*/
24 24
 
25
-function parse_w3cdtf ( $date_str ) {
25
+function parse_w3cdtf ( $date_str )
26
+{
26 27
     
27 28
     # regex to match wc3dtf
28 29
     $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
@@ -37,8 +38,7 @@  discard block
 block discarded – undo
37 38
         $offset = 0;
38 39
         if ( $match[10] == 'Z' ) {
39 40
             # zulu time, aka GMT
40
-        }
41
-        else {
41
+        } else {
42 42
             list( $tz_mod, $tz_hour, $tz_min ) =
43 43
                 array( $match[8], $match[9], $match[10]);
44 44
             
@@ -58,8 +58,7 @@  discard block
 block discarded – undo
58 58
         }
59 59
         $epoch = $epoch + $offset;
60 60
         return $epoch;
61
-    }
62
-    else {
61
+    } else {
63 62
         return -1;
64 63
     }
65 64
 }
Please login to merge, or discard this patch.
manager/media/rss/extlib/Snoopy.class.inc 1 patch
Braces   +192 added lines, -127 removed lines patch added patch discarded remove patch
@@ -121,14 +121,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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));
Please login to merge, or discard this patch.
manager/includes/accesscontrol.inc.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
 if(file_exists(MODX_BASE_PATH . 'assets/cache/installProc.inc.php')) {
22 22
 	include_once(MODX_BASE_PATH . 'assets/cache/installProc.inc.php');
23 23
 	if(isset($installStartTime)) {
24
-		if((time() - $installStartTime) > 5 * 60) { // if install flag older than 5 minutes, discard
24
+		if((time() - $installStartTime) > 5 * 60) {
25
+// if install flag older than 5 minutes, discard
25 26
 			unset($installStartTime);
26 27
 			@ chmod(MODX_BASE_PATH . 'assets/cache/installProc.inc.php', 0755);
27 28
 			unlink(MODX_BASE_PATH . 'assets/cache/installProc.inc.php');
@@ -155,7 +156,8 @@  discard block
 block discarded – undo
155 156
 		} elseif(is_file($theme_path . 'templates/actions/login.tpl')) {
156 157
 			$target = $theme_path . 'templates/actions/login.tpl';
157 158
 			$login_tpl = file_get_contents($target);
158
-		} elseif(is_file($theme_path . 'html/login.html')) { // ClipperCMS compatible
159
+		} elseif(is_file($theme_path . 'html/login.html')) {
160
+// ClipperCMS compatible
159 161
 			$target = $theme_path . 'html/login.html';
160 162
 			$login_tpl = file_get_contents($target);
161 163
 		} else {
Please login to merge, or discard this patch.
manager/includes/tmplvars.format.inc.php 1 patch
Braces   +21 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,7 +5,8 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Added by Raymond 20-Jan-2005
8
-function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '') {
8
+function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = "", $docid = "", $sep = '')
9
+{
9 10
 
10 11
 	global $modx;
11 12
 
@@ -49,7 +50,9 @@  discard block
 block discarded – undo
49 50
 					if(isset($params['align']) && $params['align'] != 'none') {
50 51
 						$attr['align'] = $params['align'];
51 52
 					}
52
-					foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
53
+					foreach($attr as $k => $v) {
54
+					    $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
55
+					}
53 56
 					$attributes .= ' ' . $params['attrib'];
54 57
 
55 58
 					// Output the image with attributes
@@ -117,7 +120,9 @@  discard block
 block discarded – undo
117 120
 						'style' => $params['style'],
118 121
 						'target' => $params['target'],
119 122
 					);
120
-					foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
123
+					foreach($attr as $k => $v) {
124
+					    $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
125
+					}
121 126
 					$attributes .= ' ' . $params['attrib']; // add extra
122 127
 
123 128
 					// Output the link
@@ -145,7 +150,9 @@  discard block
 block discarded – undo
145 150
 					'class' => $params['class'],
146 151
 					'style' => $params['style'],
147 152
 				);
148
-				foreach($attr as $k => $v) $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
153
+				foreach($attr as $k => $v) {
154
+				    $attributes .= ($v ? ' ' . $k . '="' . $v . '"' : '');
155
+				}
149 156
 				$attributes .= ' ' . $params['attrib']; // add extra
150 157
 
151 158
 				// Output the HTML Tag
@@ -325,19 +332,24 @@  discard block
 block discarded – undo
325 332
 	return $o;
326 333
 }
327 334
 
328
-function decodeParamValue($s) {
335
+function decodeParamValue($s)
336
+{
329 337
 	$s = str_replace("%3D", '=', $s); // =
330 338
 	$s = str_replace("%26", '&', $s); // &
331 339
 	return $s;
332 340
 }
333 341
 
334 342
 // returns an array if a delimiter is present. returns array is a recordset is present
335
-function parseInput($src, $delim = "||", $type = "string", $columns = true) { // type can be: string, array
343
+function parseInput($src, $delim = "||", $type = "string", $columns = true)
344
+{
345
+// type can be: string, array
336 346
 	global $modx;
337 347
 	if($modx->db->isResult($src)) {
338 348
 		// must be a recordset
339 349
 		$rows = array();
340
-		while($cols = $modx->db->getRow($src, 'num')) $rows[] = ($columns) ? $cols : implode(" ", $cols);
350
+		while($cols = $modx->db->getRow($src, 'num')) {
351
+		    $rows[] = ($columns) ? $cols : implode(" ", $cols);
352
+		}
341 353
 		return ($type == "array") ? $rows : implode($delim, $rows);
342 354
 	} else {
343 355
 		// must be a text
@@ -349,7 +361,8 @@  discard block
 block discarded – undo
349 361
 	}
350 362
 }
351 363
 
352
-function getUnixtimeFromDateString($value) {
364
+function getUnixtimeFromDateString($value)
365
+{
353 366
 	$timestamp = false;
354 367
 	// Check for MySQL or legacy style date
355 368
 	$date_match_1 = '/^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$/';
Please login to merge, or discard this patch.
manager/includes/rss.inc.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@  discard block
 block discarded – undo
29 29
 // include MagPieRSS
30 30
 require_once(MODX_MANAGER_PATH.'media/rss/rss_fetch.inc');
31 31
 // Convert relative path into absolute url
32
-function rel2abs( $rel, $base ) {
32
+function rel2abs( $rel, $base )
33
+{
33 34
 	// parse base URL  and convert to local variables: $scheme, $host,  $path
34 35
 	extract( parse_url( $base ) );
35 36
 	if ( strpos( $rel,"//" ) === 0 ) {
@@ -63,7 +64,7 @@  discard block
 block discarded – undo
63 64
 foreach ($urls as $section=>$url) {
64 65
 	$output = '';
65 66
     $rss = @fetch_rss($url);
66
-    if( !$rss ){
67
+    if( !$rss ) {
67 68
     	$feedData[$section] = 'Failed to retrieve ' . $url;
68 69
     	continue;
69 70
 	}
Please login to merge, or discard this patch.
manager/includes/charsets.php 1 patch
Braces   +31 added lines, -15 removed lines patch added patch discarded remove patch
@@ -65,21 +65,37 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
manager/includes/preload.functions.inc.php 1 patch
Braces   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,13 +3,15 @@  discard block
 block discarded – undo
3 3
 global $site_sessionname;
4 4
 $site_sessionname = genEvoSessionName(); // For legacy extras not using startCMSSession
5 5
 
6
-function genEvoSessionName() {
6
+function genEvoSessionName()
7
+{
7 8
     $_ = crc32(__FILE__);
8 9
     $_ = sprintf('%u', $_);
9 10
     return 'evo' . base_convert($_,10,36);
10 11
 }
11 12
 
12
-function startCMSSession(){
13
+function startCMSSession()
14
+{
13 15
     
14 16
     global $site_sessionname, $https_port, $session_cookie_path, $session_cookie_domain;
15 17
     
@@ -23,24 +25,27 @@  discard block
 block discarded – undo
23 25
     session_start();
24 26
 
25 27
     $key = "modx.{$context}.session.cookie.lifetime";
26
-    if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
28
+    if (isset($_SESSION[$key]) && is_numeric($_SESSION[$key])) {
27 29
         $cookieLifetime= intval($_SESSION[$key]);
28
-        if($cookieLifetime) $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime;
30
+        if($cookieLifetime) {
31
+            $cookieExpiration = $_SERVER['REQUEST_TIME']+$cookieLifetime;
32
+        }
29 33
         setcookie(session_name(), session_id(), $cookieExpiration, $cookiePath, $cookieDomain, $secure, true);
30 34
     }
31
-    if (!isset($_SESSION['modx.session.created.time'])) {
35
+    if (!isset($_SESSION['modx.session.created.time'])) {
32 36
         $_SESSION['modx.session.created.time'] = $_SERVER['REQUEST_TIME'];
33 37
     }
34 38
 }
35 39
 
36
-function removeInvalidCmsSessionFromStorage(&$storage, $session_name) {
37
-    if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted'))
38
-    {
40
+function removeInvalidCmsSessionFromStorage(&$storage, $session_name)
41
+{
42
+    if (isset($storage[$session_name]) && ($storage[$session_name] === '' || $storage[$session_name] === 'deleted')) {
39 43
     unset($storage[$session_name]);
40 44
     }
41 45
 }
42 46
 
43
-function removeInvalidCmsSessionIds($session_name) {
47
+function removeInvalidCmsSessionIds($session_name)
48
+{
44 49
     // session ids is invalid iff it is empty string
45 50
     // storage priorioty can see in PHP source ext/session/session.c
46 51
     removeInvalidCmsSessionFromStorage($_COOKIE, $session_name);
Please login to merge, or discard this patch.
manager/includes/categories.inc.php 1 patch
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,18 +3,22 @@  discard block
 block discarded – undo
3 3
 //Kyle Jaebker - 08/07/06
4 4
 
5 5
 //Create a new category
6
-function newCategory($newCat) {
6
+function newCategory($newCat)
7
+{
7 8
     global $modx;
8 9
     $useTable = $modx->getFullTableName('categories');
9 10
     $categoryId = $modx->db->insert(
10 11
         array(
11 12
             'category' => $modx->db->escape($newCat),
12 13
         ), $useTable);
13
-    if (!$categoryId) $categoryId = 0;
14
+    if (!$categoryId) {
15
+        $categoryId = 0;
16
+    }
14 17
     return $categoryId;
15 18
 }
16 19
 //check if new category already exists
17
-function checkCategory($newCat = '') {
20
+function checkCategory($newCat = '')
21
+{
18 22
     global $modx;
19 23
     $useTable = $modx->getFullTableName('categories');
20 24
     $newCat = $modx->db->escape($newCat);
@@ -25,13 +29,17 @@  discard block
 block discarded – undo
25 29
     return 0;
26 30
 }
27 31
 //Check for category, create new if not exists
28
-function getCategory($category='') {
32
+function getCategory($category='')
33
+{
29 34
     $categoryId = checkCategory($category);
30
-    if(!$categoryId) $categoryId = newCategory($category);
35
+    if(!$categoryId) {
36
+        $categoryId = newCategory($category);
37
+    }
31 38
     return $categoryId;
32 39
 }
33 40
 //Get all categories
34
-function getCategories() {
41
+function getCategories()
42
+{
35 43
     global $modx;
36 44
     $useTable = $modx->getFullTableName('categories');
37 45
     $cats = $modx->db->select('id, category', $modx->getFullTableName('categories'), '', 'category');
@@ -43,7 +51,8 @@  discard block
 block discarded – undo
43 51
     return $resourceArray;
44 52
 }
45 53
 //Delete category & associations
46
-function deleteCategory($catId=0) {
54
+function deleteCategory($catId=0)
55
+{
47 56
     global $modx;
48 57
     if ($catId) {
49 58
         $resetTables = array('site_plugins', 'site_snippets', 'site_htmlsnippets', 'site_templates', 'site_tmplvars', 'site_modules');
Please login to merge, or discard this patch.
manager/includes/protect.inc.php 1 patch
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,37 +6,50 @@
 block discarded – undo
6 6
 error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
7 7
 
8 8
 // Null is evil
9
-if (isset($_SERVER['QUERY_STRING']) && strpos(urldecode($_SERVER['QUERY_STRING']), chr(0)) !== false)
9
+if (isset($_SERVER['QUERY_STRING']) && strpos(urldecode($_SERVER['QUERY_STRING']), chr(0)) !== false) {
10 10
     die();
11
+}
11 12
 
12 13
 global $sanitize_seed;
13 14
 $sanitize_seed = 'sanitize_seed_' . base_convert(md5(__FILE__),16,36);
14 15
 
15 16
 // sanitize array
16 17
 if (!function_exists('modx_sanitize_gpc')) {
17
-    function modx_sanitize_gpc(& $values, $depth=0) {
18
-        if(200 < $depth) exit('GPC Array nested too deep!');
18
+    function modx_sanitize_gpc(& $values, $depth=0)
19
+    {
20
+        if(200 < $depth) {
21
+            exit('GPC Array nested too deep!');
22
+        }
19 23
         if(is_array($values)) {
20 24
             $depth++;
21 25
             foreach ($values as $key => $value) {
22
-                if (is_array($value)) modx_sanitize_gpc($value, $depth);
23
-                else                  $values[$key] = getSanitizedValue($value);
26
+                if (is_array($value)) {
27
+                    modx_sanitize_gpc($value, $depth);
28
+                } else {
29
+                    $values[$key] = getSanitizedValue($value);
30
+                }
24 31
             }
32
+        } else {
33
+            $values = getSanitizedValue($values);
25 34
         }
26
-        else $values = getSanitizedValue($values);
27 35
         
28 36
         return $values;
29 37
     }
30 38
 }
31 39
 
32
-function getSanitizedValue($value='') {
40
+function getSanitizedValue($value='')
41
+{
33 42
     global $sanitize_seed;
34 43
     
35
-    if(!$value) return $value;
44
+    if(!$value) {
45
+        return $value;
46
+    }
36 47
     
37 48
     $brackets = explode(' ', '[[ ]] [! !] [* *] [( )] {{ }} [+ +] [~ ~] [^ ^]');
38 49
     foreach($brackets as $bracket) {
39
-        if(strpos($value,$bracket)===false) continue;
50
+        if(strpos($value,$bracket)===false) {
51
+            continue;
52
+        }
40 53
         $sanitizedBracket = str_replace('#', $sanitize_seed, sprintf('#%s#%s#', substr($bracket,0,1), substr($bracket,1,1)));
41 54
         $value = str_replace($bracket,$sanitizedBracket,$value);
42 55
     }
Please login to merge, or discard this patch.