3 /////////////////////////////////////////////////////////////////
4 /// getID3() by James Heinrich <info@getid3.org> //
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 /////////////////////////////////////////////////////////////////
11 // write.lyrics3.php //
12 // module for writing Lyrics3 tags //
13 // dependencies: module.tag.lyrics3.php //
15 /////////////////////////////////////////////////////////////////
18 class getid3_write_lyrics3
29 //public $lyrics3_version = 2; // 1 or 2
32 * Any non-critical errors will be stored here.
36 public $warnings = array();
39 * Any critical errors will be stored here.
43 public $errors = array();
45 public function __construct() {
51 public function WriteLyrics3() {
52 $this->errors
[] = 'WriteLyrics3() not yet functional - cannot write Lyrics3';
59 public function DeleteLyrics3() {
60 // Initialize getID3 engine
62 $ThisFileInfo = $getID3->analyze($this->filename
);
63 if (isset($ThisFileInfo['lyrics3']['tag_offset_start']) && isset($ThisFileInfo['lyrics3']['tag_offset_end'])) {
64 if (is_readable($this->filename
) && getID3
::is_writable($this->filename
) && is_file($this->filename
) && ($fp = fopen($this->filename
, 'a+b'))) {
67 $oldignoreuserabort = ignore_user_abort(true);
69 fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_end']);
70 $DataAfterLyrics3 = '';
71 if ($ThisFileInfo['filesize'] > $ThisFileInfo['lyrics3']['tag_offset_end']) {
72 $DataAfterLyrics3 = fread($fp, $ThisFileInfo['filesize'] - $ThisFileInfo['lyrics3']['tag_offset_end']);
75 ftruncate($fp, $ThisFileInfo['lyrics3']['tag_offset_start']);
77 if (!empty($DataAfterLyrics3)) {
78 fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_start']);
79 fwrite($fp, $DataAfterLyrics3, strlen($DataAfterLyrics3));
84 ignore_user_abort($oldignoreuserabort);
89 $this->errors
[] = 'Cannot fopen('.$this->filename
.', "a+b")';