ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GetId3\Write\Vorbiscomment Class Reference

GetId3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //. More...

+ Collaboration diagram for GetId3\Write\Vorbiscomment:

Public Member Functions

 __construct ()
 
 WriteVorbisComment ()
 
 DeleteVorbisComment ()
 
 CleanVorbisCommentName ($originalcommentname)
 

Data Fields

 $filename
 
 $tag_data
 
 $warnings = array()
 
 $errors = array()
 

Detailed Description

GetId3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //.

module for writing VorbisComment tags

Author
James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g http://www.getid3.org helperapps/vorbiscomment.exe

Definition at line 29 of file Vorbiscomment.php.

Constructor & Destructor Documentation

◆ __construct()

GetId3\Write\Vorbiscomment::__construct ( )
Returns
boolean

Definition at line 49 of file Vorbiscomment.php.

50 {
51 return true;
52 }

Member Function Documentation

◆ CleanVorbisCommentName()

GetId3\Write\Vorbiscomment::CleanVorbisCommentName (   $originalcommentname)
Parameters
type$originalcommentname
Returns
type

Definition at line 150 of file Vorbiscomment.php.

151 {
152 // A case-insensitive field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
153 // ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through
154 // 0x7A inclusive (a-z).
155
156 // replace invalid chars with a space, return uppercase text
157 // Thanks Chris Bolt <chris-getid3Øbolt*cx> for improving this function
158 // note: *reg_replace() replaces nulls with empty string (not space)
159 return strtoupper(preg_replace('#[^ -<>-}]#', ' ', str_replace("\x00", ' ', $originalcommentname)));
160
161 }

Referenced by GetId3\Write\Vorbiscomment\WriteVorbisComment().

+ Here is the caller graph for this function:

◆ DeleteVorbisComment()

GetId3\Write\Vorbiscomment::DeleteVorbisComment ( )
Returns
type

Definition at line 138 of file Vorbiscomment.php.

139 {
140 $this->tag_data = array(array());
141
142 return $this->WriteVorbisComment();
143 }

References GetId3\Write\Vorbiscomment\WriteVorbisComment().

+ Here is the call graph for this function:

◆ WriteVorbisComment()

GetId3\Write\Vorbiscomment::WriteVorbisComment ( )
Returns
boolean

Definition at line 58 of file Vorbiscomment.php.

59 {
60 if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
61 $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call vorbiscomment, tags not written';
62
63 return false;
64 }
65
66 // Create file with new comments
67 $tempcommentsfilename = tempnam(GetId3Core::getTempDir(), 'getID3');
68 if (is_writable($tempcommentsfilename) && is_file($tempcommentsfilename) && ($fpcomments = fopen($tempcommentsfilename, 'wb'))) {
69
70 foreach ($this->tag_data as $key => $value) {
71 foreach ($value as $commentdata) {
72 fwrite($fpcomments, $this->CleanVorbisCommentName($key).'='.$commentdata."\n");
73 }
74 }
75 fclose($fpcomments);
76
77 } else {
78 $this->errors[] = 'failed to open temporary tags file "'.$tempcommentsfilename.'", tags not written';
79
80 return false;
81 }
82
83 $oldignoreuserabort = ignore_user_abort(true);
85
86 if (file_exists(GetId3Core::getHelperAppsDir().'vorbiscomment.exe')) {
87 //$commandline = '"'.GetId3Core::getHelperAppsDir().'vorbiscomment.exe" -w --raw -c "'.$tempcommentsfilename.'" "'.str_replace('/', '\\', $this->filename).'"';
88 // vorbiscomment works fine if you copy-paste the above commandline into a command prompt,
89 // but refuses to work with `backtick` if there are "doublequotes" present around BOTH
90 // the metaflac pathname and the target filename. For whatever reason...??
91 // The solution is simply ensure that the metaflac pathname has no spaces,
92 // and therefore does not need to be quoted
93
94 // On top of that, if error messages are not always captured properly under Windows
95 // To at least see if there was a problem, compare file modification timestamps before and after writing
96 clearstatcache();
97 $timestampbeforewriting = filemtime($this->filename);
98
99 $commandline = GetId3Core::getHelperAppsDir().'vorbiscomment.exe -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
100 $VorbiscommentError = `$commandline`;
101
102 if (empty($VorbiscommentError)) {
103 clearstatcache();
104 if ($timestampbeforewriting == filemtime($this->filename)) {
105 $VorbiscommentError = 'File modification timestamp has not changed - it looks like the tags were not written';
106 }
107 }
108 } else {
109 $VorbiscommentError = 'vorbiscomment.exe not found in '.GetId3Core::getHelperAppsDir();
110 }
111
112 } else {
113
114 $commandline = 'vorbiscomment -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
115 $VorbiscommentError = `$commandline`;
116
117 }
118
119 // Remove temporary comments file
120 unlink($tempcommentsfilename);
121 ignore_user_abort($oldignoreuserabort);
122
123 if (!empty($VorbiscommentError)) {
124
125 $this->errors[] = 'system call to vorbiscomment failed with message: '."\n\n".$VorbiscommentError;
126
127 return false;
128
129 }
130
131 return true;
132 }
static environmentIsWindows()
static getHelperAppsDir()
Definition: GetId3Core.php:186
CleanVorbisCommentName($originalcommentname)

References GetId3\Write\Vorbiscomment\CleanVorbisCommentName(), GetId3\GetId3Core\environmentIsWindows(), GetId3\GetId3Core\getHelperAppsDir(), and GetId3\GetId3Core\getTempDir().

Referenced by GetId3\Write\Vorbiscomment\DeleteVorbisComment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $errors

GetId3\Write\Vorbiscomment::$errors = array()

Definition at line 43 of file Vorbiscomment.php.

◆ $filename

GetId3\Write\Vorbiscomment::$filename

Definition at line 32 of file Vorbiscomment.php.

◆ $tag_data

GetId3\Write\Vorbiscomment::$tag_data

Definition at line 33 of file Vorbiscomment.php.

◆ $warnings

GetId3\Write\Vorbiscomment::$warnings = array()

Definition at line 38 of file Vorbiscomment.php.


The documentation for this class was generated from the following file: