Completed
Push — 1.10.x ( f55f3b...22bf41 )
by Yannick
707:00 queued 656:35
created
main/inc/lib/fileUpload.lib.php 3 patches
Doc Comments   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,6 +17,7 @@  discard block
 block discarded – undo
17 17
  *
18 18
  * @author - Hugues Peeters <[email protected]>
19 19
  * @param  - file_name (string) name of a file
20
+ * @param string $file_name
20 21
  * @return - the filenam phps'ized
21 22
  */
22 23
 function php2phps($file_name) {
@@ -73,7 +74,7 @@  discard block
 block discarded – undo
73 74
  * Returns the name without extension, used for the title
74 75
  *
75 76
  * @param string $name
76
- * @return name without the extension
77
+ * @return string without the extension
77 78
  */
78 79
 function get_document_title($name) {
79 80
     // If they upload .htaccess...
@@ -86,7 +87,7 @@  discard block
 block discarded – undo
86 87
  * This function checks if the upload succeeded
87 88
  *
88 89
  * @param array $uploaded_file ($_FILES)
89
- * @return true if upload succeeded
90
+ * @return boolean if upload succeeded
90 91
  */
91 92
 function process_uploaded_file($uploaded_file, $show_output = true)
92 93
 {
@@ -698,6 +699,8 @@  discard block
 block discarded – undo
698 699
  * @param  - dir (string) - Path of the directory
699 700
  *           whe the file should be added
700 701
  * @param  - max_dir_space (int) - maximum size of the diretory in byte
702
+ * @param string $dir
703
+ * @param integer $max_dir_space
701 704
  * @return - boolean true if there is enough space,
702 705
  *				boolean false otherwise
703 706
  *
@@ -1022,7 +1025,7 @@  discard block
 block discarded – undo
1022 1025
  * @param array  $courseInfo
1023 1026
  * @param array  $userInfo
1024 1027
  * @param array  $uploaded_file - follows the $_FILES Structure
1025
- * @param string $upload_path   - destination of the upload.
1028
+ * @param string $uploadPath   - destination of the upload.
1026 1029
  *                               This path is to append to $base_work_dir
1027 1030
  * @param string $base_work_dir  - base working directory of the module
1028 1031
  * @param int    $maxFilledSpace  - amount of bytes to not exceed in the base
@@ -1201,7 +1204,7 @@  discard block
 block discarded – undo
1201 1204
  * @param bool $save_visibility
1202 1205
  * @param int $group_id
1203 1206
  * @param int $session_id Session ID, if any
1204
- * @return int id if inserted document
1207
+ * @return string|false id if inserted document
1205 1208
  */
1206 1209
 function add_document(
1207 1210
     $_course,
@@ -1337,7 +1340,7 @@  discard block
 block discarded – undo
1337 1340
  *
1338 1341
  * @author	Olivier Cauberghe <[email protected]>
1339 1342
  * @param	path+filename eg: /main/document/document.php
1340
- * @return	The directory depth
1343
+ * @return	integer directory depth
1341 1344
  */
1342 1345
 function get_levels($filename) {
1343 1346
     $levels = explode('/', $filename);
@@ -1354,6 +1357,7 @@  discard block
 block discarded – undo
1354 1357
  * @author	Olivier Cauberghe <[email protected]>
1355 1358
  * @param	path,filename
1356 1359
  * action:	Adds an entry to the document table with the default settings.
1360
+ * @param string $upload_path
1357 1361
  */
1358 1362
 function set_default_settings($upload_path, $filename, $filetype = 'file')
1359 1363
 {
@@ -1778,6 +1782,7 @@  discard block
 block discarded – undo
1778 1782
 
1779 1783
 @author Roan Embrechts
1780 1784
 @version 0.6
1785
+ * @param string $buffer
1781 1786
  */
1782 1787
 function api_replace_links_in_string($upload_path, $buffer) {
1783 1788
     // Search for hyperlinks
@@ -2013,7 +2018,6 @@  discard block
 block discarded – undo
2013 2018
  * @param int $groupId
2014 2019
  * @param bool $output
2015 2020
  * @param array $parent
2016
- * @param string $uploadPath
2017 2021
  *
2018 2022
  */
2019 2023
 function add_all_documents_in_folder_to_database(
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -993,7 +993,9 @@
 block discarded – undo
993 993
                     if ($file != '.' && $file != '..') {
994 994
 
995 995
                         $filetype = 'file';
996
-                        if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder';
996
+                        if (is_dir($base_work_dir.$upload_path.'/'.$file)) {
997
+                            $filetype = 'folder';
998
+                        }
997 999
 
998 1000
                         $safe_file = api_replace_dangerous_char($file, 'strict');
999 1001
                         @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file);
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
     $name_no_ext = substr($name, 0, strlen($name) - strlen(strstr($name, $ext)));
64 64
     $n = 0;
65 65
     $unique = '';
66
-    while (file_exists($path . $name_no_ext . $unique . $ext)) {
67
-        $unique = '_' . ++$n;
66
+    while (file_exists($path.$name_no_ext.$unique.$ext)) {
67
+        $unique = '_'.++$n;
68 68
     }
69
-    return $name_no_ext . $unique . $ext;
69
+    return $name_no_ext.$unique.$ext;
70 70
 }
71 71
 
72 72
 /**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                 // Not used at the moment, but could be handy if we want to limit the size of an upload (e.g. image upload in html editor).
106 106
                 $max_file_size = intval($_POST['MAX_FILE_SIZE']);
107 107
                 if ($show_output) {
108
-                    Display::display_error_message(get_lang('UplExceedMaxPostSize'). format_file_size($max_file_size));
108
+                    Display::display_error_message(get_lang('UplExceedMaxPostSize').format_file_size($max_file_size));
109 109
                 }
110 110
 
111 111
                 return false;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             case 4:
120 120
                 // No file was uploaded.
121 121
                 if ($show_output) {
122
-                    Display::display_error_message(get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst'));
122
+                    Display::display_error_message(get_lang('UplNoFileUploaded').' '.get_lang('UplSelectFileFirst'));
123 123
                 }
124 124
 
125 125
                 return false;
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
                             // Display success message with extra info to user
460 460
                             if ($output) {
461 461
                                 Display::display_confirmation_message(
462
-                                    get_lang('UplUploadSucceeded') . '<br /> ' . $documentTitle . ' ' . get_lang('UplFileOverwritten'),
462
+                                    get_lang('UplUploadSucceeded').'<br /> '.$documentTitle.' '.get_lang('UplFileOverwritten'),
463 463
                                     false
464 464
                                 );
465 465
                             }
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
                         // Display success message to user
584 584
                         if ($output) {
585 585
                             Display::display_confirmation_message(
586
-                                get_lang('UplUploadSucceeded') . '<br />' . get_lang('UplFileSavedAs') .' '.$documentTitle,
586
+                                get_lang('UplUploadSucceeded').'<br />'.get_lang('UplFileSavedAs').' '.$documentTitle,
587 587
                                 false
588 588
                             );
589 589
                         }
@@ -730,12 +730,12 @@  discard block
 block discarded – undo
730 730
 function dir_total_space($dir_path)
731 731
 {
732 732
     $save_dir = getcwd();
733
-    chdir($dir_path) ;
733
+    chdir($dir_path);
734 734
     $handle = opendir($dir_path);
735 735
     $sumSize = 0;
736 736
     $dirList = array();
737 737
     while ($element = readdir($handle)) {
738
-        if ( $element == '.' || $element == '..') {
738
+        if ($element == '.' || $element == '..') {
739 739
             continue; // Skip the current and parent directories
740 740
         }
741 741
         if (is_file($element)) {
@@ -746,11 +746,11 @@  discard block
 block discarded – undo
746 746
         }
747 747
     }
748 748
 
749
-    closedir($handle) ;
749
+    closedir($handle);
750 750
 
751 751
     if (sizeof($dirList) > 0) {
752 752
         foreach ($dirList as $j) {
753
-            $sizeDir = dir_total_space($j);	// Recursivity
753
+            $sizeDir = dir_total_space($j); // Recursivity
754 754
             $sumSize += $sizeDir;
755 755
         }
756 756
     }
@@ -784,63 +784,63 @@  discard block
 block discarded – undo
784 784
 
785 785
         static $mime_type = array();
786 786
 
787
-        $mime_type[] = 'application/msword';             $extension[] = '.doc';
788
-        $mime_type[] = 'application/rtf';                $extension[] = '.rtf';
789
-        $mime_type[] = 'application/vnd.ms-powerpoint';  $extension[] = '.ppt';
790
-        $mime_type[] = 'application/vnd.ms-excel';       $extension[] = '.xls';
791
-        $mime_type[] = 'application/pdf';                $extension[] = '.pdf';
792
-        $mime_type[] = 'application/postscript';         $extension[] = '.ps';
793
-        $mime_type[] = 'application/mac-binhex40';       $extension[] = '.hqx';
794
-        $mime_type[] = 'application/x-gzip';             $extension[] = 'tar.gz';
795
-        $mime_type[] = 'application/x-shockwave-flash';  $extension[] = '.swf';
796
-        $mime_type[] = 'application/x-stuffit';          $extension[] = '.sit';
797
-        $mime_type[] = 'application/x-tar';              $extension[] = '.tar';
798
-        $mime_type[] = 'application/zip';                $extension[] = '.zip';
799
-        $mime_type[] = 'application/x-tar';              $extension[] = '.tar';
800
-        $mime_type[] = 'text/html';                      $extension[] = '.html';
801
-        $mime_type[] = 'text/plain';                     $extension[] = '.txt';
802
-        $mime_type[] = 'text/rtf';                       $extension[] = '.rtf';
803
-        $mime_type[] = 'img/gif';                        $extension[] = '.gif';
804
-        $mime_type[] = 'img/jpeg';                       $extension[] = '.jpg';
805
-        $mime_type[] = 'img/png';                        $extension[] = '.png';
806
-        $mime_type[] = 'audio/midi';                     $extension[] = '.mid';
807
-        $mime_type[] = 'audio/mpeg';                     $extension[] = '.mp3';
808
-        $mime_type[] = 'audio/x-aiff';                   $extension[] = '.aif';
809
-        $mime_type[] = 'audio/x-pn-realaudio';           $extension[] = '.rm';
810
-        $mime_type[] = 'audio/x-pn-realaudio-plugin';    $extension[] = '.rpm';
811
-        $mime_type[] = 'audio/x-wav';                    $extension[] = '.wav';
812
-        $mime_type[] = 'video/mpeg';                     $extension[] = '.mpg';
813
-        $mime_type[] = 'video/mpeg4-generic';            $extension[] = '.mp4';
814
-        $mime_type[] = 'video/quicktime';                $extension[] = '.mov';
815
-        $mime_type[] = 'video/x-msvideo';                $extension[] = '.avi';
816
-
817
-        $mime_type[] = 'video/x-ms-wmv';                 $extension[] = '.wmv';
818
-        $mime_type[] = 'video/x-flv';                    $extension[] = '.flv';
819
-        $mime_type[] = 'image/svg+xml';                  $extension[] = '.svg';
820
-        $mime_type[] = 'image/svg+xml';                  $extension[] = '.svgz';
821
-        $mime_type[] = 'video/ogg';                  	 $extension[] = '.ogv';
822
-        $mime_type[] = 'audio/ogg';                  	 $extension[] = '.oga';
823
-        $mime_type[] = 'application/ogg';                $extension[] = '.ogg';
824
-        $mime_type[] = 'application/ogg';                $extension[] = '.ogx';
825
-        $mime_type[] = 'application/x-freemind';         $extension[] = '.mm';
826
-
827
-        $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12';							$extension[] = '.docm';
828
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';	$extension[] = '.docx';
829
-        $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12';							$extension[] = '.dotm';
830
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template';	$extension[] = '.dotx';
831
-        $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12';					$extension[] = '.potm';
832
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template';		$extension[] = '.potx';
833
-        $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12';						$extension[] = '.ppam';
834
-        $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12';					$extension[] = '.ppsm';
835
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow';	$extension[] = '.ppsx';
836
-        $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12';				$extension[] = '.pptm';
837
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';	$extension[] = '.pptx';
838
-        $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12';							$extension[] = '.xlam';
839
-        $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12';						$extension[] = '.xlsb';
840
-        $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12';							$extension[] = '.xlsm';
841
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';			$extension[] = '.xlsx';
842
-        $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12';							$extension[] = '.xltm';
843
-        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template';		$extension[] = '.xltx';
787
+        $mime_type[] = 'application/msword'; $extension[] = '.doc';
788
+        $mime_type[] = 'application/rtf'; $extension[] = '.rtf';
789
+        $mime_type[] = 'application/vnd.ms-powerpoint'; $extension[] = '.ppt';
790
+        $mime_type[] = 'application/vnd.ms-excel'; $extension[] = '.xls';
791
+        $mime_type[] = 'application/pdf'; $extension[] = '.pdf';
792
+        $mime_type[] = 'application/postscript'; $extension[] = '.ps';
793
+        $mime_type[] = 'application/mac-binhex40'; $extension[] = '.hqx';
794
+        $mime_type[] = 'application/x-gzip'; $extension[] = 'tar.gz';
795
+        $mime_type[] = 'application/x-shockwave-flash'; $extension[] = '.swf';
796
+        $mime_type[] = 'application/x-stuffit'; $extension[] = '.sit';
797
+        $mime_type[] = 'application/x-tar'; $extension[] = '.tar';
798
+        $mime_type[] = 'application/zip'; $extension[] = '.zip';
799
+        $mime_type[] = 'application/x-tar'; $extension[] = '.tar';
800
+        $mime_type[] = 'text/html'; $extension[] = '.html';
801
+        $mime_type[] = 'text/plain'; $extension[] = '.txt';
802
+        $mime_type[] = 'text/rtf'; $extension[] = '.rtf';
803
+        $mime_type[] = 'img/gif'; $extension[] = '.gif';
804
+        $mime_type[] = 'img/jpeg'; $extension[] = '.jpg';
805
+        $mime_type[] = 'img/png'; $extension[] = '.png';
806
+        $mime_type[] = 'audio/midi'; $extension[] = '.mid';
807
+        $mime_type[] = 'audio/mpeg'; $extension[] = '.mp3';
808
+        $mime_type[] = 'audio/x-aiff'; $extension[] = '.aif';
809
+        $mime_type[] = 'audio/x-pn-realaudio'; $extension[] = '.rm';
810
+        $mime_type[] = 'audio/x-pn-realaudio-plugin'; $extension[] = '.rpm';
811
+        $mime_type[] = 'audio/x-wav'; $extension[] = '.wav';
812
+        $mime_type[] = 'video/mpeg'; $extension[] = '.mpg';
813
+        $mime_type[] = 'video/mpeg4-generic'; $extension[] = '.mp4';
814
+        $mime_type[] = 'video/quicktime'; $extension[] = '.mov';
815
+        $mime_type[] = 'video/x-msvideo'; $extension[] = '.avi';
816
+
817
+        $mime_type[] = 'video/x-ms-wmv'; $extension[] = '.wmv';
818
+        $mime_type[] = 'video/x-flv'; $extension[] = '.flv';
819
+        $mime_type[] = 'image/svg+xml'; $extension[] = '.svg';
820
+        $mime_type[] = 'image/svg+xml'; $extension[] = '.svgz';
821
+        $mime_type[] = 'video/ogg'; $extension[] = '.ogv';
822
+        $mime_type[] = 'audio/ogg'; $extension[] = '.oga';
823
+        $mime_type[] = 'application/ogg'; $extension[] = '.ogg';
824
+        $mime_type[] = 'application/ogg'; $extension[] = '.ogx';
825
+        $mime_type[] = 'application/x-freemind'; $extension[] = '.mm';
826
+
827
+        $mime_type[] = 'application/vnd.ms-word.document.macroEnabled.12'; $extension[] = '.docm';
828
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; $extension[] = '.docx';
829
+        $mime_type[] = 'application/vnd.ms-word.template.macroEnabled.12'; $extension[] = '.dotm';
830
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template'; $extension[] = '.dotx';
831
+        $mime_type[] = 'application/vnd.ms-powerpoint.template.macroEnabled.12'; $extension[] = '.potm';
832
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.template'; $extension[] = '.potx';
833
+        $mime_type[] = 'application/vnd.ms-powerpoint.addin.macroEnabled.12'; $extension[] = '.ppam';
834
+        $mime_type[] = 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12'; $extension[] = '.ppsm';
835
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'; $extension[] = '.ppsx';
836
+        $mime_type[] = 'application/vnd.ms-powerpoint.presentation.macroEnabled.12'; $extension[] = '.pptm';
837
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; $extension[] = '.pptx';
838
+        $mime_type[] = 'application/vnd.ms-excel.addin.macroEnabled.12'; $extension[] = '.xlam';
839
+        $mime_type[] = 'application/vnd.ms-excel.sheet.binary.macroEnabled.12'; $extension[] = '.xlsb';
840
+        $mime_type[] = 'application/vnd.ms-excel.sheet.macroEnabled.12'; $extension[] = '.xlsm';
841
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $extension[] = '.xlsx';
842
+        $mime_type[] = 'application/vnd.ms-excel.template.macroEnabled.12'; $extension[] = '.xltm';
843
+        $mime_type[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'; $extension[] = '.xltx';
844 844
 
845 845
         // Test on PC (files with no extension get application/octet-stream)
846 846
         //$mime_type[] = 'application/octet-stream';      $extension[] = '.ext';
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 
850 850
         foreach ($mime_type as $key => & $type) {
851 851
             if ($type == $file_type) {
852
-                $file_name .=  $extension[$key];
852
+                $file_name .= $extension[$key];
853 853
                 break;
854 854
             }
855 855
         }
@@ -957,12 +957,12 @@  discard block
 block discarded – undo
957 957
         }
958 958
 
959 959
         // It happens on Linux that $upload_path sometimes doesn't start with '/'
960
-        if ($upload_path[0] != '/' && substr($base_work_dir,-1,1) != '/') {
960
+        if ($upload_path[0] != '/' && substr($base_work_dir, -1, 1) != '/') {
961 961
             $upload_path = '/'.$upload_path;
962 962
         }
963 963
 
964 964
         if ($upload_path[strlen($upload_path) - 1] == '/') {
965
-            $upload_path=substr($upload_path, 0, -1);
965
+            $upload_path = substr($upload_path, 0, -1);
966 966
         }
967 967
 
968 968
         /*	Uncompressing phase */
@@ -974,15 +974,15 @@  discard block
 block discarded – undo
974 974
             - add it to the database
975 975
             - parse & change relative html links
976 976
         */
977
-        if (PHP_OS == 'Linux' && ! get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC ***
977
+        if (PHP_OS == 'Linux' && !get_cfg_var('safe_mode') && false) { // *** UGent, changed by OC ***
978 978
             // Shell Method - if this is possible, it gains some speed
979
-            exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." " .$uploaded_file['tmp_name']);
979
+            exec("unzip -d \"".$base_work_dir.$upload_path."/\"".$uploaded_file['name']." ".$uploaded_file['tmp_name']);
980 980
         } else {
981 981
             // PHP method - slower...
982 982
             $save_dir = getcwd();
983 983
             chdir($base_work_dir.$upload_path);
984 984
             $unzippingState = $zip_file->extract();
985
-            for ($j=0; $j < count($unzippingState); $j++) {
985
+            for ($j = 0; $j < count($unzippingState); $j++) {
986 986
                 $state = $unzippingState[$j];
987 987
 
988 988
                 // Fix relative links in html files
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
                         if (is_dir($base_work_dir.$upload_path.'/'.$file)) $filetype = 'folder';
997 997
 
998 998
                         $safe_file = api_replace_dangerous_char($file, 'strict');
999
-                        @rename($base_work_dir.$upload_path.'/'.$file,$base_work_dir.$upload_path.'/'.$safe_file);
1000
-                        set_default_settings($upload_path, $safe_file,$filetype);
999
+                        @rename($base_work_dir.$upload_path.'/'.$file, $base_work_dir.$upload_path.'/'.$safe_file);
1000
+                        set_default_settings($upload_path, $safe_file, $filetype);
1001 1001
                     }
1002 1002
                 }
1003 1003
 
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
     $zip = new PclZip($uploaded_file['tmp_name']);
1048 1048
 
1049 1049
     // Check the zip content (real size and file extension)
1050
-    $zip_content_array = (array)$zip->listContent();
1050
+    $zip_content_array = (array) $zip->listContent();
1051 1051
 
1052 1052
     $realSize = 0;
1053 1053
     foreach ($zip_content_array as & $this_content) {
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 function filter_extension(&$filename)
1144 1144
 {
1145 1145
     if (substr($filename, -1) == '/') {
1146
-        return 1;  // Authorize directories
1146
+        return 1; // Authorize directories
1147 1147
     }
1148 1148
     $blacklist = api_get_setting('upload_extensions_list_type');
1149 1149
     if ($blacklist != 'whitelist') { // if = blacklist
@@ -1369,9 +1369,9 @@  discard block
 block discarded – undo
1369 1369
     $upload_path = str_replace('//', '/', $upload_path);
1370 1370
 
1371 1371
     if ($upload_path == '/') {
1372
-        $upload_path='';
1372
+        $upload_path = '';
1373 1373
     } elseif (!empty($upload_path) && $upload_path[0] != '/') {
1374
-        $upload_path="/$upload_path";
1374
+        $upload_path = "/$upload_path";
1375 1375
     }
1376 1376
 
1377 1377
     $endchar = substr($filename, strlen($filename) - 1, 1);
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
     $img_path_list = array();
1410 1410
 
1411 1411
     if (!$fp = fopen($html_file, 'r')) {
1412
-        return ;
1412
+        return;
1413 1413
     }
1414 1414
 
1415 1415
     // Aearch and store occurences of the <img> tag in an array
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
         $img_tag_list = $matches[0];
1430 1430
     }
1431 1431
 
1432
-    fclose ($fp);
1432
+    fclose($fp);
1433 1433
     unset($buffer);
1434 1434
 
1435 1435
     // Search the image file path from all the <IMG> tag detected
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 
1530 1530
     if (!is_dir($base_work_dir.$systemFolderName)) {
1531 1531
         $result = mkdir(
1532
-            $base_work_dir . $systemFolderName,
1532
+            $base_work_dir.$systemFolderName,
1533 1533
             api_get_permissions_for_new_directories(),
1534 1534
             true
1535 1535
         );
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
                     WHERE
1543 1543
                         c_id = $course_id AND
1544 1544
                         (
1545
-                            path = '" . $systemFolderName . "'
1545
+                            path = '".$systemFolderName."'
1546 1546
                         )
1547 1547
             ";
1548 1548
 
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
 
1696 1696
     // Fix the image tags
1697 1697
 
1698
-    for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb ; $i++) {
1698
+    for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb; $i++) {
1699 1699
         $replace_what = $original_img_path[$i];
1700 1700
         // We only need the directory and the filename /path/to/file_html_files/missing_file.gif -> file_html_files/missing_file.gif
1701 1701
         $exploded_file_path = explode('/', $new_img_path[$i]);
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
         .'</body>'
1737 1737
         .'</html>';
1738 1738
     if (file_exists($file_path)) {
1739
-        if (!($fp = fopen ($file_path, 'w'))) {
1739
+        if (!($fp = fopen($file_path, 'w'))) {
1740 1740
             return false;
1741 1741
         }
1742 1742
         return fwrite($fp, $file_content);
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
     // Open the file
1757 1757
     if (file_exists($full_file_name)) {
1758 1758
         $fp = fopen($full_file_name, 'r');
1759
-        $buffer = fread ($fp, filesize ($full_file_name));
1759
+        $buffer = fread($fp, filesize($full_file_name));
1760 1760
 
1761 1761
         // Parse the contents
1762 1762
         $new_html_content = api_replace_links_in_string($upload_path, $buffer);
@@ -1899,7 +1899,7 @@  discard block
 block discarded – undo
1899 1899
 
1900 1900
         foreach ($tag_list as & $this_tag) {
1901 1901
             //Display::display_normal_message(htmlentities($this_tag)); //debug
1902
-            if ( preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) {
1902
+            if (preg_match("~".$param_name."[\s]*=[\s]*[\"]{1}([^\"]+)[\"]{1}~i", $this_tag, $matches)) {
1903 1903
                 $file_path_list[] = $matches[1]; // older
1904 1904
                 $href_list[] = $matches[0]; // to also add target="_self"
1905 1905
             }
@@ -1920,9 +1920,9 @@  discard block
 block discarded – undo
1920 1920
 
1921 1921
                 // Fix the link to use download.php or showinframes.php
1922 1922
                 if (preg_match("/<a([\s]*[\"\/:'=a-z0-9]*){5}href[^<]*>/i", $tag_list[$count])) {
1923
-                    $replace_by[$count] = " $param_name =\"showinframes.php?file=" . $upload_path.$file_path_list[$count]."\" target=\"_self\" ";
1923
+                    $replace_by[$count] = " $param_name =\"showinframes.php?file=".$upload_path.$file_path_list[$count]."\" target=\"_self\" ";
1924 1924
                 } else {
1925
-                    $replace_by[$count] = " $param_name =\"download.php?doc_url=" . $upload_path.$file_path_list[$count]."\" ";
1925
+                    $replace_by[$count] = " $param_name =\"download.php?doc_url=".$upload_path.$file_path_list[$count]."\" ";
1926 1926
                 }
1927 1927
             } else {
1928 1928
                 // "mailto" or url already fixed, leave as is
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
             }
1932 1932
         } elseif ($is_absolute_hyperlink) {
1933 1933
             //$message .= "Absolute hyperlink, don't change, add target=_self: ";
1934
-            $replace_by[$count] = " $param_name=\"" . $file_path_list[$count] . "\" target =\"_self\"";
1934
+            $replace_by[$count] = " $param_name=\"".$file_path_list[$count]."\" target =\"_self\"";
1935 1935
         } else {
1936 1936
             // Don't change anything
1937 1937
             //$message .= "Local anchor, don't change: ";
@@ -1976,7 +1976,7 @@  discard block
 block discarded – undo
1976 1976
 {
1977 1977
     // Do we need a / or not?
1978 1978
     $added_slash = ($upload_path == '/') ? '' : '/';
1979
-    $folder_id      = DocumentManager::get_document_id(api_get_course_info(), $upload_path);
1979
+    $folder_id = DocumentManager::get_document_id(api_get_course_info(), $upload_path);
1980 1980
     // Build the form
1981 1981
     $form = "<p><strong>".get_lang('MissingImagesDetected')."</strong></p>"
1982 1982
         ."<form method=\"post\" action=\"".api_get_self()."\" enctype=\"multipart/form-data\">"
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Element/DateRangePicker.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -145,6 +145,7 @@
 block discarded – undo
145 145
 
146 146
     /**
147 147
     * @param array $dates result of parseDateRange()
148
+    * @param string $format
148 149
     *
149 150
     * @return bool
150 151
     */
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 class DateRangePicker extends HTML_QuickForm_text
8 8
 {
9 9
     /**
10
-    * Constructor
11
-    */
10
+     * Constructor
11
+     */
12 12
     public function __construct($elementName = null, $elementLabel = null, $attributes = null)
13 13
     {
14 14
         if (!isset($attributes['id'])) {
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
     }
145 145
 
146 146
     /**
147
-    * @param array $dates result of parseDateRange()
148
-    *
149
-    * @return bool
150
-    */
147
+     * @param array $dates result of parseDateRange()
148
+     *
149
+     * @return bool
150
+     */
151 151
     public function validateDates($dates, $format = null)
152 152
     {
153 153
         if (empty($dates['start']) || empty($dates['end'])) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@
 block discarded – undo
88 88
         }
89 89
 
90 90
         $timePicker = 'true';
91
-        $timePickerValue =  $this->getAttribute('timePicker');
91
+        $timePickerValue = $this->getAttribute('timePicker');
92 92
         if (!empty($timePickerValue)) {
93 93
             $timePicker = $timePickerValue;
94 94
         }
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/FormValidator.class.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * @param string $label
214 214
      * @param array $attributes
215 215
      *
216
-     * @return mixed
216
+     * @return HTML_QuickForm_element
217 217
      */
218 218
     public function addDatePicker($name, $label, $attributes = [])
219 219
     {
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      * @param string $label
226 226
      * @param array $attributes
227 227
      *
228
-     * @return mixed
228
+     * @return HTML_QuickForm_element
229 229
      */
230 230
     public function addDateTimePicker($name, $label, $attributes = [])
231 231
     {
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
      * @param array  $options
689 689
      * @param array  $attributes
690 690
      *
691
-     * @return HTML_QuickForm_radio
691
+     * @return HTML_QuickForm_group
692 692
      */
693 693
     public function addRadio($name, $label, $options = array(), $attributes = array())
694 694
     {
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
      * @param string $name
818 818
      * @param string $label
819 819
      *
820
-     * @return mixed
820
+     * @return HTML_QuickForm_element
821 821
      */
822 822
     public function addButtonAdvancedSettings($name, $label = '')
823 823
     {
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
     /**
915 915
      * This function has been created for avoiding changes directly within QuickForm class.
916 916
      * When we use it, the element is threated as 'required' to be dealt during validation.
917
-     * @param array $element					The array of elements
917
+     * @param array $elements					The array of elements
918 918
      * @param string $message					The message displayed
919 919
      */
920 920
     public function add_multiple_required_rule($elements, $message)
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         $renderer->setHeaderTemplate('<legend>{header}</legend>');
100 100
 
101 101
         //Set required field template
102
-        $this->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
102
+        $this->setRequiredNote('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>');
103 103
         $noteTemplate = <<<EOT
104 104
 	<div class="form-group">
105 105
 		<div class="col-sm-offset-2 col-sm-10">{requiredNote}</div>
@@ -851,9 +851,9 @@  discard block
 block discarded – undo
851 851
             $label = get_lang('PleaseStandBy');
852 852
         }
853 853
         $this->with_progress_bar = true;
854
-        $this->updateAttributes("onsubmit=\"javascript: myUpload.start('dynamic_div','".Display::returnIconPath('progress_bar.gif')."','" . $label . "','" . $this->getAttribute('id') . "')\"");
855
-        $this->addElement('html', '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>');
856
-        $this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . (abs(intval($delay)) * 1000) . ');</script>');
854
+        $this->updateAttributes("onsubmit=\"javascript: myUpload.start('dynamic_div','".Display::returnIconPath('progress_bar.gif')."','".$label."','".$this->getAttribute('id')."')\"");
855
+        $this->addElement('html', '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>');
856
+        $this->addElement('html', '<script type="text/javascript">var myUpload = new upload('.(abs(intval($delay)) * 1000).');</script>');
857 857
     }
858 858
 
859 859
     /**
@@ -870,11 +870,11 @@  discard block
 block discarded – undo
870 870
             return;
871 871
         }
872 872
 
873
-        $xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH) . 'upload.xajax.php');
873
+        $xajax_upload = new xajax(api_get_path(WEB_LIBRARY_PATH).'upload.xajax.php');
874 874
 
875 875
         $xajax_upload->registerFunction('updateProgress');
876 876
         // IMPORTANT : must be the first element of the form
877
-        $el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="' . $upload_id . '" />'), $element_after);
877
+        $el = $this->insertElementBefore(FormValidator::createElement('html', '<input type="hidden" name="UPLOAD_IDENTIFIER" value="'.$upload_id.'" />'), $element_after);
878 878
 
879 879
         $this->addElement('html', '<br />');
880 880
 
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
         $this->addElement(
883 883
             'html',
884 884
             '<div id="dynamic_div_container" style="display:none">
885
-                <div id="dynamic_div_label">' . get_lang('UploadFile') . '</div>
885
+                <div id="dynamic_div_label">' . get_lang('UploadFile').'</div>
886 886
                 <div id="dynamic_div_frame" style="width:214px; height:12px; border:1px solid grey; background-image:url(' . Display::returnIconPath('real_upload_frame.gif').');">
887 887
                     <div id="dynamic_div_filled" style="width:0%;height:100%;background-image:url(' . Display::returnIconPath('real_upload_step.gif').');background-repeat:repeat-x;background-position:center;"></div>
888 888
                 </div>
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
             $this->addElement('html', '
894 894
 			<div id="dynamic_div_waiter_container" style="display:none">
895 895
 				<div id="dynamic_div_waiter_label">
896
-					' . get_lang('SlideshowConversion') . '
896
+					' . get_lang('SlideshowConversion').'
897 897
 				</div>
898 898
 				<div id="dynamic_div_waiter_frame">
899 899
 					'.Display::return_icon('real_upload_frame.gif').'
@@ -903,18 +903,18 @@  discard block
 block discarded – undo
903 903
         }
904 904
 
905 905
         // Get the xajax code
906
-        $this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH) . 'xajax'));
906
+        $this->addElement('html', $xajax_upload->getJavascript(api_get_path(WEB_LIBRARY_PATH).'xajax'));
907 907
 
908 908
         // Get the upload code
909
-        $this->addElement('html', '<script language="javascript" src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/upload.js" type="text/javascript"></script>');
910
-        $this->addElement('html', '<script type="text/javascript">var myUpload = new upload(' . (abs(intval($delay)) * 1000) . ');</script>');
909
+        $this->addElement('html', '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/upload.js" type="text/javascript"></script>');
910
+        $this->addElement('html', '<script type="text/javascript">var myUpload = new upload('.(abs(intval($delay)) * 1000).');</script>');
911 911
 
912 912
         if (!$wait_after_upload) {
913 913
             $wait_after_upload = 0;
914 914
         }
915 915
 
916 916
         // Add the upload event
917
-        $this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','" . $upload_id . "','" . $this->getAttribute('id') . "'," . $wait_after_upload . ")\"");
917
+        $this->updateAttributes("onsubmit=\"javascript: myUpload.startRealUpload('dynamic_div','".$upload_id."','".$this->getAttribute('id')."',".$wait_after_upload.")\"");
918 918
     }
919 919
 
920 920
     /**
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Rule/HTML.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,7 @@
 block discarded – undo
25 25
      * Get allowed tags
26 26
      * @param int $mode NO_HTML, STUDENT_HTML, TEACHER_HTML,
27 27
      * STUDENT_HTML_FULLPAGE or TEACHER_HTML_FULLPAGE
28
-     * @param boolean $fullpage If true, the allowed tags for full-page editing
29
-     * are returned.
28
+     * @return string
30 29
      */
31 30
     static function get_allowed_tags($mode)
32 31
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      */
17 17
     function validate($html, $mode = NO_HTML)
18 18
     {
19
-        $allowed_tags = self::get_allowed_tags ($mode, $fullpage);
19
+        $allowed_tags = self::get_allowed_tags($mode, $fullpage);
20 20
         $cleaned_html = kses($html, $allowed_tags);
21 21
         return $html == $cleaned_html;
22 22
     }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         // Include the allowed tags.
34 34
         //include(dirname(__FILE__).'/allowed_tags.inc.php');
35 35
         global $allowed_tags_student, $allowed_tags_student_full_page, $allowed_tags_teacher, $allowed_tags_teacher_full_page;
36
-        switch($mode)
36
+        switch ($mode)
37 37
         {
38 38
             case NO_HTML:
39 39
                 return array();
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Rule/MaxFileSize.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 {
10 10
 	/**
11 11
 	 * @param $value array     Uploaded file info (from $_FILES)
12
-	 * @param null $options
13 12
 	 * @return bool
14 13
 	 */
15 14
 	public function validate($elementValue, $maxSize)
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
  */
8 8
 class HTML_QuickForm_Rule_MaxFileSize extends HTML_QuickForm_Rule
9 9
 {
10
-	/**
11
-	 * @param $value array     Uploaded file info (from $_FILES)
12
-	 * @param null $options
13
-	 * @return bool
14
-	 */
15
-	public function validate($elementValue, $maxSize)
16
-	{
17
-		if (!empty($elementValue['error']) &&
18
-			(UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])
19
-		) {
20
-			return false;
21
-		}
22
-		if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
23
-			return true;
24
-		}
10
+    /**
11
+     * @param $value array     Uploaded file info (from $_FILES)
12
+     * @param null $options
13
+     * @return bool
14
+     */
15
+    public function validate($elementValue, $maxSize)
16
+    {
17
+        if (!empty($elementValue['error']) &&
18
+            (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])
19
+        ) {
20
+            return false;
21
+        }
22
+        if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
23
+            return true;
24
+        }
25 25
 
26
-		return ($maxSize >= @filesize($elementValue['tmp_name']));
27
-	}
26
+        return ($maxSize >= @filesize($elementValue['tmp_name']));
27
+    }
28 28
 }
Please login to merge, or discard this patch.
main/inc/lib/formvalidator/Rule/MobilePhoneNumber.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
      *
17 17
      * @param string Mobile phone number to be validated
18 18
      * @param string Not using it. Just to respect the declaration
19
-     * @return boolean Returns true if valid, false otherwise.
19
+     * @return integer Returns true if valid, false otherwise.
20 20
      */
21 21
     function validate($mobilePhoneNumber, $options = null)
22 22
     {
Please login to merge, or discard this patch.
main/inc/lib/getid3/getid3.php 4 patches
Doc Comments   +22 added lines patch added patch discarded remove patch
@@ -456,6 +456,10 @@  discard block
 block discarded – undo
456 456
 
457 457
 
458 458
     // Add warning(s) to $this->warnings[]
459
+
460
+    /**
461
+     * @param string $message
462
+     */
459 463
     public function warning($message) {
460 464
 
461 465
         if (is_array($message)) {
@@ -482,6 +486,11 @@  discard block
 block discarded – undo
482 486
 
483 487
 
484 488
     // Convert string between charsets -- iconv() wrapper
489
+
490
+    /**
491
+     * @param string $out_charset
492
+     * @param string $string
493
+     */
485 494
     public function iconv($in_charset, $out_charset, $string, $drop01 = false) {
486 495
 
487 496
         if ($drop01 && ($string === "\x00" || $string === "\x01")) {
@@ -509,6 +518,9 @@  discard block
 block discarded – undo
509 518
 
510 519
 
511 520
 
521
+    /**
522
+     * @param string $name
523
+     */
512 524
     public function include_module($name) {
513 525
 
514 526
         if (!file_exists($this->include_path.'module.'.$name.'.php')) {
@@ -1342,6 +1354,10 @@  discard block
 block discarded – undo
1342 1354
 
1343 1355
 
1344 1356
     // Convert Big Endian byte string to int - max 32 bits
1357
+
1358
+    /**
1359
+     * @param string $byte_word
1360
+     */
1345 1361
     public static function BigEndian2Int($byte_word, $signed = false) {
1346 1362
 
1347 1363
         $int_value = 0;
@@ -1391,6 +1407,9 @@  discard block
 block discarded – undo
1391 1407
 
1392 1408
 
1393 1409
 
1410
+    /**
1411
+     * @param string $byte_word
1412
+     */
1394 1413
     public static function BigEndian2Float($byte_word) {
1395 1414
 
1396 1415
 		// ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
@@ -1478,6 +1497,9 @@  discard block
 block discarded – undo
1478 1497
 
1479 1498
 
1480 1499
 
1500
+	/**
1501
+	 * @param string $binary_numerator
1502
+	 */
1481 1503
 	public static function DecimalBinary2Float($binary_numerator) {
1482 1504
 		$numerator   = bindec($binary_numerator);
1483 1505
 		$denominator = bindec('1'.str_repeat('0', strlen($binary_numerator)));
Please login to merge, or discard this patch.
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         $class = new $class_name($this);
301 301
 
302 302
         try {
303
-             $this->option_analyze and $class->Analyze();
303
+                $this->option_analyze and $class->Analyze();
304 304
             }
305 305
         catch (getid3_exception $e) {
306 306
             throw $e;
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             // CalculateReplayGain() {
384 384
             if (@$this->info['replay_gain']) {
385 385
                 if (!@$this->info['replay_gain']['reference_volume']) {
386
-                     $this->info['replay_gain']['reference_volume'] = 89;
386
+                        $this->info['replay_gain']['reference_volume'] = 89;
387 387
                 }
388 388
                 if (isset($this->info['replay_gain']['track']['adjustment'])) {
389 389
                     $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 
404 404
             // ProcessAudioStreams() {
405 405
             if (@!$this->info['audio']['streams'] && (@$this->info['audio']['bitrate'] || @$this->info['audio']['channels'] || @$this->info['audio']['sample_rate'])) {
406
-                  foreach ($this->info['audio'] as $key => $value) {
406
+                    foreach ($this->info['audio'] as $key => $value) {
407 407
                     if ($key != 'streams') {
408 408
                         $this->info['audio']['streams'][0][$key] = $value;
409 409
                     }
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
                             'group'     => 'audio',
545 545
                             'module'    => 'ac3',
546 546
                             'mime_type' => 'audio/ac3',
547
-                          ),
547
+                            ),
548 548
 
549 549
                 // AAC  - audio       - Advanced Audio Coding (AAC) - ADIF format
550 550
                 'adif' => array (
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
                             'module'    => 'aac_adif',
554 554
                             'mime_type' => 'application/octet-stream',
555 555
                             'fail_ape'  => 'WARNING',
556
-                          ),
556
+                            ),
557 557
 
558 558
 
559 559
                 // AAC  - audio       - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
                             'module'    => 'aac_adts',
564 564
                             'mime_type' => 'application/octet-stream',
565 565
                             'fail_ape'  => 'WARNING',
566
-                          ),
566
+                            ),
567 567
 
568 568
 
569 569
                 // AU   - audio       - NeXT/Sun AUdio (AU)
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
                             'group'     => 'audio',
573 573
                             'module'    => 'au',
574 574
                             'mime_type' => 'audio/basic',
575
-                          ),
575
+                            ),
576 576
 
577 577
                 // AVR  - audio       - Audio Visual Research
578 578
                 'avr'  => array (
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
                             'group'     => 'audio',
581 581
                             'module'    => 'avr',
582 582
                             'mime_type' => 'application/octet-stream',
583
-                          ),
583
+                            ),
584 584
 
585 585
                 // BONK - audio       - Bonk v0.9+
586 586
                 'bonk' => array (
@@ -588,15 +588,15 @@  discard block
 block discarded – undo
588 588
                             'group'     => 'audio',
589 589
                             'module'    => 'bonk',
590 590
                             'mime_type' => 'audio/xmms-bonk',
591
-                          ),
591
+                            ),
592 592
 
593 593
                 // DTS  - audio       - Dolby Theatre System
594
-				'dts'  => array(
595
-							'pattern'   => '^\x7F\xFE\x80\x01',
596
-							'group'     => 'audio',
597
-							'module'    => 'dts',
598
-							'mime_type' => 'audio/dts',
599
-						),
594
+                'dts'  => array(
595
+                            'pattern'   => '^\x7F\xFE\x80\x01',
596
+                            'group'     => 'audio',
597
+                            'module'    => 'dts',
598
+                            'mime_type' => 'audio/dts',
599
+                        ),
600 600
 
601 601
                 // FLAC - audio       - Free Lossless Audio Codec
602 602
                 'flac' => array (
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
                             'group'     => 'audio',
605 605
                             'module'    => 'xiph',
606 606
                             'mime_type' => 'audio/x-flac',
607
-                          ),
607
+                            ),
608 608
 
609 609
                 // LA   - audio       - Lossless Audio (LA)
610 610
                 'la'   => array (
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
                             'group'     => 'audio',
613 613
                             'module'    => 'la',
614 614
                             'mime_type' => 'application/octet-stream',
615
-                          ),
615
+                            ),
616 616
 
617 617
                 // LPAC - audio       - Lossless Predictive Audio Compression (LPAC)
618 618
                 'lpac' => array (
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
                             'group'     => 'audio',
621 621
                             'module'    => 'lpac',
622 622
                             'mime_type' => 'application/octet-stream',
623
-                          ),
623
+                            ),
624 624
 
625 625
                 // MIDI - audio       - MIDI (Musical Instrument Digital Interface)
626 626
                 'midi' => array (
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
                             'group'     => 'audio',
629 629
                             'module'    => 'midi',
630 630
                             'mime_type' => 'audio/midi',
631
-                          ),
631
+                            ),
632 632
 
633 633
                 // MAC  - audio       - Monkey's Audio Compressor
634 634
                 'mac'  => array (
@@ -636,31 +636,31 @@  discard block
 block discarded – undo
636 636
                             'group'     => 'audio',
637 637
                             'module'    => 'monkey',
638 638
                             'mime_type' => 'application/octet-stream',
639
-                          ),
639
+                            ),
640 640
 
641 641
                 // MOD  - audio       - MODule (assorted sub-formats)
642 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 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 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 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 666
                 'mpc'  => array (
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
                             'group'     => 'audio',
669 669
                             'module'    => 'mpc',
670 670
                             'mime_type' => 'audio/x-musepack',
671
-                          ),
671
+                            ),
672 672
 
673 673
                 // MPC  - audio       - Musepack / MPEGplus SV4-6
674 674
                 'mpc_old' => array (
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
                             'group'     => 'audio',
677 677
                             'module'    => 'mpc_old',
678 678
                             'mime_type' => 'application/octet-stream',
679
-                          ),
679
+                            ),
680 680
 
681 681
 
682 682
                 // MP3  - audio       - MPEG-audio Layer 3 (very similar to AAC-ADTS)
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
                             'group'     => 'audio',
686 686
                             'module'    => 'mp3',
687 687
                             'mime_type' => 'audio/mpeg',
688
-                          ),
688
+                            ),
689 689
 
690 690
                 // OFR  - audio       - OptimFROG
691 691
                 'ofr'  => array (
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
                             'group'     => 'audio',
694 694
                             'module'    => 'optimfrog',
695 695
                             'mime_type' => 'application/octet-stream',
696
-                          ),
696
+                            ),
697 697
 
698 698
                 // RKAU - audio       - RKive AUdio compressor
699 699
                 'rkau' => array (
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
                             'group'     => 'audio',
702 702
                             'module'    => 'rkau',
703 703
                             'mime_type' => 'application/octet-stream',
704
-                          ),
704
+                            ),
705 705
 
706 706
                 // SHN  - audio       - Shorten
707 707
                 'shn'  => array (
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
                             'mime_type' => 'audio/xmms-shn',
712 712
                             'fail_id3'  => 'ERROR',
713 713
                             'fail_ape'  => 'ERROR',
714
-                          ),
714
+                            ),
715 715
 
716 716
                 // TTA  - audio       - TTA Lossless Audio Compressor (http://tta.corecodec.org)
717 717
                 'tta'  => array (
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
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 725
                 'voc'  => array (
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
                             'group'     => 'audio',
728 728
                             'module'    => 'voc',
729 729
                             'mime_type' => 'audio/voc',
730
-                          ),
730
+                            ),
731 731
 
732 732
                 // VQF  - audio       - transform-domain weighted interleave Vector Quantization Format (VQF)
733 733
                 'vqf'  => array (
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
                             'group'     => 'audio',
736 736
                             'module'    => 'vqf',
737 737
                             'mime_type' => 'application/octet-stream',
738
-                          ),
738
+                            ),
739 739
 
740 740
                 // WV  - audio        - WavPack (v4.0+)
741 741
                 'vw'  => array(
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
                             'group'     => 'audio',
744 744
                             'module'    => 'wavpack',
745 745
                             'mime_type' => 'application/octet-stream',
746
-                          ),
746
+                            ),
747 747
 
748 748
 
749 749
                 // Audio-Video formats
@@ -754,13 +754,13 @@  discard block
 block discarded – undo
754 754
                             'group'     => 'audio-video',
755 755
                             'module'    => 'asf',
756 756
                             'mime_type' => 'video/x-ms-asf',
757
-                          ),
757
+                            ),
758 758
 
759 759
                 // BINK  - audio/video - Bink / Smacker
760 760
                 'bink' => array(
761 761
                             'pattern'   => '^(BIK|SMK)',
762 762
                             'mime_type' => 'application/octet-stream',
763
-                          ),
763
+                            ),
764 764
 
765 765
                 // FLV  - audio/video - FLash Video
766 766
                 'flv' => array(
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
                             'group'     => 'audio-video',
769 769
                             'module'    => 'flv',
770 770
                             'mime_type' => 'video/x-flv',
771
-                          ),
771
+                            ),
772 772
 
773 773
                 // MKAV - audio/video - Mastroka
774 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 780
                 'mpeg' => array (
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
                             'group'     => 'audio-video',
783 783
                             'module'    => 'mpeg',
784 784
                             'mime_type' => 'video/mpeg',
785
-                          ),
785
+                            ),
786 786
 
787 787
                 // NSV  - audio/video - Nullsoft Streaming Video (NSV)
788 788
                 'nsv'  => array (
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
                             'group'     => 'audio-video',
791 791
                             'module'    => 'nsv',
792 792
                             'mime_type' => 'application/octet-stream',
793
-                          ),
793
+                            ),
794 794
 
795 795
                 // Ogg  - audio/video - Ogg (Ogg Vorbis, OggFLAC, Speex, Ogg Theora(*), Ogg Tarkin(*))
796 796
                 'ogg'  => array (
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
                             'mime_type' => 'application/ogg',
801 801
                             'fail_id3'  => 'WARNING',
802 802
                             'fail_ape'  => 'WARNING',
803
-                          ),
803
+                            ),
804 804
 
805 805
                 // QT   - audio/video - Quicktime
806 806
                 'quicktime' => array (
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
                             'group'     => 'audio-video',
809 809
                             'module'    => 'quicktime',
810 810
                             'mime_type' => 'video/quicktime',
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 814
                 'riff' => array (
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
                             'module'    => 'riff',
818 818
                             'mime_type' => 'audio/x-wave',
819 819
                             'fail_ape'  => 'WARNING',
820
-                          ),
820
+                            ),
821 821
 
822 822
                 // Real - audio/video - RealAudio, RealVideo
823 823
                 'real' => array (
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
                             'group'     => 'audio-video',
826 826
                             'module'    => 'real',
827 827
                             'mime_type' => 'audio/x-realaudio',
828
-                          ),
828
+                            ),
829 829
 
830 830
                 // SWF - audio/video - ShockWave Flash
831 831
                 'swf' => array (
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
                             'group'     => 'audio-video',
834 834
                             'module'    => 'swf',
835 835
                             'mime_type' => 'application/x-shockwave-flash',
836
-                          ),
836
+                            ),
837 837
 
838 838
 
839 839
                 // Still-Image formats
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
                             'mime_type' => 'image/bmp',
847 847
                             'fail_id3'  => 'ERROR',
848 848
                             'fail_ape'  => 'ERROR',
849
-                          ),
849
+                            ),
850 850
 
