diff --git a/ecrire/inc.php3 b/ecrire/inc.php3 index 7b671975ef0ed8a7a7b26d33e2d25f5ffb006b05..d258bbe1fd3b31e7ab97e1460e449fedd4f0609b 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 75af597f80c2398237e72cfe47b728cd5178a053..1211f6188ad0af0a6e94f132b85af1a4a8f7e56b 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; } }