ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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

 getid3_write_vorbiscomment ()
 
 WriteVorbisComment ()
 
 DeleteVorbisComment ()
 
 CleanVorbisCommentName ($originalcommentname)
 
 getid3_write_vorbiscomment ()
 
 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 //

Definition at line 17 of file write.vorbiscomment.php.

Member Function Documentation

◆ CleanVorbisCommentName() [1/2]

getid3_write_vorbiscomment::CleanVorbisCommentName (   $originalcommentname)

Definition at line 110 of file write.vorbiscomment.php.

110 {
111 // A case-insensitive field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
112 // ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through
113 // 0x7A inclusive (a-z).
114
115 // replace invalid chars with a space, return uppercase text
116 // Thanks Chris Bolt <chris-getid3Øbolt*cx> for improving this function
117 // note: ereg_replace() replaces nulls with empty string (not space)
118 return strtoupper(ereg_replace('[^ -<>-}]', ' ', str_replace("\x00", ' ', $originalcommentname)));
119
120 }

Referenced by WriteVorbisComment().

+ Here is the caller graph for this function:

◆ CleanVorbisCommentName() [2/2]

getid3_write_vorbiscomment::CleanVorbisCommentName (   $originalcommentname)

Definition at line 108 of file write.vorbiscomment.php.

108 {
109 // A case-insensitive field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
110 // ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through
111 // 0x7A inclusive (a-z).
112
113 // replace invalid chars with a space, return uppercase text
114 // Thanks Chris Bolt <chris-getid3Øbolt*cx> for improving this function
115 // note: *reg_replace() replaces nulls with empty string (not space)
116 return strtoupper(preg_replace('#[^ -<>-}]#', ' ', str_replace("\x00", ' ', $originalcommentname)));
117
118 }

◆ DeleteVorbisComment() [1/2]

getid3_write_vorbiscomment::DeleteVorbisComment ( )

Definition at line 105 of file write.vorbiscomment.php.

105 {
106 $this->tag_data = array(array());
107 return $this->WriteVorbisComment();
108 }

References WriteVorbisComment().

+ Here is the call graph for this function:

◆ DeleteVorbisComment() [2/2]

getid3_write_vorbiscomment::DeleteVorbisComment ( )

Definition at line 103 of file write.vorbiscomment.php.

103 {
104 $this->tag_data = array(array());
105 return $this->WriteVorbisComment();
106 }

References WriteVorbisComment().

+ Here is the call graph for this function:

◆ getid3_write_vorbiscomment() [1/2]

getid3_write_vorbiscomment::getid3_write_vorbiscomment ( )

Definition at line 25 of file write.vorbiscomment.php.

25 {
26 return true;
27 }

◆ getid3_write_vorbiscomment() [2/2]

getid3_write_vorbiscomment::getid3_write_vorbiscomment ( )

Definition at line 26 of file write.vorbiscomment.php.

26 {
27 return true;
28 }

◆ WriteVorbisComment() [1/2]

getid3_write_vorbiscomment::WriteVorbisComment ( )

Definition at line 29 of file write.vorbiscomment.php.

29 {
30
31 if (!ini_get('safe_mode')) {
32
33 // Create file with new comments
34 $tempcommentsfilename = tempnam('*', 'getID3');
35 if ($fpcomments = @fopen($tempcommentsfilename, 'wb')) {
36
37 foreach ($this->tag_data as $key => $value) {
38 foreach ($value as $commentdata) {
39 fwrite($fpcomments, $this->CleanVorbisCommentName($key).'='.$commentdata."\n");
40 }
41 }
42 fclose($fpcomments);
43
44 } else {
45
46 $this->errors[] = 'failed to open temporary tags file "'.$tempcommentsfilename.'", tags not written';
47 return false;
48
49 }
50
51 $oldignoreuserabort = ignore_user_abort(true);
52 if (GETID3_OS_ISWINDOWS) {
53
54 if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
55 //$commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w --raw -c "'.$tempcommentsfilename.'" "'.str_replace('/', '\\', $this->filename).'"';
56 // vorbiscomment works fine if you copy-paste the above commandline into a command prompt,
57 // but refuses to work with `backtick` if there are "doublequotes" present around BOTH
58 // the metaflac pathname and the target filename. For whatever reason...??
59 // The solution is simply ensure that the metaflac pathname has no spaces,
60 // and therefore does not need to be quoted
61
62 // On top of that, if error messages are not always captured properly under Windows
63 // To at least see if there was a problem, compare file modification timestamps before and after writing
64 clearstatcache();
65 $timestampbeforewriting = filemtime($this->filename);
66
67 $commandline = GETID3_HELPERAPPSDIR.'vorbiscomment.exe -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
68 $VorbiscommentError = `$commandline`;
69
70 if (empty($VorbiscommentError)) {
71 clearstatcache();
72 if ($timestampbeforewriting == filemtime($this->filename)) {
73 $VorbiscommentError = 'File modification timestamp has not changed - it looks like the tags were not written';
74 }
75 }
76 } else {
77 $VorbiscommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
78 }
79
80 } else {
81
82 $commandline = 'vorbiscomment -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
83 $VorbiscommentError = `$commandline`;
84
85 }
86
87 // Remove temporary comments file
88 unlink($tempcommentsfilename);
89 ignore_user_abort($oldignoreuserabort);
90
91 if (!empty($VorbiscommentError)) {
92
93 $this->errors[] = 'system call to vorbiscomment failed with message: '."\n\n".$VorbiscommentError;
94 return false;
95
96 }
97
98 return true;
99 }
100
101 $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call vorbiscomment, tags not written';
102 return false;
103 }
CleanVorbisCommentName($originalcommentname)

