From 38a4ffd44d4e06f15beed5e9fabe0dc4874dae45 Mon Sep 17 00:00:00 2001 From: "maieul@maieul.net" <> Date: Sun, 11 Dec 2016 21:04:05 +0000 Subject: [PATCH] =?UTF-8?q?Pour=20le=20moment=20il=20n'existe=20pas=20de?= =?UTF-8?q?=20saisie=20input=20qui=20permette=20d'envoyer=20un=20tableau.?= =?UTF-8?q?=20Par=20cons=C3=A9quent=20le=20.yaml=20ne=20permet=20pas=20de?= =?UTF-8?q?=20remplir=20le=20tableau=20d'option=20de=20v=C3=A9rification?= =?UTF-8?q?=20selon=20un=20sch=C3=A9ma=20'dimension=5Fmax'=3D>array(=20=20?= =?UTF-8?q?=20'hauteur'=3D>une=5Fhauteur,=20=20=20'largeur'=3D>une=5Flarge?= =?UTF-8?q?ur=20)=20En=20cons=C3=A9quence,=20on=20modifier=20l=C3=A9g?= =?UTF-8?q?=C3=A8rement=20la=20saisie=20v=C3=A9rifier=20pour=20permettre?= =?UTF-8?q?=20de=20passer=20"=C3=A0=20plat"=20les=20r=C3=A9glages=20de=20v?= =?UTF-8?q?=C3=A9rification=20de=20dimension=20sous=20la=20forme=20'hauteu?= =?UTF-8?q?r=5Fmax'=3D>une=5Fhauteur,=20'largeur=5Fmax'=3D>une=5Flargeur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- verifier/fichiers.php | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/verifier/fichiers.php b/verifier/fichiers.php index fbbffed..9a76f7b 100755 --- a/verifier/fichiers.php +++ b/verifier/fichiers.php @@ -19,7 +19,11 @@ if (!defined("_ECRIRE_INC_VERSION")) { * - dimension_max, tableau contenant les dimension max: * - largeur (en px) * - hauteur (en px) - * - autoriser_rotation : boolean à mettre à true si on autorise une image qui tiendrait dans ces dimensions si on faisait une rotation de 90° + * - autoriser_rotation : booléen à mettre à true (ou bien string égale à 'on') si on autorise une image qui tiendrait dans ces dimensions si on faisait une rotation de 90° + * - on peut remplacer ce tableau par des strings directement dans $options: + * - largeur_max + * - hauteur_max + * - autoriser_rotation * @param array|string &$erreurs_par_fichier * Si on vérifier un upload multiple, un tableau, passé par référence, qui contient le détail des erreurs fichier de $_FILES['fichier'] par fichier * Si on vérifie un upload unique, une chaîne qui contiendra l'erreur du fichier. @@ -34,6 +38,32 @@ function verifier_fichiers_dist($valeur, $options, &$erreurs_par_fichier) { } } + // normalisation de $options + if (isset($options['largeur_max']) and !isset($options['dimension_max']['largeur'])) { + if (!isset($options['dimension_max'])) { + $options['dimension_max'] = array(); + } + $options['dimension_max']['largeur'] = $options['largeur_max']; + unset($options['largeur_max']); + } + if (isset($options['hauteur_max']) and !isset($options['dimension_max']['hauteur'])) { + if (!isset($options['dimension_max'])) { + $options['dimension_max'] = array(); + } + $options['dimension_max']['hauteur'] = $options['hauteur_max']; + unset($options['hauteur_max']); + } + if (isset($options['dimension_autoriser_rotation']) and !isset($options['dimension_max']['autoriser_rotation'])) { + if (!isset($options['dimension_max'])) { + $options['dimension_max'] = array(); + } + $options['dimension_max']['autoriser_rotation'] = $options['dimension_autoriser_rotation']; + unset($options['dimension_autoriser_rotation']); + } + if (isset($options['dimension_max']['autoriser_rotation']) and $options['dimension_max']['autoriser_rotation'] == 'on') { + $options['dimension_max']['autoriser_rotation'] = True; + } + // Vérification proprement dite foreach ($valeur['tmp_name'] as $cle=>$tmp_name){//On parcourt tous les fichiers if ($valeur['error'][$cle]!=0){//On vérifie uniquement les fichiers bien expediés continue; -- GitLab