ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
getid3_write_metaflac Class Reference

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

+ Collaboration diagram for getid3_write_metaflac:

Public Member Functions

 getid3_write_metaflac ()
 
 WriteMetaFLAC ()
 
 DeleteMetaFLAC ()
 
 CleanmetaflacName ($originalcommentname)
 
 getid3_write_metaflac ()
 
 WriteMetaFLAC ()
 
 DeleteMetaFLAC ()
 
 CleanmetaflacName ($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.metaflac.php.

Member Function Documentation

◆ CleanmetaflacName() [1/2]

getid3_write_metaflac::CleanmetaflacName (   $originalcommentname)

Definition at line 153 of file write.metaflac.php.

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

Referenced by WriteMetaFLAC().

+ Here is the caller graph for this function:

◆ CleanmetaflacName() [2/2]

getid3_write_metaflac::CleanmetaflacName (   $originalcommentname)

Definition at line 150 of file write.metaflac.php.

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

◆ DeleteMetaFLAC() [1/2]

getid3_write_metaflac::DeleteMetaFLAC ( )

Definition at line 107 of file write.metaflac.php.

107 {
108
109 if (!ini_get('safe_mode')) {
110
111 $oldignoreuserabort = ignore_user_abort(true);
112 if (GETID3_OS_ISWINDOWS) {
113
114 if (file_exists(GETID3_HELPERAPPSDIR.'metaflac.exe')) {
115 // To at least see if there was a problem, compare file modification timestamps before and after writing
116 clearstatcache();
117 $timestampbeforewriting = filemtime($this->filename);
118
119 $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --remove-vc-all "'.$this->filename.'" 2>&1';
120 $metaflacError = `$commandline`;
121
122 if (empty($metaflacError)) {
123 clearstatcache();
124 if ($timestampbeforewriting == filemtime($this->filename)) {
125 $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not deleted';
126 }
127 }
128 } else {
129 $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
130 }
131
132 } else {
133
134 // It's simpler on *nix
135 $commandline = 'metaflac --remove-vc-all "'.$this->filename.'" 2>&1';
136 $metaflacError = `$commandline`;
137
138 }
139
140 ignore_user_abort($oldignoreuserabort);
141
142 if (!empty($metaflacError)) {
143 $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
144 return false;
145 }
146 return true;
147 }
148 $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not deleted';
149 return false;
150 }

◆ DeleteMetaFLAC() [2/2]

getid3_write_metaflac::DeleteMetaFLAC ( )

Definition at line 104 of file write.metaflac.php.

104 {
105
106 if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
107 $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not deleted';
108 return false;
109 }
110
111 $oldignoreuserabort = ignore_user_abort(true);
112 if (GETID3_OS_ISWINDOWS) {
113
114 if (file_exists(GETID3_HELPERAPPSDIR.'metaflac.exe')) {
115 // To at least see if there was a problem, compare file modification timestamps before and after writing
116 clearstatcache();
117 $timestampbeforewriting = filemtime($this->filename);
118
119 $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --remove-all-tags "'.$this->filename.'" 2>&1';
120 $metaflacError = `$commandline`;
121
122 if (empty($metaflacError)) {
123 clearstatcache();
124 if ($timestampbeforewriting == filemtime($this->filename)) {
125 $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not deleted';
126 }
127 }
128 } else {
129 $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
130 }
131
132 } else {
133
134 // It's simpler on *nix
135 $commandline = 'metaflac --remove-all-tags "'.$this->filename.'" 2>&1';
136 $metaflacError = `$commandline`;
137
138 }
139
140 ignore_user_abort($oldignoreuserabort);
141
142 if (!empty($metaflacError)) {
143 $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
144 return false;
145 }
146 return true;
147 }

◆ getid3_write_metaflac() [1/2]

getid3_write_metaflac::getid3_write_metaflac ( )

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

25 {
26 return true;
27 }

◆ getid3_write_metaflac() [2/2]

getid3_write_metaflac::getid3_write_metaflac ( )

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

26 {
27 return true;
28 }

◆ WriteMetaFLAC() [1/2]

getid3_write_metaflac::WriteMetaFLAC ( )

