/lib/vendor/getid3-1.9.0/getid3/write.id3v2.php
PHP | 1230 lines | 882 code | 94 blank | 254 comment | 278 complexity | cfccc1e1b07fee2303968da292fb7c7a MD5 | raw file
Possible License(s): LGPL-3.0, GPL-2.0, ISC, AGPL-3.0, LGPL-2.1, BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- <?php
- /////////////////////////////////////////////////////////////////
- /// getID3() by James Heinrich <info@getid3.org> //
- // available at http://getid3.sourceforge.net //
- // or http://www.getid3.org //
- /////////////////////////////////////////////////////////////////
- // See readme.txt for more details //
- /////////////////////////////////////////////////////////////////
- /// //
- // write.id3v2.php //
- // module for writing ID3v2 tags //
- // dependencies: module.tag.id3v2.php //
- // ///
- /////////////////////////////////////////////////////////////////
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true);
- class getid3_write_id3v2
- {
- var $filename;
- var $tag_data;
- var $fread_buffer_size = 32768; // read buffer size in bytes
- var $paddedlength = 4096; // minimum length of ID3v2 tag in bytes
- var $majorversion = 3; // ID3v2 major version (2, 3 (recommended), 4)
- var $minorversion = 0; // ID3v2 minor version - always 0
- var $merge_existing_data = false; // if true, merge new data with existing tags; if false, delete old tag data and only write new tags
- var $id3v2_default_encodingid = 0; // default text encoding (ISO-8859-1) if not explicitly passed
- var $id3v2_use_unsynchronisation = false; // the specs say it should be TRUE, but most other ID3v2-aware programs are broken if unsynchronization is used, so by default don't use it.
- var $warnings = array(); // any non-critical errors will be stored here
- var $errors = array(); // any critical errors will be stored here
- function getid3_write_id3v2() {
- return true;
- }
- function WriteID3v2() {
- // File MUST be writeable - CHMOD(646) at least. It's best if the
- // directory is also writeable, because that method is both faster and less susceptible to errors.
- if (!empty($this->filename) && (is_writeable($this->filename) || (!file_exists($this->filename) && is_writeable(dirname($this->filename))))) {
- // Initialize getID3 engine
- $getID3 = new getID3;
- $OldThisFileInfo = $getID3->analyze($this->filename);
- if (!getid3_lib::intValueSupported($OldThisFileInfo['filesize'])) {
- $this->errors[] = 'Unable to write ID3v2 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
- fclose($fp_source);
- return false;
- }
- if ($this->merge_existing_data) {
- // merge with existing data
- if (!empty($OldThisFileInfo['id3v2'])) {
- $this->tag_data = $this->array_join_merge($OldThisFileInfo['id3v2'], $this->tag_data);
- }
- }
- $this->paddedlength = (isset($OldThisFileInfo['id3v2']['headerlength']) ? max($OldThisFileInfo['id3v2']['headerlength'], $this->paddedlength) : $this->paddedlength);
- if ($NewID3v2Tag = $this->GenerateID3v2Tag()) {
- if (file_exists($this->filename) && is_writeable($this->filename) && isset($OldThisFileInfo['id3v2']['headerlength']) && ($OldThisFileInfo['id3v2']['headerlength'] == strlen($NewID3v2Tag))) {
- // best and fastest method - insert-overwrite existing tag (padded to length of old tag if neccesary)
- if (file_exists($this->filename)) {
- if (is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'r+b'))) {
- rewind($fp);
- fwrite($fp, $NewID3v2Tag, strlen($NewID3v2Tag));
- fclose($fp);
- } else {
- $this->errors[] = 'Could not fopen("'.$this->filename.'", "r+b")';
- }
- } else {
- if (is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'wb'))) {
- rewind($fp);
- fwrite($fp, $NewID3v2Tag, strlen($NewID3v2Tag));
- fclose($fp);
- } else {
- $this->errors[] = 'Could not fopen("'.$this->filename.'", "wb")';
- }
- }
- } else {
- if ($tempfilename = tempnam(GETID3_TEMP_DIR, 'getID3')) {
- if (is_readable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'rb'))) {
- if (is_writable($tempfilename) && is_file($tempfilename) && ($fp_temp = fopen($tempfilename, 'wb'))) {
- fwrite($fp_temp, $NewID3v2Tag, strlen($NewID3v2Tag));
- rewind($fp_source);
- if (!empty($OldThisFileInfo['avdataoffset'])) {
- fseek($fp_source, $OldThisFileInfo['avdataoffset'], SEEK_SET);
- }
- while ($buffer = fread($fp_source, $this->fread_buffer_size)) {
- fwrite($fp_temp, $buffer, strlen($buffer));
- }
- fclose($fp_temp);
- fclose($fp_source);
- copy($tempfilename, $this->filename);
- unlink($tempfilename);
- return true;
- } else {
- $this->errors[] = 'Could not fopen("'.$tempfilename.'", "wb")';
- }
- fclose($fp_source);
- } else {
- $this->errors[] = 'Could not fopen("'.$this->filename.'", "rb")';
- }
- }
- return false;
- }
- } else {
- $this->errors[] = '$this->GenerateID3v2Tag() failed';
- }
- if (!empty($this->errors)) {
- return false;
- }
- return true;
- } else {
- $this->errors[] = 'WriteID3v2() failed: !is_writeable('.$this->filename.')';
- }
- return false;
- }
- function RemoveID3v2() {
- // File MUST be writeable - CHMOD(646) at least. It's best if the
- // directory is also writeable, because that method is both faster and less susceptible to errors.
- if (is_writeable(dirname($this->filename))) {
- // preferred method - only one copying operation, minimal chance of corrupting
- // original file if script is interrupted, but required directory to be writeable
- if (is_readable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'rb'))) {
- // Initialize getID3 engine
- $getID3 = new getID3;
- $OldThisFileInfo = $getID3->analyze($this->filename);
- if (!getid3_lib::intValueSupported($OldThisFileInfo['filesize'])) {
- $this->errors[] = 'Unable to remove ID3v2 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
- fclose($fp_source);
- return false;
- }
- rewind($fp_source);
- if ($OldThisFileInfo['avdataoffset'] !== false) {
- fseek($fp_source, $OldThisFileInfo['avdataoffset'], SEEK_SET);
- }
- if (is_writable($this->filename) && is_file($this->filename) && ($fp_temp = fopen($this->filename.'getid3tmp', 'w+b'))) {
- while ($buffer = fread($fp_source, $this->fread_buffer_size)) {
- fwrite($fp_temp, $buffer, strlen($buffer));
- }
- fclose($fp_temp);
- } else {
- $this->errors[] = 'Could not fopen("'.$this->filename.'getid3tmp", "w+b")';
- }
- fclose($fp_source);
- } else {
- $this->errors[] = 'Could not fopen("'.$this->filename.'", "rb")';
- }
- if (file_exists($this->filename)) {
- unlink($this->filename);
- }
- rename($this->filename.'getid3tmp', $this->filename);
- } elseif (is_writable($this->filename)) {
- // less desirable alternate method - double-copies the file, overwrites original file
- // and could corrupt source file if the script is interrupted or an error occurs.
- if (is_readable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'rb'))) {
- // Initialize getID3 engine
- $getID3 = new getID3;
- $OldThisFileInfo = $getID3->analyze($this->filename);
- if (!getid3_lib::intValueSupported($OldThisFileInfo['filesize'])) {
- $this->errors[] = 'Unable to remove ID3v2 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
- fclose($fp_source);
- return false;
- }
- rewind($fp_source);
- if ($OldThisFileInfo['avdataoffset'] !== false) {
- fseek($fp_source, $OldThisFileInfo['avdataoffset'], SEEK_SET);
- }
- if ($fp_temp = tmpfile()) {
- while ($buffer = fread($fp_source, $this->fread_buffer_size)) {
- fwrite($fp_temp, $buffer, strlen($buffer));
- }
- fclose($fp_source);
- if (is_writable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'wb'))) {
- rewind($fp_temp);
- while ($buffer = fread($fp_temp, $this->fread_buffer_size)) {
- fwrite($fp_source, $buffer, strlen($buffer));
- }
- fseek($fp_temp, -128, SEEK_END);
- fclose($fp_source);
- } else {
- $this->errors[] = 'Could not fopen("'.$this->filename.'", "wb")';
- }
- fclose($fp_temp);
- } else {
- $this->errors[] = 'Could not create tmpfile()';
- }
- } else {
- $this->errors[] = 'Could not fopen("'.$this->filename.'", "rb")';
- }
- } else {
- $this->errors[] = 'Directory and file both not writeable';
- }
- if (!empty($this->errors)) {
- return false;
- }
- return true;
- }
- function GenerateID3v2TagFlags($flags) {
- switch ($this->majorversion) {
- case 4:
- // %abcd0000
- $flag = (!empty($flags['unsynchronisation']) ? '1' : '0'); // a - Unsynchronisation
- $flag .= (!empty($flags['extendedheader'] ) ? '1' : '0'); // b - Extended header
- $flag .= (!empty($flags['experimental'] ) ? '1' : '0'); // c - Experimental indicator
- $flag .= (!empty($flags['footer'] ) ? '1' : '0'); // d - Footer present
- $flag .= '0000';
- break;
- case 3:
- // %abc00000
- $flag = (!empty($flags['unsynchronisation']) ? '1' : '0'); // a - Unsynchronisation
- $flag .= (!empty($flags['extendedheader'] ) ? '1' : '0'); // b - Extended header
- $flag .= (!empty($flags['experimental'] ) ? '1' : '0'); // c - Experimental indicator
- $flag .= '00000';
- break;
- case 2:
- // %ab000000
- $flag = (!empty($flags['unsynchronisation']) ? '1' : '0'); // a - Unsynchronisation
- $flag .= (!empty($flags['compression'] ) ? '1' : '0'); // b - Compression
- $flag .= '000000';
- break;
- default:
- return false;
- break;
- }
- return chr(bindec($flag));
- }
- function GenerateID3v2FrameFlags($TagAlter=false, $FileAlter=false, $ReadOnly=false, $Compression=false, $Encryption=false, $GroupingIdentity=false, $Unsynchronisation=false, $DataLengthIndicator=false) {
- switch ($this->majorversion) {
- case 4:
- // %0abc0000 %0h00kmnp
- $flag1 = '0';
- $flag1 .= $TagAlter ? '1' : '0'; // a - Tag alter preservation (true == discard)
- $flag1 .= $FileAlter ? '1' : '0'; // b - File alter preservation (true == discard)
- $flag1 .= $ReadOnly ? '1' : '0'; // c - Read only (true == read only)
- $flag1 .= '0000';
- $flag2 = '0';
- $flag2 .= $GroupingIdentity ? '1' : '0'; // h - Grouping identity (true == contains group information)
- $flag2 .= '00';
- $flag2 .= $Compression ? '1' : '0'; // k - Compression (true == compressed)
- $flag2 .= $Encryption ? '1' : '0'; // m - Encryption (true == encrypted)
- $flag2 .= $Unsynchronisation ? '1' : '0'; // n - Unsynchronisation (true == unsynchronised)
- $flag2 .= $DataLengthIndicator ? '1' : '0'; // p - Data length indicator (true == data length indicator added)
- break;
- case 3:
- // %abc00000 %ijk00000
- $flag1 = $TagAlter ? '1' : '0'; // a - Tag alter preservation (true == discard)
- $flag1 .= $FileAlter ? '1' : '0'; // b - File alter preservation (true == discard)
- $flag1 .= $ReadOnly ? '1' : '0'; // c - Read only (true == read only)
- $flag1 .= '00000';
- $flag2 = $Compression ? '1' : '0'; // i - Compression (true == compressed)
- $flag2 .= $Encryption ? '1' : '0'; // j - Encryption (true == encrypted)
- $flag2 .= $GroupingIdentity ? '1' : '0'; // k - Grouping identity (true == contains group information)
- $flag2 .= '00000';
- break;
- default:
- return false;
- break;
- }
- return chr(bindec($flag1)).chr(bindec($flag2));
- }
- function GenerateID3v2FrameData($frame_name, $source_data_array) {
- if (!getid3_id3v2::IsValidID3v2FrameName($frame_name, $this->majorversion)) {
- return false;
- }
- $framedata = '';
- if (($this->majorversion < 3) || ($this->majorversion > 4)) {
- $this->errors[] = 'Only ID3v2.3 and ID3v2.4 are supported in GenerateID3v2FrameData()';
- } else { // $this->majorversion 3 or 4
- switch ($frame_name) {
- case 'UFID':
- // 4.1 UFID Unique file identifier
- // Owner identifier <text string> $00
- // Identifier <up to 64 bytes binary data>
- if (strlen($source_data_array['data']) > 64) {
- $this->errors[] = 'Identifier not allowed to be longer than 64 bytes in '.$frame_name.' (supplied data was '.strlen($source_data_array['data']).' bytes long)';
- } else {
- $framedata .= str_replace("\x00", '', $source_data_array['ownerid'])."\x00";
- $framedata .= substr($source_data_array['data'], 0, 64); // max 64 bytes - truncate anything longer
- }
- break;
- case 'TXXX':
- // 4.2.2 TXXX User defined text information frame
- // Text encoding $xx
- // Description <text string according to encoding> $00 (00)
- // Value <text string according to encoding>
- $source_data_array['encodingid'] = (isset($source_data_array['encodingid']) ? $source_data_array['encodingid'] : $this->id3v2_default_encodingid);
- if (!$this->ID3v2IsValidTextEncoding($source_data_array['encodingid'], $this->majorversion)) {
- $this->errors[] = 'Invalid Text Encoding in '.$frame_name.' ('.$source_data_array['encodingid'].') for ID3v2.'.$this->majorversion;
- } else {
- $framedata .= chr($source_data_array['encodingid']);
- $framedata .= $source_data_array['description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
- $framedata .= $source_data_array['data'];
- }
- break;
- case 'WXXX':
- // 4.3.2 WXXX User defined URL link frame
- // Text encoding $xx
- // Description <text string according to encoding> $00 (00)
- // URL <text string>
- $source_data_array['encodingid'] = (isset($source_data_array['encodingid']) ? $source_data_array['encodingid'] : $this->id3v2_default_encodingid);
- if (!$this->ID3v2IsValidTextEncoding($source_data_array['encodingid'], $this->majorversion)) {
- $this->errors[] = 'Invalid Text Encoding in '.$frame_name.' ('.$source_data_array['encodingid'].') for ID3v2.'.$this->majorversion;
- } elseif (!isset($source_data_array['data']) || !$this->IsValidURL($source_data_array['data'], false, false)) {
- //$this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')';
- // probably should be an error, need to rewrite IsValidURL() to handle other encodings
- $this->warnings[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')';
- } else {
- $framedata .= chr($source_data_array['encodingid']);
- $framedata .= $source_data_array['description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
- $framedata .= $source_data_array['data'];
- }
- break;
- case 'IPLS':
- // 4.4 IPLS Involved people list (ID3v2.3 only)
- // Text encoding $xx
- // People list strings <textstrings>
- $source_data_array['encodingid'] = (isset($source_data_array['encodingid']) ? $source_data_array['encodingid'] : $this->id3v2_default_encodingid);
- if (!$this->ID3v2IsValidTextEncoding($source_data_array['encodingid'], $this->majorversion)) {
- $this->errors[] = 'Invalid Text Encoding in '.$frame_name.' ('.$source_data_array['encodingid'].') for ID3v2.'.$this->majorversion;
- } else {
- $framedata .= chr($source_data_array['encodingid']);
- $framedata .= $source_data_array['data'];
- }
- break;
- case 'MCDI':
- // 4.4 MCDI Music CD identifier
- // CD TOC <binary data>
- $framedata .= $source_data_array['data'];
- break;
- case 'ETCO':
- // 4.5 ETCO Event timing codes
- // Time stamp format $xx
- // Where time stamp format is:
- // $01 (32-bit value) MPEG frames from beginning of file
- // $02 (32-bit value) milliseconds from beginning of file
- // Followed by a list of key events in the following format:
- // Type of event $xx
- // Time stamp $xx (xx ...)
- // The 'Time stamp' is set to zero if directly at the beginning of the sound
- // or after the previous event. All events MUST be sorted in chronological order.
- if (($source_data_array['timestampformat'] > 2) || ($source_data_array['timestampformat'] < 1)) {
- $this->errors[] = 'Invalid Time Stamp Format byte in '.$frame_name.' ('.$source_data_array['timestampformat'].')';
- } else {
- $framedata .= chr($source_data_array['timestampformat']);
- foreach ($source_data_array as $key => $val) {
- if (!$this->ID3v2IsValidETCOevent($val['typeid'])) {
- $this->errors[] = 'Invalid Event Type byte in '.$frame_name.' ('.$val['typeid'].')';
- } elseif (($key != 'timestampformat') && ($key != 'flags')) {
- if (($val['timestamp'] > 0) && ($previousETCOtimestamp >= $val['timestamp'])) {
- // The 'Time stamp' is set to zero if directly at the beginning of the sound
- // or after the previous event. All events MUST be sorted in chronological order.
- $this->errors[] = 'Out-of-order timestamp in '.$frame_name.' ('.$val['timestamp'].') for Event Type ('.$val['typeid'].')';
- } else {
- $framedata .= chr($val['typeid']);
- $framedata .= getid3_lib::BigEndian2String($val['timestamp'], 4, false);
- }
- }
- }
- }
- break;
- case 'MLLT':
- // 4.6 MLLT MPEG location lookup table
- // MPEG frames between reference $xx xx
- // Bytes between reference $xx xx xx
- // Milliseconds between reference $xx xx xx
- // Bits for bytes deviation $xx
- // Bits for milliseconds dev. $xx
- // Then for every reference the following data is included;
- // Deviation in bytes %xxx....
- // Deviation in milliseconds %xxx....
- if (($source_data_array['framesbetweenreferences'] > 0) && ($source_data_array['framesbetweenreferences'] <= 65535)) {
- $framedata .= getid3_lib::BigEndian2String($source_data_array['framesbetweenreferences'], 2, false);
- } else {
- $this->errors[] = 'Invalid MPEG Frames Between References in '.$frame_name.' ('.$source_data_array['framesbetweenreferences'].')';
- }
- if (($source_data_array['bytesbetweenreferences'] > 0) && ($source_data_array['bytesbetweenreferences'] <= 16777215)) {
- $framedata .= getid3_lib::BigEndian2String($source_data_array['bytesbetweenreferences'], 3, false);
- } else {
- $this->errors[] = 'Invalid bytes Between References in '.$frame_name.' ('.$source_data_array['bytesbetweenreferences'].')';
- }
- if (($source_data_array['msbetweenreferences'] > 0) && ($source_data_array['msbetweenreferences'] <= 16777215)) {
- $framedata .= getid3_lib::BigEndian2String($source_data_array['msbetweenreferences'], 3, false);
- } else {
- $this->errors[] = 'Invalid Milliseconds Between References in '.$frame_name.' ('.$source_data_array['msbetweenreferences'].')';
- }
- if (!$this->IsWithinBitRange($source_data_array['bitsforbytesdeviation'], 8, false)) {
- if (($source_data_array['bitsforbytesdeviation'] % 4) == 0) {
- $framedata .= chr($source_data_array['bitsforbytesdeviation']);
- } else {
- $this->errors[] = 'Bits For Bytes Deviation in '.$frame_name.' ('.$source_data_array['bitsforbytesdeviation'].') must be a multiple of 4.';
- }
- } else {
- $this->errors[] = 'Invalid Bits For Bytes Deviation in '.$frame_name.' ('.$source_data_array['bitsforbytesdeviation'].')';
- }
- if (!$this->IsWithinBitRange($source_data_array['bitsformsdeviation'], 8, false)) {
- if (($source_data_array['bitsformsdeviation'] % 4) == 0) {
- $framedata .= chr($source_data_array['bitsformsdeviation']);
- } else {
- $this->errors[] = 'Bits For Milliseconds Deviation in '.$frame_name.' ('.$source_data_array['bitsforbytesdeviation'].') must be a multiple of 4.';
- }
- } else {
- $this->errors[] = 'Invalid Bits For Milliseconds Deviation in '.$frame_name.' ('.$source_data_array['bitsformsdeviation'].')';
- }
- foreach ($source_data_array as $key => $val) {
- if (($key != 'framesbetweenreferences') && ($key != 'bytesbetweenreferences') && ($key != 'msbetweenreferences') && ($key != 'bitsforbytesdeviation') && ($key != 'bitsformsdeviation') && ($key != 'flags')) {
- $unwrittenbitstream .= str_pad(getid3_lib::Dec2Bin($val['bytedeviation']), $source_data_array['bitsforbytesdeviation'], '0', STR_PAD_LEFT);
- $unwrittenbitstream .= str_pad(getid3_lib::Dec2Bin($val['msdeviation']), $source_data_array['bitsformsdeviation'], '0', STR_PAD_LEFT);
- }
- }
- for ($i = 0; $i < strlen($unwrittenbitstream); $i += 8) {
- $highnibble = bindec(substr($unwrittenbitstream, $i, 4)) << 4;
- $lownibble = bindec(substr($unwrittenbitstream, $i + 4, 4));
- $framedata .= chr($highnibble & $lownibble);
- }
- break;
- case 'SYTC':
- // 4.7 SYTC Synchronised tempo codes
- // Time stamp format $xx
- // Tempo data <binary data>
- // Where time stamp format is:
- // $01 (32-bit value) MPEG frames from beginning of file
- // $02 (32-bit value) milliseconds from beginning of file
- if (($source_data_array['timestampformat'] > 2) || ($source_data_array['timestampformat'] < 1)) {
- $this->errors[] = 'Invalid Time Stamp Format byte in '.$frame_name.' ('.$source_data_array['timestampformat'].')';
- } else {
- $framedata .= chr($source_data_array['timestampformat']);
- foreach ($source_data_array as $key => $val) {
- if (!$this->ID3v2IsValidETCOevent($val['typeid'])) {
- $this->errors[] = 'Invalid Event Type byte in '.$frame_name.' ('.$val['typeid'].')';
- } elseif (($key != 'timestampformat') && ($key != 'flags')) {
- if (($val['tempo'] < 0) || ($val['tempo'] > 510)) {
- $this->errors[] = 'Invalid Tempo (max = 510) in '.$frame_name.' ('.$val['tempo'].') at timestamp ('.$val['timestamp'].')';
- } else {
- if ($val['tempo'] > 255) {
- $framedata .= chr(255);
- $val['tempo'] -= 255;
- }
- $framedata .= chr($val['tempo']);
- $framedata .= getid3_lib::BigEndian2String($val['timestamp'], 4, false);
- }
- }
- }
- }
- break;
- case 'USLT':
- // 4.8 USLT Unsynchronised lyric/text transcription
- // Text encoding $xx
- // Language $xx xx xx
- // Content descriptor <text string according to encoding> $00 (00)
- // Lyrics/text <full text string according to encoding>
- $source_data_array['encodingid'] = (isset($source_data_array['encodingid']) ? $source_data_array['encodingid'] : $this->id3v2_default_encodingid);
- if (!$this->ID3v2IsValidTextEncoding($source_data_array['encodingid'])) {
- $this->errors[] = 'Invalid Text Encoding in '.$frame_name.' ('.$source_data_array['encodingid'].') for ID3v2.'.$this->majorversion;
- } elseif (getid3_id3v2::LanguageLookup($source_data_array['language'], true) == '') {
- $this->errors[] = 'Invalid Language in '.$frame_name.' ('.$source_data_array['language'].')';
- } else {
- $framedata .= chr($source_data_array['encodingid']);
- $framedata .= strtolower($source_data_array['language']);
- $framedata .= $source_data_array['description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
- $framedata .= $source_data_array['data'];
- }
- break;
- case 'SYLT':
- // 4.9 SYLT Synchronised lyric/text
- // Text encoding $xx
- // Language $xx xx xx
- // Time stamp format $xx
- // $01 (32-bit value) MPEG frames from beginning of file
- // $02 (32-bit value) milliseconds from beginning of file
- // Content type $xx
- // Content descriptor <text string according to encoding> $00 (00)
- // Terminated text to be synced (typically a syllable)
- // Sync identifier (terminator to above string) $00 (00)
- // Time stamp $xx (xx ...)
- $source_data_array['encodingid'] = (isset($source_data_array['encodingid']) ? $source_data_array['encodingid'] : $this->id3v2_default_encodingid);
- if (!$this->ID3v2IsValidTextEncoding($source_data_array['encodingid'])) {
- $this->errors[] = 'Invalid Text Encoding in '.$frame_name.' ('.$source_data_array['encodingid'].') for ID3v2.'.$this->majorversion;
- } elseif (getid3_id3v2::LanguageLookup($source_data_array['language'], true) == '') {
- $this->errors[] = 'Invalid Language in '.$frame_name.' ('.$source_data_array['language'].')';
- } elseif (($source_data_array['timestampformat'] > 2) || ($source_data_array['timestampformat'] < 1)) {
- $this->errors[] = 'Invalid Time Stamp Format byte in '.$frame_name.' ('.$source_data_array['timestampformat'].')';
- } elseif (!$this->ID3v2IsValidSYLTtype($source_data_array['contenttypeid'])) {
- $this->errors[] = 'Invalid Content Type byte in '.$frame_name.' ('.$source_data_array['contenttypeid'].')';
- } elseif (!is_array($source_data_array['data'])) {
- $this->errors[] = 'Invalid Lyric/Timestamp data in '.$frame_name.' (must be an array)';
- } else {
- $framedata .= chr($source_data_array['encodingid']);
- $framedata .= strtolower($source_data_array['language']);
- $framedata .= chr($source_data_array['timestampformat']);
- $framedata .= chr($source_data_array['contenttypeid']);
- $framedata .= $source_data_array['description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
- ksort($source_data_array['data']);
- foreach ($source_data_array['data'] as $key => $val) {
- $framedata .= $val['data'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
- $framedata .= getid3_lib::BigEndian2String($val['timestamp'], 4, false);
- }
- }
- break;
- case 'COMM':
- // 4.10 COMM Comments
- // Text encoding $xx
- // Language $xx xx xx
- // Short content descrip. <text string according to encoding> $00 (00)
- // The actual text <full text string according to encoding>
- $source_data_array['encodingid'] = (isset($source_data_array['encodingid']) ? $source_data_array['encodingid'] : $this->id3v2_default_encodingid);
- if (!$this->ID3v2IsValidTextEncoding($source_data_array['encodingid'])) {
- $this->errors[] = 'Invalid Text Encoding in '.$frame_name.' ('.$source_data_array['encodingid'].') for ID3v2.'.$this->majorversion;
- } elseif (getid3_id3v2::LanguageLookup($source_data_array['language'], true) == '') {
- $this->errors[] = 'Invalid Language in '.$frame_name.' ('.$source_data_array['language'].')';
- } else {
- $framedata .= chr($source_data_array['encodingid']);
- $framedata .= strtolower($source_data_array['language']);
- $framedata .= $source_data_array['description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
- $framedata .= $source_data_array['data'];
- }
- break;
- case 'RVA2':
- // 4.11 RVA2 Relative volume adjustment (2) (ID3v2.4+ only)
- // Identification <text string> $00
- // The 'identification' string is used to identify the situation and/or
- // device where this adjustment should apply. The following is then
- // repeated for every channel:
- // Type of channel $xx
- // Volume adjustment $xx xx
- // Bits representing peak $xx
- // Peak volume $xx (xx ...)
- $framedata .= str_replace("\x00", '', $source_data_array['description'])."\x00";
- foreach ($source_data_array as $key => $val) {
- if ($key != 'description') {
- $framedata .= chr($val['channeltypeid']);
- $framedata .= getid3_lib::BigEndian2String($val['volumeadjust'], 2, false, true); // signed 16-bit
- if (!$this->IsWithinBitRange($source_data_array['bitspeakvolume'], 8, false)) {
- $framedata .= chr($val['bitspeakvolume']);
- if ($val['bitspeakvolume'] > 0) {
- $framedata .= getid3_lib::BigEndian2String($val['peakvolume'], ceil($val['bitspeakvolume'] / 8), false, false);
- }
- } else {
- $this->errors[] = 'Invalid Bits Representing Peak Volume in '.$frame_name.' ('.$val['bitspeakvolume'].') (range = 0 to 255)';
- }
- }
- }
- break;
- case 'RVAD':
- // 4.12 RVAD Relative volume adjustment (ID3v2.3 only)
- // Increment/decrement %00fedcba
- // Bits used for volume descr. $xx
- // Relative volume change, right $xx xx (xx ...) // a
- // Relative volume change, left $xx xx (xx ...) // b
- // Peak volume right $xx xx (xx ...)
- // Peak volume left $xx xx (xx ...)
- // Relative volume change, right back $xx xx (xx ...) // c
- // Relative volume change, left back $xx xx (xx ...) // d
- // Peak volume right back $xx xx (xx ...)
- // Peak volume left back $xx xx (xx ...)
- // Relative volume change, center $xx xx (xx ...) // e
- // Peak volume center $xx xx (xx ...)
- // Relative volume change, bass $xx xx (xx ...) // f
- // Peak volume bass $xx xx (xx ...)
- if (!$this->IsWithinBitRange($source_data_array['bitsvolume'], 8, false)) {
- $this->errors[] = 'Invalid Bits For Volume Description byte in '.$frame_name.' ('.$source_data_array['bitsvolume'].') (range = 1 to 255)';
- } else {
- $incdecflag .= '00';
- $incdecflag .= $source_data_array['incdec']['right'] ? '1' : '0'; // a - Relative volume change, right
- $incdecflag .= $source_data_array['incdec']['left'] ? '1' : '0'; // b - Relative volume change, left
- $incdecflag .= $source_data_array['incdec']['rightrear'] ? '1' : '0'; // c - Relative volume change, right back
- $incdecflag .= $source_data_array['incdec']['leftrear'] ? '1' : '0'; // d - Relative volume change, left back
- $incdecflag .= $source_data_array['incdec']['center'] ? '1' : '0'; // e - Relative volume change, center
- $incdecflag .= $source_data_array['incdec']['bass'] ? '1' : '0'; // f - Relative volume change, bass
- $framedata .= chr(bindec($incdecflag));
- $framedata .= chr($source_data_array['bitsvolume']);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['volumechange']['right'], ceil($source_data_array['bitsvolume'] / 8), false);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['volumechange']['left'], ceil($source_data_array['bitsvolume'] / 8), false);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['peakvolume']['right'], ceil($source_data_array['bitsvolume'] / 8), false);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['peakvolume']['left'], ceil($source_data_array['bitsvolume'] / 8), false);
- if ($source_data_array['volumechange']['rightrear'] || $source_data_array['volumechange']['leftrear'] ||
- $source_data_array['peakvolume']['rightrear'] || $source_data_array['peakvolume']['leftrear'] ||
- $source_data_array['volumechange']['center'] || $source_data_array['peakvolume']['center'] ||
- $source_data_array['volumechange']['bass'] || $source_data_array['peakvolume']['bass']) {
- $framedata .= getid3_lib::BigEndian2String($source_data_array['volumechange']['rightrear'], ceil($source_data_array['bitsvolume']/8), false);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['volumechange']['leftrear'], ceil($source_data_array['bitsvolume']/8), false);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['peakvolume']['rightrear'], ceil($source_data_array['bitsvolume']/8), false);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['peakvolume']['leftrear'], ceil($source_data_array['bitsvolume']/8), false);
- }
- if ($source_data_array['volumechange']['center'] || $source_data_array['peakvolume']['center'] ||
- $source_data_array['volumechange']['bass'] || $source_data_array['peakvolume']['bass']) {
- $framedata .= getid3_lib::BigEndian2String($source_data_array['volumechange']['center'], ceil($source_data_array['bitsvolume']/8), false);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['peakvolume']['center'], ceil($source_data_array['bitsvolume']/8), false);
- }
- if ($source_data_array['volumechange']['bass'] || $source_data_array['peakvolume']['bass']) {
- $framedata .= getid3_lib::BigEndian2String($source_data_array['volumechange']['bass'], ceil($source_data_array['bitsvolume']/8), false);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['peakvolume']['bass'], ceil($source_data_array['bitsvolume']/8), false);
- }
- }
- break;
- case 'EQU2':
- // 4.12 EQU2 Equalisation (2) (ID3v2.4+ only)
- // Interpolation method $xx
- // $00 Band
- // $01 Linear
- // Identification <text string> $00
- // The following is then repeated for every adjustment point
- // Frequency $xx xx
- // Volume adjustment $xx xx
- if (($source_data_array['interpolationmethod'] < 0) || ($source_data_array['interpolationmethod'] > 1)) {
- $this->errors[] = 'Invalid Interpolation Method byte in '.$frame_name.' ('.$source_data_array['interpolationmethod'].') (valid = 0 or 1)';
- } else {
- $framedata .= chr($source_data_array['interpolationmethod']);
- $framedata .= str_replace("\x00", '', $source_data_array['description'])."\x00";
- foreach ($source_data_array['data'] as $key => $val) {
- $framedata .= getid3_lib::BigEndian2String(intval(round($key * 2)), 2, false);
- $framedata .= getid3_lib::BigEndian2String($val, 2, false, true); // signed 16-bit
- }
- }
- break;
- case 'EQUA':
- // 4.12 EQUA Equalisation (ID3v2.3 only)
- // Adjustment bits $xx
- // This is followed by 2 bytes + ('adjustment bits' rounded up to the
- // nearest byte) for every equalisation band in the following format,
- // giving a frequency range of 0 - 32767Hz:
- // Increment/decrement %x (MSB of the Frequency)
- // Frequency (lower 15 bits)
- // Adjustment $xx (xx ...)
- if (!$this->IsWithinBitRange($source_data_array['bitsvolume'], 8, false)) {
- $this->errors[] = 'Invalid Adjustment Bits byte in '.$frame_name.' ('.$source_data_array['bitsvolume'].') (range = 1 to 255)';
- } else {
- $framedata .= chr($source_data_array['adjustmentbits']);
- foreach ($source_data_array as $key => $val) {
- if ($key != 'bitsvolume') {
- if (($key > 32767) || ($key < 0)) {
- $this->errors[] = 'Invalid Frequency in '.$frame_name.' ('.$key.') (range = 0 to 32767)';
- } else {
- if ($val >= 0) {
- // put MSB of frequency to 1 if increment, 0 if decrement
- $key |= 0x8000;
- }
- $framedata .= getid3_lib::BigEndian2String($key, 2, false);
- $framedata .= getid3_lib::BigEndian2String($val, ceil($source_data_array['adjustmentbits'] / 8), false);
- }
- }
- }
- }
- break;
- case 'RVRB':
- // 4.13 RVRB Reverb
- // Reverb left (ms) $xx xx
- // Reverb right (ms) $xx xx
- // Reverb bounces, left $xx
- // Reverb bounces, right $xx
- // Reverb feedback, left to left $xx
- // Reverb feedback, left to right $xx
- // Reverb feedback, right to right $xx
- // Reverb feedback, right to left $xx
- // Premix left to right $xx
- // Premix right to left $xx
- if (!$this->IsWithinBitRange($source_data_array['left'], 16, false)) {
- $this->errors[] = 'Invalid Reverb Left in '.$frame_name.' ('.$source_data_array['left'].') (range = 0 to 65535)';
- } elseif (!$this->IsWithinBitRange($source_data_array['right'], 16, false)) {
- $this->errors[] = 'Invalid Reverb Left in '.$frame_name.' ('.$source_data_array['right'].') (range = 0 to 65535)';
- } elseif (!$this->IsWithinBitRange($source_data_array['bouncesL'], 8, false)) {
- $this->errors[] = 'Invalid Reverb Bounces, Left in '.$frame_name.' ('.$source_data_array['bouncesL'].') (range = 0 to 255)';
- } elseif (!$this->IsWithinBitRange($source_data_array['bouncesR'], 8, false)) {
- $this->errors[] = 'Invalid Reverb Bounces, Right in '.$frame_name.' ('.$source_data_array['bouncesR'].') (range = 0 to 255)';
- } elseif (!$this->IsWithinBitRange($source_data_array['feedbackLL'], 8, false)) {
- $this->errors[] = 'Invalid Reverb Feedback, Left-To-Left in '.$frame_name.' ('.$source_data_array['feedbackLL'].') (range = 0 to 255)';
- } elseif (!$this->IsWithinBitRange($source_data_array['feedbackLR'], 8, false)) {
- $this->errors[] = 'Invalid Reverb Feedback, Left-To-Right in '.$frame_name.' ('.$source_data_array['feedbackLR'].') (range = 0 to 255)';
- } elseif (!$this->IsWithinBitRange($source_data_array['feedbackRR'], 8, false)) {
- $this->errors[] = 'Invalid Reverb Feedback, Right-To-Right in '.$frame_name.' ('.$source_data_array['feedbackRR'].') (range = 0 to 255)';
- } elseif (!$this->IsWithinBitRange($source_data_array['feedbackRL'], 8, false)) {
- $this->errors[] = 'Invalid Reverb Feedback, Right-To-Left in '.$frame_name.' ('.$source_data_array['feedbackRL'].') (range = 0 to 255)';
- } elseif (!$this->IsWithinBitRange($source_data_array['premixLR'], 8, false)) {
- $this->errors[] = 'Invalid Premix, Left-To-Right in '.$frame_name.' ('.$source_data_array['premixLR'].') (range = 0 to 255)';
- } elseif (!$this->IsWithinBitRange($source_data_array['premixRL'], 8, false)) {
- $this->errors[] = 'Invalid Premix, Right-To-Left in '.$frame_name.' ('.$source_data_array['premixRL'].') (range = 0 to 255)';
- } else {
- $framedata .= getid3_lib::BigEndian2String($source_data_array['left'], 2, false);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['right'], 2, false);
- $framedata .= chr($source_data_array['bouncesL']);
- $framedata .= chr($source_data_array['bouncesR']);
- $framedata .= chr($source_data_array['feedbackLL']);
- $framedata .= chr($source_data_array['feedbackLR']);
- $framedata .= chr($source_data_array['feedbackRR']);
- $framedata .= chr($source_data_array['feedbackRL']);
- $framedata .= chr($source_data_array['premixLR']);
- $framedata .= chr($source_data_array['premixRL']);
- }
- break;
- case 'APIC':
- // 4.14 APIC Attached picture
- // Text encoding $xx
- // MIME type <text string> $00
- // Picture type $xx
- // Description <text string according to encoding> $00 (00)
- // Picture data <binary data>
- $source_data_array['encodingid'] = (isset($source_data_array['encodingid']) ? $source_data_array['encodingid'] : $this->id3v2_default_encodingid);
- if (!$this->ID3v2IsValidTextEncoding($source_data_array['encodingid'])) {
- $this->errors[] = 'Invalid Text Encoding in '.$frame_name.' ('.$source_data_array['encodingid'].') for ID3v2.'.$this->majorversion;
- } elseif (!$this->ID3v2IsValidAPICpicturetype($source_data_array['picturetypeid'])) {
- $this->errors[] = 'Invalid Picture Type byte in '.$frame_name.' ('.$source_data_array['picturetypeid'].') for ID3v2.'.$this->majorversion;
- } elseif (($this->majorversion >= 3) && (!$this->ID3v2IsValidAPICimageformat($source_data_array['mime']))) {
- $this->errors[] = 'Invalid MIME Type in '.$frame_name.' ('.$source_data_array['mime'].') for ID3v2.'.$this->majorversion;
- } elseif (($source_data_array['mime'] == '-->') && (!$this->IsValidURL($source_data_array['data'], false, false))) {
- //$this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')';
- // probably should be an error, need to rewrite IsValidURL() to handle other encodings
- $this->warnings[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')';
- } else {
- $framedata .= chr($source_data_array['encodingid']);
- $framedata .= str_replace("\x00", '', $source_data_array['mime'])."\x00";
- $framedata .= chr($source_data_array['picturetypeid']);
- $framedata .= (!empty($source_data_array['description']) ? $source_data_array['description'] : '').getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
- $framedata .= $source_data_array['data'];
- }
- break;
- case 'GEOB':
- // 4.15 GEOB General encapsulated object
- // Text encoding $xx
- // MIME type <text string> $00
- // Filename <text string according to encoding> $00 (00)
- // Content description <text string according to encoding> $00 (00)
- // Encapsulated object <binary data>
- $source_data_array['encodingid'] = (isset($source_data_array['encodingid']) ? $source_data_array['encodingid'] : $this->id3v2_default_encodingid);
- if (!$this->ID3v2IsValidTextEncoding($source_data_array['encodingid'])) {
- $this->errors[] = 'Invalid Text Encoding in '.$frame_name.' ('.$source_data_array['encodingid'].') for ID3v2.'.$this->majorversion;
- } elseif (!$this->IsValidMIMEstring($source_data_array['mime'])) {
- $this->errors[] = 'Invalid MIME Type in '.$frame_name.' ('.$source_data_array['mime'].')';
- } elseif (!$source_data_array['description']) {
- $this->errors[] = 'Missing Description in '.$frame_name;
- } else {
- $framedata .= chr($source_data_array['encodingid']);
- $framedata .= str_replace("\x00", '', $source_data_array['mime'])."\x00";
- $framedata .= $source_data_array['filename'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
- $framedata .= $source_data_array['description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array['encodingid']);
- $framedata .= $source_data_array['data'];
- }
- break;
- case 'PCNT':
- // 4.16 PCNT Play counter
- // When the counter reaches all one's, one byte is inserted in
- // front of the counter thus making the counter eight bits bigger
- // Counter $xx xx xx xx (xx ...)
- $framedata .= getid3_lib::BigEndian2String($source_data_array['data'], 4, false);
- break;
- case 'POPM':
- // 4.17 POPM Popularimeter
- // When the counter reaches all one's, one byte is inserted in
- // front of the counter thus making the counter eight bits bigger
- // Email to user <text string> $00
- // Rating $xx
- // Counter $xx xx xx xx (xx ...)
- if (!$this->IsWithinBitRange($source_data_array['rating'], 8, false)) {
- $this->errors[] = 'Invalid Rating byte in '.$frame_name.' ('.$source_data_array['rating'].') (range = 0 to 255)';
- } elseif (!IsValidEmail($source_data_array['email'])) {
- $this->errors[] = 'Invalid Email in '.$frame_name.' ('.$source_data_array['email'].')';
- } else {
- $framedata .= str_replace("\x00", '', $source_data_array['email'])."\x00";
- $framedata .= chr($source_data_array['rating']);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['data'], 4, false);
- }
- break;
- case 'RBUF':
- // 4.18 RBUF Recommended buffer size
- // Buffer size $xx xx xx
- // Embedded info flag %0000000x
- // Offset to next tag $xx xx xx xx
- if (!$this->IsWithinBitRange($source_data_array['buffersize'], 24, false)) {
- $this->errors[] = 'Invalid Buffer Size in '.$frame_name;
- } elseif (!$this->IsWithinBitRange($source_data_array['nexttagoffset'], 32, false)) {
- $this->errors[] = 'Invalid Offset To Next Tag in '.$frame_name;
- } else {
- $framedata .= getid3_lib::BigEndian2String($source_data_array['buffersize'], 3, false);
- $flag .= '0000000';
- $flag .= $source_data_array['flags']['embededinfo'] ? '1' : '0';
- $framedata .= chr(bindec($flag));
- $framedata .= getid3_lib::BigEndian2String($source_data_array['nexttagoffset'], 4, false);
- }
- break;
- case 'AENC':
- // 4.19 AENC Audio encryption
- // Owner identifier <text string> $00
- // Preview start $xx xx
- // Preview length $xx xx
- // Encryption info <binary data>
- if (!$this->IsWithinBitRange($source_data_array['previewstart'], 16, false)) {
- $this->errors[] = 'Invalid Preview Start in '.$frame_name.' ('.$source_data_array['previewstart'].')';
- } elseif (!$this->IsWithinBitRange($source_data_array['previewlength'], 16, false)) {
- $this->errors[] = 'Invalid Preview Length in '.$frame_name.' ('.$source_data_array['previewlength'].')';
- } else {
- $framedata .= str_replace("\x00", '', $source_data_array['ownerid'])."\x00";
- $framedata .= getid3_lib::BigEndian2String($source_data_array['previewstart'], 2, false);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['previewlength'], 2, false);
- $framedata .= $source_data_array['encryptioninfo'];
- }
- break;
- case 'LINK':
- // 4.20 LINK Linked information
- // Frame identifier $xx xx xx xx
- // URL <text string> $00
- // ID and additional data <text string(s)>
- if (!getid3_id3v2::IsValidID3v2FrameName($source_data_array['frameid'], $this->majorversion)) {
- $this->errors[] = 'Invalid Frame Identifier in '.$frame_name.' ('.$source_data_array['frameid'].')';
- } elseif (!$this->IsValidURL($source_data_array['data'], true, false)) {
- //$this->errors[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')';
- // probably should be an error, need to rewrite IsValidURL() to handle other encodings
- $this->warnings[] = 'Invalid URL in '.$frame_name.' ('.$source_data_array['data'].')';
- } elseif ((($source_data_array['frameid'] == 'AENC') || ($source_data_array['frameid'] == 'APIC') || ($source_data_array['frameid'] == 'GEOB') || ($source_data_array['frameid'] == 'TXXX')) && ($source_data_array['additionaldata'] == '')) {
- $this->errors[] = 'Content Descriptor must be specified as additional data for Frame Identifier of '.$source_data_array['frameid'].' in '.$frame_name;
- } elseif (($source_data_array['frameid'] == 'USER') && (getid3_id3v2::LanguageLookup($source_data_array['additionaldata'], true) == '')) {
- $this->errors[] = 'Language must be specified as additional data for Frame Identifier of '.$source_data_array['frameid'].' in '.$frame_name;
- } elseif (($source_data_array['frameid'] == 'PRIV') && ($source_data_array['additionaldata'] == '')) {
- $this->errors[] = 'Owner Identifier must be specified as additional data for Frame Identifier of '.$source_data_array['frameid'].' in '.$frame_name;
- } elseif ((($source_data_array['frameid'] == 'COMM') || ($source_data_array['frameid'] == 'SYLT') || ($source_data_array['frameid'] == 'USLT')) && ((getid3_id3v2::LanguageLookup(substr($source_data_array['additionaldata'], 0, 3), true) == '') || (substr($source_data_array['additionaldata'], 3) == ''))) {
- $this->errors[] = 'Language followed by Content Descriptor must be specified as additional data for Frame Identifier of '.$source_data_array['frameid'].' in '.$frame_name;
- } else {
- $framedata .= $source_data_array['frameid'];
- $framedata .= str_replace("\x00", '', $source_data_array['data'])."\x00";
- switch ($source_data_array['frameid']) {
- case 'COMM':
- case 'SYLT':
- case 'USLT':
- case 'PRIV':
- case 'USER':
- case 'AENC':
- case 'APIC':
- case 'GEOB':
- case 'TXXX':
- $framedata .= $source_data_array['additionaldata'];
- break;
- case 'ASPI':
- case 'ETCO':
- case 'EQU2':
- case 'MCID':
- case 'MLLT':
- case 'OWNE':
- case 'RVA2':
- case 'RVRB':
- case 'SYTC':
- case 'IPLS':
- case 'RVAD':
- case 'EQUA':
- // no additional data required
- break;
- case 'RBUF':
- if ($this->majorversion == 3) {
- // no additional data required
- } else {
- $this->errors[] = $source_data_array['frameid'].' is not a valid Frame Identifier in '.$frame_name.' (in ID3v2.'.$this->majorversion.')';
- }
- default:
- if ((substr($source_data_array['frameid'], 0, 1) == 'T') || (substr($source_data_array['frameid'], 0, 1) == 'W')) {
- // no additional data required
- } else {
- $this->errors[] = $source_data_array['frameid'].' is not a valid Frame Identifier in '.$frame_name.' (in ID3v2.'.$this->majorversion.')';
- }
- break;
- }
- }
- break;
- case 'POSS':
- // 4.21 POSS Position synchronisation frame (ID3v2.3+ only)
- // Time stamp format $xx
- // Position $xx (xx ...)
- if (($source_data_array['timestampformat'] < 1) || ($source_data_array['timestampformat'] > 2)) {
- $this->errors[] = 'Invalid Time Stamp Format in '.$frame_name.' ('.$source_data_array['timestampformat'].') (valid = 1 or 2)';
- } elseif (!$this->IsWithinBitRange($source_data_array['position'], 32, false)) {
- $this->errors[] = 'Invalid Position in '.$frame_name.' ('.$source_data_array['position'].') (range = 0 to 4294967295)';
- } else {
- $framedata .= chr($source_data_array['timestampformat']);
- $framedata .= getid3_lib::BigEndian2String($source_data_array['position'], 4, false);
- }
- break;
- case 'USER':
- // 4.22 USER Terms of use (ID3v2.3+ only…
Large files files are truncated, but you can click here to view the full file