diff --git a/ecrire/inc_flock.php b/ecrire/inc_flock.php index 02cc579265ec1a478b0a4300d77b1999f4ea3190..63617ea6b5bb622a376bdda96af956814e195b90 100644 --- a/ecrire/inc_flock.php +++ b/ecrire/inc_flock.php @@ -197,8 +197,11 @@ function preg_files($dir, $pattern=-1 /* AUTO */ ) { if ($pattern == -1) $pattern = "^$dir"; $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)) { while (($f = readdir($d)) !== false) { @@ -211,7 +214,7 @@ function preg_files($dir, $pattern=-1 /* AUTO */ ) { $fichiers[] = "$dir/$f"; } else if (is_dir("$dir/$f")) { $beginning = $fichiers; - $end = preg_files("$dir/$f", $pattern); + $end = preg_files("$dir/$f/", $pattern); $fichiers = array_merge((array)$beginning, (array)$end); } } diff --git a/ecrire/inc_logos.php b/ecrire/inc_logos.php index 4234588ad697328b2a0d909ddd77596ad6f38143..9fd416d404d7d2c5130969a62f1e1a55fb21666e 100644 --- a/ecrire/inc_logos.php +++ b/ecrire/inc_logos.php @@ -117,19 +117,14 @@ function afficher_logo($racine, $titre, $logo, $redirect) { _T('bouton_telecharger'), "' class='fondo' style='font-size:9px' /></div>"; $afficher = ""; - if ($GLOBALS['flag_upload']) { - if (@is_dir(_DIR_TRANSFERT) AND is_readable(_DIR_TRANSFERT)) { - $myDir = opendir(_DIR_TRANSFERT); - while(($entryName = readdir($myDir)) !== false){ - if (!ereg("^\.",$entryName) AND eregi("(gif|jpg|png)$",$entryName)){ - $entryName = addslashes($entryName); - $afficher .= "\n<option value='$entryName'>$entryName</option>"; - } - } - closedir($myDir); - } else - spip_log("repertoire "._DIR_TRANSFERT." absent ou illisible"); + if ($GLOBALS['flag_upload'] + AND $fichiers = preg_files(_DIR_TRANSFERT, '[.](gif|jpg|png)$')) { + foreach ($fichiers as $f) { + $f = substr($f, strlen(_DIR_TRANSFERT)); + $afficher .= "\n<option value='$f'>$f</option>"; + } } + if (!$afficher) { echo _T('info_installer_images_dossier', array('upload' => '<b>' . _DIR_TRANSFERT . '</b>'));