Changeset 46112 for trunk/src/wp-includes/ID3/module.tag.id3v1.php
- Timestamp:
- 09/14/2019 07:06:09 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/module.tag.id3v1.php
r41196 r46112 1 1 <?php 2 2 3 ///////////////////////////////////////////////////////////////// 3 4 /// getID3() by James Heinrich <info@getid3.org> // 4 // available at http://getid3.sourceforge.net // 5 // or http://www.getid3.org // 6 // also https://github.com/JamesHeinrich/getID3 // 7 ///////////////////////////////////////////////////////////////// 8 // See readme.txt for more details // 5 // available at https://github.com/JamesHeinrich/getID3 // 6 // or https://www.getid3.org // 7 // or http://getid3.sourceforge.net // 8 // see readme.txt for more details // 9 9 ///////////////////////////////////////////////////////////////// 10 10 // // … … 18 18 class getid3_id3v1 extends getid3_handler 19 19 { 20 20 /** 21 * @return bool 22 */ 21 23 public function Analyze() { 22 24 $info = &$this->getid3->info; … … 44 46 // If second-last byte of comment field is null and last byte of comment field is non-null 45 47 // then this is ID3v1.1 and the comment field is 28 bytes long and the 30th byte is the track number 46 if (($id3v1tag {125} === "\x00") && ($id3v1tag{126}!== "\x00")) {47 $ParsedID3v1['track ']= ord(substr($ParsedID3v1['comment'], 29, 1));48 $ParsedID3v1['comment'] = substr($ParsedID3v1['comment'], 0, 28);48 if (($id3v1tag[125] === "\x00") && ($id3v1tag[126] !== "\x00")) { 49 $ParsedID3v1['track_number'] = ord(substr($ParsedID3v1['comment'], 29, 1)); 50 $ParsedID3v1['comment'] = substr($ParsedID3v1['comment'], 0, 28); 49 51 } 50 52 $ParsedID3v1['comment'] = $this->cutfield($ParsedID3v1['comment']); … … 67 69 foreach ($ParsedID3v1['comments'] as $tag_key => $valuearray) { 68 70 foreach ($valuearray as $key => $value) { 69 if (preg_match('#^[\\x00-\\x40\\xA8\\ B8\\x80-\\xFF]+$#', $value)) {71 if (preg_match('#^[\\x00-\\x40\\xA8\\xB8\\x80-\\xFF]+$#', $value)) { 70 72 foreach (array('Windows-1251', 'KOI8-R') as $id3v1_bad_encoding) { 71 73 if (function_exists('mb_convert_encoding') && @mb_convert_encoding($value, $id3v1_bad_encoding, $id3v1_bad_encoding) === $value) { … … 90 92 (isset($ParsedID3v1['genre']) ? $this->LookupGenreID($ParsedID3v1['genre']) : false), 91 93 $ParsedID3v1['comment'], 92 (!empty($ParsedID3v1['track ']) ? $ParsedID3v1['track'] : ''));94 (!empty($ParsedID3v1['track_number']) ? $ParsedID3v1['track_number'] : '')); 93 95 $ParsedID3v1['padding_valid'] = true; 94 96 if ($id3v1tag !== $GoodFormatID3v1tag) { … … 125 127 } 126 128 129 /** 130 * @param string $str 131 * 132 * @return string 133 */ 127 134 public static function cutfield($str) { 128 135 return trim(substr($str, 0, strcspn($str, "\x00"))); 129 136 } 130 137 138 /** 139 * @param bool $allowSCMPXextended 140 * 141 * @return string[] 142 */ 131 143 public static function ArrayOfGenres($allowSCMPXextended=false) { 132 144 static $GenreLookup = array( … … 313 325 } 314 326 327 /** 328 * @param string $genreid 329 * @param bool $allowSCMPXextended 330 * 331 * @return string|false 332 */ 315 333 public static function LookupGenreName($genreid, $allowSCMPXextended=true) { 316 334 switch ($genreid) { … … 329 347 } 330 348 349 /** 350 * @param string $genre 351 * @param bool $allowSCMPXextended 352 * 353 * @return string|false 354 */ 331 355 public static function LookupGenreID($genre, $allowSCMPXextended=false) { 332 356 $GenreLookup = self::ArrayOfGenres($allowSCMPXextended); … … 340 364 } 341 365 366 /** 367 * @param string $OriginalGenre 368 * 369 * @return string|false 370 */ 342 371 public static function StandardiseID3v1GenreName($OriginalGenre) { 343 372 if (($GenreID = self::LookupGenreID($OriginalGenre)) !== false) { … … 347 376 } 348 377 378 /** 379 * @param string $title 380 * @param string $artist 381 * @param string $album 382 * @param string $year 383 * @param int $genreid 384 * @param string $comment 385 * @param int|string $track 386 * 387 * @return string 388 */ 349 389 public static function GenerateID3v1Tag($title, $artist, $album, $year, $genreid, $comment, $track='') { 350 390 $ID3v1Tag = 'TAG';
Note: See TracChangeset
for help on using the changeset viewer.