diff --git a/lib/getid3/getid3.lib.php b/lib/getid3/getid3.lib.php index 2f13f53..f6a6423 100644 --- a/lib/getid3/getid3.lib.php +++ b/lib/getid3/getid3.lib.php @@ -20,7 +20,7 @@ class getid3_lib if ($hex) { $returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT); } else { - $returnstring .= ' '.(ereg("[\x20-\x7E]", $string{$i}) ? $string{$i} : '¤'); + $returnstring .= ' '.(preg_match("/[\x20-\x7E]/i", $string{$i}) ? $string{$i} : '¤'); } if ($spaces) { $returnstring .= ' '; @@ -530,7 +530,7 @@ class getid3_lib } } $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]; } @@ -538,7 +538,7 @@ class getid3_lib // The following works under UNIX only $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]; } @@ -565,14 +565,14 @@ class getid3_lib } } $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]; } } else { $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]; } diff --git a/lib/getid3/getid3.php b/lib/getid3/getid3.php index 18be9a7..81856dc 100644 --- a/lib/getid3/getid3.php +++ b/lib/getid3/getid3.php @@ -60,7 +60,7 @@ class getID3 // Check memory $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 $memory_limit = $matches[1] * 1048576; } @@ -179,9 +179,14 @@ class getID3 // Disable magic_quotes_runtime, if neccesary $old_magic_quotes_runtime = get_magic_quotes_runtime(); // store current setting of magic_quotes_runtime if ($old_magic_quotes_runtime) { - set_magic_quotes_runtime(0); // turn off magic_quotes_runtime - if (get_magic_quotes_runtime()) { - return $this->error('Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled'); + if (version_compare(phpversion(), "5.3") === -1) { + set_magic_quotes_runtime(0); // turn off magic_quotes_runtime + 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) { $commandline = 'dir /-C "'.str_replace('/', DIRECTORY_SEPARATOR, $filename).'"'; $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]; } } else { $commandline = 'ls -o -g -G --time-style=long-iso '.escapeshellarg($filename); $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]; } } @@ -408,7 +413,7 @@ class getID3 $this->CleanUp(); // 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 $this->info; diff --git a/lib/getid3/module.audio.mp3.php b/lib/getid3/module.audio.mp3.php index 1cc6f41..6fed9c6 100644 --- a/lib/getid3/module.audio.mp3.php +++ b/lib/getid3/module.audio.mp3.php @@ -1548,7 +1548,7 @@ class getid3_mp3 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.'; foreach ($ThisFileInfo['mpeg']['audio'] as $key1 => $value1) { - if (!eregi('_distribution$', $key1)) { + if (!preg_match('/_distribution$/i', $key1)) { continue; } foreach ($value1 as $key2 => $value2) { diff --git a/lib/getid3/module.tag.id3v2.php b/lib/getid3/module.tag.id3v2.php index fd7ac18..dadf8f6 100644 --- a/lib/getid3/module.tag.id3v2.php +++ b/lib/getid3/module.tag.id3v2.php @@ -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]); } @@ -461,7 +461,7 @@ class getid3_id3v2 $unprocessed = substr($unprocessed, $endpos + 1); } 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 $genrestring = '('.$genrestring.')'; } @@ -3137,12 +3137,12 @@ class getid3_id3v2 function IsValidID3v2FrameName($framename, $id3v2majorversion) { switch ($id3v2majorversion) { case 2: - return ereg('[A-Z][A-Z0-9]{2}', $framename); + return preg_match('/[A-Z][A-Z0-9]{2}/i', $framename); break; case 3: case 4: - return ereg('[A-Z][A-Z0-9]{3}', $framename); + return preg_match('/[A-Z][A-Z0-9]{3}/i', $framename); break; } return false;