GetID3 used now deprecated functions like ereg and set_magic_quotes_runtime. Convert ereg to preg_match and throw an error if magic quotes are enabled on PHP >= 5.3.

git-svn-id: http://kusabax.cultnet.net/svn/repo/stable@216 73d99b7e-4f53-4972-b7b7-2ecd3c4d89ee
This commit is contained in:
Sazpaimon committed 2009-08-16 07:29:23 +00:00
1 parent 6afde4b284
commit 0bdb656e9a
4 files changed
+22 -17

No files matched your search

+5 -5
View File
@@ -20,7 +20,7 @@ class getid3_lib
if ($hex) { if ($hex) {
$returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT); $returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
} else { } else {
$returnstring .= ' '.(ereg("[\x20-\x7E]", $string{$i}) ? $string{$i} : '¤'); $returnstring .= ' '.(preg_match("/[\x20-\x7E]/i", $string{$i}) ? $string{$i} : '¤');
} }
if ($spaces) { if ($spaces) {
$returnstring .= ' '; $returnstring .= ' ';
@@ -530,7 +530,7 @@ class getid3_lib
} }
} }
$commandline = GETID3_HELPERAPPSDIR.'md5sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"'; $commandline = GETID3_HELPERAPPSDIR.'md5sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"';
if (ereg("^[\\]?([0-9a-f]{32})", strtolower(`$commandline`), $r)) { if (preg_match("/^[\\]?([0-9a-f]{32})/", strtolower(`$commandline`), $r)) {
return $r[1]; return $r[1];
} }
@@ -538,7 +538,7 @@ class getid3_lib
// The following works under UNIX only // The following works under UNIX only
$file = str_replace('`', '\\`', $file); $file = str_replace('`', '\\`', $file);
if (ereg("^([0-9a-f]{32})[ \t\n\r]", `md5sum "$file"`, $r)) { if (preg_match("/^([0-9a-f]{32})[ \t\n\r]/", `md5sum "$file"`, $r)) {
return $r[1]; return $r[1];
} }
@@ -565,14 +565,14 @@ class getid3_lib
} }
} }
$commandline = GETID3_HELPERAPPSDIR.'sha1sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"'; $commandline = GETID3_HELPERAPPSDIR.'sha1sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"';
if (ereg("^sha1=([0-9a-f]{40})", strtolower(`$commandline`), $r)) { if (preg_match("/^sha1=([0-9a-f]{40})/", strtolower(`$commandline`), $r)) {
return $r[1]; return $r[1];
} }
} else { } else {
$commandline = 'sha1sum '.escapeshellarg($file).''; $commandline = 'sha1sum '.escapeshellarg($file).'';
if (ereg("^([0-9a-f]{40})[ \t\n\r]", strtolower(`$commandline`), $r)) { if (preg_match("/^([0-9a-f]{40})[ \t\n\r]/", strtolower(`$commandline`), $r)) {
return $r[1]; return $r[1];
} }
+12 -7
View File
@@ -60,7 +60,7 @@ class getID3
// Check memory // Check memory
$memory_limit = ini_get('memory_limit'); $memory_limit = ini_get('memory_limit');
if (eregi('([0-9]+)M', $memory_limit, $matches)) { if (preg_match('/([0-9]+)[Mm]/', $memory_limit, $matches)) {
// could be stored as "16M" rather than 16777216 for example // could be stored as "16M" rather than 16777216 for example
$memory_limit = $matches[1] * 1048576; $memory_limit = $matches[1] * 1048576;
} }
@@ -179,9 +179,14 @@ class getID3
// Disable magic_quotes_runtime, if neccesary // Disable magic_quotes_runtime, if neccesary
$old_magic_quotes_runtime = get_magic_quotes_runtime(); // store current setting of magic_quotes_runtime $old_magic_quotes_runtime = get_magic_quotes_runtime(); // store current setting of magic_quotes_runtime
if ($old_magic_quotes_runtime) { if ($old_magic_quotes_runtime) {
set_magic_quotes_runtime(0); // turn off magic_quotes_runtime if (version_compare(phpversion(), "5.3") === -1) {
if (get_magic_quotes_runtime()) { set_magic_quotes_runtime(0); // turn off magic_quotes_runtime
return $this->error('Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled'); if (get_magic_quotes_runtime()) {
return $this->error('Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled');
}
}
else {
return $this->error('Magic quotes are depricated in PHP 5.3 - getID3() will not operate with PHP 5.3 installed and magic quotes enabled.');
} }
} }
@@ -216,13 +221,13 @@ class getID3
if (GETID3_OS_ISWINDOWS) { if (GETID3_OS_ISWINDOWS) {
$commandline = 'dir /-C "'.str_replace('/', DIRECTORY_SEPARATOR, $filename).'"'; $commandline = 'dir /-C "'.str_replace('/', DIRECTORY_SEPARATOR, $filename).'"';
$dir_output = `$commandline`; $dir_output = `$commandline`;
if (eregi('1 File\(s\)[ ]+([0-9]+) bytes', $dir_output, $matches)) { if (preg_match('/1 File\(s\)[ ]+([0-9]+) bytes/i', $dir_output, $matches)) {
$real_filesize = (float) $matches[1]; $real_filesize = (float) $matches[1];
} }
} else { } else {
$commandline = 'ls -o -g -G --time-style=long-iso '.escapeshellarg($filename); $commandline = 'ls -o -g -G --time-style=long-iso '.escapeshellarg($filename);
$dir_output = `$commandline`; $dir_output = `$commandline`;
if (eregi('([0-9]+) ([0-9]{4}-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}) '.preg_quote($filename).'$', $dir_output, $matches)) { if (preg_match('/([0-9]+) ([0-9]{4}-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}) /i'.preg_quote($filename).'$', $dir_output, $matches)) {
$real_filesize = (float) $matches[1]; $real_filesize = (float) $matches[1];
} }
} }
@@ -408,7 +413,7 @@ class getID3
$this->CleanUp(); $this->CleanUp();
// restore magic_quotes_runtime setting // restore magic_quotes_runtime setting
set_magic_quotes_runtime($old_magic_quotes_runtime); if ($old_magic_quotes_runtime) set_magic_quotes_runtime($old_magic_quotes_runtime);
// return info array // return info array
return $this->info; return $this->info;
+1 -1
View File
@@ -1548,7 +1548,7 @@ class getid3_mp3
if ($pct_data_scanned > 0) { if ($pct_data_scanned > 0) {
$ThisFileInfo['warning'][] = 'too many MPEG audio frames to scan, only scanned '.$frames_scanned.' frames in '.$max_scan_segments.' segments ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.'; $ThisFileInfo['warning'][] = 'too many MPEG audio frames to scan, only scanned '.$frames_scanned.' frames in '.$max_scan_segments.' segments ('.number_format($pct_data_scanned * 100, 1).'% of file) and extrapolated distribution, playtime and bitrate may be incorrect.';
foreach ($ThisFileInfo['mpeg']['audio'] as $key1 => $value1) { foreach ($ThisFileInfo['mpeg']['audio'] as $key1 => $value1) {
if (!eregi('_distribution$', $key1)) { if (!preg_match('/_distribution$/i', $key1)) {
continue; continue;
} }
foreach ($value1 as $key2 => $value2) { foreach ($value1 as $key2 => $value2) {
+4 -4
View File
@@ -429,7 +429,7 @@ class getid3_id3v2
} }
} }
if (!isset($thisfile_id3v2['comments']['year']) && ereg('^([0-9]{4})', trim(@$thisfile_id3v2['comments']['recording_time'][0]), $matches)) { if (!isset($thisfile_id3v2['comments']['year']) && preg_match('/^([0-9]{4})/', trim(@$thisfile_id3v2['comments']['recording_time'][0]), $matches)) {
$thisfile_id3v2['comments']['year'] = array($matches[1]); $thisfile_id3v2['comments']['year'] = array($matches[1]);
} }
@@ -461,7 +461,7 @@ class getid3_id3v2
$unprocessed = substr($unprocessed, $endpos + 1); $unprocessed = substr($unprocessed, $endpos + 1);
} }
unset($unprocessed); unset($unprocessed);
} elseif (eregi('^([0-9]+|CR|RX)$', $genrestring)) { } elseif (preg_match('/^([0-9]+|CR|RX)$/i', $genrestring)) {
// some tagging program (including some that use TagLib) fail to include null byte after numeric genre // some tagging program (including some that use TagLib) fail to include null byte after numeric genre
$genrestring = '('.$genrestring.')'; $genrestring = '('.$genrestring.')';
} }
@@ -3137,12 +3137,12 @@ class getid3_id3v2
function IsValidID3v2FrameName($framename, $id3v2majorversion) { function IsValidID3v2FrameName($framename, $id3v2majorversion) {
switch ($id3v2majorversion) { switch ($id3v2majorversion) {
case 2: case 2:
return ereg('[A-Z][A-Z0-9]{2}', $framename); return preg_match('/[A-Z][A-Z0-9]{2}/i', $framename);
break; break;
case 3: case 3:
case 4: case 4:
return ereg('[A-Z][A-Z0-9]{3}', $framename); return preg_match('/[A-Z][A-Z0-9]{3}/i', $framename);
break; break;
} }
return false; return false;