diff --git a/inc/getdocument.php b/inc/getdocument.php index 6071cf83016986b225541750b514044aa26c03a9..78039cb3df30a3df7049dbd45332fa981412a8b0 100644 --- a/inc/getdocument.php +++ b/inc/getdocument.php @@ -41,30 +41,5 @@ function erreur_upload_trop_gros() { exit; } -// -// Gestion des fichiers ZIP -// -// http://doc.spip.org/@accepte_fichier_upload -/* -function accepte_fichier_upload ($f) { - if (!preg_match(",.*__MACOSX/,", $f) - AND !preg_match(",^\.,", basename($f))) { - $ext = corriger_extension((strtolower(substr(strrchr($f, "."), 1)))); - return sql_countsel('spip_types_documents', "extension=" . sql_quote($ext) . " AND upload='oui'"); - } -} -*/ -# callback pour le deballage d'un zip telecharge -# http://www.phpconcept.net/pclzip/man/en/?options-pclzip_cb_pre_extractfunction -// http://doc.spip.org/@callback_deballe_fichier -/* -function callback_deballe_fichier($p_event, &$p_header) { - if (accepte_fichier_upload($p_header['filename'])) { - $p_header['filename'] = _tmp_dir . basename($p_header['filename']); - return 1; - } else { - return 0; - } -} -*/ + ?> diff --git a/inc/joindre_document.php b/inc/joindre_document.php index 0171c7131fc5b955b924de6fa1d67ace42098351..e334cdae1a109cde37e03fb31c573c25c889a926 100644 --- a/inc/joindre_document.php +++ b/inc/joindre_document.php @@ -238,7 +238,7 @@ function joindre_decrire_contenu_zip($zip) { $fichiers = array(); $erreurs = array(); foreach ($list as $file) { - if (is_array(verifier_upload_autorise($f = $file['stored_filename']))) + if (accepte_fichier_upload($f = $file['stored_filename'])) $fichiers[$f] = $file; else // pas de message pour les dossiers et fichiers caches @@ -298,4 +298,32 @@ function fixer_extension_document($doc) { return array($extension,$name); } } + +// +// Gestion des fichiers ZIP +// +// http://doc.spip.org/@accepte_fichier_upload + +function accepte_fichier_upload ($f) { + if (!preg_match(",.*__MACOSX/,", $f) + AND !preg_match(",^\.,", basename($f))) { + include_spip('action/ajouter_documents'); + $ext = corriger_extension((strtolower(substr(strrchr($f, "."), 1)))); + return sql_countsel('spip_types_documents', "extension=" . sql_quote($ext) . " AND upload='oui'"); + } +} + +# callback pour le deballage d'un zip telecharge +# http://www.phpconcept.net/pclzip/man/en/?options-pclzip_cb_pre_extractfunction +// http://doc.spip.org/@callback_deballe_fichier + +function callback_deballe_fichier($p_event, &$p_header) { + if (accepte_fichier_upload($p_header['filename'])) { + $p_header['filename'] = _tmp_dir . basename($p_header['filename']); + return 1; + } else { + return 0; + } +} + ?> \ No newline at end of file