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

virer le ./ au niveau de find_in_path plutot que include_local

parent c68f66ed
Branches
Étiquettes
Aucune requête de fusion associée trouvée
...@@ -18,16 +18,15 @@ if (defined("_ECRIRE_INC_VERSION")) return; ...@@ -18,16 +18,15 @@ if (defined("_ECRIRE_INC_VERSION")) return;
$included_files = array(); $included_files = array();
function include_local($file) { function include_local($file, $silence=false) {
$nom = preg_replace("/\.php3?$/",'', $file); $nom = preg_replace("/\.php3?$/",'', $file);
$nom = preg_replace(",^./,",'', $nom); # spip_log("$nom $file");
spip_log("$nom $file");
if (@$GLOBALS['included_files'][$nom]++) return; if (@$GLOBALS['included_files'][$nom]++) return;
if (is_readable($f = $nom . '.php')) if (is_readable($f = $nom . '.php'))
include($f); include($f);
else if (is_readable($f = $nom . '.php3')) else if (is_readable($f = $nom . '.php3'))
include($f); include($f);
else spip_log($file . " illisible"); else if (!$silence) spip_log($file . " illisible");
} }
function include_ecrire($file) { function include_ecrire($file) {
...@@ -44,7 +43,7 @@ function include_fonction($nom) { ...@@ -44,7 +43,7 @@ function include_fonction($nom) {
define_once('_DIR_INCLUDE', _DIR_RESTREINT); define_once('_DIR_INCLUDE', _DIR_RESTREINT);
$nom = preg_replace("/\.php3?$/",'', basename($nom)); $nom = preg_replace("/\.php3?$/",'', basename($nom));
$inc = ('inc_' . $nom); $inc = ('inc_' . $nom);
spip_log("if $inc"); # spip_log("if $inc");
$f = find_in_path($inc . '.php'); $f = find_in_path($inc . '.php');
if ($f && is_readable($f)) { if ($f && is_readable($f)) {
if (!$GLOBALS['included_files'][$inc]++) include($f); if (!$GLOBALS['included_files'][$inc]++) include($f);
...@@ -514,15 +513,17 @@ function find_in_path ($filename, $path='AUTO') { ...@@ -514,15 +513,17 @@ function find_in_path ($filename, $path='AUTO') {
$path = $GLOBALS['dossier_squelettes'].'/:'.$path; $path = $GLOBALS['dossier_squelettes'].'/:'.$path;
} }
// Depuis l'espace prive, remonter d'un cran
$racine = (_DIR_RESTREINT ? '' : '../'); $racine = (_DIR_RESTREINT ? '' : '../');
// Parcourir le chemin // Parcourir le chemin
foreach (split(':', $path) as $dir) { foreach (split(':', $path) as $dir) {
if (substr($dir, 0,1)<>'/') $dir = "$racine$dir"; // Depuis l'espace prive, remonter d'un cran, sauf pour les absolus
if (substr($dir, -1,1)<>'/') $dir .= "/"; $racine = ($dir[0] <> '/' && !_DIR_RESTREINT) ? '../' : '';
$f = "$dir$filename"; if ($dir[0] == '.') $dir = "";
# spip_log("find_in_path: essai $f"); else if ($dir && $dir[strlen($dir)-1] <> '/') $dir .= "/";
$f = "$racine$dir$filename";
# spip_log("find_in_path: essai $racine $dir $filename");
if (@is_readable($f)) { if (@is_readable($f)) {
return $f; return $f;
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter