<?php
+
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
-// available at http://getid3.sourceforge.net //
-// or http://www.getid3.org //
-// also https://github.com/JamesHeinrich/getID3 //
-/////////////////////////////////////////////////////////////////
-// See readme.txt for more details //
+// available at https://github.com/JamesHeinrich/getID3 //
+// or https://www.getid3.org //
+// or http://getid3.sourceforge.net //
+// see readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// write.real.php //
class getid3_write_real
{
+ /**
+ * @var string
+ */
public $filename;
+
+ /**
+ * @var array
+ */
public $tag_data = array();
- public $fread_buffer_size = 32768; // read buffer size in bytes
- public $warnings = array(); // any non-critical errors will be stored here
- public $errors = array(); // any critical errors will be stored here
- public $paddedlength = 512; // minimum length of CONT tag in bytes
+
+ /**
+ * Read buffer size in bytes.
+ *
+ * @var int
+ */
+ public $fread_buffer_size = 32768;
+
+ /**
+ * Any non-critical errors will be stored here.
+ *
+ * @var array
+ */
+ public $warnings = array();
+
+ /**
+ * Any critical errors will be stored here.
+ *
+ * @var array
+ */
+ public $errors = array();
+
+ /**
+ * Minimum length of CONT tag in bytes.
+ *
+ * @var int
+ */
+ public $paddedlength = 512;
public function __construct() {
- return true;
}
+ /**
+ * @return bool
+ */
public function WriteReal() {
// File MUST be writeable - CHMOD(646) at least
- if (is_writeable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'r+b'))) {
+ if (getID3::is_writable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'r+b'))) {
// Initialize getID3 engine
$getID3 = new getID3;
fclose($fp_source);
return false;
}
+ $oldChunkInfo = array();
foreach ($OldThisFileInfo['real']['chunks'] as $chunknumber => $chunkarray) {
$oldChunkInfo[$chunkarray['name']] = $chunkarray;
}
$AfterOffset = $oldChunkInfo['CONT']['offset'] + $oldChunkInfo['CONT']['length'];
}
if ($tempfilename = tempnam(GETID3_TEMP_DIR, 'getID3')) {
- if (is_writable($tempfilename) && is_file($tempfilename) && ($fp_temp = fopen($tempfilename, 'wb'))) {
+ if (getID3::is_writable($tempfilename) && is_file($tempfilename) && ($fp_temp = fopen($tempfilename, 'wb'))) {
rewind($fp_source);
fwrite($fp_temp, fread($fp_source, $BeforeOffset));
return false;
}
+ /**
+ * @param array $chunks
+ *
+ * @return string
+ */
public function GenerateRMFchunk(&$chunks) {
$oldCONTexists = false;
+ $chunkNameKeys = array();
foreach ($chunks as $key => $chunk) {
$chunkNameKeys[$chunk['name']] = $key;
if ($chunk['name'] == 'CONT') {
return $RMFchunk;
}
+ /**
+ * @param array $chunks
+ * @param string $new_CONT_tag_data
+ *
+ * @return string
+ */
public function GeneratePROPchunk(&$chunks, &$new_CONT_tag_data) {
$old_CONT_length = 0;
$old_DATA_offset = 0;
$old_INDX_offset = 0;
+ $chunkNameKeys = array();
foreach ($chunks as $key => $chunk) {
$chunkNameKeys[$chunk['name']] = $key;
if ($chunk['name'] == 'CONT') {
return $PROPchunk;
}
+ /**
+ * @return string
+ */
public function GenerateCONTchunk() {
foreach ($this->tag_data as $key => $value) {
// limit each value to 0xFFFF bytes
return $CONTchunk;
}
+ /**
+ * @return bool
+ */
public function RemoveReal() {
// File MUST be writeable - CHMOD(646) at least
- if (is_writeable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'r+b'))) {
+ if (getID3::is_writable($this->filename) && is_file($this->filename) && ($fp_source = fopen($this->filename, 'r+b'))) {
// Initialize getID3 engine
$getID3 = new getID3;
$BeforeOffset = $oldChunkInfo['CONT']['offset'];
$AfterOffset = $oldChunkInfo['CONT']['offset'] + $oldChunkInfo['CONT']['length'];
if ($tempfilename = tempnam(GETID3_TEMP_DIR, 'getID3')) {
- if (is_writable($tempfilename) && is_file($tempfilename) && ($fp_temp = fopen($tempfilename, 'wb'))) {
+ if (getID3::is_writable($tempfilename) && is_file($tempfilename) && ($fp_temp = fopen($tempfilename, 'wb'))) {
rewind($fp_source);
fwrite($fp_temp, fread($fp_source, $BeforeOffset));