123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <?php
- class getid3_write_metaflac
- {
- var $filename;
- var $tag_data;
- var $warnings = array();
- var $errors = array();
- function getid3_write_metaflac() {
- return true;
- }
- function WriteMetaFLAC() {
- if (!ini_get('safe_mode')) {
-
- $tempcommentsfilename = tempnam('*', 'getID3');
- if ($fpcomments = @fopen($tempcommentsfilename, 'wb')) {
- foreach ($this->tag_data as $key => $value) {
- foreach ($value as $commentdata) {
- fwrite($fpcomments, $this->CleanmetaflacName($key).'='.$commentdata."\n");
- }
- }
- fclose($fpcomments);
- } else {
- $this->errors[] = 'failed to open temporary tags file "'.$tempcommentsfilename.'", tags not written';
- return false;
- }
- $oldignoreuserabort = ignore_user_abort(true);
- if (GETID3_OS_ISWINDOWS) {
- if (file_exists(GETID3_HELPERAPPSDIR.'metaflac.exe')) {
-
-
-
-
-
-
-
-
- clearstatcache();
- $timestampbeforewriting = filemtime($this->filename);
- $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --no-utf8-convert --remove-all-tags --import-tags-from="'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
- $metaflacError = `$commandline`;
- if (empty($metaflacError)) {
- clearstatcache();
- if ($timestampbeforewriting == filemtime($this->filename)) {
- $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not written';
- }
- }
- } else {
- $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
- }
- } else {
-
- $commandline = 'metaflac --no-utf8-convert --remove-all-tags --import-tags-from='.$tempcommentsfilename.' "'.$this->filename.'" 2>&1';
- $metaflacError = `$commandline`;
- }
-
- unlink($tempcommentsfilename);
- ignore_user_abort($oldignoreuserabort);
- if (!empty($metaflacError)) {
- $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
- return false;
- }
- return true;
- }
- $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not written';
- return false;
- }
- function DeleteMetaFLAC() {
- if (!ini_get('safe_mode')) {
- $oldignoreuserabort = ignore_user_abort(true);
- if (GETID3_OS_ISWINDOWS) {
- if (file_exists(GETID3_HELPERAPPSDIR.'metaflac.exe')) {
-
- clearstatcache();
- $timestampbeforewriting = filemtime($this->filename);
- $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --remove-all-tags "'.$this->filename.'" 2>&1';
- $metaflacError = `$commandline`;
- if (empty($metaflacError)) {
- clearstatcache();
- if ($timestampbeforewriting == filemtime($this->filename)) {
- $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not deleted';
- }
- }
- } else {
- $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
- }
- } else {
-
- $commandline = 'metaflac --remove-all-tags "'.$this->filename.'" 2>&1';
- $metaflacError = `$commandline`;
- }
- ignore_user_abort($oldignoreuserabort);
- if (!empty($metaflacError)) {
- $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
- return false;
- }
- return true;
- }
- $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not deleted';
- return false;
- }
- function CleanmetaflacName($originalcommentname) {
-
-
-
-
-
-
- return strtoupper(ereg_replace('[^ -<>-}]', ' ', str_replace("\x00", ' ', $originalcommentname)));
- }
- }
- ?>
|