851 851
                 // GIF  - still image - Graphics Interchange Format
852 852
                 'gif'  => array (
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
                             'mime_type' => 'image/gif',
857 857
                             'fail_id3'  => 'ERROR',
858 858
                             'fail_ape'  => 'ERROR',
859
-                          ),
859
+                            ),
860 860
 
861 861
                 // JPEG - still image - Joint Photographic Experts Group (JPEG)
862 862
                 'jpeg'  => array (
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
                             'mime_type' => 'image/jpeg',
867 867
                             'fail_id3'  => 'ERROR',
868 868
                             'fail_ape'  => 'ERROR',
869
-                          ),
869
+                            ),
870 870
 
871 871
                 // PCD  - still image - Kodak Photo CD
872 872
                 'pcd'  => array (
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
                             'mime_type' => 'image/x-photo-cd',
877 877
                             'fail_id3'  => 'ERROR',
878 878
                             'fail_ape'  => 'ERROR',
879
-                          ),
879
+                            ),
880 880
 
881 881
 
882 882
                 // PNG  - still image - Portable Network Graphics (PNG)
@@ -887,16 +887,16 @@  discard block
 block discarded – undo
887 887
                             'mime_type' => 'image/png',
888 888
                             'fail_id3'  => 'ERROR',
889 889
                             'fail_ape'  => 'ERROR',
