X-Git-Url: http://git.cyclocoop.org/?p=lhc%2Fweb%2Fclavette_www.git;a=blobdiff_plain;f=www%2Fecrire%2Fpublic%2Fevaluer_page.php;h=49c7090df4353eb483bffc7da61de93c4e258de0;hp=85f56110975ccd168cadc12d08291c906f6cf317;hb=cc641eb476987612f6d6df1a5417c1c5582a8ab8;hpb=7d84a490677fb716a1fd4df260f8eab35f6a8506 diff --git a/www/ecrire/public/evaluer_page.php b/www/ecrire/public/evaluer_page.php index 85f5611..49c7090 100644 --- a/www/ecrire/public/evaluer_page.php +++ b/www/ecrire/public/evaluer_page.php @@ -3,7 +3,7 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2014 * + * Copyright (c) 2001-2016 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -52,8 +52,43 @@ if ($page['process_ins'] != 'html') { if (strpos($page['texte'],'?xml')!==false) $page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']); - $res = eval('?' . '>' . $page['texte']); - $page['texte'] = ob_get_contents(); + try { + $res = eval('?' . '>' . $page['texte']); + // error catching 5.2<=PHP<7 + if ($res === false + and function_exists('error_get_last') + and ($erreur = error_get_last()) ) { + $code = $page['texte']; + $GLOBALS['numero_ligne_php'] = 1; + if (!function_exists('numerote_ligne_php')){ + function numerote_ligne_php($match){ + $GLOBALS['numero_ligne_php']++; + return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; + } + } + $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); + $code = trim(highlight_string($code,true)); + erreur_squelette("L".$erreur['line'].": ".$erreur['message']."
".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); + $page['texte'] = ""; + } + else { + $page['texte'] = ob_get_contents(); + } + } + catch (Exception $e){ + $code = $page['texte']; + $GLOBALS['numero_ligne_php'] = 1; + if (!function_exists('numerote_ligne_php')){ + function numerote_ligne_php($match){ + $GLOBALS['numero_ligne_php']++; + return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; + } + } + $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); + $code = trim(highlight_string($code,true)); + erreur_squelette("L".$e->getLine().": ".$e->getMessage()."
".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang'])); + $page['texte'] = ""; + } ob_end_clean(); $page['process_ins'] = 'html';