X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fecrire%2Fpublic%2Fsandbox.php;h=79169297b5d689c8e80c6593855d1126fec9f951;hb=1cd23582fed8f669ccf8246eb120237731da3db0;hp=3de0a7bdea90ea7cf764b19e5900f9f348de05e5;hpb=a9541742f84ce7e258d46dd8407242289ab2ec72;p=lhc%2Fweb%2Fwww.git diff --git a/www/ecrire/public/sandbox.php b/www/ecrire/public/sandbox.php index 3de0a7bd..79169297 100644 --- a/www/ecrire/public/sandbox.php +++ b/www/ecrire/public/sandbox.php @@ -3,7 +3,7 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2012 * + * Copyright (c) 2001-2014 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -59,9 +59,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 +73,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); } /**