Go to the documentation of this file.00001 <?php
00004
00005
00007
00009
00010
00011
00012
00013
00015
00016 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE__, true);
00017
00018 class getid3_write_id3v1
00019 {
00020 var $filename;
00021 var $tag_data;
00022 var $warnings = array();
00023 var $errors = array();
00024
00025 function getid3_write_id3v1() {
00026 return true;
00027 }
00028
00029 function WriteID3v1() {
00030
00031 if (is_writeable($this->filename)) {
00032 if ($fp_source = @fopen($this->filename, 'r+b')) {
00033
00034 fseek($fp_source, -128, SEEK_END);
00035 if (fread($fp_source, 3) == 'TAG') {
00036 fseek($fp_source, -128, SEEK_END);
00037 } else {
00038 fseek($fp_source, 0, SEEK_END);
00039 }
00040
00041 $new_id3v1_tag_data = getid3_id3v1::GenerateID3v1Tag(
00042 @$this->tag_data['title'],
00043 @$this->tag_data['artist'],
00044 @$this->tag_data['album'],
00045 @$this->tag_data['year'],
00046 @$this->tag_data['genreid'],
00047 @$this->tag_data['comment'],
00048 @$this->tag_data['track']);
00049 fwrite($fp_source, $new_id3v1_tag_data, 128);
00050 fclose($fp_source);
00051 return true;
00052
00053 } else {
00054 $this->errors[] = 'Could not open '.$this->filename.' mode "r+b"';
00055 return false;
00056 }
00057 }
00058 $this->errors[] = 'File is not writeable: '.$this->filename;
00059 return false;
00060 }
00061
00062 function FixID3v1Padding() {
00063
00064
00065
00066
00067 $getID3 = new getID3;
00068 $ThisFileInfo = $getID3->analyze($this->filename);
00069 if (isset($ThisFileInfo['tags']['id3v1'])) {
00070 foreach ($ThisFileInfo['tags']['id3v1'] as $key => $value) {
00071 $id3v1data[$key] = implode(',', $value);
00072 }
00073 $this->tag_data = $id3v1data;
00074 return $this->WriteID3v1();
00075 }
00076 return false;
00077 }
00078
00079 function RemoveID3v1() {
00080
00081 if (is_writeable($this->filename)) {
00082 if ($fp_source = @fopen($this->filename, 'r+b')) {
00083
00084 fseek($fp_source, -128, SEEK_END);
00085 if (fread($fp_source, 3) == 'TAG') {
00086 ftruncate($fp_source, filesize($this->filename) - 128);
00087 } else {
00088
00089 }
00090 fclose($fp_source);
00091 return true;
00092
00093 } else {
00094 $this->errors[] = 'Could not open '.$this->filename.' mode "r+b"';
00095 }
00096 } else {
00097 $this->errors[] = $this->filename.' is not writeable';
00098 }
00099 return false;
00100 }
00101
00102 }
00103
00104 ?>