00001 <?php
00004
00005
00007
00009
00010
00011
00012
00013
00015
00016
00017 class getid3_write_vorbiscomment
00018 {
00019
00020 var $filename;
00021 var $tag_data;
00022 var $warnings = array();
00023 var $errors = array();
00024
00025 function getid3_write_vorbiscomment() {
00026 return true;
00027 }
00028
00029 function WriteVorbisComment() {
00030
00031 if (!ini_get('safe_mode')) {
00032
00033
00034 $tempcommentsfilename = tempnam('*', 'getID3');
00035 if ($fpcomments = @fopen($tempcommentsfilename, 'wb')) {
00036
00037 foreach ($this->tag_data as $key => $value) {
00038 foreach ($value as $commentdata) {
00039 fwrite($fpcomments, $this->CleanVorbisCommentName($key).'='.$commentdata."\n");
00040 }
00041 }
00042 fclose($fpcomments);
00043
00044 } else {
00045
00046 $this->errors[] = 'failed to open temporary tags file "'.$tempcommentsfilename.'", tags not written';
00047 return false;
00048
00049 }
00050
00051 $oldignoreuserabort = ignore_user_abort(true);
00052 if (GETID3_OS_ISWINDOWS) {
00053
00054 if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 clearstatcache();
00065 $timestampbeforewriting = filemtime($this->filename);
00066
00067 $commandline = GETID3_HELPERAPPSDIR.'vorbiscomment.exe -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
00068 $VorbiscommentError = `$commandline`;
00069
00070 if (empty($VorbiscommentError)) {
00071 clearstatcache();
00072 if ($timestampbeforewriting == filemtime($this->filename)) {
00073 $VorbiscommentError = 'File modification timestamp has not changed - it looks like the tags were not written';
00074 }
00075 }
00076 } else {
00077 $VorbiscommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
00078 }
00079
00080 } else {
00081
00082 $commandline = 'vorbiscomment -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
00083 $VorbiscommentError = `$commandline`;
00084
00085 }
00086
00087
00088 unlink($tempcommentsfilename);
00089 ignore_user_abort($oldignoreuserabort);
00090
00091 if (!empty($VorbiscommentError)) {
00092
00093 $this->errors[] = 'system call to vorbiscomment failed with message: '."\n\n".$VorbiscommentError;
00094 return false;
00095
00096 }
00097
00098 return true;
00099 }
00100
00101 $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call vorbiscomment, tags not written';
00102 return false;
00103 }
00104
00105 function DeleteVorbisComment() {
00106 $this->tag_data = array(array());
00107 return $this->WriteVorbisComment();
00108 }
00109
00110 function CleanVorbisCommentName($originalcommentname) {
00111
00112
00113
00114
00115
00116
00117
00118 return strtoupper(ereg_replace('[^ -<>-}]', ' ', str_replace("\x00", ' ', $originalcommentname)));
00119
00120 }
00121
00122 }
00123
00124 ?>