--- a/wp/wp-includes/ID3/getid3.php Tue Jun 09 11:14:17 2015 +0000
+++ b/wp/wp-includes/ID3/getid3.php Mon Oct 14 17:39:30 2019 +0200
@@ -22,13 +22,16 @@
if (!defined('IMG_JPG') && defined('IMAGETYPE_JPEG')) {
define('IMG_JPG', IMAGETYPE_JPEG);
}
+if (!defined('ENT_SUBSTITUTE')) { // PHP5.3 adds ENT_IGNORE, PHP5.4 adds ENT_SUBSTITUTE
+ define('ENT_SUBSTITUTE', (defined('ENT_IGNORE') ? ENT_IGNORE : 8));
+}
// attempt to define temp dir as something flexible but reliable
$temp_dir = ini_get('upload_tmp_dir');
if ($temp_dir && (!is_dir($temp_dir) || !is_readable($temp_dir))) {
$temp_dir = '';
}
-if (!$temp_dir) {
+if (!$temp_dir && function_exists('sys_get_temp_dir')) { // sys_get_temp_dir added in PHP v5.2.1
// sys_get_temp_dir() may give inaccessible temp dir, e.g. with open_basedir on virtual hosts
$temp_dir = sys_get_temp_dir();
}
@@ -109,7 +112,7 @@
protected $startup_error = '';
protected $startup_warning = '';
- const VERSION = '1.9.8-20140511';
+ const VERSION = '1.9.14-201706111222';
const FREAD_BUFFER_SIZE = 32768;
const ATTACHMENTS_NONE = false;
@@ -120,19 +123,19 @@
// Check memory
$this->memory_limit = ini_get('memory_limit');
- if (preg_match('#([0-9]+)M#i', $this->memory_limit, $matches)) {
+ if (preg_match('#([0-9]+) ?M#i', $this->memory_limit, $matches)) {
// could be stored as "16M" rather than 16777216 for example
$this->memory_limit = $matches[1] * 1048576;
- } elseif (preg_match('#([0-9]+)G#i', $this->memory_limit, $matches)) { // The 'G' modifier is available since PHP 5.1.0
+ } elseif (preg_match('#([0-9]+) ?G#i', $this->memory_limit, $matches)) { // The 'G' modifier is available since PHP 5.1.0
// could be stored as "2G" rather than 2147483648 for example
$this->memory_limit = $matches[1] * 1073741824;
}
if ($this->memory_limit <= 0) {
// memory limits probably disabled
} elseif ($this->memory_limit <= 4194304) {
- $this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini';
+ $this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini'."\n";
} elseif ($this->memory_limit <= 12582912) {
- $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
+ $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini'."\n";
}
// Check safe_mode off
@@ -140,27 +143,30 @@
$this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
}
- if (intval(ini_get('mbstring.func_overload')) > 0) {
- $this->warning('WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", this may break things.');
+ if (($mbstring_func_overload = ini_get('mbstring.func_overload')) && ($mbstring_func_overload & 0x02)) {
+ // http://php.net/manual/en/mbstring.overload.php
+ // "mbstring.func_overload in php.ini is a positive value that represents a combination of bitmasks specifying the categories of functions to be overloaded. It should be set to 1 to overload the mail() function. 2 for string functions, 4 for regular expression functions"
+ // getID3 cannot run when string functions are overloaded. It doesn't matter if mail() or ereg* functions are overloaded since getID3 does not use those.
+ $this->startup_error .= 'WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", getID3 cannot run with this setting (bitmask 2 (string functions) cannot be set). Recommended to disable entirely.'."\n";
}
// Check for magic_quotes_runtime
if (function_exists('get_magic_quotes_runtime')) {
if (get_magic_quotes_runtime()) {
- return $this->startup_error('magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).');
+ $this->startup_error .= 'magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).'."\n";
}
}
// Check for magic_quotes_gpc
if (function_exists('magic_quotes_gpc')) {
if (get_magic_quotes_gpc()) {
- return $this->startup_error('magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).');
+ $this->startup_error .= 'magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).'."\n";
}
}
// Load support library
if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
- $this->startup_error .= 'getid3.lib.php is missing or corrupt';
+ $this->startup_error .= 'getid3.lib.php is missing or corrupt'."\n";
}
if ($this->option_max_2gb_check === null) {
@@ -179,7 +185,7 @@
$helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
if (!is_dir($helperappsdir)) {
- $this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
+ $this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist'."\n";
} elseif (strpos(realpath($helperappsdir), ' ') !== false) {
$DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
$path_so_far = array();
@@ -199,7 +205,7 @@
}
}
} else {
- $this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.';
+ $this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.'."\n";
}
}
$path_so_far[] = $value;
@@ -209,6 +215,11 @@
define('GETID3_HELPERAPPSDIR', $helperappsdir.DIRECTORY_SEPARATOR);
}
+ if (!empty($this->startup_error)) {
+ echo $this->startup_error;
+ throw new getid3_exception($this->startup_error);
+ }
+
return true;
}
@@ -236,28 +247,30 @@
}
- public function openfile($filename) {
+ public function openfile($filename, $filesize=null) {
try {
if (!empty($this->startup_error)) {
throw new getid3_exception($this->startup_error);
}
if (!empty($this->startup_warning)) {
- $this->warning($this->startup_warning);
+ foreach (explode("\n", $this->startup_warning) as $startup_warning) {
+ $this->warning($startup_warning);
+ }
}
// init result array and set parameters
$this->filename = $filename;
$this->info = array();
$this->info['GETID3_VERSION'] = $this->version();
- $this->info['php_memory_limit'] = $this->memory_limit;
+ $this->info['php_memory_limit'] = (($this->memory_limit > 0) ? $this->memory_limit : false);
// remote files not supported
- if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
+ if (preg_match('#^(ht|f)tp://#', $filename)) {
throw new getid3_exception('Remote files are not supported - please copy the file locally first');
}
$filename = str_replace('/', DIRECTORY_SEPARATOR, $filename);
- $filename = preg_replace('#(.+)'.preg_quote(DIRECTORY_SEPARATOR).'{2,}#U', '\1'.DIRECTORY_SEPARATOR, $filename);
+ $filename = preg_replace('#(?<!gs:)('.preg_quote(DIRECTORY_SEPARATOR).'{2,})#', DIRECTORY_SEPARATOR, $filename);
// open local file
//if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) { // see http://www.getid3.org/phpBB3/viewtopic.php?t=1720
@@ -280,7 +293,7 @@
throw new getid3_exception('Could not open "'.$filename.'" ('.implode('; ', $errormessagelist).')');
}
- $this->info['filesize'] = filesize($filename);
+ $this->info['filesize'] = (!is_null($filesize) ? $filesize : filesize($filename));
// set redundant parameters - might be needed in some include file
// filenames / filepaths in getID3 are always expressed with forward slashes (unix-style) for both Windows and other to try and minimize confusion
$filename = str_replace('\\', '/', $filename);
@@ -288,6 +301,17 @@
$this->info['filename'] = getid3_lib::mb_basename($filename);
$this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
+ // set more parameters
+ $this->info['avdataoffset'] = 0;
+ $this->info['avdataend'] = $this->info['filesize'];
+ $this->info['fileformat'] = ''; // filled in later
+ $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
+ $this->info['video']['dataformat'] = ''; // filled in later, unset if not used
+ $this->info['tags'] = array(); // filled in later, unset if not used
+ $this->info['error'] = array(); // filled in later, unset if not used
+ $this->info['warning'] = array(); // filled in later, unset if not used
+ $this->info['comments'] = array(); // filled in later, unset if not used
+ $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
// option_max_2gb_check
if ($this->option_max_2gb_check) {
@@ -314,18 +338,6 @@
}
}
- // set more parameters
- $this->info['avdataoffset'] = 0;
- $this->info['avdataend'] = $this->info['filesize'];
- $this->info['fileformat'] = ''; // filled in later
- $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
- $this->info['video']['dataformat'] = ''; // filled in later, unset if not used
- $this->info['tags'] = array(); // filled in later, unset if not used
- $this->info['error'] = array(); // filled in later, unset if not used
- $this->info['warning'] = array(); // filled in later, unset if not used
- $this->info['comments'] = array(); // filled in later, unset if not used
- $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
-
return true;
} catch (Exception $e) {
@@ -335,9 +347,9 @@
}
// public: analyze file
- public function analyze($filename) {
+ public function analyze($filename, $filesize=null, $original_filename='') {
try {
- if (!$this->openfile($filename)) {
+ if (!$this->openfile($filename, $filesize)) {
return $this->info;
}
@@ -382,7 +394,7 @@
$formattest = fread($this->fp, 32774);
// determine format
- $determined_format = $this->GetFileFormat($formattest, $filename);
+ $determined_format = $this->GetFileFormat($formattest, ($original_filename ? $original_filename : $filename));
// unable to determine file format
if (!$determined_format) {
@@ -419,14 +431,14 @@
return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
}
- // module requires iconv support
+ // module requires mb_convert_encoding/iconv support
// Check encoding/iconv support
- if (!empty($determined_format['iconv_req']) && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
- $errormessage = 'iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
+ if (!empty($determined_format['iconv_req']) && !function_exists('mb_convert_encoding') && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
+ $errormessage = 'mb_convert_encoding() or iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
if (GETID3_OS_ISWINDOWS) {
- $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
+ $errormessage .= 'PHP does not have mb_convert_encoding() or iconv() support. Please enable php_mbstring.dll / php_iconv.dll in php.ini, and copy php_mbstring.dll / iconv.dll from c:/php/dlls to c:/windows/system32';
} else {
- $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
+ $errormessage .= 'PHP is not compiled with mb_convert_encoding() or iconv() support. Please recompile with the --enable-mbstring / --with-iconv switch';
}
return $this->error($errormessage);
}
@@ -561,7 +573,7 @@
// AC-3 - audio - Dolby AC-3 / Dolby Digital
'ac3' => array(
- 'pattern' => '^\x0B\x77',
+ 'pattern' => '^\\x0B\\x77',
'group' => 'audio',
'module' => 'ac3',
'mime_type' => 'audio/ac3',
@@ -579,7 +591,7 @@
/*
// AA - audio - Audible Audiobook
'aa' => array(
- 'pattern' => '^.{4}\x57\x90\x75\x36',
+ 'pattern' => '^.{4}\\x57\\x90\\x75\\x36',
'group' => 'audio',
'module' => 'aa',
'mime_type' => 'audio/audible',
@@ -587,7 +599,7 @@
*/
// AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
'adts' => array(
- 'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]',
+ 'pattern' => '^\\xFF[\\xF0-\\xF1\\xF8-\\xF9]',
'group' => 'audio',
'module' => 'aac',
'mime_type' => 'application/octet-stream',
@@ -597,7 +609,7 @@
// AU - audio - NeXT/Sun AUdio (AU)
'au' => array(
- 'pattern' => '^\.snd',
+ 'pattern' => '^\\.snd',
'group' => 'audio',
'module' => 'au',
'mime_type' => 'audio/basic',
@@ -605,7 +617,7 @@
// AMR - audio - Adaptive Multi Rate
'amr' => array(
- 'pattern' => '^\x23\x21AMR\x0A', // #!AMR[0A]
+ 'pattern' => '^\\x23\\x21AMR\\x0A', // #!AMR[0A]
'group' => 'audio',
'module' => 'amr',
'mime_type' => 'audio/amr',
@@ -621,15 +633,23 @@
// BONK - audio - Bonk v0.9+
'bonk' => array(
- 'pattern' => '^\x00(BONK|INFO|META| ID3)',
+ 'pattern' => '^\\x00(BONK|INFO|META| ID3)',
'group' => 'audio',
'module' => 'bonk',
'mime_type' => 'audio/xmms-bonk',
),
+ // DSF - audio - Direct Stream Digital (DSD) Storage Facility files (DSF) - https://en.wikipedia.org/wiki/Direct_Stream_Digital
+ 'dsf' => array(
+ 'pattern' => '^DSD ', // including trailing space: 44 53 44 20
+ 'group' => 'audio',
+ 'module' => 'dsf',
+ 'mime_type' => 'audio/dsd',
+ ),
+
// DSS - audio - Digital Speech Standard
'dss' => array(
- 'pattern' => '^[\x02-\x03]ds[s2]',
+ 'pattern' => '^[\\x02-\\x06]ds[s2]',
'group' => 'audio',
'module' => 'dss',
'mime_type' => 'application/octet-stream',
@@ -637,7 +657,7 @@
// DTS - audio - Dolby Theatre System
'dts' => array(
- 'pattern' => '^\x7F\xFE\x80\x01',
+ 'pattern' => '^\\x7F\\xFE\\x80\\x01',
'group' => 'audio',
'module' => 'dts',
'mime_type' => 'audio/dts',
@@ -722,7 +742,7 @@
// MPC - audio - Musepack / MPEGplus
'mpc' => array(
- 'pattern' => '^(MPCK|MP\+|[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
+ 'pattern' => '^(MPCK|MP\\+|[\\x00\\x01\\x10\\x11\\x40\\x41\\x50\\x51\\x80\\x81\\x90\\x91\\xC0\\xC1\\xD0\\xD1][\\x20-\\x37][\\x00\\x20\\x40\\x60\\x80\\xA0\\xC0\\xE0])',
'group' => 'audio',
'module' => 'mpc',
'mime_type' => 'audio/x-musepack',
@@ -730,7 +750,7 @@
// MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS)
'mp3' => array(
- 'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\x0B\x10-\x1B\x20-\x2B\x30-\x3B\x40-\x4B\x50-\x5B\x60-\x6B\x70-\x7B\x80-\x8B\x90-\x9B\xA0-\xAB\xB0-\xBB\xC0-\xCB\xD0-\xDB\xE0-\xEB\xF0-\xFB]',
+ 'pattern' => '^\\xFF[\\xE2-\\xE7\\xF2-\\xF7\\xFA-\\xFF][\\x00-\\x0B\\x10-\\x1B\\x20-\\x2B\\x30-\\x3B\\x40-\\x4B\\x50-\\x5B\\x60-\\x6B\\x70-\\x7B\\x80-\\x8B\\x90-\\x9B\\xA0-\\xAB\\xB0-\\xBB\\xC0-\\xCB\\xD0-\\xDB\\xE0-\\xEB\\xF0-\\xFB]',
'group' => 'audio',
'module' => 'mp3',
'mime_type' => 'audio/mpeg',
@@ -738,7 +758,7 @@
// OFR - audio - OptimFROG
'ofr' => array(
- 'pattern' => '^(\*RIFF|OFR)',
+ 'pattern' => '^(\\*RIFF|OFR)',
'group' => 'audio',
'module' => 'optimfrog',
'mime_type' => 'application/octet-stream',
@@ -764,7 +784,7 @@
// TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org)
'tta' => array(
- 'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
+ 'pattern' => '^TTA', // could also be '^TTA(\\x01|\\x02|\\x03|2|1)'
'group' => 'audio',
'module' => 'tta',
'mime_type' => 'application/octet-stream',
@@ -799,7 +819,7 @@
// ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
'asf' => array(
- 'pattern' => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
+ 'pattern' => '^\\x30\\x26\\xB2\\x75\\x8E\\x66\\xCF\\x11\\xA6\\xD9\\x00\\xAA\\x00\\x62\\xCE\\x6C',
'group' => 'audio-video',
'module' => 'asf',
'mime_type' => 'video/x-ms-asf',
@@ -816,7 +836,7 @@
// FLV - audio/video - FLash Video
'flv' => array(
- 'pattern' => '^FLV\x01',
+ 'pattern' => '^FLV[\\x01]',
'group' => 'audio-video',
'module' => 'flv',
'mime_type' => 'video/x-flv',
@@ -824,7 +844,7 @@
// MKAV - audio/video - Mastroka
'matroska' => array(
- 'pattern' => '^\x1A\x45\xDF\xA3',
+ 'pattern' => '^\\x1A\\x45\\xDF\\xA3',
'group' => 'audio-video',
'module' => 'matroska',
'mime_type' => 'video/x-matroska', // may also be audio/x-matroska
@@ -832,7 +852,7 @@
// MPEG - audio/video - MPEG (Moving Pictures Experts Group)
'mpeg' => array(
- 'pattern' => '^\x00\x00\x01(\xBA|\xB3)',
+ 'pattern' => '^\\x00\\x00\\x01[\\xB3\\xBA]',
'group' => 'audio-video',
'module' => 'mpeg',
'mime_type' => 'video/mpeg',
@@ -869,13 +889,13 @@
'pattern' => '^(RIFF|SDSS|FORM)',
'group' => 'audio-video',
'module' => 'riff',
- 'mime_type' => 'audio/x-wave',
+ 'mime_type' => 'audio/x-wav',
'fail_ape' => 'WARNING',
),
// Real - audio/video - RealAudio, RealVideo
'real' => array(
- 'pattern' => '^(\\.RMF|\\.ra)',
+ 'pattern' => '^\\.(RMF|ra)',
'group' => 'audio-video',
'module' => 'real',
'mime_type' => 'audio/x-realaudio',
@@ -891,7 +911,7 @@
// TS - audio/video - MPEG-2 Transport Stream
'ts' => array(
- 'pattern' => '^(\x47.{187}){10,}', // packets are 188 bytes long and start with 0x47 "G". Check for at least 10 packets matching this pattern
+ 'pattern' => '^(\\x47.{187}){10,}', // packets are 188 bytes long and start with 0x47 "G". Check for at least 10 packets matching this pattern
'group' => 'audio-video',
'module' => 'ts',
'mime_type' => 'video/MP2T',
@@ -922,7 +942,7 @@
// JPEG - still image - Joint Photographic Experts Group (JPEG)
'jpg' => array(
- 'pattern' => '^\xFF\xD8\xFF',
+ 'pattern' => '^\\xFF\\xD8\\xFF',
'group' => 'graphic',
'module' => 'jpg',
'mime_type' => 'image/jpeg',
@@ -932,7 +952,7 @@
// PCD - still image - Kodak Photo CD
'pcd' => array(
- 'pattern' => '^.{2048}PCD_IPI\x00',
+ 'pattern' => '^.{2048}PCD_IPI\\x00',
'group' => 'graphic',
'module' => 'pcd',
'mime_type' => 'image/x-photo-cd',
@@ -943,7 +963,7 @@
// PNG - still image - Portable Network Graphics (PNG)
'png' => array(
- 'pattern' => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
+ 'pattern' => '^\\x89\\x50\\x4E\\x47\\x0D\\x0A\\x1A\\x0A',
'group' => 'graphic',
'module' => 'png',
'mime_type' => 'image/png',
@@ -954,7 +974,7 @@
// SVG - still image - Scalable Vector Graphics (SVG)
'svg' => array(
- 'pattern' => '(<!DOCTYPE svg PUBLIC |xmlns="http:\/\/www\.w3\.org\/2000\/svg")',
+ 'pattern' => '(<!DOCTYPE svg PUBLIC |xmlns="http://www\\.w3\\.org/2000/svg")',
'group' => 'graphic',
'module' => 'svg',
'mime_type' => 'image/svg+xml',
@@ -965,7 +985,7 @@
// TIFF - still image - Tagged Information File Format (TIFF)
'tiff' => array(
- 'pattern' => '^(II\x2A\x00|MM\x00\x2A)',
+ 'pattern' => '^(II\\x2A\\x00|MM\\x00\\x2A)',
'group' => 'graphic',
'module' => 'tiff',
'mime_type' => 'image/tiff',
@@ -976,7 +996,7 @@
// EFAX - still image - eFax (TIFF derivative)
'efax' => array(
- 'pattern' => '^\xDC\xFE',
+ 'pattern' => '^\\xDC\\xFE',
'group' => 'graphic',
'module' => 'efax',
'mime_type' => 'image/efax',
@@ -1000,7 +1020,7 @@
// RAR - data - RAR compressed data
'rar' => array(
- 'pattern' => '^Rar\!',
+ 'pattern' => '^Rar\\!',
'group' => 'archive',
'module' => 'rar',
'mime_type' => 'application/octet-stream',
@@ -1010,7 +1030,7 @@
// SZIP - audio/data - SZIP compressed data
'szip' => array(
- 'pattern' => '^SZ\x0A\x04',
+ 'pattern' => '^SZ\\x0A\\x04',
'group' => 'archive',
'module' => 'szip',
'mime_type' => 'application/octet-stream',
@@ -1020,7 +1040,7 @@
// TAR - data - TAR compressed data
'tar' => array(
- 'pattern' => '^.{100}[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',
+ 'pattern' => '^.{100}[0-9\\x20]{7}\\x00[0-9\\x20]{7}\\x00[0-9\\x20]{7}\\x00[0-9\\x20\\x00]{12}[0-9\\x20\\x00]{12}',
'group' => 'archive',
'module' => 'tar',
'mime_type' => 'application/x-tar',
@@ -1030,7 +1050,7 @@
// GZIP - data - GZIP compressed data
'gz' => array(
- 'pattern' => '^\x1F\x8B\x08',
+ 'pattern' => '^\\x1F\\x8B\\x08',
'group' => 'archive',
'module' => 'gzip',
'mime_type' => 'application/x-gzip',
@@ -1040,7 +1060,7 @@
// ZIP - data - ZIP compressed data
'zip' => array(
- 'pattern' => '^PK\x03\x04',
+ 'pattern' => '^PK\\x03\\x04',
'group' => 'archive',
'module' => 'zip',
'mime_type' => 'application/zip',
@@ -1053,7 +1073,7 @@
// PAR2 - data - Parity Volume Set Specification 2.0
'par2' => array (
- 'pattern' => '^PAR2\x00PKT',
+ 'pattern' => '^PAR2\\x00PKT',
'group' => 'misc',
'module' => 'par2',
'mime_type' => 'application/octet-stream',
@@ -1063,7 +1083,7 @@
// PDF - data - Portable Document Format
'pdf' => array(
- 'pattern' => '^\x25PDF',
+ 'pattern' => '^\\x25PDF',
'group' => 'misc',
'module' => 'pdf',
'mime_type' => 'application/pdf',
@@ -1073,7 +1093,7 @@
// MSOFFICE - data - ZIP compressed data
'msoffice' => array(
- 'pattern' => '^\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1', // D0CF11E == DOCFILE == Microsoft Office Document
+ 'pattern' => '^\\xD0\\xCF\\x11\\xE0\\xA1\\xB1\\x1A\\xE1', // D0CF11E == DOCFILE == Microsoft Office Document
'group' => 'misc',
'module' => 'msoffice',
'mime_type' => 'application/octet-stream',
@@ -1114,14 +1134,14 @@
}
- if (preg_match('#\.mp[123a]$#i', $filename)) {
+ if (preg_match('#\\.mp[123a]$#i', $filename)) {
// Too many mp3 encoders on the market put gabage in front of mpeg files
// use assume format on these if format detection failed
$GetFileFormatArray = $this->GetFileFormatArray();
$info = $GetFileFormatArray['mp3'];
$info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
return $info;
- } elseif (preg_match('/\.cue$/i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) {
+ } elseif (preg_match('#\\.cue$#i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) {
// there's not really a useful consistent "magic" at the beginning of .cue files to identify them
// so until I think of something better, just go by filename if all other format checks fail
// and verify there's at least one instance of "TRACK xx AUDIO" in the file
@@ -1222,13 +1242,14 @@
continue;
}
+ $this->CharConvert($this->info['tags'][$tag_name], $this->info[$comment_name]['encoding']); // only copy gets converted!
+
if ($this->option_tags_html) {
foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
- $this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $encoding);
+ $this->info['tags_html'][$tag_name][$tag_key] = getid3_lib::recursiveMultiByteCharString2HTML($valuearray, $this->info[$comment_name]['encoding']);
}
}
- $this->CharConvert($this->info['tags'][$tag_name], $encoding); // only copy gets converted!
}
}
@@ -1352,8 +1373,8 @@
if (!empty($VorbisCommentError)) {
- $this->info['warning'][] = 'Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
- $this->info[$algorithm.'_data'] = false;
+ $this->warning('Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError);
+ $this->info[$algorithm.'_data'] = false;
} else {
@@ -1582,6 +1603,17 @@
return true;
}
+ public static function is_writable ($filename) {
+ $ret = is_writable($filename);
+
+ if (!$ret) {
+ $perms = fileperms($filename);
+ $ret = ($perms & 0x0080) || ($perms & 0x0010) || ($perms & 0x0002);
+ }
+
+ return $ret;
+ }
+
}
@@ -1661,7 +1693,23 @@
if (!getid3_lib::intValueSupported($pos)) {
throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
}
- return fread($this->getid3->fp, $bytes);
+
+ //return fread($this->getid3->fp, $bytes);
+ /*
+ * http://www.getid3.org/phpBB3/viewtopic.php?t=1930
+ * "I found out that the root cause for the problem was how getID3 uses the PHP system function fread().
+ * It seems to assume that fread() would always return as many bytes as were requested.
+ * However, according the PHP manual (http://php.net/manual/en/function.fread.php), this is the case only with regular local files, but not e.g. with Linux pipes.
+ * The call may return only part of the requested data and a new call is needed to get more."
+ */
+ $contents = '';
+ do {
+ $part = fread($this->getid3->fp, $bytes);
+ $partLength = strlen($part);
+ $bytes -= $partLength;
+ $contents .= $part;
+ } while (($bytes > 0) && ($partLength > 0));
+ return $contents;
}
protected function fseek($bytes, $whence=SEEK_SET) {
@@ -1741,7 +1789,7 @@
// set up destination path
$dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR);
- if (!is_dir($dir) || !is_writable($dir)) { // check supplied directory
+ if (!is_dir($dir) || !getID3::is_writable($dir)) { // check supplied directory
throw new Exception('supplied path ('.$dir.') does not exist, or is not writable');
}
$dest = $dir.DIRECTORY_SEPARATOR.$name.($image_mime ? '.'.getid3_lib::ImageExtFromMime($image_mime) : '');
@@ -1793,4 +1841,4 @@
class getid3_exception extends Exception
{
public $message;
-}
\ No newline at end of file
+}