Definition at line 29 of file write.metaflac.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->CleanmetaflacName($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.'metaflac.exe')) {
55 //$commandline = '"'.GETID3_HELPERAPPSDIR.'metaflac.exe" --no-utf8-convert --remove-vc-all --import-vc-from="'.$tempcommentsfilename.'" "'.str_replace('/', '\\', $this->filename).'"';
56 // metaflac 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.'metaflac.exe --no-utf8-convert --remove-vc-all --import-vc-from="'.$tempcommentsfilename.'" "'.$this->filename.'" 2>&1';
68 $metaflacError = `$commandline`;
69
70 if (empty($metaflacError)) {
71 clearstatcache();
72 if ($timestampbeforewriting == filemtime($this->filename)) {
73 $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not written';
74 }
75 }
76 } else {
77 $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
78 }
79
80 } else {
81
82 // It's simpler on *nix
83 $commandline = 'metaflac --no-utf8-convert --remove-vc-all --import-vc-from='.$tempcommentsfilename.' "'.$this->filename.'" 2>&1';
84 $metaflacError = `$commandline`;
85
86 }
87
88 // Remove temporary comments file
89 unlink($tempcommentsfilename);
90 ignore_user_abort($oldignoreuserabort);
91
92 if (!empty($metaflacError)) {
93
94 $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
95 return false;
96
97 }
98
99 return true;
100 }
101
102 $this->errors[] = 'PHP running in Safe Mode (backtick operator not available) - cannot call metaflac, tags not written';
103 return false;
104 }
CleanmetaflacName($originalcommentname)

References CleanmetaflacName().

+ Here is the call graph for this function:

◆ WriteMetaFLAC() [2/2]

getid3_write_metaflac::WriteMetaFLAC ( )

Definition at line 30 of file write.metaflac.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 metaflac, 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 foreach ($this->tag_data as $key => $value) {
41 foreach ($value as $commentdata) {
42 fwrite($fpcomments, $this->CleanmetaflacName($key).'='.$commentdata."\n");
43 }
44 }
45 fclose($fpcomments);
46
47 } else {
48 $this->errors[] = 'failed to open temporary tags file, tags not written - fopen("'.$tempcommentsfilename.'", "wb")';
49 return false;
50 }
51
52 $oldignoreuserabort = ignore_user_abort(true);
53 if (GETID3_OS_ISWINDOWS) {
54
55 if (file_exists(GETID3_HELPERAPPSDIR.'metaflac.exe')) {
56 //$commandline = '"'.GETID3_HELPERAPPSDIR.'metaflac.exe" --no-utf8-convert --remove-all-tags --import-tags-from="'.$tempcommentsfilename.'" "'.str_replace('/', '\\', $this->filename).'"';
57 // metaflac works fine if you copy-paste the above commandline into a command prompt,
58 // but refuses to work with `backtick` if there are "doublequotes" present around BOTH
59 // the metaflac pathname and the target filename. For whatever reason...??
60 // The solution is simply ensure that the metaflac pathname has no spaces,
61 // and therefore does not need to be quoted
62
63 // On top of that, if error messages are not always captured properly under Windows
64 // To at least see if there was a problem, compare file modification timestamps before and after writing
65 clearstatcache();
66 $timestampbeforewriting = filemtime($this->filename);
67
68 $commandline = GETID3_HELPERAPPSDIR.'metaflac.exe --no-utf8-convert --remove-all-tags --import-tags-from='.escapeshellarg($tempcommentsfilename).' '.escapeshellarg($this->filename).' 2>&1';
69 $metaflacError = `$commandline`;
70
71 if (empty($metaflacError)) {
72 clearstatcache();
73 if ($timestampbeforewriting == filemtime($this->filename)) {
74 $metaflacError = 'File modification timestamp has not changed - it looks like the tags were not written';
75 }
76 }
77 } else {
78 $metaflacError = 'metaflac.exe not found in '.GETID3_HELPERAPPSDIR;
79 }
80
81 } else {
82
83 // It's simpler on *nix
84 $commandline = 'metaflac --no-utf8-convert --remove-all-tags --import-tags-from='.escapeshellarg($tempcommentsfilename).' '.escapeshellarg($this->filename).' 2>&1';
85 $metaflacError = `$commandline`;
86
87 }
88
89 // Remove temporary comments file
90 unlink($tempcommentsfilename);
91 ignore_user_abort($oldignoreuserabort);
92
93 if (!empty($metaflacError)) {
94
95 $this->errors[] = 'System call to metaflac failed with this message returned: '."\n\n".$metaflacError;
96 return false;
97
98 }
99
100 return true;
101 }

References CleanmetaflacName().

+ Here is the call graph for this function:

Field Documentation

◆ $errors

getid3_write_metaflac::$errors = array()

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

◆ $filename

getid3_write_metaflac::$filename

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

◆ $tag_data

getid3_write_metaflac::$tag_data

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

◆ $warnings

getid3_write_metaflac::$warnings = array()

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


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