3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2019 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) {
18 * Evaluer la page produite par un squelette
20 * Évalue une page pour la transformer en texte statique
21 * Elle peut contenir un < ?xml a securiser avant eval
22 * ou du php d'origine inconnue
24 * Attention cette partie eval() doit impérativement
25 * être déclenchée dans l'espace des globales (donc pas
33 // Cas d'une page contenant du PHP :
34 if (empty($page['process_ins']) or $page['process_ins'] != 'html') {
36 include_spip('inc/lang');
38 // restaurer l'etat des notes avant calcul
39 if (isset($page['notes'])
41 and $notes = charger_fonction("notes", "inc", true)
43 $notes($page['notes'], 'restaurer_etat');
46 if (strpos($page['texte'], '?xml') !== false) {
47 $page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']);
51 $res = eval('?' . '>' . $page['texte']);
52 // error catching 5.2<=PHP<7
54 and function_exists('error_get_last')
55 and ($erreur = error_get_last()) ) {
56 $code = $page['texte'];
57 $GLOBALS['numero_ligne_php'] = 1;
58 if (!function_exists('numerote_ligne_php')){
59 function numerote_ligne_php($match){
60 $GLOBALS['numero_ligne_php']++
;
61 return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT
)."*/";
64 $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code);
65 $code = trim(highlight_string($code,true));
66 erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang']));
67 $page['texte'] = "<!-- Erreur -->";
70 $page['texte'] = ob_get_contents();
74 $code = $page['texte'];
75 $GLOBALS['numero_ligne_php'] = 1;
76 if (!function_exists('numerote_ligne_php')){
77 function numerote_ligne_php($match){
78 $GLOBALS['numero_ligne_php']++
;
79 return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT
)."*/";
82 $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code);
83 $code = trim(highlight_string($code,true));
84 erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang']));
85 $page['texte'] = "<!-- Erreur -->";
89 $page['process_ins'] = 'html';
91 if (strpos($page['texte'], '?xml') !== false) {
92 $page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']);
96 page_base_href($page['texte']);