890
-                          ),
890
+                            ),
891 891
 
892 892
 
893 893
                 // SVG  - still image - Scalable Vector Graphics (SVG)
894
-				'svg'  => array(
895
-							'pattern'   => '<!DOCTYPE svg PUBLIC ',
896
-							'mime_type' => 'image/svg+xml',
897
-							'fail_id3'  => 'ERROR',
898
-							'fail_ape'  => 'ERROR',
899
-						),
894
+                'svg'  => array(
895
+                            'pattern'   => '<!DOCTYPE svg PUBLIC ',
896
+                            'mime_type' => 'image/svg+xml',
897
+                            'fail_id3'  => 'ERROR',
898
+                            'fail_ape'  => 'ERROR',
899
+                        ),
900 900
 
901 901
 
902 902
                 // TIFF  - still image - Tagged Information File Format (TIFF)
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
                             'mime_type' => 'image/tiff',
908 908
                             'fail_id3'  => 'ERROR',
909 909
                             'fail_ape'  => 'ERROR',
910
-                          ),
910
+                            ),
911 911
 
912 912
 
913 913
                 // Data formats
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
                             'mime_type' => 'application/octet-stream',
918 918
                             'fail_id3'  => 'ERROR',
919 919
                             'fail_ape'  => 'ERROR',