References CleanVorbisCommentName().

Referenced by DeleteVorbisComment().

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

◆ WriteVorbisComment() [2/2]

getid3_write_vorbiscomment::WriteVorbisComment ( )

Definition at line 30 of file write.vorbiscomment.php.

30 {
31
32 if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
33 $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call vorbiscomment, tags not written';
34 return false;
35 }
36
37 // Create file with new comments
38 $tempcommentsfilename = tempnam(GETID3_TEMP_DIR, 'getID3');
39 if (is_writable($tempcommentsfilename) && is_file($tempcommentsfilename) && ($fpcomments = fopen($tempcommentsfilename, 'wb'))) {
40
41 foreach ($this->tag_data as $key => $value) {
42 foreach ($value as $commentdata) {
43 fwrite($fpcomments, $this->CleanVorbisCommentName($key).'='.$commentdata."\n");
44 }
45 }
46 fclose($fpcomments);
47
48 } else {
49 $this->errors[] = 'failed to open temporary tags file "'.$tempcommentsfilename.'", tags not written';
50 return false;
51 }
52
53 $oldignoreuserabort = ignore_user_abort(true);
54 if (GETID3_OS_ISWINDOWS) {
55
56 if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
57 //$commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w --raw -c "'.$tempcommentsfilename.'" "'.str_replace('/', '\\', $this->filename).'"';
58 // vorbiscomment works fine if you copy-paste the above commandline into a command prompt,
59 // but refuses to work with `backtick` if there are "doublequotes" present around BOTH
60 // the metaflac pathname and the target filename. For whatever reason...??
61 // The solution is simply ensure that the metaflac pathname has no spaces,
62 // and therefore does not need to be quoted
63
64 // On top of that, if error messages are not always captured properly under Windows
65 // To at least see if there was a problem, compare file modification timestamps before and after writing
66 clearstatcache();
67 $timestampbeforewriting = filemtime($this->filename);
68
69 $commandline = GETID3_HELPERAPPSDIR.'vorbiscomment.exe -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
70 $VorbiscommentError = `$commandline`;
71
72 if (empty($VorbiscommentError)) {
73 clearstatcache();
74 if ($timestampbeforewriting == filemtime($this->filename)) {
75 $VorbiscommentError = 'File modification timestamp has not changed - it looks like the tags were not written';
76 }
77 }
78 } else {
79 $VorbiscommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
80 }
81
82 } else {
83
84 $commandline = 'vorbiscomment -w --raw -c "'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
85 $VorbiscommentError = `$commandline`;
86
87 }
88
89 // Remove temporary comments file
90 unlink($tempcommentsfilename);
91 ignore_user_abort($oldignoreuserabort);
92
93 if (!empty($VorbiscommentError)) {
94
95 $this->errors[] = 'system call to vorbiscomment failed with message: '."\n\n".$VorbiscommentError;
96 return false;
97
98 }
99
100 return true;
101 }

References CleanVorbisCommentName().

+ Here is the call graph for this function:

Field Documentation

◆ $errors

getid3_write_vorbiscomment::$errors = array()

Definition at line 23 of file write.vorbiscomment.php.

◆ $filename

getid3_write_vorbiscomment::$filename

Definition at line 20 of file write.vorbiscomment.php.

◆ $tag_data

getid3_write_vorbiscomment::$tag_data

Definition at line 21 of file write.vorbiscomment.php.

◆ $warnings

getid3_write_vorbiscomment::$warnings = array()

Definition at line 22 of file write.vorbiscomment.php.


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