123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- class getid3_write_vorbiscomment
- {
- var $filename;
- var $tag_data;
- var $warnings = array();
- var $errors = array();
- function getid3_write_vorbiscomment() {
- return true;
- }
- function WriteVorbisComment() {
- 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->CleanVorbisCommentName($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.'vorbiscomment.exe')) {
-
-
-
-
-
-
-
-
- clearstatcache();
- $timestampbeforewriting = filemtime($this->filename);
- $commandline = GETID3_HELPERAPPSDIR.'vorbiscomment.exe -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
- $VorbiscommentError = `$commandline`;
- if (empty($VorbiscommentError)) {
- clearstatcache();
- if ($timestampbeforewriting == filemtime($this->filename)) {
- $VorbiscommentError = 'File modification timestamp has not changed - it looks like the tags were not written';
- }
- }
- } else {
- $VorbiscommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
- }
- } else {
- $commandline = 'vorbiscomment -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
- $VorbiscommentError = `$commandline`;
- }
-
- unlink($tempcommentsfilename);
- ignore_user_abort($oldignoreuserabort);
- if (!empty($VorbiscommentError)) {
- $this->errors[] = 'system call to vorbiscomment failed with message: '."\n\n".$VorbiscommentError;
- return false;
- }
- return true;
- }
- $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call vorbiscomment, tags not written';
- return false;
- }
- function DeleteVorbisComment() {
- $this->tag_data = array(array());
- return $this->WriteVorbisComment();
- }
- function CleanVorbisCommentName($originalcommentname) {
-
-
-
-
-
-
- return strtoupper(ereg_replace('[^ -<>-}]', ' ', str_replace("\x00", ' ', $originalcommentname)));
- }
- }
- ?>
|