Browse Source

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

svn/root/tags/spip-1.9.1i
Fil 16 years ago
parent
commit
ffbd9f0e68
  1. 9
      ecrire/inc_flock.php
  2. 19
      ecrire/inc_logos.php

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

19
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>'));

Loading…
Cancel
Save