Browse Source

le trunk

v1
kent1@arscenic.info 10 years ago
commit
971fb2695c
  1. 103
      .gitattributes
  2. 61
      action/getid3_appliquer_cover_defaut.php
  3. 45
      action/getid3_infos.php
  4. 36
      action/getid3_verifier_binaires.php
  5. 29
      base/getid3_base.php
  6. 111
      base/getid3_upgrade.php
  7. 36
      exec/getid3_infos.php
  8. 20
      fonds/cfg_getid3.html
  9. 46
      formulaires/config_getid3.html
  10. 64
      formulaires/editer_id3.html
  11. 102
      formulaires/editer_id3.php
  12. 27
      genie/getid3_taches_generales.php
  13. 211
      getid3/extension.cache.dbm.php
  14. 170
      getid3/extension.cache.mysql.php
  15. 1292
      getid3/getid3.lib.php
  16. 1757
      getid3/getid3.php
  17. 280
      getid3/module.archive.gzip.php
  18. 53
      getid3/module.archive.rar.php
  19. 96
      getid3/module.archive.szip.php
  20. 178
      getid3/module.archive.tar.php
  21. 424
      getid3/module.archive.zip.php
  22. 1707
      getid3/module.audio-video.asf.php
  23. 73
      getid3/module.audio-video.bink.php
  24. 724
      getid3/module.audio-video.flv.php
  25. 1939
      getid3/module.audio-video.matroska.php
  26. 299
      getid3/module.audio-video.mpeg.php
  27. 226
      getid3/module.audio-video.nsv.php
  28. 2114
      getid3/module.audio-video.quicktime.php
  29. 530
      getid3/module.audio-video.real.php
  30. 2372
      getid3/module.audio-video.riff.php
  31. 142
      getid3/module.audio-video.swf.php
  32. 59
      getid3/module.audio.aa.php
  33. 514
      getid3/module.audio.aac.php
  34. 498
      getid3/module.audio.ac3.php
  35. 165
      getid3/module.audio.au.php
  36. 127
      getid3/module.audio.avr.php
  37. 230
      getid3/module.audio.bonk.php
  38. 75
      getid3/module.audio.dss.php
  39. 242
      getid3/module.audio.dts.php
  40. 480
      getid3/module.audio.flac.php
  41. 229
      getid3/module.audio.la.php
  42. 130
      getid3/module.audio.lpac.php
  43. 526
      getid3/module.audio.midi.php
  44. 101
      getid3/module.audio.mod.php
  45. 205
      getid3/module.audio.monkey.php
  46. 2011
      getid3/module.audio.mp3.php
  47. 509
      getid3/module.audio.mpc.php
  48. 709
      getid3/module.audio.ogg.php
  49. 429
      getid3/module.audio.optimfrog.php
  50. 94
      getid3/module.audio.rkau.php
  51. 183
      getid3/module.audio.shorten.php
  52. 109
      getid3/module.audio.tta.php
  53. 207
      getid3/module.audio.voc.php
  54. 162
      getid3/module.audio.vqf.php
  55. 400
      getid3/module.audio.wavpack.php
  56. 690
      getid3/module.graphic.bmp.php
  57. 184
      getid3/module.graphic.gif.php
  58. 338
      getid3/module.graphic.jpg.php
  59. 134
      getid3/module.graphic.pcd.php
  60. 520
      getid3/module.graphic.png.php
  61. 104
      getid3/module.graphic.svg.php
  62. 227
      getid3/module.graphic.tiff.php
  63. 312
      getid3/module.misc.cue.php
  64. 61
      getid3/module.misc.exe.php
  65. 389
      getid3/module.misc.iso.php
  66. 40
      getid3/module.misc.msoffice.php
  67. 33
      getid3/module.misc.par2.php
  68. 33
      getid3/module.misc.pdf.php
  69. 372
      getid3/module.tag.apetag.php
  70. 362
      getid3/module.tag.id3v1.php
  71. 3303
      getid3/module.tag.id3v2.php
  72. 297
      getid3/module.tag.lyrics3.php
  73. 766
      getid3/module.tag.xmp.php
  74. 225
      getid3/write.apetag.php
  75. 138
      getid3/write.id3v1.php
  76. 2050
      getid3/write.id3v2.php
  77. 73
      getid3/write.lyrics3.php
  78. 163
      getid3/write.metaflac.php
  79. 615
      getid3/write.php
  80. 275
      getid3/write.real.php
  81. 121
      getid3/write.vorbiscomment.php
  82. 68
      getid3_fonctions.php
  83. 14
      getid3_options.php
  84. 189
      getid3_pipelines.php
  85. BIN
      images/id3v2-24.png
  86. BIN
      images/id3v2.png
  87. 155
      inc/getid3_ecrire_infos.php
  88. 119
      inc/getid3_recuperer_infos.php
  89. 82
      inc/getid3_verifier_binaires.php
  90. 63
      inc/infos_son.php
  91. 103
      inc/recuperer_id3.php
  92. 3
      lang/getid3.xml
  93. 123
      lang/getid3_en.php
  94. 121
      lang/getid3_fr.php
  95. 22
      modeles/doc_player_getid3.html
  96. 21
      notifications/getid3_verifier_binaires.html
  97. 46
      notifications/getid3_verifier_binaires.php
  98. 60
      plugin.xml
  99. 45
      prive/exec/document_id3_editer.html
  100. 15
      prive/exec/document_id3_editer_fonctions.php
  101. Some files were not shown because too many files have changed in this diff Show More

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

61
action/getid3_appliquer_cover_defaut.php

@ -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;
}
?>

45
action/getid3_infos.php

@ -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;
}
?>

36
action/getid3_verifier_binaires.php

@ -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);
}
}
?>

29
base/getid3_base.php

@ -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;
}
?>

111
base/getid3_upgrade.php

@ -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);
}
?>

36
exec/getid3_infos.php

@ -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);
}
?>

20
fonds/cfg_getid3.html

@ -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>

46
formulaires/config_getid3.html

@ -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>

64
formulaires/editer_id3.html

@ -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>

102
formulaires/editer_id3.php

@ -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);
}

27
genie/getid3_taches_generales.php

@ -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;
}
?>

211
getid3/extension.cache.dbm.php

@ -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;
}
}
?>

170
getid3/extension.cache.mysql.php

@ -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);
}
}
?>

1292
getid3/getid3.lib.php

File diff suppressed because it is too large Load Diff

1757
getid3/getid3.php

File diff suppressed because it is too large Load Diff

280
getid3/module.archive.gzip.php

@ -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] : '');
}
}
?>

53
getid3/module.archive.rar.php

@ -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;
}
}
?>

96
getid3/module.archive.szip.php

@ -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;
}
}
?>

178
getid3/module.archive.tar.php

@ -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
{