Skip to content
Extraits de code Groupes Projets
Valider ffbd9f0e rédigé par Fil's avatar Fil
Parcourir les fichiers

bug sur recursivite dans preg_files + utiliser preg_files pour l'upload de logo

parent 30b6488b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -197,8 +197,11 @@ function preg_files($dir, $pattern=-1 /* AUTO */ ) { ...@@ -197,8 +197,11 @@ function preg_files($dir, $pattern=-1 /* AUTO */ ) {
if ($pattern == -1) if ($pattern == -1)
$pattern = "^$dir"; $pattern = "^$dir";
$fichiers = array(); $fichiers = array();
// A quoi sert cette ligne?
// $dir = preg_replace(',/[^/]*$,', '', $dir); // revenir au repertoire racine si on a recu dossier/truc
// pour regarder dossier/truc/ ne pas oublier le / final
$dir = preg_replace(',/[^/]*$,', '', $dir);
if ($dir == '') $dir = '.';
if (@is_dir($dir) AND is_readable($dir) AND $d = @opendir($dir)) { if (@is_dir($dir) AND is_readable($dir) AND $d = @opendir($dir)) {
while (($f = readdir($d)) !== false) { while (($f = readdir($d)) !== false) {
...@@ -211,7 +214,7 @@ function preg_files($dir, $pattern=-1 /* AUTO */ ) { ...@@ -211,7 +214,7 @@ function preg_files($dir, $pattern=-1 /* AUTO */ ) {
$fichiers[] = "$dir/$f"; $fichiers[] = "$dir/$f";
} else if (is_dir("$dir/$f")) { } else if (is_dir("$dir/$f")) {
$beginning = $fichiers; $beginning = $fichiers;
$end = preg_files("$dir/$f", $pattern); $end = preg_files("$dir/$f/", $pattern);
$fichiers = array_merge((array)$beginning, (array)$end); $fichiers = array_merge((array)$beginning, (array)$end);
} }
} }
......
...@@ -117,19 +117,14 @@ function afficher_logo($racine, $titre, $logo, $redirect) { ...@@ -117,19 +117,14 @@ function afficher_logo($racine, $titre, $logo, $redirect) {
_T('bouton_telecharger'), _T('bouton_telecharger'),
"' class='fondo' style='font-size:9px' /></div>"; "' class='fondo' style='font-size:9px' /></div>";
$afficher = ""; $afficher = "";
if ($GLOBALS['flag_upload']) { if ($GLOBALS['flag_upload']
if (@is_dir(_DIR_TRANSFERT) AND is_readable(_DIR_TRANSFERT)) { AND $fichiers = preg_files(_DIR_TRANSFERT, '[.](gif|jpg|png)$')) {
$myDir = opendir(_DIR_TRANSFERT); foreach ($fichiers as $f) {
while(($entryName = readdir($myDir)) !== false){ $f = substr($f, strlen(_DIR_TRANSFERT));
if (!ereg("^\.",$entryName) AND eregi("(gif|jpg|png)$",$entryName)){ $afficher .= "\n<option value='$f'>$f</option>";
$entryName = addslashes($entryName); }
$afficher .= "\n<option value='$entryName'>$entryName</option>";
}
}
closedir($myDir);
} else
spip_log("repertoire "._DIR_TRANSFERT." absent ou illisible");
} }
if (!$afficher) { if (!$afficher) {
echo _T('info_installer_images_dossier', echo _T('info_installer_images_dossier',
array('upload' => '<b>' . _DIR_TRANSFERT . '</b>')); array('upload' => '<b>' . _DIR_TRANSFERT . '</b>'));
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter