X-Git-Url: http://git.cyclocoop.org/?p=ptitvelo%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Fpublic%2Fsandbox.php;h=a742c234ac622e9783c8f06cac7e0c88f21c9326;hp=8f3cb75aa6b4dacab14efa69a24fd94790e430ba;hb=e847eea4a82a7396dd0abf860f9b30d654f38629;hpb=d686c3e22e97dd46ef42bcd0f138c65083f8f232 diff --git a/www/ecrire/public/sandbox.php b/www/ecrire/public/sandbox.php index 8f3cb75..a742c23 100644 --- a/www/ecrire/public/sandbox.php +++ b/www/ecrire/public/sandbox.php @@ -48,7 +48,16 @@ function sandbox_composer_filtre($fonc, $code, $arglist, &$p){ // le filtre est defini sous forme de fonction ou de methode // par ex. dans inc_texte, inc_filtres ou mes_fonctions elseif ($f = chercher_filtre($fonc)) { - $code = "$f($code$arglist)"; + // cas particulier : le filtre |set doit acceder a la $Pile + // proto: filtre_set(&$Pile, $val, $args...) + $refl = new ReflectionFunction($f); + $refs = $refl->getParameters(); + if (isset($refs[0]) AND $refs[0]->name == 'Pile') { + $code = "$f(\$Pile,$code$arglist)"; + } + else { + $code = "$f($code$arglist)"; + } } // le filtre n'existe pas, // on le notifie @@ -59,9 +68,13 @@ function sandbox_composer_filtre($fonc, $code, $arglist, &$p){ // Calculer un // La constante ci-dessous donne le code general quand il s'agit d'un script. -define('CODE_INCLURE_SCRIPT', 'if (($path = %s) AND is_readable($path)) { -include $path; -} else erreur_squelette(array("fichier_introuvable", array("fichier" => "%s")), array(%s));' +define('CODE_INCLURE_SCRIPT', 'if (!($path = %s) OR !is_readable($path)) + erreur_squelette(array("fichier_introuvable", array("fichier" => "%s")), array(%s)); +else { + $contexte_inclus = %s; + include $path; +} +' ); /** @@ -69,16 +82,17 @@ include $path; * * @param string $fichier * @param Object $p + * @param array $_contexte * @return string */ -function sandbox_composer_inclure_php($fichier, &$p){ +function sandbox_composer_inclure_php($fichier, &$p, $_contexte){ $compil = texte_script(memoriser_contexte_compil($p)); // si inexistant, on essaiera a l'execution if ($path = find_in_path($fichier)) $path = "\"$path\""; else $path = "find_in_path(\"$fichier\")"; - return sprintf(CODE_INCLURE_SCRIPT, $path, $fichier, $compil); + return sprintf(CODE_INCLURE_SCRIPT, $path, $fichier, $compil, $_contexte); } /**