mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-05 19:41:55 +02:00
improved quarantine a little more and updated to new getid3 some genre issues still unresolved
This commit is contained in:
parent
1c1ad6ef87
commit
d45a743f64
20 changed files with 502 additions and 312 deletions
|
@ -30,6 +30,9 @@ init_preferences();
|
|||
|
||||
usage();
|
||||
|
||||
/* Check if they want to force delete */
|
||||
$force_delete = $GLOBALS['argv']['1'];
|
||||
|
||||
// grab list of files from table
|
||||
$sql = "SELECT id, file, user,action FROM upload WHERE action != 'quarantine'";
|
||||
$db_results = mysql_query($sql, dbh());
|
||||
|
@ -93,8 +96,13 @@ foreach ($files['add'] as $data) {
|
|||
}
|
||||
|
||||
$results = unlink($data['file']);
|
||||
if (!$results) { echo "Error: Unable to delete " . $data['file'] . "\n";}
|
||||
|
||||
if (!$results AND !$force_delete) { echo "Error: Unable to delete " . $data['file'] . "\n";}
|
||||
elseif (!$results) {
|
||||
echo "Error: Unable to delete " . $data['file'] . "\n";
|
||||
echo "Force Delete enabled, removing from Database...\n";
|
||||
$sql = "DELETE FROM upload WHERE id='" . $data['id'] . "'";
|
||||
$db_results = mysql_query($sql, dbh());
|
||||
} // if not able to unlike
|
||||
else {
|
||||
echo _('Adding') . " " . $target_file . " " . _('to database') . "\n";
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
--------------------------------------------------------------------------
|
||||
v.3.3.3-Alpha1
|
||||
- Added new version of getid3() library which will hopefully
|
||||
resolve some PHP5 related issues
|
||||
- Fixed security issue that allowed users to gain gues access to
|
||||
ampache if register globals is enabled.
|
||||
- Added xml based query for artists,genre,albums and search see
|
||||
|
|
|
@ -524,7 +524,7 @@ class getid3_lib
|
|||
die(implode(' and ', $RequiredFiles).' are required in '.GETID3_HELPERAPPSDIR.' for getid3_lib::md5_file() to function under Windows in PHP < v4.2.0');
|
||||
}
|
||||
}
|
||||
$commandline = GETID3_HELPERAPPSDIR.'md5sum.exe "'.str_replace('/', GETID3_OS_DIRSLASH, $file).'"';
|
||||
$commandline = GETID3_HELPERAPPSDIR.'md5sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"';
|
||||
if (ereg("^[\\]?([0-9a-f]{32})", strtolower(`$commandline`), $r)) {
|
||||
return $r[1];
|
||||
}
|
||||
|
@ -559,14 +559,14 @@ class getid3_lib
|
|||
die(implode(' and ', $RequiredFiles).' are required in '.GETID3_HELPERAPPSDIR.' for getid3_lib::sha1_file() to function under Windows in PHP < v4.3.0');
|
||||
}
|
||||
}
|
||||
$commandline = GETID3_HELPERAPPSDIR.'sha1sum.exe "'.str_replace('/', GETID3_OS_DIRSLASH, $file).'"';
|
||||
$commandline = GETID3_HELPERAPPSDIR.'sha1sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"';
|
||||
if (ereg("^sha1=([0-9a-f]{40})", strtolower(`$commandline`), $r)) {
|
||||
return $r[1];
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$commandline = 'sha1sum "'.$file.'"';
|
||||
$commandline = 'sha1sum '.escapeshellarg($file).'';
|
||||
if (ereg("^([0-9a-f]{40})[ \t\n\r]", strtolower(`$commandline`), $r)) {
|
||||
return $r[1];
|
||||
}
|
||||
|
@ -617,14 +617,14 @@ class getid3_lib
|
|||
break;
|
||||
}
|
||||
}
|
||||
$commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' "'.str_replace('/', GETID3_OS_DIRSLASH, $file).'" | ';
|
||||
$commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' "'.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).'" | ';
|
||||
$commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | ';
|
||||
$commandline .= GETID3_HELPERAPPSDIR.$windows_call;
|
||||
|
||||
} else {
|
||||
|
||||
$commandline = 'head -c '.$end.' "'.$file.'" | ';
|
||||
$commandline .= 'tail -c '.$size.' | ';
|
||||
$commandline = 'head -c'.$end.' '.escapeshellarg($file).' | ';
|
||||
$commandline .= 'tail -c'.$size.' | ';
|
||||
$commandline .= $unix_call;
|
||||
|
||||
}
|
||||
|
@ -1170,7 +1170,7 @@ class getid3_lib
|
|||
function GetDataImageSize($imgData) {
|
||||
$GetDataImageSize = false;
|
||||
if ($tempfilename = tempnam('*', 'getID3')) {
|
||||
if ($tmp = @fopen($tempfilename, 'rb')) {
|
||||
if ($tmp = @fopen($tempfilename, 'wb')) {
|
||||
fwrite($tmp, $imgData);
|
||||
fclose($tmp);
|
||||
$GetDataImageSize = @GetImageSize($tempfilename);
|
||||
|
@ -1202,7 +1202,8 @@ class getid3_lib
|
|||
}
|
||||
|
||||
function CopyTagsToComments(&$ThisFileInfo) {
|
||||
// Copy all entries from ['tags'] into common ['comments'] and ['comments_html']
|
||||
|
||||
// Copy all entries from ['tags'] into common ['comments']
|
||||
if (!empty($ThisFileInfo['tags'])) {
|
||||
foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
|
||||
foreach ($tagarray as $tagname => $tagdata) {
|
||||
|
@ -1237,14 +1238,18 @@ class getid3_lib
|
|||
}
|
||||
if (empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
|
||||
$ThisFileInfo['comments'][$tagname][] = trim($value);
|
||||
if (isset($ThisFileInfo['tags_html'][$tagtype][$tagname][$key])) {
|
||||
$ThisFileInfo['comments_html'][$tagname][] = $ThisFileInfo['tags_html'][$tagtype][$tagname][$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy to ['comments_html']
|
||||
foreach ($ThisFileInfo['comments'] as $field => $values) {
|
||||
foreach ($values as $index => $value) {
|
||||
$ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', getid3_lib::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
// Defines
|
||||
define('GETID3_VERSION', '1.7.5-200512251515');
|
||||
define('GETID3_VERSION', '1.7.7');
|
||||
define('GETID3_FREAD_BUFFER_SIZE', 16384); // read buffer size in bytes
|
||||
|
||||
|
||||
|
@ -18,28 +18,29 @@ define('GETID3_FREAD_BUFFER_SIZE', 16384); // read buffer size in bytes
|
|||
class getID3
|
||||
{
|
||||
// public: Settings
|
||||
var $encoding = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv())
|
||||
// Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
|
||||
var $encoding = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv())
|
||||
// Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
|
||||
|
||||
var $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written
|
||||
// in other encodings such as 'EUC-CN'
|
||||
var $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN'
|
||||
|
||||
var $tempdir = '*'; // default '*' should use system temp dir
|
||||
|
||||
// public: Optional tag checks - disable for speed.
|
||||
var $option_tag_id3v1 = true; // Read and process ID3v1 tags
|
||||
var $option_tag_id3v2 = true; // Read and process ID3v2 tags
|
||||
var $option_tag_lyrics3 = true; // Read and process Lyrics3 tags
|
||||
var $option_tag_apetag = true; // Read and process APE tags
|
||||
var $option_tags_process = true; // Copy tags to root key 'tags' and encode to $this->encoding
|
||||
var $option_tags_html = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
|
||||
var $option_tag_id3v1 = true; // Read and process ID3v1 tags
|
||||
var $option_tag_id3v2 = true; // Read and process ID3v2 tags
|
||||
var $option_tag_lyrics3 = true; // Read and process Lyrics3 tags
|
||||
var $option_tag_apetag = true; // Read and process APE tags
|
||||
var $option_tags_process = true; // Copy tags to root key 'tags' and encode to $this->encoding
|
||||
var $option_tags_html = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
|
||||
|
||||
// public: Optional tag/comment calucations
|
||||
var $option_extra_info = true; // Calculate additional info such as bitrate, channelmode etc
|
||||
var $option_extra_info = true; // Calculate additional info such as bitrate, channelmode etc
|
||||
|
||||
// public: Optional calculations
|
||||
var $option_md5_data = false; // Get MD5 sum of data part - slow
|
||||
var $option_md5_data_source = false; // Use MD5 of source file if availble - only FLAC and OptimFROG
|
||||
var $option_sha1_data = false; // Get SHA1 sum of data part - slow
|
||||
var $option_max_2gb_check = true; // Check whether file is larger than 2 Gb and thus not supported by PHP
|
||||
var $option_md5_data = false; // Get MD5 sum of data part - slow
|
||||
var $option_md5_data_source = false; // Use MD5 of source file if availble - only FLAC and OptimFROG
|
||||
var $option_sha1_data = false; // Get SHA1 sum of data part - slow
|
||||
var $option_max_2gb_check = true; // Check whether file is larger than 2 Gb and thus not supported by PHP
|
||||
|
||||
// private
|
||||
var $filename;
|
||||
|
@ -88,11 +89,9 @@ class getID3
|
|||
|
||||
// Get base path of getID3() - ONCE
|
||||
if (!defined('GETID3_INCLUDEPATH')) {
|
||||
define('GETID3_OS_DIRSLASH', (GETID3_OS_ISWINDOWS ? '\\' : '/'));
|
||||
|
||||
foreach (get_included_files() as $key => $val) {
|
||||
if (basename($val) == 'getid3.php') {
|
||||
define('GETID3_INCLUDEPATH', dirname($val).GETID3_OS_DIRSLASH);
|
||||
define('GETID3_INCLUDEPATH', dirname($val).DIRECTORY_SEPARATOR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +110,7 @@ class getID3
|
|||
// ie for "C:/Program Files/Apache/" put "C:/PROGRA~1/APACHE/"
|
||||
// IMPORTANT: This path must include the trailing slash
|
||||
if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
|
||||
$helperappsdir = GETID3_INCLUDEPATH.'..'.GETID3_OS_DIRSLASH.'helperapps'; // must not have any space in this path
|
||||
$helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
|
||||
|
||||
if (!is_dir($helperappsdir)) {
|
||||
|
||||
|
@ -119,37 +118,51 @@ class getID3
|
|||
|
||||
} elseif (strpos(realpath($helperappsdir), ' ') !== false) {
|
||||
|
||||
$DirPieces = explode(GETID3_OS_DIRSLASH, realpath($helperappsdir));
|
||||
$DirPieces8 = $DirPieces;
|
||||
|
||||
$CLIdir = $DirPieces[0].' && cd \\';
|
||||
for ($i = 1; $i < count($DirPieces); $i++) {
|
||||
if (strpos($DirPieces[$i], ' ') === false) {
|
||||
$CLIdir .= ' && cd '.$DirPieces[$i];
|
||||
} else {
|
||||
ob_start();
|
||||
system($CLIdir.' && dir /ad /x');
|
||||
$subdirsraw = explode("\n", ob_get_contents());
|
||||
ob_end_clean();
|
||||
foreach ($subdirsraw as $line) {
|
||||
if (eregi('^[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2} [AP]M <DIR> ([^ ]{8}) '.preg_quote($DirPieces[$i]).'$', trim($line), $matches)) {
|
||||
$CLIdir .= ' && cd '.$matches[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$DirPieces8[$i] = $matches[1];
|
||||
}
|
||||
}
|
||||
$helperappsdir = implode(GETID3_OS_DIRSLASH, $DirPieces8);
|
||||
$DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
|
||||
$DirPieces8 = $DirPieces;
|
||||
|
||||
$CLIdir = $DirPieces[0].' && cd \\';
|
||||
for ($i = 1; $i < count($DirPieces); $i++) {
|
||||
if (strpos($DirPieces[$i], ' ') === false) {
|
||||
$CLIdir .= ' && cd '.$DirPieces[$i];
|
||||
} else {
|
||||
ob_start();
|
||||
system($CLIdir.' && dir /ad /x');
|
||||
$subdirsraw = explode("\n", ob_get_contents());
|
||||
ob_end_clean();
|
||||
foreach ($subdirsraw as $dummy => $line) {
|
||||
if (eregi('^[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2} [AP]M <DIR> ([^ ]{8}) '.preg_quote($DirPieces[$i]).'$', trim($line), $matches)) {
|
||||
$CLIdir .= ' && cd '.$matches[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$DirPieces8[$i] = $matches[1];
|
||||
}
|
||||
}
|
||||
$helperappsdir = implode(DIRECTORY_SEPARATOR, $DirPieces8);
|
||||
|
||||
}
|
||||
define('GETID3_HELPERAPPSDIR', realpath($helperappsdir).GETID3_OS_DIRSLASH);
|
||||
define('GETID3_HELPERAPPSDIR', realpath($helperappsdir).DIRECTORY_SEPARATOR);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// public: setOption
|
||||
function setOption($optArray) {
|
||||
if (!is_array($optArray) || empty($optArray)) {
|
||||
return false;
|
||||
}
|
||||
foreach ($optArray as $opt => $val) {
|
||||
if (isset($this, $opt) === false) {
|
||||
continue;
|
||||
}
|
||||
$this->$opt = $val;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// public: analyze file - replaces GetAllFileInfo() and GetTagOnly()
|
||||
function analyze($filename) {
|
||||
|
@ -406,7 +419,7 @@ class getID3
|
|||
|
||||
// remove possible empty keys
|
||||
$AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams');
|
||||
foreach ($AVpossibleEmptyKeys as $key) {
|
||||
foreach ($AVpossibleEmptyKeys as $dummy => $key) {
|
||||
if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) {
|
||||
unset($this->info['audio'][$key]);
|
||||
}
|
||||
|
@ -669,12 +682,12 @@ class getID3
|
|||
),
|
||||
|
||||
// FLV - audio/video - FLash Video
|
||||
'flv' => array(
|
||||
'pattern' => '^FLV\x01',
|
||||
'group' => 'audio-video',
|
||||
'module' => 'flv',
|
||||
'mime_type' => 'video/x-flv',
|
||||
),
|
||||
'flv' => array(
|
||||
'pattern' => '^FLV\x01',
|
||||
'group' => 'audio-video',
|
||||
'module' => 'flv',
|
||||
'mime_type' => 'video/x-flv',
|
||||
),
|
||||
|
||||
// MKAV - audio/video - Mastroka
|
||||
'matroska' => array(
|
||||
|
@ -832,7 +845,7 @@ class getID3
|
|||
'fail_ape' => 'ERROR',
|
||||
),
|
||||
|
||||
// SZIP - audio - SZIP compressed data
|
||||
// SZIP - audio/data - SZIP compressed data
|
||||
'szip' => array(
|
||||
'pattern' => '^SZ\x0A\x04',
|
||||
'group' => 'archive',
|
||||
|
@ -862,7 +875,7 @@ class getID3
|
|||
'fail_ape' => 'ERROR',
|
||||
),
|
||||
|
||||
// ZIP - data - ZIP compressed data
|
||||
// ZIP - data - ZIP compressed data
|
||||
'zip' => array(
|
||||
'pattern' => '^PK\x03\x04',
|
||||
'group' => 'archive',
|
||||
|
@ -870,7 +883,30 @@ class getID3
|
|||
'mime_type' => 'application/zip',
|
||||
'fail_id3' => 'ERROR',
|
||||
'fail_ape' => 'ERROR',
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
// Misc other formats
|
||||
|
||||
// PDF - data - ZIP compressed data
|
||||
'pdf' => array(
|
||||
'pattern' => '^\x25PDF',
|
||||
'group' => 'misc',
|
||||
'module' => 'pdf',
|
||||
'mime_type' => 'application/pdf',
|
||||
'fail_id3' => 'ERROR',
|
||||
'fail_ape' => 'ERROR',
|
||||
),
|
||||
|
||||
// MSOFFICE - data - ZIP compressed data
|
||||
'msoffice' => array(
|
||||
'pattern' => '^\xD0\xCF\x11\xE0', // D0CF11E == DOCFILE == Microsoft Office Document
|
||||
'group' => 'misc',
|
||||
'module' => 'msoffice',
|
||||
'mime_type' => 'application/octet-stream',
|
||||
'fail_id3' => 'ERROR',
|
||||
'fail_ape' => 'ERROR',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -898,29 +934,12 @@ class getID3
|
|||
|
||||
|
||||
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('/\.tar$/i', $filename)) {
|
||||
//
|
||||
// // TAR files don't have any useful header to work from
|
||||
// // TAR - data - TAR compressed data
|
||||
// $info = array(
|
||||
// 'pattern' => '^.{512}',
|
||||
// 'group' => 'archive',
|
||||
// 'module' => 'tar',
|
||||
// 'mime_type' => 'application/octet-stream',
|
||||
// 'fail_id3' => 'ERROR',
|
||||
// 'fail_ape' => 'ERROR',
|
||||
// );
|
||||
// $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
|
||||
// return $info;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1087,6 +1106,7 @@ class getID3
|
|||
} else {
|
||||
|
||||
$commandline = 'vorbiscomment -w -c "'.$empty.'" "'.$file.'" "'.$temp.'" 2>&1';
|
||||
$commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
|
||||
$VorbisCommentError = `$commandline`;
|
||||
|
||||
}
|
||||
|
@ -1276,6 +1296,10 @@ class getID3
|
|||
return true;
|
||||
}
|
||||
|
||||
function getid3_tempnam() {
|
||||
return tempnam($this->tempdir, 'gI3');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
55
modules/id3/getid3/helperapps/readme.txt
Normal file
55
modules/id3/getid3/helperapps/readme.txt
Normal file
|
@ -0,0 +1,55 @@
|
|||
/////////////////////////////////////////////////////////////////
|
||||
/// getID3() by James Heinrich <info@getid3.org> //
|
||||
// available at http://getid3.sourceforge.net //
|
||||
// or http://www.getid3.org //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// /helperapps/readme.txt - part of getID3() //
|
||||
// List of binary files required under Windows for some //
|
||||
// features and/or file formats //
|
||||
// See /readme.txt for more details //
|
||||
// ///
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
This directory should contain binaries of various helper applications
|
||||
that getID3() depends on to handle some file formats under Windows.
|
||||
|
||||
The location of this directory is configurable in /getid3/getid3.php
|
||||
as GETID3_HELPERAPPSDIR
|
||||
|
||||
If this directory is empty, or you are missing any files, please
|
||||
download the latest version of the "getID3()-WindowsSupport" package
|
||||
from the usual download location (http://getid3.sourceforge.net)
|
||||
|
||||
|
||||
|
||||
Included files:
|
||||
=====================================================
|
||||
|
||||
Taken from http://www.cygwin.com/
|
||||
* cygwin1.dll
|
||||
|
||||
Taken from http://unxutils.sourceforge.net/
|
||||
* head.exe
|
||||
* md5sum.exe
|
||||
* tail.exe
|
||||
|
||||
Taken from http://ebible.org/mpj/software.htm
|
||||
* sha1sum.exe
|
||||
|
||||
Taken from http://www.vorbis.com/download.psp
|
||||
* vorbiscomment.exe
|
||||
|
||||
Taken from http://flac.sourceforge.net/download.html
|
||||
* metaflac.exe
|
||||
|
||||
Taken from http://www.etree.org/shncom.html
|
||||
* shorten.exe
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Changelog:
|
||||
|
||||
2003.12.29:
|
||||
* Initial release
|
|
@ -17,15 +17,10 @@
|
|||
class getid3_gzip {
|
||||
|
||||
// public: Optional file list - disable for speed.
|
||||
var $option_gzip_parse_contents = true; // decode gzipped files, if possible, and parse recursively (.tar.gz for example)
|
||||
var $option_gzip_parse_contents = false; // decode gzipped files, if possible, and parse recursively (.tar.gz for example)
|
||||
|
||||
function getid3_gzip(&$fd, &$ThisFileInfo) {
|
||||
$ThisFileInfo['fileformat'] = 'gzip';
|
||||
return $this->read_gzip($fd, $ThisFileInfo);
|
||||
}
|
||||
|
||||
// Reads the gzip-file
|
||||
function read_gzip($fd, &$ThisFileInfo) {
|
||||
|
||||
$start_length = 10;
|
||||
$unpack_header = 'a1id1/a1id2/a1cmethod/a1flags/a4mtime/a1xflags/a1os';
|
||||
|
|
|
@ -18,35 +18,25 @@ class getid3_tar {
|
|||
|
||||
function getid3_tar(&$fd, &$ThisFileInfo) {
|
||||
$ThisFileInfo['fileformat'] = 'tar';
|
||||
|
||||
@fseek($fd, 0);
|
||||
$filebuffer = @fread($fd, $ThisFileInfo['filesize']);
|
||||
return $this->read_tar($filebuffer, $ThisFileInfo);
|
||||
}
|
||||
|
||||
// Reads the tar-file
|
||||
function read_tar(&$filebuffer, &$ThisFileInfo) {
|
||||
|
||||
$header_length = 512;
|
||||
$unpack_header = 'a100fname/a8mode/a8uid/a8gid/a12size/a12mtime/a8chksum/a1typflag/a100lnkname/a6magic/a2ver/a32uname/a32gname/a8devmaj/a8devmin/a155/prefix';
|
||||
|
||||
$null_512k = str_repeat("\0", 512); // end-of-file marker
|
||||
|
||||
$ThisFileInfo['tar']['files'] = array();
|
||||
|
||||
while(strlen($filebuffer) != 0) {
|
||||
$buffer = substr($filebuffer, 0, $header_length);
|
||||
$filebuffer = substr($filebuffer, strlen($buffer));
|
||||
$unpack_header = 'a100fname/a8mode/a8uid/a8gid/a12size/a12mtime/a8chksum/a1typflag/a100lnkname/a6magic/a2ver/a32uname/a32gname/a8devmaj/a8devmin/a155/prefix';
|
||||
$null_512k = str_repeat("\0", 512); // end-of-file marker
|
||||
|
||||
@fseek($fd, 0);
|
||||
while (!feof($fd)) {
|
||||
$buffer = fread($fd, 512);
|
||||
|
||||
// check the block
|
||||
$checksum = 0;
|
||||
for ($i = 0; $i < 148; $i++) {
|
||||
$checksum += ord(substr($buffer, $i, 1));
|
||||
$checksum += ord($buffer{$i});
|
||||
}
|
||||
for ($i = 148; $i < 156; $i++) {
|
||||
$checksum += ord(' ');
|
||||
}
|
||||
for ($i = 156; $i < 512; $i++) {
|
||||
$checksum += ord(substr($buffer, $i, 1));
|
||||
$checksum += ord($buffer{$i});
|
||||
}
|
||||
$attr = unpack($unpack_header, $buffer);
|
||||
$name = trim(@$attr['fname']);
|
||||
|
@ -65,8 +55,8 @@ class getid3_tar {
|
|||
$devmaj = octdec(trim(@$attr['devmaj']));
|
||||
$devmin = octdec(trim(@$attr['devmin']));
|
||||
$prefix = trim(@$attr['prefix']);
|
||||
// EOF Found
|
||||
if (($checksum == 256) && ($chksum == 0)) {
|
||||
// EOF Found
|
||||
break;
|
||||
}
|
||||
if ($prefix) {
|
||||
|
@ -75,22 +65,18 @@ class getid3_tar {
|
|||
if ((preg_match('#/$#', $name)) && !$name) {
|
||||
$typeflag = 5;
|
||||
}
|
||||
// If it's the end of the tar-file...
|
||||
if ($buffer == $null_512k) {
|
||||
// it's the end of the tar-file...
|
||||
break;
|
||||
}
|
||||
// Read the next chunk
|
||||
$data = substr($filebuffer, 0, $size);
|
||||
$filebuffer = substr($filebuffer, strlen($data));
|
||||
if (strlen($data) != $size) {
|
||||
$ThisFileInfo['error'][] = 'Read error on tar file';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read to the next chunk
|
||||
fseek($fd, $size, SEEK_CUR);
|
||||
|
||||
$diff = $size % 512;
|
||||
if ($diff != 0) {
|
||||
// Padding, throw away
|
||||
$buff = substr($filebuffer, 0, (512 - $diff));
|
||||
$filebuffer = substr($filebuffer, strlen($buff));
|
||||
fseek($fd, (512 - $diff), SEEK_CUR);
|
||||
}
|
||||
// Protect against tar-files with garbage at the end
|
||||
if ($name == '') {
|
||||
|
@ -122,7 +108,7 @@ class getid3_tar {
|
|||
// Parses the file mode to file permissions
|
||||
function display_perms($mode) {
|
||||
// Determine Type
|
||||
if ($mode & 0x1000) $type='p'; // FIFO pipe
|
||||
if ($mode & 0x1000) $type='p'; // FIFO pipe
|
||||
elseif ($mode & 0x2000) $type='c'; // Character special
|
||||
elseif ($mode & 0x4000) $type='d'; // Directory
|
||||
elseif ($mode & 0x6000) $type='b'; // Block special
|
||||
|
|
|
@ -406,7 +406,7 @@ class getid3_zip
|
|||
$UNIXminute = (($DOStime & 0x07E0) >> 5);
|
||||
$UNIXhour = (($DOStime & 0xF800) >> 11);
|
||||
|
||||
return mktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
|
||||
return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1071,6 +1071,7 @@ class getid3_asf
|
|||
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
|
||||
if (@$dataarray['flags']['stream_number'] == $streamnumber) {
|
||||
$thisfile_asf_videomedia_currentstream['bitrate'] = $dataarray['bitrate'];
|
||||
$thisfile_video['streams'][$streamnumber]['bitrate'] = $dataarray['bitrate'];
|
||||
$thisfile_video['bitrate'] += $dataarray['bitrate'];
|
||||
break;
|
||||
}
|
||||
|
@ -1084,7 +1085,6 @@ class getid3_asf
|
|||
$thisfile_video['streams'][$streamnumber]['resolution_x'] = $thisfile_asf_videomedia_currentstream['image_width'];
|
||||
$thisfile_video['streams'][$streamnumber]['resolution_y'] = $thisfile_asf_videomedia_currentstream['image_height'];
|
||||
$thisfile_video['streams'][$streamnumber]['bits_per_sample'] = $thisfile_asf_videomedia_currentstream['format_data']['bits_per_pixel'];
|
||||
$thisfile_video['streams'][$streamnumber]['bitrate'] = $thisfile_asf_videomedia_currentstream['bitrate'];
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
// Steve Webster <steve.webster@featurecreep.com> //
|
||||
// * version 0.2 (22 February 2006) //
|
||||
// //
|
||||
// Modified to not read entire file into memory //
|
||||
// by James Heinrich <info@getid3.org> //
|
||||
// * version 0.3 (15 June 2006) //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// module.audio-video.flv.php //
|
||||
|
@ -37,81 +41,84 @@ class getid3_flv
|
|||
function getid3_flv(&$fd, &$ThisFileInfo, $ReturnAllTagData=false) {
|
||||
fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
|
||||
|
||||
$FLVfileData = fread($fd, $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']);
|
||||
$FLVdataLength = $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset'];
|
||||
$FLVheader = fread($fd, 5);
|
||||
|
||||
$FLVmagic = substr($FLVfileData, 0, 3);
|
||||
if ($FLVmagic != 'FLV') {
|
||||
$ThisFileInfo['fileformat'] = 'flv';
|
||||
$ThisFileInfo['flv']['header']['signature'] = substr($FLVheader, 0, 3);
|
||||
$ThisFileInfo['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
|
||||
$TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));
|
||||
|
||||
if ($ThisFileInfo['flv']['header']['signature'] != 'FLV') {
|
||||
$ThisFileInfo['error'][] = 'Expecting "FLV" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$ThisFileInfo['flv']['header']['signature'].'"';
|
||||
unset($ThisFileInfo['flv']);
|
||||
unset($ThisFileInfo['fileformat']);
|
||||
return false;
|
||||
}
|
||||
$ThisFileInfo['flv']['header']['signature'] = $FLVmagic;
|
||||
$ThisFileInfo['flv']['header']['version'] = ord($FLVfileData{3});
|
||||
$ThisFileInfo['fileformat'] = 'flv';
|
||||
|
||||
$TypeFlags = ord($FLVfileData{4});
|
||||
$ThisFileInfo['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 4);
|
||||
$ThisFileInfo['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 1);
|
||||
$ThisFileInfo['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04);
|
||||
$ThisFileInfo['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01);
|
||||
|
||||
$FrameSizeDataLength = getid3_lib::BigEndian2Int(substr($FLVfileData, 5, 4));
|
||||
|
||||
// FLV tags
|
||||
$CurrentOffset = $FrameSizeDataLength;
|
||||
$FLVdataLength = strlen($FLVfileData);
|
||||
$FrameSizeDataLength = getid3_lib::BigEndian2Int(fread($fd, 4));
|
||||
$FLVheaderFrameLength = 9;
|
||||
if ($FrameSizeDataLength > $FLVheaderFrameLength) {
|
||||
fseek($fd, $FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
|
||||
}
|
||||
|
||||
$Duration = 0;
|
||||
while ((ftell($fd) + 1) < $ThisFileInfo['avdataend']) {
|
||||
//if (!$ThisFileInfo['flv']['header']['hasAudio'] || isset($ThisFileInfo['flv']['audio']['audioFormat'])) {
|
||||
// if (!$ThisFileInfo['flv']['header']['hasVideo'] || isset($ThisFileInfo['flv']['video']['videoCodec'])) {
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
$SoundFormat = null;
|
||||
$VideoFormat = null;
|
||||
while ($CurrentOffset < $FLVdataLength) {
|
||||
// previous tag size
|
||||
$PreviousTagLength = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset, 4));
|
||||
$CurrentOffset += 4;
|
||||
$ThisTagHeader = fread($fd, 16);
|
||||
|
||||
$TagType = ord(substr($FLVfileData, $CurrentOffset, 1));
|
||||
$DataLength = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 1, 3));
|
||||
$Timestamp = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 4, 3));
|
||||
$PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4));
|
||||
$TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1));
|
||||
$DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3));
|
||||
$Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3));
|
||||
$LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1));
|
||||
$NextOffset = ftell($fd) - 1 + $DataLength;
|
||||
|
||||
switch ($TagType) {
|
||||
case GETID3_FLV_TAG_AUDIO:
|
||||
if (is_null($SoundFormat)) {
|
||||
$SoundInfo = ord(substr($FLVfileData, $CurrentOffset + 11, 1));
|
||||
$SoundFormat = $SoundInfo & 0x07;
|
||||
$ThisFileInfo['flv']['audio']['audioFormat'] = $SoundFormat;
|
||||
$ThisFileInfo['flv']['audio']['audioRate'] = ($SoundInfo & 0x30) / 0x10;
|
||||
$ThisFileInfo['flv']['audio']['audioSampleSize'] = ($SoundInfo & 0x40) / 0x40;
|
||||
$ThisFileInfo['flv']['audio']['audioType'] = ($SoundInfo & 0x80) / 0x80;
|
||||
if (!isset($ThisFileInfo['flv']['audio']['audioFormat'])) {
|
||||
$ThisFileInfo['flv']['audio']['audioFormat'] = $LastHeaderByte & 0x07;
|
||||
$ThisFileInfo['flv']['audio']['audioRate'] = ($LastHeaderByte & 0x30) / 0x10;
|
||||
$ThisFileInfo['flv']['audio']['audioSampleSize'] = ($LastHeaderByte & 0x40) / 0x40;
|
||||
$ThisFileInfo['flv']['audio']['audioType'] = ($LastHeaderByte & 0x80) / 0x80;
|
||||
}
|
||||
break;
|
||||
|
||||
case GETID3_FLV_TAG_VIDEO:
|
||||
if (is_null($VideoFormat)) {
|
||||
$VideoInfo = ord(substr($FLVfileData, $CurrentOffset + 11, 1));
|
||||
$VideoFormat = $VideoInfo & 0x07;
|
||||
$ThisFileInfo['flv']['video']['videoCodec'] = $VideoFormat;
|
||||
if (!isset($ThisFileInfo['flv']['video']['videoCodec'])) {
|
||||
$ThisFileInfo['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07;
|
||||
|
||||
if ($VideoFormat != GETID3_FLV_VIDEO_VP6) {
|
||||
$FLVvideoHeader = fread($fd, 11);
|
||||
|
||||
$PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 15, 2))) >> 7;
|
||||
if ($ThisFileInfo['flv']['video']['videoCodec'] != GETID3_FLV_VIDEO_VP6) {
|
||||
|
||||
$PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 3, 2))) >> 7;
|
||||
$PictureSizeType = $PictureSizeType & 0x0007;
|
||||
$ThisFileInfo['flv']['header']['videoSizeType'] = $PictureSizeType;
|
||||
switch ($PictureSizeType) {
|
||||
case 0:
|
||||
$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 16, 2));
|
||||
$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
|
||||
$PictureSizeEnc <<= 1;
|
||||
$ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8;
|
||||
$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 17, 2));
|
||||
$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
|
||||
$PictureSizeEnc <<= 1;
|
||||
$ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 16, 4));
|
||||
$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 4));
|
||||
$PictureSizeEnc <<= 1;
|
||||
$ThisFileInfo['video']['resolution_x'] = ($PictureSizeEnc & 0xFFFF0000) >> 16;
|
||||
|
||||
$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVfileData, $CurrentOffset + 18, 4));
|
||||
$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 4));
|
||||
$PictureSizeEnc <<= 1;
|
||||
$ThisFileInfo['video']['resolution_y'] = ($PictureSizeEnc & 0xFFFF0000) >> 16;
|
||||
break;
|
||||
|
@ -154,16 +161,15 @@ class getid3_flv
|
|||
// Meta tag
|
||||
case GETID3_FLV_TAG_META:
|
||||
|
||||
$reader = new AMFReader(new AMFStream(substr($FLVfileData, $CurrentOffset + 11, $DataLength)));
|
||||
fseek($fd, -1, SEEK_CUR);
|
||||
$reader = new AMFReader(new AMFStream(fread($fd, $DataLength)));
|
||||
$eventName = $reader->readData();
|
||||
$ThisFileInfo['meta'][$eventName] = $reader->readData();
|
||||
|
||||
unset($reader);
|
||||
|
||||
$ThisFileInfo['video']['frame_rate'] = $ThisFileInfo['meta']['onMetaData']['framerate'];
|
||||
$ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['meta']['onMetaData']['width'];
|
||||
$ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['meta']['onMetaData']['height'];
|
||||
|
||||
$ThisFileInfo['video']['frame_rate'] = $ThisFileInfo['meta']['onMetaData']['framerate'];
|
||||
$ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['meta']['onMetaData']['width'];
|
||||
$ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['meta']['onMetaData']['height'];
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -175,7 +181,7 @@ class getid3_flv
|
|||
$Duration = $Timestamp;
|
||||
}
|
||||
|
||||
$CurrentOffset += ($DataLength + 11);
|
||||
fseek($fd, $NextOffset, SEEK_SET);
|
||||
}
|
||||
|
||||
$ThisFileInfo['playtime_seconds'] = $Duration / 1000;
|
||||
|
@ -191,7 +197,7 @@ class getid3_flv
|
|||
$ThisFileInfo['audio']['dataformat'] = 'flv';
|
||||
}
|
||||
if (@$ThisFileInfo['flv']['header']['hasVideo']) {
|
||||
$ThisFileInfo['video']['codec'] = $this->FLVvideoCodec($ThisFileInfo['flv']['video']['videoCodec']);
|
||||
$ThisFileInfo['video']['codec'] = $this->FLVvideoCodec($ThisFileInfo['flv']['video']['videoCodec']);
|
||||
$ThisFileInfo['video']['dataformat'] = 'flv';
|
||||
$ThisFileInfo['video']['lossless'] = false;
|
||||
}
|
||||
|
|
|
@ -520,7 +520,7 @@ class getid3_quicktime
|
|||
$atomstructure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atomdata, $sttsEntriesDataOffset, 4));
|
||||
$sttsEntriesDataOffset += 4;
|
||||
|
||||
if (!empty($ThisFileInfo['quicktime']['time_scale'])) {
|
||||
if (!empty($ThisFileInfo['quicktime']['time_scale']) && (@$atomstructure['time_to_sample_table'][$i]['sample_duration'] > 0)) {
|
||||
$stts_new_framerate = $ThisFileInfo['quicktime']['time_scale'] / $atomstructure['time_to_sample_table'][$i]['sample_duration'];
|
||||
if ($stts_new_framerate <= 60) {
|
||||
// some atoms have durations of "1" giving a very large framerate, which probably is not right
|
||||
|
|
|
@ -201,7 +201,7 @@ class getid3_riff
|
|||
$thisfile_riff_WAVE_bext_0['reserved'] = getid3_lib::LittleEndian2Int(substr($thisfile_riff_WAVE_bext_0['data'], 347, 254));
|
||||
$thisfile_riff_WAVE_bext_0['coding_history'] = explode("\r\n", trim(substr($thisfile_riff_WAVE_bext_0['data'], 601)));
|
||||
|
||||
$thisfile_riff_WAVE_bext_0['origin_date_unix'] = mktime(
|
||||
$thisfile_riff_WAVE_bext_0['origin_date_unix'] = gmmktime(
|
||||
substr($thisfile_riff_WAVE_bext_0['origin_time'], 0, 2),
|
||||
substr($thisfile_riff_WAVE_bext_0['origin_time'], 3, 2),
|
||||
substr($thisfile_riff_WAVE_bext_0['origin_time'], 6, 2),
|
||||
|
@ -1005,7 +1005,7 @@ class getid3_riff
|
|||
}
|
||||
|
||||
|
||||
function RIFFcommentsParse(&$RIFFinfoArray, &$CommentsTargetArray) {
|
||||
function RIFFcommentsParse(&$RIFFinfoArray, &$CommentsTargetArray) {
|
||||
$RIFFinfoKeyLookup = array(
|
||||
'IARL'=>'archivallocation',
|
||||
'IART'=>'artist',
|
||||
|
@ -1055,9 +1055,9 @@ class getid3_riff
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function ParseRIFF(&$fd, $startoffset, $maxoffset, &$ThisFileInfo) {
|
||||
|
||||
|
|
|
@ -299,7 +299,7 @@ class getid3_aac
|
|||
}
|
||||
|
||||
// used to calculate bitrate below
|
||||
static $BitrateCache = array();
|
||||
$BitrateCache = array();
|
||||
|
||||
|
||||
while (true) {
|
||||
|
|
|
@ -47,7 +47,7 @@ class getid3_flac
|
|||
$METAdataBlockLength = getid3_lib::BigEndian2Int(substr($METAdataBlockHeader, 1, 3));
|
||||
$METAdataBlockTypeText = getid3_flac::FLACmetaBlockTypeLookup($METAdataBlockType);
|
||||
|
||||
if ($METAdataBlockLength <= 0) {
|
||||
if ($METAdataBlockLength < 0) {
|
||||
$ThisFileInfo['error'][] = 'corrupt or invalid METADATA_BLOCK_HEADER.BLOCK_TYPE ('.$METAdataBlockType.') at offset '.$METAdataBlockOffset;
|
||||
break;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class getid3_flac
|
|||
$ThisFileInfo_flac_METAdataBlockTypeText_raw['block_type'] = $METAdataBlockType;
|
||||
$ThisFileInfo_flac_METAdataBlockTypeText_raw['block_type_text'] = $METAdataBlockTypeText;
|
||||
$ThisFileInfo_flac_METAdataBlockTypeText_raw['block_length'] = $METAdataBlockLength;
|
||||
$ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'] = fread($fd, $METAdataBlockLength);
|
||||
$ThisFileInfo_flac_METAdataBlockTypeText_raw['block_data'] = @fread($fd, $METAdataBlockLength);
|
||||
$ThisFileInfo['avdataoffset'] = ftell($fd);
|
||||
|
||||
switch ($METAdataBlockTypeText) {
|
||||
|
|
|
@ -1880,51 +1880,57 @@ class getid3_mp3
|
|||
}
|
||||
|
||||
function LAMEpresetUsedLookup($LAMEtag) {
|
||||
if ($LAMEtag['preset_used_id'] == 0) {
|
||||
// no preset used (LAME >=3.93)
|
||||
// no preset recorded (LAME <3.93)
|
||||
return '';
|
||||
}
|
||||
static $LAMEpresetUsedLookup = array();
|
||||
if (empty($LAMEpresetUsedLookup)) {
|
||||
for ($i = 8; $i <= 320; $i++) {
|
||||
switch ($LAMEtag['vbr_method']) {
|
||||
case 'cbr':
|
||||
$LAMEpresetUsedLookup[$i] = '--alt-preset '.$LAMEtag['vbr_method'].' '.$i;
|
||||
break;
|
||||
case 'abr':
|
||||
default: // other VBR modes shouldn't be here(?)
|
||||
$LAMEpresetUsedLookup[$i] = '--alt-preset '.$i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// named old-style presets (studio, phone, voice, etc) are handled in GuessEncoderOptions()
|
||||
if ($LAMEtag['preset_used_id'] == 0) {
|
||||
// no preset used (LAME >=3.93)
|
||||
// no preset recorded (LAME <3.93)
|
||||
return '';
|
||||
}
|
||||
$LAMEpresetUsedLookup = array();
|
||||
|
||||
// named alt-presets
|
||||
$LAMEpresetUsedLookup[1000] = '--r3mix';
|
||||
$LAMEpresetUsedLookup[1001] = '--alt-preset standard';
|
||||
$LAMEpresetUsedLookup[1002] = '--alt-preset extreme';
|
||||
$LAMEpresetUsedLookup[1003] = '--alt-preset insane';
|
||||
$LAMEpresetUsedLookup[1004] = '--alt-preset fast standard';
|
||||
$LAMEpresetUsedLookup[1005] = '--alt-preset fast extreme';
|
||||
$LAMEpresetUsedLookup[1006] = '--alt-preset medium';
|
||||
$LAMEpresetUsedLookup[1007] = '--alt-preset fast medium';
|
||||
///// THIS PART CANNOT BE STATIC .
|
||||
for ($i = 8; $i <= 320; $i++) {
|
||||
switch ($LAMEtag['vbr_method']) {
|
||||
case 'cbr':
|
||||
$LAMEpresetUsedLookup[$i] = '--alt-preset '.$LAMEtag['vbr_method'].' '.$i;
|
||||
break;
|
||||
case 'abr':
|
||||
default: // other VBR modes shouldn't be here(?)
|
||||
$LAMEpresetUsedLookup[$i] = '--alt-preset '.$i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// LAME 3.94 additions/changes
|
||||
$LAMEpresetUsedLookup[1010] = '--preset portable'; // 3.94a15 Oct 21 2003
|
||||
$LAMEpresetUsedLookup[1015] = '--preset radio'; // 3.94a15 Oct 21 2003
|
||||
// named old-style presets (studio, phone, voice, etc) are handled in GuessEncoderOptions()
|
||||
|
||||
$LAMEpresetUsedLookup[320] = '--preset insane'; // 3.94a15 Nov 12 2003
|
||||
$LAMEpresetUsedLookup[430] = '--preset radio'; // 3.94a15 Nov 12 2003
|
||||
$LAMEpresetUsedLookup[450] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'portable'; // 3.94a15 Nov 12 2003
|
||||
$LAMEpresetUsedLookup[460] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'medium'; // 3.94a15 Nov 12 2003
|
||||
$LAMEpresetUsedLookup[470] = '--r3mix'; // 3.94b1 Dec 18 2003
|
||||
$LAMEpresetUsedLookup[480] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'standard'; // 3.94a15 Nov 12 2003
|
||||
$LAMEpresetUsedLookup[500] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'extreme'; // 3.94a15 Nov 12 2003
|
||||
}
|
||||
return (isset($LAMEpresetUsedLookup[$LAMEtag['preset_used_id']]) ? $LAMEpresetUsedLookup[$LAMEtag['preset_used_id']] : 'new/unknown preset: '.$LAMEtag['preset_used_id'].' - report to info@getid3.org');
|
||||
}
|
||||
// named alt-presets
|
||||
$LAMEpresetUsedLookup[1000] = '--r3mix';
|
||||
$LAMEpresetUsedLookup[1001] = '--alt-preset standard';
|
||||
$LAMEpresetUsedLookup[1002] = '--alt-preset extreme';
|
||||
$LAMEpresetUsedLookup[1003] = '--alt-preset insane';
|
||||
$LAMEpresetUsedLookup[1004] = '--alt-preset fast standard';
|
||||
$LAMEpresetUsedLookup[1005] = '--alt-preset fast extreme';
|
||||
$LAMEpresetUsedLookup[1006] = '--alt-preset medium';
|
||||
$LAMEpresetUsedLookup[1007] = '--alt-preset fast medium';
|
||||
|
||||
// LAME 3.94 additions/changes
|
||||
$LAMEpresetUsedLookup[1010] = '--preset portable'; // 3.94a15 Oct 21 2003
|
||||
$LAMEpresetUsedLookup[1015] = '--preset radio'; // 3.94a15 Oct 21 2003
|
||||
|
||||
$LAMEpresetUsedLookup[320] = '--preset insane'; // 3.94a15 Nov 12 2003
|
||||
$LAMEpresetUsedLookup[410] = '-V9';
|
||||
$LAMEpresetUsedLookup[420] = '-V8';
|
||||
$LAMEpresetUsedLookup[440] = '-V6';
|
||||
$LAMEpresetUsedLookup[430] = '--preset radio'; // 3.94a15 Nov 12 2003
|
||||
$LAMEpresetUsedLookup[450] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'portable'; // 3.94a15 Nov 12 2003
|
||||
$LAMEpresetUsedLookup[460] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'medium'; // 3.94a15 Nov 12 2003
|
||||
$LAMEpresetUsedLookup[470] = '--r3mix'; // 3.94b1 Dec 18 2003
|
||||
$LAMEpresetUsedLookup[480] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'standard'; // 3.94a15 Nov 12 2003
|
||||
$LAMEpresetUsedLookup[490] = '-V1';
|
||||
$LAMEpresetUsedLookup[500] = '--preset '.(($LAMEtag['raw']['vbr_method'] == 4) ? 'fast ' : '').'extreme'; // 3.94a15 Nov 12 2003
|
||||
|
||||
return (isset($LAMEpresetUsedLookup[$LAMEtag['preset_used_id']]) ? $LAMEpresetUsedLookup[$LAMEtag['preset_used_id']] : 'new/unknown preset: '.$LAMEtag['preset_used_id'].' - report to info@getid3.org');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -124,6 +124,7 @@ class getid3_shorten
|
|||
}
|
||||
}
|
||||
$commandline = GETID3_HELPERAPPSDIR.'shorten.exe -x "'.$ThisFileInfo['filenamepath'].'" - | '.GETID3_HELPERAPPSDIR.'head.exe -c 44';
|
||||
$commandline = str_replace('/', '\\', $commandline);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -135,7 +136,7 @@ class getid3_shorten
|
|||
$ThisFileInfo['error'][] = 'shorten binary was not found in path or /usr/local/bin';
|
||||
return false;
|
||||
}
|
||||
$commandline = (file_exists('/usr/local/bin/shorten') ? '/usr/local/bin/' : '' ) . 'shorten -x "'.$ThisFileInfo['filenamepath'].'" - | head -c 44';
|
||||
$commandline = (file_exists('/usr/local/bin/shorten') ? '/usr/local/bin/' : '' ) . 'shorten -x '.escapeshellarg($ThisFileInfo['filenamepath']).' - | head -c 44';
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -338,7 +338,7 @@ class getid3_iso
|
|||
if (!$UNIXyear) {
|
||||
return false;
|
||||
}
|
||||
return mktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
|
||||
return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
|
||||
}
|
||||
|
||||
function ISOtime2UNIXtime($ISOtime) {
|
||||
|
@ -359,7 +359,7 @@ class getid3_iso
|
|||
$UNIXsecond = ord($ISOtime{5});
|
||||
$GMToffset = $this->TwosCompliment2Decimal(ord($ISOtime{5}));
|
||||
|
||||
return mktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
|
||||
return gmmktime($UNIXhour, $UNIXminute, $UNIXsecond, $UNIXmonth, $UNIXday, $UNIXyear);
|
||||
}
|
||||
|
||||
function TwosCompliment2Decimal($BinaryValue) {
|
||||
|
|
|
@ -234,7 +234,7 @@ class getid3_id3v2
|
|||
} elseif (($frame_name == "\x00".'MP3') || ($frame_name == "\x00\x00".'MP') || ($frame_name == ' MP3') || ($frame_name == 'MP3e')) {
|
||||
// MP3ext known broken frames - "ok" for the purposes of this test
|
||||
} elseif (($id3v2_majorversion == 4) && ($this->IsValidID3v2FrameName(substr($framedata, getid3_lib::BigEndian2Int(substr($frame_header, 4, 4), 0), 4), 3))) {
|
||||
$ThisFileInfo['warning'][] = 'ID3v2 tag written as ID3v2.4, but with non-synchsafe integers (ID3v2.3 style). Older versions of Helium2 (www.helium2.com) is a known culprit of this. Tag has been parsed as ID3v2.3';
|
||||
$ThisFileInfo['warning'][] = 'ID3v2 tag written as ID3v2.4, but with non-synchsafe integers (ID3v2.3 style). Older versions of (Helium2; iTunes) are known culprits of this. Tag has been parsed as ID3v2.3';
|
||||
$id3v2_majorversion = 3;
|
||||
$frame_size = getid3_lib::BigEndian2Int(substr($frame_header, 4, 4), 0); // 32-bit integer
|
||||
}
|
||||
|
@ -292,7 +292,8 @@ class getid3_id3v2
|
|||
} else {
|
||||
|
||||
// next frame is invalid too, abort processing
|
||||
unset($framedata);
|
||||
//unset($framedata);
|
||||
$framedata = null;
|
||||
$ThisFileInfo['error'][] = 'Next ID3v2 frame is also invalid, aborting processing.';
|
||||
|
||||
}
|
||||
|
@ -305,7 +306,8 @@ class getid3_id3v2
|
|||
} else {
|
||||
|
||||
// next frame is invalid too, abort processing
|
||||
unset($framedata);
|
||||
//unset($framedata);
|
||||
$framedata = null;
|
||||
$ThisFileInfo['warning'][] = 'Invalid ID3v2 frame size, aborting.';
|
||||
|
||||
}
|
||||
|
@ -386,6 +388,10 @@ class getid3_id3v2
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($thisfile_id3v2['comments']['year']) && ereg('^([0-9]{4})', trim(@$thisfile_id3v2['comments']['recording_time'][0]), $matches)) {
|
||||
$thisfile_id3v2['comments']['year'] = array($matches[1]);
|
||||
}
|
||||
|
||||
|
||||
// Set avdataoffset
|
||||
$ThisFileInfo['avdataoffset'] = $thisfile_id3v2['headerlength'];
|
||||
|
@ -2873,88 +2879,168 @@ class getid3_id3v2
|
|||
|
||||
$begin = __LINE__;
|
||||
|
||||
/** This is not a comment!
|
||||
|
||||
COM comment
|
||||
COMM comment
|
||||
TAL album
|
||||
TALB album
|
||||
TBP bpm
|
||||
TBPM bpm
|
||||
TCM composer
|
||||
TCO genre
|
||||
TCOM composer
|
||||
TCON genre
|
||||
TCOP copyright
|
||||
TCR copyright
|
||||
TEN encoded_by
|
||||
TENC encoded_by
|
||||
TEXT lyricist
|
||||
TIT1 description
|
||||
TIT2 title
|
||||
TIT3 subtitle
|
||||
TLA language
|
||||
TLAN language
|
||||
TLE length
|
||||
TLEN length
|
||||
TMOO mood
|
||||
TOA original_artist
|
||||
TOAL original_album
|
||||
TOF original_filename
|
||||
TOFN original_filename
|
||||
TOL original_lyricist
|
||||
TOLY original_lyricist
|
||||
TOPE original_artist
|
||||
TOT original_album
|
||||
TP1 artist
|
||||
TP2 band
|
||||
TP3 conductor
|
||||
TP4 remixer
|
||||
TPB publisher
|
||||
TPE1 artist
|
||||
TPE2 band
|
||||
TPE3 conductor
|
||||
TPE4 remixer
|
||||
TPUB publisher
|
||||
TRC isrc
|
||||
TRCK track
|
||||
TRK track
|
||||
TSI size
|
||||
TSIZ size
|
||||
TSRC isrc
|
||||
TSS encoder_settings
|
||||
TSSE encoder_settings
|
||||
TSST subtitle
|
||||
TT1 description
|
||||
TT2 title
|
||||
TT3 subtitle
|
||||
TXT lyricist
|
||||
TXX text
|
||||
TXXX text
|
||||
TYE year
|
||||
TYER year
|
||||
UFI unique_file_identifier
|
||||
UFID unique_file_identifier
|
||||
ULT unsychronised_lyric
|
||||
USER terms_of_use
|
||||
USLT unsynchronised lyric
|
||||
WAF url_file
|
||||
WAR url_artist
|
||||
WAS url_source
|
||||
WCOP copyright
|
||||
WCP copyright
|
||||
WOAF url_file
|
||||
WOAR url_artist
|
||||
WOAS url_source
|
||||
WORS url_station
|
||||
WPB url_publisher
|
||||
WPUB url_publisher
|
||||
WXX url_user
|
||||
WXXX url_user
|
||||
TFEA featured_artist
|
||||
TSTU studio
|
||||
|
||||
*/
|
||||
/** This is not a comment!
|
||||
|
||||
AENC audio_encryption
|
||||
APIC attached_picture
|
||||
ASPI audio_seek_point_index
|
||||
BUF recommended_buffer_size
|
||||
CNT play_counter
|
||||
COM comments
|
||||
COMM comments
|
||||
COMR commercial_frame
|
||||
CRA audio_encryption
|
||||
CRM encrypted_meta_frame
|
||||
ENCR encryption_method_registration
|
||||
EQU equalisation
|
||||
EQU2 equalisation
|
||||
EQUA equalisation
|
||||
ETC event_timing_codes
|
||||
ETCO event_timing_codes
|
||||
GEO general_encapsulated_object
|
||||
GEOB general_encapsulated_object
|
||||
GRID group_identification_registration
|
||||
IPL involved_people_list
|
||||
IPLS involved_people_list
|
||||
LINK linked_information
|
||||
LNK linked_information
|
||||
MCDI music_cd_identifier
|
||||
MCI music_cd_identifier
|
||||
MLL mpeg_location_lookup_table
|
||||
MLLT mpeg_location_lookup_table
|
||||
OWNE ownership_frame
|
||||
PCNT play_counter
|
||||
PIC attached_picture
|
||||
POP popularimeter
|
||||
POPM popularimeter
|
||||
POSS position_synchronisation_frame
|
||||
PRIV private_frame
|
||||
RBUF recommended_buffer_size
|
||||
REV reverb
|
||||
RVA relative_volume_adjustment
|
||||
RVA2 relative_volume_adjustment
|
||||
RVAD relative_volume_adjustment
|
||||
RVRB reverb
|
||||
SEEK seek_frame
|
||||
SIGN signature_frame
|
||||
SLT synchronised_lyric
|
||||
STC synced_tempo_codes
|
||||
SYLT synchronised_lyric
|
||||
SYTC synchronised_tempo_codes
|
||||
TAL album
|
||||
TALB album
|
||||
TBP bpm
|
||||
TBPM bpm
|
||||
TCM composer
|
||||
TCO content_type
|
||||
TCOM composer
|
||||
TCON content_type
|
||||
TCOP copyright_message
|
||||
TCR copyright_message
|
||||
TDA date
|
||||
TDAT date
|
||||
TDEN encoding_time
|
||||
TDLY playlist_delay
|
||||
TDOR original_release_time
|
||||
TDRC recording_time
|
||||
TDRL release_time
|
||||
TDTG tagging_time
|
||||
TDY playlist_delay
|
||||
TEN encoded_by
|
||||
TENC encoded_by
|
||||
TEXT lyricist
|
||||
TFLT file_type
|
||||
TFT file_type
|
||||
TIM time
|
||||
TIME time
|
||||
TIPL involved_people_list
|
||||
TIT1 content_group_description
|
||||
TIT2 title
|
||||
TIT3 subtitle
|
||||
TKE initial_key
|
||||
TKEY initial_key
|
||||
TLA language
|
||||
TLAN language
|
||||
TLE length
|
||||
TLEN length
|
||||
TMCL musician_credits_list
|
||||
TMED media_type
|
||||
TMOO mood
|
||||
TMT media_type
|
||||
TOA original_artist
|
||||
TOAL original_album
|
||||
TOF original_filename
|
||||
TOFN original_filename
|
||||
TOL original_lyricist
|
||||
TOLY original_lyricist
|
||||
TOPE original_artist
|
||||
TOR original_year
|
||||
TORY original_year
|
||||
TOT original_album
|
||||
TOWN file_owner
|
||||
TP1 artist
|
||||
TP2 band
|
||||
TP3 conductor
|
||||
TP4 remixer
|
||||
TPA part_of_a_set
|
||||
TPB publisher
|
||||
TPE1 artist
|
||||
TPE2 band
|
||||
TPE3 conductor
|
||||
TPE4 remixer
|
||||
TPOS part_of_a_set
|
||||
TPRO produced_notice
|
||||
TPUB publisher
|
||||
TRC isrc
|
||||
TRCK track_number
|
||||
TRD recording_dates
|
||||
TRDA recording_dates
|
||||
TRK track_number
|
||||
TRSN internet_radio_station_name
|
||||
TRSO internet_radio_station_owner
|
||||
TSI size
|
||||
TSIZ size
|
||||
TSOA album_sort_order
|
||||
TSOP performer_sort_order
|
||||
TSOT title_sort_order
|
||||
TSRC isrc
|
||||
TSS encoder_settings
|
||||
TSSE encoder_settings
|
||||
TSST set_subtitle
|
||||
TT1 description
|
||||
TT2 title
|
||||
TT3 subtitle
|
||||
TXT lyricist
|
||||
TXX text
|
||||
TXXX text
|
||||
TYE year
|
||||
TYER year
|
||||
UFI unique_file_identifier
|
||||
UFID unique_file_identifier
|
||||
ULT unsychronised_lyric
|
||||
USER terms_of_use
|
||||
USLT unsynchronised_lyric
|
||||
WAF url_file
|
||||
WAR url_artist
|
||||
WAS url_source
|
||||
WCM commercial_information
|
||||
WCOM commercial_information
|
||||
WCOP copyright
|
||||
WCP copyright
|
||||
WOAF url_file
|
||||
WOAR url_artist
|
||||
WOAS url_source
|
||||
WORS url_station
|
||||
WPAY url_payment
|
||||
WPB url_publisher
|
||||
WPUB url_publisher
|
||||
WXX url_user
|
||||
WXXX url_user
|
||||
TFEA featured_artist
|
||||
TSTU recording_studio
|
||||
rgad replay_gain_adjustment
|
||||
|
||||
*/
|
||||
|
||||
return getid3_lib::EmbeddedLookup($framename, $begin, __LINE__, __FILE__, 'id3v2-framename_short');
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ class getid3_writetags
|
|||
case 'mp3':
|
||||
case 'mp2':
|
||||
case 'mp1':
|
||||
case 'riff': // maybe not officially, but people do it anyway
|
||||
$AllowedTagFormats = array('id3v1', 'id3v2.2', 'id3v2.3', 'id3v2.4', 'ape', 'lyrics3');
|
||||
break;
|
||||
|
||||
|
@ -300,7 +301,7 @@ class getid3_writetags
|
|||
$this->errors[] = 'WriteVorbisComment() failed with message(s):<PRE><UL><LI>'.trim(implode('</LI><LI>', $vorbiscomment_writer->errors)).'</LI></UL></PRE>';
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = 'WriteVorbisComment() failed';
|
||||
$this->errors[] = 'FormatDataForVorbisComment() failed';
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -348,11 +348,26 @@ class vainfo {
|
|||
|
||||
/* Go through the tags */
|
||||
foreach ($tags as $tag=>$data) {
|
||||
|
||||
/* This is our baseline for naming so
|
||||
* no translation is needed
|
||||
|
||||
/**
|
||||
* the new getid3 handles this differently
|
||||
* so we now need to account for it :(
|
||||
*/
|
||||
$array[$tag] = $this->_clean_tag($data['0'],$this->_file_encoding);
|
||||
switch ($tag) {
|
||||
case 'track_number':
|
||||
$array['track'] = $this->_clean_tag($data['0'],$this->_file_encoding);
|
||||
break;
|
||||
case 'content_type':
|
||||
$data['0'] = preg_replace("/^\(\d+\)/","",$data['0']);
|
||||
$array['genre'] = $this->_clean_tag($data['0'],$this->_file_encoding);
|
||||
break;
|
||||
case 'comments':
|
||||
$array['comment'] = $this->_clean_tag($data['0'],$this->_file_encoding);
|
||||
break;
|
||||
default:
|
||||
$array[$tag] = $this->_clean_tag($data['0'],$this->_file_encoding);
|
||||
break;
|
||||
} // end switch on tag
|
||||
|
||||
} // end foreach
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue