v1
kent1@arscenic.info 12 years ago
commit 971fb2695c

103
.gitattributes vendored

@ -0,0 +1,103 @@
* 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
base/getid3_upgrade.php -text
exec/getid3_infos.php -text
fonds/cfg_getid3.html -text
formulaires/config_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/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.aa.php -text
getid3/module.audio.aac.php -text
getid3/module.audio.ac3.php -text
getid3/module.audio.au.php -text
getid3/module.audio.avr.php -text
getid3/module.audio.bonk.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.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_fonctions.php -text
/getid3_options.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/infos_son.php -text
inc/recuperer_id3.php -text
lang/getid3.xml -text
lang/getid3_en.php -text
lang/getid3_fr.php -text
modeles/doc_player_getid3.html -text
notifications/getid3_verifier_binaires.html -text
notifications/getid3_verifier_binaires.php -text
/plugin.xml -text
prive/exec/document_id3_editer.html -text
prive/exec/document_id3_editer_fonctions.php -text
prive/prive_infos_son.html -text
prive/style_prive_plugin_getid3.html -text
/test_id3.html -text

@ -0,0 +1,61 @@
<?php
/**
* GetID3
* Gestion des métadonnées de fichiers sonores directement dans SPIP
*
* Auteurs :
* Quentin Drouet (kent1), BoOz
* 2008-2010 - Distribué sous licence GNU/GPL
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
function action_getid3_appliquer_cover_defaut(){
if(!autoriser('webmestre'))
return false;
if(!strlen($cover_defaut = lire_config('getid3/cover_defaut','')) > 1)
return false;
$id_document = _request('arg');
$nb_modifs = 0;
if(is_numeric($id_document)){
if(sql_getfetsel('id_vignette','spip_documents','id_document='.intval($id_document)) == 0)
$documents_modifs[] = $id_document;
}else{
$sons = array('mp3');
$documents = sql_select('id_document','spip_documents','id_vignette=0 AND '.sql_in('extension', $sons));
while($document = sql_fetch($documents)){
$documents_modifs[] = $document['id_document'];
}
}
if(count($documents_modifs) > 0){
include_spip('inc/documents');
include_spip('inc/distant');
$cover_defaut = find_in_path(copie_locale($cover_defaut));
$ajouter_documents = charger_fonction('ajouter_documents', 'inc');
list($extension,$arg) = fixer_extension_document($cover_defaut);
foreach($documents_modifs as $document_modif){
$x = $ajouter_documents($cover_defaut, $cover_defaut,
$type, $id, 'vignette', $document_modif, $actifs);
if(is_numeric($x) && ($x > 0))
$nb_modifs++;
}
}
if($redirect = _request('redirect')){
$redirect = parametre_url(urldecode($redirect),
'modifs', $nb_modifs, '&');
include_spip('inc/headers');
redirige_par_entete($redirect);
}else
return $nb_modifs;
}
?>

@ -0,0 +1,45 @@
<?php
/**
* GetID3
* Gestion des métadonnées de fichiers sonores directement dans SPIP
*
* Auteurs :
* Quentin Drouet (kent1), BoOz
* 2008-2010 - Distribué sous licence GNU/GPL
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/charsets'); # pour le nom de fichier
include_spip('inc/actions');
function action_getid3_infos_dist(){
global $redirect;
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
if (!preg_match(",^(-?)(\d+)\W(\w+)\W?(\d*)\W?(\d*)$,", $arg, $r)){
spip_log("action_getid3_infos_dist incompris: " . $arg);
$redirect = urldecode(_request('redirect'));
return;
}
else{
action_getid3_infos_post($r);
}
}
function action_getid3_infos_post($r){
list($arg, $sign, $id_objet, $objet, $id_document, $suite) = $r;
$recuperer_infos = charger_fonction('getid3_recuperer_infos','inc');
$infos = $recuperer_infos($id_document);
if(_request("iframe") == 'iframe') {
$redirect = parametre_url(urldecode($iframe_redirect),"show_video_infos",join(',',$documents_actifs),'&')."&iframe=iframe";
}
return $redirect;
}
?>

@ -0,0 +1,36 @@
<?php
/**
* GetID3
* Gestion des métadonnées de fichiers sonores directement dans SPIP
*
* Auteurs :
* Quentin Drouet (kent1), BoOz
* 2008-2010 - Distribué sous licence GNU/GPL
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/actions');
/**
* Action de vérification des binaires
*/
function action_getid3_verifier_binaires_dist(){
global $visiteur_session;
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
include_spip('inc/autoriser');
if(autoriser('configurer','',$visiteur_session)){
$verifier_binaires = charger_fonction('getid3_verifier_binaires','inc');
$verifier_binaires(true);
}
if(_request('redirect')){
$redirect = str_replace('&amp;','&',urldecode(_request('redirect')));
redirige_par_entete($redirect);
}
}
?>

@ -0,0 +1,29 @@
<?php
/**
* GetID3
* Gestion des métadonnées de fichiers sonores directement dans SPIP
*
* Auteurs :
* Quentin Drouet (kent1), BoOz
* 2008-2010 - Distribué sous licence GNU/GPL
*
* Définition des tables
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
function getid3_declarer_tables_principales($tables_principales){
$tables_principales['spip_documents']['field']['duree'] = "VARCHAR(255) DEFAULT '' NOT NULL";
$tables_principales['spip_documents']['field']['bitrate'] = "INTEGER NOT NULL";
$tables_principales['spip_documents']['field']['bitrate_mode'] = "text DEFAULT '' NOT NULL";
$tables_principales['spip_documents']['field']['audiosamplerate'] = "INTEGER NOT NULL";
$tables_principales['spip_documents']['field']['encodeur'] = "text DEFAULT '' NOT NULL";
$tables_principales['spip_documents']['field']['bits'] = "INTEGER NOT NULL";
$tables_principales['spip_documents']['field']['canaux'] = "text DEFAULT '' NOT NULL";
return $tables_principales;
}
?>

@ -0,0 +1,111 @@
<?php
/**
* GetID3
* Gestion des métadonnées de fichiers sonores directement dans SPIP
*
* Auteurs :
* Quentin Drouet (kent1), BoOz
* 2008-2010 - Distribué sous licence GNU/GPL
*
* Définition des tables
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/meta');
function getid3_upgrade($nom_meta_base_version,$version_cible){
$current_version = 0.0;
if ( (!isset($GLOBALS['meta'][$nom_meta_base_version]) )
|| (($current_version = $GLOBALS['meta'][$nom_meta_base_version])!=$version_cible)){
if (version_compare($current_version,'0.0','<=')){
include_spip('base/create');
maj_tables('spip_documents');
$getid3_binaires = charger_fonction('getid3_verifier_binaires','inc');
$getid3_binaires(true);
ecrire_meta($nom_meta_base_version,$current_version=$version_cible,'non');
echo '<p>'._T('getid3:install_ajout_champs_documents').'</p>';
}
if (version_compare($current_version,'0.1','<')){
include_spip('base/create');
maj_tables('spip_documents');
ecrire_meta($nom_meta_base_version,$current_version=0.1);
echo _T('getid3:install_mise_a_jour_base',array('version'=>'0.1'));
}
if (version_compare($current_version,'0.2','<')){
include_spip('base/create');
maj_tables('spip_documents');
ecrire_meta($nom_meta_base_version,$current_version=0.2);
echo _T('getid3:install_mise_a_jour_base',array('version'=>'0.2'));
}
if (version_compare($current_version,'0.3','<')){
global $tables_images, $tables_sequences, $tables_documents, $tables_mime;
$tables_mime['3ga'] = 'audio/3ga';
$tables_mime['aac'] = 'audio/x-aac';
$tables_mime['ac3'] = 'audio/x-aac';
$tables_mime['aifc'] = 'audio/x-aifc';
$tables_mime['amr'] = 'audio/amr';
$tables_mime['ape'] = 'audio/x-monkeys-audio';
$tables_mime['m4r'] = 'audio/aac';
$tables_mime['wma'] = 'audio/x-ms-wma';
$tables_sequences['3ga'] = '3GP Audio File';
$tables_sequences['aac'] = 'Advanced Audio Coding';
$tables_sequences['ac3'] = 'AC-3 Compressed Audio';
$tables_sequences['aifc'] = 'Compressed AIFF Audio';
$tables_sequences['amr'] = 'Adaptive Multi-Rate Audio';
$tables_sequences['ape'] = 'Monkey\'s Audio File';
$tables_sequences['m4r'] = 'iPhone Ringtone';
$tables_sequences['wma'] = 'Windows Media Audio';
// Init ou Re-init ==> replace pas insert
$freplace = sql_serveur('replace', $serveur);
spip_log($tables_mime,'id3');
foreach ($tables_mime as $extension => $type_mime) {
if (isset($tables_images[$extension])) {
$titre = $tables_images[$extension];
$inclus='image';
}
else if (isset($tables_sequences[$extension])) {
$titre = $tables_sequences[$extension];
$inclus='embed';
}
else {
$inclus='non';
if (isset($tables_documents[$extension]))
$titre = $tables_documents[$extension];
else
$titre = '';
}
$freplace('spip_types_documents',
array('mime_type' => $type_mime,
'titre' => $titre,
'inclus' => $inclus,
'extension' => $extension,
'upload' => 'oui'
),
'', $serveur);
}
ecrire_meta($nom_meta_base_version,$current_version=0.3);
echo _T('getid3:install_mise_a_jour_base',array('version'=>'0.3'));
}
if (version_compare($current_version,'0.3.1','<')){
/**
* Vérifier si les logiciels sont présents
*/
$getid3_binaires = charger_fonction('getid3_verifier_binaires','inc');
$getid3_binaires(true);
ecrire_meta($nom_meta_base_version,$current_version='0.3.1');
}
}
}
function getid3_vider_tables($nom_meta_base_version) {
effacer_meta($nom_meta_base_version);
}
?>

@ -0,0 +1,36 @@
<?php
/**
* GetID3
* Gestion des métadonnées de fichiers sonores directement dans SPIP
*
* Auteurs :
* Quentin Drouet (kent1), BoOz
* 2008-2010 - Distribué sous licence GNU/GPL
*
*/
if (!defined("_ECRIRE_INC_VERSION")) return;
include_spip('inc/actions'); // *action_auteur
function exec_getid3_infos_dist()
{
$type = _request("type");
$id = _request('id_article');
//$id = intval(_request(id_table_objet($type)));
$script = _request("script"); // generalisation a tester
$id_document= _request('show_infos_docs');
exec_getid3_infos_args($id, $type, $id_document, $script);
}
function exec_getid3_infos_args($id_article, $type,$id_document,$script) {
include_spip('inc/actions');
$infos_videos = charger_fonction('infos_son', 'inc');
if(_request("iframe")=="iframe") {
$res = $infos_videos($id, $id_document,$type,$script, 'ajax').
$infos_videos($id, $id_document,$type,$script, 'ajax');
ajax_retour("<div class='upload_answer upload_document_added'>".$res."</div>",false);
} else ajax_retour($infos_videos($id, $id_document,$type,$script, 'ajax'));
//return ajax_action_greffe("spipmotion", $id_document, $corps);
}
?>

@ -0,0 +1,20 @@
<!-- titre=<:getid3:titre_getid3:> -->
<!-- icone=images/id3v2-24.png -->
<!-- logo=images/id3v2.png -->
<!-- descriptif=[(#AUTORISER{webmestre}|oui)[(#CONFIG{getid3/cover_defaut}|strlen|>{1}|oui)[(#VAL{modifs}|_request|oui)#SET{modifs,#VAL{modifs}|_request}<div class="formulaire_spip"><p class="reponse_formulaire reponse_formulaire_ok">[(#GET{modifs}|singulier_ou_pluriel{<:getid3:message_cover_defaut_modifiee:>,<:getid3:message_cover_defaut_modifiees:>})]</p></div>][(#GET{modifs}|non)[(#BOUTON_ACTION{<:getid3:bouton_appliquer_cover_defaut:>,[(#URL_ACTION_AUTEUR{getid3_appliquer_cover_defaut,'',#SELF})],'',<:getid3:message_validation_appliquer_cover:>})]]]
[(#CONFIG{getid3_casse}|=={oui}|oui)
<div class="formulaire_spip">
<p class="reponse_formulaire_erreur"><:getid3:erreur_logiciels_indisponibles:></p>
<p><:getid3:erreur_formats_ecriture_impossible:></p>
<ul>
[(#CONFIG{getid3_vorbiscomment_casse}|=={oui}|oui)<li>.ogg (<:getid3:erreur_necessite{soft=vorbiscomment}:>)</li>]
[(#CONFIG{getid3_metaflac_casse}|=={oui}|oui)<li>.flac (<:getid3:erreur_necessite{soft=metaflac}:>)</li>]
</ul>
[(#BOUTON_ACTION{<:getid3:label_verifier_logiciels:>,#URL_ACTION_AUTEUR{getid3_verifier_binaires,1,#SELF}})]
</div>
]
] -->
#CACHE{0}
<div class="ajax">
#FORMULAIRE_CONFIG_GETID3
</div>

@ -0,0 +1,46 @@
<!-- autoriser=configurer -->
<!-- refus=<:cfg:refus_configuration_administrateur:> -->
<!-- nom=getid3 -->
<div class="formulaire_spip formulaire_cfg formulaire_#FORM">
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>]
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
<form method="post" action="#ENV{action}">
<div>
#ACTION_FORMULAIRE{#ENV{action}}
<ul>
<li class="fieldset">
<h3 class="legend"><:getid3:legende_ecriture_tags:></h3>
<ul>
<li class="editer_ecriture_tags">
<label><:getid3:label_reecriture_tags:></label>
<div class="choix">
<input type="checkbox" name="reecriture_tags[]" value="titre" id="reecriture_tags_titre"[(#VAL{titre}|in_array{#ENV**{reecriture_tags,#ARRAY}}|oui)checked="checked"] />
<label for="reecriture_tags_titre"><:getid3:label_reecriture_tags_titre:></label>
</div>
<div class="choix">
<input type="checkbox" name="reecriture_tags[]" value="descriptif" id="reecriture_tags_descriptif"[(#VAL{descriptif}|in_array{#ENV**{reecriture_tags,#ARRAY}}|oui)checked="checked"] />
<label for="reecriture_tags_descriptif"><:getid3:label_reecriture_tags_descriptif:></label>
</div>
<div class="choix">
<input type="checkbox" name="reecriture_tags[]" value="logo" id="reecriture_tags_logo"[(#VAL{logo}|in_array{#ENV**{reecriture_tags,#ARRAY}}|oui)checked="checked"] />
<label for="reecriture_tags_logo"><:getid3:label_reecriture_tags_logo:></label>
</div>
</li>
<li class="editer_cover_defaut">
<label><:getid3:label_cover_defaut:></label>
[<div>(#ENV{cover_defaut}|image_reduire{150,150}|inserer_attribut{alt,""})</div>]
<p class="explication"><:getid3:explication_cover_defaut:></p>
<input type="text" name="cover_defaut" id="cover_defaut" value="#ENV{cover_defaut}" class="text" />
</li>
</ul>
</li>
</ul>
<p class="boutons">
<input type="submit" name="_cfg_ok" value="<:bouton_enregistrer:>" class="submit" />
</p>
</div>
</form>
</div>

@ -0,0 +1,64 @@
<div class='formulaire_spip formulaire_editer formulaire_id3_editer formulaire_id3_editer-#ENV{id_document}'>
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV{message_ok})</p>]
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV{message_erreur})</p>]
<BOUCLE_editable(CONDITION){si #ENV{editable}}>
<form method='post' action='#ENV{action}' enctype='multipart/form-data'><div>
[(#REM) declarer les hidden qui declencheront le service du formulaire
parametre : url d'action ]
#ACTION_FORMULAIRE{#ENV{action}}
<input type='hidden' name='id_document' value='#ENV{id_document}' />
[(#REM) un bouton submit pour enregistrer qui sera declenche par le return
il ne doit pas etre hidden pour marcher dans safari
]
<div style="position:absolute;left:-10000px;"><input type='submit' class='submit' value='<:bouton_enregistrer:>' /></div>
<ul>
<li class="editer_title[ (#ENV{erreurs}|table_valeur{title}|oui)erreur]">
<label for="title"><:getid3:label_title:></label>[
<span class='erreur_message'>(#ENV{erreurs}|table_valeur{title})</span>
]<input type='text' class='text' name='title' id='title' value="[(#ENV{title,''})]" />
</li>
<li class="editer_artist[ (#ENV{erreurs}|table_valeur{artist}|oui)erreur]">
<label for="artist"><:getid3:label_artist:></label>[
<span class='erreur_message'>(#ENV{erreurs}|table_valeur{artist})</span>
]<input type='text' class='text' name='artist' id='artist' value="[(#ENV{artist,''})]" />
</li>
<li class="editer_album[ (#ENV{erreurs}|table_valeur{album}|oui)erreur]">
<label for="album"><:getid3:label_album:></label>[
<span class='erreur_message'>(#ENV{erreurs}|table_valeur{album})</span>
]<input type='text' class='text' name='album' id='album' value="[(#ENV{album,''})]" />
</li>
<li class="editer_year[ (#ENV{erreurs}|table_valeur{year}|oui)erreur]">
<label for="year"><:getid3:label_year:></label>[
<span class='erreur_message'>(#ENV{erreurs}|table_valeur{year})</span>
]<input type='text' class='text' name='year' id='year' size="4" maxlength="4" value="[(#ENV{year,''})]" />
</li>
<li class="editer_comment[ (#ENV{erreurs}|table_valeur{comment}|oui)erreur]">
<label for="comment"><:getid3:label_comment:></label>[
<span class='erreur_message'>(#ENV{erreurs}|table_valeur{comment})</span>
]<textarea name='comment' id='comment'[ lang='(#LANGUE)'] rows='2' cols='40'>[(#ENV{comment})]</textarea>
</li>
<li class="editer_genre[ (#ENV{erreurs}|table_valeur{genre}|oui)erreur]">
<label for="genre"><:getid3:label_genre:></label>[
<span class='erreur_message'>(#ENV{erreurs}|table_valeur{genre})</span>
]<input type='text' class='text' name='genre' id='genre' value="[(#ENV{genre,''})]" />
</li>
<li class="editer_cover[ (#ENV{erreurs}|table_valeur{cover}|oui)erreur]">
<div>
<BOUCLE_covers(POUR){tableau #ENV{covers}}>
[(#VALEUR|image_reduire{120,120})]
</BOUCLE_covers>
</div>
<label for='cover'><:getid3:label_cover:></label>[
<span class='erreur_message'>(#ENV{message_cover_defaut}|filtrer_entites)</span>][
<span class='erreur_message'>(#ENV**{erreurs}|table_valeur{cover})</span>
]<input class='file' type="file" name="cover" value='#ENV{cover}' id="cover" size='14' />
</li>
</ul>
[(#REM) ajouter les saisies supplementaires : extra et autre, a cet endroit ]
<!--extra-->
<p class="boutons">
<input type='submit' class='submit' value='<:bouton_enregistrer:>' />
</p>
</div></form>
</BOUCLE_editable>
</div>

@ -0,0 +1,102 @@
<?php
/**
* Plugin GetID3
* (c) 2008-2010 BoOz et kent1
* Distribue sous licence GPL
* Formulaire d'édition des tags ID3 d'un fichier sonore
*/
/**
* Chargement des donnees du formulaire
*
* @param int $id l'id du document
* @return array
*/
function formulaires_editer_id3_charger($id){
$valeurs = array();
$config_id3 = lire_config('getid3',array());
$infos_doc = sql_fetsel('*','spip_documents','id_document='.intval($id));
if(!in_array($infos_doc['extension'],lire_config('getid3_write',array('mp3')))){
$valeurs['message_erreur'] = _T('getid3:message_extension_invalide_ecriture');
}else if($infos_doc['distant'] == 'oui'){
$valeurs['message_erreur'] = _T('getid3:message_erreur_document_distant_ecriture');
}
if(isset($valeurs['message_erreur'])){
$valeurs['editable'] = false;
}else{
/**
* Récupération des tags habituels:
* - title
* - artist
* - group
* - year
* - album
*/
include_spip('inc/documents');
$fichier = get_spip_doc($infos_doc['fichier']);
$recuperer_id3 = charger_fonction('recuperer_id3','inc');
$valeurs = $recuperer_id3($fichier);
foreach($valeurs as $valeur => $info){
if(preg_match('/cover/',$valeur)){
$valeurs['covers'][] = $info;
$valeurs['_hidden'] .= "<input type='hidden' name='old_cover' id='old_cover' value='$info' />";
}else{
$valeurs[$valeur] = filtrer_entites($info);
}
}
if(!count($valeurs['covers']) && (strlen($config_id3['cover_defaut']) > 0)){
$valeurs['covers'][] = $config_id3['cover_defaut'];
$valeurs['_hidden'] .= "<input type='hidden' name='old_cover' id='old_cover' value='".$config_id3['cover_defaut']."' />";
$valeurs['message_cover_defaut'] = _T('getid3:message_valider_cover_defaut');
}
$valeurs['id_document'] = $id;
}
return $valeurs;
}
/**
* Traitement du formulaire
*
* @param int $id
* @return array
*/
function formulaires_editer_id3_traiter($id){
$valeurs = array();
$infos = array('title','artist','album','year','genre','comment');
foreach($infos as $info){
$valeurs[$info] = _request($info);
}
$post = isset($_FILES) ? $_FILES : $GLOBALS['HTTP_POST_FILES'];
$files = null;
if (is_array($post)){
if (!($post['cover']['error'] == 4) && in_array($post['cover']['type'],array('image/png','image/jpeg','image/gif'))){
include_spip('inc/getdocument');
$dest = _DIR_TMP.$post['cover']['name'];
deplacer_fichier_upload($post['cover']['tmp_name'],$dest);
$files[] = $dest;
}elseif(_request('old_cover')){
$files[] = _request('old_cover');
}
}
$ecrire_id3 = charger_fonction('getid3_ecrire_infos','inc');
$err = $ecrire_id3($id,$valeurs,$files);
spip_log($err,'getid3');
if(is_array($files)){
foreach($files as $file){
supprimer_fichier($file);
}
}
if(_request('redirect')){
$redirect = parametre_url(urldecode(_request('redirect')),
'id_document', $id, '&');
include_spip('inc/headers');
redirige_par_entete($redirect);
}
return array('message_ok'=>_T('getid3:message_fichier_maj'),'editable'=>true);
}

@ -0,0 +1,27 @@
<?php
/**
* GetID3
* Gestion des métadonnées de fichiers sonores directement dans SPIP
*
* Auteurs :
* Quentin Drouet (kent1), BoOz
* 2008-2010 - Distribué sous licence GNU/GPL
*
*/
/**
* Fonction appelée par le génie de SPIP à intervalle régulier
* Par défaut tous les jours
*
* -* vérifie que la configuration n'est pas cassée (en activant la notification)
*
* @return
* @param object $time
*/
function genie_getid3_taches_generales($time){
$verifier_binaires = charger_fonction('getid3_verifier_binaires','inc');
$verifier_binaires(true);
return 1;
}
?>

@ -0,0 +1,211 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
/////////////////////////////////////////////////////////////////
// //
// extension.cache.dbm.php - part of getID3() //
// Please see readme.txt for more information //
// ///
/////////////////////////////////////////////////////////////////
// //
// This extension written by Allan Hansen <ahØartemis*dk> //
// ///
/////////////////////////////////////////////////////////////////
/**
* This is a caching extension for getID3(). It works the exact same
* way as the getID3 class, but return cached information very fast
*
* Example:
*
* Normal getID3 usage (example):
*
* require_once 'getid3/getid3.php';
* $getID3 = new getID3;
* $getID3->encoding = 'UTF-8';
* $info1 = $getID3->analyze('file1.flac');
* $info2 = $getID3->analyze('file2.wv');
*
* getID3_cached usage:
*
* require_once 'getid3/getid3.php';
* require_once 'getid3/getid3/extension.cache.dbm.php';
* $getID3 = new getID3_cached('db3', '/tmp/getid3_cache.dbm',
* '/tmp/getid3_cache.lock');
* $getID3->encoding = 'UTF-8';
* $info1 = $getID3->analyze('file1.flac');
* $info2 = $getID3->analyze('file2.wv');
*
*
* Supported Cache Types
*
* SQL Databases: (use extension.cache.mysql)
*
* cache_type cache_options
* -------------------------------------------------------------------
* mysql host, database, username, password
*
*
* DBM-Style Databases: (this extension)
*
* cache_type cache_options
* -------------------------------------------------------------------
* gdbm dbm_filename, lock_filename
* ndbm dbm_filename, lock_filename
* db2 dbm_filename, lock_filename
* db3 dbm_filename, lock_filename
* db4 dbm_filename, lock_filename (PHP5 required)
*
* PHP must have write access to both dbm_filename and lock_filename.
*
*
* Recommended Cache Types
*
* Infrequent updates, many reads any DBM
* Frequent updates mysql
*/
class getID3_cached_dbm extends getID3
{
// public: constructor - see top of this file for cache type and cache_options
function getID3_cached_dbm($cache_type, $dbm_filename, $lock_filename) {
// Check for dba extension
if (!extension_loaded('dba')) {
throw new Exception('PHP is not compiled with dba support, required to use DBM style cache.');
}
// Check for specific dba driver
if (!function_exists('dba_handlers') || !in_array($cache_type, dba_handlers())) {
throw new Exception('PHP is not compiled --with '.$cache_type.' support, required to use DBM style cache.');
}
// Create lock file if needed
if (!file_exists($lock_filename)) {
if (!touch($lock_filename)) {
throw new Exception('failed to create lock file: '.$lock_filename);
}
}
// Open lock file for writing
if (!is_writeable($lock_filename)) {
throw new Exception('lock file: '.$lock_filename.' is not writable');
}
$this->lock = fopen($lock_filename, 'w');
// Acquire exclusive write lock to lock file
flock($this->lock, LOCK_EX);
// Create dbm-file if needed
if (!file_exists($dbm_filename)) {
if (!touch($dbm_filename)) {
throw new Exception('failed to create dbm file: '.$dbm_filename);
}
}
// Try to open dbm file for writing
$this->dba = dba_open($dbm_filename, 'w', $cache_type);
if (!$this->dba) {
// Failed - create new dbm file
$this->dba = dba_open($dbm_filename, 'n', $cache_type);
if (!$this->dba) {
throw new Exception('failed to create dbm file: '.$dbm_filename);
}
// Insert getID3 version number
dba_insert($this::VERSION, $this::VERSION, $this->dba);
}
// Init misc values
$this->cache_type = $cache_type;
$this->dbm_filename = $dbm_filename;
// Register destructor
register_shutdown_function(array($this, '__destruct'));
// Check version number and clear cache if changed
if (dba_fetch($this::VERSION, $this->dba) != $this::VERSION) {
$this->clear_cache();
}
parent::getID3();
}
// public: destuctor
function __destruct() {
// Close dbm file
dba_close($this->dba);
// Release exclusive lock
flock($this->lock, LOCK_UN);
// Close lock file
fclose($this->lock);
}
// public: clear cache
function clear_cache() {
// Close dbm file
dba_close($this->dba);
// Create new dbm file
$this->dba = dba_open($this->dbm_filename, 'n', $this->cache_type);
if (!$this->dba) {
throw new Exception('failed to clear cache/recreate dbm file: '.$this->dbm_filename);
}
// Insert getID3 version number
dba_insert($this::VERSION, $this::VERSION, $this->dba);
// Re-register shutdown function
register_shutdown_function(array($this, '__destruct'));
}
// public: analyze file
function analyze($filename) {
if (file_exists($filename)) {
// Calc key filename::mod_time::size - should be unique
$key = $filename.'::'.filemtime($filename).'::'.filesize($filename);
// Loopup key
$result = dba_fetch($key, $this->dba);
// Hit
if ($result !== false) {
return unserialize($result);
}
}
// Miss
$result = parent::analyze($filename);
// Save result
if (file_exists($filename)) {
dba_insert($key, serialize($result), $this->dba);
}
return $result;
}
}
?>

@ -0,0 +1,170 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
/////////////////////////////////////////////////////////////////
// //
// extension.cache.mysql.php - part of getID3() //
// Please see readme.txt for more information //
// ///
/////////////////////////////////////////////////////////////////
// //
// This extension written by Allan Hansen <ahØartemis*dk> //
// ///
/////////////////////////////////////////////////////////////////
/**
* This is a caching extension for getID3(). It works the exact same
* way as the getID3 class, but return cached information very fast
*
* Example: (see also demo.cache.mysql.php in /demo/)
*
* Normal getID3 usage (example):
*
* require_once 'getid3/getid3.php';
* $getID3 = new getID3;
* $getID3->encoding = 'UTF-8';
* $info1 = $getID3->analyze('file1.flac');
* $info2 = $getID3->analyze('file2.wv');
*
* getID3_cached usage:
*
* require_once 'getid3/getid3.php';
* require_once 'getid3/getid3/extension.cache.mysql.php';
* $getID3 = new getID3_cached_mysql('localhost', 'database',
* 'username', 'password');
* $getID3->encoding = 'UTF-8';
* $info1 = $getID3->analyze('file1.flac');
* $info2 = $getID3->analyze('file2.wv');
*
*
* Supported Cache Types (this extension)
*
* SQL Databases:
*
* cache_type cache_options
* -------------------------------------------------------------------
* mysql host, database, username, password
*
*
* DBM-Style Databases: (use extension.cache.dbm)
*
* cache_type cache_options
* -------------------------------------------------------------------
* gdbm dbm_filename, lock_filename
* ndbm dbm_filename, lock_filename
* db2 dbm_filename, lock_filename
* db3 dbm_filename, lock_filename
* db4 dbm_filename, lock_filename (PHP5 required)
*
* PHP must have write access to both dbm_filename and lock_filename.
*
*
* Recommended Cache Types
*
* Infrequent updates, many reads any DBM
* Frequent updates mysql
*/
class getID3_cached_mysql extends getID3
{
// private vars
var $cursor;
var $connection;
// public: constructor - see top of this file for cache type and cache_options
function getID3_cached_mysql($host, $database, $username, $password) {
// Check for mysql support
if (!function_exists('mysql_pconnect')) {
throw new Exception('PHP not compiled with mysql support.');
}
// Connect to database
$this->connection = mysql_pconnect($host, $username, $password);
if (!$this->connection) {
throw new Exception('mysql_pconnect() failed - check permissions and spelling.');
}
// Select database
if (!mysql_select_db($database, $this->connection)) {
throw new Exception('Cannot use database '.$database);
}
// Create cache table if not exists
$this->create_table();
// Check version number and clear cache if changed
$version = '';
if ($this->cursor = mysql_query("SELECT `value` FROM `getid3_cache` WHERE (`filename` = '".mysql_real_escape_string($this::VERSION)."') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')", $this->connection)) {
list($version) = mysql_fetch_array($this->cursor);
}
if ($version != $this::VERSION) {
$this->clear_cache();
}
parent::getID3();
}
// public: clear cache
function clear_cache() {
$this->cursor = mysql_query("DELETE FROM `getid3_cache`", $this->connection);
$this->cursor = mysql_query("INSERT INTO `getid3_cache` VALUES ('".$this::VERSION."', -1, -1, -1, '".$this::VERSION."')", $this->connection);
}
// public: analyze file
function analyze($filename) {
if (file_exists($filename)) {
// Short-hands
$filetime = filemtime($filename);
$filesize = filesize($filename);
// Loopup file
$result = '';
if ($this->cursor = mysql_query("SELECT `value` FROM `getid3_cache` WHERE (`filename` = '".mysql_real_escape_string($filename)."') AND (`filesize` = '".mysql_real_escape_string($filesize)."') AND (`filetime` = '".mysql_real_escape_string($filetime)."')", $this->connection)) {
// Hit
list($result) = mysql_fetch_array($this->cursor);
return unserialize(base64_decode($result));
}
}
// Miss
$analysis = parent::analyze($filename);
// Save result
if (file_exists($filename)) {
$this->cursor = mysql_query("INSERT INTO `getid3_cache` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES ('".mysql_real_escape_string($filename)."', '".mysql_real_escape_string($filesize)."', '".mysql_real_escape_string($filetime)."', '".mysql_real_escape_string(time())."', '".mysql_real_escape_string(base64_encode(serialize($analysis)))."')", $this->connection);
}
return $result;
}
// private: (re)create sql table
function create_table($drop=false) {
$this->cursor = mysql_query("CREATE TABLE IF NOT EXISTS `getid3_cache` (
`filename` 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',
`value` TEXT NOT NULL,
PRIMARY KEY (`filename`,`filesize`,`filetime`)) TYPE=MyISAM", $this->connection);
echo mysql_error($this->connection);
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,280 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.gzip.php //
// module for analyzing GZIP files //
// dependencies: NONE //
// ///
/////////////////////////////////////////////////////////////////
// //
// Module originally written by //
// Mike Mozolin <teddybearØmail*ru> //
// //
/////////////////////////////////////////////////////////////////
class getid3_gzip extends getid3_handler {
// public: Optional file list - disable for speed.
var $option_gzip_parse_contents = false; // decode gzipped files, if possible, and parse recursively (.tar.gz for example)
function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'gzip';
$start_length = 10;
$unpack_header = 'a1id1/a1id2/a1cmethod/a1flags/a4mtime/a1xflags/a1os';
//+---+---+---+---+---+---+---+---+---+---+
//|ID1|ID2|CM |FLG| MTIME |XFL|OS |
//+---+---+---+---+---+---+---+---+---+---+
if ($info['filesize'] > $info['php_memory_limit']) {
$info['error'][] = 'File is too large ('.number_format($info['filesize']).' bytes) to read into memory (limit: '.number_format($info['php_memory_limit'] / 1048576).'MB)';
return false;
}
fseek($this->getid3->fp, 0);
$buffer = fread($this->getid3->fp, $info['filesize']);
$arr_members = explode("\x1F\x8B\x08", $buffer);
while (true) {
$is_wrong_members = false;
$num_members = intval(count($arr_members));
for ($i = 0; $i < $num_members; $i++) {
if (strlen($arr_members[$i]) == 0) {
continue;
}
$buf = "\x1F\x8B\x08".$arr_members[$i];
$attr = unpack($unpack_header, substr($buf, 0, $start_length));
if (!$this->get_os_type(ord($attr['os']))) {
// Merge member with previous if wrong OS type
$arr_members[$i - 1] .= $buf;
$arr_members[$i] = '';
$is_wrong_members = true;
continue;
}
}
if (!$is_wrong_members) {
break;
}
}
$info['gzip']['files'] = array();
$fpointer = 0;
$idx = 0;
for ($i = 0; $i < $num_members; $i++) {
if (strlen($arr_members[$i]) == 0) {
continue;
}
$thisInfo = &$info['gzip']['member_header'][++$idx];
$buff = "\x1F\x8B\x08".$arr_members[$i];
$attr = unpack($unpack_header, substr($buff, 0, $start_length));
$thisInfo['filemtime'] = getid3_lib::LittleEndian2Int($attr['mtime']);
$thisInfo['raw']['id1'] = ord($attr['cmethod']);
$thisInfo['raw']['id2'] = ord($attr['cmethod']);
$thisInfo['raw']['cmethod'] = ord($attr['cmethod']);
$thisInfo['raw']['os'] = ord($attr['os']);
$thisInfo['raw']['xflags'] = ord($attr['xflags']);
$thisInfo['raw']['flags'] = ord($attr['flags']);
$thisInfo['flags']['crc16'] = (bool) ($thisInfo['raw']['flags'] & 0x02);
$thisInfo['flags']['extra'] = (bool) ($thisInfo['raw']['flags'] & 0x04);
$thisInfo['flags']['filename'] = (bool) ($thisInfo['raw']['flags'] & 0x08);
$thisInfo['flags']['comment'] = (bool) ($thisInfo['raw']['flags'] & 0x10);
$thisInfo['compression'] = $this->get_xflag_type($thisInfo['raw']['xflags']);
$thisInfo['os'] = $this->get_os_type($thisInfo['raw']['os']);
if (!$thisInfo['os']) {
$info['error'][] = 'Read error on gzip file';
return false;
}
$fpointer = 10;
$arr_xsubfield = array();
// bit 2 - FLG.FEXTRA
//+---+---+=================================+
//| XLEN |...XLEN bytes of "extra field"...|
//+---+---+=================================+
if ($thisInfo['flags']['extra']) {
$w_xlen = substr($buff, $fpointer, 2);
$xlen = getid3_lib::LittleEndian2Int($w_xlen);
$fpointer += 2;
$thisInfo['raw']['xfield'] = substr($buff, $fpointer, $xlen);
// Extra SubFields
//+---+---+---+---+==================================+
//|SI1|SI2| LEN |... LEN bytes of subfield data ...|
//+---+---+---+---+==================================+
$idx = 0;
while (true) {
if ($idx >= $xlen) {
break;
}
$si1 = ord(substr($buff, $fpointer + $idx++, 1));
$si2 = ord(substr($buff, $fpointer + $idx++, 1));
if (($si1 == 0x41) && ($si2 == 0x70)) {
$w_xsublen = substr($buff, $fpointer + $idx, 2);
$xsublen = getid3_lib::LittleEndian2Int($w_xsublen);
$idx += 2;
$arr_xsubfield[] = substr($buff, $fpointer + $idx, $xsublen);
$idx += $xsublen;
} else {
break;
}
}
$fpointer += $xlen;
}
// bit 3 - FLG.FNAME
//+=========================================+
//|...original file name, zero-terminated...|
//+=========================================+
// GZIP files may have only one file, with no filename, so assume original filename is current filename without .gz
$thisInfo['filename'] = preg_replace('#\.gz$#i', '', $info['filename']);
if ($thisInfo['flags']['filename']) {
while (true) {
if (ord($buff[$fpointer]) == 0) {
$fpointer++;
break;
}
$thisInfo['filename'] .= $buff[$fpointer];
$fpointer++;
}
}
// bit 4 - FLG.FCOMMENT
//+===================================+
//|...file comment, zero-terminated...|
//+===================================+
if ($thisInfo['flags']['comment']) {
while (true) {
if (ord($buff[$fpointer]) == 0) {
$fpointer++;
break;
}
$thisInfo['comment'] .= $buff[$fpointer];
$fpointer++;
}
}
// bit 1 - FLG.FHCRC
//+---+---+
//| CRC16 |
//+---+---+
if ($thisInfo['flags']['crc16']) {
$w_crc = substr($buff, $fpointer, 2);
$thisInfo['crc16'] = getid3_lib::LittleEndian2Int($w_crc);
$fpointer += 2;
}
// bit 0 - FLG.FTEXT
//if ($thisInfo['raw']['flags'] & 0x01) {
// Ignored...
//}
// bits 5, 6, 7 - reserved
$thisInfo['crc32'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 8, 4));
$thisInfo['filesize'] = getid3_lib::LittleEndian2Int(substr($buff, strlen($buff) - 4));
$info['gzip']['files'] = getid3_lib::array_merge_clobber($info['gzip']['files'], getid3_lib::CreateDeepArray($thisInfo['filename'], '/', $thisInfo['filesize']));
if ($this->option_gzip_parse_contents) {
// Try to inflate GZip
$csize = 0;
$inflated = '';
$chkcrc32 = '';
if (function_exists('gzinflate')) {
$cdata = substr($buff, $fpointer);
$cdata = substr($cdata, 0, strlen($cdata) - 8);
$csize = strlen($cdata);
$inflated = gzinflate($cdata);
// Calculate CRC32 for inflated content
$thisInfo['crc32_valid'] = (bool) (sprintf('%u', crc32($inflated)) == $thisInfo['crc32']);
// determine format
$formattest = substr($inflated, 0, 32774);
$getid3_temp = new getID3();
$determined_format = $getid3_temp->GetFileFormat($formattest);
unset($getid3_temp);
// file format is determined
$determined_format['module'] = (isset($determined_format['module']) ? $determined_format['module'] : '');
switch ($determined_format['module']) {
case 'tar':
// view TAR-file info
if (file_exists(GETID3_INCLUDEPATH.$determined_format['include']) && include_once(GETID3_INCLUDEPATH.$determined_format['include'])) {
if (($temp_tar_filename = tempnam(GETID3_TEMP_DIR, 'getID3')) === false) {
// can't find anywhere to create a temp file, abort
$info['error'][] = 'Unable to create temp file to parse TAR inside GZIP file';
break;
}
if ($fp_temp_tar = fopen($temp_tar_filename, 'w+b')) {
fwrite($fp_temp_tar, $inflated);
fclose($fp_temp_tar);
$getid3_temp = new getID3();
$getid3_temp->openfile($temp_tar_filename);
$getid3_tar = new getid3_tar($getid3_temp);
$getid3_tar->Analyze();
$info['gzip']['member_header'][$idx]['tar'] = $getid3_temp->info['tar'];
unset($getid3_temp, $getid3_tar);
unlink($temp_tar_filename);
} else {
$info['error'][] = 'Unable to fopen() temp file to parse TAR inside GZIP file';
break;
}
}
break;
case '':
default:
// unknown or unhandled format
break;
}
}
}
}
return true;
}
// Converts the OS type
function get_os_type($key) {
static $os_type = array(
'0' => 'FAT filesystem (MS-DOS, OS/2, NT/Win32)',
'1' => 'Amiga',
'2' => 'VMS (or OpenVMS)',
'3' => 'Unix',
'4' => 'VM/CMS',
'5' => 'Atari TOS',
'6' => 'HPFS filesystem (OS/2, NT)',
'7' => 'Macintosh',
'8' => 'Z-System',
'9' => 'CP/M',
'10' => 'TOPS-20',
'11' => 'NTFS filesystem (NT)',
'12' => 'QDOS',
'13' => 'Acorn RISCOS',
'255' => 'unknown'
);
return (isset($os_type[$key]) ? $os_type[$key] : '');
}
// Converts the eXtra FLags
function get_xflag_type($key) {
static $xflag_type = array(
'0' => 'unknown',
'2' => 'maximum compression',
'4' => 'fastest algorithm'
);
return (isset($xflag_type[$key]) ? $xflag_type[$key] : '');
}
}
?>

@ -0,0 +1,53 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.rar.php //
// module for analyzing RAR files //
// dependencies: NONE //
// ///
/////////////////////////////////////////////////////////////////
class getid3_rar extends getid3_handler
{
var $option_use_rar_extension = false;
function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'rar';
if ($this->option_use_rar_extension === true) {
if (function_exists('rar_open')) {
if ($rp = rar_open($info['filenamepath'])) {
$info['rar']['files'] = array();
$entries = rar_list($rp);
foreach ($entries as $entry) {
$info['rar']['files'] = getid3_lib::array_merge_clobber($info['rar']['files'], getid3_lib::CreateDeepArray($entry->getName(), '/', $entry->getUnpackedSize()));
}
rar_close($rp);
return true;
} else {
$info['error'][] = 'failed to rar_open('.$info['filename'].')';
}
} else {
$info['error'][] = 'RAR support does not appear to be available in this PHP installation';
}
} else {
$info['error'][] = 'PHP-RAR processing has been disabled (set $getid3_rar->option_use_rar_extension=true to enable)';
}
return false;
}
}
?>

@ -0,0 +1,96 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.szip.php //
// module for analyzing SZIP compressed files //
// dependencies: NONE //
// ///
/////////////////////////////////////////////////////////////////
class getid3_szip extends getid3_handler
{
function Analyze() {
$info = &$this->getid3->info;
fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
$SZIPHeader = fread($this->getid3->fp, 6);
if (substr($SZIPHeader, 0, 4) != "SZ\x0A\x04") {
$info['error'][] = 'Expecting "53 5A 0A 04" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($SZIPHeader, 0, 4)).'"';
return false;
}
$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));
while (!feof($this->getid3->fp)) {
$NextBlockID = fread($this->getid3->fp, 2);
switch ($NextBlockID) {
case 'SZ':
// Note that szip files can be concatenated, this has the same effect as
// concatenating the files. this also means that global header blocks
// might be present between directory/data blocks.
fseek($this->getid3->fp, 4, SEEK_CUR);
break;
case 'BH':
$BHheaderbytes = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 3));
$BHheaderdata = fread($this->getid3->fp, $BHheaderbytes);
$BHheaderoffset = 0;
while (strpos($BHheaderdata, "\x00", $BHheaderoffset) > 0) {
//filename as \0 terminated string (empty string indicates end)
//owner as \0 terminated string (empty is same as last file)
//group as \0 terminated string (empty is same as last file)
//3 byte filelength in this block
//2 byte access flags
//4 byte creation time (like in unix)
//4 byte modification time (like in unix)
//4 byte access time (like in unix)
$BHdataArray['filename'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00"));
$BHheaderoffset += (strlen($BHdataArray['filename']) + 1);
$BHdataArray['owner'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00"));
$BHheaderoffset += (strlen($BHdataArray['owner']) + 1);
$BHdataArray['group'] = substr($BHheaderdata, $BHheaderoffset, strcspn($BHheaderdata, "\x00"));
$BHheaderoffset += (strlen($BHdataArray['group']) + 1);
$BHdataArray['filelength'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 3));
$BHheaderoffset += 3;
$BHdataArray['access_flags'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 2));
$BHheaderoffset += 2;
$BHdataArray['creation_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
$BHheaderoffset += 4;
$BHdataArray['modification_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
$BHheaderoffset += 4;
$BHdataArray['access_time'] = getid3_lib::BigEndian2Int(substr($BHheaderdata, $BHheaderoffset, 4));
$BHheaderoffset += 4;
$info['szip']['BH'][] = $BHdataArray;
}
break;
default:
break 2;
}
}
return true;
}
}
?>

@ -0,0 +1,178 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.tar.php //
// module for analyzing TAR files //
// dependencies: NONE //
// ///
/////////////////////////////////////////////////////////////////
// //
// Module originally written by //
// Mike Mozolin <teddybearØmail*ru> //
// //
/////////////////////////////////////////////////////////////////
class getid3_tar extends getid3_handler
{
function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'tar';
$info['tar']['files'] = array();
$unpack_header = 'a100fname/a8mode/a8uid/a8gid/a12size/a12mtime/a8chksum/a1typflag/a100lnkname/a6magic/a2ver/a32uname/a32gname/a8devmaj/a8devmin/a155prefix';
$null_512k = str_repeat("\x00", 512); // end-of-file marker
fseek($this->getid3->fp, 0);
while (!feof($this->getid3->fp)) {
$buffer = fread($this->getid3->fp, 512);
if (strlen($buffer) < 512) {
break;
}
// check the block
$checksum = 0;
for ($i = 0; $i < 148; $i++) {
$checksum += ord($buffer{$i});
}
for ($i = 148; $i < 156; $i++) {
$checksum += ord(' ');
}
for ($i = 156; $i < 512; $i++) {
$checksum += ord($buffer{$i});
}
$attr = unpack($unpack_header, $buffer);
$name = (isset($attr['fname'] ) ? trim($attr['fname'] ) : '');
$mode = octdec(isset($attr['mode'] ) ? trim($attr['mode'] ) : '');
$uid = octdec(isset($attr['uid'] ) ? trim($attr['uid'] ) : '');
$gid = octdec(isset($attr['gid'] ) ? trim($attr['gid'] ) : '');
$size = octdec(isset($attr['size'] ) ? trim($attr['size'] ) : '');
$mtime = octdec(isset($attr['mtime'] ) ? trim($attr['mtime'] ) : '');
$chksum = octdec(isset($attr['chksum'] ) ? trim($attr['chksum'] ) : '');
$typflag = (isset($attr['typflag']) ? trim($attr['typflag']) : '');
$lnkname = (isset($attr['lnkname']) ? trim($attr['lnkname']) : '');
$magic = (isset($attr['magic'] ) ? trim($attr['magic'] ) : '');
$ver = (isset($attr['ver'] ) ? trim($attr['ver'] ) : '');
$uname = (isset($attr['uname'] ) ? trim($attr['uname'] ) : '');
$gname = (isset($attr['gname'] ) ? trim($attr['gname'] ) : '');
$devmaj = octdec(isset($attr['devmaj'] ) ? trim($attr['devmaj'] ) : '');
$devmin = octdec(isset($attr['devmin'] ) ? trim($attr['devmin'] ) : '');
$prefix = (isset($attr['prefix'] ) ? trim($attr['prefix'] ) : '');
if (($checksum == 256) && ($chksum == 0)) {
// EOF Found
break;
}
if ($prefix) {
$name = $prefix.'/'.$name;
}
if ((preg_match('#/$#', $name)) && !$name) {
$typeflag = 5;
}
if ($buffer == $null_512k) {
// it's the end of the tar-file...
break;
}
// Read to the next chunk
fseek($this->getid3->fp, $size, SEEK_CUR);
$diff = $size % 512;
if ($diff != 0) {
// Padding, throw away
fseek($this->getid3->fp, (512 - $diff), SEEK_CUR);
}
// Protect against tar-files with garbage at the end
if ($name == '') {
break;
}
$info['tar']['file_details'][$name] = array (
'name' => $name,
'mode_raw' => $mode,
'mode' => getid3_tar::display_perms($mode),
'uid' => $uid,
'gid' => $gid,
'size' => $size,
'mtime' => $mtime,
'chksum' => $chksum,
'typeflag' => getid3_tar::get_flag_type($typflag),
'linkname' => $lnkname,
'magic' => $magic,
'version' => $ver,
'uname' => $uname,
'gname' => $gname,
'devmajor' => $devmaj,
'devminor' => $devmin
);
$info['tar']['files'] = getid3_lib::array_merge_clobber($info['tar']['files'], getid3_lib::CreateDeepArray($info['tar']['file_details'][$name]['name'], '/', $size));
}
return true;
}
// Parses the file mode to file permissions
function display_perms($mode) {
// Determine Type
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
elseif ($mode & 0x8000) $type='-'; // Regular
elseif ($mode & 0xA000) $type='l'; // Symbolic Link
elseif ($mode & 0xC000) $type='s'; // Socket
else $type='u'; // UNKNOWN
// Determine permissions
$owner['read'] = (($mode & 00400) ? 'r' : '-');
$owner['write'] = (($mode & 00200) ? 'w' : '-');
$owner['execute'] = (($mode & 00100) ? 'x' : '-');
$group['read'] = (($mode & 00040) ? 'r' : '-');
$group['write'] = (($mode & 00020) ? 'w' : '-');
$group['execute'] = (($mode & 00010) ? 'x' : '-');
$world['read'] = (($mode & 00004) ? 'r' : '-');
$world['write'] = (($mode & 00002) ? 'w' : '-');
$world['execute'] = (($mode & 00001) ? 'x' : '-');
// Adjust for SUID, SGID and sticky bit
if ($mode & 0x800) $owner['execute'] = ($owner['execute'] == 'x') ? 's' : 'S';
if ($mode & 0x400) $group['execute'] = ($group['execute'] == 'x') ? 's' : 'S';
if ($mode & 0x200) $world['execute'] = ($world['execute'] == 'x') ? 't' : 'T';
$s = sprintf('%1s', $type);
$s .= sprintf('%1s%1s%1s', $owner['read'], $owner['write'], $owner['execute']);
$s .= sprintf('%1s%1s%1s', $group['read'], $group['write'], $group['execute']);
$s .= sprintf('%1s%1s%1s'."\n", $world['read'], $world['write'], $world['execute']);
return $s;
}
// Converts the file type
function get_flag_type($typflag) {
static $flag_types = array(
'0' => 'LF_NORMAL',
'1' => 'LF_LINK',
'2' => 'LF_SYNLINK',
'3' => 'LF_CHR',
'4' => 'LF_BLK',
'5' => 'LF_DIR',
'6' => 'LF_FIFO',
'7' => 'LF_CONFIG',
'D' => 'LF_DUMPDIR',
'K' => 'LF_LONGLINK',
'L' => 'LF_LONGNAME',
'M' => 'LF_MULTIVOL',
'N' => 'LF_NAMES',
'S' => 'LF_SPARSE',
'V' => 'LF_VOLHDR'
);
return (isset($flag_types[$typflag]) ? $flag_types[$typflag] : '');
}
}
?>

@ -0,0 +1,424 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.archive.zip.php //
// module for analyzing pkZip files //
// dependencies: NONE //
// ///
/////////////////////////////////////////////////////////////////
class getid3_zip extends getid3_handler
{
function Analyze() {
$info = &$this->getid3->info;
$info['fileformat'] = 'zip';
$info['zip']['encoding'] = 'ISO-8859-1';
$info['zip']['files'] = array();
$info['zip']['compressed_size'] = 0;
$info['zip']['uncompressed_size'] = 0;
$info['zip']['entries_count'] = 0;
if (!getid3_lib::intValueSupported($info['filesize'])) {
$info['error'][] = 'File is larger than '.round(PHP_INT_MAX / 1073741824).'GB, not supported by PHP';
return false;