920
-                          ),
920
+                            ),
921 921
 
922 922
                 // ISO  - data        - International Standards Organization (ISO) CD-ROM Image
923 923
                 'iso'  => array (
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
                             'mime_type' => 'application/octet-stream',
928 928
                             'fail_id3'  => 'ERROR',
929 929
                             'fail_ape'  => 'ERROR',
930
-                          ),
930
+                            ),
931 931
 
932 932
                 // RAR  - data        - RAR compressed data
933 933
                 'rar'  => array(
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
                             'mime_type' => 'application/octet-stream',
936 936
                             'fail_id3'  => 'ERROR',
937 937
                             'fail_ape'  => 'ERROR',
938
-                          ),
938
+                            ),
939 939
 
940 940
                 // SZIP - audio       - SZIP compressed data
941 941
                 'szip' => array (
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
                             'mime_type' => 'application/octet-stream',
946 946
                             'fail_id3'  => 'ERROR',
947 947
                             'fail_ape'  => 'ERROR',
948
-                          ),
948
+                            ),
949 949
 
950 950
                 // TAR  - data        - TAR compressed data
951 951
                 'tar'  => array(
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
                             'mime_type' => 'application/x-tar',
956 956
                             'fail_id3'  => 'ERROR',
957 957
                             'fail_ape'  => 'ERROR',
958
-                          ),
958
+                            ),
959 959
 
960 960
                 // GZIP  - data        - GZIP compressed data
961 961
                 'gz'  => array(
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
                             'mime_type' => 'application/x-gzip',
966 966
                             'fail_id3'  => 'ERROR',
967 967
                             'fail_ape'  => 'ERROR',
968
-                          ),
968
+                            ),
969 969
 
970 970
 
971 971
                 // ZIP  - data        - ZIP compressed data
@@ -976,33 +976,33 @@  discard block
 block discarded – undo
976 976
                             'mime_type' => 'application/zip',
977 977
                             'fail_id3'  => 'ERROR',
978 978
                             'fail_ape'  => 'ERROR',
979
-                          ),
979
+                            ),
980 980
 
981 981
 
982 982
                 // PAR2 - data        - Parity Volume Set Specification 2.0
983 983
                 'par2' => array (
984
-                			'pattern'   => '^PAR2\x00PKT',
985
-							'mime_type' => 'application/octet-stream',
986
-							'fail_id3'  => 'ERROR',
987
-							'fail_ape'  => 'ERROR',
988
-						),
984
+                            'pattern'   => '^PAR2\x00PKT',
985
+                            'mime_type' => 'application/octet-stream',
986
+                            'fail_id3'  => 'ERROR',
987
+                            'fail_ape'  => 'ERROR',
988
+                        ),
989 989
 
990 990
 
991
-                 // PDF  - data       - Portable Document Format
992
-                 'pdf' => array(
991
+                    // PDF  - data       - Portable Document Format
992
+                    'pdf' => array(
993 993
                             'pattern'   => '^\x25PDF',
994 994
                             'mime_type' => 'application/pdf',
995 995
                             'fail_id3'  => 'ERROR',
996 996
                             'fail_ape'  => 'ERROR',
997
-                           ),
997
+                            ),
998 998
 
999
-                 // DOC  - data       - Microsoft Word
1000
-                 'msoffice' => array(
999
+                    // DOC  - data       - Microsoft Word
1000
+                    'msoffice' => array(
1001 1001
                             'pattern'   => '^\xD0\xCF\x11\xE0', // D0CF11E == DOCFILE == Microsoft Office Document
1002 1002
                             'mime_type' => 'application/octet-stream',
1003 1003
                             'fail_id3'  => 'ERROR',
1004 1004
                             'fail_ape'  => 'ERROR',
1005
-                          ),
1005
+                            ),
1006 1006
             );
1007 1007
 
1008 1008
         return $format_info;
@@ -1393,99 +1393,99 @@  discard block
 block discarded – undo
1393 1393
 
