From e456ce76dbc04dfed8a95c7c3805f6311640b1a2 Mon Sep 17 00:00:00 2001 From: Fil <fil@rezo.net> Date: Wed, 11 Jan 2006 14:22:44 +0000 Subject: [PATCH] =?UTF-8?q?mettre=20le=20chemin=20vers=20les=20dirs=20des?= =?UTF-8?q?=20plugins=20activ=C3=A9s=20dans=20le=20PATH=20et=20gestion=20u?= =?UTF-8?q?n=20peu=20diff=C3=A9rente=20des=20pages=20priv=C3=A9es=20des=20?= =?UTF-8?q?plugins=20(cf.=20=5Fplugins=5F/rien/=20sur=20SPIP-Zone)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecrire/inc.php3 | 36 +++++++++++------------------------- ecrire/inc_utils.php | 32 ++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/ecrire/inc.php3 b/ecrire/inc.php3 index 7b671975ef..d258bbe1fd 100644 --- a/ecrire/inc.php3 +++ b/ecrire/inc.php3 @@ -137,31 +137,17 @@ if (!isset($reinstall)) { } } -### CAS SPECIAL : on a recupere un appel a un plugin -### ecrire/?plugin=forms&page=forms_edit -$var_f = ''; - -if ($plug = $_GET['plugin']) { - if (!in_array($plug, $plugins)) { - ## envoyer sur la page de configuration des plugins ?? - die ("Le plugin '".htmlspecialchars($plug)."' n'est pas activé, ou inexistant."); - } - if (preg_match(',^[0-9a-z_]*$,i', $_GET['page']) - AND ( - file_exists($f = _DIR_PLUGINS.$plug.'/ecrire/'.$_GET['page'].'.php') - OR file_exists($f = _DIR_PLUGINS.$plug.'/ecrire/index.php') - )) { - include_ecrire("inc_presentation"); - include($f); - } else { - die ("Le plugin '".htmlspecialchars($plug)."' n'a pas d'interface utilisateur."); - } -} -### cas general: on passe la main a la page demandee dans ecrire/ -else { - $var_f = include_fonction($SCRIPT_NAME); - $var_f(); -} +// +// Determiner la fonction qui fabriquera la page demandee, et l'appeler +// + +## temporaire en attendant un truc general qui evitera $SCRIPT_NAME +if ($_GET['page'] AND +preg_match(',^[0-9a-z_]*$,i', $_GET['page'])) + $SCRIPT_NAME = $_GET['page']; + +$var_f = include_fonction($SCRIPT_NAME); +$var_f(); ?> diff --git a/ecrire/inc_utils.php b/ecrire/inc_utils.php index 75af597f80..1211f6188a 100644 --- a/ecrire/inc_utils.php +++ b/ecrire/inc_utils.php @@ -539,23 +539,35 @@ function texte_script($texte) { // function find_in_path ($filename, $path='AUTO') { + static $autopath; + // Chemin standard depuis l'espace public if ($path == 'AUTO') { - $path = _SPIP_PATH; - if ($GLOBALS['dossier_squelettes']) - $path = $GLOBALS['dossier_squelettes'].'/:'.$path; + if (!$autopath) { + $autopath = _SPIP_PATH; + // Ajouter les repertoires des plugins + foreach ($GLOBALS['plugins'] as $plug) + $autopath = _DIR_PLUGINS.$plug.'/:'.$autopath; + + if ($GLOBALS['dossier_squelettes']) + $autopath = $GLOBALS['dossier_squelettes'].'/:'.$autopath; + } + $path = $autopath; } +#spip_log("path = $path"); // Parcourir le chemin foreach (split(':', $path) as $dir) { - // Depuis l'espace prive, remonter d'un cran, sauf pour les absolus - $racine = ($dir[0]=='/') ? '' : _DIR_RACINE; - if ($dir[0] == '.') $dir = ""; - 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)) { + // Depuis l'espace prive, remonter d'un cran, sauf pour : + // - les absolus (/) ; - les locaux (./) ; les remontees (../) + $racine = preg_match('@^([.]{0,2}/)@', $dir) ? '' : _DIR_RACINE; + // ajouter un / eventuellement manquant + if (substr($dir,_1) <> '/') + $dir .= "/"; +#spip_log("find_in_path: essai $racine $dir $filename"); + if (@is_readable($f = "$racine$dir$filename")) { + #spip_log("trouve $f"); return $f; } } -- GitLab