Changeset 41196 for trunk/src/wp-includes/ID3/getid3.php
- Timestamp:
- 07/31/2017 07:49:31 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/getid3.php
r32979 r41196 22 22 if (!defined('IMG_JPG') && defined('IMAGETYPE_JPEG')) { 23 23 define('IMG_JPG', IMAGETYPE_JPEG); 24 } 25 if (!defined('ENT_SUBSTITUTE')) { // PHP5.3 adds ENT_IGNORE, PHP5.4 adds ENT_SUBSTITUTE 26 define('ENT_SUBSTITUTE', (defined('ENT_IGNORE') ? ENT_IGNORE : 8)); 24 27 } 25 28 … … 110 113 protected $startup_warning = ''; 111 114 112 const VERSION = '1.9. 9-20141121';115 const VERSION = '1.9.14-201706111222'; 113 116 const FREAD_BUFFER_SIZE = 32768; 114 117 … … 121 124 // Check memory 122 125 $this->memory_limit = ini_get('memory_limit'); 123 if (preg_match('#([0-9]+) M#i', $this->memory_limit, $matches)) {126 if (preg_match('#([0-9]+) ?M#i', $this->memory_limit, $matches)) { 124 127 // could be stored as "16M" rather than 16777216 for example 125 128 $this->memory_limit = $matches[1] * 1048576; 126 } elseif (preg_match('#([0-9]+) G#i', $this->memory_limit, $matches)) { // The 'G' modifier is available since PHP 5.1.0129 } elseif (preg_match('#([0-9]+) ?G#i', $this->memory_limit, $matches)) { // The 'G' modifier is available since PHP 5.1.0 127 130 // could be stored as "2G" rather than 2147483648 for example 128 131 $this->memory_limit = $matches[1] * 1073741824; … … 131 134 // memory limits probably disabled 132 135 } elseif ($this->memory_limit <= 4194304) { 133 $this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini' ;136 $this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini'."\n"; 134 137 } elseif ($this->memory_limit <= 12582912) { 135 $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini' ;138 $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini'."\n"; 136 139 } 137 140 … … 141 144 } 142 145 143 if (intval(ini_get('mbstring.func_overload')) > 0) { 144 $this->warning('WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", this may break things.'); 146 if (($mbstring_func_overload = ini_get('mbstring.func_overload')) && ($mbstring_func_overload & 0x02)) { 147 // http://php.net/manual/en/mbstring.overload.php 148 // "mbstring.func_overload in php.ini is a positive value that represents a combination of bitmasks specifying the categories of functions to be overloaded. It should be set to 1 to overload the mail() function. 2 for string functions, 4 for regular expression functions" 149 // getID3 cannot run when string functions are overloaded. It doesn't matter if mail() or ereg* functions are overloaded since getID3 does not use those. 150 $this->startup_error .= 'WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", getID3 cannot run with this setting (bitmask 2 (string functions) cannot be set). Recommended to disable entirely.'."\n"; 145 151 } 146 152 … … 148 154 if (function_exists('get_magic_quotes_runtime')) { 149 155 if (get_magic_quotes_runtime()) { 150 return $this->startup_error('magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).');156 $this->startup_error .= 'magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).'."\n"; 151 157 } 152 158 } … … 155 161 if (function_exists('magic_quotes_gpc')) { 156 162 if (get_magic_quotes_gpc()) { 157 return $this->startup_error('magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).');163 $this->startup_error .= 'magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).'."\n"; 158 164 } 159 165 } … … 161 167 // Load support library 162 168 if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) { 163 $this->startup_error .= 'getid3.lib.php is missing or corrupt' ;169 $this->startup_error .= 'getid3.lib.php is missing or corrupt'."\n"; 164 170 } 165 171 … … 180 186 181 187 if (!is_dir($helperappsdir)) { 182 $this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist' ;188 $this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist'."\n"; 183 189 } elseif (strpos(realpath($helperappsdir), ' ') !== false) { 184 190 $DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir)); … … 200 206 } 201 207 } else { 202 $this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.' ;208 $this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.'."\n"; 203 209 } 204 210 } … … 208 214 } 209 215 define('GETID3_HELPERAPPSDIR', $helperappsdir.DIRECTORY_SEPARATOR); 216 } 217 218 if (!empty($this->startup_error)) { 219 echo $this->startup_error; 220 throw new getid3_exception($this->startup_error); 210 221 } 211 222 … … 237 248 238 249 239 public function openfile($filename ) {250 public function openfile($filename, $filesize=null) { 240 251 try { 241 252 if (!empty($this->startup_error)) { … … 243 254 } 244 255 if (!empty($this->startup_warning)) { 245 $this->warning($this->startup_warning); 256 foreach (explode("\n", $this->startup_warning) as $startup_warning) { 257 $this->warning($startup_warning); 258 } 246 259 } 247 260 … … 253 266 254 267 // remote files not supported 255 if (preg_match(' /^(ht|f)tp:\/\//', $filename)) {268 if (preg_match('#^(ht|f)tp://#', $filename)) { 256 269 throw new getid3_exception('Remote files are not supported - please copy the file locally first'); 257 270 } 258 271 259 272 $filename = str_replace('/', DIRECTORY_SEPARATOR, $filename); 260 $filename = preg_replace('#( .+)'.preg_quote(DIRECTORY_SEPARATOR).'{2,}#U', '\1'.DIRECTORY_SEPARATOR, $filename);273 $filename = preg_replace('#(?<!gs:)('.preg_quote(DIRECTORY_SEPARATOR).'{2,})#', DIRECTORY_SEPARATOR, $filename); 261 274 262 275 // open local file … … 281 294 } 282 295 283 $this->info['filesize'] = filesize($filename);296 $this->info['filesize'] = (!is_null($filesize) ? $filesize : filesize($filename)); 284 297 // set redundant parameters - might be needed in some include file 285 298 // filenames / filepaths in getID3 are always expressed with forward slashes (unix-style) for both Windows and other to try and minimize confusion … … 289 302 $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename']; 290 303 304 // set more parameters 305 $this->info['avdataoffset'] = 0; 306 $this->info['avdataend'] = $this->info['filesize']; 307 $this->info['fileformat'] = ''; // filled in later 308 $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used 309 $this->info['video']['dataformat'] = ''; // filled in later, unset if not used 310 $this->info['tags'] = array(); // filled in later, unset if not used 311 $this->info['error'] = array(); // filled in later, unset if not used 312 $this->info['warning'] = array(); // filled in later, unset if not used 313 $this->info['comments'] = array(); // filled in later, unset if not used 314 $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired 291 315 292 316 // option_max_2gb_check … … 315 339 } 316 340 317 // set more parameters318 $this->info['avdataoffset'] = 0;319 $this->info['avdataend'] = $this->info['filesize'];320 $this->info['fileformat'] = ''; // filled in later321 $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used322 $this->info['video']['dataformat'] = ''; // filled in later, unset if not used323 $this->info['tags'] = array(); // filled in later, unset if not used324 $this->info['error'] = array(); // filled in later, unset if not used325 $this->info['warning'] = array(); // filled in later, unset if not used326 $this->info['comments'] = array(); // filled in later, unset if not used327 $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired328 329 341 return true; 330 342 … … 336 348 337 349 // public: analyze file 338 public function analyze($filename ) {350 public function analyze($filename, $filesize=null, $original_filename='') { 339 351 try { 340 if (!$this->openfile($filename )) {352 if (!$this->openfile($filename, $filesize)) { 341 353 return $this->info; 342 354 } … … 383 395 384 396 // determine format 385 $determined_format = $this->GetFileFormat($formattest, $filename);397 $determined_format = $this->GetFileFormat($formattest, ($original_filename ? $original_filename : $filename)); 386 398 387 399 // unable to determine file format … … 420 432 } 421 433 422 // module requires iconv support434 // module requires mb_convert_encoding/iconv support 423 435 // Check encoding/iconv support 424 if (!empty($determined_format['iconv_req']) && !function_exists(' iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {425 $errormessage = ' iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';436 if (!empty($determined_format['iconv_req']) && !function_exists('mb_convert_encoding') && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) { 437 $errormessage = 'mb_convert_encoding() or iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. '; 426 438 if (GETID3_OS_ISWINDOWS) { 427 $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copyiconv.dll from c:/php/dlls to c:/windows/system32';439 $errormessage .= 'PHP does not have mb_convert_encoding() or iconv() support. Please enable php_mbstring.dll / php_iconv.dll in php.ini, and copy php_mbstring.dll / iconv.dll from c:/php/dlls to c:/windows/system32'; 428 440 } else { 429 $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the--with-iconv switch';441 $errormessage .= 'PHP is not compiled with mb_convert_encoding() or iconv() support. Please recompile with the --enable-mbstring / --with-iconv switch'; 430 442 } 431 443 return $this->error($errormessage); … … 562 574 // AC-3 - audio - Dolby AC-3 / Dolby Digital 563 575 'ac3' => array( 564 'pattern' => '^\ x0B\x77',576 'pattern' => '^\\x0B\\x77', 565 577 'group' => 'audio', 566 578 'module' => 'ac3', … … 580 592 // AA - audio - Audible Audiobook 581 593 'aa' => array( 582 'pattern' => '^.{4}\ x57\x90\x75\x36',594 'pattern' => '^.{4}\\x57\\x90\\x75\\x36', 583 595 'group' => 'audio', 584 596 'module' => 'aa', … … 588 600 // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3) 589 601 'adts' => array( 590 'pattern' => '^\ xFF[\xF0-\xF1\xF8-\xF9]',602 'pattern' => '^\\xFF[\\xF0-\\xF1\\xF8-\\xF9]', 591 603 'group' => 'audio', 592 604 'module' => 'aac', … … 598 610 // AU - audio - NeXT/Sun AUdio (AU) 599 611 'au' => array( 600 'pattern' => '^\ .snd',612 'pattern' => '^\\.snd', 601 613 'group' => 'audio', 602 614 'module' => 'au', … … 606 618 // AMR - audio - Adaptive Multi Rate 607 619 'amr' => array( 608 'pattern' => '^\ x23\x21AMR\x0A', // #!AMR[0A]620 'pattern' => '^\\x23\\x21AMR\\x0A', // #!AMR[0A] 609 621 'group' => 'audio', 610 622 'module' => 'amr', … … 622 634 // BONK - audio - Bonk v0.9+ 623 635 'bonk' => array( 624 'pattern' => '^\ x00(BONK|INFO|META| ID3)',636 'pattern' => '^\\x00(BONK|INFO|META| ID3)', 625 637 'group' => 'audio', 626 638 'module' => 'bonk', … … 628 640 ), 629 641 642 // DSF - audio - Direct Stream Digital (DSD) Storage Facility files (DSF) - https://en.wikipedia.org/wiki/Direct_Stream_Digital 643 'dsf' => array( 644 'pattern' => '^DSD ', // including trailing space: 44 53 44 20 645 'group' => 'audio', 646 'module' => 'dsf', 647 'mime_type' => 'audio/dsd', 648 ), 649 630 650 // DSS - audio - Digital Speech Standard 631 651 'dss' => array( 632 'pattern' => '^[\ x02-\x03]ds[s2]',652 'pattern' => '^[\\x02-\\x06]ds[s2]', 633 653 'group' => 'audio', 634 654 'module' => 'dss', … … 638 658 // DTS - audio - Dolby Theatre System 639 659 'dts' => array( 640 'pattern' => '^\ x7F\xFE\x80\x01',660 'pattern' => '^\\x7F\\xFE\\x80\\x01', 641 661 'group' => 'audio', 642 662 'module' => 'dts', … … 723 743 // MPC - audio - Musepack / MPEGplus 724 744 'mpc' => array( 725 'pattern' => '^(MPCK|MP\ +|[\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])',745 'pattern' => '^(MPCK|MP\\+|[\\x00\\x01\\x10\\x11\\x40\\x41\\x50\\x51\\x80\\x81\\x90\\x91\\xC0\\xC1\\xD0\\xD1][\\x20-\\x37][\\x00\\x20\\x40\\x60\\x80\\xA0\\xC0\\xE0])', 726 746 'group' => 'audio', 727 747 'module' => 'mpc', … … 731 751 // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS) 732 752 'mp3' => array( 733 'pattern' => '^\ xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\x0B\x10-\x1B\x20-\x2B\x30-\x3B\x40-\x4B\x50-\x5B\x60-\x6B\x70-\x7B\x80-\x8B\x90-\x9B\xA0-\xAB\xB0-\xBB\xC0-\xCB\xD0-\xDB\xE0-\xEB\xF0-\xFB]',753 'pattern' => '^\\xFF[\\xE2-\\xE7\\xF2-\\xF7\\xFA-\\xFF][\\x00-\\x0B\\x10-\\x1B\\x20-\\x2B\\x30-\\x3B\\x40-\\x4B\\x50-\\x5B\\x60-\\x6B\\x70-\\x7B\\x80-\\x8B\\x90-\\x9B\\xA0-\\xAB\\xB0-\\xBB\\xC0-\\xCB\\xD0-\\xDB\\xE0-\\xEB\\xF0-\\xFB]', 734 754 'group' => 'audio', 735 755 'module' => 'mp3', … … 739 759 // OFR - audio - OptimFROG 740 760 'ofr' => array( 741 'pattern' => '^(\ *RIFF|OFR)',761 'pattern' => '^(\\*RIFF|OFR)', 742 762 'group' => 'audio', 743 763 'module' => 'optimfrog', … … 765 785 // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org) 766 786 'tta' => array( 767 'pattern' => '^TTA', // could also be '^TTA(\ x01|\x02|\x03|2|1)'787 'pattern' => '^TTA', // could also be '^TTA(\\x01|\\x02|\\x03|2|1)' 768 788 'group' => 'audio', 769 789 'module' => 'tta', … … 800 820 // ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio 801 821 'asf' => array( 802 'pattern' => '^\ x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',822 'pattern' => '^\\x30\\x26\\xB2\\x75\\x8E\\x66\\xCF\\x11\\xA6\\xD9\\x00\\xAA\\x00\\x62\\xCE\\x6C', 803 823 'group' => 'audio-video', 804 824 'module' => 'asf', … … 817 837 // FLV - audio/video - FLash Video 818 838 'flv' => array( 819 'pattern' => '^FLV \x01',839 'pattern' => '^FLV[\\x01]', 820 840 'group' => 'audio-video', 821 841 'module' => 'flv', … … 825 845 // MKAV - audio/video - Mastroka 826 846 'matroska' => array( 827 'pattern' => '^\ x1A\x45\xDF\xA3',847 'pattern' => '^\\x1A\\x45\\xDF\\xA3', 828 848 'group' => 'audio-video', 829 849 'module' => 'matroska', … … 833 853 // MPEG - audio/video - MPEG (Moving Pictures Experts Group) 834 854 'mpeg' => array( 835 'pattern' => '^\ x00\x00\x01(\xBA|\xB3)',855 'pattern' => '^\\x00\\x00\\x01[\\xB3\\xBA]', 836 856 'group' => 'audio-video', 837 857 'module' => 'mpeg', … … 870 890 'group' => 'audio-video', 871 891 'module' => 'riff', 872 'mime_type' => 'audio/x-wav e',892 'mime_type' => 'audio/x-wav', 873 893 'fail_ape' => 'WARNING', 874 894 ), … … 876 896 // Real - audio/video - RealAudio, RealVideo 877 897 'real' => array( 878 'pattern' => '^ (\\.RMF|\\.ra)',898 'pattern' => '^\\.(RMF|ra)', 879 899 'group' => 'audio-video', 880 900 'module' => 'real', … … 892 912 // TS - audio/video - MPEG-2 Transport Stream 893 913 'ts' => array( 894 'pattern' => '^(\ x47.{187}){10,}', // packets are 188 bytes long and start with 0x47 "G". Check for at least 10 packets matching this pattern914 'pattern' => '^(\\x47.{187}){10,}', // packets are 188 bytes long and start with 0x47 "G". Check for at least 10 packets matching this pattern 895 915 'group' => 'audio-video', 896 916 'module' => 'ts', … … 923 943 // JPEG - still image - Joint Photographic Experts Group (JPEG) 924 944 'jpg' => array( 925 'pattern' => '^\ xFF\xD8\xFF',945 'pattern' => '^\\xFF\\xD8\\xFF', 926 946 'group' => 'graphic', 927 947 'module' => 'jpg', … … 933 953 // PCD - still image - Kodak Photo CD 934 954 'pcd' => array( 935 'pattern' => '^.{2048}PCD_IPI\ x00',955 'pattern' => '^.{2048}PCD_IPI\\x00', 936 956 'group' => 'graphic', 937 957 'module' => 'pcd', … … 944 964 // PNG - still image - Portable Network Graphics (PNG) 945 965 'png' => array( 946 'pattern' => '^\ x89\x50\x4E\x47\x0D\x0A\x1A\x0A',966 'pattern' => '^\\x89\\x50\\x4E\\x47\\x0D\\x0A\\x1A\\x0A', 947 967 'group' => 'graphic', 948 968 'module' => 'png', … … 955 975 // SVG - still image - Scalable Vector Graphics (SVG) 956 976 'svg' => array( 957 'pattern' => '(<!DOCTYPE svg PUBLIC |xmlns="http: \/\/www\.w3\.org\/2000\/svg")',977 'pattern' => '(<!DOCTYPE svg PUBLIC |xmlns="http://www\\.w3\\.org/2000/svg")', 958 978 'group' => 'graphic', 959 979 'module' => 'svg', … … 966 986 // TIFF - still image - Tagged Information File Format (TIFF) 967 987 'tiff' => array( 968 'pattern' => '^(II\ x2A\x00|MM\x00\x2A)',988 'pattern' => '^(II\\x2A\\x00|MM\\x00\\x2A)', 969 989 'group' => 'graphic', 970 990 'module' => 'tiff', … … 977 997 // EFAX - still image - eFax (TIFF derivative) 978 998 'efax' => array( 979 'pattern' => '^\ xDC\xFE',999 'pattern' => '^\\xDC\\xFE', 980 1000 'group' => 'graphic', 981 1001 'module' => 'efax', … … 1001 1021 // RAR - data - RAR compressed data 1002 1022 'rar' => array( 1003 'pattern' => '^Rar\ !',1023 'pattern' => '^Rar\\!', 1004 1024 'group' => 'archive', 1005 1025 'module' => 'rar', … … 1011 1031 // SZIP - audio/data - SZIP compressed data 1012 1032 'szip' => array( 1013 'pattern' => '^SZ\ x0A\x04',1033 'pattern' => '^SZ\\x0A\\x04', 1014 1034 'group' => 'archive', 1015 1035 'module' => 'szip', … … 1021 1041 // TAR - data - TAR compressed data 1022 1042 'tar' => array( 1023 'pattern' => '^.{100}[0-9\ x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',1043 'pattern' => '^.{100}[0-9\\x20]{7}\\x00[0-9\\x20]{7}\\x00[0-9\\x20]{7}\\x00[0-9\\x20\\x00]{12}[0-9\\x20\\x00]{12}', 1024 1044 'group' => 'archive', 1025 1045 'module' => 'tar', … … 1031 1051 // GZIP - data - GZIP compressed data 1032 1052 'gz' => array( 1033 'pattern' => '^\ x1F\x8B\x08',1053 'pattern' => '^\\x1F\\x8B\\x08', 1034 1054 'group' => 'archive', 1035 1055 'module' => 'gzip', … … 1041 1061 // ZIP - data - ZIP compressed data 1042 1062 'zip' => array( 1043 'pattern' => '^PK\ x03\x04',1063 'pattern' => '^PK\\x03\\x04', 1044 1064 'group' => 'archive', 1045 1065 'module' => 'zip', … … 1054 1074 // PAR2 - data - Parity Volume Set Specification 2.0 1055 1075 'par2' => array ( 1056 'pattern' => '^PAR2\ x00PKT',1076 'pattern' => '^PAR2\\x00PKT', 1057 1077 'group' => 'misc', 1058 1078 'module' => 'par2', … … 1064 1084 // PDF - data - Portable Document Format 1065 1085 'pdf' => array( 1066 'pattern' => '^\ x25PDF',1086 'pattern' => '^\\x25PDF', 1067 1087 'group' => 'misc', 1068 1088 'module' => 'pdf', … … 1074 1094 // MSOFFICE - data - ZIP compressed data 1075 1095 'msoffice' => array( 1076 'pattern' => '^\ xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1', // D0CF11E == DOCFILE == Microsoft Office Document1096 'pattern' => '^\\xD0\\xCF\\x11\\xE0\\xA1\\xB1\\x1A\\xE1', // D0CF11E == DOCFILE == Microsoft Office Document 1077 1097 'group' => 'misc', 1078 1098 'module' => 'msoffice', … … 1115 1135 1116 1136 1117 if (preg_match('#\ .mp[123a]$#i', $filename)) {1137 if (preg_match('#\\.mp[123a]$#i', $filename)) { 1118 1138 // Too many mp3 encoders on the market put gabage in front of mpeg files 1119 1139 // use assume format on these if format detection failed … … 1122 1142 $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php'; 1123 1143 return $info; 1124 } elseif (preg_match(' /\.cue$/i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) {1144 } elseif (preg_match('#\\.cue$#i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) { 1125 1145 // there's not really a useful consistent "magic" at the beginning of .cue files to identify them 1126 1146 // so until I think of something better, just go by filename if all other format checks fail … … 1223 1243 } 1224 1244 1245 $this->CharConvert($this->info['tags'][$tag_name], $this->info[$comment_name]['encoding']); // only copy gets converted! 1246 1225 1247 if ($this->option_tags_html) { 1226 1248 foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) { 1227 $this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $ encoding);1249 $this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $this->info[$comment_name]['encoding']); 1228 1250 } 1229 1251 } 1230 1252 1231 $this->CharConvert($this->info['tags'][$tag_name], $encoding); // only copy gets converted!1232 1253 } 1233 1254 … … 1353 1374 if (!empty($VorbisCommentError)) { 1354 1375 1355 $this-> info['warning'][] = 'Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;1356 $this->info[$algorithm.'_data'] 1376 $this->warning('Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError); 1377 $this->info[$algorithm.'_data'] = false; 1357 1378 1358 1379 } else { … … 1583 1604 } 1584 1605 1606 public static function is_writable ($filename) { 1607 $ret = is_writable($filename); 1608 1609 if (!$ret) { 1610 $perms = fileperms($filename); 1611 $ret = ($perms & 0x0080) || ($perms & 0x0010) || ($perms & 0x0002); 1612 } 1613 1614 return $ret; 1615 } 1616 1585 1617 } 1586 1618 … … 1662 1694 throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10); 1663 1695 } 1664 return fread($this->getid3->fp, $bytes); 1696 1697 //return fread($this->getid3->fp, $bytes); 1698 /* 1699 * http://www.getid3.org/phpBB3/viewtopic.php?t=1930 1700 * "I found out that the root cause for the problem was how getID3 uses the PHP system function fread(). 1701 * It seems to assume that fread() would always return as many bytes as were requested. 1702 * However, according the PHP manual (http://php.net/manual/en/function.fread.php), this is the case only with regular local files, but not e.g. with Linux pipes. 1703 * The call may return only part of the requested data and a new call is needed to get more." 1704 */ 1705 $contents = ''; 1706 do { 1707 $part = fread($this->getid3->fp, $bytes); 1708 $partLength = strlen($part); 1709 $bytes -= $partLength; 1710 $contents .= $part; 1711 } while (($bytes > 0) && ($partLength > 0)); 1712 return $contents; 1665 1713 } 1666 1714 … … 1742 1790 // set up destination path 1743 1791 $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR); 1744 if (!is_dir($dir) || ! is_writable($dir)) { // check supplied directory1792 if (!is_dir($dir) || !getID3::is_writable($dir)) { // check supplied directory 1745 1793 throw new Exception('supplied path ('.$dir.') does not exist, or is not writable'); 1746 1794 }
Note: See TracChangeset
for help on using the changeset viewer.