1394 1394
     public static function BigEndian2Float($byte_word) {
1395 1395
 
1396
-		// ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
1397
-		// http://www.psc.edu/general/software/packages/ieee/ieee.html
1398
-		// http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
1396
+        // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
1397
+        // http://www.psc.edu/general/software/packages/ieee/ieee.html
1398
+        // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
1399 1399
 
1400
-		$bit_word = getid3_lib::BigEndian2Bin($byte_word);
1401
-		if (!$bit_word) {
1400
+        $bit_word = getid3_lib::BigEndian2Bin($byte_word);
1401
+        if (!$bit_word) {
1402 1402
             return 0;
1403 1403
         }
1404
-		$sign_bit = $bit_word{0};
1405
-
1406
-		switch (strlen($byte_word) * 8) {
1407
-			case 32:
1408
-				$exponent_bits = 8;
1409
-				$fraction_bits = 23;
1410
-				break;
1411
-
1412
-			case 64:
1413
-				$exponent_bits = 11;
1414
-				$fraction_bits = 52;
1415
-				break;
1416
-
1417
-			case 80:
1418
-				// 80-bit Apple SANE format
1419
-				// http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
1420
-				$exponent_string = substr($bit_word, 1, 15);
1421
-				$is_normalized = intval($bit_word{16});
1422
-				$fraction_string = substr($bit_word, 17, 63);
1423
-				$exponent = pow(2, getid3_lib::Bin2Dec($exponent_string) - 16383);
1424
-				$fraction = $is_normalized + getid3_lib::DecimalBinary2Float($fraction_string);
1425
-				$float_value = $exponent * $fraction;
1426
-				if ($sign_bit == '1') {
1427
-					$float_value *= -1;
1428
-				}
1429
-				return $float_value;
1430
-				break;
1431
-
1432
-			default:
1433
-				return false;
1434
-				break;
1435
-		}
1436
-		$exponent_string = substr($bit_word, 1, $exponent_bits);
1437
-		$fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits);
1438
-		$exponent = bindec($exponent_string);
1439
-		$fraction = bindec($fraction_string);
1440
-
1441
-		if (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction != 0)) {
1442
-			// Not a Number
1443
-			$float_value = false;
1444
-		} elseif (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction == 0)) {
1445
-			if ($sign_bit == '1') {
1446
-				$float_value = '-infinity';
1447
-			} else {
1448
-				$float_value = '+infinity';
1449
-			}
1450
-		} elseif (($exponent == 0) && ($fraction == 0)) {
1451
-			if ($sign_bit == '1') {
1452
-				$float_value = -0;
1453
-			} else {
1454
-				$float_value = 0;
1455
-			}
1456
-			$float_value = ($sign_bit ? 0 : -0);
1457
-		} elseif (($exponent == 0) && ($fraction != 0)) {
1458
-			// These are 'unnormalized' values
1459
-			$float_value = pow(2, (-1 * (pow(2, $exponent_bits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fraction_string);
1460
-			if ($sign_bit == '1') {
1461
-				$float_value *= -1;
1462
-			}
1463
-		} elseif ($exponent != 0) {
1464
-			$float_value = pow(2, ($exponent - (pow(2, $exponent_bits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fraction_string));
1465
-			if ($sign_bit == '1') {
1466
-				$float_value *= -1;
1467
-			}
1468
-		}
1469
-		return (float) $float_value;
1470
-	}
1471
-
1472
-
1473
-
1474
-	public static function LittleEndian2Float($byte_word) {
1475
-
1476
-		return getid3_lib::BigEndian2Float(strrev($byte_word));
1477
-	}
1478
-
1479
-
1480
-
1481
-	public static function DecimalBinary2Float($binary_numerator) {
1482
-		$numerator   = bindec($binary_numerator);
1483
-		$denominator = bindec('1'.str_repeat('0', strlen($binary_numerator)));
1484
-		return ($numerator / $denominator);
1485
-	}
1486
-
1487
-
1488
-	public static function PrintHexBytes($string, $hex=true, $spaces=true, $html_safe=true) {
1404
+        $sign_bit = $bit_word{0};
1405
+
1406
+        switch (strlen($byte_word) * 8) {
1407
+            case 32:
1408
+                $exponent_bits = 8;
1409
+                $fraction_bits = 23;
1410
+                break;
1411
+
1412
+            case 64:
1413
+                $exponent_bits = 11;
1414
+                $fraction_bits = 52;
1415
+                break;
1416
+
1417
+            case 80:
1418
+                // 80-bit Apple SANE format
1419
+                // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
1420
+                $exponent_string = substr($bit_word, 1, 15);
1421
+                $is_normalized = intval($bit_word{16});
1422
+                $fraction_string = substr($bit_word, 17, 63);
1423
+                $exponent = pow(2, getid3_lib::Bin2Dec($exponent_string) - 16383);
1424
+                $fraction = $is_normalized + getid3_lib::DecimalBinary2Float($fraction_string);
1425
+                $float_value = $exponent * $fraction;
1426
+                if ($sign_bit == '1') {
1427
+                    $float_value *= -1;
1428
+                }
1429
+                return $float_value;
1430
+                break;
1431
+
1432
+            default:
1433
+                return false;
1434
+                break;
1435
+        }
1436
+        $exponent_string = substr($bit_word, 1, $exponent_bits);
1437
+        $fraction_string = substr($bit_word, $exponent_bits + 1, $fraction_bits);
1438
+        $exponent = bindec($exponent_string);
1439
+        $fraction = bindec($fraction_string);
1440
+
1441
+        if (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction != 0)) {
1442
+            // Not a Number
1443
+            $float_value = false;
1444
+        } elseif (($exponent == (pow(2, $exponent_bits) - 1)) && ($fraction == 0)) {
1445
+            if ($sign_bit == '1') {
1446
+                $float_value = '-infinity';
1447
+            } else {
1448
+                $float_value = '+infinity';
1449
+            }
1450
+        } elseif (($exponent == 0) && ($fraction == 0)) {
1451
+            if ($sign_bit == '1') {
1452
+                $float_value = -0;
1453
+            } else {
1454
+                $float_value = 0;
1455
+            }
1456
+            $float_value = ($sign_bit ? 0 : -0);
1457
+        } elseif (($exponent == 0) && ($fraction != 0)) {
1458
+            // These are 'unnormalized' values
1459
+            $float_value = pow(2, (-1 * (pow(2, $exponent_bits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fraction_string);
1460
+            if ($sign_bit == '1') {
1461
+                $float_value *= -1;
1462
+            }
1463
+        } elseif ($exponent != 0) {
1464
+            $float_value = pow(2, ($exponent - (pow(2, $exponent_bits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fraction_string));
1465
+            if ($sign_bit == '1') {
1466
+                $float_value *= -1;
1467
+            }
1468
+        }
1469
+        return (float) $float_value;
1470
+    }
1471
+
1472
+
1473
+
1474
+    public static function LittleEndian2Float($byte_word) {
1475
+
1476
+        return getid3_lib::BigEndian2Float(strrev($byte_word));
1477
+    }
1478
+
1479
+
1480
+
1481
+    public static function DecimalBinary2Float($binary_numerator) {
1482
+        $numerator   = bindec($binary_numerator);
1483
+        $denominator = bindec('1'.str_repeat('0', strlen($binary_numerator)));
1484
+        return ($numerator / $denominator);
1485
+    }
1486
+
1487
+
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++) {
Please login to merge, or discard this 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.
Braces   +8 added lines, -17 removed lines patch added patch discarded remove patch
@@ -198,8 +198,7 @@  discard block
 block discarded – undo
198 198
                     $tag_class = 'getid3_' . $tag_name;
199 199
                     $tag = new $tag_class($this);
200 200
                     $tag->Analyze();
201
-                }
202
-                catch (getid3_exception $e) {
201
+                } catch (getid3_exception $e) {
203 202
                     throw $e;
204 203
                 }
205 204
             }
@@ -243,9 +242,7 @@  discard block
 block discarded – undo
243 242
             // use assume format on these if format detection failed
244 243
             if (preg_match('/\.mp[123a]$/i', $filename)) {
245 244
                 $determined_format = $file_format_array['mp3'];
246
-            }
247
-
248
-            else {
245
+            } else {
249 246
                 fclose($this->fp);
250 247
                 throw new getid3_exception('Unable to determine file format');
251 248
             }
@@ -259,8 +256,7 @@  discard block
 block discarded – undo
259 256
             if ($determined_format['fail_id3'] === 'ERROR') {
260 257
                 fclose($this->fp);
261 258
                 throw new getid3_exception('ID3 tags not allowed on this file type.');
262
-            }
263
-            elseif ($determined_format['fail_id3'] === 'WARNING') {
259
+            } elseif ($determined_format['fail_id3'] === 'WARNING') {
264 260
                 @$this->info['id3v1'] and $this->warning('ID3v1 tags not allowed on this file type.');
265 261
                 @$this->info['id3v2'] and $this->warning('ID3v2 tags not allowed on this file type.');
266 262
             }
@@ -301,11 +297,9 @@  discard block
 block discarded – undo
301 297
 
302 298
         try {
303 299
              $this->option_analyze and $class->Analyze();
304
-            }
305
-        catch (getid3_exception $e) {
300
+            } catch (getid3_exception $e) {
306 301
             throw $e;
307
-        }
308
-        catch (Exception $e) {
302
+        } catch (Exception $e) {
309 303
             throw new getid3_exception('Corrupt file.');
310 304
         }
311 305
 
@@ -460,8 +454,7 @@  discard block
 block discarded – undo
460 454
 
461 455
         if (is_array($message)) {
462 456
             $this->warnings = array_merge($this->warnings, $message);
463
-        }
464
-        else {
457
+        } else {
465 458
             $this->warnings[] = $message;
466 459
         }
467 460
     }
@@ -1101,8 +1094,7 @@  discard block
 block discarded – undo
1101 1094
                             if (empty($this->info['comments'][$tag_name])) {
1102 1095
 
1103 1096
                                 // fall through and append value
1104
-                            }
1105
-                            elseif ($tag_type == 'id3v1') {
1097
+                            } elseif ($tag_type == 'id3v1') {
1106 1098
 
1107 1099
                                 $new_value_length = strlen(trim($value));
1108 1100
                                 foreach ($this->info['comments'][$tag_name] as $existing_key => $existing_value) {
@@ -1112,8 +1104,7 @@  discard block
 block discarded – undo
1112 1104
                                         break 2;
1113 1105
                                     }
1114 1106
                                 }
1115
-                            }
1116
-                            else {
1107
+                            } else {
1117 1108
 
1118 1109
                                 $new_value_length = strlen(trim($value));
1119 1110
                                 foreach ($this->info['comments'][$tag_name] as $existing_key => $existing_value) {
Please login to merge, or discard this patch.
main/inc/lib/getid3/module.audio-video.flv.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -276,6 +276,9 @@  discard block
 block discarded – undo
276 276
 	public $pos;
277 277
 
278 278
 
279
+	/**
280
+	 * @param string $bytes
281
+	 */
279 282
 	public function AMFStream($bytes) {
280 283
 
281 284
 		$this->bytes = $bytes;
@@ -389,6 +392,9 @@  discard block
 block discarded – undo
389 392
 {
390 393
 	public $stream;
391 394
 
395
+	/**
396
+	 * @param AMFStream $stream
397
+	 */
392 398
 	public function __construct($stream) {
393 399
 
394 400
 		$this->stream = $stream;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
  */
48 48
 class getid3_flv extends getid3_handler {
49 49
 
50
-    const TAG_AUDIO    =  8;
51
-    const TAG_VIDEO    =  9;
50
+    const TAG_AUDIO    = 8;
51
+    const TAG_VIDEO    = 9;
52 52
     const TAG_META     = 18;
53 53
 
54 54
     const VIDEO_H263   = 2;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	{
61 61
 	    $info = &$this->getid3->info;
62 62
 
63
-	    $info['flv'] = array ();
63
+	    $info['flv'] = array();
64 64
 	    $info_flv = &$info['flv'];
65 65
 
66 66
 		fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		$flv_header = fread($this->getid3->fp, 5);
70 70
 
71 71
 		$info['fileformat'] = 'flv';
72
-		$info_flv['header']['signature'] =                           substr($flv_header, 0, 3);
72
+		$info_flv['header']['signature'] = substr($flv_header, 0, 3);
73 73
 		$info_flv['header']['version']   = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1));
74 74
 		$type_flags                      = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1));
75 75
 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 
88 88
 			$this_tag_header = fread($this->getid3->fp, 16);
89 89
 
90
-			$previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header,  0, 4));
91
-			$tag_type            = getid3_lib::BigEndian2Int(substr($this_tag_header,  4, 1));
92
-			$data_length         = getid3_lib::BigEndian2Int(substr($this_tag_header,  5, 3));
93
-			$timestamp           = getid3_lib::BigEndian2Int(substr($this_tag_header,  8, 3));
90
+			$previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header, 0, 4));
91
+			$tag_type            = getid3_lib::BigEndian2Int(substr($this_tag_header, 4, 1));
92
+			$data_length         = getid3_lib::BigEndian2Int(substr($this_tag_header, 5, 3));
93
+			$timestamp           = getid3_lib::BigEndian2Int(substr($this_tag_header, 8, 3));
94 94
 			$last_header_byte    = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1));
95 95
 			$next_offset         = ftell($this->getid3->fp) - 1 + $data_length;
96 96
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 				case getid3_flv::TAG_AUDIO:
100 100
 					if (!isset($info_flv['audio']['audioFormat'])) {
101
-						$info_flv['audio']['audioFormat']     =  $last_header_byte & 0x07;
101
+						$info_flv['audio']['audioFormat']     = $last_header_byte & 0x07;
102 102
 						$info_flv['audio']['audioRate']       = ($last_header_byte & 0x30) / 0x10;
103 103
 						$info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40;
104 104
 						$info_flv['audio']['audioType']       = ($last_header_byte & 0x80) / 0x80;
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 
402 402
 		$type = $this->stream->readByte();
403 403
 
404
-		switch($type) {
404
+		switch ($type) {
405 405
 			// Double
406 406
 			case 0:
407 407
 				$value = $this->readDouble();
Please login to merge, or discard this patch.
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -56,522 +56,522 @@
 block discarded – undo
56 56
     const VIDEO_VP6    = 4;
57 57
 
58 58
 
59
-	public function Analyze()
60
-	{
61
-	    $info = &$this->getid3->info;
62
-
63
-	    $info['flv'] = array ();
64
-	    $info_flv = &$info['flv'];
65
-
66
-		fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
67
-
68
-		$flv_data_length = $info['avdataend'] - $info['avdataoffset'];
69
-		$flv_header = fread($this->getid3->fp, 5);
70
-
71
-		$info['fileformat'] = 'flv';
72
-		$info_flv['header']['signature'] =                           substr($flv_header, 0, 3);
73
-		$info_flv['header']['version']   = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1));
74
-		$type_flags                      = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1));
75
-
76
-		$info_flv['header']['hasAudio'] = (bool) ($type_flags & 0x04);
77
-		$info_flv['header']['hasVideo'] = (bool) ($type_flags & 0x01);
78
-
79
-		$frame_size_data_length = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4));
80
-		$flv_header_frame_length = 9;
81
-		if ($frame_size_data_length > $flv_header_frame_length) {
82
-			fseek($this->getid3->fp, $frame_size_data_length - $flv_header_frame_length, SEEK_CUR);
83
-		}
84
-
85
-		$duration = 0;
86
-		while ((ftell($this->getid3->fp) + 1) < $info['avdataend']) {
87
-
88
-			$this_tag_header = fread($this->getid3->fp, 16);
89
-
90
-			$previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header,  0, 4));
91
-			$tag_type            = getid3_lib::BigEndian2Int(substr($this_tag_header,  4, 1));
92
-			$data_length         = getid3_lib::BigEndian2Int(substr($this_tag_header,  5, 3));
93
-			$timestamp           = getid3_lib::BigEndian2Int(substr($this_tag_header,  8, 3));
94
-			$last_header_byte    = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1));
95
-			$next_offset         = ftell($this->getid3->fp) - 1 + $data_length;
96
-
97
-			switch ($tag_type) {
98
-
99
-				case getid3_flv::TAG_AUDIO:
100
-					if (!isset($info_flv['audio']['audioFormat'])) {
101
-						$info_flv['audio']['audioFormat']     =  $last_header_byte & 0x07;
102
-						$info_flv['audio']['audioRate']       = ($last_header_byte & 0x30) / 0x10;
103
-						$info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40;
104
-						$info_flv['audio']['audioType']       = ($last_header_byte & 0x80) / 0x80;
105
-					}
106
-					break;
107
-
108
-
109
-				case getid3_flv::TAG_VIDEO:
110
-					if (!isset($info_flv['video']['videoCodec'])) {
111
-						$info_flv['video']['videoCodec'] = $last_header_byte & 0x07;
112
-
113
-						$flv_video_header = fread($this->getid3->fp, 11);
114
-
115
-						if ($info_flv['video']['videoCodec'] != getid3_flv::VIDEO_VP6) {
116
-
117
-							$picture_size_type = (getid3_lib::BigEndian2Int(substr($flv_video_header, 3, 2))) >> 7;
118
-							$picture_size_type = $picture_size_type & 0x0007;
119
-							$info_flv['header']['videoSizeType'] = $picture_size_type;
120
-
121
-							switch ($picture_size_type) {
122
-								case 0:
123
-									$picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 2));
124
-									$picture_size_enc <<= 1;
125
-									$info['video']['resolution_x'] = ($picture_size_enc & 0xFF00) >> 8;
126
-									$picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 6, 2));
127
-									$picture_size_enc <<= 1;
128
-									$info['video']['resolution_y'] = ($picture_size_enc & 0xFF00) >> 8;
129
-									break;
130
-
131
-								case 1:
132
-									$picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 4));
133
-									$picture_size_enc <<= 1;
134
-									$info['video']['resolution_x'] = ($picture_size_enc & 0xFFFF0000) >> 16;
135
-
136
-									$picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 7, 4));
137
-									$picture_size_enc <<= 1;
138
-									$info['video']['resolution_y'] = ($picture_size_enc & 0xFFFF0000) >> 16;
139
-									break;
140
-
141
-								case 2:
142
-									$info['video']['resolution_x'] = 352;
143
-									$info['video']['resolution_y'] = 288;
144
-									break;
145
-
146
-								case 3:
147
-									$info['video']['resolution_x'] = 176;
148
-									$info['video']['resolution_y'] = 144;
149
-									break;
150
-
151
-								case 4:
152
-									$info['video']['resolution_x'] = 128;
153
-									$info['video']['resolution_y'] = 96;
154
-									break;
155
-
156
-								case 5:
157
-									$info['video']['resolution_x'] = 320;
158
-									$info['video']['resolution_y'] = 240;
159
-									break;
160
-
161
-								case 6:
162
-									$info['video']['resolution_x'] = 160;
163
-									$info['video']['resolution_y'] = 120;
164
-									break;
165
-
166
-								default:
167
-									$info['video']['resolution_x'] = 0;
168
-									$info['video']['resolution_y'] = 0;
169
-									break;
170
-							}
171
-						}
172
-					}
173
-					break;
174
-
175
-
176
-				// Meta tag
177
-				case getid3_flv::TAG_META:
178
-
179
-					fseek($this->getid3->fp, -1, SEEK_CUR);
180
-					$reader = new AMFReader(new AMFStream(fread($this->getid3->fp, $data_length)));
181
-					$event_name = $reader->readData();
182
-					$info['meta'][$event_name] = $reader->readData();
183
-					unset($reader);
184
-
185
-					$info['video']['frame_rate']   = @$info['meta']['onMetaData']['framerate'];
186
-					$info['video']['resolution_x'] = @$info['meta']['onMetaData']['width'];
187
-					$info['video']['resolution_y'] = @$info['meta']['onMetaData']['height'];
188
-					break;
189
-
190
-				default:
191
-					// noop
192
-					break;
193
-			}
194
-
195
-			if ($timestamp > $duration) {
196
-				$duration = $timestamp;
197
-			}
198
-
199
-			fseek($this->getid3->fp, $next_offset, SEEK_SET);
200
-		}
201
-
202
-		if ($info['playtime_seconds'] = $duration / 1000) {
203
-		    $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds'];
204
-		}
205
-
206
-		if ($info_flv['header']['hasAudio']) {
207
-			$info['audio']['codec']           = $this->FLVaudioFormat($info_flv['audio']['audioFormat']);
208
-			$info['audio']['sample_rate']     = $this->FLVaudioRate($info_flv['audio']['audioRate']);
209
-			$info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info_flv['audio']['audioSampleSize']);
210
-
211
-			$info['audio']['channels']   = $info_flv['audio']['audioType'] + 1; // 0=mono,1=stereo
212
-			$info['audio']['lossless']   = ($info_flv['audio']['audioFormat'] ? false : true); // 0=uncompressed
213
-			$info['audio']['dataformat'] = 'flv';
214
-		}
215
-		if (@$info_flv['header']['hasVideo']) {
216
-			$info['video']['codec']      = $this->FLVvideoCodec($info_flv['video']['videoCodec']);
217
-			$info['video']['dataformat'] = 'flv';
218
-			$info['video']['lossless']   = false;
219
-		}
220
-
221
-		return true;
222
-	}
223
-
224
-
225
-	public static function FLVaudioFormat($id) {
226
-
227
-		static $lookup = array(
228
-			0 => 'uncompressed',
229
-			1 => 'ADPCM',
230
-			2 => 'mp3',
231
-			5 => 'Nellymoser 8kHz mono',
232
-			6 => 'Nellymoser',
233
-		);
234
-		return (@$lookup[$id] ? @$lookup[$id] : false);
235
-	}
236
-
237
-
238
-	public static function FLVaudioRate($id) {
239
-
240
-		static $lookup = array(
241
-			0 =>  5500,
242
-			1 => 11025,
243
-			2 => 22050,
244
-			3 => 44100,
245
-		);
246
-		return (@$lookup[$id] ? @$lookup[$id] : false);
247
-	}
248
-
249
-
250
-	public static function FLVaudioBitDepth($id) {
251
-
252
-		static $lookup = array(
253
-			0 =>  8,
254
-			1 => 16,
255
-		);
256
-		return (@$lookup[$id] ? @$lookup[$id] : false);
257
-	}
258
-
259
-
260
-	public static function FLVvideoCodec($id) {
261
-
262
-		static $lookup = array(
263
-			getid3_flv::VIDEO_H263   => 'Sorenson H.263',
264
-			getid3_flv::VIDEO_SCREEN => 'Screen video',
265
-			getid3_flv::VIDEO_VP6    => 'On2 VP6',
266
-		);
267
-		return (@$lookup[$id] ? @$lookup[$id] : false);
268
-	}
59
+    public function Analyze()
60
+    {
61
+        $info = &$this->getid3->info;
62
+
63
+        $info['flv'] = array ();
64
+        $info_flv = &$info['flv'];
65
+
66
+        fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
67
+
68
+        $flv_data_length = $info['avdataend'] - $info['avdataoffset'];
69
+        $flv_header = fread($this->getid3->fp, 5);
70
+
71
+        $info['fileformat'] = 'flv';
72
+        $info_flv['header']['signature'] =                           substr($flv_header, 0, 3);
73
+        $info_flv['header']['version']   = getid3_lib::BigEndian2Int(substr($flv_header, 3, 1));
74
+        $type_flags                      = getid3_lib::BigEndian2Int(substr($flv_header, 4, 1));
75
+
76
+        $info_flv['header']['hasAudio'] = (bool) ($type_flags & 0x04);
77
+        $info_flv['header']['hasVideo'] = (bool) ($type_flags & 0x01);
78
+
79
+        $frame_size_data_length = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4));
80
+        $flv_header_frame_length = 9;
81
+        if ($frame_size_data_length > $flv_header_frame_length) {
82
+            fseek($this->getid3->fp, $frame_size_data_length - $flv_header_frame_length, SEEK_CUR);
83
+        }
84
+
85
+        $duration = 0;
86
+        while ((ftell($this->getid3->fp) + 1) < $info['avdataend']) {
87
+
88
+            $this_tag_header = fread($this->getid3->fp, 16);
89
+
90
+            $previous_tag_length = getid3_lib::BigEndian2Int(substr($this_tag_header,  0, 4));
91
+            $tag_type            = getid3_lib::BigEndian2Int(substr($this_tag_header,  4, 1));
92
+            $data_length         = getid3_lib::BigEndian2Int(substr($this_tag_header,  5, 3));
93
+            $timestamp           = getid3_lib::BigEndian2Int(substr($this_tag_header,  8, 3));
94
+            $last_header_byte    = getid3_lib::BigEndian2Int(substr($this_tag_header, 15, 1));
95
+            $next_offset         = ftell($this->getid3->fp) - 1 + $data_length;
96
+
97
+            switch ($tag_type) {
98
+
99
+                case getid3_flv::TAG_AUDIO:
100
+                    if (!isset($info_flv['audio']['audioFormat'])) {
101
+                        $info_flv['audio']['audioFormat']     =  $last_header_byte & 0x07;
102
+                        $info_flv['audio']['audioRate']       = ($last_header_byte & 0x30) / 0x10;
103
+                        $info_flv['audio']['audioSampleSize'] = ($last_header_byte & 0x40) / 0x40;
104
+                        $info_flv['audio']['audioType']       = ($last_header_byte & 0x80) / 0x80;
105
+                    }
106
+                    break;
107
+
108
+
109
+                case getid3_flv::TAG_VIDEO:
110
+                    if (!isset($info_flv['video']['videoCodec'])) {
111
+                        $info_flv['video']['videoCodec'] = $last_header_byte & 0x07;
112
+
113
+                        $flv_video_header = fread($this->getid3->fp, 11);
114
+
115
+                        if ($info_flv['video']['videoCodec'] != getid3_flv::VIDEO_VP6) {
116
+
117
+                            $picture_size_type = (getid3_lib::BigEndian2Int(substr($flv_video_header, 3, 2))) >> 7;
118
+                            $picture_size_type = $picture_size_type & 0x0007;
119
+                            $info_flv['header']['videoSizeType'] = $picture_size_type;
120
+
121
+                            switch ($picture_size_type) {
122
+                                case 0:
123
+                                    $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 2));
124
+                                    $picture_size_enc <<= 1;
125
+                                    $info['video']['resolution_x'] = ($picture_size_enc & 0xFF00) >> 8;
126
+                                    $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 6, 2));
127
+                                    $picture_size_enc <<= 1;
128
+                                    $info['video']['resolution_y'] = ($picture_size_enc & 0xFF00) >> 8;
129
+                                    break;
130
+
131
+                                case 1:
132
+                                    $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 5, 4));
133
+                                    $picture_size_enc <<= 1;
134
+                                    $info['video']['resolution_x'] = ($picture_size_enc & 0xFFFF0000) >> 16;
135
+
136
+                                    $picture_size_enc = getid3_lib::BigEndian2Int(substr($flv_video_header, 7, 4));
137
+                                    $picture_size_enc <<= 1;
138
+                                    $info['video']['resolution_y'] = ($picture_size_enc & 0xFFFF0000) >> 16;
139
+                                    break;
140
+
141
+                                case 2:
142
+                                    $info['video']['resolution_x'] = 352;
143
+                                    $info['video']['resolution_y'] = 288;
144
+                                    break;
145
+
146
+                                case 3:
147
+                                    $info['video']['resolution_x'] = 176;
148
+                                    $info['video']['resolution_y'] = 144;
149
+                                    break;
150
+
151
+                                case 4:
152
+                                    $info['video']['resolution_x'] = 128;
153
+                                    $info['video']['resolution_y'] = 96;
154
+                                    break;
155
+
156
+                                case 5:
157
+                                    $info['video']['resolution_x'] = 320;
158
+                                    $info['video']['resolution_y'] = 240;
159
+                                    break;
160
+
161
+                                case 6:
162
+                                    $info['video']['resolution_x'] = 160;
163
+                                    $info['video']['resolution_y'] = 120;
164
+                                    break;
165
+
166
+                                default:
167
+                                    $info['video']['resolution_x'] = 0;
168
+                                    $info['video']['resolution_y'] = 0;
169
+                                    break;
170
+                            }
171
+                        }
172
+                    }
173
+                    break;
174
+
175
+
176
+                // Meta tag
177
+                case getid3_flv::TAG_META:
178
+
179
+                    fseek($this->getid3->fp, -1, SEEK_CUR);
180
+                    $reader = new AMFReader(new AMFStream(fread($this->getid3->fp, $data_length)));
181
+                    $event_name = $reader->readData();
182
+                    $info['meta'][$event_name] = $reader->readData();
183
+                    unset($reader);
184
+
185
+                    $info['video']['frame_rate']   = @$info['meta']['onMetaData']['framerate'];
186
+                    $info['video']['resolution_x'] = @$info['meta']['onMetaData']['width'];
187
+                    $info['video']['resolution_y'] = @$info['meta']['onMetaData']['height'];
188
+                    break;
189
+
190
+                default:
191
+                    // noop
192
+                    break;
193
+            }
194
+
195
+            if ($timestamp > $duration) {
196
+                $duration = $timestamp;
197
+            }
198
+
199
+            fseek($this->getid3->fp, $next_offset, SEEK_SET);
200
+        }
201
+
202
+        if ($info['playtime_seconds'] = $duration / 1000) {
203
+            $info['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) / $info['playtime_seconds'];
204
+        }
205
+
206
+        if ($info_flv['header']['hasAudio']) {
207
+            $info['audio']['codec']           = $this->FLVaudioFormat($info_flv['audio']['audioFormat']);
208
+            $info['audio']['sample_rate']     = $this->FLVaudioRate($info_flv['audio']['audioRate']);
209
+            $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info_flv['audio']['audioSampleSize']);
210
+
211
+            $info['audio']['channels']   = $info_flv['audio']['audioType'] + 1; // 0=mono,1=stereo
212
+            $info['audio']['lossless']   = ($info_flv['audio']['audioFormat'] ? false : true); // 0=uncompressed
213
+            $info['audio']['dataformat'] = 'flv';
214
+        }
215
+        if (@$info_flv['header']['hasVideo']) {
216
+            $info['video']['codec']      = $this->FLVvideoCodec($info_flv['video']['videoCodec']);
217
+            $info['video']['dataformat'] = 'flv';
218
+            $info['video']['lossless']   = false;
219
+        }
220
+
221
+        return true;
222
+    }
223
+
224
+
225
+    public static function FLVaudioFormat($id) {
226
+
227
+        static $lookup = array(
228
+            0 => 'uncompressed',
229
+            1 => 'ADPCM',
230
+            2 => 'mp3',
231
+            5 => 'Nellymoser 8kHz mono',
232
+            6 => 'Nellymoser',
233
+        );
234
+        return (@$lookup[$id] ? @$lookup[$id] : false);
235
+    }
236
+
237
+
238
+    public static function FLVaudioRate($id) {
239
+
240
+        static $lookup = array(
241
+            0 =>  5500,
242
+            1 => 11025,
243
+            2 => 22050,
244
+            3 => 44100,
245
+        );
246
+        return (@$lookup[$id] ? @$lookup[$id] : false);
247
+    }
248
+
249
+
250
+    public static function FLVaudioBitDepth($id) {
251
+
252
+        static $lookup = array(
253
+            0 =>  8,
254
+            1 => 16,
255
+        );
256
+        return (@$lookup[$id] ? @$lookup[$id] : false);
257
+    }
258
+
259
+
260
+    public static function FLVvideoCodec($id) {
261
+
262
+        static $lookup = array(
263
+            getid3_flv::VIDEO_H263   => 'Sorenson H.263',
264
+            getid3_flv::VIDEO_SCREEN => 'Screen video',
265
+            getid3_flv::VIDEO_VP6    => 'On2 VP6',
266
+        );
267
+        return (@$lookup[$id] ? @$lookup[$id] : false);
268
+    }
269 269
 }
