123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- class getid3_write_vorbiscomment
- {
-
-
- public $filename;
-
-
-
- public $tag_data;
-
-
-
- public $warnings = array();
-
-
-
- public $errors = array();
-
- public function __construct() {
- }
-
-
-
- public function WriteVorbisComment() {
-
- if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
- $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call vorbiscomment, tags not written';
- return false;
- }
-
-
- $tempcommentsfilename = tempnam(GETID3_TEMP_DIR, 'getID3');
- if (getID3::is_writable($tempcommentsfilename) && is_file($tempcommentsfilename) && ($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;
- }
-
-
-
- public function DeleteVorbisComment() {
- $this->tag_data = array(array());
- return $this->WriteVorbisComment();
- }
-
-
-
- public function CleanVorbisCommentName($originalcommentname) {
-
-
-
-
-
-
-
- return strtoupper(preg_replace('#[^ -<>-}]#', ' ', str_replace("\x00", ' ', $originalcommentname)));
-
- }
-
- }
|