File indexing completed on 2024-12-22 05:33:15
0001 <?php 0002 ///////////////////////////////////////////////////////////////// 0003 /// getID3() by James Heinrich <info@getid3.org> // 0004 // available at http://getid3.sourceforge.net // 0005 // or http://www.getid3.org // 0006 // also https://github.com/JamesHeinrich/getID3 // 0007 ///////////////////////////////////////////////////////////////// 0008 // See readme.txt for more details // 0009 ///////////////////////////////////////////////////////////////// 0010 // // 0011 // write.lyrics3.php // 0012 // module for writing Lyrics3 tags // 0013 // dependencies: module.tag.lyrics3.php // 0014 // /// 0015 ///////////////////////////////////////////////////////////////// 0016 0017 0018 class getid3_write_lyrics3 0019 { 0020 public $filename; 0021 public $tag_data; 0022 //public $lyrics3_version = 2; // 1 or 2 0023 public $warnings = array(); // any non-critical errors will be stored here 0024 public $errors = array(); // any critical errors will be stored here 0025 0026 public function getid3_write_lyrics3() { 0027 return true; 0028 } 0029 0030 public function WriteLyrics3() { 0031 $this->errors[] = 'WriteLyrics3() not yet functional - cannot write Lyrics3'; 0032 return false; 0033 } 0034 public function DeleteLyrics3() { 0035 // Initialize getID3 engine 0036 $getID3 = new getID3; 0037 $ThisFileInfo = $getID3->analyze($this->filename); 0038 if (isset($ThisFileInfo['lyrics3']['tag_offset_start']) && isset($ThisFileInfo['lyrics3']['tag_offset_end'])) { 0039 if (is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) { 0040 0041 flock($fp, LOCK_EX); 0042 $oldignoreuserabort = ignore_user_abort(true); 0043 0044 fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_end']); 0045 $DataAfterLyrics3 = ''; 0046 if ($ThisFileInfo['filesize'] > $ThisFileInfo['lyrics3']['tag_offset_end']) { 0047 $DataAfterLyrics3 = fread($fp, $ThisFileInfo['filesize'] - $ThisFileInfo['lyrics3']['tag_offset_end']); 0048 } 0049 0050 ftruncate($fp, $ThisFileInfo['lyrics3']['tag_offset_start']); 0051 0052 if (!empty($DataAfterLyrics3)) { 0053 fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_start']); 0054 fwrite($fp, $DataAfterLyrics3, strlen($DataAfterLyrics3)); 0055 } 0056 0057 flock($fp, LOCK_UN); 0058 fclose($fp); 0059 ignore_user_abort($oldignoreuserabort); 0060 0061 return true; 0062 0063 } else { 0064 $this->errors[] = 'Cannot fopen('.$this->filename.', "a+b")'; 0065 return false; 0066 } 0067 } 0068 // no Lyrics3 present 0069 return true; 0070 } 0071 0072 }