getID3() by James Heinrich <info@getid3.org> // More...
Public Member Functions | |
| getid3_write_vorbiscomment () | |
| WriteVorbisComment () | |
| DeleteVorbisComment () | |
| CleanVorbisCommentName ($originalcommentname) | |
Data Fields | |
| $filename | |
| $tag_data | |
| $warnings = array() | |
| $errors = array() | |
getID3() by James Heinrich <info@getid3.org> //
Definition at line 17 of file write.vorbiscomment.php.
| getid3_write_vorbiscomment::CleanVorbisCommentName | ( | $ | originalcommentname | ) |
Definition at line 110 of file write.vorbiscomment.php.
Referenced by WriteVorbisComment().
{
// A case-insensitive field name that may consist of ASCII 0x20 through 0x7D, 0x3D ('=') excluded.
// ASCII 0x41 through 0x5A inclusive (A-Z) is to be considered equivalent to ASCII 0x61 through
// 0x7A inclusive (a-z).
// replace invalid chars with a space, return uppercase text
// Thanks Chris Bolt <chris-getid3Øbolt*cx> for improving this function
// note: ereg_replace() replaces nulls with empty string (not space)
return strtoupper(ereg_replace('[^ -<>-}]', ' ', str_replace("\x00", ' ', $originalcommentname)));
}
Here is the caller graph for this function:| getid3_write_vorbiscomment::DeleteVorbisComment | ( | ) |
Definition at line 105 of file write.vorbiscomment.php.
References WriteVorbisComment().
{
$this->tag_data = array(array());
return $this->WriteVorbisComment();
}
Here is the call graph for this function:| getid3_write_vorbiscomment::getid3_write_vorbiscomment | ( | ) |
Definition at line 25 of file write.vorbiscomment.php.
{
return true;
}
| getid3_write_vorbiscomment::WriteVorbisComment | ( | ) |
Definition at line 29 of file write.vorbiscomment.php.
References CleanVorbisCommentName().
Referenced by DeleteVorbisComment().
{
if (!ini_get('safe_mode')) {
// Create file with new comments
$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')) {
//$commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w --raw -c "'.$tempcommentsfilename.'" "'.str_replace('/', '\\', $this->filename).'"';
// vorbiscomment works fine if you copy-paste the above commandline into a command prompt,
// but refuses to work with `backtick` if there are "doublequotes" present around BOTH
// the metaflac pathname and the target filename. For whatever reason...??
// The solution is simply ensure that the metaflac pathname has no spaces,
// and therefore does not need to be quoted
// On top of that, if error messages are not always captured properly under Windows
// To at least see if there was a problem, compare file modification timestamps before and after writing
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`;
}
// Remove temporary comments file
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;
}
Here is the call graph for this function:
Here is the caller graph for this function:| getid3_write_vorbiscomment::$errors = array() |
Definition at line 23 of file write.vorbiscomment.php.
| getid3_write_vorbiscomment::$filename |
Definition at line 20 of file write.vorbiscomment.php.
| getid3_write_vorbiscomment::$tag_data |
Definition at line 21 of file write.vorbiscomment.php.
| getid3_write_vorbiscomment::$warnings = array() |
Definition at line 22 of file write.vorbiscomment.php.
1.7.1