Annotation of /trunk/lib/getid3/write.lyrics3.php
Parent Directory
|
Revision Log
Revision 2 - (view) (download)
| 1 : | andphe | 2 | <?php |
| 2 : | ///////////////////////////////////////////////////////////////// | ||
| 3 : | /// getID3() by James Heinrich <info@getid3.org> // | ||
| 4 : | // available at http://getid3.sourceforge.net // | ||
| 5 : | // or http://www.getid3.org // | ||
| 6 : | ///////////////////////////////////////////////////////////////// | ||
| 7 : | // See readme.txt for more details // | ||
| 8 : | ///////////////////////////////////////////////////////////////// | ||
| 9 : | // // | ||
| 10 : | // write.lyrics3.php // | ||
| 11 : | // module for writing Lyrics3 tags // | ||
| 12 : | // dependencies: module.tag.lyrics3.php // | ||
| 13 : | // /// | ||
| 14 : | ///////////////////////////////////////////////////////////////// | ||
| 15 : | // MOS Intruder Alerts | ||
| 16 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 17 : | |||
| 18 : | class getid3_write_lyrics3 | ||
| 19 : | { | ||
| 20 : | var $filename; | ||
| 21 : | var $tag_data; | ||
| 22 : | //var $lyrics3_version = 2; // 1 or 2 | ||
| 23 : | var $warnings = array(); // any non-critical errors will be stored here | ||
| 24 : | var $errors = array(); // any critical errors will be stored here | ||
| 25 : | |||
| 26 : | function getid3_write_lyrics3() { | ||
| 27 : | return true; | ||
| 28 : | } | ||
| 29 : | |||
| 30 : | function WriteLyrics3() { | ||
| 31 : | $this->errors[] = 'WriteLyrics3() not yet functional - cannot write Lyrics3'; | ||
| 32 : | return false; | ||
| 33 : | } | ||
| 34 : | |||
| 35 : | function DeleteLyrics3() { | ||
| 36 : | // Initialize getID3 engine | ||
| 37 : | $getID3 = new getID3; | ||
| 38 : | $ThisFileInfo = $getID3->analyze($this->filename); | ||
| 39 : | if (isset($ThisFileInfo['lyrics3']['tag_offset_start']) && isset($ThisFileInfo['lyrics3']['tag_offset_end'])) { | ||
| 40 : | if ($fp = @fopen($this->filename, 'a+b')) { | ||
| 41 : | |||
| 42 : | flock($fp, LOCK_EX); | ||
| 43 : | $oldignoreuserabort = ignore_user_abort(true); | ||
| 44 : | |||
| 45 : | fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_end'], SEEK_SET); | ||
| 46 : | $DataAfterLyrics3 = ''; | ||
| 47 : | if ($ThisFileInfo['filesize'] > $ThisFileInfo['lyrics3']['tag_offset_end']) { | ||
| 48 : | $DataAfterLyrics3 = fread($fp, $ThisFileInfo['filesize'] - $ThisFileInfo['lyrics3']['tag_offset_end']); | ||
| 49 : | } | ||
| 50 : | |||
| 51 : | ftruncate($fp, $ThisFileInfo['lyrics3']['tag_offset_start']); | ||
| 52 : | |||
| 53 : | if (!empty($DataAfterLyrics3)) { | ||
| 54 : | fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_start'], SEEK_SET); | ||
| 55 : | fwrite($fp, $DataAfterLyrics3, strlen($DataAfterLyrics3)); | ||
| 56 : | } | ||
| 57 : | |||
| 58 : | flock($fp, LOCK_UN); | ||
| 59 : | fclose($fp); | ||
| 60 : | ignore_user_abort($oldignoreuserabort); | ||
| 61 : | |||
| 62 : | return true; | ||
| 63 : | |||
| 64 : | } else { | ||
| 65 : | |||
| 66 : | $this->errors[] = 'Cannot open "'.$this->filename.'" in "a+b" mode'; | ||
| 67 : | return false; | ||
| 68 : | |||
| 69 : | } | ||
| 70 : | } | ||
| 71 : | // no Lyrics3 present | ||
| 72 : | return true; | ||
| 73 : | } | ||
| 74 : | |||
| 75 : | |||
| 76 : | |||
| 77 : | } | ||
| 78 : | |||
| 79 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

