309 if (($this->majorversion < 3) || ($this->majorversion > 4)) {
311 $this->errors[] =
'Only ID3v2.3 and ID3v2.4 are supported in GenerateID3v2FrameData()';
315 switch ($frame_name) {
320 if (strlen($source_data_array[
'data']) > 64) {
321 $this->errors[] =
'Identifier not allowed to be longer than 64 bytes in '.$frame_name.
' (supplied data was '.strlen($source_data_array[
'data']).
' bytes long)';
323 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'ownerid']).
"\x00";
324 $framedata .= substr($source_data_array[
'data'], 0, 64);
335 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
') for ID3v2.'.
$this->majorversion;
337 $framedata .= chr($source_data_array[
'encodingid']);
338 $framedata .= $source_data_array[
'description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array[
'encodingid']);
339 $framedata .= $source_data_array[
'data'];
350 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
') for ID3v2.'.
$this->majorversion;
351 } elseif (!isset($source_data_array[
'data']) || !$this->
IsValidURL($source_data_array[
'data'],
false,
false)) {
354 $this->warnings[] =
'Invalid URL in '.$frame_name.
' ('.$source_data_array[
'data'].
')';
356 $framedata .= chr($source_data_array[
'encodingid']);
357 $framedata .= $source_data_array[
'description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array[
'encodingid']);
358 $framedata .= $source_data_array[
'data'];
368 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
') for ID3v2.'.
$this->majorversion;
370 $framedata .= chr($source_data_array[
'encodingid']);
371 $framedata .= $source_data_array[
'data'];
378 $framedata .= $source_data_array[
'data'];
392 if (($source_data_array[
'timestampformat'] > 2) || ($source_data_array[
'timestampformat'] < 1)) {
393 $this->errors[] =
'Invalid Time Stamp Format byte in '.$frame_name.
' ('.$source_data_array[
'timestampformat'].
')';
395 $framedata .= chr($source_data_array[
'timestampformat']);
396 foreach ($source_data_array as
$key => $val) {
398 $this->errors[] =
'Invalid Event Type byte in '.$frame_name.
' ('.$val[
'typeid'].
')';
399 } elseif ((
$key !=
'timestampformat') && (
$key !=
'flags')) {
400 if (($val[
'timestamp'] > 0) && ($previousETCOtimestamp >= $val[
'timestamp'])) {
403 $this->errors[] =
'Out-of-order timestamp in '.$frame_name.
' ('.$val[
'timestamp'].
') for Event Type ('.$val[
'typeid'].
')';
405 $framedata .= chr($val[
'typeid']);
423 if (($source_data_array[
'framesbetweenreferences'] > 0) && ($source_data_array[
'framesbetweenreferences'] <= 65535)) {
426 $this->errors[] =
'Invalid MPEG Frames Between References in '.$frame_name.
' ('.$source_data_array[
'framesbetweenreferences'].
')';
428 if (($source_data_array[
'bytesbetweenreferences'] > 0) && ($source_data_array[
'bytesbetweenreferences'] <= 16777215)) {
431 $this->errors[] =
'Invalid bytes Between References in '.$frame_name.
' ('.$source_data_array[
'bytesbetweenreferences'].
')';
433 if (($source_data_array[
'msbetweenreferences'] > 0) && ($source_data_array[
'msbetweenreferences'] <= 16777215)) {
436 $this->errors[] =
'Invalid Milliseconds Between References in '.$frame_name.
' ('.$source_data_array[
'msbetweenreferences'].
')';
438 if (!$this->
IsWithinBitRange($source_data_array[
'bitsforbytesdeviation'], 8,
false)) {
439 if (($source_data_array[
'bitsforbytesdeviation'] % 4) == 0) {
440 $framedata .= chr($source_data_array[
'bitsforbytesdeviation']);
442 $this->errors[] =
'Bits For Bytes Deviation in '.$frame_name.
' ('.$source_data_array[
'bitsforbytesdeviation'].
') must be a multiple of 4.';
445 $this->errors[] =
'Invalid Bits For Bytes Deviation in '.$frame_name.
' ('.$source_data_array[
'bitsforbytesdeviation'].
')';
447 if (!$this->
IsWithinBitRange($source_data_array[
'bitsformsdeviation'], 8,
false)) {
448 if (($source_data_array[
'bitsformsdeviation'] % 4) == 0) {
449 $framedata .= chr($source_data_array[
'bitsformsdeviation']);
451 $this->errors[] =
'Bits For Milliseconds Deviation in '.$frame_name.
' ('.$source_data_array[
'bitsforbytesdeviation'].
') must be a multiple of 4.';
454 $this->errors[] =
'Invalid Bits For Milliseconds Deviation in '.$frame_name.
' ('.$source_data_array[
'bitsformsdeviation'].
')';
456 foreach ($source_data_array as
$key => $val) {
457 if ((
$key !=
'framesbetweenreferences') && (
$key !=
'bytesbetweenreferences') && (
$key !=
'msbetweenreferences') && (
$key !=
'bitsforbytesdeviation') && (
$key !=
'bitsformsdeviation') && (
$key !=
'flags')) {
458 $unwrittenbitstream .= str_pad(
getid3_lib::Dec2Bin($val[
'bytedeviation']), $source_data_array[
'bitsforbytesdeviation'],
'0', STR_PAD_LEFT);
459 $unwrittenbitstream .= str_pad(
getid3_lib::Dec2Bin($val[
'msdeviation']), $source_data_array[
'bitsformsdeviation'],
'0', STR_PAD_LEFT);
462 for (
$i = 0;
$i < strlen($unwrittenbitstream);
$i += 8) {
463 $highnibble = bindec(substr($unwrittenbitstream,
$i, 4)) << 4;
464 $lownibble = bindec(substr($unwrittenbitstream,
$i + 4, 4));
465 $framedata .= chr($highnibble & $lownibble);
476 if (($source_data_array[
'timestampformat'] > 2) || ($source_data_array[
'timestampformat'] < 1)) {
477 $this->errors[] =
'Invalid Time Stamp Format byte in '.$frame_name.
' ('.$source_data_array[
'timestampformat'].
')';
479 $framedata .= chr($source_data_array[
'timestampformat']);
480 foreach ($source_data_array as
$key => $val) {
482 $this->errors[] =
'Invalid Event Type byte in '.$frame_name.
' ('.$val[
'typeid'].
')';
483 } elseif ((
$key !=
'timestampformat') && (
$key !=
'flags')) {
484 if (($val[
'tempo'] < 0) || ($val[
'tempo'] > 510)) {
485 $this->errors[] =
'Invalid Tempo (max = 510) in '.$frame_name.
' ('.$val[
'tempo'].
') at timestamp ('.$val[
'timestamp'].
')';
487 if ($val[
'tempo'] > 255) {
488 $framedata .= chr(255);
489 $val[
'tempo'] -= 255;
491 $framedata .= chr($val[
'tempo']);
507 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
') for ID3v2.'.
$this->majorversion;
509 $this->errors[] =
'Invalid Language in '.$frame_name.
' ('.$source_data_array[
'language'].
')';
511 $framedata .= chr($source_data_array[
'encodingid']);
512 $framedata .= strtolower($source_data_array[
'language']);
513 $framedata .= $source_data_array[
'description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array[
'encodingid']);
514 $framedata .= $source_data_array[
'data'];
532 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
') for ID3v2.'.
$this->majorversion;
534 $this->errors[] =
'Invalid Language in '.$frame_name.
' ('.$source_data_array[
'language'].
')';
535 } elseif (($source_data_array[
'timestampformat'] > 2) || ($source_data_array[
'timestampformat'] < 1)) {
536 $this->errors[] =
'Invalid Time Stamp Format byte in '.$frame_name.
' ('.$source_data_array[
'timestampformat'].
')';
538 $this->errors[] =
'Invalid Content Type byte in '.$frame_name.
' ('.$source_data_array[
'contenttypeid'].
')';
539 } elseif (!is_array($source_data_array[
'data'])) {
540 $this->errors[] =
'Invalid Lyric/Timestamp data in '.$frame_name.
' (must be an array)';
542 $framedata .= chr($source_data_array[
'encodingid']);
543 $framedata .= strtolower($source_data_array[
'language']);
544 $framedata .= chr($source_data_array[
'timestampformat']);
545 $framedata .= chr($source_data_array[
'contenttypeid']);
546 $framedata .= $source_data_array[
'description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array[
'encodingid']);
547 ksort($source_data_array[
'data']);
548 foreach ($source_data_array[
'data'] as
$key => $val) {
549 $framedata .= $val[
'data'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array[
'encodingid']);
563 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
') for ID3v2.'.
$this->majorversion;
565 $this->errors[] =
'Invalid Language in '.$frame_name.
' ('.$source_data_array[
'language'].
')';
567 $framedata .= chr($source_data_array[
'encodingid']);
568 $framedata .= strtolower($source_data_array[
'language']);
569 $framedata .= $source_data_array[
'description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array[
'encodingid']);
570 $framedata .= $source_data_array[
'data'];
584 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'description']).
"\x00";
585 foreach ($source_data_array as
$key => $val) {
586 if (
$key !=
'description') {
587 $framedata .= chr($val[
'channeltypeid']);
589 if (!$this->
IsWithinBitRange($source_data_array[
'bitspeakvolume'], 8,
false)) {
590 $framedata .= chr($val[
'bitspeakvolume']);
591 if ($val[
'bitspeakvolume'] > 0) {
595 $this->errors[] =
'Invalid Bits Representing Peak Volume in '.$frame_name.
' ('.$val[
'bitspeakvolume'].
') (range = 0 to 255)';
618 $this->errors[] =
'Invalid Bits For Volume Description byte in '.$frame_name.
' ('.$source_data_array[
'bitsvolume'].
') (range = 1 to 255)';
621 $incdecflag .= $source_data_array[
'incdec'][
'right'] ?
'1' :
'0';
622 $incdecflag .= $source_data_array[
'incdec'][
'left'] ?
'1' :
'0';
623 $incdecflag .= $source_data_array[
'incdec'][
'rightrear'] ?
'1' :
'0';
624 $incdecflag .= $source_data_array[
'incdec'][
'leftrear'] ?
'1' :
'0';
625 $incdecflag .= $source_data_array[
'incdec'][
'center'] ?
'1' :
'0';
626 $incdecflag .= $source_data_array[
'incdec'][
'bass'] ?
'1' :
'0';
627 $framedata .= chr(bindec($incdecflag));
628 $framedata .= chr($source_data_array[
'bitsvolume']);
629 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'volumechange'][
'right'], ceil($source_data_array[
'bitsvolume'] / 8),
false);
630 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'volumechange'][
'left'], ceil($source_data_array[
'bitsvolume'] / 8),
false);
631 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'peakvolume'][
'right'], ceil($source_data_array[
'bitsvolume'] / 8),
false);
632 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'peakvolume'][
'left'], ceil($source_data_array[
'bitsvolume'] / 8),
false);
633 if ($source_data_array[
'volumechange'][
'rightrear'] || $source_data_array[
'volumechange'][
'leftrear'] ||
634 $source_data_array[
'peakvolume'][
'rightrear'] || $source_data_array[
'peakvolume'][
'leftrear'] ||
635 $source_data_array[
'volumechange'][
'center'] || $source_data_array[
'peakvolume'][
'center'] ||
636 $source_data_array[
'volumechange'][
'bass'] || $source_data_array[
'peakvolume'][
'bass']) {
637 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'volumechange'][
'rightrear'], ceil($source_data_array[
'bitsvolume']/8),
false);
638 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'volumechange'][
'leftrear'], ceil($source_data_array[
'bitsvolume']/8),
false);
639 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'peakvolume'][
'rightrear'], ceil($source_data_array[
'bitsvolume']/8),
false);
640 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'peakvolume'][
'leftrear'], ceil($source_data_array[
'bitsvolume']/8),
false);
642 if ($source_data_array[
'volumechange'][
'center'] || $source_data_array[
'peakvolume'][
'center'] ||
643 $source_data_array[
'volumechange'][
'bass'] || $source_data_array[
'peakvolume'][
'bass']) {
644 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'volumechange'][
'center'], ceil($source_data_array[
'bitsvolume']/8),
false);
645 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'peakvolume'][
'center'], ceil($source_data_array[
'bitsvolume']/8),
false);
647 if ($source_data_array[
'volumechange'][
'bass'] || $source_data_array[
'peakvolume'][
'bass']) {
648 $framedata .=
getid3_lib::BigEndian2String($source_data_array[
'volumechange'][
'bass'], ceil($source_data_array[
'bitsvolume']/8),
false);
663 if (($source_data_array[
'interpolationmethod'] < 0) || ($source_data_array[
'interpolationmethod'] > 1)) {
664 $this->errors[] =
'Invalid Interpolation Method byte in '.$frame_name.
' ('.$source_data_array[
'interpolationmethod'].
') (valid = 0 or 1)';
666 $framedata .= chr($source_data_array[
'interpolationmethod']);
667 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'description']).
"\x00";
668 foreach ($source_data_array[
'data'] as
$key => $val) {
685 $this->errors[] =
'Invalid Adjustment Bits byte in '.$frame_name.
' ('.$source_data_array[
'bitsvolume'].
') (range = 1 to 255)';
687 $framedata .= chr($source_data_array[
'adjustmentbits']);
688 foreach ($source_data_array as
$key => $val) {
689 if (
$key !=
'bitsvolume') {
691 $this->errors[] =
'Invalid Frequency in '.$frame_name.
' ('.
$key.
') (range = 0 to 32767)';
718 $this->errors[] =
'Invalid Reverb Left in '.$frame_name.
' ('.$source_data_array[
'left'].
') (range = 0 to 65535)';
719 } elseif (!$this->
IsWithinBitRange($source_data_array[
'right'], 16,
false)) {
720 $this->errors[] =
'Invalid Reverb Left in '.$frame_name.
' ('.$source_data_array[
'right'].
') (range = 0 to 65535)';
721 } elseif (!$this->
IsWithinBitRange($source_data_array[
'bouncesL'], 8,
false)) {
722 $this->errors[] =
'Invalid Reverb Bounces, Left in '.$frame_name.
' ('.$source_data_array[
'bouncesL'].
') (range = 0 to 255)';
723 } elseif (!$this->
IsWithinBitRange($source_data_array[
'bouncesR'], 8,
false)) {
724 $this->errors[] =
'Invalid Reverb Bounces, Right in '.$frame_name.
' ('.$source_data_array[
'bouncesR'].
') (range = 0 to 255)';
725 } elseif (!$this->
IsWithinBitRange($source_data_array[
'feedbackLL'], 8,
false)) {
726 $this->errors[] =
'Invalid Reverb Feedback, Left-To-Left in '.$frame_name.
' ('.$source_data_array[
'feedbackLL'].
') (range = 0 to 255)';
727 } elseif (!$this->
IsWithinBitRange($source_data_array[
'feedbackLR'], 8,
false)) {
728 $this->errors[] =
'Invalid Reverb Feedback, Left-To-Right in '.$frame_name.
' ('.$source_data_array[
'feedbackLR'].
') (range = 0 to 255)';
729 } elseif (!$this->
IsWithinBitRange($source_data_array[
'feedbackRR'], 8,
false)) {
730 $this->errors[] =
'Invalid Reverb Feedback, Right-To-Right in '.$frame_name.
' ('.$source_data_array[
'feedbackRR'].
') (range = 0 to 255)';
731 } elseif (!$this->
IsWithinBitRange($source_data_array[
'feedbackRL'], 8,
false)) {
732 $this->errors[] =
'Invalid Reverb Feedback, Right-To-Left in '.$frame_name.
' ('.$source_data_array[
'feedbackRL'].
') (range = 0 to 255)';
733 } elseif (!$this->
IsWithinBitRange($source_data_array[
'premixLR'], 8,
false)) {
734 $this->errors[] =
'Invalid Premix, Left-To-Right in '.$frame_name.
' ('.$source_data_array[
'premixLR'].
') (range = 0 to 255)';
735 } elseif (!$this->
IsWithinBitRange($source_data_array[
'premixRL'], 8,
false)) {
736 $this->errors[] =
'Invalid Premix, Right-To-Left in '.$frame_name.
' ('.$source_data_array[
'premixRL'].
') (range = 0 to 255)';
740 $framedata .= chr($source_data_array[
'bouncesL']);
741 $framedata .= chr($source_data_array[
'bouncesR']);
742 $framedata .= chr($source_data_array[
'feedbackLL']);
743 $framedata .= chr($source_data_array[
'feedbackLR']);
744 $framedata .= chr($source_data_array[
'feedbackRR']);
745 $framedata .= chr($source_data_array[
'feedbackRL']);
746 $framedata .= chr($source_data_array[
'premixLR']);
747 $framedata .= chr($source_data_array[
'premixRL']);
760 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
') for ID3v2.'.
$this->majorversion;
762 $this->errors[] =
'Invalid Picture Type byte in '.$frame_name.
' ('.$source_data_array[
'picturetypeid'].
') for ID3v2.'.
$this->majorversion;
764 $this->errors[] =
'Invalid MIME Type in '.$frame_name.
' ('.$source_data_array[
'mime'].
') for ID3v2.'.
$this->majorversion;
765 } elseif (($source_data_array[
'mime'] ==
'-->') && (!$this->
IsValidURL($source_data_array[
'data'],
false,
false))) {
768 $this->warnings[] =
'Invalid URL in '.$frame_name.
' ('.$source_data_array[
'data'].
')';
770 $framedata .= chr($source_data_array[
'encodingid']);
771 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'mime']).
"\x00";
772 $framedata .= chr($source_data_array[
'picturetypeid']);
774 $framedata .= $source_data_array[
'data'];
787 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
') for ID3v2.'.
$this->majorversion;
789 $this->errors[] =
'Invalid MIME Type in '.$frame_name.
' ('.$source_data_array[
'mime'].
')';
790 } elseif (!$source_data_array[
'description']) {
791 $this->errors[] =
'Missing Description in '.$frame_name;
793 $framedata .= chr($source_data_array[
'encodingid']);
794 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'mime']).
"\x00";
795 $framedata .= $source_data_array[
'filename'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array[
'encodingid']);
796 $framedata .= $source_data_array[
'description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array[
'encodingid']);
797 $framedata .= $source_data_array[
'data'];
817 $this->errors[] =
'Invalid Rating byte in '.$frame_name.
' ('.$source_data_array[
'rating'].
') (range = 0 to 255)';
818 } elseif (!$this->
IsValidEmail($source_data_array[
'email'])) {
819 $this->errors[] =
'Invalid Email in '.$frame_name.
' ('.$source_data_array[
'email'].
')';
821 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'email']).
"\x00";
822 $framedata .= chr($source_data_array[
'rating']);
832 if (!$this->
IsWithinBitRange($source_data_array[
'buffersize'], 24,
false)) {
833 $this->errors[] =
'Invalid Buffer Size in '.$frame_name;
834 } elseif (!$this->
IsWithinBitRange($source_data_array[
'nexttagoffset'], 32,
false)) {
835 $this->errors[] =
'Invalid Offset To Next Tag in '.$frame_name;
839 $flag .= $source_data_array[
'flags'][
'embededinfo'] ?
'1' :
'0';
840 $framedata .= chr(bindec($flag));
851 if (!$this->
IsWithinBitRange($source_data_array[
'previewstart'], 16,
false)) {
852 $this->errors[] =
'Invalid Preview Start in '.$frame_name.
' ('.$source_data_array[
'previewstart'].
')';
853 } elseif (!$this->
IsWithinBitRange($source_data_array[
'previewlength'], 16,
false)) {
854 $this->errors[] =
'Invalid Preview Length in '.$frame_name.
' ('.$source_data_array[
'previewlength'].
')';
856 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'ownerid']).
"\x00";
859 $framedata .= $source_data_array[
'encryptioninfo'];
869 $this->errors[] =
'Invalid Frame Identifier in '.$frame_name.
' ('.$source_data_array[
'frameid'].
')';
870 } elseif (!$this->
IsValidURL($source_data_array[
'data'],
true,
false)) {
873 $this->warnings[] =
'Invalid URL in '.$frame_name.
' ('.$source_data_array[
'data'].
')';
874 } 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'] ==
'')) {
875 $this->errors[] =
'Content Descriptor must be specified as additional data for Frame Identifier of '.$source_data_array[
'frameid'].
' in '.$frame_name;
876 } elseif (($source_data_array[
'frameid'] ==
'USER') && (
getid3_id3v2::LanguageLookup($source_data_array[
'additionaldata'],
true) ==
'')) {
877 $this->errors[] =
'Language must be specified as additional data for Frame Identifier of '.$source_data_array[
'frameid'].
' in '.$frame_name;
878 } elseif (($source_data_array[
'frameid'] ==
'PRIV') && ($source_data_array[
'additionaldata'] ==
'')) {
879 $this->errors[] =
'Owner Identifier must be specified as additional data for Frame Identifier of '.$source_data_array[
'frameid'].
' in '.$frame_name;
880 } 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) ==
''))) {
881 $this->errors[] =
'Language followed by Content Descriptor must be specified as additional data for Frame Identifier of '.$source_data_array[
'frameid'].
' in '.$frame_name;
883 $framedata .= $source_data_array[
'frameid'];
884 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'data']).
"\x00";
885 switch ($source_data_array[
'frameid']) {
895 $framedata .= $source_data_array[
'additionaldata'];
912 if ($this->majorversion == 3) {
915 $this->errors[] = $source_data_array[
'frameid'].
' is not a valid Frame Identifier in '.$frame_name.
' (in ID3v2.'.$this->majorversion.
')';
919 if ((substr($source_data_array[
'frameid'], 0, 1) ==
'T') || (substr($source_data_array[
'frameid'], 0, 1) ==
'W')) {
922 $this->errors[] = $source_data_array[
'frameid'].
' is not a valid Frame Identifier in '.$frame_name.
' (in ID3v2.'.$this->majorversion.
')';
933 if (($source_data_array[
'timestampformat'] < 1) || ($source_data_array[
'timestampformat'] > 2)) {
934 $this->errors[] =
'Invalid Time Stamp Format in '.$frame_name.
' ('.$source_data_array[
'timestampformat'].
') (valid = 1 or 2)';
935 } elseif (!$this->
IsWithinBitRange($source_data_array[
'position'], 32,
false)) {
936 $this->errors[] =
'Invalid Position in '.$frame_name.
' ('.$source_data_array[
'position'].
') (range = 0 to 4294967295)';
938 $framedata .= chr($source_data_array[
'timestampformat']);
950 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
')';
952 $this->errors[] =
'Invalid Language in '.$frame_name.
' ('.$source_data_array[
'language'].
')';
954 $framedata .= chr($source_data_array[
'encodingid']);
955 $framedata .= strtolower($source_data_array[
'language']);
956 $framedata .= $source_data_array[
'data'];
968 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
')';
969 } elseif (!$this->IsANumber($source_data_array[
'pricepaid'][
'value'],
false)) {
970 $this->errors[] =
'Invalid Price Paid in '.$frame_name.
' ('.$source_data_array[
'pricepaid'][
'value'].
')';
971 } elseif (!$this->IsValidDateStampString($source_data_array[
'purchasedate'])) {
972 $this->errors[] =
'Invalid Date Of Purchase in '.$frame_name.
' ('.$source_data_array[
'purchasedate'].
') (format = YYYYMMDD)';
974 $framedata .= chr($source_data_array[
'encodingid']);
975 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'pricepaid'][
'value']).
"\x00";
976 $framedata .= $source_data_array[
'purchasedate'];
977 $framedata .= $source_data_array[
'seller'];
994 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
')';
995 } elseif (!$this->IsValidDateStampString($source_data_array[
'pricevaliduntil'])) {
996 $this->errors[] =
'Invalid Valid Until date in '.$frame_name.
' ('.$source_data_array[
'pricevaliduntil'].
') (format = YYYYMMDD)';
997 } elseif (!$this->
IsValidURL($source_data_array[
'contacturl'],
false,
true)) {
998 $this->errors[] =
'Invalid Contact URL in '.$frame_name.
' ('.$source_data_array[
'contacturl'].
') (allowed schemes: http, https, ftp, mailto)';
1000 $this->errors[] =
'Invalid Received As byte in '.$frame_name.
' ('.$source_data_array[
'contacturl'].
') (range = 0 to 8)';
1002 $this->errors[] =
'Invalid MIME Type in '.$frame_name.
' ('.$source_data_array[
'mime'].
')';
1004 $framedata .= chr($source_data_array[
'encodingid']);
1005 unset($pricestring);
1006 foreach ($source_data_array[
'price'] as
$key => $val) {
1008 $pricestrings[] =
$key.$val[
'value'];
1010 $this->errors[] =
'Invalid Price String in '.$frame_name.
' ('.
$key.$val[
'value'].
')';
1013 $framedata .= implode(
'/', $pricestrings);
1014 $framedata .= $source_data_array[
'pricevaliduntil'];
1015 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'contacturl']).
"\x00";
1016 $framedata .= chr($source_data_array[
'receivedasid']);
1017 $framedata .= $source_data_array[
'sellername'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array[
'encodingid']);
1018 $framedata .= $source_data_array[
'description'].getid3_id3v2::TextEncodingTerminatorLookup($source_data_array[
'encodingid']);
1019 $framedata .= $source_data_array[
'mime'].
"\x00";
1020 $framedata .= $source_data_array[
'logo'];
1029 if (!$this->
IsWithinBitRange($source_data_array[
'methodsymbol'], 8,
false)) {
1030 $this->errors[] =
'Invalid Group Symbol in '.$frame_name.
' ('.$source_data_array[
'methodsymbol'].
') (range = 0 to 255)';
1032 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'ownerid']).
"\x00";
1033 $framedata .= ord($source_data_array[
'methodsymbol']);
1034 $framedata .= $source_data_array[
'data'];
1043 if (!$this->
IsWithinBitRange($source_data_array[
'groupsymbol'], 8,
false)) {
1044 $this->errors[] =
'Invalid Group Symbol in '.$frame_name.
' ('.$source_data_array[
'groupsymbol'].
') (range = 0 to 255)';
1046 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'ownerid']).
"\x00";
1047 $framedata .= ord($source_data_array[
'groupsymbol']);
1048 $framedata .= $source_data_array[
'data'];
1056 $framedata .= str_replace(
"\x00",
'', $source_data_array[
'ownerid']).
"\x00";
1057 $framedata .= $source_data_array[
'data'];
1064 if (!$this->
IsWithinBitRange($source_data_array[
'groupsymbol'], 8,
false)) {
1065 $this->errors[] =
'Invalid Group Symbol in '.$frame_name.
' ('.$source_data_array[
'groupsymbol'].
') (range = 0 to 255)';
1067 $framedata .= ord($source_data_array[
'groupsymbol']);
1068 $framedata .= $source_data_array[
'data'];
1076 $this->errors[] =
'Invalid Minimum Offset in '.$frame_name.
' ('.$source_data_array[
'data'].
') (range = 0 to 4294967295)';
1090 if (!$this->
IsWithinBitRange($source_data_array[
'datastart'], 32,
false)) {
1091 $this->errors[] =
'Invalid Indexed Data Start in '.$frame_name.
' ('.$source_data_array[
'datastart'].
') (range = 0 to 4294967295)';
1092 } elseif (!$this->
IsWithinBitRange($source_data_array[
'datalength'], 32,
false)) {
1093 $this->errors[] =
'Invalid Indexed Data Length in '.$frame_name.
' ('.$source_data_array[
'datalength'].
') (range = 0 to 4294967295)';
1094 } elseif (!$this->
IsWithinBitRange($source_data_array[
'indexpoints'], 16,
false)) {
1095 $this->errors[] =
'Invalid Number Of Index Points in '.$frame_name.
' ('.$source_data_array[
'indexpoints'].
') (range = 0 to 65535)';
1096 } elseif (!$this->
IsWithinBitRange($source_data_array[
'bitsperpoint'], 8,
false)) {
1097 $this->errors[] =
'Invalid Bits Per Index Point in '.$frame_name.
' ('.$source_data_array[
'bitsperpoint'].
') (range = 0 to 255)';
1098 } elseif ($source_data_array[
'indexpoints'] != count($source_data_array[
'indexes'])) {
1099 $this->errors[] =
'Number Of Index Points does not match actual supplied data in '.$frame_name;
1105 foreach ($source_data_array[
'indexes'] as
$key => $val) {
1122 if (($source_data_array[
'track_adjustment'] > 51) || ($source_data_array[
'track_adjustment'] < -51)) {
1123 $this->errors[] =
'Invalid Track Adjustment in '.$frame_name.
' ('.$source_data_array[
'track_adjustment'].
') (range = -51.0 to +51.0)';
1124 } elseif (($source_data_array[
'album_adjustment'] > 51) || ($source_data_array[
'album_adjustment'] < -51)) {
1125 $this->errors[] =
'Invalid Album Adjustment in '.$frame_name.
' ('.$source_data_array[
'album_adjustment'].
') (range = -51.0 to +51.0)';
1127 $this->errors[] =
'Invalid Track Name Code in '.$frame_name.
' ('.$source_data_array[
'raw'][
'track_name'].
') (range = 0 to 2)';
1129 $this->errors[] =
'Invalid Album Name Code in '.$frame_name.
' ('.$source_data_array[
'raw'][
'album_name'].
') (range = 0 to 2)';
1131 $this->errors[] =
'Invalid Track Originator Code in '.$frame_name.
' ('.$source_data_array[
'raw'][
'track_originator'].
') (range = 0 to 3)';
1133 $this->errors[] =
'Invalid Album Originator Code in '.$frame_name.
' ('.$source_data_array[
'raw'][
'album_originator'].
') (range = 0 to 3)';
1136 $framedata .=
getid3_lib::RGADgainString($source_data_array[
'raw'][
'track_name'], $source_data_array[
'raw'][
'track_originator'], $source_data_array[
'track_adjustment']);
1137 $framedata .=
getid3_lib::RGADgainString($source_data_array[
'raw'][
'album_name'], $source_data_array[
'raw'][
'album_originator'], $source_data_array[
'album_adjustment']);
1142 if ((($this->majorversion == 2) && (strlen($frame_name) != 3)) || (($this->majorversion > 2) && (strlen($frame_name) != 4))) {
1144 } elseif ($frame_name{0} ==
'T') {
1150 $this->errors[] =
'Invalid Text Encoding in '.$frame_name.
' ('.$source_data_array[
'encodingid'].
') for ID3v2.'.
$this->majorversion;
1152 $framedata .= chr($source_data_array[
'encodingid']);
1153 $framedata .= $source_data_array[
'data'];
1155 } elseif ($frame_name{0} ==
'W') {
1158 if (!$this->
IsValidURL($source_data_array[
'data'],
false,
false)) {
1161 $this->warnings[] =
'Invalid URL in '.$frame_name.
' ('.$source_data_array[
'data'].
')';
1163 $framedata .= $source_data_array[
'data'];
1166 $this->errors[] = $frame_name.
' not yet supported in $this->GenerateID3v2FrameData()';
1171 if (!empty($this->errors)) {
static IsValidURL($url, $allowUserPass=false)
static IsWithinBitRange($number, $maxbits, $signed=false)
static ID3v2IsValidRGADoriginator($RGADoriginator)
ID3v2IsValidSYLTtype($contenttype)
static IsValidMIMEstring($mimestring)
$id3v2_default_encodingid
ID3v2IsValidCOMRreceivedAs($receivedas)
static LanguageLookup($languagecode, $casesensitive=false)
static Float2String($floatvalue, $bits)
ID3v2IsValidETCOevent($eventid)
static RGADgainString($namecode, $originatorcode, $replaygain)
static IsValidEmail($email)
ID3v2IsValidTextEncoding($textencodingbyte)
ID3v2IsValidPriceString($pricestring)
static IsValidID3v2FrameName($framename, $id3v2majorversion)
static ID3v2IsValidRGADname($RGADname)
ID3v2IsValidAPICpicturetype($picturetype)
ID3v2IsValidAPICimageformat($imageformat)
static TextEncodingTerminatorLookup($encoding)
static BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false)