Completed
Push — 1.10.x ( c135db...ea3352 )
by Julito
26:21
created
main/inc/lib/getid3/getid3.php 1 patch
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -27,42 +27,42 @@  discard block
 block discarded – undo
27 27
     //// Settings Section - do NOT modify this file - change setting after newing getid3!
28 28
 
29 29
     // Encoding
30
-    public $encoding                 = 'ISO-8859-1';      // CASE SENSITIVE! - i.e. (must be supported by iconv() - see http://www.gnu.org/software/libiconv/).  Examples:  ISO-8859-1  UTF-8  UTF-16  UTF-16BE.
31
-    public $encoding_id3v1           = 'ISO-8859-1';      // Override SPECIFICATION encoding for broken ID3v1 tags caused by bad tag programs. Examples: 'EUC-CN' for "Chinese MP3s" and 'CP1251' for "Cyrillic".
32
-    public $encoding_id3v2           = 'ISO-8859-1';      // Override ISO-8859-1 encoding for broken ID3v2 tags caused by BRAINDEAD tag programs that writes system codepage as 'ISO-8859-1' instead of UTF-8.
30
+    public $encoding                 = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv() - see http://www.gnu.org/software/libiconv/).  Examples:  ISO-8859-1  UTF-8  UTF-16  UTF-16BE.
31
+    public $encoding_id3v1           = 'ISO-8859-1'; // Override SPECIFICATION encoding for broken ID3v1 tags caused by bad tag programs. Examples: 'EUC-CN' for "Chinese MP3s" and 'CP1251' for "Cyrillic".
32
+    public $encoding_id3v2           = 'ISO-8859-1'; // Override ISO-8859-1 encoding for broken ID3v2 tags caused by BRAINDEAD tag programs that writes system codepage as 'ISO-8859-1' instead of UTF-8.
33 33
 
34 34
     // Tags - disable for speed
35
-    public $option_tag_id3v1         = false;              // Read and process ID3v1 tags.
36
-    public $option_tag_id3v2         = false;              // Read and process ID3v2 tags.
37
-    public $option_tag_lyrics3       = false;              // Read and process Lyrics3 tags.
38
-    public $option_tag_apetag        = false;              // Read and process APE tags.
35
+    public $option_tag_id3v1         = false; // Read and process ID3v1 tags.
36
+    public $option_tag_id3v2         = false; // Read and process ID3v2 tags.
37
+    public $option_tag_lyrics3       = false; // Read and process Lyrics3 tags.
38
+    public $option_tag_apetag        = false; // Read and process APE tags.
39 39
 
40 40
     // Misc calucations - disable for speed
41
-    public $option_analyze           = true;              // Analyze file - disable if you only need to detect file format.
42
-    public $option_accurate_results  = true;              // Disable to greatly speed up parsing of some file formats at the cost of accuracy.
43
-    public $option_tags_process      = true;              // Copy tags to root key 'tags' and 'comments' and encode to $this->encoding.
44
-    public $option_tags_images       = false;             // Scan tags for binary image data - ID3v2 and vorbiscomments only.
45
-    public $option_extra_info        = true;              // Calculate/return additional info such as bitrate, channelmode etc.
46
-    public $option_max_2gb_check     = false;             // Check whether file is larger than 2 Gb and thus not supported by PHP.
41
+    public $option_analyze           = true; // Analyze file - disable if you only need to detect file format.
42
+    public $option_accurate_results  = true; // Disable to greatly speed up parsing of some file formats at the cost of accuracy.
43
+    public $option_tags_process      = true; // Copy tags to root key 'tags' and 'comments' and encode to $this->encoding.
44
+    public $option_tags_images       = false; // Scan tags for binary image data - ID3v2 and vorbiscomments only.
45
+    public $option_extra_info        = true; // Calculate/return additional info such as bitrate, channelmode etc.
46
+    public $option_max_2gb_check     = false; // Check whether file is larger than 2 Gb and thus not supported by PHP.
47 47
 
48 48
     // Misc data hashes - slow - require hash module
49
-    public $option_md5_data          = false;             // Get MD5 sum of data part - slow.
50
-    public $option_md5_data_source   = false;             // Use MD5 of source file if available - only FLAC, MAC, OptimFROG and Wavpack4.
51
-    public $option_sha1_data         = false;             // Get SHA1 sum of data part - slow.
49
+    public $option_md5_data          = false; // Get MD5 sum of data part - slow.
50
+    public $option_md5_data_source   = false; // Use MD5 of source file if available - only FLAC, MAC, OptimFROG and Wavpack4.
51
+    public $option_sha1_data         = false; // Get SHA1 sum of data part - slow.
52 52
 
53 53
     // Public variables
54
-    public $filename;                                     // Filename of file being analysed.
55
-    public $fp;                                           // Filepointer to file being analysed.
56
-    public $info;                                         // Result array.
54
+    public $filename; // Filename of file being analysed.
55
+    public $fp; // Filepointer to file being analysed.
56
+    public $info; // Result array.
57 57
 
58 58
     // Protected variables
59
-    protected $include_path;                              // getid3 include path.
60
-    protected $warnings = array ();
59
+    protected $include_path; // getid3 include path.
60
+    protected $warnings = array();
61 61
     protected $iconv_present;
62 62
 
63 63
     // Class constants
64 64
     const VERSION           = '2.0.0b4';
65
-    const FREAD_BUFFER_SIZE = 16384;                      // Read buffer size in bytes.
65
+    const FREAD_BUFFER_SIZE = 16384; // Read buffer size in bytes.
66 66
     const ICONV_TEST_STRING = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~�������������������������������� �����������������������������������������������������������������������������������������������';
67 67
 
68 68
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         }
88 88
 
89 89
         // Get include_path
90
-        $this->include_path = $include_path = dirname(__FILE__) . '/';
90
+        $this->include_path = $include_path = dirname(__FILE__).'/';
91 91
 
92 92
         // Check for presence of iconv() and make sure it works (simpel test only).