270 270
 
271 271
 
272 272
 
273 273
 class AMFStream
274 274
 {
275
-	public $bytes;
276
-	public $pos;
275
+    public $bytes;
276
+    public $pos;
277 277
 
278 278
 
279
-	public function AMFStream($bytes) {
279
+    public function AMFStream($bytes) {
280 280
 
281
-		$this->bytes = $bytes;
282
-		$this->pos = 0;
283
-	}
281
+        $this->bytes = $bytes;
282
+        $this->pos = 0;
283
+    }
284 284
 
285 285
 
286
-	public function readByte() {
286
+    public function readByte() {
287 287
 
288
-		return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
289
-	}
288
+        return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
289
+    }
290 290
 
291 291
 
292
-	public function readInt() {
292
+    public function readInt() {
293 293
 
294
-		return ($this->readByte() << 8) + $this->readByte();
295
-	}
294
+        return ($this->readByte() << 8) + $this->readByte();
295
+    }
296 296
 
297 297
 
298
-	public function readLong() {
298
+    public function readLong() {
299 299
 
300
-		return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
301
-	}
300
+        return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
301
+    }
302 302
 
303 303
 
304
-	public function readDouble() {
304
+    public function readDouble() {
305 305
 
306
-		return getid3_lib::BigEndian2Float($this->read(8));
307
-	}
306
+        return getid3_lib::BigEndian2Float($this->read(8));
307
+    }
308 308
 
309 309
 
310
-	public function readUTF() {
310
+    public function readUTF() {
311 311
 
312
-		$length = $this->readInt();
313
-		return $this->read($length);
314
-	}
312
+        $length = $this->readInt();
313
+        return $this->read($length);
314
+    }
315 315
 
316 316
 
317
-	public function readLongUTF() {
317
+    public function readLongUTF() {
318 318
 
319
-		$length = $this->readLong();
320
-		return $this->read($length);
321
-	}
319
+        $length = $this->readLong();
320
+        return $this->read($length);
321
+    }
322 322
 
323 323
 
324
-	public function read($length) {
324
+    public function read($length) {
325 325
 
326
-		$val = substr($this->bytes, $this->pos, $length);
327
-		$this->pos += $length;
328
-		return $val;
329
-	}
326
+        $val = substr($this->bytes, $this->pos, $length);
327
+        $this->pos += $length;
328
+        return $val;
329
+    }
330 330
 
331 331
 
332
-	public function peekByte() {
332
+    public function peekByte() {
333 333
 
334
-		$pos = $this->pos;
335
-		$val = $this->readByte();
336
-		$this->pos = $pos;
337
-		return $val;
338
-	}
334
+        $pos = $this->pos;
335
+        $val = $this->readByte();
336
+        $this->pos = $pos;
337
+        return $val;
338
+    }
339 339
 
340 340
 
341
-	public function peekInt() {
341
+    public function peekInt() {
342 342
 
343
-		$pos = $this->pos;
344
-		$val = $this->readInt();
345
-		$this->pos = $pos;
346
-		return $val;
347
-	}
343
+        $pos = $this->pos;
344
+        $val = $this->readInt();
345
+        $this->pos = $pos;
346
+        return $val;
347
+    }
348 348
 
349 349
 
350
-	public function peekLong() {
350
+    public function peekLong() {
351 351
 
352
-		$pos = $this->pos;
353
-		$val = $this->readLong();
354
-		$this->pos = $pos;
355
-		return $val;
356
-	}
352
+        $pos = $this->pos;
353
+        $val = $this->readLong();
354
+        $this->pos = $pos;
355
+        return $val;
356
+    }
357 357
 
358 358
 
359
-	public function peekDouble() {
359
+    public function peekDouble() {
360 360
 
361
-		$pos = $this->pos;
362
-		$val = $this->readDouble();
363
-		$this->pos = $pos;
364
-		return $val;
365
-	}
361
+        $pos = $this->pos;
362
+        $val = $this->readDouble();
363
+        $this->pos = $pos;
364
+        return $val;
365
+    }
366 366
 
367 367
 
368
-	public function peekUTF() {
368
+    public function peekUTF() {
369 369
 
370
-		$pos = $this->pos;
371
-		$val = $this->readUTF();
372
-		$this->pos = $pos;
373
-		return $val;
374
-	}
370
+        $pos = $this->pos;
371
+        $val = $this->readUTF();
372
+        $this->pos = $pos;
373
+        return $val;
374
+    }
375 375
 
376 376
 
377
-	public function peekLongUTF() {
377
+    public function peekLongUTF() {
378 378
 
379
-		$pos = $this->pos;
380
-		$val = $this->readLongUTF();
381
-		$this->pos = $pos;
382
-		return $val;
383
-	}
379
+        $pos = $this->pos;
380
+        $val = $this->readLongUTF();
381
+        $this->pos = $pos;
382
+        return $val;
383
+    }
384 384
 }
