Go to the documentation of this file.00001 <?php
00004
00005
00007
00009
00010
00011
00012
00013
00015
00016
00017 class getid3_write_metaflac
00018 {
00019
00020 var $filename;
00021 var $tag_data;
00022 var $warnings = array();
00023 var $errors = array();
00024
00025 function getid3_write_metaflac() {
00026 return true;
00027 }
00028
00029 function WriteMetaFLAC() {
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->CleanmetaflacName($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.'metaflac.exe')) {
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 clearstatcache();
00065 $timestampbeforewriting = filemtime($this->filename);
00066
00067 $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --no-utf8-convert --remove-vc-all --import-vc-from="'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
00068 $metaflacError = `$commandline`;
00069
00070 if (empty($metaflacError)) {
00071 clearstatcache();
00072 if ($timestampbeforewriting == filemtime($this->filename)) {
00073 $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not written';
00074 }
00075 }
00076 } else {
00077 $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
00078 }
00079
00080 } else {
00081
00082
00083 $commandline = 'metaflac --no-utf8-convert --remove-vc-all --import-vc-from='.$tempcommentsfilename.' "'.$this->filename.'" 2>&1';
00084 $metaflacError = `$commandline`;
00085
00086 }
00087
00088
00089 unlink($tempcommentsfilename);
00090 ignore_user_abort($oldignoreuserabort);
00091
00092 if (!empty($metaflacError)) {
00093
00094 $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
00095 return false;
00096
00097 }
00098
00099 return true;
00100 }
00101
00102 $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not written';
00103 return false;
00104 }
00105
00106
00107 function DeleteMetaFLAC() {
00108
00109 if (!ini_get('safe_mode')) {
00110
00111 $oldignoreuserabort = ignore_user_abort(true);
00112 if (GETID3_OS_ISWINDOWS) {
00113
00114 if (file_exists(GETID3_HELPERAPPSDIR.'metaflac.exe')) {
00115
00116 clearstatcache();
00117 $timestampbeforewriting = filemtime($this->filename);
00118
00119 $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --remove-vc-all "'.$this->filename.'" 2>&1';
00120 $metaflacError = `$commandline`;
00121
00122 if (empty($metaflacError)) {
00123 clearstatcache();
00124 if ($timestampbeforewriting == filemtime($this->filename)) {
00125 $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not deleted';
00126 }
00127 }
00128 } else {
00129 $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
00130 }
00131
00132 } else {
00133
00134
00135 $commandline = 'metaflac --remove-vc-all "'.$this->filename.'" 2>&1';
00136 $metaflacError = `$commandline`;
00137
00138 }
00139
00140 ignore_user_abort($oldignoreuserabort);
00141
00142 if (!empty($metaflacError)) {
00143 $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
00144 return false;
00145 }
00146 return true;
00147 }
00148 $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not deleted';
00149 return false;
00150 }
00151
00152
00153 function CleanmetaflacName($originalcommentname) {
00154
00155
00156
00157
00158
00159
00160
00161 return strtoupper(ereg_replace('[^ -<>-}]', ' ', str_replace("\x00", ' ', $originalcommentname)));
00162
00163 }
00164
00165 }
00166
00167 ?>