Changeset 29734 for trunk/src/wp-includes/ID3/getid3.php
- Timestamp:
- 09/11/2014 07:06:33 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/getid3.php
r24696 r29734 4 4 // available at http://getid3.sourceforge.net // 5 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 6 7 ///////////////////////////////////////////////////////////////// 7 8 // // … … 18 19 define('GETID3_INCLUDEPATH', dirname(__FILE__).DIRECTORY_SEPARATOR); 19 20 } 21 // Workaround Bug #39923 (https://bugs.php.net/bug.php?id=39923) 22 if (!defined('IMG_JPG') && defined('IMAGETYPE_JPEG')) { 23 define('IMG_JPG', IMAGETYPE_JPEG); 24 } 20 25 21 26 // attempt to define temp dir as something flexible but reliable … … 24 29 $temp_dir = ''; 25 30 } 26 if (!$temp_dir && function_exists('sys_get_temp_dir')) { 27 // PHP v5.2.1+ 31 if (!$temp_dir) { 28 32 // sys_get_temp_dir() may give inaccessible temp dir, e.g. with open_basedir on virtual hosts 29 33 $temp_dir = sys_get_temp_dir(); 30 34 } 31 $temp_dir = realpath($temp_dir);35 $temp_dir = @realpath($temp_dir); // see https://github.com/JamesHeinrich/getID3/pull/10 32 36 $open_basedir = ini_get('open_basedir'); 33 37 if ($open_basedir) { … … 58 62 } 59 63 // $temp_dir = '/something/else/'; // feel free to override temp dir here if it works better for your system 60 define('GETID3_TEMP_DIR', $temp_dir); 64 if (!defined('GETID3_TEMP_DIR')) { 65 define('GETID3_TEMP_DIR', $temp_dir); 66 } 61 67 unset($open_basedir, $temp_dir); 62 68 … … 98 104 public $info; // Result array. 99 105 public $tempdir = GETID3_TEMP_DIR; 106 public $memory_limit = 0; 100 107 101 108 // Protected variables 102 109 protected $startup_error = ''; 103 110 protected $startup_warning = ''; 104 protected $memory_limit = 0; 105 106 const VERSION = '1.9.7-20130705'; 111 112 const VERSION = '1.9.8-20140511'; 107 113 const FREAD_BUFFER_SIZE = 32768; 108 114 … … 112 118 // public: constructor 113 119 public function __construct() { 114 115 // Check for PHP version116 $required_php_version = '5.0.5';117 if (version_compare(PHP_VERSION, $required_php_version, '<')) {118 $this->startup_error .= 'getID3() requires PHP v'.$required_php_version.' or higher - you are running v'.PHP_VERSION;119 return false;120 }121 120 122 121 // Check memory … … 262 261 263 262 // open local file 264 if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { 263 //if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { // see http://www.getid3.org/phpBB3/viewtopic.php?t=1720 264 if ((is_readable($filename) || file_exists($filename)) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { 265 265 // great 266 266 } else { 267 throw new getid3_exception('Could not open "'.$filename.'" (does not exist, or is not a file)'); 267 $errormessagelist = array(); 268 if (!is_readable($filename)) { 269 $errormessagelist[] = '!is_readable'; 270 } 271 if (!is_file($filename)) { 272 $errormessagelist[] = '!is_file'; 273 } 274 if (!file_exists($filename)) { 275 $errormessagelist[] = '!file_exists'; 276 } 277 if (empty($errormessagelist)) { 278 $errormessagelist[] = 'fopen failed'; 279 } 280 throw new getid3_exception('Could not open "'.$filename.'" ('.implode('; ', $errormessagelist).')'); 268 281 } 269 282 270 283 $this->info['filesize'] = filesize($filename); 271 284 // set redundant parameters - might be needed in some include file 272 $this->info['filename'] = basename($filename); 285 // filenames / filepaths in getID3 are always expressed with forward slashes (unix-style) for both Windows and other to try and minimize confusion 286 $filename = str_replace('\\', '/', $filename); 273 287 $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename))); 288 $this->info['filename'] = getid3_lib::mb_basename($filename); 274 289 $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename']; 275 290 … … 353 368 // ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier 354 369 if (!$this->option_tag_id3v2) { 355 fseek($this->fp, 0 , SEEK_SET);370 fseek($this->fp, 0); 356 371 $header = fread($this->fp, 10); 357 372 if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) { … … 364 379 365 380 // read 32 kb file data 366 fseek($this->fp, $this->info['avdataoffset'] , SEEK_SET);381 fseek($this->fp, $this->info['avdataoffset']); 367 382 $formattest = fread($this->fp, 32774); 368 383 … … 587 602 'module' => 'au', 588 603 'mime_type' => 'audio/basic', 604 ), 605 606 // AMR - audio - Adaptive Multi Rate 607 'amr' => array( 608 'pattern' => '^\x23\x21AMR\x0A', // #!AMR[0A] 609 'group' => 'audio', 610 'module' => 'amr', 611 'mime_type' => 'audio/amr', 589 612 ), 590 613 … … 1162 1185 'flac' => array('vorbiscomment' , 'UTF-8'), 1163 1186 'divxtag' => array('divx' , 'ISO-8859-1'), 1187 'iptc' => array('iptc' , 'ISO-8859-1'), 1164 1188 ); 1165 1189 } … … 1182 1206 } 1183 1207 if ($value) { 1184 $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value; 1208 if (!is_numeric($key)) { 1209 $this->info['tags'][trim($tag_name)][trim($tag_key)][$key] = $value; 1210 } else { 1211 $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value; 1212 } 1185 1213 } 1186 1214 } … … 1197 1225 if ($this->option_tags_html) { 1198 1226 foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) { 1199 foreach ($valuearray as $key => $value) { 1200 if (is_string($value)) { 1201 //$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding); 1202 $this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('�', '', trim(getid3_lib::MultiByteCharString2HTML($value, $encoding))); 1203 } else { 1204 $this->info['tags_html'][$tag_name][$tag_key][$key] = $value; 1205 } 1206 } 1227 $this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $encoding); 1207 1228 } 1208 1229 } … … 1260 1281 } 1261 1282 1262 1263 1283 public function getHashdata($algorithm) { 1264 1284 switch ($algorithm) { … … 1566 1586 1567 1587 1568 abstract class getid3_handler 1569 { 1588 abstract class getid3_handler { 1589 1590 /** 1591 * @var getID3 1592 */ 1570 1593 protected $getid3; // pointer 1571 1594 … … 1594 1617 public function AnalyzeString($string) { 1595 1618 // Enter string mode 1596 1619 $this->setStringMode($string); 1597 1620 1598 1621 // Save info … … 1635 1658 return substr($this->data_string, $this->data_string_position - $bytes, $bytes); 1636 1659 } 1637 1638 1660 $pos = $this->ftell() + $bytes; 1661 if (!getid3_lib::intValueSupported($pos)) { 1639 1662 throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10); 1640 1663 } 1641 1664 return fread($this->getid3->fp, $bytes); 1642 1665 } … … 1658 1681 } 1659 1682 return 0; 1660 1661 1662 1683 } else { 1684 $pos = $bytes; 1685 if ($whence == SEEK_CUR) { 1663 1686 $pos = $this->ftell() + $bytes; 1664 1665 $pos = $this-> info['filesize'] + $bytes;1666 1667 1687 } elseif ($whence == SEEK_END) { 1688 $pos = $this->getid3->info['filesize'] + $bytes; 1689 } 1690 if (!getid3_lib::intValueSupported($pos)) { 1668 1691 throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10); 1669 1692 } … … 1683 1706 } 1684 1707 1685 protected function error($text) 1686 { 1708 protected function error($text) { 1687 1709 $this->getid3->info['error'][] = $text; 1688 1710 … … 1690 1712 } 1691 1713 1692 protected function warning($text) 1693 { 1714 protected function warning($text) { 1694 1715 return $this->getid3->warning($text); 1695 1716 } 1696 1717 1697 protected function notice($text) 1698 { 1718 protected function notice($text) { 1699 1719 // does nothing for now 1700 1720 }
Note: See TracChangeset
for help on using the changeset viewer.