Compatible SPIP 4.1

Mise à jour de la lib en 1.9.21 (et remise dedans de la fonction getid3_lib::ImageTypesLookup supprimée suite à https://github.com/JamesHeinrich/getID3/pull/156, signalé https://github.com/JamesHeinrich/getID3/issues/391)

En test car seuls les MP3 ont été testés (avec ou sans couverture)
master
RealET 1 year ago
parent 53de7fe78a
commit 923db966dd

118
.gitattributes vendored

@ -1,118 +0,0 @@
* text=auto !eol
action/getid3_appliquer_cover_defaut.php -text
action/getid3_infos.php -text
action/getid3_verifier_binaires.php -text
base/getid3_base.php -text
demo/test_id3.html -text
demo/test_id3_fonctions.php -text
formulaires/configurer_getid3.html -text
formulaires/editer_id3.html -text
formulaires/editer_id3.php -text
genie/getid3_taches_generales.php -text
getid3/extension.cache.dbm.php -text
getid3/extension.cache.mysql.php -text
getid3/extension.cache.mysqli.php -text
getid3/extension.cache.sqlite3.php -text
getid3/getid3.lib.php -text
getid3/getid3.php -text
getid3/module.archive.gzip.php -text
getid3/module.archive.rar.php -text
getid3/module.archive.szip.php -text
getid3/module.archive.tar.php -text
getid3/module.archive.zip.php -text
getid3/module.audio-video.asf.php -text
getid3/module.audio-video.bink.php -text
getid3/module.audio-video.flv.php -text
getid3/module.audio-video.matroska.php -text
getid3/module.audio-video.mpeg.php -text
getid3/module.audio-video.nsv.php -text
getid3/module.audio-video.quicktime.php -text
getid3/module.audio-video.real.php -text
getid3/module.audio-video.riff.php -text
getid3/module.audio-video.swf.php -text
getid3/module.audio-video.ts.php -text
getid3/module.audio.aa.php -text
getid3/module.audio.aac.php -text
getid3/module.audio.ac3.php -text
getid3/module.audio.amr.php -text
getid3/module.audio.au.php -text
getid3/module.audio.avr.php -text
getid3/module.audio.bonk.php -text
getid3/module.audio.dsf.php -text
getid3/module.audio.dss.php -text
getid3/module.audio.dts.php -text
getid3/module.audio.flac.php -text
getid3/module.audio.la.php -text
getid3/module.audio.lpac.php -text
getid3/module.audio.midi.php -text
getid3/module.audio.mod.php -text
getid3/module.audio.monkey.php -text
getid3/module.audio.mp3.php -text
getid3/module.audio.mpc.php -text
getid3/module.audio.ogg.php -text
getid3/module.audio.optimfrog.php -text
getid3/module.audio.rkau.php -text
getid3/module.audio.shorten.php -text
getid3/module.audio.tta.php -text
getid3/module.audio.voc.php -text
getid3/module.audio.vqf.php -text
getid3/module.audio.wavpack.php -text
getid3/module.graphic.bmp.php -text
getid3/module.graphic.efax.php -text
getid3/module.graphic.gif.php -text
getid3/module.graphic.jpg.php -text
getid3/module.graphic.pcd.php -text
getid3/module.graphic.png.php -text
getid3/module.graphic.svg.php -text
getid3/module.graphic.tiff.php -text
getid3/module.misc.cue.php -text
getid3/module.misc.exe.php -text
getid3/module.misc.iso.php -text
getid3/module.misc.msoffice.php -text
getid3/module.misc.par2.php -text
getid3/module.misc.pdf.php -text
getid3/module.tag.apetag.php -text
getid3/module.tag.id3v1.php -text
getid3/module.tag.id3v2.php -text
getid3/module.tag.lyrics3.php -text
getid3/module.tag.xmp.php -text
getid3/write.apetag.php -text
getid3/write.id3v1.php -text
getid3/write.id3v2.php -text
getid3/write.lyrics3.php -text
getid3/write.metaflac.php -text
getid3/write.php -text
getid3/write.real.php -text
getid3/write.vorbiscomment.php -text
/getid3_administrations.php -text
/getid3_fonctions.php -text
/getid3_pipelines.php -text
images/id3v2-24.png -text
images/id3v2.png -text
inc/getid3_ecrire_infos.php -text
inc/getid3_recuperer_infos.php -text
inc/getid3_verifier_binaires.php -text
inc/recuperer_id3.php -text
lang/getid3.xml -text
lang/getid3_en.php -text
lang/getid3_es.php -text
lang/getid3_fr.php -text
lang/getid3_sk.php -text
lang/paquet-getid3.xml -text
lang/paquet-getid3_en.php -text
lang/paquet-getid3_es.php -text
lang/paquet-getid3_fr.php -text
lang/paquet-getid3_sk.php -text
metadata/audio.php -text
metadata/flv.php -text
metadata/video.php -text
notifications/getid3_verifier_binaires.html -text
notifications/getid3_verifier_binaires.php -text
/paquet.xml -text
prive/squelettes/contenu/configurer_getid3.html -text
prive/squelettes/contenu/document_id3_editer.html -text
prive/squelettes/inclure/metadatas_document_desc_action.html -text
prive/squelettes/inclure/prive_infos_media.html -text
prive/squelettes/navigation/document_id3_editer.html -text
prive/style_prive_plugin_getid3.html -text
prive/themes/spip/images/id3v2-24.png -text

@ -1,10 +1,10 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// //
// extension.cache.dbm.php - part of getID3() //
// Please see readme.txt for more information //
@ -72,8 +72,36 @@
class getID3_cached_dbm extends getID3
{
// public: constructor - see top of this file for cache type and cache_options
/**
* @var resource
*/
private $dba;
/**
* @var resource|bool
*/
private $lock;
/**
* @var string
*/
private $cache_type;
/**
* @var string
*/
private $dbm_filename;
/**
* constructor - see top of this file for cache type and cache_options
*
* @param string $cache_type
* @param string $dbm_filename
* @param string $lock_filename
*
* @throws Exception
* @throws getid3_exception
*/
public function __construct($cache_type, $dbm_filename, $lock_filename) {
// Check for dba extension
@ -141,7 +169,9 @@ class getID3_cached_dbm extends getID3
// public: destructor
/**
* destructor
*/
public function __destruct() {
// Close dbm file
@ -156,7 +186,11 @@ class getID3_cached_dbm extends getID3
// public: clear cache
/**
* clear cache
*
* @throws Exception
*/
public function clear_cache() {
// Close dbm file
@ -178,9 +212,19 @@ class getID3_cached_dbm extends getID3
// public: analyze file
public function analyze($filename) {
/**
* clear cache
*
* @param string $filename
* @param int $filesize
* @param string $original_filename
* @param resource $fp
*
* @return mixed
*/
public function analyze($filename, $filesize=null, $original_filename='', $fp=null) {
$key = null;
if (file_exists($filename)) {
// Calc key filename::mod_time::size - should be unique
@ -196,10 +240,10 @@ class getID3_cached_dbm extends getID3
}
// Miss
$result = parent::analyze($filename);
$result = parent::analyze($filename, $filesize, $original_filename, $fp);
// Save result
if (file_exists($filename)) {
if (isset($key) && file_exists($filename)) {
dba_insert($key, serialize($result), $this->dba);
}

@ -1,10 +1,10 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// //
// extension.cache.mysql.php - part of getID3() //
// Please see readme.txt for more information //
@ -73,13 +73,34 @@
class getID3_cached_mysql extends getID3
{
// private vars
/**
* @var resource
*/
private $cursor;
private $connection;
/**
* @var resource
*/
private $connection;
// public: constructor - see top of this file for cache type and cache_options
/**
* @var string
*/
private $table;
/**
* constructor - see top of this file for cache type and cache_options
*
* @param string $host
* @param string $database
* @param string $username
* @param string $password
* @param string $table
*
* @throws Exception
* @throws getid3_exception
*/
public function __construct($host, $database, $username, $password, $table='getid3_cache') {
// Check for mysql support
@ -124,7 +145,9 @@ class getID3_cached_mysql extends getID3
// public: clear cache
/**
* clear cache
*/
public function clear_cache() {
$this->cursor = mysql_query('DELETE FROM `'.mysql_real_escape_string($this->table).'`', $this->connection);
@ -133,9 +156,19 @@ class getID3_cached_mysql extends getID3
// public: analyze file
public function analyze($filename, $filesize=null, $original_filename='') {
/**
* analyze file
*
* @param string $filename
* @param int $filesize
* @param string $original_filename
* @param resource $fp
*
* @return mixed
*/
public function analyze($filename, $filesize=null, $original_filename='', $fp=null) {
$filetime = 0;
if (file_exists($filename)) {
// Short-hands
@ -157,7 +190,7 @@ class getID3_cached_mysql extends getID3
}
// Miss
$analysis = parent::analyze($filename, $filesize, $original_filename);
$analysis = parent::analyze($filename, $filesize, $original_filename, $fp);
// Save result
if (file_exists($filename)) {
@ -174,7 +207,11 @@ class getID3_cached_mysql extends getID3
// private: (re)create sql table
/**
* (re)create sql table
*
* @param bool $drop
*/
private function create_table($drop=false) {
$SQLquery = 'CREATE TABLE IF NOT EXISTS `'.mysql_real_escape_string($this->table).'` (';
@ -183,7 +220,7 @@ class getID3_cached_mysql extends getID3
$SQLquery .= ', `filetime` INT(11) NOT NULL DEFAULT \'0\'';
$SQLquery .= ', `analyzetime` INT(11) NOT NULL DEFAULT \'0\'';
$SQLquery .= ', `value` LONGTEXT NOT NULL';
$SQLquery .= ', PRIMARY KEY (`filename`, `filesize`, `filetime`)) ENGINE=MyISAM CHARACTER SET=latin1 COLLATE=latin1_general_ci';
$SQLquery .= ', PRIMARY KEY (`filename`, `filesize`, `filetime`))';
$this->cursor = mysql_query($SQLquery, $this->connection);
echo mysql_error($this->connection);
}

@ -1,14 +1,14 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// //
// extension.cache.mysqli.php - part of getID3() //
// extension.cache.mysqli.php - part of getID3() //
// Please see readme.txt for more information //
// ///
// //
/////////////////////////////////////////////////////////////////
// //
// This extension written by Allan Hansen <ahØartemis*dk> //
@ -72,12 +72,39 @@
class getID3_cached_mysqli extends getID3
{
// private vars
/**
* @var mysqli
*/
private $mysqli;
/**
* @var mysqli_result
*/
private $cursor;
/**
* @var string
*/
private $table;
// public: constructor - see top of this file for cache type and cache_options
/**
* @var bool
*/
private $db_structure_check;
/**
* constructor - see top of this file for cache type and cache_options
*
* @param string $host
* @param string $database
* @param string $username
* @param string $password
* @param string $table
*
* @throws Exception
* @throws getid3_exception
*/
public function __construct($host, $database, $username, $password, $table='getid3_cache') {
// Check for mysqli support
@ -87,8 +114,8 @@ class getID3_cached_mysqli extends getID3
// Connect to database
$this->mysqli = new mysqli($host, $username, $password);
if (!$this->mysqli) {
throw new Exception('mysqli_connect() failed - check permissions and spelling.');
if ($this->mysqli->connect_error) {
throw new Exception('Connect Error (' . $this->mysqli->connect_errno . ') ' . $this->mysqli->connect_error);
}
// Select database
@ -102,14 +129,15 @@ class getID3_cached_mysqli extends getID3
// Create cache table if not exists
$this->create_table();
$this->db_structure_check = true; // set to false if you know your table structure has already been migrated to use `hash` as the primary key to avoid
$this->migrate_db_structure();
// Check version number and clear cache if changed
$version = '';
$SQLquery = 'SELECT `value`';
$SQLquery .= ' FROM `'.$this->mysqli->real_escape_string($this->table).'`';
$SQLquery .= ' WHERE (`filename` = \''.$this->mysqli->real_escape_string(getID3::VERSION).'\')';
$SQLquery .= ' AND (`filesize` = -1)';
$SQLquery .= ' AND (`filetime` = -1)';
$SQLquery .= ' AND (`analyzetime` = -1)';
$SQLquery .= ' AND (`hash` = \'getID3::VERSION\')';
if ($this->cursor = $this->mysqli->query($SQLquery)) {
list($version) = $this->cursor->fetch_array();
}
@ -121,16 +149,59 @@ class getID3_cached_mysqli extends getID3
}
// public: clear cache
/**
* clear cache
*/
public function clear_cache() {
$this->mysqli->query('DELETE FROM `'.$this->mysqli->real_escape_string($this->table).'`');
$this->mysqli->query('INSERT INTO `'.$this->mysqli->real_escape_string($this->table).'` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES (\''.getID3::VERSION.'\', -1, -1, -1, \''.getID3::VERSION.'\')');
$this->mysqli->query('TRUNCATE TABLE `'.$this->mysqli->real_escape_string($this->table).'`');
$this->mysqli->query('INSERT INTO `'.$this->mysqli->real_escape_string($this->table).'` (`hash`, `filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES (\'getID3::VERSION\', \''.getID3::VERSION.'\', -1, -1, -1, \''.getID3::VERSION.'\')');
}
/**
* migrate database structure if needed
*/
public function migrate_db_structure() {
// Check for table structure
if ($this->db_structure_check) {
$SQLquery = 'SHOW COLUMNS';
$SQLquery .= ' FROM `'.$this->mysqli->real_escape_string($this->table).'`';
$SQLquery .= ' LIKE \'hash\'';
$this->cursor = $this->mysqli->query($SQLquery);
if ($this->cursor->num_rows == 0) {
// table has not been migrated, add column, add hashes, change index
$SQLquery = 'ALTER TABLE `getid3_cache` DROP PRIMARY KEY, ADD `hash` CHAR(32) NOT NULL DEFAULT \'\' FIRST, ADD PRIMARY KEY(`hash`)';
$this->mysqli->query($SQLquery);
$SQLquery = 'UPDATE `getid3_cache` SET';
$SQLquery .= ' `hash` = MD5(`filename`, `filesize`, `filetime`)';
$SQLquery .= ' WHERE (`filesize` > -1)';
$this->mysqli->query($SQLquery);
$SQLquery = 'UPDATE `getid3_cache` SET';
$SQLquery .= ' `hash` = \'getID3::VERSION\'';
$SQLquery .= ' WHERE (`filesize` = -1)';
$SQLquery .= ' AND (`filetime` = -1)';
$SQLquery .= ' AND (`filetime` = -1)';
$this->mysqli->query($SQLquery);
}
}
}
// public: analyze file
public function analyze($filename, $filesize=null, $original_filename='') {
/**
* analyze file
*
* @param string $filename
* @param int $filesize
* @param string $original_filename
* @param resource $fp
*
* @return mixed
*/
public function analyze($filename, $filesize=null, $original_filename='', $fp=null) {
$filetime = 0;
if (file_exists($filename)) {
// Short-hands
@ -140,9 +211,7 @@ class getID3_cached_mysqli extends getID3
// Lookup file
$SQLquery = 'SELECT `value`';
$SQLquery .= ' FROM `'.$this->mysqli->real_escape_string($this->table).'`';
$SQLquery .= ' WHERE (`filename` = \''.$this->mysqli->real_escape_string($filename).'\')';
$SQLquery .= ' AND (`filesize` = \''.$this->mysqli->real_escape_string($filesize).'\')';
$SQLquery .= ' AND (`filetime` = \''.$this->mysqli->real_escape_string($filetime).'\')';
$SQLquery .= ' WHERE (`hash` = \''.$this->mysqli->real_escape_string(md5($filename.$filesize.$filetime)).'\')';
$this->cursor = $this->mysqli->query($SQLquery);
if ($this->cursor->num_rows > 0) {
// Hit
@ -152,32 +221,43 @@ class getID3_cached_mysqli extends getID3
}
// Miss
$analysis = parent::analyze($filename, $filesize, $original_filename);
$analysis = parent::analyze($filename, $filesize, $original_filename, $fp);
// Save result
if (file_exists($filename)) {
$SQLquery = 'INSERT INTO `'.$this->mysqli->real_escape_string($this->table).'` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES (';
$SQLquery .= '\''.$this->mysqli->real_escape_string($filename).'\'';
$SQLquery = 'INSERT INTO `'.$this->mysqli->real_escape_string($this->table).'` (`hash`, `filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES (';
$SQLquery .= '\''.$this->mysqli->real_escape_string(md5($filename.$filesize.$filetime)).'\'';
$SQLquery .= ', \''.$this->mysqli->real_escape_string($filename).'\'';
$SQLquery .= ', \''.$this->mysqli->real_escape_string($filesize).'\'';
$SQLquery .= ', \''.$this->mysqli->real_escape_string($filetime).'\'';
$SQLquery .= ', \''.$this->mysqli->real_escape_string(time() ).'\'';
$SQLquery .= ', \''.$this->mysqli->real_escape_string(base64_encode(serialize($analysis))).'\')';
$SQLquery .= ', UNIX_TIMESTAMP()';
$SQLquery .= ', \''.$this->mysqli->real_escape_string(base64_encode(serialize($analysis))).'\'';
$SQLquery .= ')';
$this->cursor = $this->mysqli->query($SQLquery);
}
return $analysis;
}
// private: (re)create mysqli table
/**
* (re)create mysqli table
*
* @param bool $drop
*/
private function create_table($drop=false) {
if ($drop) {
$SQLquery = 'DROP TABLE IF EXISTS `'.$this->mysqli->real_escape_string($this->table).'`';
$this->mysqli->query($SQLquery);
}
$SQLquery = 'CREATE TABLE IF NOT EXISTS `'.$this->mysqli->real_escape_string($this->table).'` (';
$SQLquery .= '`filename` VARCHAR(990) NOT NULL DEFAULT \'\'';
$SQLquery .= '`hash` CHAR(32) NOT NULL DEFAULT \'\'';
$SQLquery .= ', `filename` VARCHAR(1000) NOT NULL DEFAULT \'\'';
$SQLquery .= ', `filesize` INT(11) NOT NULL DEFAULT \'0\'';
$SQLquery .= ', `filetime` INT(11) NOT NULL DEFAULT \'0\'';
$SQLquery .= ', `analyzetime` INT(11) NOT NULL DEFAULT \'0\'';
$SQLquery .= ', `value` LONGTEXT NOT NULL';
$SQLquery .= ', PRIMARY KEY (`filename`, `filesize`, `filetime`)) ENGINE=MyISAM CHARACTER SET=latin1 COLLATE=latin1_general_ci';
$SQLquery .= ', PRIMARY KEY (`hash`))';
$this->cursor = $this->mysqli->query($SQLquery);
echo $this->mysqli->error;
}
}
}

@ -1,21 +1,27 @@
<?php
/////////////////////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////////////////////
/// //
// extension.cache.sqlite3.php - part of getID3() //
// Please see readme.txt for more information //
// ///
/////////////////////////////////////////////////////////////////////////////////
/// //
// MySQL extension written by Allan Hansen <ahØartemis*dk> //
// Table name mod by Carlo Capocasa <calroØcarlocapocasa*com> //
// MySQL extension was reworked for SQLite3 by Karl G. Holz <newaeonØmac*com> //
// ///
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// //
// extension.cache.mysqli.php - part of getID3() //
// Please see readme.txt for more information //
// //
/////////////////////////////////////////////////////////////////
// //
// extension.cache.sqlite3.php - part of getID3() //
// Please see readme.txt for more information //
// //
/////////////////////////////////////////////////////////////////
/// //
// MySQL extension written by Allan Hansen <ahØartemis*dk> //
// Table name mod by Carlo Capocasa <calroØcarlocapocasa*com> //
// MySQL extension was reworked for SQLite3 by //
// Karl G. Holz <newaeonØmac*com> //
// ///
/////////////////////////////////////////////////////////////////
/**
* This is a caching extension for getID3(). It works the exact same
* way as the getID3 class, but return cached information much faster
@ -89,14 +95,35 @@
*
*
*/
class getID3_cached_sqlite3 extends getID3 {
class getID3_cached_sqlite3 extends getID3
{
/**
* hold the sqlite db
*
* @var SQLite3 Resource
*/
private $db;
/**
* __construct()
* @param string $table holds name of sqlite table
* @return type
*/
* table to use for caching
*
* @var string $table
*/
private $table;
/**
* @param string $table holds name of sqlite table
* @param boolean $hide
*
* @throws getid3_exception
* @throws Exception
*/
public function __construct($table='getid3_cache', $hide=false) {
// Check for SQLite3 support
if (!function_exists('sqlite_open')) {
throw new Exception('PHP not compiled with SQLite3 support.');
}
$this->table = $table; // Set table
$file = dirname(__FILE__).'/'.basename(__FILE__, 'php').'sqlite';
if ($hide) {
@ -106,7 +133,7 @@ class getID3_cached_sqlite3 extends getID3 {
$db = $this->db;
$this->create_table(); // Create cache table if not exists
$version = '';
$sql = $this->version_check;
$sql = $this->getQuery('version_check');
$stmt = $db->prepare($sql);
$stmt->bindValue(':filename', getID3::VERSION, SQLITE3_TEXT);
$result = $stmt->execute();
@ -114,39 +141,27 @@ class getID3_cached_sqlite3 extends getID3 {
if ($version != getID3::VERSION) { // Check version number and clear cache if changed
$this->clear_cache();
}
return parent::__construct();
parent::__construct();
}
/**
* close the database connection
*/
* close the database connection
*/
public function __destruct() {
$db=$this->db;
$db->close();
}
/**
* hold the sqlite db
* @var SQLite Resource
*/
private $db;
/**
* table to use for caching
* @var string $table
*/
private $table;
/**
* clear the cache
* @access private
* @return type
*/
* clear the cache
*
* @return SQLite3Result
*/
private function clear_cache() {
$db = $this->db;
$sql = $this->delete_cache;
$sql = $this->getQuery('delete_cache');
$db->exec($sql);
$sql = $this->set_version;
$sql = $this->getQuery('set_version');
$stmt = $db->prepare($sql);
$stmt->bindValue(':filename', getID3::VERSION, SQLITE3_TEXT);
$stmt->bindValue(':dirname', getID3::VERSION, SQLITE3_TEXT);
@ -155,11 +170,16 @@ class getID3_cached_sqlite3 extends getID3 {
}
/**
* analyze file and cache them, if cached pull from the db
* @param type $filename
* @return boolean
*/
public function analyze($filename, $filesize=null, $original_filename='') {
* analyze file and cache them, if cached pull from the db
*
* @param string $filename
* @param integer $filesize
* @param string $original_filename
* @param resource $fp
*
* @return mixed|false
*/
public function analyze($filename, $filesize=null, $original_filename='', $fp=null) {
if (!file_exists($filename)) {
return false;
}
@ -171,7 +191,7 @@ class getID3_cached_sqlite3 extends getID3 {
$dirname = dirname($filename);
// Lookup file
$db = $this->db;
$sql = $this->get_id3_data;
$sql = $this->getQuery('get_id3_data');
$stmt = $db->prepare($sql);
$stmt->bindValue(':filename', $filename, SQLITE3_TEXT);
$stmt->bindValue(':filesize', $filesize_real, SQLITE3_INTEGER);
@ -182,9 +202,9 @@ class getID3_cached_sqlite3 extends getID3 {
return unserialize(base64_decode($result));
}
// if it hasn't been analyzed before, then do it now
$analysis = parent::analyze($filename, $filesize, $original_filename);
$analysis = parent::analyze($filename, $filesize, $original_filename, $fp);
// Save result
$sql = $this->cache_file;
$sql = $this->getQuery('cache_file');
$stmt = $db->prepare($sql);
$stmt->bindValue(':filename', $filename, SQLITE3_TEXT);
$stmt->bindValue(':dirname', $dirname, SQLITE3_TEXT);
@ -197,30 +217,31 @@ class getID3_cached_sqlite3 extends getID3 {
}
/**
* create data base table
* this is almost the same as MySQL, with the exception of the dirname being added
* @return type
*/
* create data base table
* this is almost the same as MySQL, with the exception of the dirname being added
*
* @return bool
*/
private function create_table() {
$db = $this->db;
$sql = $this->make_table;
$sql = $this->getQuery('make_table');
return $db->exec($sql);
}
/**
* get cached directory
*
* This function is not in the MySQL extention, it's ment to speed up requesting multiple files
* which is ideal for podcasting, playlists, etc.
*
* @access public
* @param string $dir directory to search the cache database for
* @return array return an array of matching id3 data
*/
* get cached directory
*
* This function is not in the MySQL extention, it's ment to speed up requesting multiple files
* which is ideal for podcasting, playlists, etc.
*
* @param string $dir directory to search the cache database for
*
* @return array return an array of matching id3 data
*/
public function get_cached_dir($dir) {
$db = $this->db;
$rows = array();
$sql = $this->get_cached_dir;
$sql = $this->getQuery('get_cached_dir');
$stmt = $db->prepare($sql);
$stmt->bindValue(':dirname', $dir, SQLITE3_TEXT);
$res = $stmt->execute();
@ -231,36 +252,46 @@ class getID3_cached_sqlite3 extends getID3 {
}
/**
* use the magical __get() for sql queries
*
* access as easy as $this->{case name}, returns NULL if query is not found
*/
public function __get($name) {
switch($name) {
* returns NULL if query is not found
*
* @param string $name
*
* @return null|string
*/
public function getQuery($name)
{
switch ($name) {
case 'version_check':
return "SELECT val FROM $this->table WHERE filename = :filename AND filesize = '-1' AND filetime = '-1' AND analyzetime = '-1'";
break;
case 'delete_cache':
return "DELETE FROM $this->table";
break;
case 'set_version':
return "INSERT INTO $this->table (filename, dirname, filesize, filetime, analyzetime, val) VALUES (:filename, :dirname, -1, -1, -1, :val)";
break;
case 'get_id3_data':
return "SELECT val FROM $this->table WHERE filename = :filename AND filesize = :filesize AND filetime = :filetime";
break;
case 'cache_file':
return "INSERT INTO $this->table (filename, dirname, filesize, filetime, analyzetime, val) VALUES (:filename, :dirname, :filesize, :filetime, :atime, :val)";
break;
case 'make_table':
//return "CREATE TABLE IF NOT EXISTS $this->table (filename VARCHAR(255) NOT NULL DEFAULT '', dirname VARCHAR(255) NOT NULL DEFAULT '', filesize INT(11) NOT NULL DEFAULT '0', filetime INT(11) NOT NULL DEFAULT '0', analyzetime INT(11) NOT NULL DEFAULT '0', val text not null, PRIMARY KEY (filename, filesize, filetime))";
return "CREATE TABLE IF NOT EXISTS $this->table (filename VARCHAR(255) DEFAULT '', dirname VARCHAR(255) DEFAULT '', filesize INT(11) DEFAULT '0', filetime INT(11) DEFAULT '0', analyzetime INT(11) DEFAULT '0', val text, PRIMARY KEY (filename, filesize, filetime))";
break;
case 'get_cached_dir':
return "SELECT val FROM $this->table WHERE dirname = :dirname";
break;
default:
return null;
}
return null;
}
/**
* use the magical __get() for sql queries
*
* access as easy as $this->{case name}, returns NULL if query is not found
*
* @param string $name
*
* @return string
* @deprecated use getQuery() instead
*/
public function __get($name) {
return $this->getQuery($name);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,11 +1,11 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// see readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.gzip.php //
@ -19,12 +19,23 @@
// //
/////////////////////////////////////////////////////////////////
if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
exit;
}
class getid3_gzip extends getid3_handler {
// public: Optional file list - disable for speed.
public $option_gzip_parse_contents = false; // decode gzipped files, if possible, and parse recursively (.tar.gz for example)
class getid3_gzip extends getid3_handler
{
/**
* Optional file list - disable for speed.
* Decode gzipped files, if possible, and parse recursively (.tar.gz for example).
*
* @var bool
*/
public $parse_contents = false;
/**
* @return bool
*/
public function Analyze() {
$info = &$this->getid3->info;
@ -44,9 +55,10 @@ class getid3_gzip extends getid3_handler {
$buffer = $this->fread($info['filesize']);
$arr_members = explode("\x1F\x8B\x08", $buffer);
$num_members = 0;
while (true) {
$is_wrong_members = false;
$num_members = intval(count($arr_members));
$num_members = count($arr_members);
for ($i = 0; $i < $num_members; $i++) {
if (strlen($arr_members[$i]) == 0) {
continue;
@ -71,13 +83,13 @@ class getid3_gzip extends getid3_handler {
$fpointer = 0;
$idx = 0;
for ($i = 0; $i < $num_members; $i++) {
if (strlen($arr_members[$i]) == 0) {
foreach ($arr_members as $member) {
if (strlen($member) == 0) {
continue;
}
$thisInfo = &$info['gzip']['member_header'][++$idx];
$buff = "\x1F\x8B\x08".$arr_members[$i];
$buff = "\x1F\x8B\x08". $member;
$attr = unpack($unpack_header, substr($buff, 0, $start_length));
$thisInfo['filemtime'] = getid3_lib::LittleEndian2Int($attr['mtime']);
@ -187,7 +199,7 @@ class getid3_gzip extends getid3_handler {
$info['gzip']['files'] = getid3_lib::array_merge_clobber($info['gzip']['files'], getid3_lib::CreateDeepArray($thisInfo['filename'], '/', $thisInfo['filesize']));
if ($this->option_gzip_parse_contents) {
if ($this->parse_contents) {
// Try to inflate GZip
$csize = 0;
$inflated = '';
@ -199,7 +211,7 @@ class getid3_gzip extends getid3_handler {
$inflated = gzinflate($cdata);
// Calculate CRC32 for inflated content
$thisInfo['crc32_valid'] = (bool) (sprintf('%u', crc32($inflated)) == $thisInfo['crc32']);
$thisInfo['crc32_valid'] = sprintf('%u', crc32($inflated)) == $thisInfo['crc32'];
// determine format
$formattest = substr($inflated, 0, 32774);
@ -240,13 +252,21 @@ class getid3_gzip extends getid3_handler {
// unknown or unhandled format
break;
}
} else {
$this->warning('PHP is not compiled with gzinflate() support. Please enable PHP Zlib extension or recompile with the --with-zlib switch');
}
}
}
return true;
}
// Converts the OS type
/**
* Converts the OS type.
*
* @param string $key
*
* @return string
*/
public function get_os_type($key) {
static $os_type = array(
'0' => 'FAT filesystem (MS-DOS, OS/2, NT/Win32)',
@ -268,7 +288,13 @@ class getid3_gzip extends getid3_handler {
return (isset($os_type[$key]) ? $os_type[$key] : '');
}
// Converts the eXtra FLags
/**
* Converts the eXtra FLags.
*
* @param string $key
*
* @return string
*/
public function get_xflag_type($key) {
static $xflag_type = array(
'0' => 'unknown',

@ -0,0 +1,92 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// see readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.hpk.php //
// module for analyzing HPK files //
// dependencies: NONE //
// ///
/////////////////////////////////////////////////////////////////
if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
exit;
}
class getid3_hpk extends getid3_handler
{
/**
* @return bool
*/
public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'hpk';
$this->fseek($info['avdataoffset']);
$HPKheader = $this->fread(36);
if (substr($HPKheader, 0, 4) == 'BPUL') {
$info['hpk']['header']['signature'] = substr($HPKheader, 0, 4);
$info['hpk']['header']['data_offset'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 4, 4));
$info['hpk']['header']['fragments_per_file'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 8, 4));
//$info['hpk']['header']['unknown1'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 12, 4));
$info['hpk']['header']['fragments_residual_offset'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 16, 4));
$info['hpk']['header']['fragments_residual_count'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 20, 4));
//$info['hpk']['header']['unknown2'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 24, 4));
$info['hpk']['header']['fragmented_filesystem_offset'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 28, 4));
$info['hpk']['header']['fragmented_filesystem_length'] = getid3_lib::LittleEndian2Int(substr($HPKheader, 32, 4));
$info['hpk']['header']['filesystem_entries'] = $info['hpk']['header']['fragmented_filesystem_length'] / ($info['hpk']['header']['fragments_per_file'] * 8);
$this->fseek($info['hpk']['header']['fragmented_filesystem_offset']);
for ($i = 0; $i < $info['hpk']['header']['filesystem_entries']; $i++) {
$offset = getid3_lib::LittleEndian2Int($this->fread(4));
$length = getid3_lib::LittleEndian2Int($this->fread(4));
$info['hpk']['filesystem'][$i] = array('offset' => $offset, 'length' => $length);
}
$this->error('HPK parsing incomplete (and mostly broken) in this version of getID3() ['.$this->getid3->version().']');
/*
$filename = '';
$dirs = array();
foreach ($info['hpk']['filesystem'] as $key => $filesystemdata) {
$this->fseek($filesystemdata['offset']);
$first4 = $this->fread(4);
if (($first4 == 'LZ4 ') || ($first4 == 'ZLIB')) {
// actual data, ignore
$info['hpk']['toc'][$key] = array(
'filename' => ltrim(implode('/', $dirs).'/'.$filename, '/'),
'offset' => $filesystemdata['offset'],
'length' => $filesystemdata['length'],
);
$filename = '';
$dirs = array();
} else {
$fragment_index = getid3_lib::LittleEndian2Int($first4);
$fragment_type = getid3_lib::LittleEndian2Int($this->fread(4)); // file = 0, directory = 1
$name_length = getid3_lib::LittleEndian2Int($this->fread(2));
if ($fragment_type == 1) {
$dirs[] = $this->fread($name_length);
} else {
$filename = $this->fread($name_length);
}
}
}
*/
} else {
$this->error('Expecting "BPUL" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($HPKheader, 0, 4)).'"');
return false;
}
return true;
}
}

@ -1,11 +1,11 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// see readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.rar.php //
@ -14,18 +14,28 @@
// ///
/////////////////////////////////////////////////////////////////
if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
exit;
}
class getid3_rar extends getid3_handler
{
public $option_use_rar_extension = false;
/**
* if true use PHP RarArchive extension, if false (non-extension parsing not yet written in getID3)
*
* @var bool
*/
public $use_php_rar_extension = true;
/**
* @return bool
*/
public function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'rar';
if ($this->option_use_rar_extension === true) {
if ($this->use_php_rar_extension === true) {
if (function_exists('rar_open')) {
if ($rp = rar_open($info['filenamepath'])) {
$info['rar']['files'] = array();
@ -42,7 +52,7 @@ class getid3_rar extends getid3_handler
$this->error('RAR support does not appear to be available in this PHP installation');
}
} else {
$this->error('PHP-RAR processing has been disabled (set $getid3_rar->option_use_rar_extension=true to enable)');
$this->error('PHP-RAR processing has been disabled (set $getid3_rar->use_php_rar_extension=true to enable)');
}
return false;

@ -1,11 +1,11 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// see readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.szip.php //
@ -14,10 +14,15 @@
// ///
/////////////////////////////////////////////////////////////////
if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
exit;
}
class getid3_szip extends getid3_handler
{
/**
* @return bool
*/
public function Analyze() {
$info = &$this->getid3->info;
@ -30,8 +35,8 @@ class getid3_szip extends getid3_handler
$info['fileformat'] = 'szip';
$info['szip']['major_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 4, 1));
$info['szip']['minor_version'] = getid3_lib::BigEndian2Int(substr($SZIPHeader, 5, 1));
$this->error('SZIP parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
return false;
$this->error('SZIP parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
return false;
while (!$this->feof()) {
$NextBlockID = $this->fread(2);

@ -1,11 +1,11 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// see readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.tar.php //
@ -19,10 +19,15 @@
// //
/////////////////////////////////////////////////////////////////
if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
exit;
}
class getid3_tar extends getid3_handler
{
/**
* @return bool
*/
public function Analyze() {
$info = &$this->getid3->info;
@ -42,13 +47,13 @@ class getid3_tar extends getid3_handler
// check the block
$checksum = 0;
for ($i = 0; $i < 148; $i++) {
$checksum += ord($buffer{$i});
$checksum += ord($buffer[$i]);
}
for ($i = 148; $i < 156; $i++) {
$checksum += ord(' ');
}
for ($i = 156; $i < 512; $i++) {
$checksum += ord($buffer{$i});
$checksum += ord($buffer[$i]);
}
$attr = unpack($unpack_header, $buffer);
$name = (isset($attr['fname'] ) ? trim($attr['fname'] ) : '');
@ -117,7 +122,13 @@ class getid3_tar extends getid3_handler
return true;
}
// Parses the file mode to file permissions
/**
* Parses the file mode to file permissions.
*
* @param int $mode
*
* @return string
*/
public function display_perms($mode) {
// Determine Type
if ($mode & 0x1000) $type='p'; // FIFO pipe
@ -130,6 +141,9 @@ class getid3_tar extends getid3_handler
else $type='u'; // UNKNOWN
// Determine permissions
$owner = array();
$group = array();
$world = array();
$owner['read'] = (($mode & 00400) ? 'r' : '-');
$owner['write'] = (($mode & 00200) ? 'w' : '-');
$owner['execute'] = (($mode & 00100) ? 'x' : '-');
@ -152,7 +166,13 @@ class getid3_tar extends getid3_handler
return $s;
}
// Converts the file type
/**
* Converts the file type.
*
* @param string $typflag
*
* @return mixed|string
*/
public function get_flag_type($typflag) {
static $flag_types = array(
'0' => 'LF_NORMAL',

@ -0,0 +1,44 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// see readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.xz.php //
// module for analyzing XZ files //
// dependencies: NONE //
// ///
/////////////////////////////////////////////////////////////////
if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
exit;
}
class getid3_xz extends getid3_handler
{
/**
* @return bool
*/
public function Analyze() {
$info = &$this->getid3->info;
$this->fseek($info['avdataoffset']);
$xzheader = $this->fread(6);
// https://tukaani.org/xz/xz-file-format-1.0.4.txt
$info['xz']['stream_header']['magic'] = substr($xzheader, 0, 6);
if ($info['xz']['stream_header']['magic'] != "\xFD".'7zXZ'."\x00") {
$this->error('Invalid XZ stream header magic (expecting FD 37 7A 58 5A 00, found '.getid3_lib::PrintHexBytes($info['xz']['stream_header']['magic']).') at offset '.$info['avdataoffset']);
return false;
}
$info['fileformat'] = 'xz';
$this->error('XZ parsing not enabled in this version of getID3() ['.$this->getid3->version().']');
return false;
}
}

@ -1,11 +1,11 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// see readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.zip.php //
@ -14,10 +14,15 @@
// ///
/////////////////////////////////////////////////////////////////
if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
exit;
}
class getid3_zip extends getid3_handler
{
/**
* @return bool
*/
public function Analyze() {
$info = &$this->getid3->info;
@ -48,7 +53,7 @@ class getid3_zip extends getid3_handler
$this->fseek($info['zip']['end_central_directory']['directory_offset']);
$info['zip']['entries_count'] = 0;
while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($this->getid3->fp)) {
while ($centraldirectoryentry = $this->ZIPparseCentralDirectory()) {
$info['zip']['central_directory'][] = $centraldirectoryentry;
$info['zip']['entries_count']++;
$info['zip']['compressed_size'] += $centraldirectoryentry['compressed_size'];
@ -90,19 +95,39 @@ class getid3_zip extends getid3_handler
}
}
// check for EPUB files
if (!empty($info['zip']['entries'][0]['filename']) &&
($info['zip']['entries'][0]['filename'] == 'mimetype') &&
($info['zip']['entries'][0]['compression_method'] == 'store') &&
($info['zip']['entries'][0]['uncompressed_size'] == 20) &&
isset($info['zip']['entries'][0]['data_offset'])) {
// http://idpf.org/epub/30/spec/epub30-ocf.html
// "3.3 OCF ZIP Container Media Type Identification
// OCF ZIP Containers must include a mimetype file as the first file in the Container, and the contents of this file must be the MIME type string application/epub+zip.
// The contents of the mimetype file must not contain any leading padding or whitespace, must not begin with the Unicode signature (or Byte Order Mark),
// and the case of the MIME type string must be exactly as presented above. The mimetype file additionally must be neither compressed nor encrypted,
// and there must not be an extra field in its ZIP header."
$this->fseek($info['zip']['entries'][0]['data_offset']);
if ($this->fread(20) == 'application/epub+zip') {
$info['fileformat'] = 'zip.epub';
$info['mime_type'] = 'application/epub+zip';
}
}
// check for Office Open XML files (e.g. .docx, .xlsx)
if (!empty($info['zip']['files']['[Content_Types].xml']) &&
!empty($info['zip']['files']['_rels']['.rels']) &&
!empty($info['zip']['files']['docProps']['app.xml']) &&
!empty($info['zip']['files']['docProps']['core.xml'])) {
// http://technet.microsoft.com/en-us/library/cc179224.aspx
$info['fileformat'] = 'zip.msoffice';
if (!empty($ThisFileInfo['zip']['files']['ppt'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
} elseif (!empty($ThisFileInfo['zip']['files']['xl'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
} elseif (!empty($ThisFileInfo['zip']['files']['word'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
}
// http://technet.microsoft.com/en-us/library/cc179224.aspx
$info['fileformat'] = 'zip.msoffice';
if (!empty($info['zip']['files']['ppt'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
} elseif (!empty($info['zip']['files']['xl'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
} elseif (!empty($info['zip']['files']['word'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
}
}
return true;
@ -129,7 +154,9 @@ class getid3_zip extends getid3_handler
return true;
}
/**
* @return bool
*/
public function getZIPHeaderFilepointerTopDown() {
$info = &$this->getid3->info;
@ -150,7 +177,7 @@ class getid3_zip extends getid3_handler
}
$info['zip']['entries_count'] = 0;
while ($centraldirectoryentry = $this->ZIPparseCentralDirectory($this->getid3->fp)) {
while ($centraldirectoryentry = $this->ZIPparseCentralDirectory()) {
$info['zip']['central_directory'][] = $centraldirectoryentry;
$info['zip']['entries_count']++;
$info['zip']['compressed_size'] += $centraldirectoryentry['compressed_size'];
@ -175,7 +202,9 @@ class getid3_zip extends getid3_handler
return true;
}
/**
* @return bool
*/
public function getZIPentriesFilepointer() {
$info = &$this->getid3->info;
@ -198,8 +227,11 @@ class getid3_zip extends getid3_handler
return true;
}
/**
* @return array|false
*/
public function ZIPparseLocalFileHeader() {
$LocalFileHeader = array();
$LocalFileHeader['offset'] = $this->ftell();
$ZIPlocalFileHeader = $this->fread(30);
@ -265,7 +297,7 @@ class getid3_zip extends getid3_handler
$DataDescriptor = $this->fread(16);
$LocalFileHeader['data_descriptor']['signature'] = getid3_lib::LittleEndian2Int(substr($DataDescriptor, 0, 4));
if ($LocalFileHeader['data_descriptor']['signature'] != 0x08074B50) { // "PK\x07\x08"
$this->getid3->warning[] = 'invalid Local File Header Data Descriptor Signature at offset '.($this->ftell() - 16).' - expecting 08 07 4B 50, found '.getid3_lib::PrintHexBytes($LocalFileHeader['data_descriptor']['signature']);
$this->getid3->warning('invalid Local File Header Data Descriptor Signature at offset '.($this->ftell() - 16).' - expecting 08 07 4B 50, found '.getid3_lib::PrintHexBytes($LocalFileHeader['data_descriptor']['signature']));
$this->fseek($LocalFileHeader['offset']); // seek back to where filepointer originally was so it can be handled properly
return false;
}
@ -294,8 +326,11 @@ class getid3_zip extends getid3_handler
return $LocalFileHeader;
}
/**
* @return array|false
*/
public function ZIPparseCentralDirectory() {
$CentralDirectory = array();
$CentralDirectory['offset'] = $this->ftell();
$ZIPcentralDirectory = $this->fread(46);
@ -351,7 +386,11 @@ class getid3_zip extends getid3_handler
return $CentralDirectory;
}
/**
* @return array|false
*/
public function ZIPparseEndOfCentralDirectory() {
$EndOfCentralDirectory = array();
$EndOfCentralDirectory['offset'] = $this->ftell();
$ZIPendOfCentralDirectory = $this->fread(22);
@ -377,9 +416,15 @@ class getid3_zip extends getid3_handler
return $EndOfCentralDirectory;
}
/**
* @param int $flagbytes
* @param int $compressionmethod
*
* @return array
*/
public static function ZIPparseGeneralPurposeFlags($flagbytes, $compressionmethod) {
// https://users.cs.jmu.edu/buchhofp/forensics/formats/pkzip-printable.html
$ParsedFlags = array();
$ParsedFlags['encrypted'] = (bool) ($flagbytes & 0x0001);
// 0x0002 -- see below
// 0x0004 -- see below
@ -425,7 +470,11 @@ class getid3_zip extends getid3_handler
return $ParsedFlags;
}
/**
* @param int $index
*
* @return string
*/
public static function ZIPversionOSLookup($index) {
static $ZIPversionOSLookup = array(
0 => 'MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)',
@ -453,6 +502,11 @@ class getid3_zip extends getid3_handler
return (isset($ZIPversionOSLookup[$index]) ? $ZIPversionOSLookup[$index] : '[unknown]');
}
/**
* @param int $index
*
* @return string
*/
public static function ZIPcompressionMethodLookup($index) {
// http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/ZIP.html
static $ZIPcompressionMethodLookup = array(
@ -484,6 +538,12 @@ class getid3_zip extends getid3_handler
return (isset($ZIPcompressionMethodLookup[$index]) ? $ZIPcompressionMethodLookup[$index] : '[unknown]');
}
/**
* @param int $DOSdate
* @param int $DOStime
*
* @return int
*/
public static function DOStime2UNIXtime($DOSdate, $DOStime) {
// wFatDate
// Specifies the MS-DOS date. The date is a packed 16-bit value with the following format:

@ -1,11 +1,10 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
// also https://github.com/JamesHeinrich/getID3 //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
// available at https://github.com/JamesHeinrich/getID3 //
// or https://www.getid3.org //
// or http://getid3.sourceforge.net //
// see readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.audio-video.asf.php //
@ -14,10 +13,16 @@
// ///
/////////////////////////////////////////////////////////////////
if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
exit;
}
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
class getid3_asf extends getid3_handler {
class getid3_asf extends getid3_handler
{
/**
* @param getID3 $getid3
*/
public function __construct(getID3 $getid3) {
parent::__construct($getid3); // extends getid3_handler::__construct()