385 385
 
386 386
 
387 387
 
388 388
 class AMFReader
389 389
 {
390
-	public $stream;
390
+    public $stream;
391 391
 
392
-	public function __construct($stream) {
392
+    public function __construct($stream) {
393 393
 
394
-		$this->stream = $stream;
395
-	}
394
+        $this->stream = $stream;
395
+    }
396 396
 
397 397
 
398
-	public function readData() {
398
+    public function readData() {
399 399
 
400
-		$value = null;
400
+        $value = null;
401 401
 
402
-		$type = $this->stream->readByte();
402
+        $type = $this->stream->readByte();
403 403
 
404
-		switch($type) {
405
-			// Double
406
-			case 0:
407
-				$value = $this->readDouble();
408
-			break;
404
+        switch($type) {
405
+            // Double
406
+            case 0:
407
+                $value = $this->readDouble();
408
+            break;
409 409
 
410
-			// Boolean
411
-			case 1:
412
-				$value = $this->readBoolean();
413
-				break;
410
+            // Boolean
411
+            case 1:
412
+                $value = $this->readBoolean();
413
+                break;
414 414
 
415
-			// String
416
-			case 2:
417
-				$value = $this->readString();
418
-				break;
415
+            // String
416
+            case 2:
417
+                $value = $this->readString();
418
+                break;
419 419
 
420
-			// Object
421
-			case 3:
422
-				$value = $this->readObject();
423
-				break;
420
+            // Object
421
+            case 3:
422
+                $value = $this->readObject();
423
+                break;
424 424
 
425
-			// null
426
-			case 6:
427
-				return null;
428
-				break;
425
+            // null
426
+            case 6:
427
+                return null;
428
+                break;
429 429
 
430
-			// Mixed array
431
-			case 8:
432
-				$value = $this->readMixedArray();
433
-				break;
430
+            // Mixed array
431
+            case 8:
432
+                $value = $this->readMixedArray();
433
+                break;
434 434
 
435
-			// Array
436
-			case 10:
437
-				$value = $this->readArray();
438
-				break;
435
+            // Array
436
+            case 10:
437
+                $value = $this->readArray();
438
+                break;
439 439
 
440
-			// Date
441
-			case 11:
442
-				$value = $this->readDate();
443
-				break;
440
+            // Date
441
+            case 11:
442
+                $value = $this->readDate();
443
+                break;
444 444
 
445
-			// Long string
446
-			case 13:
447
-				$value = $this->readLongString();
448
-				break;
445
+            // Long string
446
+            case 13:
447
+                $value = $this->readLongString();
448
+                break;
449 449
 
450
-			// XML (handled as string)
451
-			case 15:
452
-				$value = $this->readXML();
453
-				break;
450
+            // XML (handled as string)
451
+            case 15:
452
+                $value = $this->readXML();
453
+                break;
454 454
 
455
-			// Typed object (handled as object)
456
-			case 16:
457
-				$value = $this->readTypedObject();
458
-				break;
455
+            // Typed object (handled as object)
456
+            case 16:
457
+                $value = $this->readTypedObject();
458
+                break;
459 459
 
460
-			// Long string
461
-			default:
462
-				$value = '(unknown or unsupported data type)';
463
-			break;
464
-		}
460
+            // Long string
461
+            default:
462
+                $value = '(unknown or unsupported data type)';
463
+            break;
464
+        }
465 465
 
466
-		return $value;
467
-	}
466
+        return $value;
467
+    }
468 468
 
469 469
 
470
-	public function readDouble() {
470
+    public function readDouble() {
471 471
 
472
-		return $this->stream->readDouble();
473
-	}
472
+        return $this->stream->readDouble();
473
+    }
474 474
 
475 475
 
476
-	public function readBoolean() {
476
+    public function readBoolean() {
477 477
 
478
-		return $this->stream->readByte() == 1;
479
-	}
478
+        return $this->stream->readByte() == 1;
479
+    }
480 480
 
481 481
 
482
-	public function readString() {
482
+    public function readString() {
483 483
 
484
-		return $this->stream->readUTF();
485
-	}
484
+        return $this->stream->readUTF();
485
+    }
486 486
 
487 487
 
488
-	public function readObject() {
488
+    public function readObject() {
489 489
 
490
-		// Get highest numerical index - ignored
491
-		$highestIndex = $this->stream->readLong();
490
+        // Get highest numerical index - ignored
491
+        $highestIndex = $this->stream->readLong();
492 492
 
493
-		$data = array();
493
+        $data = array();
494 494
 
495
-		while ($key = $this->stream->readUTF()) {
496
-			// Mixed array record ends with empty string (0x00 0x00) and 0x09
497
-			if (($key == '') && ($this->stream->peekByte() == 0x09)) {
498
-				// Consume byte
499
-				$this->stream->readByte();
500
-				break;
501
-			}
495
+        while ($key = $this->stream->readUTF()) {
496
+            // Mixed array record ends with empty string (0x00 0x00) and 0x09
497
+            if (($key == '') && ($this->stream->peekByte() == 0x09)) {
498
+                // Consume byte
499
+                $this->stream->readByte();
500
+                break;
501
+            }
502 502
 
503
-			$data[$key] = $this->readData();
504
-		}
503
+            $data[$key] = $this->readData();
504
+        }
505 505
 
506
-		return $data;
507
-	}
506
+        return $data;
507
+    }
508 508
 
509 509
 
510
-	public function readMixedArray() {
510
+    public function readMixedArray() {
511 511
 
512
-		// Get highest numerical index - ignored
513
-		$highestIndex = $this->stream->readLong();
512
+        // Get highest numerical index - ignored
513
+        $highestIndex = $this->stream->readLong();
514 514
 
515
-		$data = array();
515
+        $data = array();
516 516
 
517
-		while ($key = $this->stream->readUTF()) {
518
-			// Mixed array record ends with empty string (0x00 0x00) and 0x09
519
-			if (($key == '') && ($this->stream->peekByte() == 0x09)) {
520
-				// Consume byte
521
-				$this->stream->readByte();
522
-				break;
523
-			}
517
+        while ($key = $this->stream->readUTF()) {
518
+            // Mixed array record ends with empty string (0x00 0x00) and 0x09
519
+            if (($key == '') && ($this->stream->peekByte() == 0x09)) {
520
+                // Consume byte
521
+                $this->stream->readByte();
522
+                break;
523
+            }
524 524
 
525
-			if (is_numeric($key)) {
526
-				$key = (float) $key;
527
-			}
525
+            if (is_numeric($key)) {
526
+                $key = (float) $key;
527
+            }
528 528
 
529
-			$data[$key] = $this->readData();
530
-		}
529
+            $data[$key] = $this->readData();
530
+        }
531 531
 
532
-		return $data;
533
-	}
532
+        return $data;
533
+    }
534 534
 
535 535
 
536
-	public function readArray() {
536
+    public function readArray() {
537 537
 
538
-		$length = $this->stream->readLong();
538
+        $length = $this->stream->readLong();
539 539
 
540
-		$data = array();
540
+        $data = array();
541 541
 
542
-		for ($i = 0; $i < count($length); $i++) {
543
-			$data[] = $this->readData();
544
-		}
542
+        for ($i = 0; $i < count($length); $i++) {
543
+            $data[] = $this->readData();
544
+        }
545 545
 
546
-		return $data;
547
-	}
546
+        return $data;
547
+    }
548 548
 
549 549
 
550
-	public function readDate() {
550
+    public function readDate() {
551 551
 
552
-		$timestamp = $this->stream->readDouble();
553
-		$timezone = $this->stream->readInt();
554
-		return $timestamp;
555
-	}
552
+        $timestamp = $this->stream->readDouble();
553
+        $timezone = $this->stream->readInt();
554
+        return $timestamp;
555
+    }
556 556
 
557 557
 
558
-	public function readLongString() {
558
+    public function readLongString() {
559 559
 
560
-		return $this->stream->readLongUTF();
561
-	}
560
+        return $this->stream->readLongUTF();
561
+    }
562 562
 
563 563
 
564
-	public function readXML() {
564
+    public function readXML() {
565 565
 
566
-		return $this->stream->readLongUTF();
567
-	}
566
+        return $this->stream->readLongUTF();
567
+    }
568 568
 
569 569
 
570
-	public function readTypedObject() {
570
+    public function readTypedObject() {
571 571
 
572
-		$className = $this->stream->readUTF();
573
-		return $this->readObject();
574
-	}
572
+        $className = $this->stream->readUTF();
573
+        return $this->readObject();
574
+    }
575 575
 }
576 576
 
577 577
 ?>
Please login to merge, or discard this patch.
main/inc/lib/glossary.lib.php 3 patches
Doc Comments   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * This functions stores the glossary in the database
87 87
      *
88 88
      * @param array    Array of title + description (glossary_title => $title, glossary_comment => $comment)
89
-     * @return mixed   Term id on success, false on failure
89
+     * @return false|string   Term id on success, false on failure
90 90
      * @author Christian Fasanando <[email protected]>
91 91
      * @author Patrick Cool <[email protected]>, Ghent University, Belgium
92 92
      * @version januari 2009, dokeos 1.8.6
@@ -443,6 +443,10 @@  discard block
 block discarded – undo
443 443
      * @param integer Number of items to collect
444 444
      * @param string  Name of column on which to order
