Browse Source

Avant de d'utiliser un readdir(), il faut toujours verifier que le résultat de la fonction opendir() est une ressource valide.

Nettoyage du code pour enlever les '@' inutiles devant opendir()
svn/root/tags/spip-3.2-alpha-1
Gilles Vincent 6 years ago
parent
commit
74251660e2
  1. 2
      ecrire/action/calculer_taille_cache.php
  2. 2
      ecrire/exec/admin_plugin.php
  3. 19
      ecrire/inc/documents.php
  4. 2
      ecrire/inc/flock.php
  5. 2
      ecrire/inc/install.php
  6. 6
      ecrire/inc/invalideur.php
  7. 2
      ecrire/inc/plugin.php
  8. 36
      ecrire/maj/svn10000.php
  9. 2
      ecrire/public/composer.php
  10. 2
      prive/formulaires/declarer_bases.php

2
ecrire/action/calculer_taille_cache.php

@ -75,7 +75,7 @@ function action_calculer_taille_cache_dist($arg = null) {
* @return int Taille en octets
*/
function calculer_taille_dossier($dir) {
$handle = @opendir($dir);
$handle = opendir($dir);
if (!$handle) {
return 0;
}

2
ecrire/exec/admin_plugin.php

@ -297,7 +297,7 @@ function liste_librairies() {
$libs = array();
foreach (array_reverse(creer_chemin()) as $d) {
if (is_dir($dir = $d . 'lib/')
and $t = @opendir($dir)
and $t = opendir($dir)
) {
while (($f = readdir($t)) !== false) {
if ($f[0] != '.'

19
ecrire/inc/documents.php

@ -100,15 +100,16 @@ function creer_repertoire_documents($ext) {
* @param string $nom
*/
function effacer_repertoire_temporaire($nom) {
$d = opendir($nom);
while (($f = readdir($d)) !== false) {
if (is_file("$nom/$f")) {
spip_unlink("$nom/$f");
} else {
if ($f <> '.' and $f <> '..'
and is_dir("$nom/$f")
) {
effacer_repertoire_temporaire("$nom/$f");
if ($d = opendir($nom)) {
while (($f = readdir($d)) !== false) {
if (is_file("$nom/$f")) {
spip_unlink("$nom/$f");
} else {
if ($f <> '.' and $f <> '..'
and is_dir("$nom/$f")
) {
effacer_repertoire_temporaire("$nom/$f");
}
}
}
}

2
ecrire/inc/flock.php

@ -673,7 +673,7 @@ function preg_files($dir, $pattern = -1 /* AUTO */, $maxfiles = 10000, $recurs =
$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 && ($nbfiles < $maxfiles)) {
if ($f[0] != '.' # ignorer . .. .svn etc
and $f != 'CVS'

2
ecrire/inc/install.php

@ -354,7 +354,7 @@ function fieldset_champs($champs = array()) {
function install_select_serveur() {
$options = array();
$dir = _DIR_RESTREINT . 'req/';
$d = @opendir($dir);
$d = opendir($dir);
if (!$d) {
return array();
}

6
ecrire/inc/invalideur.php

@ -50,7 +50,7 @@ if (!defined('_AGE_CACHE_ATIME')) {
function nombre_de_fichiers_repertoire($dir, $nb_estim_taille = 20) {
$taille = 0; // mesurer la taille de N fichiers au hasard dans le repertoire
$nb = $nb_estim_taille;
if (!$h = @opendir($dir)) {
if (!$h = opendir($dir)) {
return false;
}
$total = 0;
@ -84,7 +84,7 @@ function taille_du_cache() {
$time = $GLOBALS['meta']['cache_mark'];
for ($i=0; $i < 256; $i++) {
$dir = _DIR_CACHE.sprintf('%02s', dechex($i));
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) {
if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) AND $a = stat("$dir/$f")) {
$n++;
@ -178,7 +178,7 @@ function suivre_invalideur($cond, $modif = true) {
* Nombre de fichiers supprimés
**/
function purger_repertoire($dir, $options = array()) {
$handle = @opendir($dir);
$handle = opendir($dir);
if (!$handle) {
return;
}

2
ecrire/inc/plugin.php

@ -76,7 +76,7 @@ function fast_find_plugin_dirs($dir, $max_prof = 100) {
}
$subdirs = array();
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) {
if ($f[0] != '.' # ignorer . .. .svn etc
and $f != 'CVS'

36
ecrire/maj/svn10000.php

@ -654,11 +654,12 @@ $GLOBALS['maj'][19268] = array(
**/
function supprimer_toutes_sessions() {
spip_log("supprimer sessions auteur");
$dir = opendir(_DIR_SESSIONS);
while (($f = readdir($dir)) !== false) {
spip_unlink(_DIR_SESSIONS . $f);
if (time() >= _TIME_OUT) {
return;
if ($dir = opendir(_DIR_SESSIONS)) {
while (($f = readdir($dir)) !== false) {
spip_unlink(_DIR_SESSIONS . $f);
if (time() >= _TIME_OUT) {
return;
}
}
}
}
@ -674,18 +675,19 @@ $GLOBALS['maj'][21676] = array(
function ranger_cache_gd2() {
spip_log("ranger_cache_gd2");
$base = _DIR_VAR . "cache-gd2/";
$dir = opendir($base);
while (($f = readdir($dir)) !== false) {
if (!is_dir($base . $f) and strncmp($f, ".", 1) !== 0
and preg_match(",[0-9a-f]{32}\.\w+,", $f)
) {
$sub = substr($f, 0, 2);
$sub = sous_repertoire($base, $sub);
@rename($base . $f, $sub . substr($f, 2));
@unlink($base . $f); // au cas ou le rename a foire (collision)
}
if (time() >= _TIME_OUT) {
return;
if ($dir = opendir($base)) {
while (($f = readdir($dir)) !== false) {
if (!is_dir($base . $f) and strncmp($f, ".", 1) !== 0
and preg_match(",[0-9a-f]{32}\.\w+,", $f)
) {
$sub = substr($f, 0, 2);
$sub = sous_repertoire($base, $sub);
@rename($base . $f, $sub . substr($f, 2));
@unlink($base . $f); // au cas ou le rename a foire (collision)
}
if (time() >= _TIME_OUT) {
return;
}
}
}
}

2
ecrire/public/composer.php

@ -550,7 +550,7 @@ function lister_objets_avec_logos($type) {
. join('|', $GLOBALS['formats_logos'])
. ")$/";
if ($d = @opendir(_DIR_LOGOS)) {
if ($d = opendir(_DIR_LOGOS)) {
while (($f = readdir($d)) !== false) {
if (preg_match($type, $f, $r)) {
$logos[] = $r[1];

2
prive/formulaires/declarer_bases.php

@ -56,7 +56,7 @@ function formulaires_declarer_bases_charger_dist() {
function liste_serveurs() {
$options = array();
$dir = _DIR_RESTREINT . 'req/';
$d = @opendir($dir);
$d = opendir($dir);
if (!$d) {
return array();
}

Loading…
Cancel
Save