93 93
         if (function_exists('iconv') && @iconv('UTF-16LE', 'ISO-8859-1', @iconv('ISO-8859-1', 'UTF-16LE', getid3::ICONV_TEST_STRING)) == getid3::ICONV_TEST_STRING) {
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
 
125 125
         // Check safe_mode off
126
-        if ((bool)ini_get('safe_mode')) {
126
+        if ((bool) ini_get('safe_mode')) {
127 127
             $this->warning('Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbis/flac tag writing disabled.');
128 128
         }
129 129
 
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 
138 138
         // Init and save values
139 139
         $this->filename = $filename;
140
-        $this->warnings = array ();
140
+        $this->warnings = array();
141 141
 
142 142
         // Init result array and set parameters
143
-        $this->info = array ();
143
+        $this->info = array();
144 144
         $this->info['GETID3_VERSION'] = getid3::VERSION;
145 145
 
146 146
         // Remote files not supported
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 
180 180
             fseek($this->fp, 0, SEEK_SET);
181 181
             $header = fread($this->fp, 10);
182
-            if (substr($header, 0, 3) == 'ID3'  &&  strlen($header) == 10) {
182
+            if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) {
183 183
                 $this->info['id3v2']['header']        = true;
184 184
                 $this->info['id3v2']['majorversion']  = ord($header{3});
185 185
                 $this->info['id3v2']['minorversion']  = ord($header{4});
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 
190 190
 
191 191
         // Handle tags
192
-        foreach (array ("id3v2", "id3v1", "apetag", "lyrics3") as $tag_name) {
192
+        foreach (array("id3v2", "id3v1", "apetag", "lyrics3") as $tag_name) {
193 193
 
194
-            $option_tag = 'option_tag_' . $tag_name;
194
+            $option_tag = 'option_tag_'.$tag_name;
195 195
             if ($this->$option_tag) {
196 196
                 $this->include_module('tag.'.$tag_name);
197 197
                 try {
198
-                    $tag_class = 'getid3_' . $tag_name;
198
+                    $tag_class = 'getid3_'.$tag_name;
199 199
                     $tag = new $tag_class($this);
200 200
                     $tag->Analyze();
201 201
                 }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                     return $this->info;
232 232
                 }
233 233
 
234
-                $determined_format = $info;  // copy $info deleted by foreach()
234
+                $determined_format = $info; // copy $info deleted by foreach()
235 235
                 continue;
236 236
             }
237 237
         }
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
             // Set playtime string
343 343
             if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
344
-                $this->info['playtime_string'] =  floor(round($this->info['playtime_seconds']) / 60) . ':' . str_pad(floor(round($this->info['playtime_seconds']) % 60), 2, 0, STR_PAD_LEFT);;
344
+                $this->info['playtime_string'] = floor(round($this->info['playtime_seconds']) / 60).':'.str_pad(floor(round($this->info['playtime_seconds']) % 60), 2, 0, STR_PAD_LEFT); ;
345 345
             }
346 346
 
347 347
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
             if (@$this->info['video'] && @$this->info['video']['resolution_x'] && @$this->info['video']['resolution_y'] && @$this->info['video']['bits_per_sample']) {
350 350
 
351 351
                 // From static image formats
352
-                if (in_array($this->info['video']['dataformat'], array ('bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff'))) {
352
+                if (in_array($this->info['video']['dataformat'], array('bmp', 'gif', 'jpeg', 'jpg', 'png', 'tiff'))) {
353 353
                     $frame_rate         = 1;
354 354
                     $bitrate_compressed = $this->info['filesize'] * 8;
355 355
                 }
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
     //  Clear all warnings when cloning
472 472
     public function __clone() {
473 473
 
474
-        $this->warnings = array ();
474
+        $this->warnings = array();
475 475
 
476 476
         // Copy info array, otherwise it will be a reference.
477 477
         $temp = $this->info;
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
             return $result;
504 504
         }
505 505
 
506
-        $this->warning('iconv() was unable to convert the string: "' . $string . '" from ' . $in_charset . ' to ' . $out_charset);
506
+        $this->warning('iconv() was unable to convert the string: "'.$string.'" from '.$in_charset.' to '.$out_charset);
507 507
         return $string;
508 508
     }
509 509
 
@@ -534,12 +534,12 @@  discard block
 block discarded – undo
534 534
     // Return array containing information about all supported formats
535 535
     public static function GetFileFormatArray() {
536 536
 
537
-        static $format_info = array (
537
+        static $format_info = array(
538 538
 
539 539
                 // Audio formats
540 540
 
541 541
                 // AC-3   - audio      - Dolby AC-3 / Dolby Digital
542
-                'ac3'  => array (
542
+                'ac3'  => array(
543 543
                             'pattern'   => '^\x0B\x77',
544 544
                             'group'     => 'audio',
545 545
                             'module'    => 'ac3',
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
                           ),
548 548
 
549 549
                 // AAC  - audio       - Advanced Audio Coding (AAC) - ADIF format
550
-                'adif' => array (
550
+                'adif' => array(
551 551
                             'pattern'   => '^ADIF',
552 552
                             'group'     => 'audio',
553 553
                             'module'    => 'aac_adif',
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
 
559 559
                 // AAC  - audio       - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
560
-                'adts' => array (
560
+                'adts' => array(
561 561
                             'pattern'   => '^\xFF[\xF0-\xF1\xF8-\xF9]',
562 562
                             'group'     => 'audio',
563 563
                             'module'    => 'aac_adts',
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 
568 568
 
569 569
                 // AU   - audio       - NeXT/Sun AUdio (AU)
570
-                'au'   => array (
570
+                'au'   => array(
571 571
                             'pattern'   => '^\.snd',
572 572
                             'group'     => 'audio',
573 573
                             'module'    => 'au',
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
                           ),
576 576
 
577 577
                 // AVR  - audio       - Audio Visual Research
578
-                'avr'  => array (
578
+                'avr'  => array(
579 579
                             'pattern'   => '^2BIT',
580 580
                             'group'     => 'audio',
581 581
                             'module'    => 'avr',
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
                           ),
584 584
 
585 585
                 // BONK - audio       - Bonk v0.9+
586
-                'bonk' => array (
586
+                'bonk' => array(
587 587
                             'pattern'   => '^\x00(BONK|INFO|META| ID3)',
588 588
                             'group'     => 'audio',
589 589
                             'module'    => 'bonk',
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 						),
600 600
 
601 601
                 // FLAC - audio       - Free Lossless Audio Codec
602
-                'flac' => array (
602
+                'flac' => array(
603 603
                             'pattern'   => '^fLaC',
604 604
                             'group'     => 'audio',
605 605
                             'module'    => 'xiph',
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
                           ),
608 608
 
609 609
                 // LA   - audio       - Lossless Audio (LA)
610
-                'la'   => array (
610
+                'la'   => array(
611 611
                             'pattern'   => '^LA0[2-4]',
612 612
                             'group'     => 'audio',
613 613
                             'module'    => 'la',
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
                           ),
616 616
 
617 617
                 // LPAC - audio       - Lossless Predictive Audio Compression (LPAC)
618
-                'lpac' => array (
618
+                'lpac' => array(
619 619
                             'pattern'   => '^LPAC',
620 620
                             'group'     => 'audio',
621 621
                             'module'    => 'lpac',
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
                           ),
624 624
 
625 625
                 // MIDI - audio       - MIDI (Musical Instrument Digital Interface)
626
-                'midi' => array (
626
+                'midi' => array(
627 627
                             'pattern'   => '^MThd',
628 628
                             'group'     => 'audio',
629 629
                             'module'    => 'midi',
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
                           ),
632 632
 
633 633
                 // MAC  - audio       - Monkey's Audio Compressor
634
-                'mac'  => array (
634
+                'mac'  => array(
635 635
                             'pattern'   => '^MAC ',
636 636
                             'group'     => 'audio',
637 637
                             'module'    => 'monkey',
@@ -639,31 +639,31 @@  discard block
 block discarded – undo
639 639
                           ),
640 640
 
641 641
                 // MOD  - audio       - MODule (assorted sub-formats)
642
-                'mod'  => array (
642
+                'mod'  => array(
643 643
                             'pattern'   => '^.{1080}(M.K.|[5-9]CHN|[1-3][0-9]CH)',
644 644
                             'mime_type' => 'audio/mod',
645 645
                           ),
646 646
 
647 647
                 // MOD  - audio       - MODule (Impulse Tracker)
648
-                'it'   => array (
648
+                'it'   => array(
649 649
                             'pattern'   => '^IMPM',
650 650
                             'mime_type' => 'audio/it',
651 651
                           ),
652 652
 
653 653
                 // MOD  - audio       - MODule (eXtended Module, various sub-formats)
654
-                'xm'   => array (
654
+                'xm'   => array(
655 655
                             'pattern'   => '^Extended Module',
656 656
                             'mime_type' => 'audio/xm',
657 657
                           ),
658 658
 
659 659
                 // MOD  - audio       - MODule (ScreamTracker)
660
-                's3m'  => array (
660
+                's3m'  => array(
661 661
                             'pattern'   => '^.{44}SCRM',
662 662
                             'mime_type' => 'audio/s3m',
663 663
                           ),
664 664
 
665 665
                 // MPC  - audio       - Musepack / MPEGplus SV7+
666
-                'mpc'  => array (
666
+                'mpc'  => array(
667 667
                             'pattern'   => '^(MP\+)',
668 668
                             'group'     => 'audio',
669 669
                             'module'    => 'mpc',
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
                           ),
672 672
 
673 673
                 // MPC  - audio       - Musepack / MPEGplus SV4-6
674
-                'mpc_old' => array (
674
+                'mpc_old' => array(
675 675
                             'pattern'   => '^([\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
676 676
                             'group'     => 'audio',
677 677
                             'module'    => 'mpc_old',
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 
681 681
 
682 682
                 // MP3  - audio       - MPEG-audio Layer 3 (very similar to AAC-ADTS)
683
-                'mp3'  => array (
683
+                'mp3'  => array(
684 684
                             'pattern'   => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]',
685 685
                             'group'     => 'audio',
686 686
                             'module'    => 'mp3',
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
                           ),
689 689
 
690 690
                 // OFR  - audio       - OptimFROG
691
-                'ofr'  => array (
691
+                'ofr'  => array(
692 692
                             'pattern'   => '^(\*RIFF|OFR)',
693 693
                             'group'     => 'audio',
694 694
                             'module'    => 'optimfrog',
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
                           ),
697 697
 
698 698
                 // RKAU - audio       - RKive AUdio compressor
699
-                'rkau' => array (
699
+                'rkau' => array(
700 700
                             'pattern'   => '^RKA',
701 701
                             'group'     => 'audio',
702 702
                             'module'    => 'rkau',
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
                           ),
705 705
 
706 706
                 // SHN  - audio       - Shorten
707
-                'shn'  => array (
707
+                'shn'  => array(
708 708
                             'pattern'   => '^ajkg',
709 709
                             'group'     => 'audio',
710 710
                             'module'    => 'shorten',
@@ -714,15 +714,15 @@  discard block
 block discarded – undo
714 714
                           ),
715 715
 
716 716
                 // TTA  - audio       - TTA Lossless Audio Compressor (http://tta.corecodec.org)
717
-                'tta'  => array (
718
-                            'pattern'   => '^TTA',  // could also be '^TTA(\x01|\x02|\x03|2|1)'
717
+                'tta'  => array(
718
+                            'pattern'   => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
719 719
                             'group'     => 'audio',
720 720
                             'module'    => 'tta',
721 721
                             'mime_type' => 'application/octet-stream',
722 722
                           ),
723 723
 
724 724
                 // VOC  - audio       - Creative Voice (VOC)
725
-                'voc'  => array (
725
+                'voc'  => array(
726 726
                             'pattern'   => '^Creative Voice File',
727 727
                             'group'     => 'audio',
728 728
                             'module'    => 'voc',
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
                           ),
731 731
 
732 732
                 // VQF  - audio       - transform-domain weighted interleave Vector Quantization Format (VQF)
733
-                'vqf'  => array (
733
+                'vqf'  => array(
734 734
                             'pattern'   => '^TWIN',
735 735
                             'group'     => 'audio',
736 736
                             'module'    => 'vqf',
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
                 // Audio-Video formats
750 750
 
751 751
                 // ASF  - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
752
-                'asf'  => array (
752
+                'asf'  => array(
753 753
                             'pattern'   => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
754 754
                             'group'     => 'audio-video',
755 755
                             'module'    => 'asf',
@@ -771,13 +771,13 @@  discard block
 block discarded – undo
771 771
                           ),
772 772
 
773 773
                 // MKAV - audio/video - Mastroka
774
-                'matroska' => array (
774
+                'matroska' => array(
775 775
                             'pattern'   => '^\x1A\x45\xDF\xA3',
776 776
                             'mime_type' => 'application/octet-stream',
777 777
                           ),
778 778
 
779 779
                 // MPEG - audio/video - MPEG (Moving Pictures Experts Group)
780
-                'mpeg' => array (
780
+                'mpeg' => array(
781 781
                             'pattern'   => '^\x00\x00\x01(\xBA|\xB3)',
782 782
                             'group'     => 'audio-video',
783 783
                             'module'    => 'mpeg',
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
                           ),
786 786
 
787 787
                 // NSV  - audio/video - Nullsoft Streaming Video (NSV)
788
-                'nsv'  => array (
788
+                'nsv'  => array(
789 789
                             'pattern'   => '^NSV[sf]',
790 790
                             'group'     => 'audio-video',
791 791
                             'module'    => 'nsv',
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
                           ),
794 794
 
795 795
                 // Ogg  - audio/video - Ogg (Ogg Vorbis, OggFLAC, Speex, Ogg Theora(*), Ogg Tarkin(*))
796
-                'ogg'  => array (
796
+                'ogg'  => array(
797 797
                             'pattern'   => '^OggS',
798 798
                             'group'     => 'audio',
799 799
                             'module'    => 'xiph',
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
                           ),
804 804
 
805 805
                 // QT   - audio/video - Quicktime
806
-                'quicktime' => array (
806
+                'quicktime' => array(
807 807
                             'pattern'   => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
808 808
                             'group'     => 'audio-video',
809 809
                             'module'    => 'quicktime',
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
                           ),
812 812
 
813 813
                 // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
814
-                'riff' => array (
814
+                'riff' => array(
815 815
                             'pattern'   => '^(RIFF|SDSS|FORM)',
816 816
                             'group'     => 'audio-video',
817 817
                             'module'    => 'riff',
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
                           ),
821 821
 
822 822
                 // Real - audio/video - RealAudio, RealVideo
823
-                'real' => array (
823
+                'real' => array(
824 824
                             'pattern'   => '^(\.RMF|.ra)',
825 825
                             'group'     => 'audio-video',
826 826
                             'module'    => 'real',
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
                           ),
829 829
 
830 830
                 // SWF - audio/video - ShockWave Flash
831
-                'swf' => array (
831
+                'swf' => array(
832 832
                             'pattern'   => '^(F|C)WS',
833 833
                             'group'     => 'audio-video',
834 834
                             'module'    => 'swf',
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
                 // Still-Image formats
840 840
 
841 841
                 // BMP  - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
842
-                'bmp'  => array (
842
+                'bmp'  => array(
843 843
                             'pattern'   => '^BM',
844 844
                             'group'     => 'graphic',
845 845
                             'module'    => 'bmp',
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
                           ),
850 850
 
851 851
                 // GIF  - still image - Graphics Interchange Format
852
-                'gif'  => array (
852
+                'gif'  => array(
853 853
                             'pattern'   => '^GIF',
854 854
                             'group'     => 'graphic',
855 855
                             'module'    => 'gif',
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
                           ),
860 860
 
861 861
                 // JPEG - still image - Joint Photographic Experts Group (JPEG)
862
-                'jpeg'  => array (
862
+                'jpeg'  => array(
863 863
                             'pattern'   => '^\xFF\xD8\xFF',
864 864
                             'group'     => 'graphic',
865 865
                             'module'    => 'jpeg',
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
                           ),
870 870
 
871 871
                 // PCD  - still image - Kodak Photo CD
872
-                'pcd'  => array (
872
+                'pcd'  => array(
873 873
                             'pattern'   => '^.{2048}PCD_IPI\x00',
874 874
                             'group'     => 'graphic',
875 875
                             'module'    => 'pcd',
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 
881 881
 
882 882
                 // PNG  - still image - Portable Network Graphics (PNG)
883
-                'png'  => array (
883
+                'png'  => array(
884 884
                             'pattern'   => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
885 885
                             'group'     => 'graphic',
886 886
                             'module'    => 'png',
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 
901 901
 
902 902
                 // TIFF  - still image - Tagged Information File Format (TIFF)
903
-                'tiff' => array (
903
+                'tiff' => array(
904 904
                             'pattern'   => '^(II\x2A\x00|MM\x00\x2A)',
905 905
                             'group'     => 'graphic',
906 906
                             'module'    => 'tiff',
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
                           ),
921 921
 
922 922
                 // ISO  - data        - International Standards Organization (ISO) CD-ROM Image
923
-                'iso'  => array (
923
+                'iso'  => array(
924 924
                             'pattern'   => '^.{32769}CD001',
925 925
                             'group'     => 'misc',
926 926
                             'module'    => 'iso',
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
                           ),
939 939
 
940 940
                 // SZIP - audio       - SZIP compressed data
941
-                'szip' => array (
941
+                'szip' => array(
942 942
                             'pattern'   => '^SZ\x0A\x04',
943 943
                             'group'     => 'archive',
944 944
                             'module'    => 'szip',
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 
970 970
 
971 971
                 // ZIP  - data        - ZIP compressed data
972
-                'zip'  => array (
972
+                'zip'  => array(
973 973
                             'pattern'   => '^PK\x03\x04',
974 974
                             'group'     => 'archive',
975 975
                             'module'    => 'zip',
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 
981 981
 
982 982
                 // PAR2 - data        - Parity Volume Set Specification 2.0
983
-                'par2' => array (
983
+                'par2' => array(
984 984
                 			'pattern'   => '^PAR2\x00PKT',
985 985
 							'mime_type' => 'application/octet-stream',
986 986
 							'fail_id3'  => 'ERROR',
@@ -1039,22 +1039,22 @@  discard block
 block discarded – undo
1039 1039
     protected function HandleAllTags() {
1040 1040
 
1041 1041
         // Key name => array (tag name, character encoding)
1042
-        static $tags = array (
1043
-            'asf'       => array ('asf',           'UTF-16LE'),
1044
-            'midi'      => array ('midi',          'ISO-8859-1'),
1045
-            'nsv'       => array ('nsv',           'ISO-8859-1'),
1046
-            'ogg'       => array ('vorbiscomment', 'UTF-8'),
1047
-            'png'       => array ('png',           'UTF-8'),
1048
-            'tiff'      => array ('tiff',          'ISO-8859-1'),
1049
-            'quicktime' => array ('quicktime',     'ISO-8859-1'),
1050
-            'real'      => array ('real',          'ISO-8859-1'),
1051
-            'vqf'       => array ('vqf',           'ISO-8859-1'),
1052
-            'zip'       => array ('zip',           'ISO-8859-1'),
1053
-            'riff'      => array ('riff',          'ISO-8859-1'),
1054
-            'lyrics3'   => array ('lyrics3',       'ISO-8859-1'),
1055
-            'id3v1'     => array ('id3v1',         ''),            // change below - cannot assign variable to static array
1056
-            'id3v2'     => array ('id3v2',         'UTF-8'),       // module converts all frames to UTF-8
1057
-            'ape'       => array ('ape',           'UTF-8')
1042
+        static $tags = array(
1043
+            'asf'       => array('asf', 'UTF-16LE'),
1044
+            'midi'      => array('midi', 'ISO-8859-1'),
1045
+            'nsv'       => array('nsv', 'ISO-8859-1'),
1046
+            'ogg'       => array('vorbiscomment', 'UTF-8'),
1047
+            'png'       => array('png', 'UTF-8'),
1048
+            'tiff'      => array('tiff', 'ISO-8859-1'),
1049
+            'quicktime' => array('quicktime', 'ISO-8859-1'),
1050
+            'real'      => array('real', 'ISO-8859-1'),
1051
+            'vqf'       => array('vqf', 'ISO-8859-1'),
1052
+            'zip'       => array('zip', 'ISO-8859-1'),
1053
+            'riff'      => array('riff', 'ISO-8859-1'),
1054
+            'lyrics3'   => array('lyrics3', 'ISO-8859-1'),
1055
+            'id3v1'     => array('id3v1', ''), // change below - cannot assign variable to static array
1056
+            'id3v2'     => array('id3v2', 'UTF-8'), // module converts all frames to UTF-8
1057
+            'ape'       => array('ape', 'UTF-8')
1058 1058
         );
1059 1059
         $tags['id3v1'][1] = $this->encoding_id3v1;
1060 1060
 
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
             list($tag_name, $encoding) = $tag_name_encoding_array;
1064 1064
 
1065 1065
             // Fill in default encoding type if not already present
1066
-            @$this->info[$comment_name]  and  $this->info[$comment_name]['encoding'] = $encoding;
1066
+            @$this->info[$comment_name] and $this->info[$comment_name]['encoding'] = $encoding;
1067 1067
 
1068 1068
             // Copy comments if key name set
1069 1069
             if (@$this->info[$comment_name]['comments']) {
@@ -1142,11 +1142,11 @@  discard block
 block discarded – undo
1142 1142
 abstract class getid3_handler
1143 1143
 {
1144 1144
 
1145
-    protected $getid3;                          // pointer
1145
+    protected $getid3; // pointer
1146 1146
 
1147
-    protected $data_string_flag = false;        // analyzing filepointer or string
1148
-    protected $data_string;                     // string to analyze
1149
-    protected $data_string_position = 0;        // seek position in string
1147
+    protected $data_string_flag = false; // analyzing filepointer or string
1148
+    protected $data_string; // string to analyze
1149
+    protected $data_string_position = 0; // seek position in string
1150 1150
 
1151 1151
 
1152 1152
     public function __construct(getID3 $getid3) {
@@ -1247,20 +1247,20 @@  discard block
 block discarded – undo
1247 1247
     public function __construct($filename) {
1248 1248
 
1249 1249
         if (!file_exists($filename)) {
1250
-            throw new getid3_exception('File does not exist: "' . $filename . '"');
1250
+            throw new getid3_exception('File does not exist: "'.$filename.'"');
1251 1251
         }
1252 1252
 
1253 1253
         if (!is_writeable($filename)) {
1254
-            throw new getid3_exception('File is not writeable: "' . $filename . '"');
1254
+            throw new getid3_exception('File is not writeable: "'.$filename.'"');
1255 1255
         }
1256 1256
 
1257 1257
         if (!is_writeable(dirname($filename))) {
1258
-            throw new getid3_exception('Directory is not writeable: ' . dirname($filename) . ' (need to write lock file).');
1258
+            throw new getid3_exception('Directory is not writeable: '.dirname($filename).' (need to write lock file).');
1259 1259
         }
1260 1260
 
1261 1261
         $this->user_abort = ignore_user_abort(true);
1262 1262
 
1263
-        $this->fp_lock = fopen($filename . '.getid3.lock', 'w');
1263
+        $this->fp_lock = fopen($filename.'.getid3.lock', 'w');
1264 1264
         flock($this->fp_lock, LOCK_EX);
1265 1265
 
1266 1266
         $this->filename = $filename;
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
 
1272 1272
         flock($this->fp_lock, LOCK_UN);
1273 1273
         fclose($this->fp_lock);
1274
-        unlink($this->filename . '.getid3.lock');
1274
+        unlink($this->filename.'.getid3.lock');
1275 1275
 
1276 1276
         ignore_user_abort($this->user_abort);
1277 1277
     }
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 
1326 1326
 
1327 1327
     // Convert number to Little Endian byte string
1328
-    public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
1328
+    public static function LittleEndian2String($number, $minbytes = 1, $synchsafe = false) {
1329 1329
         $intstring = '';
1330 1330
         while ($number > 0) {
1331 1331
             if ($synchsafe) {
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
 	}
1486 1486
 
1487 1487
 
1488
-	public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) {
1488
+	public static function PrintHexBytes($string, $hex = true, $spaces = true, $html_safe = true) {
1489 1489
 
1490 1490
         $return_string = '';
1491 1491
         for ($i = 0; $i < strlen($string); $i++) {
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
 
1546 1546
     public static function NameLookup($name_code) {
1547 1547
 
1548
-        static $lookup = array (
1548
+        static $lookup = array(
1549 1549
             0 => 'not set',
1550 1550
             1 => 'Track Gain Adjustment',
1551 1551
             2 => 'Album Gain Adjustment'
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 
1559 1559
     public static function OriginatorLookup($originator_code) {
1560 1560
 
1561
-        static $lookup = array (
1561
+        static $lookup = array(
1562 1562
             0 => 'unspecified',
1563 1563
             1 => 'pre-set by artist/producer/mastering engineer',
1564 1564
             2 => 'set by user',
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
 
1573 1573
     public static function AdjustmentLookup($raw_adjustment, $sign_bit) {
1574 1574
 
1575
-        return (float)$raw_adjustment / 10 * ($sign_bit == 1 ? -1 : 1);
1575
+        return (float) $raw_adjustment / 10 * ($sign_bit == 1 ? -1 : 1);
1576 1576
     }
1577 1577
 
1578 1578
 
Please login to merge, or discard this patch.
main/inc/lib/login_redirection.class.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,30 +18,30 @@  discard block
 block discarded – undo
18 18
         if (api_is_student() && !api_get_setting('student_page_after_login') == '') {
19 19
             $redirect_url = html_entity_decode(api_get_setting('student_page_after_login'));
20 20
             if ($redirect_url[0] == "/") {
21
-                $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url;
21
+                $redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url;
22 22
             }
23 23
         }
24 24
         if (api_is_teacher() && !api_get_setting('teacher_page_after_login') == '') {
25 25
             $redirect_url = html_entity_decode(api_get_setting('teacher_page_after_login'));
26 26
             if ($redirect_url[0] == "/") {
27
-                $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url;
27
+                $redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url;
28 28
             }
29 29
         }
30 30
         if (api_is_drh() && !api_get_setting('drh_page_after_login') == '') {
31 31
             $redirect_url = html_entity_decode(api_get_setting('drh_page_after_login'));
32 32
             if ($redirect_url[0] == "/") {
33
-                $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url;
33
+                $redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url;
34 34
             }
35 35
         }
36 36
         if (api_is_session_admin() && !api_get_setting('sessionadmin_page_after_login') == '') {
37 37
             $redirect_url = html_entity_decode(api_get_setting('sessionadmin_page_after_login'));
38 38
             if ($redirect_url[0] == "/") {
39
-                $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url;
39
+                $redirect_url = substr(api_get_path(WEB_PATH), 0, -1).$redirect_url;
40 40
             }
41 41
         }
42 42
 
43 43
         if (!empty($redirect_url)) {
44
-            header('Location: ' . $redirect_url . $param);
44
+            header('Location: '.$redirect_url.$param);
45 45
             exit();
46 46
         }
47 47
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         if (CustomPages::enabled()) {
50 50
             CustomPages::display(CustomPages::INDEX_LOGGED);
51 51
         }
52
-        header('location: ' . api_get_path(WEB_PATH) . api_get_setting('page_after_login') . $param);
52
+        header('location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login').$param);
53 53
         exit();
54 54
     }
55 55
 }
Please login to merge, or discard this patch.
main/inc/lib/attendance.lib.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             $course_id = intval($course_id);
74 74
         }
75 75
 
76
-        $session_id = isset($session_id)?intval($session_id):api_get_session_id();
76
+        $session_id = isset($session_id) ? intval($session_id) : api_get_session_id();
77 77
         $condition_session = api_get_session_condition($session_id);
78 78
 
79 79
         // Get attendance data
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                 WHERE c_id = $course_id AND active = 1 $condition_session ";
83 83
         $rs  = Database::query($sql);
84 84
         if (Database::num_rows($rs) > 0) {
85
-            while ($row = Database::fetch_array($rs,'ASSOC')) {
85
+            while ($row = Database::fetch_array($rs, 'ASSOC')) {
86 86
                 $data[$row['id']] = $row;
87 87
             }
88 88
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		$from = intval($from);
109 109
 		$number_of_items = intval($number_of_items);
110 110
 
111
-		if (!in_array($direction, array('ASC','DESC'))) {
111
+		if (!in_array($direction, array('ASC', 'DESC'))) {
112 112
 			$direction = 'ASC';
113 113
 		}
114 114
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 				LIMIT $from,$number_of_items ";
136 136
 
137 137
 		$res = Database::query($sql);
138
-		$attendances = array ();
138
+		$attendances = array();
139 139
 		$user_info = api_get_user_info();
140 140
 		$allowDelete = api_get_setting('allow_delete_attendance');
141 141
 
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 						$attendance[2] = '<span class="muted">'.$attendance[2].'</span>';
195 195
 					}
196 196
 					if ($allowDelete === 'true') {
197
-						$actions .= '<a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0]. '">' .
198
-							Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
197
+						$actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$attendance[0].'">'.
198
+							Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
199 199
 					}
200 200
 				} else {
201 201
 					$is_locked_attendance = self::is_locked_attendance($attendance[0]);
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 							$attendance[2] = '<span class="muted">'.$attendance[2].'</span>';
216 216
 						}
217 217
 						if ($allowDelete === 'true') {
218
-							$actions .= ' <a href="index.php?' . api_get_cidreq() . '&action=attendance_delete&attendance_id=' . $attendance[0].'">' .
219
-								Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
218
+							$actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$attendance[0].'">'.
219
+								Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
220 220
 						}
221 221
 					}
222 222
 				}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 				$is_done_all_calendar = self::is_all_attendance_calendar_done($attendance[0]);
226 226
 
227 227
 				if ($is_done_all_calendar) {
228
-					$locked   = $attendance[4];
228
+					$locked = $attendance[4];
229 229
 					if ($locked == 0) {
230 230
 						if (api_is_platform_admin()) {
231 231
 							$message_alert = get_lang('AreYouSureToLockTheAttendance');
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 				}
246 246
 				$actions .= '</center>';
247 247
 
248
-				$attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3],$actions);
248
+				$attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3], $actions);
249 249
 			} else {
250 250
 				$attendance[0] = '&nbsp;';
251 251
 				$attendances[] = array($attendance[0], $attendance[1], $attendance[2], $attendance[3]);
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 	public function attendance_add($link_to_gradebook = false)
286 286
 	{
287 287
 		$_course = api_get_course_info();
288
-		$tbl_attendance	= Database :: get_course_table(TABLE_ATTENDANCE);
288
+		$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
289 289
 		$table_link = Database:: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
290 290
 		$session_id = api_get_session_id();
291 291
 		$user_id = api_get_user_id();
292 292
 		$course_code = $_course['code'];
293 293
 		$course_id = $_course['real_id'];
294
-		$title_gradebook= $this->attendance_qualify_title;
294
+		$title_gradebook = $this->attendance_qualify_title;
295 295
 		$value_calification = 0;
296 296
 		$weight_calification = floatval($this->attendance_weight);
297 297
 
@@ -434,12 +434,12 @@  discard block
 block discarded – undo
434 434
 	public function attendance_restore($attendance_id)
435 435
 	{
436 436
 		$_course = api_get_course_info();
437
-		$tbl_attendance	= Database :: get_course_table(TABLE_ATTENDANCE);
437
+		$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
438 438
 		$user_id = api_get_user_id();
439 439
 		$course_id = $_course['real_id'];
440 440
 		if (is_array($attendance_id)) {
441 441
 			foreach ($attendance_id as $id) {
442
-				$id	= intval($id);
442
+				$id = intval($id);
443 443
 				$sql = "UPDATE $tbl_attendance SET active = 1
444 444
 						WHERE c_id = $course_id AND id = '$id'";
445 445
 				$result = Database::query($sql);
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
                     );
456 456
 				}
457 457
 			}
458
-		} else  {
459
-			$attendance_id	= intval($attendance_id);
458
+		} else {
459
+			$attendance_id = intval($attendance_id);
460 460
 			$sql = "UPDATE $tbl_attendance SET active = 1
461 461
 					WHERE c_id = $course_id AND id = '$attendance_id'";
462 462
 			$result = Database::query($sql);
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
 	public function attendance_delete($attendance_id)
485 485
 	{
486 486
 		$_course = api_get_course_info();
487
-		$tbl_attendance	= Database :: get_course_table(TABLE_ATTENDANCE);
487
+		$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
488 488
         $user_id = api_get_user_id();
489 489
         $course_id = $_course['real_id'];
490 490
 
491 491
 		if (is_array($attendance_id)) {
492 492
 			foreach ($attendance_id as $id) {
493
-				$id	= intval($id);
493
+				$id = intval($id);
494 494
 				$sql = "UPDATE $tbl_attendance SET active = 2
495 495
 						WHERE c_id = $course_id AND id = '$id'";
496 496
 				$result = Database::query($sql);
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
                     );
507 507
 				}
508 508
 			}
509
-		} else  {
510
-			$attendance_id= intval($attendance_id);
509
+		} else {
510
+			$attendance_id = intval($attendance_id);
511 511
 			$sql = "UPDATE $tbl_attendance SET active = 2
512 512
 					WHERE c_id = $course_id AND id = '$attendance_id'";
513 513
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 	public function changeVisibility($attendanceId, $status = 1)
539 539
 	{
540 540
 		$_course = api_get_course_info();
541
-		$tbl_attendance	= Database :: get_course_table(TABLE_ATTENDANCE);
541
+		$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
542 542
 		$user_id = api_get_user_id();
543 543
 		$course_id = $_course['real_id'];
544 544
 		$status = intval($status);
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 
551 551
 		if (is_array($attendanceId)) {
552 552
 			foreach ($attendanceId as $id) {
553
-				$id	= intval($id);
553
+				$id = intval($id);
554 554
 				$sql = "UPDATE $tbl_attendance SET active = $status
555 555
 						WHERE c_id = $course_id AND id = '$id'";
556 556
 				$result = Database::query($sql);
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
 					api_item_property_update($_course, TOOL_ATTENDANCE, $id, $action, $user_id);
561 561
 				}
562 562
 			}
563
-		} else  {
564
-			$attendanceId	= intval($attendanceId);
563
+		} else {
564
+			$attendanceId = intval($attendanceId);
565 565
 			$sql = "UPDATE $tbl_attendance SET active = $status
566 566
 					WHERE c_id = $course_id AND id = '$attendanceId'";
567 567
 			$result = Database::query($sql);
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 		$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
592 592
 		$course_id = api_get_course_int_id();
593 593
 		$attendance_id = intval($attendance_id);
594
-		$locked = ($lock)?1:0;
594
+		$locked = ($lock) ? 1 : 0;
595 595
 		$upd = "UPDATE $tbl_attendance SET locked = $locked
596 596
 				WHERE c_id = $course_id AND id = $attendance_id";
597 597
 		$result = Database::query($upd);
@@ -720,8 +720,8 @@  discard block
 block discarded – undo
720 720
 	 */
721 721
 	public function attendance_sheet_add($calendar_id, $users_present, $attendance_id)
722 722
 	{
723
-		$tbl_attendance_sheet 	= Database::get_course_table(TABLE_ATTENDANCE_SHEET);
724
-		$tbl_attendance_calendar= Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
723
+		$tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
724
+		$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
725 725
 
726 726
 		$calendar_id = intval($calendar_id);
727 727
 		$attendance_id = intval($attendance_id);
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 		$course_id = api_get_course_int_id();
730 730
 
731 731
 		$user_ids = array_keys($users);
732
-		$users_absent = array_diff($user_ids,$users_present);
732
+		$users_absent = array_diff($user_ids, $users_present);
733 733
 		$affected_rows = 0;
734 734
 
735 735
 		// get last edit type
@@ -993,13 +993,13 @@  discard block
 block discarded – undo
993 993
 	public function get_faults_of_user($user_id, $attendance_id, $groupId = null)
994 994
 	{
995 995
 		// initializing database table and variables
996
-		$user_id 		= intval($user_id);
996
+		$user_id = intval($user_id);
997 997
 		$attendance_id 	= intval($attendance_id);
998 998
 		$results = array();
999 999
 		$calendar_count = self::get_number_of_attendance_calendar($attendance_id, $groupId, NULL, $user_id);
1000 1000
 		// $total_done_attendance 	= $attendance_data['attendance_qualify_max'];
1001
-        $total_done_attendance 	= self::get_number_of_attendance_calendar($attendance_id, $groupId, true, $user_id);
1002
-		$attendance_user_score  = $this->get_user_score($user_id, $attendance_id, $groupId);
1001
+        $total_done_attendance = self::get_number_of_attendance_calendar($attendance_id, $groupId, true, $user_id);
1002
+		$attendance_user_score = $this->get_user_score($user_id, $attendance_id, $groupId);
1003 1003
 
1004 1004
 		//This is the main change of the BT#1381
1005 1005
 		//$total_done_attendance = $calendar_count;
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
         }
1013 1013
 
1014 1014
         $faults = $faults > 0 ? $faults : 0;
1015
-		$faults_porcent = $calendar_count > 0 ?round(($faults*100)/$calendar_count,0):0;
1015
+		$faults_porcent = $calendar_count > 0 ? round(($faults * 100) / $calendar_count, 0) : 0;
1016 1016
         $results['faults'] = $faults;
1017 1017
         $results['total'] = $calendar_count;
1018 1018
         $results['faults_porcent'] = $faults_porcent;
@@ -1046,13 +1046,13 @@  discard block
 block discarded – undo
1046 1046
 			//$course_code = $course['code'];
1047 1047
 			//$course_info = api_get_course_info($course_code);
1048 1048
 			$course_id = $course['real_id'];
1049
-			$tbl_attendance_result 	= Database::get_course_table(TABLE_ATTENDANCE_RESULT);
1049
+			$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
1050 1050
 
1051 1051
 			$attendances_by_course = $this->get_attendances_list($course_id);
1052 1052
 
1053 1053
 			foreach ($attendances_by_course as $attendance) {
1054 1054
 				// get total faults and total weight
1055
-				$total_done_attendance 	= $attendance['attendance_qualify_max'];
1055
+				$total_done_attendance = $attendance['attendance_qualify_max'];
1056 1056
 				$sql = "SELECT score
1057 1057
 						FROM $tbl_attendance_result
1058 1058
                         WHERE
@@ -1065,16 +1065,16 @@  discard block
 block discarded – undo
1065 1065
 					$row = Database::fetch_array($rs);
1066 1066
 					$score = $row['score'];
1067 1067
 				}
1068
-				$faults = $total_done_attendance-$score;
1069
-				$faults = $faults > 0 ? $faults:0;
1068
+				$faults = $total_done_attendance - $score;
1069
+				$faults = $faults > 0 ? $faults : 0;
1070 1070
 				$total_faults += $faults;
1071 1071
 				$total_weight += $total_done_attendance;
1072 1072
 			}
1073 1073
 		}
1074 1074
 
1075
-		$porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0;
1075
+		$porcent = $total_weight > 0 ? round(($total_faults * 100) / $total_weight, 0) : 0;
1076 1076
 		$results['faults'] 	= $total_faults;
1077
-		$results['total']	= $total_weight;
1077
+		$results['total'] = $total_weight;
1078 1078
 		$results['porcent'] = $porcent;
1079 1079
 
1080 1080
 		return $results;
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 	{
1093 1093
 		// Database tables and variables
1094 1094
 		$course_info = api_get_course_info($course_code);
1095
-		$tbl_attendance_result 	= Database::get_course_table(TABLE_ATTENDANCE_RESULT);
1095
+		$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
1096 1096
 		$user_id = intval($user_id);
1097 1097
 		$results = array();
1098 1098
 		$total_faults = $total_weight = $porcent = 0;
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 
1101 1101
 		foreach ($attendances_by_course as $attendance) {
1102 1102
 			// Get total faults and total weight
1103
-			$total_done_attendance 	= $attendance['attendance_qualify_max'];
1103
+			$total_done_attendance = $attendance['attendance_qualify_max'];
1104 1104
 			$sql = "SELECT score FROM $tbl_attendance_result
1105 1105
 					WHERE
1106 1106
 						c_id = {$course_info['real_id']} AND
@@ -1112,15 +1112,15 @@  discard block
 block discarded – undo
1112 1112
 				$row = Database::fetch_array($rs);
1113 1113
 				$score = $row['score'];
1114 1114
 			}
1115
-			$faults = $total_done_attendance-$score;
1116
-			$faults = $faults > 0 ? $faults:0;
1115
+			$faults = $total_done_attendance - $score;
1116
+			$faults = $faults > 0 ? $faults : 0;
1117 1117
 			$total_faults += $faults;
1118 1118
 			$total_weight += $total_done_attendance;
1119 1119
 		}
1120 1120
 
1121
-		$porcent = $total_weight > 0 ?round(($total_faults*100)/$total_weight,0):0;
1121
+		$porcent = $total_weight > 0 ? round(($total_faults * 100) / $total_weight, 0) : 0;
1122 1122
 		$results['faults'] 	= $total_faults;
1123
-		$results['total']	= $total_weight;
1123
+		$results['total'] = $total_weight;
1124 1124
 		$results['porcent'] = $porcent;
1125 1125
 
1126 1126
 		return $results;
@@ -1134,8 +1134,8 @@  discard block
 block discarded – undo
1134 1134
 	 */
1135 1135
 	public function get_users_attendance_sheet($attendance_id, $user_id = 0, $groupId = null)
1136 1136
 	{
1137
-		$tbl_attendance_sheet 	= Database::get_course_table(TABLE_ATTENDANCE_SHEET);
1138
-		$tbl_attendance_calendar= Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
1137
+		$tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
1138
+		$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
1139 1139
 
1140 1140
 		$attendance_calendar = $this->get_attendance_calendar($attendance_id, 'all', null, $groupId);
1141 1141
 		$calendar_ids = array();
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 					        WHERE
1158 1158
 					        	c_id = $course_id AND
1159 1159
 					        	user_id = '$uid' AND
1160
-					        	attendance_calendar_id IN(".implode(',',$calendar_ids).")
1160
+					        	attendance_calendar_id IN(".implode(',', $calendar_ids).")
1161 1161
 							";
1162 1162
 					$res = Database::query($sql);
1163 1163
 					if (Database::num_rows($res) > 0) {
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 							att.c_id = $course_id AND
1180 1180
 							cal.c_id =  $course_id AND
1181 1181
 							att.user_id = '$user_id' AND
1182
-							att.attendance_calendar_id IN (".implode(',',$calendar_ids).")
1182
+							att.attendance_calendar_id IN (".implode(',', $calendar_ids).")
1183 1183
                         ORDER BY date_time";
1184 1184
 				$res = Database::query($sql);
1185 1185
 				if (Database::num_rows($res) > 0) {
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 	 */
1256 1256
 	public function get_user_score($user_id, $attendance_id, $groupId = null)
1257 1257
 	{
1258
-		$tbl_attendance_result 	= Database::get_course_table(TABLE_ATTENDANCE_RESULT);
1258
+		$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
1259 1259
         $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
1260 1260
         $tbl_attendance_cal_rel_group = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR_REL_GROUP);
1261 1261
         $tbl_attendance_cal = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
                    ";
1370 1370
 		}
1371 1371
 
1372
-		if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done','calendar_id'))) {
1372
+		if (!in_array($type, array('today', 'all', 'all_done', 'all_not_done', 'calendar_id'))) {
1373 1373
 			$type = 'all';
1374 1374
 		}
1375 1375
 
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 			case 'calendar_id':
1378 1378
 				$calendar_id = intval($calendar_id);
1379 1379
 				if (!empty($calendar_id)) {
1380
-					$sql.= " AND c.id = $calendar_id";
1380
+					$sql .= " AND c.id = $calendar_id";
1381 1381
 				}
1382 1382
 				break;
1383 1383
 			case 'today':
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 		$rs = Database::query($sql);
1399 1399
 		$data = array();
1400 1400
 		if (Database::num_rows($rs) > 0) {
1401
-			while ($row = Database::fetch_array($rs,'ASSOC')) {
1401
+			while ($row = Database::fetch_array($rs, 'ASSOC')) {
1402 1402
 				$row['db_date_time'] = $row['date_time'];
1403 1403
 				$row['date_time'] = api_get_local_time($row['date_time']);
1404 1404
 				$row['date'] = api_format_date($row['date_time'], DATE_FORMAT_SHORT);
@@ -1762,14 +1762,14 @@  discard block
 block discarded – undo
1762 1762
 	 * @param   int     The number of years to add
1763 1763
 	 * @return  int     The new timestamp
1764 1764
 	 */
1765
-	private function add_month($timestamp, $num=1)
1765
+	private function add_month($timestamp, $num = 1)
1766 1766
 	{
1767 1767
 		$values = api_get_utc_datetime($timestamp);
1768
-		$values = str_replace(array(':','-',' '), '/', $values);
1769
-		list($y, $m, $d, $h, $n, $s) = split('/',$values);
1770
-		if($m+$num>12) {
1771
-			$y += floor($num/12);
1772
-			$m += $num%12;
1768
+		$values = str_replace(array(':', '-', ' '), '/', $values);
1769
+		list($y, $m, $d, $h, $n, $s) = split('/', $values);
1770
+		if ($m + $num > 12) {
1771
+			$y += floor($num / 12);
1772
+			$m += $num % 12;
1773 1773
 		} else {
1774 1774
 			$m += $num;
1775 1775
 		}
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
 	 * @param	bool	true for removing all calendar inside current attendance, false for removing by calendar id
1828 1828
 	 * @return	int affected rows
1829 1829
 	 */
1830
-	public function attendance_calendar_delete($calendar_id, $attendance_id , $all_delete = false)
1830
+	public function attendance_calendar_delete($calendar_id, $attendance_id, $all_delete = false)
1831 1831
 	{
1832 1832
 		$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
1833 1833
 		$tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET);
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
 		}
1964 1964
 
1965 1965
 		$sessionId = api_get_session_id();
1966
-		$courseCode  = api_get_course_id();
1966
+		$courseCode = api_get_course_id();
1967 1967
 		if (!empty($sessionId)) {
1968 1968
 			$users = CourseManager:: get_user_list_from_course_code(
1969 1969
 				$courseCode,
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
 
1985 1985
 		$dateTimeStartOriginal = new DateTime($startDate);
1986 1986
 		$dateTimeStart = new DateTime($startDate);
1987
-		$dateTimeEnd= new DateTime($endDate);
1987
+		$dateTimeEnd = new DateTime($endDate);
1988 1988
 		$interval = $dateTimeStart->diff($dateTimeEnd);
1989 1989
 		$days = intval($interval->format('%a'));
1990 1990
 
@@ -2057,7 +2057,7 @@  discard block
 block discarded – undo
2057 2057
 				0,
2058 2058
 				$user['lastname'].' '.$user['firstname'].' ('.$user['username'].')'
2059 2059
 			);
2060
-			$row ++;
2060
+			$row++;
2061 2061
 		}
2062 2062
 
2063 2063
 		$column = 1;
@@ -2134,7 +2134,7 @@  discard block
 block discarded – undo
2134 2134
 		$tableToString = $table->toHtml();
2135 2135
 
2136 2136
 		$params = array(
2137
-			'filename' => get_lang('Attendance') . '_' . api_get_utc_datetime(),
2137
+			'filename' => get_lang('Attendance').'_'.api_get_utc_datetime(),
2138 2138
 			'pdf_title' => get_lang('Attendance'),
2139 2139
 			'course_code' => api_get_course_id(),
2140 2140
 			'show_real_course_teachers' => true
Please login to merge, or discard this patch.
main/inc/lib/magpierss/rss_fetch.inc 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 }
27 27
 
28 28
 if (!defined('MAGPIE_DIR')) {
29
-    define('MAGPIE_DIR', dirname(__FILE__) . DIR_SEP);
29
+    define('MAGPIE_DIR', dirname(__FILE__).DIR_SEP);
30 30
 }
31 31
 
32
-require_once( MAGPIE_DIR . 'rss_parse.inc' );
33
-require_once( MAGPIE_DIR . 'rss_cache.inc' );
32
+require_once(MAGPIE_DIR.'rss_parse.inc');
33
+require_once(MAGPIE_DIR.'rss_cache.inc');
34 34
 
35 35
 // for including 3rd party libraries
36
-define('MAGPIE_EXTLIB', MAGPIE_DIR . 'extlib' . DIR_SEP);
37
-require_once( MAGPIE_EXTLIB . 'Snoopy.class.inc');
36
+define('MAGPIE_EXTLIB', MAGPIE_DIR.'extlib'.DIR_SEP);
37
+require_once(MAGPIE_EXTLIB.'Snoopy.class.inc');
38 38
 define('MAGPIE_CACHE_DIR', api_get_path(SYS_ARCHIVE_PATH));
39 39
 
40 40
 /* 
@@ -87,21 +87,21 @@  discard block
 block discarded – undo
87 87
 
88 88
 $MAGPIE_ERROR = "";
89 89
 
90
-function fetch_rss ($url) {
90
+function fetch_rss($url) {
91 91
     // initialize constants
92 92
     init();
93 93
     
94
-    if ( !isset($url) ) {
94
+    if (!isset($url)) {
95 95
         error("fetch_rss called without a url");
96 96
         return false;
97 97
     }
98 98
     
99 99
     // if cache is disabled
100
-    if ( !MAGPIE_CACHE_ON ) {
100
+    if (!MAGPIE_CACHE_ON) {
101 101
         // fetch file, and parse it
102
-        $resp = _fetch_remote_file( $url );
103
-        if ( is_success( $resp->status ) ) {
104
-            return _response_to_rss( $resp );
102
+        $resp = _fetch_remote_file($url);
103
+        if (is_success($resp->status)) {
104
+            return _response_to_rss($resp);
105 105
         }
106 106
         else {
107 107
             error("Failed to fetch $url and cache is off");
@@ -116,34 +116,34 @@  discard block
 block discarded – undo
116 116
         // 3. if cached obj fails freshness check, fetch remote
117 117
         // 4. if remote fails, return stale object, or error
118 118
         
119
-        $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
119
+        $cache = new RSSCache(MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE);
120 120
         
121 121
         if (MAGPIE_DEBUG and $cache->ERROR) {
122 122
             debug($cache->ERROR, E_USER_WARNING);
123 123
         }
124 124
         
125 125
         
126
-        $cache_status    = 0;       // response of check_cache
126
+        $cache_status    = 0; // response of check_cache
127 127
         $request_headers = array(); // HTTP headers to send with fetch
128
-        $rss             = 0;       // parsed RSS object
129
-        $errormsg        = 0;       // errors, if any
128
+        $rss             = 0; // parsed RSS object
129
+        $errormsg        = 0; // errors, if any
130 130
         
131 131
         // store parsed XML by desired output encoding
132 132
         // as character munging happens at parse time
133
-        $cache_key       = $url . MAGPIE_OUTPUT_ENCODING;
133
+        $cache_key = $url.MAGPIE_OUTPUT_ENCODING;
134 134
         
135 135
         if (!$cache->ERROR) {
136 136
             // return cache HIT, MISS, or STALE
137
-            $cache_status = $cache->check_cache( $cache_key);
137
+            $cache_status = $cache->check_cache($cache_key);
138 138
         }
139 139
                 
140 140
         // if object cached, and cache is fresh, return cached obj
141
-        if ( $cache_status == 'HIT' ) {
142
-            $rss = $cache->get( $cache_key );
143
-            if ( isset($rss) and $rss ) {
141
+        if ($cache_status == 'HIT') {
142
+            $rss = $cache->get($cache_key);
143
+            if (isset($rss) and $rss) {
144 144
                 // should be cache age
145 145
                 $rss->from_cache = 1;
146
-                if ( MAGPIE_DEBUG > 1) {
146
+                if (MAGPIE_DEBUG > 1) {
147 147
                     debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
148 148
                 }
149 149
                 return $rss;
@@ -153,50 +153,50 @@  discard block
 block discarded – undo
153 153
         // else attempt a conditional get
154 154
         
155 155
         // setup headers
156
-        if ( $cache_status == 'STALE' ) {
157
-            $rss = $cache->get( $cache_key );
158
-            if ( $rss and $rss->etag and $rss->last_modified ) {
156
+        if ($cache_status == 'STALE') {
157
+            $rss = $cache->get($cache_key);
158
+            if ($rss and $rss->etag and $rss->last_modified) {
159 159
                 $request_headers['If-None-Match'] = $rss->etag;
160 160
                 $request_headers['If-Last-Modified'] = $rss->last_modified;
161 161
             }
162 162
         }
163 163
         
164
-        $resp = _fetch_remote_file( $url, $request_headers );
164
+        $resp = _fetch_remote_file($url, $request_headers);
165 165
         
166 166
         if (isset($resp) and $resp) {
167
-          if ($resp->status == '304' ) {
167
+          if ($resp->status == '304') {
168 168
                 // we have the most current copy
169
-                if ( MAGPIE_DEBUG > 1) {
169
+                if (MAGPIE_DEBUG > 1) {
170 170
                     debug("Got 304 for $url");
171 171
                 }
172 172
                 // reset cache on 304 (at minutillo insistent prodding)
173 173
                 $cache->set($cache_key, $rss);
174 174
                 return $rss;
175 175
             }
176
-            elseif ( is_success( $resp->status ) ) {
177
-                $rss = _response_to_rss( $resp );
178
-                if ( $rss ) {
176
+            elseif (is_success($resp->status)) {
177
+                $rss = _response_to_rss($resp);
178
+                if ($rss) {
179 179
                     if (MAGPIE_DEBUG > 1) {
180 180
                         debug("Fetch successful");
181 181
                     }
182 182
                     // add object to cache
183
-                    $cache->set( $cache_key, $rss );
183
+                    $cache->set($cache_key, $rss);
184 184
                     return $rss;
185 185
                 }
186 186
             }
187 187
             else {
188 188
                 $errormsg = "Failed to fetch $url ";
189
-                if ( $resp->status == '-100' ) {
190
-                    $errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)";
189
+                if ($resp->status == '-100') {
190
+                    $errormsg .= "(Request timed out after ".MAGPIE_FETCH_TIME_OUT." seconds)";
191 191
                 }
192
-                elseif ( $resp->error ) {
192
+                elseif ($resp->error) {
193 193
                     # compensate for Snoopy's annoying habbit to tacking
194 194
                     # on '\n'
195 195
                     $http_error = substr($resp->error, 0, -2); 
196 196
                     $errormsg .= "(HTTP Error: $http_error)";
197 197
                 }
198 198
                 else {
199
-                    $errormsg .=  "(HTTP Response: " . $resp->response_code .')';
199
+                    $errormsg .= "(HTTP Response: ".$resp->response_code.')';
200 200
                 }
201 201
             }
202 202
         }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         
209 209
         // attempt to return cached object
210 210
         if ($rss) {
211
-            if ( MAGPIE_DEBUG ) {
211
+            if (MAGPIE_DEBUG) {
212 212
                 debug("Returning STALE object for $url");
213 213
             }
214 214
             return $rss;
@@ -228,21 +228,21 @@  discard block
 block discarded – undo
228 228
     Purpose:    set MAGPIE_ERROR, and trigger error
229 229
 \*=======================================================================*/
230 230
 
231
-function error ($errormsg, $lvl=E_USER_WARNING) {
231
+function error($errormsg, $lvl = E_USER_WARNING) {
232 232
         global $MAGPIE_ERROR;
233 233
         
234 234
         // append PHP's error message if track_errors enabled
235
-        if ( isset($php_errormsg) ) { 
235
+        if (isset($php_errormsg)) { 
236 236
             $errormsg .= " ($php_errormsg)";
237 237
         }
238
-        if ( $errormsg ) {
238
+        if ($errormsg) {
239 239
             $errormsg = "MagpieRSS: $errormsg";
240 240
             $MAGPIE_ERROR = $errormsg;
241
-            trigger_error( $errormsg, $lvl);                
241
+            trigger_error($errormsg, $lvl);                
242 242
         }
243 243
 }
244 244
 
245
-function debug ($debugmsg, $lvl=E_USER_NOTICE) {
245
+function debug($debugmsg, $lvl = E_USER_NOTICE) {
246 246
     trigger_error("MagpieRSS [debug] $debugmsg", $lvl);
247 247
 }
248 248
             
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
     Function:   magpie_error
251 251
     Purpose:    accessor for the magpie error variable
252 252
 \*=======================================================================*/
253
-function magpie_error ($errormsg="") {
253
+function magpie_error($errormsg = "") {
254 254
     global $MAGPIE_ERROR;
255 255
     
256
-    if ( isset($errormsg) and $errormsg ) { 
256
+    if (isset($errormsg) and $errormsg) { 
257 257
         $MAGPIE_ERROR = $errormsg;
258 258
     }
259 259
     
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
                 headers to send along with the request (optional)
268 268
     Output:     an HTTP response object (see Snoopy.class.inc)  
269 269
 \*=======================================================================*/
270
-function _fetch_remote_file ($url, $headers = "" ) {
270
+function _fetch_remote_file($url, $headers = "") {
271 271
     // Snoopy is an HTTP client in PHP
272 272
     $client = new Snoopy();
273 273
     $client->agent = MAGPIE_USER_AGENT;
274 274
     $client->read_timeout = MAGPIE_FETCH_TIME_OUT;
275 275
     $client->use_gzip = MAGPIE_USE_GZIP;
276
-    if (is_array($headers) ) {
276
+    if (is_array($headers)) {
277 277
         $client->rawheaders = $headers;
278 278
     }
279 279
     
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
     Input:      an HTTP response object (see Snoopy)
289 289
     Output:     parsed RSS object (see rss_parse)
290 290
 \*=======================================================================*/
291
-function _response_to_rss ($resp) {
292
-    $rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING );
291
+function _response_to_rss($resp) {
292
+    $rss = new MagpieRSS($resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING);
293 293
     
294 294
     // if RSS parsed successfully       
295
-    if ( $rss and !$rss->ERROR) {
295
+    if ($rss and !$rss->ERROR) {
296 296
         
297 297
         // find Etag, and Last-Modified
298
-        foreach($resp->headers as $h) {
298
+        foreach ($resp->headers as $h) {
299 299
             // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
300 300
             if (strpos($h, ": ")) {
301 301
                 list($field, $val) = explode(": ", $h, 2);
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
                 $val = "";
306 306
             }
307 307
             
308
-            if ( $field == 'ETag' ) {
308
+            if ($field == 'ETag') {
309 309
                 $rss->etag = $val;
310 310
             }
311 311
             
312
-            if ( $field == 'Last-Modified' ) {
312
+            if ($field == 'Last-Modified') {
313 313
                 $rss->last_modified = $val;
314 314
             }
315 315
         }
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
         $errormsg = "Failed to parse RSS file.";
321 321
         
322 322
         if ($rss) {
323
-            $errormsg .= " (" . $rss->ERROR . ")";
323
+            $errormsg .= " (".$rss->ERROR.")";
324 324
         }
325
-        error($errormsg,E_USER_NOTICE);
325
+        error($errormsg, E_USER_NOTICE);
326 326
         
327 327
         return false;
328 328
     } // end if ($rss and !$rss->error)
@@ -333,65 +333,65 @@  discard block
 block discarded – undo
333 333
     Purpose:    setup constants with default values
334 334
                 check for user overrides
335 335
 \*=======================================================================*/
336
-function init () {
337
-    if ( defined('MAGPIE_INITALIZED') ) {
336
+function init() {
337
+    if (defined('MAGPIE_INITALIZED')) {
338 338
         return;
339 339
     }
340 340
     else {
341 341
         define('MAGPIE_INITALIZED', true);
342 342
     }
343 343
     
344
-    if ( !defined('MAGPIE_CACHE_ON') ) {
344
+    if (!defined('MAGPIE_CACHE_ON')) {
345 345
         define('MAGPIE_CACHE_ON', true);
346 346
     }
347 347
 
348
-    if ( !defined('MAGPIE_CACHE_DIR') ) {
348
+    if (!defined('MAGPIE_CACHE_DIR')) {
349 349
         define('MAGPIE_CACHE_DIR', './cache');
350 350
     }
351 351
 
352
-    if ( !defined('MAGPIE_CACHE_AGE') ) {
353
-        define('MAGPIE_CACHE_AGE', 60*60); // one hour
352
+    if (!defined('MAGPIE_CACHE_AGE')) {
353
+        define('MAGPIE_CACHE_AGE', 60 * 60); // one hour
354 354
     }
355 355
 
356
-    if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
356
+    if (!defined('MAGPIE_CACHE_FRESH_ONLY')) {
357 357
         define('MAGPIE_CACHE_FRESH_ONLY', false);
358 358
     }
359 359
 
360
-    if ( !defined('MAGPIE_OUTPUT_ENCODING') ) {
360
+    if (!defined('MAGPIE_OUTPUT_ENCODING')) {
361 361
         define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
362 362
     }
363 363
     
364
-    if ( !defined('MAGPIE_INPUT_ENCODING') ) {
364
+    if (!defined('MAGPIE_INPUT_ENCODING')) {
365 365
         define('MAGPIE_INPUT_ENCODING', null);
366 366
     }
367 367
     
368
-    if ( !defined('MAGPIE_DETECT_ENCODING') ) {
368
+    if (!defined('MAGPIE_DETECT_ENCODING')) {
369 369
         define('MAGPIE_DETECT_ENCODING', true);
370 370
     }
371 371
     
372
-    if ( !defined('MAGPIE_DEBUG') ) {
372
+    if (!defined('MAGPIE_DEBUG')) {
373 373
         define('MAGPIE_DEBUG', 0);
374 374
     }
375 375
     
376
-    if ( !defined('MAGPIE_USER_AGENT') ) {
377
-        $ua = 'MagpieRSS/'. MAGPIE_VERSION . ' (+http://magpierss.sf.net';
376
+    if (!defined('MAGPIE_USER_AGENT')) {
377
+        $ua = 'MagpieRSS/'.MAGPIE_VERSION.' (+http://magpierss.sf.net';
378 378
         
379
-        if ( MAGPIE_CACHE_ON ) {
380
-            $ua = $ua . ')';
379
+        if (MAGPIE_CACHE_ON) {
380
+            $ua = $ua.')';
381 381
         }
382 382
         else {
383
-            $ua = $ua . '; No cache)';
383
+            $ua = $ua.'; No cache)';
384 384
         }
385 385
         
386 386
         define('MAGPIE_USER_AGENT', $ua);
387 387
     }
388 388
     
389
-    if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
389
+    if (!defined('MAGPIE_FETCH_TIME_OUT')) {
390 390
         define('MAGPIE_FETCH_TIME_OUT', 5); // 5 second timeout
391 391
     }
392 392
     
393 393
     // use gzip encoding to fetch rss files if supported?
394
-    if ( !defined('MAGPIE_USE_GZIP') ) {
394
+    if (!defined('MAGPIE_USE_GZIP')) {
395 395
         define('MAGPIE_USE_GZIP', true);    
396 396
     }
397 397
 }
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
     Function:   is_info
415 415
     Purpose:    return true if Informational status code
416 416
 \*=======================================================================*/
417
-function is_info ($sc) { 
417
+function is_info($sc) { 
418 418
     return $sc >= 100 && $sc < 200; 
419 419
 }
420 420
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
     Function:   is_success
423 423
     Purpose:    return true if Successful status code
424 424
 \*=======================================================================*/
425
-function is_success ($sc) { 
425
+function is_success($sc) { 
426 426
     return $sc >= 200 && $sc < 300; 
427 427
 }
428 428
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
     Function:   is_redirect
431 431
     Purpose:    return true if Redirection status code
432 432
 \*=======================================================================*/
433
-function is_redirect ($sc) { 
433
+function is_redirect($sc) { 
434 434
     return $sc >= 300 && $sc < 400; 
435 435
 }
436 436
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
     Function:   is_error
439 439
     Purpose:    return true if Error status code
440 440
 \*=======================================================================*/
441
-function is_error ($sc) { 
441
+function is_error($sc) { 
442 442
     return $sc >= 400 && $sc < 600; 
443 443
 }
444 444
 
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
     Function:   is_client_error
447 447
     Purpose:    return true if Error status code, and its a client error
448 448
 \*=======================================================================*/
449
-function is_client_error ($sc) { 
449
+function is_client_error($sc) { 
450 450
     return $sc >= 400 && $sc < 500; 
451 451
 }
452 452
 
@@ -454,6 +454,6 @@  discard block
 block discarded – undo
454 454
     Function:   is_client_error
455 455
     Purpose:    return true if Error status code, and its a server error
456 456
 \*=======================================================================*/
457
-function is_server_error ($sc) { 
457
+function is_server_error($sc) { 
458 458
     return $sc >= 500 && $sc < 600; 
459 459
 }
Please login to merge, or discard this patch.
main/inc/lib/magpierss/rss_cache.inc 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -19,26 +19,26 @@  discard block
 block discarded – undo
19 19
  * @package chamilo.include.rss
20 20
  */
21 21
 class RSSCache {
22
-    public $BASE_CACHE = './cache';    // where the cache files are stored
23
-    public $MAX_AGE    = 3600;         // when are files stale, default one hour
24
-    public $ERROR      = "";           // accumulate error messages
22
+    public $BASE_CACHE = './cache'; // where the cache files are stored
23
+    public $MAX_AGE    = 3600; // when are files stale, default one hour
24
+    public $ERROR      = ""; // accumulate error messages
25 25
     
26
-    public function RSSCache ($base='', $age='') {
27
-        if ( $base ) {
26
+    public function RSSCache($base = '', $age = '') {
27
+        if ($base) {
28 28
             $this->BASE_CACHE = $base;
29 29
         }
30
-        if ( $age ) {
30
+        if ($age) {
31 31
             $this->MAX_AGE = $age;
32 32
         }
33 33
         
34 34
         // attempt to make the cache directory
35
-        if ( ! file_exists( $this->BASE_CACHE ) ) {
36
-            $status = @mkdir( $this->BASE_CACHE, 0755 );
35
+        if (!file_exists($this->BASE_CACHE)) {
36
+            $status = @mkdir($this->BASE_CACHE, 0755);
37 37
             
38 38
             // if make failed 
39
-            if ( ! $status ) {
39
+            if (!$status) {
40 40
                 $this->error(
41
-                    "Cache couldn't make dir '" . $this->BASE_CACHE . "'."
41
+                    "Cache couldn't make dir '".$this->BASE_CACHE."'."
42 42
                 );
43 43
             }
44 44
         }
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
     Input:      url from wich the rss file was fetched
51 51
     Output:     true on sucess  
52 52
 \*=======================================================================*/
53
-    public function set ($url, $rss) {
53
+    public function set($url, $rss) {
54 54
         $this->ERROR = "";
55
-        $cache_file = $this->file_name( $url );
56
-        $fp = @fopen( $cache_file, 'w' );
55
+        $cache_file = $this->file_name($url);
56
+        $fp = @fopen($cache_file, 'w');
57 57
         
58
-        if ( ! $fp ) {
58
+        if (!$fp) {
59 59
             $this->error(
60 60
                 "Cache unable to open file for writing: $cache_file"
61 61
             );
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
         }
64 64
         
65 65
         
66
-        $data = $this->serialize( $rss );
67
-        fwrite( $fp, $data );
68
-        fclose( $fp );
66
+        $data = $this->serialize($rss);
67
+        fwrite($fp, $data);
68
+        fclose($fp);
69 69
         
70 70
         return $cache_file;
71 71
     }
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
     Input:      url from wich the rss file was fetched
77 77
     Output:     cached object on HIT, false on MISS 
78 78
 \*=======================================================================*/ 
79
-    public function get ($url) {
79
+    public function get($url) {
80 80
         $this->ERROR = "";
81
-        $cache_file = $this->file_name( $url );
81
+        $cache_file = $this->file_name($url);
82 82
         
83
-        if ( ! file_exists( $cache_file ) ) {
83
+        if (!file_exists($cache_file)) {
84 84
             $this->debug( 
85 85
                 "Cache doesn't contain: $url (cache file: $cache_file)"
86 86
             );
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
         }
89 89
         
90 90
         $fp = @fopen($cache_file, 'r');
91
-        if ( ! $fp ) {
91
+        if (!$fp) {
92 92
             $this->error(
93 93
                 "Failed to open cache file for reading: $cache_file"
94 94
             );
95 95
             return 0;
96 96
         }
97 97
         
98
-        if ($filesize = filesize($cache_file) ) {
99
-        	$data = fread( $fp, filesize($cache_file) );
100
-        	$rss = $this->unserialize( $data );
98
+        if ($filesize = filesize($cache_file)) {
99
+        	$data = fread($fp, filesize($cache_file));
100
+        	$rss = $this->unserialize($data);
101 101
         
102 102
         	return $rss;
103 103
     	}
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
     Input:      url from wich the rss file was fetched
113 113
     Output:     cached object on HIT, false on MISS 
114 114
 \*=======================================================================*/     
115
-    public function check_cache ( $url ) {
115
+    public function check_cache($url) {
116 116
         $this->ERROR = "";
117
-        $filename = $this->file_name( $url );
117
+        $filename = $this->file_name($url);
118 118
         
119
-        if ( file_exists( $filename ) ) {
119
+        if (file_exists($filename)) {
120 120
             // find how long ago the file was added to the cache
121 121
             // and whether that is longer then MAX_AGE
122
-            $mtime = filemtime( $filename );
122
+            $mtime = filemtime($filename);
123 123
             $age = time() - $mtime;
124
-            if ( $this->MAX_AGE > $age ) {
124
+            if ($this->MAX_AGE > $age) {
125 125
                 // object exists and is current
126 126
                 return 'HIT';
127 127
             }
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
         }
137 137
     }
138 138
 
139
-	public function cache_age( $url ) {
140
-		$filename = $this->file_name( $url);
141
-		if ( file_exists( $filename ) ) {
142
-			$mtime = filemtime( $filename );
139
+	public function cache_age($url) {
140
+		$filename = $this->file_name($url);
141
+		if (file_exists($filename)) {
142
+			$mtime = filemtime($filename);
143 143
             $age = time() - $mtime;
144 144
 			return $age;
145 145
 		}
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 /*=======================================================================*\
152 152
     Function:   serialize
153 153
 \*=======================================================================*/     
154
-    public function serialize ( $rss ) {
155
-        return serialize( $rss );
154
+    public function serialize($rss) {
155
+        return serialize($rss);
156 156
     }
157 157
 
158 158
 /*=======================================================================*\
159 159
     Function:   unserialize
160 160
 \*=======================================================================*/     
161
-    public function unserialize ( $data ) {
162
-        return unserialize( $data );
161
+    public function unserialize($data) {
162
+        return unserialize($data);
163 163
     }
164 164
     
165 165
 /*=======================================================================*\
@@ -168,31 +168,31 @@  discard block
 block discarded – undo
168 168
     Input:      url from wich the rss file was fetched
169 169
     Output:     a file name
170 170
 \*=======================================================================*/     
171
-    public function file_name ($url) {
172
-        $filename = md5( $url );
173
-        return join( DIRECTORY_SEPARATOR, array( $this->BASE_CACHE, $filename ) );
171
+    public function file_name($url) {
172
+        $filename = md5($url);
173
+        return join(DIRECTORY_SEPARATOR, array($this->BASE_CACHE, $filename));
174 174
     }
175 175
 
176 176
 /*=======================================================================*\
177 177
     Function:   error
178 178
     Purpose:    register error
179 179
 \*=======================================================================*/         
180
-    public function error ($errormsg, $lvl=E_USER_WARNING) {
180
+    public function error($errormsg, $lvl = E_USER_WARNING) {
181 181
         // append PHP's error message if track_errors enabled
182
-        if ( isset($php_errormsg) ) { 
182
+        if (isset($php_errormsg)) { 
183 183
             $errormsg .= " ($php_errormsg)";
184 184
         }
185 185
         $this->ERROR = $errormsg;
186
-        if ( MAGPIE_DEBUG ) {
187
-            trigger_error( $errormsg, $lvl);
186
+        if (MAGPIE_DEBUG) {
187
+            trigger_error($errormsg, $lvl);
188 188
         }
189 189
         else {
190
-            error_log( $errormsg, 0);
190
+            error_log($errormsg, 0);
191 191
         }
192 192
     }
193 193
     
194
-    public function debug ($debugmsg, $lvl=E_USER_NOTICE) {
195
-        if ( MAGPIE_DEBUG ) {
194
+    public function debug($debugmsg, $lvl = E_USER_NOTICE) {
195
+        if (MAGPIE_DEBUG) {
196 196
             $this->error("MagpieRSS [debug] $debugmsg", $lvl);
197 197
         }
198 198
     }
Please login to merge, or discard this patch.
main/inc/lib/magpierss/rss_utils.inc 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,35 +22,35 @@
 block discarded – undo
22 22
  *
23 23
  * NOTE: http://www.w3.org/TR/NOTE-datetime
24 24
  */
25
-function parse_w3cdtf ( $date_str ) {
25
+function parse_w3cdtf($date_str) {
26 26
     
27 27
     # regex to match wc3dtf
28 28
     $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
29 29
     
30
-    if ( preg_match( $pat, $date_str, $match ) ) {
31
-        list( $year, $month, $day, $hours, $minutes, $seconds) = 
32
-            array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
30
+    if (preg_match($pat, $date_str, $match)) {
31
+        list($year, $month, $day, $hours, $minutes, $seconds) = 
32
+            array($match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
33 33
         
34 34
         # calc epoch for current date assuming GMT
35
-        $epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
35
+        $epoch = gmmktime($hours, $minutes, $seconds, $month, $day, $year);
36 36
         
37 37
         $offset = 0;
38
-        if ( $match[10] == 'Z' ) {
38
+        if ($match[10] == 'Z') {
39 39
             # zulu time, aka GMT
40 40
         }
41 41
         else {
42
-            list( $tz_mod, $tz_hour, $tz_min ) =
43
-                array( $match[8], $match[9], $match[10]);
42
+            list($tz_mod, $tz_hour, $tz_min) =
43
+                array($match[8], $match[9], $match[10]);
44 44
             
45 45
             # zero out the variables
46
-            if ( ! $tz_hour ) { $tz_hour = 0; }
47
-            if ( ! $tz_min ) { $tz_min = 0; }
46
+            if (!$tz_hour) { $tz_hour = 0; }
47
+            if (!$tz_min) { $tz_min = 0; }
48 48
         
49
-            $offset_secs = (($tz_hour*60)+$tz_min)*60;
49
+            $offset_secs = (($tz_hour * 60) + $tz_min) * 60;
50 50
             
51 51
             # is timezone ahead of GMT?  then subtract offset
52 52
             #
53
-            if ( $tz_mod == '+' ) {
53
+            if ($tz_mod == '+') {
54 54
                 $offset_secs = $offset_secs * -1;
55 55
             }
56 56
             
Please login to merge, or discard this patch.
main/inc/lib/magpierss/extlib/Snoopy.class.inc 1 patch
Spacing   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -40,47 +40,47 @@  discard block
 block discarded – undo
40 40
 	
41 41
 	/* user definable vars */
42 42
 
43
-	public $host			=	"www.php.net";		// host name we are connecting to
44
-	public $port			=	80;					// port we are connecting to
45
-	public $proxy_host		=	"";					// proxy host to use
46
-	public $proxy_port		=	"";					// proxy port to use
47
-	public $agent			=	"Snoopy v1.0";		// agent we masquerade as
48
-	public $referer		=	"";					// referer info to pass
49
-	public $cookies		=	array();			// array of cookies to pass
43
+	public $host			= "www.php.net"; // host name we are connecting to
44
+	public $port			= 80; // port we are connecting to
45
+	public $proxy_host		= ""; // proxy host to use
46
+	public $proxy_port		= ""; // proxy port to use
47
+	public $agent = "Snoopy v1.0"; // agent we masquerade as
48
+	public $referer		= ""; // referer info to pass
49
+	public $cookies		= array(); // array of cookies to pass
50 50
 												// $cookies["username"]="joe";
51
-	public	$rawheaders		=	array();			// array of raw headers to send
51
+	public	$rawheaders = array(); // array of raw headers to send
52 52
 												// $rawheaders["Content-type"]="text/html";
53 53
 
54
-	public $maxredirs		=	5;					// http redirection depth maximum. 0 = disallow
55
-	public $lastredirectaddr	=	"";				// contains address of last redirected address
56
-	public	$offsiteok		=	true;				// allows redirection off-site
57
-	public $maxframes		=	0;					// frame content depth maximum. 0 = disallow
58
-	public $expandlinks	=	true;				// expand links to fully qualified URLs.
54
+	public $maxredirs		= 5; // http redirection depth maximum. 0 = disallow
55
+	public $lastredirectaddr = ""; // contains address of last redirected address
56
+	public	$offsiteok		= true; // allows redirection off-site
57
+	public $maxframes		= 0; // frame content depth maximum. 0 = disallow
58
+	public $expandlinks	= true; // expand links to fully qualified URLs.
59 59
 												// this only applies to fetchlinks()
60 60
 												// or submitlinks()
61
-	public $passcookies	=	true;				// pass set cookies back through redirects
61
+	public $passcookies	= true; // pass set cookies back through redirects
62 62
 												// NOTE: this currently does not respect
63 63
 												// dates, domains or paths.
64 64
 	
65
-	public	$user			=	"";					// user for http authentication
66
-	public	$pass			=	"";					// password for http authentication
65
+	public	$user			= ""; // user for http authentication
66
+	public	$pass			= ""; // password for http authentication
67 67
 	
68 68
 	// http accept types
69
-	public $accept			=	"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
69
+	public $accept			= "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
70 70
 	
71
-	public $results		=	"";					// where the content is put
71
+	public $results		= ""; // where the content is put
72 72
 		
73
-	public $error			=	"";					// error messages sent here
74
-	public	$response_code	=	"";					// response code returned from server
75
-	public	$headers		=	array();			// headers returned from server sent here
76
-	public	$maxlength		=	500000;				// max return data length (body)
77
-	public $read_timeout	=	0;					// timeout on read operations, in seconds
73
+	public $error = ""; // error messages sent here
74
+	public	$response_code = ""; // response code returned from server
75
+	public	$headers = array(); // headers returned from server sent here
76
+	public	$maxlength = 500000; // max return data length (body)
77
+	public $read_timeout = 0; // timeout on read operations, in seconds
78 78
 												// supported only since PHP 4 Beta 4
79 79
 												// set to 0 to disallow timeouts
80
-	public $timed_out		=	false;				// if a read operation timed out
81
-	public	$status			=	0;					// http request status
80
+	public $timed_out		= false; // if a read operation timed out
81
+	public	$status = 0; // http request status
82 82
 	
83
-	public	$curl_path		=	"/usr/bin/curl";
83
+	public	$curl_path		= "/usr/bin/curl";
84 84
 												// Snoopy will use cURL for fetching
85 85
 												// SSL content if a full system path to
86 86
 												// the cURL binary is supplied here.
@@ -93,24 +93,24 @@  discard block
 block discarded – undo
93 93
 												// as of this Snoopy release.
94 94
 	
95 95
 	// send Accept-encoding: gzip?
96
-	public $use_gzip		= true;	
96
+	public $use_gzip = true;	
97 97
 	
98 98
 	/**** Private variables ****/	
99 99
 	
100
-	private	$_maxlinelen	=	4096;				// max line length (headers)
100
+	private	$_maxlinelen	= 4096; // max line length (headers)
101 101
 	
102
-	private $_httpmethod	=	"GET";				// default http request method
103
-	private $_httpversion	=	"HTTP/1.0";			// default http request version
104
-	private $_submit_method	=	"POST";				// default submit method
105
-	private $_submit_type	=	"application/x-www-form-urlencoded";	// default submit type
106
-	private $_mime_boundary	=   "";					// MIME boundary for multipart/form-data submit type
107
-	private $_redirectaddr	=	false;				// will be set if page fetched is a redirect
108
-	private $_redirectdepth	=	0;					// increments on an http redirect
109
-	private $_frameurls		= 	array();			// frame src urls
110
-	private $_framedepth	=	0;					// increments on frame depth
102
+	private $_httpmethod	= "GET"; // default http request method
103
+	private $_httpversion	= "HTTP/1.0"; // default http request version
104
+	private $_submit_method	= "POST"; // default submit method
105
+	private $_submit_type	= "application/x-www-form-urlencoded"; // default submit type
106
+	private $_mime_boundary	= ""; // MIME boundary for multipart/form-data submit type
107
+	private $_redirectaddr = false; // will be set if page fetched is a redirect
108
+	private $_redirectdepth	= 0; // increments on an http redirect
109
+	private $_frameurls		= array(); // frame src urls
110
+	private $_framedepth	= 0; // increments on frame depth
111 111
 	
112
-	private $_isproxy		=	false;				// set if using a proxy server
113
-	private $_fp_timeout	=	30;					// timeout for socket connection
112
+	private $_isproxy = false; // set if using a proxy server
113
+	private $_fp_timeout	= 30; // timeout for socket connection
114 114
 
115 115
 /*======================================================================*\
116 116
 	Function:	fetch
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 		switch ($URI_PARTS["scheme"]) {
133 133
 			case "http":
134 134
 				$this->host = $URI_PARTS["host"];
135
-				if(!empty($URI_PARTS["port"]))
135
+				if (!empty($URI_PARTS["port"]))
136 136
 					$this->port = $URI_PARTS["port"];
137
-				if($this->_connect($fp))
137
+				if ($this->_connect($fp))
138 138
 				{
139
-					if($this->_isproxy)
139
+					if ($this->_isproxy)
140 140
 					{
141 141
 						// using proxy, send entire URI
142
-						$this->_httprequest($URI,$fp,$URI,$this->_httpmethod);
142
+						$this->_httprequest($URI, $fp, $URI, $this->_httpmethod);
143 143
 					}
144 144
 					else
145 145
 					{
@@ -150,30 +150,30 @@  discard block
 block discarded – undo
150 150
 					
151 151
 					$this->_disconnect($fp);
152 152
 
153
-					if($this->_redirectaddr)
153
+					if ($this->_redirectaddr)
154 154
 					{
155 155
 						/* url was redirected, check if we've hit the max depth */
156
-						if($this->maxredirs > $this->_redirectdepth)
156
+						if ($this->maxredirs > $this->_redirectdepth)
157 157
 						{
158 158
 							// only follow redirect if it's on this site, or offsiteok is true
159
-							if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
159
+							if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok)
160 160
 							{
161 161
 								/* follow the redirect */
162 162
 								$this->_redirectdepth++;
163
-								$this->lastredirectaddr=$this->_redirectaddr;
163
+								$this->lastredirectaddr = $this->_redirectaddr;
164 164
 								$this->fetch($this->_redirectaddr);
165 165
 							}
166 166
 						}
167 167
 					}
168 168
 
169
-					if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
169
+					if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
170 170
 					{
171 171
 						$frameurls = $this->_frameurls;
172 172
 						$this->_frameurls = array();
173 173
 						
174
-						while(list(,$frameurl) = each($frameurls))
174
+						while (list(,$frameurl) = each($frameurls))
175 175
 						{
176
-							if($this->_framedepth < $this->maxframes)
176
+							if ($this->_framedepth < $this->maxframes)
177 177
 							{
178 178
 								$this->fetch($frameurl);
179 179
 								$this->_framedepth++;
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
 				return true;					
191 191
 				break;
192 192
 			case "https":
193
-				if(!$this->curl_path || (!is_executable($this->curl_path))) {
193
+				if (!$this->curl_path || (!is_executable($this->curl_path))) {
194 194
 					$this->error = "Bad curl ($this->curl_path), can't fetch HTTPS \n";
195 195
 					return false;
196 196
 				}
197 197
 				$this->host = $URI_PARTS["host"];
198
-				if(!empty($URI_PARTS["port"]))
198
+				if (!empty($URI_PARTS["port"]))
199 199
 					$this->port = $URI_PARTS["port"];
200
-				if($this->_isproxy)
200
+				if ($this->_isproxy)
201 201
 				{
202 202
 					// using proxy, send entire URI
203
-					$this->_httpsrequest($URI,$URI,$this->_httpmethod);
203
+					$this->_httpsrequest($URI, $URI, $this->_httpmethod);
204 204
 				}
205 205
 				else
206 206
 				{
@@ -209,30 +209,30 @@  discard block
 block discarded – undo
209 209
 					$this->_httpsrequest($path, $URI, $this->_httpmethod);
210 210
 				}
211 211
 
212
-				if($this->_redirectaddr)
212
+				if ($this->_redirectaddr)
213 213
 				{
214 214
 					/* url was redirected, check if we've hit the max depth */
215
-					if($this->maxredirs > $this->_redirectdepth)
215
+					if ($this->maxredirs > $this->_redirectdepth)
216 216
 					{
217 217
 						// only follow redirect if it's on this site, or offsiteok is true
218
-						if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
218
+						if (preg_match("|^http://".preg_quote($this->host)."|i", $this->_redirectaddr) || $this->offsiteok)
219 219
 						{
220 220
 							/* follow the redirect */
221 221
 							$this->_redirectdepth++;
222
-							$this->lastredirectaddr=$this->_redirectaddr;
222
+							$this->lastredirectaddr = $this->_redirectaddr;
223 223
 							$this->fetch($this->_redirectaddr);
224 224
 						}
225 225
 					}
226 226
 				}
227 227
 
228
-				if($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
228
+				if ($this->_framedepth < $this->maxframes && count($this->_frameurls) > 0)
229 229
 				{
230 230
 					$frameurls = $this->_frameurls;
231 231
 					$this->_frameurls = array();
232 232
 
233
-					while(list(,$frameurl) = each($frameurls))
233
+					while (list(,$frameurl) = each($frameurls))
234 234
 					{
235
-						if($this->_framedepth < $this->maxframes)
235
+						if ($this->_framedepth < $this->maxframes)
236 236
 						{
237 237
 							$this->fetch($frameurl);
238 238
 							$this->_framedepth++;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 				break;
246 246
 			default:
247 247
 				// not a valid protocol
248
-				$this->error	=	'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
248
+				$this->error = 'Invalid protocol "'.$URI_PARTS["scheme"].'"\n';
249 249
 				return false;
250 250
 				break;
251 251
 		}		
@@ -272,20 +272,20 @@  discard block
 block discarded – undo
272 272
 						([\"\'])?					# find single or double quote
273 273
 						(?(1) (.*?)\\1 | ([^\s\>]+))		# if quote found, match up to next matching
274 274
 													# quote, otherwise match up to next space
275
-						'isx",$document,$links);
275
+						'isx",$document, $links);
276 276
 						
277 277
 
278 278
 		// catenate the non-empty matches from the conditional subpattern
279 279
 
280
-		while(list($key,$val) = each($links[2]))
280
+		while (list($key, $val) = each($links[2]))
281 281
 		{
282
-			if(!empty($val))
282
+			if (!empty($val))
283 283
 				$match[] = $val;
284 284
 		}				
285 285
 		
286
-		while(list($key,$val) = each($links[3]))
286
+		while (list($key, $val) = each($links[3]))
287 287
 		{
288
-			if(!empty($val))
288
+			if (!empty($val))
289 289
 				$match[] = $val;
290 290
 		}		
291 291
 		
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 
303 303
 	private function _stripform($document)
304 304
 	{	
305
-		preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements);
305
+		preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi", $document, $elements);
306 306
 		
307 307
 		// catenate the matches
308
-		$match = implode("\r\n",$elements[0]);
308
+		$match = implode("\r\n", $elements[0]);
309 309
 				
310 310
 		// return the links
311 311
 		return $match;
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 		// so, list your entities one by one here. I included some of the
328 328
 		// more common ones.
329 329
 								
330
-		$search = array("'<script[^>]*?>.*?</script>'si",	// strip out javascript
331
-						"'<[\/\!]*?[^<>]*?>'si",			// strip out html tags
332
-						"'([\r\n])[\s]+'",					// strip out white space
333
-						"'&(quote|#34);'i",					// replace html entities
330
+		$search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript
331
+						"'<[\/\!]*?[^<>]*?>'si", // strip out html tags
332
+						"'([\r\n])[\s]+'", // strip out white space
333
+						"'&(quote|#34);'i", // replace html entities
334 334
 						"'&(amp|#38);'i",
335 335
 						"'&(lt|#60);'i",
336 336
 						"'&(gt|#62);'i",
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 						"'&(pound|#163);'i",
341 341
 						"'&(copy|#169);'i"
342 342
 						);				
343
-		$replace = array(	"",
343
+		$replace = array("",
344 344
 							"",
345 345
 							"\\1",
346 346
 							"\"",
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 							chr(163),
354 354
 							chr(169));
355 355
 					
356
-		$text = preg_replace($search,$replace,$document);
356
+		$text = preg_replace($search, $replace, $document);
357 357
 								
358 358
 		return $text;
359 359
 	}
@@ -366,26 +366,26 @@  discard block
 block discarded – undo
366 366
 	Output:		$expandedLinks	the expanded links
367 367
 \*======================================================================*/
368 368
 
369
-	private function _expandlinks($links,$URI)
369
+	private function _expandlinks($links, $URI)
370 370
 	{
371 371
 		
372
-		preg_match("/^[^\?]+/",$URI,$match);
372
+		preg_match("/^[^\?]+/", $URI, $match);
373 373
 
374
-		$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|","",$match[0]);
374
+		$match = preg_replace("|/[^\/\.]+\.[^\/\.]+$|", "", $match[0]);
375 375
 				
376
-		$search = array( 	"|^http://".preg_quote($this->host)."|i",
376
+		$search = array("|^http://".preg_quote($this->host)."|i",
377 377
 							"|^(?!http://)(\/)?(?!mailto:)|i",
378 378
 							"|/\./|",
379 379
 							"|/[^\/]+/\.\./|"
380 380
 						);
381 381
 						
382
-		$replace = array(	"",
382
+		$replace = array("",
383 383
 							$match."/",
384 384
 							"/",
385 385
 							"/"
386 386
 						);			
387 387
 				
388
-		$expandedLinks = preg_replace($search,$replace,$links);
388
+		$expandedLinks = preg_replace($search, $replace, $links);
389 389
 
390 390
 		return $expandedLinks;
391 391
 	}
@@ -400,26 +400,26 @@  discard block
 block discarded – undo
400 400
 	Output:		
401 401
 \*======================================================================*/
402 402
 	
403
-	private function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
403
+	private function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "")
404 404
 	{
405
-		if($this->passcookies && $this->_redirectaddr)
405
+		if ($this->passcookies && $this->_redirectaddr)
406 406
 			$this->setcookies();
407 407
 			
408 408
 		$URI_PARTS = parse_url($URI);
409
-		if(empty($url))
409
+		if (empty($url))
410 410
 			$url = "/";
411 411
 		$headers = $http_method." ".$url." ".$this->_httpversion."\r\n";		
412
-		if(!empty($this->agent))
412
+		if (!empty($this->agent))
413 413
 			$headers .= "User-Agent: ".$this->agent."\r\n";
414
-		if(!empty($this->host) && !isset($this->rawheaders['Host']))
414
+		if (!empty($this->host) && !isset($this->rawheaders['Host']))
415 415
 			$headers .= "Host: ".$this->host."\r\n";
416
-		if(!empty($this->accept))
416
+		if (!empty($this->accept))
417 417
 			$headers .= "Accept: ".$this->accept."\r\n";
418 418
 		
419
-		if($this->use_gzip) {
419
+		if ($this->use_gzip) {
420 420
 			// make sure PHP was built with --with-zlib
421 421
 			// and we can handle gzipp'ed data
422
-			if ( function_exists(gzinflate) ) {
422
+			if (function_exists(gzinflate)) {
423 423
 			   $headers .= "Accept-encoding: gzip\r\n";
424 424
 			}
425 425
 			else {
@@ -430,38 +430,38 @@  discard block
 block discarded – undo
430 430
 			}
431 431
 		}
432 432
 		
433
-		if(!empty($this->referer))
433
+		if (!empty($this->referer))
434 434
 			$headers .= "Referer: ".$this->referer."\r\n";
435
-		if(!empty($this->cookies))
435
+		if (!empty($this->cookies))
436 436
 		{			
437
-			if(!is_array($this->cookies))
438
-				$this->cookies = (array)$this->cookies;
437
+			if (!is_array($this->cookies))
438
+				$this->cookies = (array) $this->cookies;
439 439
 	
440 440
 			reset($this->cookies);
441
-			if ( count($this->cookies) > 0 ) {
441
+			if (count($this->cookies) > 0) {
442 442
 				$cookie_headers .= 'Cookie: ';
443
-				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
443
+				foreach ($this->cookies as $cookieKey => $cookieVal) {
444 444
 				$cookie_headers .= $cookieKey."=".urlencode($cookieVal)."; ";
445 445
 				}
446
-				$headers .= substr($cookie_headers,0,-2) . "\r\n";
446
+				$headers .= substr($cookie_headers, 0, -2)."\r\n";
447 447
 			} 
448 448
 		}
449
-		if(!empty($this->rawheaders))
449
+		if (!empty($this->rawheaders))
450 450
 		{
451
-			if(!is_array($this->rawheaders))
452
-				$this->rawheaders = (array)$this->rawheaders;
453
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
451
+			if (!is_array($this->rawheaders))
452
+				$this->rawheaders = (array) $this->rawheaders;
453
+			while (list($headerKey, $headerVal) = each($this->rawheaders))
454 454
 				$headers .= $headerKey.": ".$headerVal."\r\n";
455 455
 		}
456
-		if(!empty($content_type)) {
456
+		if (!empty($content_type)) {
457 457
 			$headers .= "Content-type: $content_type";
458 458
 			if ($content_type == "multipart/form-data")
459 459
 				$headers .= "; boundary=".$this->_mime_boundary;
460 460
 			$headers .= "\r\n";
461 461
 		}
462
-		if(!empty($body))	
462
+		if (!empty($body))	
463 463
 			$headers .= "Content-length: ".strlen($body)."\r\n";
464
-		if(!empty($this->user) || !empty($this->pass))	
464
+		if (!empty($this->user) || !empty($this->pass))	
465 465
 			$headers .= "Authorization: BASIC ".base64_encode($this->user.":".$this->pass)."\r\n";
466 466
 
467 467
 		$headers .= "\r\n";
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 			socket_set_timeout($fp, $this->read_timeout);
472 472
 		$this->timed_out = false;
473 473
 		
474
-		fwrite($fp,$headers.$body,strlen($headers.$body));
474
+		fwrite($fp, $headers.$body, strlen($headers.$body));
475 475
 		
476 476
 		$this->_redirectaddr = false;
477 477
 		unset($this->headers);
@@ -479,30 +479,30 @@  discard block
 block discarded – undo
479 479
 		// content was returned gzip encoded?
480 480
 		$is_gzipped = false;
481 481
 						
482
-		while($currentHeader = fgets($fp,$this->_maxlinelen))
482
+		while ($currentHeader = fgets($fp, $this->_maxlinelen))
483 483
 		{
484 484
 			if ($this->read_timeout > 0 && $this->_check_timeout($fp))
485 485
 			{
486
-				$this->status=-100;
486
+				$this->status = -100;
487 487
 				return false;
488 488
 			}
489 489
 				
490 490
 		//	if($currentHeader == "\r\n")
491
-			if(preg_match("/^\r?\n$/", $currentHeader) )
491
+			if (preg_match("/^\r?\n$/", $currentHeader))
492 492
 			      break;
493 493
 						
494 494
 			// if a header begins with Location: or URI:, set the redirect
495
-			if(preg_match("/^(Location:|URI:)/i",$currentHeader))
495
+			if (preg_match("/^(Location:|URI:)/i", $currentHeader))
496 496
 			{
497 497
 				// get URL portion of the redirect
498
-				preg_match("/^(Location:|URI:)\s+(.*)/",chop($currentHeader),$matches);
498
+				preg_match("/^(Location:|URI:)\s+(.*)/", chop($currentHeader), $matches);
499 499
 				// look for :// in the Location header to see if hostname is included
500
-				if(!preg_match("|\:\/\/|",$matches[2]))
500
+				if (!preg_match("|\:\/\/|", $matches[2]))
501 501
 				{
502 502
 					// no host in the path, so prepend
503 503
 					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
504 504
 					// eliminate double slash
505
-					if(!preg_match("|^/|",$matches[2]))
505
+					if (!preg_match("|^/|", $matches[2]))
506 506
 							$this->_redirectaddr .= "/".$matches[2];
507 507
 					else
508 508
 							$this->_redirectaddr .= $matches[2];
@@ -511,16 +511,16 @@  discard block
 block discarded – undo
511 511
 					$this->_redirectaddr = $matches[2];
512 512
 			}
513 513
 		
514
-			if(preg_match("|^HTTP/|",$currentHeader))
514
+			if (preg_match("|^HTTP/|", $currentHeader))
515 515
 			{
516
-                if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status))
516
+                if (preg_match("|^HTTP/[^\s]*\s(.*?)\s|", $currentHeader, $status))
517 517
 				{
518
-					$this->status= $status[1];
518
+					$this->status = $status[1];
519 519
                 }				
520 520
 				$this->response_code = $currentHeader;
521 521
 			}
522 522
 			
523
-			if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) {
523
+			if (preg_match("/Content-Encoding: gzip/", $currentHeader)) {
524 524
 				$is_gzipped = true;
525 525
 			}
526 526
 			
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 
530 530
 		# $results = fread($fp, $this->maxlength);
531 531
 		$results = "";
532
-		while ( $data = fread($fp, $this->maxlength) ) {
532
+		while ($data = fread($fp, $this->maxlength)) {
533 533
 		    $results .= $data;
534 534
 		    if (
535 535
 		        strlen($results) > $this->maxlength ) {
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 		}
539 539
 		
540 540
 		// gunzip
541
-		if ( $is_gzipped ) {
541
+		if ($is_gzipped) {
542 542
 			// per http://www.php.net/manual/en/function.gzencode.php
543 543
 			$results = substr($results, 10);
544 544
 			$results = gzinflate($results);
@@ -546,26 +546,26 @@  discard block
 block discarded – undo
546 546
 		
547 547
 		if ($this->read_timeout > 0 && $this->_check_timeout($fp))
548 548
 		{
549
-			$this->status=-100;
549
+			$this->status = -100;
550 550
 			return false;
551 551
 		}
552 552
 		
553 553
 		// check if there is a a redirect meta tag
554 554
 		
555
-		if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
555
+		if (preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i", $results, $match))
556 556
 		{
557
-			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);	
557
+			$this->_redirectaddr = $this->_expandlinks($match[1], $URI);	
558 558
 		}
559 559
 
560 560
 		// have we hit our frame depth and is there frame src to fetch?
561
-		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
561
+		if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match))
562 562
 		{
563 563
 			$this->results[] = $results;
564
-			for($x=0; $x<count($match[1]); $x++)
565
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
564
+			for ($x = 0; $x < count($match[1]); $x++)
565
+				$this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"]."://".$this->host);
566 566
 		}
567 567
 		// have we already fetched framed content?
568
-		elseif(is_array($this->results))
568
+		elseif (is_array($this->results))
569 569
 			$this->results[] = $results;
570 570
 		// no framed content
571 571
 		else
@@ -583,66 +583,66 @@  discard block
 block discarded – undo
583 583
 	Output:		
584 584
 \*======================================================================*/
585 585
 	
586
-	private function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
586
+	private function _httpsrequest($url, $URI, $http_method, $content_type = "", $body = "")
587 587
 	{
588
-		if($this->passcookies && $this->_redirectaddr)
588
+		if ($this->passcookies && $this->_redirectaddr)
589 589
 			$this->setcookies();
590 590
 
591 591
 		$headers = array();		
592 592
 					
593 593
 		$URI_PARTS = parse_url($URI);
594
-		if(empty($url))
594
+		if (empty($url))
595 595
 			$url = "/";
596 596
 		// GET ... header not needed for curl
597 597
 		//$headers[] = $http_method." ".$url." ".$this->_httpversion;		
598
-		if(!empty($this->agent))
598
+		if (!empty($this->agent))
599 599
 			$headers[] = "User-Agent: ".$this->agent;
600
-		if(!empty($this->host))
600
+		if (!empty($this->host))
601 601
 			$headers[] = "Host: ".$this->host;
602
-		if(!empty($this->accept))
602
+		if (!empty($this->accept))
603 603
 			$headers[] = "Accept: ".$this->accept;
604
-		if(!empty($this->referer))
604
+		if (!empty($this->referer))
605 605
 			$headers[] = "Referer: ".$this->referer;
606
-		if(!empty($this->cookies))
606
+		if (!empty($this->cookies))
607 607
 		{			
608
-			if(!is_array($this->cookies))
609
-				$this->cookies = (array)$this->cookies;
608
+			if (!is_array($this->cookies))
609
+				$this->cookies = (array) $this->cookies;
610 610
 	
611 611
 			reset($this->cookies);
612
-			if ( count($this->cookies) > 0 ) {
612
+			if (count($this->cookies) > 0) {
613 613
 				$cookie_str = 'Cookie: ';
614
-				foreach ( $this->cookies as $cookieKey => $cookieVal ) {
614
+				foreach ($this->cookies as $cookieKey => $cookieVal) {
615 615
 				$cookie_str .= $cookieKey."=".urlencode($cookieVal)."; ";
616 616
 				}
617
-				$headers[] = substr($cookie_str,0,-2);
617
+				$headers[] = substr($cookie_str, 0, -2);
618 618
 			}
619 619
 		}
620
-		if(!empty($this->rawheaders))
620
+		if (!empty($this->rawheaders))
621 621
 		{
622
-			if(!is_array($this->rawheaders))
623
-				$this->rawheaders = (array)$this->rawheaders;
624
-			while(list($headerKey,$headerVal) = each($this->rawheaders))
622
+			if (!is_array($this->rawheaders))
623
+				$this->rawheaders = (array) $this->rawheaders;
624
+			while (list($headerKey, $headerVal) = each($this->rawheaders))
625 625
 				$headers[] = $headerKey.": ".$headerVal;
626 626
 		}
627
-		if(!empty($content_type)) {
627
+		if (!empty($content_type)) {
628 628
 			if ($content_type == "multipart/form-data")
629 629
 				$headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary;
630 630
 			else
631 631
 				$headers[] = "Content-type: $content_type";
632 632
 		}
633
-		if(!empty($body))	
633
+		if (!empty($body))	
634 634
 			$headers[] = "Content-length: ".strlen($body);
635
-		if(!empty($this->user) || !empty($this->pass))	
635
+		if (!empty($this->user) || !empty($this->pass))	
636 636
 			$headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
637 637
 			
638
-		for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
638
+		for ($curr_header = 0; $curr_header < count($headers); $curr_header++) {
639 639
 			$cmdline_params .= " -H \"".$headers[$curr_header]."\"";
640 640
 		}
641 641
 			  	                         
642
-		if(!empty($body))
642
+		if (!empty($body))
643 643
 			$cmdline_params .= " -d \"$body\"";
644 644
 		
645
-		if($this->read_timeout > 0)
645
+		if ($this->read_timeout > 0)
646 646
 			$cmdline_params .= " -m ".$this->read_timeout;
647 647
 		
648 648
 		$headerfile = uniqid(time());
@@ -651,37 +651,37 @@  discard block
 block discarded – undo
651 651
 		$cmdline_params .= " -k";
652 652
         $results = array();
653 653
         $return = 0;
654
-		exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI),$results,$return);
654
+		exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI), $results, $return);
655 655
 		
656
-		if($return)
656
+		if ($return)
657 657
 		{
658 658
 			$this->error = "Error: cURL could not retrieve the document, error $return.";
659 659
 			return false;
660 660
 		}
661 661
 			
662 662
 			
663
-		$results = implode("\r\n",$results);
663
+		$results = implode("\r\n", $results);
664 664
 		
665 665
 		$result_headers = file("/tmp/$headerfile");
666 666
 						
667 667
 		$this->_redirectaddr = false;
668 668
 		unset($this->headers);
669 669
 						
670
-		for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
670
+		for ($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
671 671
 		{
672 672
 			
673 673
 			// if a header begins with Location: or URI:, set the redirect
674
-			if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader]))
674
+			if (preg_match("/^(Location: |URI: )/i", $result_headers[$currentHeader]))
675 675
 			{
676 676
 				// get URL portion of the redirect
677
-				preg_match("/^(Location: |URI:)(.*)/",chop($result_headers[$currentHeader]),$matches);
677
+				preg_match("/^(Location: |URI:)(.*)/", chop($result_headers[$currentHeader]), $matches);
678 678
 				// look for :// in the Location header to see if hostname is included
679
-				if(!preg_match("|\:\/\/|",$matches[2]))
679
+				if (!preg_match("|\:\/\/|", $matches[2]))
680 680
 				{
681 681
 					// no host in the path, so prepend
682 682
 					$this->_redirectaddr = $URI_PARTS["scheme"]."://".$this->host.":".$this->port;
683 683
 					// eliminate double slash
684
-					if(!preg_match("|^/|",$matches[2]))
684
+					if (!preg_match("|^/|", $matches[2]))
685 685
 							$this->_redirectaddr .= "/".$matches[2];
686 686
 					else
687 687
 							$this->_redirectaddr .= $matches[2];
@@ -690,12 +690,12 @@  discard block
 block discarded – undo
690 690
 					$this->_redirectaddr = $matches[2];
691 691
 			}
692 692
 		
693
-			if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
693
+			if (preg_match("|^HTTP/|", $result_headers[$currentHeader]))
694 694
 			{
695 695
 			    $this->response_code = $result_headers[$currentHeader];
696
-			    if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$this->response_code, $match))
696
+			    if (preg_match("|^HTTP/[^\s]*\s(.*?)\s|", $this->response_code, $match))
697 697
 			    {
698
-				$this->status= $match[1];
698
+				$this->status = $match[1];
699 699
                 	    }
700 700
 			}
701 701
 			$this->headers[] = $result_headers[$currentHeader];
@@ -703,20 +703,20 @@  discard block
 block discarded – undo
703 703
 
704 704
 		// check if there is a a redirect meta tag
705 705
 		
706
-		if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
706
+		if (preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]+URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i", $results, $match))
707 707
 		{
708
-			$this->_redirectaddr = $this->_expandlinks($match[1],$URI);	
708
+			$this->_redirectaddr = $this->_expandlinks($match[1], $URI);	
709 709
 		}
710 710
 
711 711
 		// have we hit our frame depth and is there frame src to fetch?
712
-		if(($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i",$results,$match))
712
+		if (($this->_framedepth < $this->maxframes) && preg_match_all("'<frame\s+.*src[\s]*=[\'\"]?([^\'\"\>]+)'i", $results, $match))
713 713
 		{
714 714
 			$this->results[] = $results;
715
-			for($x=0; $x<count($match[1]); $x++)
716
-				$this->_frameurls[] = $this->_expandlinks($match[1][$x],$URI_PARTS["scheme"]."://".$this->host);
715
+			for ($x = 0; $x < count($match[1]); $x++)
716
+				$this->_frameurls[] = $this->_expandlinks($match[1][$x], $URI_PARTS["scheme"]."://".$this->host);
717 717
 		}
718 718
 		// have we already fetched framed content?
719
-		elseif(is_array($this->results))
719
+		elseif (is_array($this->results))
720 720
 			$this->results[] = $results;
721 721
 		// no framed content
722 722
 		else
@@ -734,9 +734,9 @@  discard block
 block discarded – undo
734 734
 	
735 735
 	public function setcookies()
736 736
 	{
737
-		for($x=0; $x<count($this->headers); $x++)
737
+		for ($x = 0; $x < count($this->headers); $x++)
738 738
 		{
739
-		if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x],$match))
739
+		if (preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $this->headers[$x], $match))
740 740
 			$this->cookies[$match[1]] = $match[2];
741 741
 		}
742 742
 	}
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 	
769 769
 	private function _connect(&$fp)
770 770
 	{
771
-		if(!empty($this->proxy_host) && !empty($this->proxy_port))
771
+		if (!empty($this->proxy_host) && !empty($this->proxy_port))
772 772
 			{
773 773
 				$this->_isproxy = true;
774 774
 				$host = $this->proxy_host;
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 	
783 783
 		$this->status = 0;
784 784
 		
785
-		if($fp = fsockopen(
785
+		if ($fp = fsockopen(
786 786
 					$host,
787 787
 					$port,
788 788
 					$errno,
@@ -798,16 +798,16 @@  discard block
 block discarded – undo
798 798
 		{
799 799
 			// socket connection failed
800 800
 			$this->status = $errno;
801
-			switch($errno)
801
+			switch ($errno)
802 802
 			{
803 803
 				case -3:
804
-					$this->error="socket creation failed (-3)";
804
+					$this->error = "socket creation failed (-3)";
805 805
 				case -4:
806
-					$this->error="dns lookup failure (-4)";
806
+					$this->error = "dns lookup failure (-4)";
807 807
 				case -5:
808
-					$this->error="connection refused or timed out (-5)";
808
+					$this->error = "connection refused or timed out (-5)";
809 809
 				default:
810
-					$this->error="connection failed (".$errno.")";
810
+					$this->error = "connection failed (".$errno.")";
811 811
 			}
812 812
 			return false;
813 813
 		}
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 		switch ($this->_submit_type) {
844 844
 			case "application/x-www-form-urlencoded":
845 845
 				reset($formvars);
846
-				while(list($key,$val) = each($formvars)) {
846
+				while (list($key, $val) = each($formvars)) {
847 847
 					if (is_array($val) || is_object($val)) {
848 848
 						while (list($cur_key, $cur_val) = each($val)) {
849 849
 							$postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 				$this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
858 858
 				
859 859
 				reset($formvars);
860
-				while(list($key,$val) = each($formvars)) {
860
+				while (list($key, $val) = each($formvars)) {
861 861
 					if (is_array($val) || is_object($val)) {
862 862
 						while (list($cur_key, $cur_val) = each($val)) {
863 863
 							$postdata .= "--".$this->_mime_boundary."\r\n";
Please login to merge, or discard this patch.
main/inc/lib/magpierss/rss_parse.inc 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 define('RSS', 'RSS');
25 25
 define('ATOM', 'Atom');
26 26
 
27
-require_once (MAGPIE_DIR . 'rss_utils.inc');
27
+require_once (MAGPIE_DIR.'rss_utils.inc');
28 28
 
29 29
 /**
30 30
 * Hybrid parser, and object, takes RSS as a string and returns a simple object.
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
 class MagpieRSS {
37 37
     public $parser;
38 38
     
39
-    public $current_item   = array();  // item currently being parsed
40
-    public $items          = array();  // collection of parsed items
41
-    public $channel        = array();  // hash of channel fields
39
+    public $current_item   = array(); // item currently being parsed
40
+    public $items          = array(); // collection of parsed items
41
+    public $channel        = array(); // hash of channel fields
42 42
     public $textinput      = array();
43 43
     public $image          = array();
44 44
     public $feed_type;
45 45
     public $feed_version;
46
-    public $encoding       = '';       // output encoding of parsed rss
46
+    public $encoding       = ''; // output encoding of parsed rss
47 47
     
48
-    private $_source_encoding = '';     // only set if we have to parse xml prolog
48
+    private $_source_encoding = ''; // only set if we have to parse xml prolog
49 49
     
50 50
     public $ERROR = "";
51 51
     public $WARNING = "";
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
      *                                  source encoding. (caveat emptor)
94 94
      *
95 95
      */
96
-    public function MagpieRSS ($source, $output_encoding='ISO-8859-1', 
97
-                        $input_encoding=null, $detect_encoding=true) 
96
+    public function MagpieRSS($source, $output_encoding = 'ISO-8859-1', 
97
+                        $input_encoding = null, $detect_encoding = true) 
98 98
     {   
99 99
         # if PHP xml isn't compiled in, die
100 100
         #
101 101
         if (!function_exists('xml_parser_create')) {
102
-            $this->error( "Failed to load PHP's XML Extension. " . 
102
+            $this->error("Failed to load PHP's XML Extension. ". 
103 103
                           "http://www.php.net/manual/en/ref.xml.php",
104
-                           E_USER_ERROR );
104
+                           E_USER_ERROR);
105 105
         }
106 106
         
107 107
         list($parser, $source) = $this->create_parser($source, 
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
         
110 110
         
111 111
         if (!is_resource($parser)) {
112
-            $this->error( "Failed to create an instance of PHP's XML parser. " .
112
+            $this->error("Failed to create an instance of PHP's XML parser. ".
113 113
                           "http://www.php.net/manual/en/ref.xml.php",
114
-                          E_USER_ERROR );
114
+                          E_USER_ERROR);
115 115
         }
116 116
 
117 117
         
@@ -120,27 +120,27 @@  discard block
 block discarded – undo
120 120
         # pass in parser, and a reference to this object
121 121
         # setup handlers
122 122
         #
123
-        xml_set_object( $this->parser, $this );
123
+        xml_set_object($this->parser, $this);
124 124
         xml_set_element_handler($this->parser, 
125
-                'feed_start_element', 'feed_end_element' );
125
+                'feed_start_element', 'feed_end_element');
126 126
                         
127
-        xml_set_character_data_handler( $this->parser, 'feed_cdata' ); 
127
+        xml_set_character_data_handler($this->parser, 'feed_cdata'); 
128 128
     
129
-        $status = xml_parse( $this->parser, $source );
129
+        $status = xml_parse($this->parser, $source);
130 130
         
131
-        if (! $status ) {
132
-            $errorcode = xml_get_error_code( $this->parser );
133
-            if ( $errorcode != XML_ERROR_NONE ) {
134
-                $xml_error = xml_error_string( $errorcode );
131
+        if (!$status) {
132
+            $errorcode = xml_get_error_code($this->parser);
133
+            if ($errorcode != XML_ERROR_NONE) {
134
+                $xml_error = xml_error_string($errorcode);
135 135
                 $error_line = xml_get_current_line_number($this->parser);
136 136
                 $error_col = xml_get_current_column_number($this->parser);
137 137
                 $errormsg = "$xml_error at line $error_line, column $error_col";
138 138
 
139
-                $this->error( $errormsg );
139
+                $this->error($errormsg);
140 140
             }
141 141
         }
142 142
         
143
-        xml_parser_free( $this->parser );
143
+        xml_parser_free($this->parser);
144 144
 
145 145
         $this->normalize();
146 146
     }
@@ -151,26 +151,26 @@  discard block
 block discarded – undo
151 151
         
152 152
         // check for a namespace, and split if found
153 153
         $ns = false;
154
-        if ( strpos( $element, ':' ) ) {
155
-            list($ns, $el) = split( ':', $element, 2); 
154
+        if (strpos($element, ':')) {
155
+            list($ns, $el) = split(':', $element, 2); 
156 156
         }
157
-        if ( $ns and $ns != 'rdf' ) {
157
+        if ($ns and $ns != 'rdf') {
158 158
             $this->current_namespace = $ns;
159 159
         }
160 160
             
161 161
         # if feed type isn't set, then this is first element of feed
162 162
         # identify feed from root element
163 163
         #
164
-        if (!isset($this->feed_type) ) {
165
-            if ( $el == 'rdf' ) {
164
+        if (!isset($this->feed_type)) {
165
+            if ($el == 'rdf') {
166 166
                 $this->feed_type = RSS;
167 167
                 $this->feed_version = '1.0';
168 168
             }
169
-            elseif ( $el == 'rss' ) {
169
+            elseif ($el == 'rss') {
170 170
                 $this->feed_type = RSS;
171 171
                 $this->feed_version = $attrs['version'];
172 172
             }
173
-            elseif ( $el == 'feed' ) {
173
+            elseif ($el == 'feed') {
174 174
                 $this->feed_type = ATOM;
175 175
                 $this->feed_version = $attrs['version'];
176 176
                 $this->inchannel = true;
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
             return;
179 179
         }
180 180
     
181
-        if ( $el == 'channel' ) 
181
+        if ($el == 'channel') 
182 182
         {
183 183
             $this->inchannel = true;
184 184
         }
185
-        elseif ($el == 'item' or $el == 'entry' ) 
185
+        elseif ($el == 'item' or $el == 'entry') 
186 186
         {
187 187
             $this->initem = true;
188
-            if ( isset($attrs['rdf:about']) ) {
188
+            if (isset($attrs['rdf:about'])) {
189 189
                 $this->current_item['about'] = $attrs['rdf:about']; 
190 190
             }
191 191
         }
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
         }
210 210
         
211 211
         # handle atom content constructs
212
-        elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
212
+        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS))
213 213
         {
214 214
             // avoid clashing w/ RSS mod_content
215
-            if ($el == 'content' ) {
215
+            if ($el == 'content') {
216 216
                 $el = 'atom_content';
217 217
             }
218 218
             
@@ -222,31 +222,31 @@  discard block
 block discarded – undo
222 222
         }
223 223
         
224 224
         // if inside an Atom content construct (e.g. content or summary) field treat tags as text
225
-        elseif ($this->feed_type == ATOM and $this->incontent ) 
225
+        elseif ($this->feed_type == ATOM and $this->incontent) 
226 226
         {
227 227
             // if tags are inlined, then flatten
228 228
             $attrs_str = join(' ', 
229 229
                     array_map('map_attrs', 
230 230
                     array_keys($attrs), 
231
-                    array_values($attrs) ) );
231
+                    array_values($attrs)));
232 232
             
233
-            $this->append_content( "<$element $attrs_str>"  );
233
+            $this->append_content("<$element $attrs_str>");
234 234
                     
235
-            array_unshift( $this->stack, $el );
235
+            array_unshift($this->stack, $el);
236 236
         }
237 237
         
238 238
         // Atom support many links per containging element.
239 239
         // Magpie treats link elements of type rel='alternate'
240 240
         // as being equivalent to RSS's simple link element.
241 241
         //
242
-        elseif ($this->feed_type == ATOM and $el == 'link' ) 
242
+        elseif ($this->feed_type == ATOM and $el == 'link') 
243 243
         {
244
-            if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) 
244
+            if (isset($attrs['rel']) and $attrs['rel'] == 'alternate') 
245 245
             {
246 246
                 $link_el = 'link';
247 247
             }
248 248
             else {
249
-                $link_el = 'link_' . $attrs['rel'];
249
+                $link_el = 'link_'.$attrs['rel'];
250 250
             }
251 251
             
252 252
             $this->append($link_el, $attrs['href']);
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
     
260 260
 
261 261
     
262
-    public function feed_cdata ($p, $text) {
262
+    public function feed_cdata($p, $text) {
263 263
         if ($this->feed_type == ATOM and $this->incontent) 
264 264
         {
265
-            $this->append_content( $text );
265
+            $this->append_content($text);
266 266
         }
267 267
         else {
268 268
             $current_el = join('_', array_reverse($this->stack));
@@ -270,35 +270,35 @@  discard block
 block discarded – undo
270 270
         }
271 271
     }
272 272
     
273
-    public function feed_end_element ($p, $el) {
273
+    public function feed_end_element($p, $el) {
274 274
         $el = strtolower($el);
275 275
         
276
-        if ( $el == 'item' or $el == 'entry' ) 
276
+        if ($el == 'item' or $el == 'entry') 
277 277
         {
278 278
             $this->items[] = $this->current_item;
279 279
             $this->current_item = array();
280 280
             $this->initem = false;
281 281
         }
282
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) 
282
+        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput') 
283 283
         {
284 284
             $this->intextinput = false;
285 285
         }
286
-        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) 
286
+        elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image') 
287 287
         {
288 288
             $this->inimage = false;
289 289
         }
290
-        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
290
+        elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS))
291 291
         {   
292 292
             $this->incontent = false;
293 293
         }
294
-        elseif ($el == 'channel' or $el == 'feed' ) 
294
+        elseif ($el == 'channel' or $el == 'feed') 
295 295
         {
296 296
             $this->inchannel = false;
297 297
         }
298
-        elseif ($this->feed_type == ATOM and $this->incontent  ) {
298
+        elseif ($this->feed_type == ATOM and $this->incontent) {
299 299
             // balance tags properly
300 300
             // note:  i don't think this is actually neccessary
301
-            if ( $this->stack[0] == $el ) 
301
+            if ($this->stack[0] == $el) 
302 302
             {
303 303
                 $this->append_content("</$el>");
304 304
             }
@@ -306,18 +306,18 @@  discard block
 block discarded – undo
306 306
                 $this->append_content("<$el />");
307 307
             }
308 308
 
309
-            array_shift( $this->stack );
309
+            array_shift($this->stack);
310 310
         }
311 311
         else {
312
-            array_shift( $this->stack );
312
+            array_shift($this->stack);
313 313
         }
314 314
         
315 315
         $this->current_namespace = false;
316 316
     }
317 317
     
318
-    public function concat (&$str1, $str2="") {
319
-        if (!isset($str1) ) {
320
-            $str1="";
318
+    public function concat(&$str1, $str2 = "") {
319
+        if (!isset($str1)) {
320
+            $str1 = "";
321 321
         }
322 322
         $str1 .= $str2;
323 323
     }
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
     
326 326
     
327 327
     public function append_content($text) {
328
-        if ( $this->initem ) {
329
-            $this->concat( $this->current_item[ $this->incontent ], $text );
328
+        if ($this->initem) {
329
+            $this->concat($this->current_item[$this->incontent], $text);
330 330
         }
331
-        elseif ( $this->inchannel ) {
332
-            $this->concat( $this->channel[ $this->incontent ], $text );
331
+        elseif ($this->inchannel) {
332
+            $this->concat($this->channel[$this->incontent], $text);
333 333
         }
334 334
     }
335 335
     
@@ -338,59 +338,59 @@  discard block
 block discarded – undo
338 338
         if (!$el) {
339 339
             return;
340 340
         }
341
-        if ( $this->current_namespace ) 
341
+        if ($this->current_namespace) 
342 342
         {
343
-            if ( $this->initem ) {
343
+            if ($this->initem) {
344 344
                 $this->concat(
345
-                    $this->current_item[ $this->current_namespace ][ $el ], $text);
345
+                    $this->current_item[$this->current_namespace][$el], $text);
346 346
             }
347 347
             elseif ($this->inchannel) {
348 348
                 $this->concat(
349
-                    $this->channel[ $this->current_namespace][ $el ], $text );
349
+                    $this->channel[$this->current_namespace][$el], $text );
350 350
             }
351 351
             elseif ($this->intextinput) {
352 352
                 $this->concat(
353
-                    $this->textinput[ $this->current_namespace][ $el ], $text );
353
+                    $this->textinput[$this->current_namespace][$el], $text );
354 354
             }
355 355
             elseif ($this->inimage) {
356 356
                 $this->concat(
357
-                    $this->image[ $this->current_namespace ][ $el ], $text );
357
+                    $this->image[$this->current_namespace][$el], $text );
358 358
             }
359 359
         }
360 360
         else {
361
-            if ( $this->initem ) {
361
+            if ($this->initem) {
362 362
                 $this->concat(
363
-                    $this->current_item[ $el ], $text);
363
+                    $this->current_item[$el], $text);
364 364
             }
365 365
             elseif ($this->intextinput) {
366 366
                 $this->concat(
367
-                    $this->textinput[ $el ], $text );
367
+                    $this->textinput[$el], $text );
368 368
             }
369 369
             elseif ($this->inimage) {
370 370
                 $this->concat(
371
-                    $this->image[ $el ], $text );
371
+                    $this->image[$el], $text );
372 372
             }
373 373
             elseif ($this->inchannel) {
374 374
                 $this->concat(
375
-                    $this->channel[ $el ], $text );
375
+                    $this->channel[$el], $text );
376 376
             }
377 377
             
378 378
         }
379 379
     }
380 380
     
381
-    public function normalize () {
381
+    public function normalize() {
382 382
         // if atom populate rss fields
383
-        if ( $this->is_atom() ) {
383
+        if ($this->is_atom()) {
384 384
             $this->channel['description'] = $this->channel['tagline'];
385
-            for ( $i = 0; $i < count($this->items); $i++) {
385
+            for ($i = 0; $i < count($this->items); $i++) {
386 386
                 $item = $this->items[$i];
387
-                if ( isset($item['summary']) )
387
+                if (isset($item['summary']))
388 388
                     $item['description'] = $item['summary'];
389
-                if ( isset($item['atom_content']))
389
+                if (isset($item['atom_content']))
390 390
                     $item['content']['encoded'] = $item['atom_content'];
391 391
                 
392
-                $atom_date = (isset($item['issued']) ) ? $item['issued'] : $item['modified'];
393
-                if ( $atom_date ) {
392
+                $atom_date = (isset($item['issued'])) ? $item['issued'] : $item['modified'];
393
+                if ($atom_date) {
394 394
                     $epoch = @parse_w3cdtf($atom_date);
395 395
                     if ($epoch and $epoch > 0) {
396 396
                         $item['date_timestamp'] = $epoch;
@@ -400,22 +400,22 @@  discard block
 block discarded – undo
400 400
                 $this->items[$i] = $item;
401 401
             }       
402 402
         }
403
-        elseif ( $this->is_rss() ) {
403
+        elseif ($this->is_rss()) {
404 404
             $this->channel['tagline'] = $this->channel['description'];
405
-            for ( $i = 0; $i < count($this->items); $i++) {
405
+            for ($i = 0; $i < count($this->items); $i++) {
406 406
                 $item = $this->items[$i];
407
-                if ( isset($item['description']))
407
+                if (isset($item['description']))
408 408
                     $item['summary'] = $item['description'];
409
-                if ( isset($item['content']['encoded'] ) )
409
+                if (isset($item['content']['encoded']))
410 410
                     $item['atom_content'] = $item['content']['encoded'];
411 411
                 
412
-                if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) {
412
+                if ($this->is_rss() == '1.0' and isset($item['dc']['date'])) {
413 413
                     $epoch = @parse_w3cdtf($item['dc']['date']);
414 414
                     if ($epoch and $epoch > 0) {
415 415
                         $item['date_timestamp'] = $epoch;
416 416
                     }
417 417
                 }
418
-                elseif ( isset($item['pubdate']) ) {
418
+                elseif (isset($item['pubdate'])) {
419 419
                     $epoch = @strtotime($item['pubdate']);
420 420
                     if ($epoch > 0) {
421 421
                         $item['date_timestamp'] = $epoch;
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
     }
429 429
     
430 430
     
431
-    public function is_rss () {
432
-        if ( $this->feed_type == RSS ) {
431
+    public function is_rss() {
432
+        if ($this->feed_type == RSS) {
433 433
             return $this->feed_version; 
434 434
         }
435 435
         else {
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
     }
439 439
     
440 440
     public function is_atom() {
441
-        if ( $this->feed_type == ATOM ) {
441
+        if ($this->feed_type == ATOM) {
442 442
             return $this->feed_version;
443 443
         }
444 444
         else {
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
     *
452 452
     */
453 453
     public function create_parser($source, $out_enc, $in_enc, $detect) {
454
-        if ( substr(phpversion(),0,1) == 5) {
454
+        if (substr(phpversion(), 0, 1) == 5) {
455 455
             $parser = $this->php5_create_parser($in_enc, $detect);
456 456
         }
457 457
         else {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     */
477 477
     public function php5_create_parser($in_enc, $detect) {
478 478
         // by default php5 does a fine job of detecting input encodings
479
-        if(!$detect && $in_enc) {
479
+        if (!$detect && $in_enc) {
480 480
             return xml_parser_create($in_enc);
481 481
         }
482 482
         else {
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
     *
501 501
     */
502 502
     public function php4_create_parser($source, $in_enc, $detect) {
503
-        if ( !$detect ) {
503
+        if (!$detect) {
504 504
             return array(xml_parser_create($in_enc), $source);
505 505
         }
506 506
         
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
         // cast the XML to a known encoding
525 525
         // @see http://php.net/iconv
526 526
        
527
-        if (function_exists('iconv'))  {
528
-            $encoded_source = iconv($in_enc,'UTF-8', $source);
527
+        if (function_exists('iconv')) {
528
+            $encoded_source = iconv($in_enc, 'UTF-8', $source);
529 529
             if ($encoded_source) {
530 530
                 return array(xml_parser_create('UTF-8'), $encoded_source);
531 531
             }
@@ -533,15 +533,15 @@  discard block
 block discarded – undo
533 533
         
534 534
         // iconv didn't work, try mb_convert_encoding
535 535
         // @see http://php.net/mbstring
536
-        if(function_exists('mb_convert_encoding')) {
537
-            $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc );
536
+        if (function_exists('mb_convert_encoding')) {
537
+            $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc);
538 538
             if ($encoded_source) {
539 539
                 return array(xml_parser_create('UTF-8'), $encoded_source);
540 540
             }
541 541
         }
542 542
         
543 543
         // else 
544
-        $this->error("Feed is in an unsupported character encoding. ($in_enc) " .
544
+        $this->error("Feed is in an unsupported character encoding. ($in_enc) ".
545 545
                      "You may see strange artifacts, and mangled characters.",
546 546
                      E_USER_NOTICE);
547 547
             
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
     
551 551
     public function known_encoding($enc) {
552 552
         $enc = strtoupper($enc);
553
-        if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) {
553
+        if (in_array($enc, $this->_KNOWN_ENCODINGS)) {
554 554
             return $enc;
555 555
         }
556 556
         else {
@@ -558,20 +558,20 @@  discard block
 block discarded – undo
558 558
         }
559 559
     }
560 560
 
561
-    public function error ($errormsg, $lvl=E_USER_WARNING) {
561
+    public function error($errormsg, $lvl = E_USER_WARNING) {
562 562
         // append PHP's error message if track_errors enabled
563
-        if ( isset($php_errormsg) ) { 
563
+        if (isset($php_errormsg)) { 
564 564
             $errormsg .= " ($php_errormsg)";
565 565
         }
566
-        if ( MAGPIE_DEBUG ) {
567
-            trigger_error( $errormsg, $lvl);        
566
+        if (MAGPIE_DEBUG) {
567
+            trigger_error($errormsg, $lvl);        
568 568
         }
569 569
         else {
570
-            error_log( $errormsg, 0);
570
+            error_log($errormsg, 0);
571 571
         }
572 572
         
573
-        $notices = E_USER_NOTICE|E_NOTICE;
574
-        if ( $lvl&$notices ) {
573
+        $notices = E_USER_NOTICE | E_NOTICE;
574
+        if ($lvl & $notices) {
575 575
             $this->WARNING = $errormsg;
576 576
         } else {
577 577
             $this->ERROR = $errormsg;
@@ -589,15 +589,15 @@  discard block
 block discarded – undo
589 589
 // courtesy, Ryan Currie, [email protected]
590 590
 
591 591
 if (!function_exists('array_change_key_case')) {
592
-	define("CASE_UPPER",1);
593
-	define("CASE_LOWER",0);
592
+	define("CASE_UPPER", 1);
593
+	define("CASE_LOWER", 0);
594 594
 
595 595
 
596
-	function array_change_key_case($array,$case=CASE_LOWER) {
597
-       if ($case=CASE_LOWER) $cmd=strtolower;
598
-       elseif ($case=CASE_UPPER) $cmd=strtoupper;
599
-       foreach($array as $key=>$value) {
600
-               $output[$cmd($key)]=$value;
596
+	function array_change_key_case($array, $case = CASE_LOWER) {
597
+       if ($case = CASE_LOWER) $cmd = strtolower;
598
+       elseif ($case = CASE_UPPER) $cmd = strtoupper;
599
+       foreach ($array as $key=>$value) {
600
+               $output[$cmd($key)] = $value;
601 601
        }
602 602
        return $output;
603 603
 	}
Please login to merge, or discard this patch.
main/inc/lib/conditional_login.class.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
                     if (isset($condition['conditional_function']) && $condition['conditional_function']($user) == false) {
24 24
                         $_SESSION['conditional_login']['uid'] = $user['user_id'];
25 25
                         $_SESSION['conditional_login']['can_login'] = false;
26
-                        header("Location:". $condition['url']);
26
+                        header("Location:".$condition['url']);
27 27
                         exit();
28 28
                     }
29 29
                 }
Please login to merge, or discard this patch.