445 445
      * @param string  Whether to sort in ascending (ASC) or descending (DESC)
446
+     * @param integer $from
447
+     * @param integer $number_of_items
448
+     * @param integer $column
449
+     * @param string $direction
446 450
      * @return unknown
447 451
      *
448 452
      * @author Patrick Cool <[email protected]>
@@ -520,6 +524,7 @@  discard block
 block discarded – undo
520 524
      * @param integer $glossary_id
521 525
      * @param array   Parameters to use to affect links
522 526
      * @param array   The line of results from a query on the glossary table
527
+     * @param string $url_params
523 528
      * @return string HTML string for the action icons columns
524 529
      *
525 530
      * @author Patrick Cool <[email protected]>, Ghent University, Belgium
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
      * @param int $glossary_id
40 40
      * @return string The glossary description
41 41
      */
42
-    public static function get_glossary_term_by_glossary_id ($glossary_id)
42
+    public static function get_glossary_term_by_glossary_id($glossary_id)
43 43
     {
44
-        $glossary_table  = Database::get_course_table(TABLE_GLOSSARY);
44
+        $glossary_table = Database::get_course_table(TABLE_GLOSSARY);
45 45
         $course_id = api_get_course_int_id();
46 46
         $sql = "SELECT description FROM $glossary_table
47 47
                 WHERE c_id = $course_id  AND glossary_id =".intval($glossary_id);
48
-        $rs=Database::query($sql);
48
+        $rs = Database::query($sql);
49 49
         if (Database::num_rows($rs) > 0) {
50 50
             $row = Database::fetch_array($rs);
51 51
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      * @param string The glossary term name
62 62
      * @return string The glossary description
63 63
      */
64
-    public static function get_glossary_term_by_glossary_name ($glossary_name)
64
+    public static function get_glossary_term_by_glossary_name($glossary_name)
65 65
     {
66
-        $glossary_table  = Database::get_course_table(TABLE_GLOSSARY);
66
+        $glossary_table = Database::get_course_table(TABLE_GLOSSARY);
67 67
         $session_id = api_get_session_id();
68 68
         $course_id = api_get_course_int_id();
69 69
         $sql_filter = api_get_session_condition($session_id);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $course_id = api_get_course_int_id();
164 164
 
165 165
         // check if the glossary term already exists
166
-        if (GlossaryManager::glossary_exists($values['glossary_title'],$values['glossary_id'])) {
166
+        if (GlossaryManager::glossary_exists($values['glossary_title'], $values['glossary_id'])) {
167 167
             // display the feedback message
168 168
             if ($message)
169 169
                 Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         $get_max = "SELECT MAX(display_order) FROM $t_glossary
211 211
                     WHERE c_id = $course_id ";
212 212
         $res_max = Database::query($get_max);
213
-        if (Database::num_rows($res_max)==0) {
213
+        if (Database::num_rows($res_max) == 0) {
214 214
             return 0;
215 215
         }
216 216
         $row = Database::fetch_array($res_max);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      * @author Patrick Cool <[email protected]>, Ghent University, Belgium
232 232
      * @version januari 2009, dokeos 1.8.6
233 233
      */
234
-    public static function glossary_exists($term, $not_id='')
234
+    public static function glossary_exists($term, $not_id = '')
235 235
     {
236 236
         // Database table definition
237 237
         $t_glossary = Database :: get_course_table(TABLE_GLOSSARY);
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                 WHERE
242 242
                     c_id = $course_id AND
243 243
                     name = '".Database::escape_string($term)."'";
244
-        if ($not_id<>'') {
244
+        if ($not_id <> '') {
245 245
             $sql .= " AND glossary_id <> '".intval($not_id)."'";
246 246
         }
247 247
         $result = Database::query($sql);
@@ -347,27 +347,27 @@  discard block
 block discarded – undo
347 347
         // action links
348 348
         echo '<div class="actions">';
349 349
 
350
-        if (api_is_allowed_to_edit(null,true)) {
350
+        if (api_is_allowed_to_edit(null, true)) {
351 351
             echo '<a href="index.php?'.api_get_cidreq().'&action=addglossary&msg=add?'.api_get_cidreq().'">'.
352
-                Display::return_icon('new_glossary_term.png',get_lang('TermAddNew'),'', ICON_SIZE_MEDIUM).'</a>';
352
+                Display::return_icon('new_glossary_term.png', get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM).'</a>';
353 353
         }
354 354
 
355 355
         echo '<a href="index.php?'.api_get_cidreq().'&action=export">'.
356
-            Display::return_icon('export_csv.png',get_lang('ExportGlossaryAsCSV'),'',ICON_SIZE_MEDIUM).'</a>';
357
-        if (api_is_allowed_to_edit(null,true)) {
356
+            Display::return_icon('export_csv.png', get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
357
+        if (api_is_allowed_to_edit(null, true)) {
358 358
             echo '<a href="index.php?'.api_get_cidreq().'&action=import">'.
359
-                Display::return_icon('import_csv.png',get_lang('ImportGlossary'),'',ICON_SIZE_MEDIUM).'</a>';
359
+                Display::return_icon('import_csv.png', get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM).'</a>';
360 360
         }
361 361
 
362 362
         echo '<a href="index.php?'.api_get_cidreq().'&action=export_to_pdf">'.
363
-            Display::return_icon('pdf.png',get_lang('ExportToPDF'),'', ICON_SIZE_MEDIUM).'</a>';
363
+            Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
364 364
 
365
-        if ((isset($_SESSION['glossary_view']) && $_SESSION['glossary_view'] == 'table') or (!isset($_SESSION['glossary_view']))){
365
+        if ((isset($_SESSION['glossary_view']) && $_SESSION['glossary_view'] == 'table') or (!isset($_SESSION['glossary_view']))) {
366 366
             echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=list">'.
367
-                Display::return_icon('view_detailed.png',get_lang('ListView'),'',ICON_SIZE_MEDIUM).'</a>';
367
+                Display::return_icon('view_detailed.png', get_lang('ListView'), '', ICON_SIZE_MEDIUM).'</a>';
368 368
         } else {
369 369
             echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=table">'.
370
-                Display::return_icon('view_text.png',get_lang('TableView'),'',ICON_SIZE_MEDIUM).'</a>';
370
+                Display::return_icon('view_text.png', get_lang('TableView'), '', ICON_SIZE_MEDIUM).'</a>';
371 371
         }
372 372
         echo '</div>';
373 373
         if (!$_SESSION['glossary_view'] || $_SESSION['glossary_view'] == 'table') {
@@ -380,9 +380,9 @@  discard block
 block discarded – undo
380 380
             //$table->set_header(0, '', false);
381 381
             $table->set_header(0, get_lang('TermName'), true);
382 382
             $table->set_header(1, get_lang('TermDefinition'), true);
383
-            if (api_is_allowed_to_edit(null,true)) {
383
+            if (api_is_allowed_to_edit(null, true)) {
384 384
                 $table->set_header(2, get_lang('Actions'), false, 'width=90px', array('class' => 'td_actions'));
385
-                $table->set_column_filter(2, array('GlossaryManager','actions_filter'));
385
+                $table->set_column_filter(2, array('GlossaryManager', 'actions_filter'));
386 386
             }
387 387
             $table->display();
388 388
         }
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
      */
400 400
     public static function display_glossary_list()
401 401
     {
402
-        $glossary_data = self::get_glossary_data(0,1000,0,'ASC');
402
+        $glossary_data = self::get_glossary_data(0, 1000, 0, 'ASC');
403 403
         foreach ($glossary_data as $key => $glossary_item) {
404 404
             $actions = '';
405
-            if (api_is_allowed_to_edit(null,true)) {
406
-                $actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '',$glossary_item).'</div>';
405
+            if (api_is_allowed_to_edit(null, true)) {
406
+                $actions = '<div class="pull-right">'.self::actions_filter($glossary_item[2], '', $glossary_item).'</div>';
407 407
             }
408 408
             echo Display::panel($glossary_item[1], $glossary_item[0].' '.$actions);
409 409
         }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
      * @author Patrick Cool <[email protected]>, Ghent University, Belgium
419 419
      * @version januari 2009, dokeos 1.8.6
420 420
      */
421
-    public static  function get_number_glossary_terms($session_id=0)
421
+    public static  function get_number_glossary_terms($session_id = 0)
422 422
     {
423 423
         // Database table definition
424 424
         $t_glossary = Database :: get_course_table(TABLE_GLOSSARY);
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
         $t_glossary = Database :: get_course_table(TABLE_GLOSSARY);
457 457
         $t_item_propery = Database :: get_course_table(TABLE_ITEM_PROPERTY);
458 458
 
459
-        if (api_is_allowed_to_edit(null,true)) {
459
+        if (api_is_allowed_to_edit(null, true)) {
460 460
             $col2 = " glossary.glossary_id	as col2, ";
461 461
         } else {
462 462
             $col2 = " ";
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
             'glossary.session_id'
472 472
         );
473 473
         $column = intval($column);
474
-        if (!in_array($direction,array('DESC', 'ASC'))) {
475
-            $direction          = 'ASC';
474
+        if (!in_array($direction, array('DESC', 'ASC'))) {
475
+            $direction = 'ASC';
476 476
         }
477 477
         $from = intval($from);
478 478
         $number_of_items = intval($number_of_items);
@@ -497,15 +497,15 @@  discard block
 block discarded – undo
497 497
         while ($data = Database::fetch_array($res)) {
498 498
             // Validation when belongs to a session
499 499
             $session_img = api_get_session_image($data['session_id'], $_user['status']);
500
-            $array[0] = $data[0] . $session_img;
500
+            $array[0] = $data[0].$session_img;
501 501
 
502 502
             if (!$_SESSION['glossary_view'] || $_SESSION['glossary_view'] == 'table') {
503
-                $array[1] = str_replace(array('<p>','</p>'),array('','<br />'),$data[1]);
503
+                $array[1] = str_replace(array('<p>', '</p>'), array('', '<br />'), $data[1]);
504 504
             } else {
505 505
                 $array[1] = $data[1];
506 506
             }
507 507
 
508
-            if (api_is_allowed_to_edit(null,true)) {
508
+            if (api_is_allowed_to_edit(null, true)) {
509 509
                 $array[2] = $data[2];
510 510
             }
511 511
             $return[] = $array;
@@ -528,14 +528,14 @@  discard block
 block discarded – undo
528 528
     public static function actions_filter($glossary_id, $url_params, $row)
529 529
     {
530 530
         $glossary_id = $row[2];
531
-        $return = '<a href="'.api_get_self().'?action=edit_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'&msg=edit">'.Display::return_icon('edit.png',get_lang('Edit'),'',22).'</a>';
531
+        $return = '<a href="'.api_get_self().'?action=edit_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'&msg=edit">'.Display::return_icon('edit.png', get_lang('Edit'), '', 22).'</a>';
532 532
         $glossary_data = GlossaryManager::get_glossary_information($glossary_id);
533 533
 
534 534
         $glossary_term = $glossary_data['glossary_title'];
535 535
 
536 536
         if (api_is_allowed_to_edit(null, true)) {
537 537
             if ($glossary_data['session_id'] == api_get_session_id()) {
538
-                $return .= '<a href="'.api_get_self().'?action=delete_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',22).'</a>';
538
+                $return .= '<a href="'.api_get_self().'?action=delete_glossary&amp;glossary_id='.$glossary_id.'&'.api_get_cidreq().'" onclick="return confirmation(\''.$glossary_term.'\');">'.Display::return_icon('delete.png', get_lang('Delete'), '', 22).'</a>';
539 539
             } else {
540 540
                 $return  = get_lang('EditionNotAvailableFromSession');
541 541
             }
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
     {
557 557
         return "<script type=\"text/javascript\">
558 558
 				function confirmation (name) {
559
-					if (confirm(\" ". get_lang("TermConfirmDelete") ." \"+ name + \" ?\"))
559
+					if (confirm(\" ". get_lang("TermConfirmDelete")." \"+ name + \" ?\"))
560 560
 						{return true;}
561 561
 					else
562 562
 						{return false;}
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
         $res = Database::query($sql);
617 617
         $found = false;
618 618
         while ($row = Database::fetch_array($res)) {
619
-            if ($found && empty($next_id))	{
619
+            if ($found && empty($next_id)) {
620 620
                 $next_id = $row['glossary_id'];
621 621
                 $next_display_order = $row['display_order'];
622 622
             }
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -108,8 +108,9 @@  discard block
 block discarded – undo
108 108
         // check if the glossary term already exists
109 109
         if (GlossaryManager::glossary_exists($values['glossary_title'])) {
110 110
             // display the feedback message
111
-            if ($message)
112
-                Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
111
+            if ($message) {
112
+                            Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
113
+            }
113 114
             return false;
114 115
         } else {
115 116
 
@@ -165,8 +166,9 @@  discard block
 block discarded – undo
165 166
         // check if the glossary term already exists
166 167
         if (GlossaryManager::glossary_exists($values['glossary_title'],$values['glossary_id'])) {
167 168
             // display the feedback message
168
-            if ($message)
169
-                Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
169
+            if ($message) {
170
+                            Display::display_error_message(get_lang('GlossaryTermAlreadyExistsYouShouldEditIt'));
171
+            }
170 172
             return false;
171 173
         } else {
172 174
             $sql = "UPDATE $t_glossary SET
@@ -188,8 +190,9 @@  discard block
 block discarded – undo
188 190
                 api_get_user_id()
189 191
             );
190 192
             // display the feedback message
191
-            if ($message)
192
-                Display::display_confirmation_message(get_lang('TermUpdated'));
193
+            if ($message) {
194
+                            Display::display_confirmation_message(get_lang('TermUpdated'));
195
+            }
193 196
         }
194 197
 
195 198
         return true;
@@ -323,8 +326,9 @@  discard block
 block discarded – undo
323 326
         // reorder the remaining terms
324 327
         GlossaryManager::reorder_glossary();
325 328
         $_SESSION['max_glossary_display'] = GlossaryManager::get_max_glossary_item();
326
-        if ($message)
327
-            Display::display_confirmation_message(get_lang('TermDeleted'));
329
+        if ($message) {
330
+                    Display::display_confirmation_message(get_lang('TermDeleted'));
331
+        }
328 332
         return true;
329 333
     }
330 334
 
@@ -633,8 +637,9 @@  discard block
 block discarded – undo
633 637
                  WHERE c_id = $course_id  AND glossary_id = '".Database::escape_string($next_id)."'";
634 638
         Database::query($sql1);
635 639
         Database::query($sql2);
636
-        if ($message)
637
-            Display::display_confirmation_message(get_lang('TermMoved'));
640
+        if ($message) {
641
+                    Display::display_confirmation_message(get_lang('TermMoved'));
642
+        }
638 643
     }
639 644
 
640 645
     /**
Please login to merge, or discard this patch.