@@ -53,12 +53,12 @@ discard block  | 
                                                    ||
| 53 | 53 |  	if (strlen($dossier) and substr($dossier, -1) != '/') { | 
                                                        
| 54 | 54 | $dossier .= '/';  | 
                                                        
| 55 | 55 | }  | 
                                                        
| 56 | -	$f = str_replace('/', '_', $dossier) . $nom; | 
                                                        |
| 56 | +	$f = str_replace('/', '_', $dossier).$nom; | 
                                                        |
| 57 | 57 | |
| 58 | 58 |  	if (function_exists($f)) { | 
                                                        
| 59 | 59 | return $f;  | 
                                                        
| 60 | 60 | }  | 
                                                        
| 61 | -	if (function_exists($g = $f . '_dist')) { | 
                                                        |
| 61 | +	if (function_exists($g = $f.'_dist')) { | 
                                                        |
| 62 | 62 | return $g;  | 
                                                        
| 63 | 63 | }  | 
                                                        
| 64 | 64 | |
@@ -78,7 +78,7 @@ discard block  | 
                                                    ||
| 78 | 78 | |
| 79 | 79 | // passer en minuscules (cf les balises de formulaires)  | 
                                                        
| 80 | 80 | // et inclure le fichier  | 
                                                        
| 81 | - if (!$inc = include_spip($dossier . ($d = strtolower($nom)))  | 
                                                        |
| 81 | + if (!$inc = include_spip($dossier.($d = strtolower($nom)))  | 
                                                        |
| 82 | 82 | // si le fichier truc/machin/nom.php n'existe pas,  | 
                                                        
| 83 | 83 | // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions  | 
                                                        
| 84 | 84 | and strlen(dirname($dossier)) and dirname($dossier) != '.'  | 
                                                        
@@ -97,13 +97,13 @@ discard block  | 
                                                    ||
| 97 | 97 | }  | 
                                                        
| 98 | 98 | |
| 99 | 99 | // Echec : message d'erreur  | 
                                                        
| 100 | -	spip_log("fonction $nom ($f ou $g) indisponible" . | 
                                                        |
| 100 | +	spip_log("fonction $nom ($f ou $g) indisponible". | 
                                                        |
| 101 | 101 | ($inc ? "" : " (fichier $d absent de $dossier)"));  | 
                                                        
| 102 | 102 | |
| 103 | 103 |  	include_spip('inc/minipres'); | 
                                                        
| 104 | 104 |  	echo minipres(_T('forum_titre_erreur'), | 
                                                        
| 105 | -		_T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), | 
                                                        |
| 106 | -		array('all_inline'=>true,'status'=>404)); | 
                                                        |
| 105 | +		_T('fichier_introuvable', array('fichier' => '<b>'.spip_htmlentities($d).'</b>')), | 
                                                        |
| 106 | +		array('all_inline'=>true, 'status'=>404)); | 
                                                        |
| 107 | 107 | exit;  | 
                                                        
| 108 | 108 | }  | 
                                                        
| 109 | 109 | |
@@ -148,7 +148,7 @@ discard block  | 
                                                    ||
| 148 | 148 | * - string : chemin du fichier trouvé  | 
                                                        
| 149 | 149 | **/  | 
                                                        
| 150 | 150 |  function include_spip($f, $include = true) { | 
                                                        
| 151 | - return find_in_path($f . '.php', '', $include);  | 
                                                        |
| 151 | + return find_in_path($f.'.php', '', $include);  | 
                                                        |
| 152 | 152 | }  | 
                                                        
| 153 | 153 | |
| 154 | 154 | /**  | 
                                                        
@@ -168,7 +168,7 @@ discard block  | 
                                                    ||
| 168 | 168 | * - string : chemin du fichier trouvé  | 
                                                        
| 169 | 169 | **/  | 
                                                        
| 170 | 170 |  function require_spip($f) { | 
                                                        
| 171 | - return find_in_path($f . '.php', '', 'required');  | 
                                                        |
| 171 | + return find_in_path($f.'.php', '', 'required');  | 
                                                        |
| 172 | 172 | }  | 
                                                        
| 173 | 173 | |
| 174 | 174 | /**  | 
                                                        
@@ -260,7 +260,7 @@ discard block  | 
                                                    ||
| 260 | 260 | }  | 
                                                        
| 261 | 261 | |
| 262 | 262 | // appliquer notre fonction si elle existe  | 
                                                        
| 263 | - $fonc = 'execute_pipeline_' . strtolower($action);  | 
                                                        |
| 263 | + $fonc = 'execute_pipeline_'.strtolower($action);  | 
                                                        |
| 264 | 264 |  	if (function_exists($fonc)) { | 
                                                        
| 265 | 265 | $val = $fonc($val);  | 
                                                        
| 266 | 266 | } // plantage ?  | 
                                                        
@@ -324,7 +324,7 @@ discard block  | 
                                                    ||
| 324 | 324 |  function spip_log($message = null, $name = null) { | 
                                                        
| 325 | 325 | static $pre = array();  | 
                                                        
| 326 | 326 | static $log;  | 
                                                        
| 327 | -	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); | 
                                                        |
| 327 | +	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs); | 
                                                        |
| 328 | 328 |  	if (!isset($regs[1]) or !$logname = $regs[1]) { | 
                                                        
| 329 | 329 | $logname = null;  | 
                                                        
| 330 | 330 | }  | 
                                                        
@@ -349,7 +349,7 @@ discard block  | 
                                                    ||
| 349 | 349 |  		if (!is_string($message)) { | 
                                                        
| 350 | 350 | $message = print_r($message, true);  | 
                                                        
| 351 | 351 | }  | 
                                                        
| 352 | - $log($pre[$niveau] . ' ' . $message, $logname);  | 
                                                        |
| 352 | + $log($pre[$niveau].' '.$message, $logname);  | 
                                                        |
| 353 | 353 | }  | 
                                                        
| 354 | 354 | }  | 
                                                        
| 355 | 355 | |
@@ -512,7 +512,7 @@ discard block  | 
                                                    ||
| 512 | 512 | $a = './';  | 
                                                        
| 513 | 513 | }  | 
                                                        
| 514 | 514 | |
| 515 | -	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; | 
                                                        |
| 515 | +	$regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,'; | 
                                                        |
| 516 | 516 |  	$ajouts = array_flip(explode('|', $c)); | 
                                                        
| 517 | 517 | $u = is_array($v) ? $v : rawurlencode($v);  | 
                                                        
| 518 | 518 | $testv = (is_array($v) ? count($v) : strlen($v));  | 
                                                        
@@ -539,7 +539,7 @@ discard block  | 
                                                    ||
| 539 | 539 | // Ajout. Pour une variable, remplacer au meme endroit,  | 
                                                        
| 540 | 540 | // pour un tableau ce sera fait dans la prochaine boucle  | 
                                                        
| 541 | 541 |  			elseif (substr($r[1], -2) != '[]') { | 
                                                        
| 542 | - $url[$n] = $r[1] . '=' . $u;  | 
                                                        |
| 542 | + $url[$n] = $r[1].'='.$u;  | 
                                                        |
| 543 | 543 | unset($ajouts[$r[1]]);  | 
                                                        
| 544 | 544 | }  | 
                                                        
| 545 | 545 | // Pour les tableaux on laisse tomber les valeurs de  | 
                                                        
@@ -559,11 +559,11 @@ discard block  | 
                                                    ||
| 559 | 559 |  	} elseif ($testv) { | 
                                                        
| 560 | 560 |  		foreach ($ajouts as $k => $n) { | 
                                                        
| 561 | 561 |  			if (!is_array($v)) { | 
                                                        
| 562 | - $url[] = $k . '=' . $u;  | 
                                                        |
| 562 | + $url[] = $k.'='.$u;  | 
                                                        |
| 563 | 563 |  			} else { | 
                                                        
| 564 | - $id = (substr($k, -2) == '[]') ? $k : ($k . "[]");  | 
                                                        |
| 564 | + $id = (substr($k, -2) == '[]') ? $k : ($k."[]");  | 
                                                        |
| 565 | 565 |  				foreach ($v as $w) { | 
                                                        
| 566 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : $w);  | 
                                                        |
| 566 | + $url[] = $id.'='.(is_array($w) ? 'Array' : $w);  | 
                                                        |
| 567 | 567 | }  | 
                                                        
| 568 | 568 | }  | 
                                                        
| 569 | 569 | }  | 
                                                        
@@ -574,10 +574,10 @@ discard block  | 
                                                    ||
| 574 | 574 | |
| 575 | 575 | // recomposer l'adresse  | 
                                                        
| 576 | 576 |  	if ($url) { | 
                                                        
| 577 | - $a .= '?' . join($sep, $url);  | 
                                                        |
| 577 | + $a .= '?'.join($sep, $url);  | 
                                                        |
| 578 | 578 | }  | 
                                                        
| 579 | 579 | |
| 580 | - return $a . $ancre;  | 
                                                        |
| 580 | + return $a.$ancre;  | 
                                                        |
| 581 | 581 | }  | 
                                                        
| 582 | 582 | |
| 583 | 583 | /**  | 
                                                        
@@ -609,7 +609,7 @@ discard block  | 
                                                    ||
| 609 | 609 | translitteration($ancre)  | 
                                                        
| 610 | 610 | );  | 
                                                        
| 611 | 611 | }  | 
                                                        
| 612 | - return $url . (strlen($ancre) ? '#' . $ancre : '');  | 
                                                        |
| 612 | + return $url.(strlen($ancre) ? '#'.$ancre : '');  | 
                                                        |
| 613 | 613 | }  | 
                                                        
| 614 | 614 | |
| 615 | 615 | /**  | 
                                                        
@@ -718,7 +718,7 @@ discard block  | 
                                                    ||
| 718 | 718 | * @return bool  | 
                                                        
| 719 | 719 | */  | 
                                                        
| 720 | 720 |  function test_plugin_actif($plugin) { | 
                                                        
| 721 | -	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; | 
                                                        |
| 721 | +	return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false; | 
                                                        |
| 722 | 722 | }  | 
                                                        
| 723 | 723 | |
| 724 | 724 | /**  | 
                                                        
@@ -786,8 +786,7 @@ discard block  | 
                                                    ||
| 786 | 786 | // pour les chaines non traduites, assurer un service minimum  | 
                                                        
| 787 | 787 |  		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { | 
                                                        
| 788 | 788 |  			$text = str_replace('_', ' ', | 
                                                        
| 789 | - (($n = strpos($text, ':')) === false ? $texte :  | 
                                                        |
| 790 | - substr($texte, $n + 1)));  | 
                                                        |
| 789 | + (($n = strpos($text, ':')) === false ? $texte : substr($texte, $n + 1)));  | 
                                                        |
| 791 | 790 | }  | 
                                                        
| 792 | 791 | $o['class'] = null;  | 
                                                        
| 793 | 792 | |
@@ -860,7 +859,7 @@ discard block  | 
                                                    ||
| 860 | 859 | // Si des variables n'ont pas ete inserees, le signaler  | 
                                                        
| 861 | 860 | // (chaines de langues pas a jour)  | 
                                                        
| 862 | 861 |  		if ($args) { | 
                                                        
| 863 | -			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); | 
                                                        |
| 862 | +			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG); | 
                                                        |
| 864 | 863 | }  | 
                                                        
| 865 | 864 | }  | 
                                                        
| 866 | 865 | |
@@ -884,7 +883,7 @@ discard block  | 
                                                    ||
| 884 | 883 |  function joli_repertoire($rep) { | 
                                                        
| 885 | 884 | $a = substr($rep, 0, 1);  | 
                                                        
| 886 | 885 |  	if ($a <> '.' and $a <> '/') { | 
                                                        
| 887 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;  | 
                                                        |
| 886 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;  | 
                                                        |
| 888 | 887 | }  | 
                                                        
| 889 | 888 |  	$rep = preg_replace(',(^\.\.\/),', '', $rep); | 
                                                        
| 890 | 889 | |
@@ -938,7 +937,7 @@ discard block  | 
                                                    ||
| 938 | 937 | $p -= ($x * 1000);  | 
                                                        
| 939 | 938 | }  | 
                                                        
| 940 | 939 | |
| 941 | - return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);  | 
                                                        |
| 940 | + return $s.sprintf($s ? "%07.3f ms" : "%.3f ms", $p);  | 
                                                        |
| 942 | 941 | }  | 
                                                        
| 943 | 942 | }  | 
                                                        
| 944 | 943 | |
@@ -1007,7 +1006,7 @@ discard block  | 
                                                    ||
| 1007 | 1006 |  	if ($taches and count($taches) and !spip_connect()) { | 
                                                        
| 1008 | 1007 | return false;  | 
                                                        
| 1009 | 1008 | }  | 
                                                        
| 1010 | -	spip_log("cron !", 'jq' . _LOG_DEBUG); | 
                                                        |
| 1009 | +	spip_log("cron !", 'jq'._LOG_DEBUG); | 
                                                        |
| 1011 | 1010 |  	if ($genie = charger_fonction('genie', 'inc', true)) { | 
                                                        
| 1012 | 1011 | return $genie($taches);  | 
                                                        
| 1013 | 1012 | }  | 
                                                        
@@ -1111,7 +1110,7 @@ discard block  | 
                                                    ||
| 1111 | 1110 | |
| 1112 | 1111 |  	if ($queue_next_job_time == -1) { | 
                                                        
| 1113 | 1112 |  		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { | 
                                                        
| 1114 | -			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); | 
                                                        |
| 1113 | +			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP."job_queue_next.txt"); | 
                                                        |
| 1115 | 1114 | }  | 
                                                        
| 1116 | 1115 | // utiliser un cache memoire si dispo  | 
                                                        
| 1117 | 1116 |  		if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { | 
                                                        
@@ -1178,8 +1177,8 @@ discard block  | 
                                                    ||
| 1178 | 1177 | $src = '';  | 
                                                        
| 1179 | 1178 | }  | 
                                                        
| 1180 | 1179 |  	if ($script) { | 
                                                        
| 1181 | -		$script = ("/*<![CDATA[*/\n" . | 
                                                        |
| 1182 | -			preg_replace(',</([^>]*)>,', '<\/\1>', $script) . | 
                                                        |
| 1180 | +		$script = ("/*<![CDATA[*/\n". | 
                                                        |
| 1181 | +			preg_replace(',</([^>]*)>,', '<\/\1>', $script). | 
                                                        |
| 1183 | 1182 | "/*]]>*/");  | 
                                                        
| 1184 | 1183 | }  | 
                                                        
| 1185 | 1184 |  	if ($noscript) { | 
                                                        
@@ -1265,13 +1264,13 @@ discard block  | 
                                                    ||
| 1265 | 1264 |  	if ($path_base == null) { | 
                                                        
| 1266 | 1265 | // Chemin standard depuis l'espace public  | 
                                                        
| 1267 | 1266 |  		$path = defined('_SPIP_PATH') ? _SPIP_PATH : | 
                                                        
| 1268 | - _DIR_RACINE . ':' .  | 
                                                        |
| 1269 | - _DIR_RACINE . 'squelettes-dist/:' .  | 
                                                        |
| 1270 | - _DIR_RACINE . 'prive/:' .  | 
                                                        |
| 1267 | + _DIR_RACINE.':'.  | 
                                                        |
| 1268 | + _DIR_RACINE.'squelettes-dist/:'.  | 
                                                        |
| 1269 | + _DIR_RACINE.'prive/:'.  | 
                                                        |
| 1271 | 1270 | _DIR_RESTREINT;  | 
                                                        
| 1272 | 1271 | // Ajouter squelettes/  | 
                                                        
| 1273 | -		if (@is_dir(_DIR_RACINE . 'squelettes')) { | 
                                                        |
| 1274 | - $path = _DIR_RACINE . 'squelettes/:' . $path;  | 
                                                        |
| 1272 | +		if (@is_dir(_DIR_RACINE.'squelettes')) { | 
                                                        |
| 1273 | + $path = _DIR_RACINE.'squelettes/:'.$path;  | 
                                                        |
| 1275 | 1274 | }  | 
                                                        
| 1276 | 1275 |  		foreach (explode(':', $path) as $dir) { | 
                                                        
| 1277 | 1276 |  			if (strlen($dir) and substr($dir, -1) != '/') { | 
                                                        
@@ -1283,7 +1282,7 @@ discard block  | 
                                                    ||
| 1283 | 1282 | // Et le(s) dossier(s) des squelettes nommes  | 
                                                        
| 1284 | 1283 |  		if (strlen($GLOBALS['dossier_squelettes'])) { | 
                                                        
| 1285 | 1284 |  			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { | 
                                                        
| 1286 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');  | 
                                                        |
| 1285 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');  | 
                                                        |
| 1287 | 1286 | }  | 
                                                        
| 1288 | 1287 | }  | 
                                                        
| 1289 | 1288 | $GLOBALS['path_sig'] = md5(serialize($path_full));  | 
                                                        
@@ -1294,7 +1293,7 @@ discard block  | 
                                                    ||
| 1294 | 1293 | |
| 1295 | 1294 |  	if (strlen($dir_path)) { | 
                                                        
| 1296 | 1295 | $tete = "";  | 
                                                        
| 1297 | -		if (reset($path_base) == _DIR_RACINE . 'squelettes/') { | 
                                                        |
| 1296 | +		if (reset($path_base) == _DIR_RACINE.'squelettes/') { | 
                                                        |
| 1298 | 1297 | $tete = array_shift($path_base);  | 
                                                        
| 1299 | 1298 | }  | 
                                                        
| 1300 | 1299 |  		$dirs = array_reverse(explode(':', $dir_path)); | 
                                                        
@@ -1316,7 +1315,7 @@ discard block  | 
                                                    ||
| 1316 | 1315 | // Et le(s) dossier(s) des squelettes nommes  | 
                                                        
| 1317 | 1316 |  	if (strlen($GLOBALS['dossier_squelettes'])) { | 
                                                        
| 1318 | 1317 |  		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { | 
                                                        
| 1319 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');  | 
                                                        |
| 1318 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');  | 
                                                        |
| 1320 | 1319 | }  | 
                                                        
| 1321 | 1320 | }  | 
                                                        
| 1322 | 1321 | |
@@ -1389,7 +1388,7 @@ discard block  | 
                                                    ||
| 1389 | 1388 | return $themefiles["$subdir$file"] = $f;  | 
                                                        
| 1390 | 1389 | }  | 
                                                        
| 1391 | 1390 | }  | 
                                                        
| 1392 | -	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); | 
                                                        |
| 1391 | +	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme'); | 
                                                        |
| 1393 | 1392 | |
| 1394 | 1393 | return $themefiles["$subdir$file"] = "";  | 
                                                        
| 1395 | 1394 | }  | 
                                                        
@@ -1490,8 +1489,8 @@ discard block  | 
                                                    ||
| 1490 | 1489 | return false;  | 
                                                        
| 1491 | 1490 | }  | 
                                                        
| 1492 | 1491 |  		if ($include and !isset($inc[$dirname][$file])) { | 
                                                        
| 1493 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];  | 
                                                        |
| 1494 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;  | 
                                                        |
| 1492 | + include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];  | 
                                                        |
| 1493 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true;  | 
                                                        |
| 1495 | 1494 | }  | 
                                                        
| 1496 | 1495 | |
| 1497 | 1496 | return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];  | 
                                                        
@@ -1504,14 +1503,14 @@ discard block  | 
                                                    ||
| 1504 | 1503 | }  | 
                                                        
| 1505 | 1504 | |
| 1506 | 1505 |  	foreach (creer_chemin() as $dir) { | 
                                                        
| 1507 | -		if (!isset($dirs[$a = $dir . $dirname])) { | 
                                                        |
| 1508 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);  | 
                                                        |
| 1506 | +		if (!isset($dirs[$a = $dir.$dirname])) { | 
                                                        |
| 1507 | + $dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);  | 
                                                        |
| 1509 | 1508 | }  | 
                                                        
| 1510 | 1509 |  		if ($dirs[$a]) { | 
                                                        
| 1511 | -			if (file_exists(_ROOT_CWD . ($a .= $file))) { | 
                                                        |
| 1510 | +			if (file_exists(_ROOT_CWD.($a .= $file))) { | 
                                                        |
| 1512 | 1511 |  				if ($include and !isset($inc[$dirname][$file])) { | 
                                                        
| 1513 | - include_once _ROOT_CWD . $a;  | 
                                                        |
| 1514 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;  | 
                                                        |
| 1512 | + include_once _ROOT_CWD.$a;  | 
                                                        |
| 1513 | + $inc[$dirname][$file] = $inc[''][$dirname.$file] = true;  | 
                                                        |
| 1515 | 1514 | }  | 
                                                        
| 1516 | 1515 |  				if (!defined('_SAUVER_CHEMIN')) { | 
                                                        
| 1517 | 1516 | // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher  | 
                                                        
@@ -1521,7 +1520,7 @@ discard block  | 
                                                    ||
| 1521 | 1520 |  					define('_SAUVER_CHEMIN', true); | 
                                                        
| 1522 | 1521 | }  | 
                                                        
| 1523 | 1522 | |
| 1524 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;  | 
                                                        |
| 1523 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;  | 
                                                        |
| 1525 | 1524 | }  | 
                                                        
| 1526 | 1525 | }  | 
                                                        
| 1527 | 1526 | }  | 
                                                        
@@ -1547,7 +1546,7 @@ discard block  | 
                                                    ||
| 1547 | 1546 |  		define('_SAUVER_CHEMIN', true); | 
                                                        
| 1548 | 1547 | }  | 
                                                        
| 1549 | 1548 | |
| 1550 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;  | 
                                                        |
| 1549 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;  | 
                                                        |
| 1551 | 1550 | }  | 
                                                        
| 1552 | 1551 | |
| 1553 | 1552 |  function clear_path_cache() { | 
                                                        
@@ -1616,12 +1615,12 @@ discard block  | 
                                                    ||
| 1616 | 1615 | // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue  | 
                                                        
| 1617 | 1616 | // on a pas encore inclus flock.php  | 
                                                        
| 1618 | 1617 |  	if (!function_exists('preg_files')) { | 
                                                        
| 1619 | - include_once _ROOT_RESTREINT . 'inc/flock.php';  | 
                                                        |
| 1618 | + include_once _ROOT_RESTREINT.'inc/flock.php';  | 
                                                        |
| 1620 | 1619 | }  | 
                                                        
| 1621 | 1620 | |
| 1622 | 1621 | // Parcourir le chemin  | 
                                                        
| 1623 | 1622 |  	foreach (creer_chemin() as $d) { | 
                                                        
| 1624 | - $f = $d . $dir;  | 
                                                        |
| 1623 | + $f = $d.$dir;  | 
                                                        |
| 1625 | 1624 |  		if (@is_dir($f)) { | 
                                                        
| 1626 | 1625 | $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);  | 
                                                        
| 1627 | 1626 |  			foreach ($liste as $chemin) { | 
                                                        
@@ -1722,7 +1721,7 @@ discard block  | 
                                                    ||
| 1722 | 1721 | return $res;  | 
                                                        
| 1723 | 1722 | }  | 
                                                        
| 1724 | 1723 | // Sinon c'est un raccourci ou compat SPIP < 2  | 
                                                        
| 1725 | -	if (!function_exists($f = 'generer_url_' . $entite)) { | 
                                                        |
| 1724 | +	if (!function_exists($f = 'generer_url_'.$entite)) { | 
                                                        |
| 1726 | 1725 |  		if (!function_exists($f .= '_dist')) { | 
                                                        
| 1727 | 1726 | $f = '';  | 
                                                        
| 1728 | 1727 | }  | 
                                                        
@@ -1731,8 +1730,8 @@ discard block  | 
                                                    ||
| 1731 | 1730 | $url = $f($id, $args, $ancre);  | 
                                                        
| 1732 | 1731 |  		if (strlen($args)) { | 
                                                        
| 1733 | 1732 | $url .= strstr($url, '?')  | 
                                                        
| 1734 | - ? '&' . $args  | 
                                                        |
| 1735 | - : '?' . $args;  | 
                                                        |
| 1733 | + ? '&'.$args  | 
                                                        |
| 1734 | + : '?'.$args;  | 
                                                        |
| 1736 | 1735 | }  | 
                                                        
| 1737 | 1736 | |
| 1738 | 1737 | return $url;  | 
                                                        
@@ -1763,8 +1762,8 @@ discard block  | 
                                                    ||
| 1763 | 1762 |  	include_spip('base/connect_sql'); | 
                                                        
| 1764 | 1763 | $id_type = id_table_objet($entite, $public);  | 
                                                        
| 1765 | 1764 | |
| 1766 | -	return _DIR_RACINE . get_spip_script('./') | 
                                                        |
| 1767 | - . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"  | 
                                                        |
| 1765 | +	return _DIR_RACINE.get_spip_script('./') | 
                                                        |
| 1766 | + . "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"  | 
                                                        |
| 1768 | 1767 | . (!$args ? '' : "&$args")  | 
                                                        
| 1769 | 1768 | . (!$ancre ? '' : "#$ancre");  | 
                                                        
| 1770 | 1769 | }  | 
                                                        
@@ -1916,7 +1915,7 @@ discard block  | 
                                                    ||
| 1916 | 1915 | if (!empty($_SERVER['QUERY_STRING'])  | 
                                                        
| 1917 | 1916 | and !strpos($_SERVER['REQUEST_URI'], '?')  | 
                                                        
| 1918 | 1917 |  			) { | 
                                                        
| 1919 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];  | 
                                                        |
| 1918 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];  | 
                                                        |
| 1920 | 1919 | }  | 
                                                        
| 1921 | 1920 | }  | 
                                                        
| 1922 | 1921 | }  | 
                                                        
@@ -1943,17 +1942,17 @@ discard block  | 
                                                    ||
| 1943 | 1942 |  	list($myself) = explode('?', $myself); | 
                                                        
| 1944 | 1943 | // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte  | 
                                                        
| 1945 | 1944 | // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]  | 
                                                        
| 1946 | -	if (strpos($myself,'://') !== false) { | 
                                                        |
| 1947 | -		$myself = explode('://',$myself); | 
                                                        |
| 1945 | +	if (strpos($myself, '://') !== false) { | 
                                                        |
| 1946 | +		$myself = explode('://', $myself); | 
                                                        |
| 1948 | 1947 | array_shift($myself);  | 
                                                        
| 1949 | -		$myself = implode('://',$myself); | 
                                                        |
| 1950 | -		$myself = explode('/',$myself); | 
                                                        |
| 1948 | +		$myself = implode('://', $myself); | 
                                                        |
| 1949 | +		$myself = explode('/', $myself); | 
                                                        |
| 1951 | 1950 | array_shift($myself);  | 
                                                        
| 1952 | -		$myself = implode('/',$myself); | 
                                                        |
| 1951 | +		$myself = implode('/', $myself); | 
                                                        |
| 1953 | 1952 | }  | 
                                                        
| 1954 | -	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; | 
                                                        |
| 1953 | +	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/'; | 
                                                        |
| 1955 | 1954 | |
| 1956 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');  | 
                                                        |
| 1955 | + $url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');  | 
                                                        |
| 1957 | 1956 | |
| 1958 | 1957 | return $url;  | 
                                                        
| 1959 | 1958 | }  | 
                                                        
@@ -1991,17 +1990,17 @@ discard block  | 
                                                    ||
| 1991 | 1990 | **/  | 
                                                        
| 1992 | 1991 |  function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { | 
                                                        
| 1993 | 1992 |  	if (!$rel) { | 
                                                        
| 1994 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;  | 
                                                        |
| 1993 | + $rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;  | 
                                                        |
| 1995 | 1994 |  	} else { | 
                                                        
| 1996 | 1995 |  		if (!is_string($rel)) { | 
                                                        
| 1997 | 1996 | $rel = _DIR_RESTREINT ? _DIR_RESTREINT :  | 
                                                        
| 1998 | -				('./' . _SPIP_ECRIRE_SCRIPT); | 
                                                        |
| 1997 | +				('./'._SPIP_ECRIRE_SCRIPT); | 
                                                        |
| 1999 | 1998 | }  | 
                                                        
| 2000 | 1999 | }  | 
                                                        
| 2001 | 2000 | |
| 2002 | 2001 |  	list($script, $ancre) = array_pad(explode('#', $script), 2, null); | 
                                                        
| 2003 | 2002 |  	if ($script and ($script <> 'accueil' or $rel)) { | 
                                                        
| 2004 | - $args = "?exec=$script" . (!$args ? '' : "&$args");  | 
                                                        |
| 2003 | + $args = "?exec=$script".(!$args ? '' : "&$args");  | 
                                                        |
| 2005 | 2004 |  	} elseif ($args) { | 
                                                        
| 2006 | 2005 | $args = "?$args";  | 
                                                        
| 2007 | 2006 | }  | 
                                                        
@@ -2009,7 +2008,7 @@ discard block  | 
                                                    ||
| 2009 | 2008 | $args .= "#$ancre";  | 
                                                        
| 2010 | 2009 | }  | 
                                                        
| 2011 | 2010 | |
| 2012 | -	return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); | 
                                                        |
| 2011 | +	return $rel.($no_entities ? $args : str_replace('&', '&', $args)); | 
                                                        |
| 2013 | 2012 | }  | 
                                                        
| 2014 | 2013 | |
| 2015 | 2014 | //  | 
                                                        
@@ -2079,25 +2078,25 @@ discard block  | 
                                                    ||
| 2079 | 2078 |  		if (is_array($args)) { | 
                                                        
| 2080 | 2079 | $r = '';  | 
                                                        
| 2081 | 2080 |  			foreach ($args as $k => $v) { | 
                                                        
| 2082 | - $r .= '&' . $k . '=' . $v;  | 
                                                        |
| 2081 | + $r .= '&'.$k.'='.$v;  | 
                                                        |
| 2083 | 2082 | }  | 
                                                        
| 2084 | 2083 | $args = substr($r, 1);  | 
                                                        
| 2085 | 2084 | }  | 
                                                        
| 2086 | 2085 | $action .=  | 
                                                        
| 2087 | - (strpos($action, '?') !== false ? '&' : '?') . $args;  | 
                                                        |
| 2086 | + (strpos($action, '?') !== false ? '&' : '?').$args;  | 
                                                        |
| 2088 | 2087 | }  | 
                                                        
| 2089 | 2088 |  	if (!$no_entities) { | 
                                                        
| 2090 | 2089 | $action = quote_amp($action);  | 
                                                        
| 2091 | 2090 | }  | 
                                                        
| 2092 | 2091 | |
| 2093 | 2092 | // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide  | 
                                                        
| 2094 | -	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); | 
                                                        |
| 2093 | +	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(",^/[.]/,", "/", "/$action")); | 
                                                        |
| 2095 | 2094 | }  | 
                                                        
| 2096 | 2095 | |
| 2097 | 2096 | // http://code.spip.net/@generer_url_prive  | 
                                                        
| 2098 | 2097 |  function generer_url_prive($script, $args = "", $no_entities = false) { | 
                                                        
| 2099 | 2098 | |
| 2100 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');  | 
                                                        |
| 2099 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');  | 
                                                        |
| 2101 | 2100 | }  | 
                                                        
| 2102 | 2101 | |
| 2103 | 2102 | // Pour les formulaires en methode POST,  | 
                                                        
@@ -2132,8 +2131,7 @@ discard block  | 
                                                    ||
| 2132 | 2131 | . "><div>\n"  | 
                                                        
| 2133 | 2132 | . "<input type='hidden' name='exec' value='$script1' />"  | 
                                                        
| 2134 | 2133 | . $corps  | 
                                                        
| 2135 | - . (!$submit ? '' :  | 
                                                        |
| 2136 | -		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) | 
                                                        |
| 2134 | +	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>")) | 
                                                        |
| 2137 | 2135 | . "</div></form>\n";  | 
                                                        
| 2138 | 2136 | }  | 
                                                        
| 2139 | 2137 | |
@@ -2158,14 +2156,14 @@ discard block  | 
                                                    ||
| 2158 | 2156 |  		? generer_url_ecrire(_request('exec')) | 
                                                        
| 2159 | 2157 | : generer_url_public();  | 
                                                        
| 2160 | 2158 | |
| 2161 | - return "\n<form action='" .  | 
                                                        |
| 2162 | - $h .  | 
                                                        |
| 2163 | - "'" .  | 
                                                        |
| 2164 | - $atts .  | 
                                                        |
| 2165 | - ">\n" .  | 
                                                        |
| 2166 | - "<div>" .  | 
                                                        |
| 2167 | - "\n<input type='hidden' name='action' value='$script' />" .  | 
                                                        |
| 2168 | - $corps .  | 
                                                        |
| 2159 | + return "\n<form action='".  | 
                                                        |
| 2160 | + $h.  | 
                                                        |
| 2161 | + "'".  | 
                                                        |
| 2162 | + $atts.  | 
                                                        |
| 2163 | + ">\n".  | 
                                                        |
| 2164 | + "<div>".  | 
                                                        |
| 2165 | + "\n<input type='hidden' name='action' value='$script' />".  | 
                                                        |
| 2166 | + $corps.  | 
                                                        |
| 2169 | 2167 | "</div></form>";  | 
                                                        
| 2170 | 2168 | }  | 
                                                        
| 2171 | 2169 | |
@@ -2193,7 +2191,7 @@ discard block  | 
                                                    ||
| 2193 | 2191 |  		: generer_url_public('', '', false, false); | 
                                                        
| 2194 | 2192 | $url = parametre_url($url, 'action', $script);  | 
                                                        
| 2195 | 2193 |  	if ($args) { | 
                                                        
| 2196 | -		$url .= quote_amp('&' . $args); | 
                                                        |
| 2194 | +		$url .= quote_amp('&'.$args); | 
                                                        |
| 2197 | 2195 | }  | 
                                                        
| 2198 | 2196 | |
| 2199 | 2197 |  	if ($no_entities) { | 
                                                        
@@ -2243,17 +2241,17 @@ discard block  | 
                                                    ||
| 2243 | 2241 | |
| 2244 | 2242 | // le nom du repertoire plugins/ activables/desactivables  | 
                                                        
| 2245 | 2243 |  	if (!defined('_DIR_PLUGINS')) { | 
                                                        
| 2246 | -		define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); | 
                                                        |
| 2244 | +		define('_DIR_PLUGINS', _DIR_RACINE."plugins/"); | 
                                                        |
| 2247 | 2245 | }  | 
                                                        
| 2248 | 2246 | |
| 2249 | 2247 | // le nom du repertoire des extensions/ permanentes du core, toujours actives  | 
                                                        
| 2250 | 2248 |  	if (!defined('_DIR_PLUGINS_DIST')) { | 
                                                        
| 2251 | -		define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); | 
                                                        |
| 2249 | +		define('_DIR_PLUGINS_DIST', _DIR_RACINE."plugins-dist/"); | 
                                                        |
| 2252 | 2250 | }  | 
                                                        
| 2253 | 2251 | |
| 2254 | 2252 | // le nom du repertoire des librairies  | 
                                                        
| 2255 | 2253 |  	if (!defined('_DIR_LIB')) { | 
                                                        
| 2256 | -		define('_DIR_LIB', _DIR_RACINE . "lib/"); | 
                                                        |
| 2254 | +		define('_DIR_LIB', _DIR_RACINE."lib/"); | 
                                                        |
| 2257 | 2255 | }  | 
                                                        
| 2258 | 2256 | |
| 2259 | 2257 |  	if (!defined('_DIR_IMG')) { | 
                                                        
@@ -2263,29 +2261,29 @@ discard block  | 
                                                    ||
| 2263 | 2261 |  		define('_DIR_LOGOS', $pa); | 
                                                        
| 2264 | 2262 | }  | 
                                                        
| 2265 | 2263 |  	if (!defined('_DIR_IMG_ICONES')) { | 
                                                        
| 2266 | -		define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); | 
                                                        |
| 2264 | +		define('_DIR_IMG_ICONES', _DIR_LOGOS."icones/"); | 
                                                        |
| 2267 | 2265 | }  | 
                                                        
| 2268 | 2266 | |
| 2269 | 2267 |  	if (!defined('_DIR_DUMP')) { | 
                                                        
| 2270 | -		define('_DIR_DUMP', $ti . "dump/"); | 
                                                        |
| 2268 | +		define('_DIR_DUMP', $ti."dump/"); | 
                                                        |
| 2271 | 2269 | }  | 
                                                        
| 2272 | 2270 |  	if (!defined('_DIR_SESSIONS')) { | 
                                                        
| 2273 | -		define('_DIR_SESSIONS', $ti . "sessions/"); | 
                                                        |
| 2271 | +		define('_DIR_SESSIONS', $ti."sessions/"); | 
                                                        |
| 2274 | 2272 | }  | 
                                                        
| 2275 | 2273 |  	if (!defined('_DIR_TRANSFERT')) { | 
                                                        
| 2276 | -		define('_DIR_TRANSFERT', $ti . "upload/"); | 
                                                        |
| 2274 | +		define('_DIR_TRANSFERT', $ti."upload/"); | 
                                                        |
| 2277 | 2275 | }  | 
                                                        
| 2278 | 2276 |  	if (!defined('_DIR_CACHE')) { | 
                                                        
| 2279 | -		define('_DIR_CACHE', $ti . "cache/"); | 
                                                        |
| 2277 | +		define('_DIR_CACHE', $ti."cache/"); | 
                                                        |
| 2280 | 2278 | }  | 
                                                        
| 2281 | 2279 |  	if (!defined('_DIR_CACHE_XML')) { | 
                                                        
| 2282 | -		define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); | 
                                                        |
| 2280 | +		define('_DIR_CACHE_XML', _DIR_CACHE."xml/"); | 
                                                        |
| 2283 | 2281 | }  | 
                                                        
| 2284 | 2282 |  	if (!defined('_DIR_SKELS')) { | 
                                                        
| 2285 | -		define('_DIR_SKELS', _DIR_CACHE . "skel/"); | 
                                                        |
| 2283 | +		define('_DIR_SKELS', _DIR_CACHE."skel/"); | 
                                                        |
| 2286 | 2284 | }  | 
                                                        
| 2287 | 2285 |  	if (!defined('_DIR_AIDE')) { | 
                                                        
| 2288 | -		define('_DIR_AIDE', _DIR_CACHE . "aide/"); | 
                                                        |
| 2286 | +		define('_DIR_AIDE', _DIR_CACHE."aide/"); | 
                                                        |
| 2289 | 2287 | }  | 
                                                        
| 2290 | 2288 |  	if (!defined('_DIR_TMP')) { | 
                                                        
| 2291 | 2289 |  		define('_DIR_TMP', $ti); | 
                                                        
@@ -2315,27 +2313,27 @@ discard block  | 
                                                    ||
| 2315 | 2313 | // Declaration des fichiers  | 
                                                        
| 2316 | 2314 | |
| 2317 | 2315 |  	if (!defined('_CACHE_PLUGINS_PATH')) { | 
                                                        
| 2318 | -		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); | 
                                                        |
| 2316 | +		define('_CACHE_PLUGINS_PATH', _DIR_CACHE."charger_plugins_chemins.php"); | 
                                                        |
| 2319 | 2317 | }  | 
                                                        
| 2320 | 2318 |  	if (!defined('_CACHE_PLUGINS_OPT')) { | 
                                                        
| 2321 | -		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); | 
                                                        |
| 2319 | +		define('_CACHE_PLUGINS_OPT', _DIR_CACHE."charger_plugins_options.php"); | 
                                                        |
| 2322 | 2320 | }  | 
                                                        
| 2323 | 2321 |  	if (!defined('_CACHE_PLUGINS_FCT')) { | 
                                                        
| 2324 | -		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); | 
                                                        |
| 2322 | +		define('_CACHE_PLUGINS_FCT', _DIR_CACHE."charger_plugins_fonctions.php"); | 
                                                        |
| 2325 | 2323 | }  | 
                                                        
| 2326 | 2324 |  	if (!defined('_CACHE_PIPELINES')) { | 
                                                        
| 2327 | -		define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); | 
                                                        |
| 2325 | +		define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php"); | 
                                                        |
| 2328 | 2326 | }  | 
                                                        
| 2329 | 2327 |  	if (!defined('_CACHE_CHEMIN')) { | 
                                                        
| 2330 | -		define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); | 
                                                        |
| 2328 | +		define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt"); | 
                                                        |
| 2331 | 2329 | }  | 
                                                        
| 2332 | 2330 | |
| 2333 | 2331 | # attention .php obligatoire pour ecrire_fichier_securise  | 
                                                        
| 2334 | 2332 |  	if (!defined('_FILE_META')) { | 
                                                        
| 2335 | -		define('_FILE_META', $ti . 'meta_cache.php'); | 
                                                        |
| 2333 | +		define('_FILE_META', $ti.'meta_cache.php'); | 
                                                        |
| 2336 | 2334 | }  | 
                                                        
| 2337 | 2335 |  	if (!defined('_DIR_LOG')) { | 
                                                        
| 2338 | -		define('_DIR_LOG', _DIR_TMP . 'log/'); | 
                                                        |
| 2336 | +		define('_DIR_LOG', _DIR_TMP.'log/'); | 
                                                        |
| 2339 | 2337 | }  | 
                                                        
| 2340 | 2338 |  	if (!defined('_FILE_LOG')) { | 
                                                        
| 2341 | 2339 |  		define('_FILE_LOG', 'spip'); | 
                                                        
@@ -2351,8 +2349,8 @@ discard block  | 
                                                    ||
| 2351 | 2349 | }  | 
                                                        
| 2352 | 2350 |  	if (!defined('_FILE_CONNECT')) { | 
                                                        
| 2353 | 2351 |  		define('_FILE_CONNECT', | 
                                                        
| 2354 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f  | 
                                                        |
| 2355 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f  | 
                                                        |
| 2352 | + (@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f  | 
                                                        |
| 2353 | + : (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f  | 
                                                        |
| 2356 | 2354 | : false)));  | 
                                                        
| 2357 | 2355 | }  | 
                                                        
| 2358 | 2356 | |
@@ -2362,7 +2360,7 @@ discard block  | 
                                                    ||
| 2362 | 2360 | }  | 
                                                        
| 2363 | 2361 |  	if (!defined('_FILE_CHMOD')) { | 
                                                        
| 2364 | 2362 |  		define('_FILE_CHMOD', | 
                                                        
| 2365 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f  | 
                                                        |
| 2363 | + (@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f  | 
                                                        |
| 2366 | 2364 | : false));  | 
                                                        
| 2367 | 2365 | }  | 
                                                        
| 2368 | 2366 | |
@@ -2374,10 +2372,10 @@ discard block  | 
                                                    ||
| 2374 | 2372 |  		define('_FILE_TMP_SUFFIX', '.tmp.php'); | 
                                                        
| 2375 | 2373 | }  | 
                                                        
| 2376 | 2374 |  	if (!defined('_FILE_CONNECT_TMP')) { | 
                                                        
| 2377 | -		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); | 
                                                        |
| 2375 | +		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX); | 
                                                        |
| 2378 | 2376 | }  | 
                                                        
| 2379 | 2377 |  	if (!defined('_FILE_CHMOD_TMP')) { | 
                                                        
| 2380 | -		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); | 
                                                        |
| 2378 | +		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX); | 
                                                        |
| 2381 | 2379 | }  | 
                                                        
| 2382 | 2380 | |
| 2383 | 2381 | // Definition des droits d'acces en ecriture  | 
                                                        
@@ -2395,13 +2393,13 @@ discard block  | 
                                                    ||
| 2395 | 2393 |  		define('_DEFAULT_CHARSET', 'utf-8'); | 
                                                        
| 2396 | 2394 | }  | 
                                                        
| 2397 | 2395 |  	if (!defined('_ROOT_PLUGINS')) { | 
                                                        
| 2398 | -		define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); | 
                                                        |
| 2396 | +		define('_ROOT_PLUGINS', _ROOT_RACINE."plugins/"); | 
                                                        |
| 2399 | 2397 | }  | 
                                                        
| 2400 | 2398 |  	if (!defined('_ROOT_PLUGINS_DIST')) { | 
                                                        
| 2401 | -		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); | 
                                                        |
| 2399 | +		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE."plugins-dist/"); | 
                                                        |
| 2402 | 2400 | }  | 
                                                        
| 2403 | 2401 |  	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { | 
                                                        
| 2404 | -		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); | 
                                                        |
| 2402 | +		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); | 
                                                        |
| 2405 | 2403 | }  | 
                                                        
| 2406 | 2404 | |
| 2407 | 2405 | // La taille des Log  | 
                                                        
@@ -2438,7 +2436,7 @@ discard block  | 
                                                    ||
| 2438 | 2436 | // (non surchargeable en l'etat ; attention si on utilise include_spip()  | 
                                                        
| 2439 | 2437 | // pour le rendre surchargeable, on va provoquer un reecriture  | 
                                                        
| 2440 | 2438 | // systematique du noyau ou une baisse de perfs => a etudier)  | 
                                                        
| 2441 | - include_once _ROOT_RESTREINT . 'inc/flock.php';  | 
                                                        |
| 2439 | + include_once _ROOT_RESTREINT.'inc/flock.php';  | 
                                                        |
| 2442 | 2440 | |
| 2443 | 2441 | // charger tout de suite le path et son cache  | 
                                                        
| 2444 | 2442 | load_path_cache();  | 
                                                        
@@ -2485,7 +2483,7 @@ discard block  | 
                                                    ||
| 2485 | 2483 | if (!empty($_SERVER['QUERY_STRING'])  | 
                                                        
| 2486 | 2484 | and !strpos($_SERVER['REQUEST_URI'], '?')  | 
                                                        
| 2487 | 2485 |  		) { | 
                                                        
| 2488 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];  | 
                                                        |
| 2486 | + $GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];  | 
                                                        |
| 2489 | 2487 | }  | 
                                                        
| 2490 | 2488 | }  | 
                                                        
| 2491 | 2489 | |
@@ -2521,7 +2519,7 @@ discard block  | 
                                                    ||
| 2521 | 2519 | |
| 2522 | 2520 |  			if (isset($GLOBALS['meta']['adresse_site'])) { | 
                                                        
| 2523 | 2521 | $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);  | 
                                                        
| 2524 | - $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';  | 
                                                        |
| 2522 | + $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '').'/';  | 
                                                        |
| 2525 | 2523 |  			} else { | 
                                                        
| 2526 | 2524 | $uri_ref = "";  | 
                                                        
| 2527 | 2525 | }  | 
                                                        
@@ -2609,7 +2607,7 @@ discard block  | 
                                                    ||
| 2609 | 2607 | }  | 
                                                        
| 2610 | 2608 |  	if (!defined('_CACHE_RUBRIQUES')) { | 
                                                        
| 2611 | 2609 | /** Fichier cache pour le navigateur de rubrique du bandeau */  | 
                                                        
| 2612 | -		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); | 
                                                        |
| 2610 | +		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt'); | 
                                                        |
| 2613 | 2611 | }  | 
                                                        
| 2614 | 2612 |  	if (!defined('_CACHE_RUBRIQUES_MAX')) { | 
                                                        
| 2615 | 2613 | /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */  | 
                                                        
@@ -2645,8 +2643,7 @@ discard block  | 
                                                    ||
| 2645 | 2643 | // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)  | 
                                                        
| 2646 | 2644 | // meme pb sur thttpd cf. http://forum.spip.net/fr_184153.html  | 
                                                        
| 2647 | 2645 |  	if (!defined('_SPIP_ECRIRE_SCRIPT')) { | 
                                                        
| 2648 | -		define('_SPIP_ECRIRE_SCRIPT', (empty($_SERVER['SERVER_SOFTWARE']) ? '' : | 
                                                        |
| 2649 | -			preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE']) ? | 
                                                        |
| 2646 | +		define('_SPIP_ECRIRE_SCRIPT', (empty($_SERVER['SERVER_SOFTWARE']) ? '' : preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE']) ? | 
                                                        |
| 2650 | 2647 | 'index.php' : ''));  | 
                                                        
| 2651 | 2648 | }  | 
                                                        
| 2652 | 2649 | |
@@ -2699,7 +2696,7 @@ discard block  | 
                                                    ||
| 2699 | 2696 | $memory *= 1024;  | 
                                                        
| 2700 | 2697 | }  | 
                                                        
| 2701 | 2698 |  			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { | 
                                                        
| 2702 | -				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); | 
                                                        |
| 2699 | +				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M'); | 
                                                        |
| 2703 | 2700 |  				if (trim(ini_get('memory_limit')) != $m) { | 
                                                        
| 2704 | 2701 |  					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { | 
                                                        
| 2705 | 2702 |  						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); | 
                                                        
@@ -2849,7 +2846,7 @@ discard block  | 
                                                    ||
| 2849 | 2846 | }  | 
                                                        
| 2850 | 2847 |  					if (isset($GLOBALS['visiteur_session']['nom'])) { | 
                                                        
| 2851 | 2848 | spip_log($GLOBALS['visiteur_session']['nom']  | 
                                                        
| 2852 | - . " " . _VAR_MODE);  | 
                                                        |
| 2849 | + . " "._VAR_MODE);  | 
                                                        |
| 2853 | 2850 | }  | 
                                                        
| 2854 | 2851 | } // pas autorise ?  | 
                                                        
| 2855 | 2852 |  				else { | 
                                                        
@@ -2857,7 +2854,7 @@ discard block  | 
                                                    ||
| 2857 | 2854 |  					if (!$GLOBALS['visiteur_session']) { | 
                                                        
| 2858 | 2855 |  						include_spip('inc/headers'); | 
                                                        
| 2859 | 2856 |  						redirige_par_entete(generer_url_public('login', | 
                                                        
| 2860 | - 'url=' . rawurlencode(  | 
                                                        |
| 2857 | + 'url='.rawurlencode(  | 
                                                        |
| 2861 | 2858 | parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')  | 
                                                        
| 2862 | 2859 | ), true));  | 
                                                        
| 2863 | 2860 | }  | 
                                                        
@@ -2910,10 +2907,10 @@ discard block  | 
                                                    ||
| 2910 | 2907 | // mais on risque de perturber des plugins en initialisant trop tot  | 
                                                        
| 2911 | 2908 | // certaines constantes  | 
                                                        
| 2912 | 2909 | @spip_initialisation_core(  | 
                                                        
| 2913 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),  | 
                                                        |
| 2914 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),  | 
                                                        |
| 2915 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),  | 
                                                        |
| 2916 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)  | 
                                                        |
| 2910 | + (_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),  | 
                                                        |
| 2911 | + (_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),  | 
                                                        |
| 2912 | + (_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),  | 
                                                        |
| 2913 | + (_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)  | 
                                                        |
| 2917 | 2914 | );  | 
                                                        
| 2918 | 2915 | |
| 2919 | 2916 | // Demarrer une session NON AUTHENTIFIEE si on donne son nom  | 
                                                        
@@ -2946,7 +2943,7 @@ discard block  | 
                                                    ||
| 2946 | 2943 | }  | 
                                                        
| 2947 | 2944 | |
| 2948 | 2945 | $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);  | 
                                                        
| 2949 | -	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { | 
                                                        |
| 2946 | +	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) { | 
                                                        |
| 2950 | 2947 | |
| 2951 | 2948 |  		$session = charger_fonction('session', 'inc'); | 
                                                        
| 2952 | 2949 |  		if ($session()) { | 
                                                        
@@ -3026,7 +3023,7 @@ discard block  | 
                                                    ||
| 3026 | 3023 |  		$s = pipeline('definir_session', | 
                                                        
| 3027 | 3024 | $GLOBALS['visiteur_session']  | 
                                                        
| 3028 | 3025 | ? serialize($GLOBALS['visiteur_session'])  | 
                                                        
| 3029 | - . '_' . @$_COOKIE['spip_session']  | 
                                                        |
| 3026 | + . '_'.@$_COOKIE['spip_session']  | 
                                                        |
| 3030 | 3027 | : ''  | 
                                                        
| 3031 | 3028 | );  | 
                                                        
| 3032 | 3029 | $session = $s ? substr(md5($s), 0, 8) : '';  | 
                                                        
@@ -3172,7 +3169,7 @@ discard block  | 
                                                    ||
| 3172 | 3169 | |
| 3173 | 3170 | // fix #4235  | 
                                                        
| 3174 | 3171 | // On mémorise l'état initial du sessionnement du contexte incluant  | 
                                                        
| 3175 | - $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);  | 
                                                        |
| 3172 | + $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);  | 
                                                        |
| 3176 | 3173 | |
| 3177 | 3174 | |
| 3178 | 3175 |  	foreach (is_array($fond) ? $fond : array($fond) as $f) { | 
                                                        
@@ -3262,7 +3259,7 @@ discard block  | 
                                                    ||
| 3262 | 3259 | * @return array|string  | 
                                                        
| 3263 | 3260 | */  | 
                                                        
| 3264 | 3261 |  function trouver_fond($nom, $dir = '', $pathinfo = false) { | 
                                                        
| 3265 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');  | 
                                                        |
| 3262 | + $f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');  | 
                                                        |
| 3266 | 3263 |  	if (!$pathinfo) { | 
                                                        
| 3267 | 3264 | return $f;  | 
                                                        
| 3268 | 3265 | }  | 
                                                        
@@ -3438,7 +3435,7 @@ discard block  | 
                                                    ||
| 3438 | 3435 | |
| 3439 | 3436 |  			if (!is_array($params[0])) { | 
                                                        
| 3440 | 3437 | trigger_error(  | 
                                                        
| 3441 | - 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',  | 
                                                        |
| 3438 | + 'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given',  | 
                                                        |
| 3442 | 3439 | E_USER_WARNING  | 
                                                        
| 3443 | 3440 | );  | 
                                                        
| 3444 | 3441 | return null;  | 
                                                        
@@ -2305,12 +2305,13 @@ discard block  | 
                                                    ||
| 2305 | 2305 |  		define('_DIR_CHMOD', $pi); | 
                                                        
| 2306 | 2306 | }  | 
                                                        
| 2307 | 2307 | |
| 2308 | - if (!isset($GLOBALS['test_dirs']))  | 
                                                        |
| 2309 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall  | 
                                                        |
| 2308 | +	if (!isset($GLOBALS['test_dirs'])) { | 
                                                        |
| 2309 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall  | 
                                                        |
| 2310 | 2310 | // il sera rajoute automatiquement si besoin a l'etape 2 de l'install  | 
                                                        
| 2311 | 2311 |  	{ | 
                                                        
| 2312 | 2312 | $GLOBALS['test_dirs'] = array($pa, $ti, $ta);  | 
                                                        
| 2313 | 2313 | }  | 
                                                        
| 2314 | + }  | 
                                                        |
| 2314 | 2315 | |
| 2315 | 2316 | // Declaration des fichiers  | 
                                                        
| 2316 | 2317 | |
@@ -3218,8 +3219,9 @@ discard block  | 
                                                    ||
| 3218 | 3219 | |
| 3219 | 3220 | // fix #4235 : contamination de la session appelante, pour les inclusions statiques  | 
                                                        
| 3220 | 3221 | if (isset($options['sessionnement_contaminant'])  | 
                                                        
| 3221 | - and isset($page['invalideurs']['session']))  | 
                                                        |
| 3222 | - $cache_utilise_session_appelant = $page['invalideurs']['session'];  | 
                                                        |
| 3222 | +		    and isset($page['invalideurs']['session'])) { | 
                                                        |
| 3223 | + $cache_utilise_session_appelant = $page['invalideurs']['session'];  | 
                                                        |
| 3224 | + }  | 
                                                        |
| 3223 | 3225 | }  | 
                                                        
| 3224 | 3226 | |
| 3225 | 3227 | // fix #4235 : restaurer le sessionnement du contexte appelant,  | 
                                                        
@@ -17,7 +17,7 @@ discard block  | 
                                                    ||
| 17 | 17 | **/  | 
                                                        
| 18 | 18 | |
| 19 | 19 |  if (!defined('_ECRIRE_INC_VERSION')) { | 
                                                        
| 20 | - return;  | 
                                                        |
| 20 | + return;  | 
                                                        |
| 21 | 21 | }  | 
                                                        
| 22 | 22 | |
| 23 | 23 | |
@@ -48,63 +48,63 @@ discard block  | 
                                                    ||
| 48 | 48 | * Nom de la fonction, ou false.  | 
                                                        
| 49 | 49 | */  | 
                                                        
| 50 | 50 |  function charger_fonction($nom, $dossier = 'exec', $continue = false) { | 
                                                        
| 51 | - static $echecs = array();  | 
                                                        |
| 52 | -  | 
                                                        |
| 53 | -	if (strlen($dossier) and substr($dossier, -1) != '/') { | 
                                                        |
| 54 | - $dossier .= '/';  | 
                                                        |
| 55 | - }  | 
                                                        |
| 56 | -	$f = str_replace('/', '_', $dossier) . $nom; | 
                                                        |
| 57 | -  | 
                                                        |
| 58 | -	if (function_exists($f)) { | 
                                                        |
| 59 | - return $f;  | 
                                                        |
| 60 | - }  | 
                                                        |
| 61 | -	if (function_exists($g = $f . '_dist')) { | 
                                                        |
| 62 | - return $g;  | 
                                                        |
| 63 | - }  | 
                                                        |
| 64 | -  | 
                                                        |
| 65 | -	if (isset($echecs[$f])) { | 
                                                        |
| 66 | - return $echecs[$f];  | 
                                                        |
| 67 | - }  | 
                                                        |
| 68 | - // Sinon charger le fichier de declaration si plausible  | 
                                                        |
| 69 | -  | 
                                                        |
| 70 | -	if (!preg_match(',^\w+$,', $f)) { | 
                                                        |
| 71 | -		if ($continue) { | 
                                                        |
| 72 | - return false;  | 
                                                        |
| 73 | - } //appel interne, on passe  | 
                                                        |
| 74 | -		include_spip('inc/minipres'); | 
                                                        |
| 75 | - echo minipres();  | 
                                                        |
| 76 | - exit;  | 
                                                        |
| 77 | - }  | 
                                                        |
| 78 | -  | 
                                                        |
| 79 | - // passer en minuscules (cf les balises de formulaires)  | 
                                                        |
| 80 | - // et inclure le fichier  | 
                                                        |
| 81 | - if (!$inc = include_spip($dossier . ($d = strtolower($nom)))  | 
                                                        |
| 82 | - // si le fichier truc/machin/nom.php n'existe pas,  | 
                                                        |
| 83 | - // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions  | 
                                                        |
| 84 | - and strlen(dirname($dossier)) and dirname($dossier) != '.'  | 
                                                        |
| 85 | -	) { | 
                                                        |
| 86 | - include_spip(substr($dossier, 0, -1));  | 
                                                        |
| 87 | - }  | 
                                                        |
| 88 | -	if (function_exists($f)) { | 
                                                        |
| 89 | - return $f;  | 
                                                        |
| 90 | - }  | 
                                                        |
| 91 | -	if (function_exists($g)) { | 
                                                        |
| 92 | - return $g;  | 
                                                        |
| 93 | - }  | 
                                                        |
| 94 | -  | 
                                                        |
| 95 | -	if ($continue) { | 
                                                        |
| 96 | - return $echecs[$f] = false;  | 
                                                        |
| 97 | - }  | 
                                                        |
| 98 | -  | 
                                                        |
| 99 | - // Echec : message d'erreur  | 
                                                        |
| 100 | -	spip_log("fonction $nom ($f ou $g) indisponible" . | 
                                                        |
| 101 | - ($inc ? "" : " (fichier $d absent de $dossier)"));  | 
                                                        |
| 102 | -  | 
                                                        |
| 103 | -	include_spip('inc/minipres'); | 
                                                        |
| 104 | -	echo minipres(_T('forum_titre_erreur'), | 
                                                        |
| 105 | -		_T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), | 
                                                        |
| 106 | -		array('all_inline'=>true,'status'=>404)); | 
                                                        |
| 107 | - exit;  | 
                                                        |
| 51 | + static $echecs = array();  | 
                                                        |
| 52 | +  | 
                                                        |
| 53 | +    if (strlen($dossier) and substr($dossier, -1) != '/') { | 
                                                        |
| 54 | + $dossier .= '/';  | 
                                                        |
| 55 | + }  | 
                                                        |
| 56 | +    $f = str_replace('/', '_', $dossier) . $nom; | 
                                                        |
| 57 | +  | 
                                                        |
| 58 | +    if (function_exists($f)) { | 
                                                        |
| 59 | + return $f;  | 
                                                        |
| 60 | + }  | 
                                                        |
| 61 | +    if (function_exists($g = $f . '_dist')) { | 
                                                        |
| 62 | + return $g;  | 
                                                        |
| 63 | + }  | 
                                                        |
| 64 | +  | 
                                                        |
| 65 | +    if (isset($echecs[$f])) { | 
                                                        |
| 66 | + return $echecs[$f];  | 
                                                        |
| 67 | + }  | 
                                                        |
| 68 | + // Sinon charger le fichier de declaration si plausible  | 
                                                        |
| 69 | +  | 
                                                        |
| 70 | +    if (!preg_match(',^\w+$,', $f)) { | 
                                                        |
| 71 | +        if ($continue) { | 
                                                        |
| 72 | + return false;  | 
                                                        |
| 73 | + } //appel interne, on passe  | 
                                                        |
| 74 | +        include_spip('inc/minipres'); | 
                                                        |
| 75 | + echo minipres();  | 
                                                        |
| 76 | + exit;  | 
                                                        |
| 77 | + }  | 
                                                        |
| 78 | +  | 
                                                        |
| 79 | + // passer en minuscules (cf les balises de formulaires)  | 
                                                        |
| 80 | + // et inclure le fichier  | 
                                                        |
| 81 | + if (!$inc = include_spip($dossier . ($d = strtolower($nom)))  | 
                                                        |
| 82 | + // si le fichier truc/machin/nom.php n'existe pas,  | 
                                                        |
| 83 | + // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions  | 
                                                        |
| 84 | + and strlen(dirname($dossier)) and dirname($dossier) != '.'  | 
                                                        |
| 85 | +    ) { | 
                                                        |
| 86 | + include_spip(substr($dossier, 0, -1));  | 
                                                        |
| 87 | + }  | 
                                                        |
| 88 | +    if (function_exists($f)) { | 
                                                        |
| 89 | + return $f;  | 
                                                        |
| 90 | + }  | 
                                                        |
| 91 | +    if (function_exists($g)) { | 
                                                        |
| 92 | + return $g;  | 
                                                        |
| 93 | + }  | 
                                                        |
| 94 | +  | 
                                                        |
| 95 | +    if ($continue) { | 
                                                        |
| 96 | + return $echecs[$f] = false;  | 
                                                        |
| 97 | + }  | 
                                                        |
| 98 | +  | 
                                                        |
| 99 | + // Echec : message d'erreur  | 
                                                        |
| 100 | +    spip_log("fonction $nom ($f ou $g) indisponible" . | 
                                                        |
| 101 | + ($inc ? "" : " (fichier $d absent de $dossier)"));  | 
                                                        |
| 102 | +  | 
                                                        |
| 103 | +    include_spip('inc/minipres'); | 
                                                        |
| 104 | +    echo minipres(_T('forum_titre_erreur'), | 
                                                        |
| 105 | +        _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')), | 
                                                        |
| 106 | +        array('all_inline'=>true,'status'=>404)); | 
                                                        |
| 107 | + exit;  | 
                                                        |
| 108 | 108 | }  | 
                                                        
| 109 | 109 | |
| 110 | 110 | /**  | 
                                                        
@@ -114,17 +114,17 @@ discard block  | 
                                                    ||
| 114 | 114 | * @return bool  | 
                                                        
| 115 | 115 | */  | 
                                                        
| 116 | 116 |  function include_once_check($file) { | 
                                                        
| 117 | -	if (file_exists($file)) { | 
                                                        |
| 118 | - include_once $file;  | 
                                                        |
| 117 | +    if (file_exists($file)) { | 
                                                        |
| 118 | + include_once $file;  | 
                                                        |
| 119 | 119 | |
| 120 | - return true;  | 
                                                        |
| 121 | - }  | 
                                                        |
| 122 | - $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');  | 
                                                        |
| 123 | - $crash = ($crash ? $crash : array());  | 
                                                        |
| 124 | - $crash[$file] = true;  | 
                                                        |
| 125 | -	ecrire_meta('message_crash_plugins', serialize($crash)); | 
                                                        |
| 120 | + return true;  | 
                                                        |
| 121 | + }  | 
                                                        |
| 122 | + $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');  | 
                                                        |
| 123 | + $crash = ($crash ? $crash : array());  | 
                                                        |
| 124 | + $crash[$file] = true;  | 
                                                        |
| 125 | +    ecrire_meta('message_crash_plugins', serialize($crash)); | 
                                                        |
| 126 | 126 | |
| 127 | - return false;  | 
                                                        |
| 127 | + return false;  | 
                                                        |
| 128 | 128 | }  | 
                                                        
| 129 | 129 | |
| 130 | 130 | |
@@ -148,7 +148,7 @@ discard block  | 
                                                    ||
| 148 | 148 | * - string : chemin du fichier trouvé  | 
                                                        
| 149 | 149 | **/  | 
                                                        
| 150 | 150 |  function include_spip($f, $include = true) { | 
                                                        
| 151 | - return find_in_path($f . '.php', '', $include);  | 
                                                        |
| 151 | + return find_in_path($f . '.php', '', $include);  | 
                                                        |
| 152 | 152 | }  | 
                                                        
| 153 | 153 | |
| 154 | 154 | /**  | 
                                                        
@@ -168,7 +168,7 @@ discard block  | 
                                                    ||
| 168 | 168 | * - string : chemin du fichier trouvé  | 
                                                        
| 169 | 169 | **/  | 
                                                        
| 170 | 170 |  function require_spip($f) { | 
                                                        
| 171 | - return find_in_path($f . '.php', '', 'required');  | 
                                                        |
| 171 | + return find_in_path($f . '.php', '', 'required');  | 
                                                        |
| 172 | 172 | }  | 
                                                        
| 173 | 173 | |
| 174 | 174 | /**  | 
                                                        
@@ -194,22 +194,22 @@ discard block  | 
                                                    ||
| 194 | 194 | * Les paramètres du pipeline modifiés  | 
                                                        
| 195 | 195 | **/  | 
                                                        
| 196 | 196 |  function minipipe($fonc, &$val) { | 
                                                        
| 197 | - // fonction  | 
                                                        |
| 198 | -	if (function_exists($fonc)) { | 
                                                        |
| 199 | - $val = call_user_func($fonc, $val);  | 
                                                        |
| 200 | - } // Class::Methode  | 
                                                        |
| 201 | -	else { | 
                                                        |
| 202 | -		if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) | 
                                                        |
| 203 | - and $methode = array($regs[1], $regs[2])  | 
                                                        |
| 204 | - and is_callable($methode)  | 
                                                        |
| 205 | -		) { | 
                                                        |
| 206 | - $val = call_user_func($methode, $val);  | 
                                                        |
| 207 | -		} else { | 
                                                        |
| 208 | -			spip_log("Erreur - '$fonc' non definie !"); | 
                                                        |
| 209 | - }  | 
                                                        |
| 210 | - }  | 
                                                        |
| 197 | + // fonction  | 
                                                        |
| 198 | +    if (function_exists($fonc)) { | 
                                                        |
| 199 | + $val = call_user_func($fonc, $val);  | 
                                                        |
| 200 | + } // Class::Methode  | 
                                                        |
| 201 | +    else { | 
                                                        |
| 202 | +        if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs) | 
                                                        |
| 203 | + and $methode = array($regs[1], $regs[2])  | 
                                                        |
| 204 | + and is_callable($methode)  | 
                                                        |
| 205 | +        ) { | 
                                                        |
| 206 | + $val = call_user_func($methode, $val);  | 
                                                        |
| 207 | +        } else { | 
                                                        |
| 208 | +            spip_log("Erreur - '$fonc' non definie !"); | 
                                                        |
| 209 | + }  | 
                                                        |
| 210 | + }  | 
                                                        |
| 211 | 211 | |
| 212 | - return $val;  | 
                                                        |
| 212 | + return $val;  | 
                                                        |
| 213 | 213 | }  | 
                                                        
| 214 | 214 | |
| 215 | 215 | /**  | 
                                                        
@@ -240,45 +240,45 @@ discard block  | 
                                                    ||
| 240 | 240 | * Résultat  | 
                                                        
| 241 | 241 | */  | 
                                                        
| 242 | 242 |  function pipeline($action, $val = null) { | 
                                                        
| 243 | - static $charger;  | 
                                                        |
| 244 | -  | 
                                                        |
| 245 | - // chargement initial des fonctions mises en cache, ou generation du cache  | 
                                                        |
| 246 | -	if (!$charger) { | 
                                                        |
| 247 | -		if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { | 
                                                        |
| 248 | -			include_spip('inc/plugin'); | 
                                                        |
| 249 | - // generer les fichiers php precompiles  | 
                                                        |
| 250 | - // de chargement des plugins et des pipelines  | 
                                                        |
| 251 | - actualise_plugins_actifs();  | 
                                                        |
| 252 | -			if (!($ok = @is_readable($charger))) { | 
                                                        |
| 253 | -				spip_log("fichier $charger pas cree"); | 
                                                        |
| 254 | - }  | 
                                                        |
| 255 | - }  | 
                                                        |
| 256 | -  | 
                                                        |
| 257 | -		if ($ok) { | 
                                                        |
| 258 | - include_once $charger;  | 
                                                        |
| 259 | - }  | 
                                                        |
| 260 | - }  | 
                                                        |
| 261 | -  | 
                                                        |
| 262 | - // appliquer notre fonction si elle existe  | 
                                                        |
| 263 | - $fonc = 'execute_pipeline_' . strtolower($action);  | 
                                                        |
| 264 | -	if (function_exists($fonc)) { | 
                                                        |
| 265 | - $val = $fonc($val);  | 
                                                        |
| 266 | - } // plantage ?  | 
                                                        |
| 267 | -	else { | 
                                                        |
| 268 | -		spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); | 
                                                        |
| 269 | - }  | 
                                                        |
| 270 | -  | 
                                                        |
| 271 | - // si le flux est une table avec 2 cle args&data  | 
                                                        |
| 272 | - // on ne ressort du pipe que les donnees dans 'data'  | 
                                                        |
| 273 | - // array_key_exists pour php 4.1.0  | 
                                                        |
| 274 | - if (is_array($val)  | 
                                                        |
| 275 | - and count($val) == 2  | 
                                                        |
| 276 | -		and (array_key_exists('data', $val)) | 
                                                        |
| 277 | -	) { | 
                                                        |
| 278 | - $val = $val['data'];  | 
                                                        |
| 279 | - }  | 
                                                        |
| 280 | -  | 
                                                        |
| 281 | - return $val;  | 
                                                        |
| 243 | + static $charger;  | 
                                                        |
| 244 | +  | 
                                                        |
| 245 | + // chargement initial des fonctions mises en cache, ou generation du cache  | 
                                                        |
| 246 | +    if (!$charger) { | 
                                                        |
| 247 | +        if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) { | 
                                                        |
| 248 | +            include_spip('inc/plugin'); | 
                                                        |
| 249 | + // generer les fichiers php precompiles  | 
                                                        |
| 250 | + // de chargement des plugins et des pipelines  | 
                                                        |
| 251 | + actualise_plugins_actifs();  | 
                                                        |
| 252 | +            if (!($ok = @is_readable($charger))) { | 
                                                        |
| 253 | +                spip_log("fichier $charger pas cree"); | 
                                                        |
| 254 | + }  | 
                                                        |
| 255 | + }  | 
                                                        |
| 256 | +  | 
                                                        |
| 257 | +        if ($ok) { | 
                                                        |
| 258 | + include_once $charger;  | 
                                                        |
| 259 | + }  | 
                                                        |
| 260 | + }  | 
                                                        |
| 261 | +  | 
                                                        |
| 262 | + // appliquer notre fonction si elle existe  | 
                                                        |
| 263 | + $fonc = 'execute_pipeline_' . strtolower($action);  | 
                                                        |
| 264 | +    if (function_exists($fonc)) { | 
                                                        |
| 265 | + $val = $fonc($val);  | 
                                                        |
| 266 | + } // plantage ?  | 
                                                        |
| 267 | +    else { | 
                                                        |
| 268 | +        spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR); | 
                                                        |
| 269 | + }  | 
                                                        |
| 270 | +  | 
                                                        |
| 271 | + // si le flux est une table avec 2 cle args&data  | 
                                                        |
| 272 | + // on ne ressort du pipe que les donnees dans 'data'  | 
                                                        |
| 273 | + // array_key_exists pour php 4.1.0  | 
                                                        |
| 274 | + if (is_array($val)  | 
                                                        |
| 275 | + and count($val) == 2  | 
                                                        |
| 276 | +        and (array_key_exists('data', $val)) | 
                                                        |
| 277 | +    ) { | 
                                                        |
| 278 | + $val = $val['data'];  | 
                                                        |
| 279 | + }  | 
                                                        |
| 280 | +  | 
                                                        |
| 281 | + return $val;  | 
                                                        |
| 282 | 282 | }  | 
                                                        
| 283 | 283 | |
| 284 | 284 | /**  | 
                                                        
@@ -322,35 +322,35 @@ discard block  | 
                                                    ||
| 322 | 322 | * paramètre est planté pour cause de compatibilité ascendante.  | 
                                                        
| 323 | 323 | */  | 
                                                        
| 324 | 324 |  function spip_log($message = null, $name = null) { | 
                                                        
| 325 | - static $pre = array();  | 
                                                        |
| 326 | - static $log;  | 
                                                        |
| 327 | -	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); | 
                                                        |
| 328 | -	if (!isset($regs[1]) or !$logname = $regs[1]) { | 
                                                        |
| 329 | - $logname = null;  | 
                                                        |
| 330 | - }  | 
                                                        |
| 331 | -	if (!isset($regs[2]) or !$niveau = $regs[2]) { | 
                                                        |
| 332 | - $niveau = _LOG_INFO;  | 
                                                        |
| 333 | - }  | 
                                                        |
| 334 | -  | 
                                                        |
| 335 | -	if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { | 
                                                        |
| 336 | -		if (!$pre) { | 
                                                        |
| 337 | - $pre = array(  | 
                                                        |
| 338 | - _LOG_HS => 'HS:',  | 
                                                        |
| 339 | - _LOG_ALERTE_ROUGE => 'ALERTE:',  | 
                                                        |
| 340 | - _LOG_CRITIQUE => 'CRITIQUE:',  | 
                                                        |
| 341 | - _LOG_ERREUR => 'ERREUR:',  | 
                                                        |
| 342 | - _LOG_AVERTISSEMENT => 'WARNING:',  | 
                                                        |
| 343 | - _LOG_INFO_IMPORTANTE => '!INFO:',  | 
                                                        |
| 344 | - _LOG_INFO => 'info:',  | 
                                                        |
| 345 | - _LOG_DEBUG => 'debug:'  | 
                                                        |
| 346 | - );  | 
                                                        |
| 347 | -			$log = charger_fonction('log', 'inc'); | 
                                                        |
| 348 | - }  | 
                                                        |
| 349 | -		if (!is_string($message)) { | 
                                                        |
| 350 | - $message = print_r($message, true);  | 
                                                        |
| 351 | - }  | 
                                                        |
| 352 | - $log($pre[$niveau] . ' ' . $message, $logname);  | 
                                                        |
| 353 | - }  | 
                                                        |
| 325 | + static $pre = array();  | 
                                                        |
| 326 | + static $log;  | 
                                                        |
| 327 | +    preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs); | 
                                                        |
| 328 | +    if (!isset($regs[1]) or !$logname = $regs[1]) { | 
                                                        |
| 329 | + $logname = null;  | 
                                                        |
| 330 | + }  | 
                                                        |
| 331 | +    if (!isset($regs[2]) or !$niveau = $regs[2]) { | 
                                                        |
| 332 | + $niveau = _LOG_INFO;  | 
                                                        |
| 333 | + }  | 
                                                        |
| 334 | +  | 
                                                        |
| 335 | +    if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) { | 
                                                        |
| 336 | +        if (!$pre) { | 
                                                        |
| 337 | + $pre = array(  | 
                                                        |
| 338 | + _LOG_HS => 'HS:',  | 
                                                        |
| 339 | + _LOG_ALERTE_ROUGE => 'ALERTE:',  | 
                                                        |
| 340 | + _LOG_CRITIQUE => 'CRITIQUE:',  | 
                                                        |
| 341 | + _LOG_ERREUR => 'ERREUR:',  | 
                                                        |
| 342 | + _LOG_AVERTISSEMENT => 'WARNING:',  | 
                                                        |
| 343 | + _LOG_INFO_IMPORTANTE => '!INFO:',  | 
                                                        |
| 344 | + _LOG_INFO => 'info:',  | 
                                                        |
| 345 | + _LOG_DEBUG => 'debug:'  | 
                                                        |
| 346 | + );  | 
                                                        |
| 347 | +            $log = charger_fonction('log', 'inc'); | 
                                                        |
| 348 | + }  | 
                                                        |
| 349 | +        if (!is_string($message)) { | 
                                                        |
| 350 | + $message = print_r($message, true);  | 
                                                        |
| 351 | + }  | 
                                                        |
| 352 | + $log($pre[$niveau] . ' ' . $message, $logname);  | 
                                                        |
| 353 | + }  | 
                                                        |
| 354 | 354 | }  | 
                                                        
| 355 | 355 | |
| 356 | 356 | /**  | 
                                                        
@@ -361,8 +361,8 @@ discard block  | 
                                                    ||
| 361 | 361 | * @param array $opt Tableau d'options  | 
                                                        
| 362 | 362 | **/  | 
                                                        
| 363 | 363 |  function journal($phrase, $opt = array()) { | 
                                                        
| 364 | -	$journal = charger_fonction('journal', 'inc'); | 
                                                        |
| 365 | - $journal($phrase, $opt);  | 
                                                        |
| 364 | +    $journal = charger_fonction('journal', 'inc'); | 
                                                        |
| 365 | + $journal($phrase, $opt);  | 
                                                        |
| 366 | 366 | }  | 
                                                        
| 367 | 367 | |
| 368 | 368 | |
@@ -381,36 +381,36 @@ discard block  | 
                                                    ||
| 381 | 381 | **/  | 
                                                        
| 382 | 382 |  function _request($var, $c = false) { | 
                                                        
| 383 | 383 | |
| 384 | -	if (is_array($c)) { | 
                                                        |
| 385 | - return isset($c[$var]) ? $c[$var] : null;  | 
                                                        |
| 386 | - }  | 
                                                        |
| 384 | +    if (is_array($c)) { | 
                                                        |
| 385 | + return isset($c[$var]) ? $c[$var] : null;  | 
                                                        |
| 386 | + }  | 
                                                        |
| 387 | 387 | |
| 388 | -	if (isset($_GET[$var])) { | 
                                                        |
| 389 | - $a = $_GET[$var];  | 
                                                        |
| 390 | -	} elseif (isset($_POST[$var])) { | 
                                                        |
| 391 | - $a = $_POST[$var];  | 
                                                        |
| 392 | -	} else { | 
                                                        |
| 393 | - return null;  | 
                                                        |
| 394 | - }  | 
                                                        |
| 388 | +    if (isset($_GET[$var])) { | 
                                                        |
| 389 | + $a = $_GET[$var];  | 
                                                        |
| 390 | +    } elseif (isset($_POST[$var])) { | 
                                                        |
| 391 | + $a = $_POST[$var];  | 
                                                        |
| 392 | +    } else { | 
                                                        |
| 393 | + return null;  | 
                                                        |
| 394 | + }  | 
                                                        |
| 395 | 395 | |
| 396 | - // Si on est en ajax et en POST tout a ete encode  | 
                                                        |
| 397 | - // via encodeURIComponent, il faut donc repasser  | 
                                                        |
| 398 | - // dans le charset local...  | 
                                                        |
| 399 | -	if (defined('_AJAX') | 
                                                        |
| 400 | - and _AJAX  | 
                                                        |
| 401 | - and isset($GLOBALS['meta']['charset'])  | 
                                                        |
| 402 | - and $GLOBALS['meta']['charset'] != 'utf-8'  | 
                                                        |
| 403 | - and is_string($a)  | 
                                                        |
| 404 | - // check rapide mais pas fiable  | 
                                                        |
| 405 | -		and preg_match(',[\x80-\xFF],', $a) | 
                                                        |
| 406 | - // check fiable  | 
                                                        |
| 407 | -		and include_spip('inc/charsets') | 
                                                        |
| 408 | - and is_utf8($a)  | 
                                                        |
| 409 | -	) { | 
                                                        |
| 410 | - return importer_charset($a, 'utf-8');  | 
                                                        |
| 411 | - }  | 
                                                        |
| 396 | + // Si on est en ajax et en POST tout a ete encode  | 
                                                        |
| 397 | + // via encodeURIComponent, il faut donc repasser  | 
                                                        |
| 398 | + // dans le charset local...  | 
                                                        |
| 399 | +    if (defined('_AJAX') | 
                                                        |
| 400 | + and _AJAX  | 
                                                        |
| 401 | + and isset($GLOBALS['meta']['charset'])  | 
                                                        |
| 402 | + and $GLOBALS['meta']['charset'] != 'utf-8'  | 
                                                        |
| 403 | + and is_string($a)  | 
                                                        |
| 404 | + // check rapide mais pas fiable  | 
                                                        |
| 405 | +        and preg_match(',[\x80-\xFF],', $a) | 
                                                        |
| 406 | + // check fiable  | 
                                                        |
| 407 | +        and include_spip('inc/charsets') | 
                                                        |
| 408 | + and is_utf8($a)  | 
                                                        |
| 409 | +    ) { | 
                                                        |
| 410 | + return importer_charset($a, 'utf-8');  | 
                                                        |
| 411 | + }  | 
                                                        |
| 412 | 412 | |
| 413 | - return $a;  | 
                                                        |
| 413 | + return $a;  | 
                                                        |
| 414 | 414 | }  | 
                                                        
| 415 | 415 | |
| 416 | 416 | |
@@ -428,22 +428,22 @@ discard block  | 
                                                    ||
| 428 | 428 | * - false sinon  | 
                                                        
| 429 | 429 | **/  | 
                                                        
| 430 | 430 |  function set_request($var, $val = null, $c = false) { | 
                                                        
| 431 | -	if (is_array($c)) { | 
                                                        |
| 432 | - unset($c[$var]);  | 
                                                        |
| 433 | -		if ($val !== null) { | 
                                                        |
| 434 | - $c[$var] = $val;  | 
                                                        |
| 435 | - }  | 
                                                        |
| 431 | +    if (is_array($c)) { | 
                                                        |
| 432 | + unset($c[$var]);  | 
                                                        |
| 433 | +        if ($val !== null) { | 
                                                        |
| 434 | + $c[$var] = $val;  | 
                                                        |
| 435 | + }  | 
                                                        |
| 436 | 436 | |
| 437 | - return $c;  | 
                                                        |
| 438 | - }  | 
                                                        |
| 437 | + return $c;  | 
                                                        |
| 438 | + }  | 
                                                        |
| 439 | 439 | |
| 440 | - unset($_GET[$var]);  | 
                                                        |
| 441 | - unset($_POST[$var]);  | 
                                                        |
| 442 | -	if ($val !== null) { | 
                                                        |
| 443 | - $_GET[$var] = $val;  | 
                                                        |
| 444 | - }  | 
                                                        |
| 440 | + unset($_GET[$var]);  | 
                                                        |
| 441 | + unset($_POST[$var]);  | 
                                                        |
| 442 | +    if ($val !== null) { | 
                                                        |
| 443 | + $_GET[$var] = $val;  | 
                                                        |
| 444 | + }  | 
                                                        |
| 445 | 445 | |
| 446 | - return false; # n'affecte pas $c  | 
                                                        |
| 446 | + return false; # n'affecte pas $c  | 
                                                        |
| 447 | 447 | }  | 
                                                        
| 448 | 448 | |
| 449 | 449 | |
@@ -452,23 +452,22 @@ discard block  | 
                                                    ||
| 452 | 452 | *  | 
                                                        
| 453 | 453 | * On est sur le web, on exclut certains protocoles,  | 
                                                        
| 454 | 454 | * notamment 'file://', 'php://' et d'autres…  | 
                                                        
| 455 | -  | 
                                                        |
| 456 | 455 | * @param string $url  | 
                                                        
| 457 | 456 | * @return bool  | 
                                                        
| 458 | 457 | */  | 
                                                        
| 459 | 458 |  function tester_url_absolue($url) { | 
                                                        
| 460 | - $url = trim($url);  | 
                                                        |
| 461 | -	if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { | 
                                                        |
| 462 | - if (  | 
                                                        |
| 463 | - isset($m[1])  | 
                                                        |
| 464 | - and $p = strtolower(rtrim($m[1], ':'))  | 
                                                        |
| 465 | -			and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) | 
                                                        |
| 466 | -		  ) { | 
                                                        |
| 467 | - return false;  | 
                                                        |
| 468 | - }  | 
                                                        |
| 469 | - return true;  | 
                                                        |
| 470 | - }  | 
                                                        |
| 471 | - return false;  | 
                                                        |
| 459 | + $url = trim($url);  | 
                                                        |
| 460 | +    if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) { | 
                                                        |
| 461 | + if (  | 
                                                        |
| 462 | + isset($m[1])  | 
                                                        |
| 463 | + and $p = strtolower(rtrim($m[1], ':'))  | 
                                                        |
| 464 | +            and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip')) | 
                                                        |
| 465 | +            ) { | 
                                                        |
| 466 | + return false;  | 
                                                        |
| 467 | + }  | 
                                                        |
| 468 | + return true;  | 
                                                        |
| 469 | + }  | 
                                                        |
| 470 | + return false;  | 
                                                        |
| 472 | 471 | }  | 
                                                        
| 473 | 472 | |
| 474 | 473 | /**  | 
                                                        
@@ -490,94 +489,94 @@ discard block  | 
                                                    ||
| 490 | 489 | * @return string URL  | 
                                                        
| 491 | 490 | */  | 
                                                        
| 492 | 491 |  function parametre_url($url, $c, $v = null, $sep = '&') { | 
                                                        
| 493 | - // requete erronnee : plusieurs variable dans $c et aucun $v  | 
                                                        |
| 494 | -	if (strpos($c, "|") !== false and is_null($v)) { | 
                                                        |
| 495 | - return null;  | 
                                                        |
| 496 | - }  | 
                                                        |
| 497 | -  | 
                                                        |
| 498 | - // lever l'#ancre  | 
                                                        |
| 499 | -	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { | 
                                                        |
| 500 | - $url = $r[1];  | 
                                                        |
| 501 | - $ancre = $r[2];  | 
                                                        |
| 502 | -	} else { | 
                                                        |
| 503 | - $ancre = '';  | 
                                                        |
| 504 | - }  | 
                                                        |
| 505 | -  | 
                                                        |
| 506 | - // eclater  | 
                                                        |
| 507 | -	$url = preg_split(',[?]|&|&,', $url); | 
                                                        |
| 508 | -  | 
                                                        |
| 509 | - // recuperer la base  | 
                                                        |
| 510 | - $a = array_shift($url);  | 
                                                        |
| 511 | -	if (!$a) { | 
                                                        |
| 512 | - $a = './';  | 
                                                        |
| 513 | - }  | 
                                                        |
| 514 | -  | 
                                                        |
| 515 | -	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; | 
                                                        |
| 516 | -	$ajouts = array_flip(explode('|', $c)); | 
                                                        |
| 517 | - $u = is_array($v) ? $v : rawurlencode($v);  | 
                                                        |
| 518 | - $testv = (is_array($v) ? count($v) : strlen($v));  | 
                                                        |
| 519 | - $v_read = null;  | 
                                                        |
| 520 | - // lire les variables et agir  | 
                                                        |
| 521 | -	foreach ($url as $n => $val) { | 
                                                        |
| 522 | -		if (preg_match($regexp, urldecode($val), $r)) { | 
                                                        |
| 523 | - $r = array_pad($r, 3, null);  | 
                                                        |
| 524 | -			if ($v === null) { | 
                                                        |
| 525 | - // c'est un tableau, on memorise les valeurs  | 
                                                        |
| 526 | -				if (substr($r[1], -2) == "[]") { | 
                                                        |
| 527 | -					if (!$v_read) { | 
                                                        |
| 528 | - $v_read = array();  | 
                                                        |
| 529 | - }  | 
                                                        |
| 530 | - $v_read[] = $r[2] ? substr($r[2], 1) : '';  | 
                                                        |
| 531 | - } // c'est un scalaire, on retourne direct  | 
                                                        |
| 532 | -				else { | 
                                                        |
| 533 | - return $r[2] ? substr($r[2], 1) : '';  | 
                                                        |
| 534 | - }  | 
                                                        |
| 535 | - } // suppression  | 
                                                        |
| 536 | -			elseif (!$testv) { | 
                                                        |
| 537 | - unset($url[$n]);  | 
                                                        |
| 538 | - }  | 
                                                        |
| 539 | - // Ajout. Pour une variable, remplacer au meme endroit,  | 
                                                        |
| 540 | - // pour un tableau ce sera fait dans la prochaine boucle  | 
                                                        |
| 541 | -			elseif (substr($r[1], -2) != '[]') { | 
                                                        |
| 542 | - $url[$n] = $r[1] . '=' . $u;  | 
                                                        |
| 543 | - unset($ajouts[$r[1]]);  | 
                                                        |
| 544 | - }  | 
                                                        |
| 545 | - // Pour les tableaux on laisse tomber les valeurs de  | 
                                                        |
| 546 | - // départ, on remplira à l'étape suivante  | 
                                                        |
| 547 | -			else { | 
                                                        |
| 548 | - unset($url[$n]);  | 
                                                        |
| 549 | - }  | 
                                                        |
| 550 | - }  | 
                                                        |
| 551 | - }  | 
                                                        |
| 552 | -  | 
                                                        |
| 553 | - // traiter les parametres pas encore trouves  | 
                                                        |
| 554 | - if ($v === null  | 
                                                        |
| 555 | - and $args = func_get_args()  | 
                                                        |
| 556 | - and count($args) == 2  | 
                                                        |
| 557 | -	) { | 
                                                        |
| 558 | - return $v_read; // rien trouve ou un tableau  | 
                                                        |
| 559 | -	} elseif ($testv) { | 
                                                        |
| 560 | -		foreach ($ajouts as $k => $n) { | 
                                                        |
| 561 | -			if (!is_array($v)) { | 
                                                        |
| 562 | - $url[] = $k . '=' . $u;  | 
                                                        |
| 563 | -			} else { | 
                                                        |
| 564 | - $id = (substr($k, -2) == '[]') ? $k : ($k . "[]");  | 
                                                        |
| 565 | -				foreach ($v as $w) { | 
                                                        |
| 566 | - $url[] = $id . '=' . (is_array($w) ? 'Array' : $w);  | 
                                                        |
| 567 | - }  | 
                                                        |
| 568 | - }  | 
                                                        |
| 569 | - }  | 
                                                        |
| 570 | - }  | 
                                                        |
| 571 | -  | 
                                                        |
| 572 | - // eliminer les vides  | 
                                                        |
| 573 | - $url = array_filter($url);  | 
                                                        |
| 574 | -  | 
                                                        |
| 575 | - // recomposer l'adresse  | 
                                                        |
| 576 | -	if ($url) { | 
                                                        |
| 577 | - $a .= '?' . join($sep, $url);  | 
                                                        |
| 578 | - }  | 
                                                        |
| 579 | -  | 
                                                        |
| 580 | - return $a . $ancre;  | 
                                                        |
| 492 | + // requete erronnee : plusieurs variable dans $c et aucun $v  | 
                                                        |
| 493 | +    if (strpos($c, "|") !== false and is_null($v)) { | 
                                                        |
| 494 | + return null;  | 
                                                        |
| 495 | + }  | 
                                                        |
| 496 | +  | 
                                                        |
| 497 | + // lever l'#ancre  | 
                                                        |
| 498 | +    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { | 
                                                        |
| 499 | + $url = $r[1];  | 
                                                        |
| 500 | + $ancre = $r[2];  | 
                                                        |
| 501 | +    } else { | 
                                                        |
| 502 | + $ancre = '';  | 
                                                        |
| 503 | + }  | 
                                                        |
| 504 | +  | 
                                                        |
| 505 | + // eclater  | 
                                                        |
| 506 | +    $url = preg_split(',[?]|&|&,', $url); | 
                                                        |
| 507 | +  | 
                                                        |
| 508 | + // recuperer la base  | 
                                                        |
| 509 | + $a = array_shift($url);  | 
                                                        |
| 510 | +    if (!$a) { | 
                                                        |
| 511 | + $a = './';  | 
                                                        |
| 512 | + }  | 
                                                        |
| 513 | +  | 
                                                        |
| 514 | +    $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,'; | 
                                                        |
| 515 | +    $ajouts = array_flip(explode('|', $c)); | 
                                                        |
| 516 | + $u = is_array($v) ? $v : rawurlencode($v);  | 
                                                        |
| 517 | + $testv = (is_array($v) ? count($v) : strlen($v));  | 
                                                        |
| 518 | + $v_read = null;  | 
                                                        |
| 519 | + // lire les variables et agir  | 
                                                        |
| 520 | +    foreach ($url as $n => $val) { | 
                                                        |
| 521 | +        if (preg_match($regexp, urldecode($val), $r)) { | 
                                                        |
| 522 | + $r = array_pad($r, 3, null);  | 
                                                        |
| 523 | +            if ($v === null) { | 
                                                        |
| 524 | + // c'est un tableau, on memorise les valeurs  | 
                                                        |
| 525 | +                if (substr($r[1], -2) == "[]") { | 
                                                        |
| 526 | +                    if (!$v_read) { | 
                                                        |
| 527 | + $v_read = array();  | 
                                                        |
| 528 | + }  | 
                                                        |
| 529 | + $v_read[] = $r[2] ? substr($r[2], 1) : '';  | 
                                                        |
| 530 | + } // c'est un scalaire, on retourne direct  | 
                                                        |
| 531 | +                else { | 
                                                        |
| 532 | + return $r[2] ? substr($r[2], 1) : '';  | 
                                                        |
| 533 | + }  | 
                                                        |
| 534 | + } // suppression  | 
                                                        |
| 535 | +            elseif (!$testv) { | 
                                                        |
| 536 | + unset($url[$n]);  | 
                                                        |
| 537 | + }  | 
                                                        |
| 538 | + // Ajout. Pour une variable, remplacer au meme endroit,  | 
                                                        |
| 539 | + // pour un tableau ce sera fait dans la prochaine boucle  | 
                                                        |
| 540 | +            elseif (substr($r[1], -2) != '[]') { | 
                                                        |
| 541 | + $url[$n] = $r[1] . '=' . $u;  | 
                                                        |
| 542 | + unset($ajouts[$r[1]]);  | 
                                                        |
| 543 | + }  | 
                                                        |
| 544 | + // Pour les tableaux on laisse tomber les valeurs de  | 
                                                        |
| 545 | + // départ, on remplira à l'étape suivante  | 
                                                        |
| 546 | +            else { | 
                                                        |
| 547 | + unset($url[$n]);  | 
                                                        |
| 548 | + }  | 
                                                        |
| 549 | + }  | 
                                                        |
| 550 | + }  | 
                                                        |
| 551 | +  | 
                                                        |
| 552 | + // traiter les parametres pas encore trouves  | 
                                                        |
| 553 | + if ($v === null  | 
                                                        |
| 554 | + and $args = func_get_args()  | 
                                                        |
| 555 | + and count($args) == 2  | 
                                                        |
| 556 | +    ) { | 
                                                        |
| 557 | + return $v_read; // rien trouve ou un tableau  | 
                                                        |
| 558 | +    } elseif ($testv) { | 
                                                        |
| 559 | +        foreach ($ajouts as $k => $n) { | 
                                                        |
| 560 | +            if (!is_array($v)) { | 
                                                        |
| 561 | + $url[] = $k . '=' . $u;  | 
                                                        |
| 562 | +            } else { | 
                                                        |
| 563 | + $id = (substr($k, -2) == '[]') ? $k : ($k . "[]");  | 
                                                        |
| 564 | +                foreach ($v as $w) { | 
                                                        |
| 565 | + $url[] = $id . '=' . (is_array($w) ? 'Array' : $w);  | 
                                                        |
| 566 | + }  | 
                                                        |
| 567 | + }  | 
                                                        |
| 568 | + }  | 
                                                        |
| 569 | + }  | 
                                                        |
| 570 | +  | 
                                                        |
| 571 | + // eliminer les vides  | 
                                                        |
| 572 | + $url = array_filter($url);  | 
                                                        |
| 573 | +  | 
                                                        |
| 574 | + // recomposer l'adresse  | 
                                                        |
| 575 | +    if ($url) { | 
                                                        |
| 576 | + $a .= '?' . join($sep, $url);  | 
                                                        |
| 577 | + }  | 
                                                        |
| 578 | +  | 
                                                        |
| 579 | + return $a . $ancre;  | 
                                                        |
| 581 | 580 | }  | 
                                                        
| 582 | 581 | |
| 583 | 582 | /**  | 
                                                        
@@ -595,21 +594,21 @@ discard block  | 
                                                    ||
| 595 | 594 | * @return string  | 
                                                        
| 596 | 595 | */  | 
                                                        
| 597 | 596 |  function ancre_url($url, $ancre) { | 
                                                        
| 598 | - // lever l'#ancre  | 
                                                        |
| 599 | -	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { | 
                                                        |
| 600 | - $url = $r[1];  | 
                                                        |
| 601 | - }  | 
                                                        |
| 602 | -	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { | 
                                                        |
| 603 | -		if (!function_exists('translitteration')) { | 
                                                        |
| 604 | -			include_spip('inc/charsets'); | 
                                                        |
| 605 | - }  | 
                                                        |
| 606 | - $ancre = preg_replace(  | 
                                                        |
| 607 | -			array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), | 
                                                        |
| 608 | -			array('', '-'), | 
                                                        |
| 609 | - translitteration($ancre)  | 
                                                        |
| 610 | - );  | 
                                                        |
| 611 | - }  | 
                                                        |
| 612 | - return $url . (strlen($ancre) ? '#' . $ancre : '');  | 
                                                        |
| 597 | + // lever l'#ancre  | 
                                                        |
| 598 | +    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) { | 
                                                        |
| 599 | + $url = $r[1];  | 
                                                        |
| 600 | + }  | 
                                                        |
| 601 | +    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) { | 
                                                        |
| 602 | +        if (!function_exists('translitteration')) { | 
                                                        |
| 603 | +            include_spip('inc/charsets'); | 
                                                        |
| 604 | + }  | 
                                                        |
| 605 | + $ancre = preg_replace(  | 
                                                        |
| 606 | +            array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'), | 
                                                        |
| 607 | +            array('', '-'), | 
                                                        |
| 608 | + translitteration($ancre)  | 
                                                        |
| 609 | + );  | 
                                                        |
| 610 | + }  | 
                                                        |
| 611 | + return $url . (strlen($ancre) ? '#' . $ancre : '');  | 
                                                        |
| 613 | 612 | }  | 
                                                        
| 614 | 613 | |
| 615 | 614 | /**  | 
                                                        
@@ -619,16 +618,16 @@ discard block  | 
                                                    ||
| 619 | 618 | * @return string  | 
                                                        
| 620 | 619 | */  | 
                                                        
| 621 | 620 |  function nettoyer_uri($reset = null) { | 
                                                        
| 622 | - static $done = false;  | 
                                                        |
| 623 | - static $propre = '';  | 
                                                        |
| 624 | -	if (!is_null($reset)) { | 
                                                        |
| 625 | - return $propre = $reset;  | 
                                                        |
| 626 | - }  | 
                                                        |
| 627 | -	if ($done) { | 
                                                        |
| 628 | - return $propre;  | 
                                                        |
| 629 | - }  | 
                                                        |
| 630 | - $done = true;  | 
                                                        |
| 631 | - return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);  | 
                                                        |
| 621 | + static $done = false;  | 
                                                        |
| 622 | + static $propre = '';  | 
                                                        |
| 623 | +    if (!is_null($reset)) { | 
                                                        |
| 624 | + return $propre = $reset;  | 
                                                        |
| 625 | + }  | 
                                                        |
| 626 | +    if ($done) { | 
                                                        |
| 627 | + return $propre;  | 
                                                        |
| 628 | + }  | 
                                                        |
| 629 | + $done = true;  | 
                                                        |
| 630 | + return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);  | 
                                                        |
| 632 | 631 | }  | 
                                                        
| 633 | 632 | |
| 634 | 633 | /**  | 
                                                        
@@ -640,13 +639,13 @@ discard block  | 
                                                    ||
| 640 | 639 | * @return string  | 
                                                        
| 641 | 640 | */  | 
                                                        
| 642 | 641 |  function nettoyer_uri_var($request_uri) { | 
                                                        
| 643 | - $uri1 = $request_uri;  | 
                                                        |
| 644 | -	do { | 
                                                        |
| 645 | - $uri = $uri1;  | 
                                                        |
| 646 | -		$uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', | 
                                                        |
| 647 | - '\1', $uri);  | 
                                                        |
| 648 | - } while ($uri <> $uri1);  | 
                                                        |
| 649 | -	return preg_replace(',[?&]$,', '', $uri1); | 
                                                        |
| 642 | + $uri1 = $request_uri;  | 
                                                        |
| 643 | +    do { | 
                                                        |
| 644 | + $uri = $uri1;  | 
                                                        |
| 645 | +        $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i', | 
                                                        |
| 646 | + '\1', $uri);  | 
                                                        |
| 647 | + } while ($uri <> $uri1);  | 
                                                        |
| 648 | +    return preg_replace(',[?&]$,', '', $uri1); | 
                                                        |
| 650 | 649 | }  | 
                                                        
| 651 | 650 | |
| 652 | 651 | |
@@ -660,47 +659,47 @@ discard block  | 
                                                    ||
| 660 | 659 | * URL vers soi-même  | 
                                                        
| 661 | 660 | **/  | 
                                                        
| 662 | 661 |  function self($amp = '&', $root = false) { | 
                                                        
| 663 | - $url = nettoyer_uri();  | 
                                                        |
| 664 | - if (!$root  | 
                                                        |
| 665 | - and (  | 
                                                        |
| 666 | - // si pas de profondeur on peut tronquer  | 
                                                        |
| 667 | - $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)  | 
                                                        |
| 668 | - // sinon c'est OK si _SET_HTML_BASE a ete force a false  | 
                                                        |
| 669 | -			or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) | 
                                                        |
| 670 | -	) { | 
                                                        |
| 671 | -		$url = preg_replace(',^[^?]*/,', '', $url); | 
                                                        |
| 672 | - }  | 
                                                        |
| 673 | - // ajouter le cas echeant les variables _POST['id_...']  | 
                                                        |
| 674 | -	foreach ($_POST as $v => $c) { | 
                                                        |
| 675 | -		if (substr($v, 0, 3) == 'id_') { | 
                                                        |
| 676 | - $url = parametre_url($url, $v, $c, '&');  | 
                                                        |
| 677 | - }  | 
                                                        |
| 678 | - }  | 
                                                        |
| 679 | -  | 
                                                        |
| 680 | - // supprimer les variables sans interet  | 
                                                        |
| 681 | -	if (test_espace_prive()) { | 
                                                        |
| 682 | -		$url = preg_replace(',([?&])(' | 
                                                        |
| 683 | - . 'lang|show_docs|'  | 
                                                        |
| 684 | - . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);  | 
                                                        |
| 685 | -		$url = preg_replace(',([?&])[&]+,', '\1', $url); | 
                                                        |
| 686 | -		$url = preg_replace(',[&]$,', '\1', $url); | 
                                                        |
| 687 | - }  | 
                                                        |
| 688 | -  | 
                                                        |
| 689 | - // eviter les hacks  | 
                                                        |
| 690 | -	include_spip('inc/filtres_mini'); | 
                                                        |
| 691 | - $url = spip_htmlspecialchars($url);  | 
                                                        |
| 662 | + $url = nettoyer_uri();  | 
                                                        |
| 663 | + if (!$root  | 
                                                        |
| 664 | + and (  | 
                                                        |
| 665 | + // si pas de profondeur on peut tronquer  | 
                                                        |
| 666 | + $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)  | 
                                                        |
| 667 | + // sinon c'est OK si _SET_HTML_BASE a ete force a false  | 
                                                        |
| 668 | +            or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE)) | 
                                                        |
| 669 | +    ) { | 
                                                        |
| 670 | +        $url = preg_replace(',^[^?]*/,', '', $url); | 
                                                        |
| 671 | + }  | 
                                                        |
| 672 | + // ajouter le cas echeant les variables _POST['id_...']  | 
                                                        |
| 673 | +    foreach ($_POST as $v => $c) { | 
                                                        |
| 674 | +        if (substr($v, 0, 3) == 'id_') { | 
                                                        |
| 675 | + $url = parametre_url($url, $v, $c, '&');  | 
                                                        |
| 676 | + }  | 
                                                        |
| 677 | + }  | 
                                                        |
| 678 | +  | 
                                                        |
| 679 | + // supprimer les variables sans interet  | 
                                                        |
| 680 | +    if (test_espace_prive()) { | 
                                                        |
| 681 | +        $url = preg_replace(',([?&])(' | 
                                                        |
| 682 | + . 'lang|show_docs|'  | 
                                                        |
| 683 | + . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);  | 
                                                        |
| 684 | +        $url = preg_replace(',([?&])[&]+,', '\1', $url); | 
                                                        |
| 685 | +        $url = preg_replace(',[&]$,', '\1', $url); | 
                                                        |
| 686 | + }  | 
                                                        |
| 687 | +  | 
                                                        |
| 688 | + // eviter les hacks  | 
                                                        |
| 689 | +    include_spip('inc/filtres_mini'); | 
                                                        |
| 690 | + $url = spip_htmlspecialchars($url);  | 
                                                        |
| 692 | 691 | |
| 693 | -	$url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); | 
                                                        |
| 692 | +    $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url); | 
                                                        |
| 694 | 693 | |
| 695 | - // & ?  | 
                                                        |
| 696 | -	if ($amp != '&') { | 
                                                        |
| 697 | -		$url = str_replace('&', $amp, $url); | 
                                                        |
| 698 | - }  | 
                                                        |
| 694 | + // & ?  | 
                                                        |
| 695 | +    if ($amp != '&') { | 
                                                        |
| 696 | +        $url = str_replace('&', $amp, $url); | 
                                                        |
| 697 | + }  | 
                                                        |
| 699 | 698 | |
| 700 | - // Si ca demarre par ? ou vide, donner './'  | 
                                                        |
| 701 | -	$url = preg_replace(',^([?].*)?$,', './\1', $url); | 
                                                        |
| 699 | + // Si ca demarre par ? ou vide, donner './'  | 
                                                        |
| 700 | +    $url = preg_replace(',^([?].*)?$,', './\1', $url); | 
                                                        |
| 702 | 701 | |
| 703 | - return $url;  | 
                                                        |
| 702 | + return $url;  | 
                                                        |
| 704 | 703 | }  | 
                                                        
| 705 | 704 | |
| 706 | 705 | |
@@ -711,7 +710,7 @@ discard block  | 
                                                    ||
| 711 | 710 | * true si c'est le cas, false sinon.  | 
                                                        
| 712 | 711 | */  | 
                                                        
| 713 | 712 |  function test_espace_prive() { | 
                                                        
| 714 | -	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; | 
                                                        |
| 713 | +    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false; | 
                                                        |
| 715 | 714 | }  | 
                                                        
| 716 | 715 | |
| 717 | 716 | /**  | 
                                                        
@@ -721,7 +720,7 @@ discard block  | 
                                                    ||
| 721 | 720 | * @return bool  | 
                                                        
| 722 | 721 | */  | 
                                                        
| 723 | 722 |  function test_plugin_actif($plugin) { | 
                                                        
| 724 | -	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; | 
                                                        |
| 723 | +    return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false; | 
                                                        |
| 725 | 724 | }  | 
                                                        
| 726 | 725 | |
| 727 | 726 | /**  | 
                                                        
@@ -752,51 +751,51 @@ discard block  | 
                                                    ||
| 752 | 751 | * Texte  | 
                                                        
| 753 | 752 | */  | 
                                                        
| 754 | 753 |  function _T($texte, $args = array(), $options = array()) { | 
                                                        
| 755 | - static $traduire = false;  | 
                                                        |
| 756 | -	$o = array('class' => '', 'force' => true, 'sanitize' => true); | 
                                                        |
| 757 | -	if ($options) { | 
                                                        |
| 758 | - // support de l'ancien argument $class  | 
                                                        |
| 759 | -		if (is_string($options)) { | 
                                                        |
| 760 | -			$options = array('class' => $options); | 
                                                        |
| 761 | - }  | 
                                                        |
| 762 | - $o = array_merge($o, $options);  | 
                                                        |
| 763 | - }  | 
                                                        |
| 754 | + static $traduire = false;  | 
                                                        |
| 755 | +    $o = array('class' => '', 'force' => true, 'sanitize' => true); | 
                                                        |
| 756 | +    if ($options) { | 
                                                        |
| 757 | + // support de l'ancien argument $class  | 
                                                        |
| 758 | +        if (is_string($options)) { | 
                                                        |
| 759 | +            $options = array('class' => $options); | 
                                                        |
| 760 | + }  | 
                                                        |
| 761 | + $o = array_merge($o, $options);  | 
                                                        |
| 762 | + }  | 
                                                        |
| 764 | 763 | |
| 765 | -	if (!$traduire) { | 
                                                        |
| 766 | -		$traduire = charger_fonction('traduire', 'inc'); | 
                                                        |
| 767 | -		include_spip('inc/lang'); | 
                                                        |
| 768 | - }  | 
                                                        |
| 764 | +    if (!$traduire) { | 
                                                        |
| 765 | +        $traduire = charger_fonction('traduire', 'inc'); | 
                                                        |
| 766 | +        include_spip('inc/lang'); | 
                                                        |
| 767 | + }  | 
                                                        |
| 769 | 768 | |
| 770 | - // On peut passer explicitement la langue dans le tableau  | 
                                                        |
| 771 | - // On utilise le même nom de variable que la globale  | 
                                                        |
| 772 | -	if (isset($args['spip_lang'])) { | 
                                                        |
| 773 | - $lang = $args['spip_lang'];  | 
                                                        |
| 774 | - // On l'enleve pour ne pas le passer au remplacement  | 
                                                        |
| 775 | - unset($args['spip_lang']);  | 
                                                        |
| 776 | - } // Sinon on prend la langue du contexte  | 
                                                        |
| 777 | -	else { | 
                                                        |
| 778 | - $lang = $GLOBALS['spip_lang'];  | 
                                                        |
| 779 | - }  | 
                                                        |
| 780 | - $text = $traduire($texte, $lang);  | 
                                                        |
| 769 | + // On peut passer explicitement la langue dans le tableau  | 
                                                        |
| 770 | + // On utilise le même nom de variable que la globale  | 
                                                        |
| 771 | +    if (isset($args['spip_lang'])) { | 
                                                        |
| 772 | + $lang = $args['spip_lang'];  | 
                                                        |
| 773 | + // On l'enleve pour ne pas le passer au remplacement  | 
                                                        |
| 774 | + unset($args['spip_lang']);  | 
                                                        |
| 775 | + } // Sinon on prend la langue du contexte  | 
                                                        |
| 776 | +    else { | 
                                                        |
| 777 | + $lang = $GLOBALS['spip_lang'];  | 
                                                        |
| 778 | + }  | 
                                                        |
| 779 | + $text = $traduire($texte, $lang);  | 
                                                        |
| 781 | 780 | |
| 782 | -	if (!strlen($text)) { | 
                                                        |
| 783 | -		if (!$o['force']) { | 
                                                        |
| 784 | - return '';  | 
                                                        |
| 785 | - }  | 
                                                        |
| 781 | +    if (!strlen($text)) { | 
                                                        |
| 782 | +        if (!$o['force']) { | 
                                                        |
| 783 | + return '';  | 
                                                        |
| 784 | + }  | 
                                                        |
| 786 | 785 | |
| 787 | - $text = $texte;  | 
                                                        |
| 786 | + $text = $texte;  | 
                                                        |
| 788 | 787 | |
| 789 | - // pour les chaines non traduites, assurer un service minimum  | 
                                                        |
| 790 | -		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { | 
                                                        |
| 791 | -			$text = str_replace('_', ' ', | 
                                                        |
| 792 | - (($n = strpos($text, ':')) === false ? $texte :  | 
                                                        |
| 793 | - substr($texte, $n + 1)));  | 
                                                        |
| 794 | - }  | 
                                                        |
| 795 | - $o['class'] = null;  | 
                                                        |
| 788 | + // pour les chaines non traduites, assurer un service minimum  | 
                                                        |
| 789 | +        if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) { | 
                                                        |
| 790 | +            $text = str_replace('_', ' ', | 
                                                        |
| 791 | + (($n = strpos($text, ':')) === false ? $texte :  | 
                                                        |
| 792 | + substr($texte, $n + 1)));  | 
                                                        |
| 793 | + }  | 
                                                        |
| 794 | + $o['class'] = null;  | 
                                                        |
| 796 | 795 | |
| 797 | - }  | 
                                                        |
| 796 | + }  | 
                                                        |
| 798 | 797 | |
| 799 | - return _L($text, $args, $o);  | 
                                                        |
| 798 | + return _L($text, $args, $o);  | 
                                                        |
| 800 | 799 | |
| 801 | 800 | }  | 
                                                        
| 802 | 801 | |
@@ -824,54 +823,54 @@ discard block  | 
                                                    ||
| 824 | 823 | * Texte  | 
                                                        
| 825 | 824 | */  | 
                                                        
| 826 | 825 |  function _L($text, $args = array(), $options = array()) { | 
                                                        
| 827 | - $f = $text;  | 
                                                        |
| 828 | - $defaut_options = array(  | 
                                                        |
| 829 | - 'class' => null,  | 
                                                        |
| 830 | - 'sanitize' => true,  | 
                                                        |
| 831 | - );  | 
                                                        |
| 832 | - // support de l'ancien argument $class  | 
                                                        |
| 833 | -	if ($options and is_string($options)) { | 
                                                        |
| 834 | -		$options = array('class' => $options); | 
                                                        |
| 835 | - }  | 
                                                        |
| 836 | -	if (is_array($options)) { | 
                                                        |
| 837 | - $options += $defaut_options;  | 
                                                        |
| 838 | -	} else { | 
                                                        |
| 839 | - $options = $defaut_options;  | 
                                                        |
| 840 | - }  | 
                                                        |
| 841 | -  | 
                                                        |
| 842 | -	if (is_array($args)) { | 
                                                        |
| 843 | -		if (!function_exists('interdire_scripts')) { | 
                                                        |
| 844 | -			include_spip('inc/texte'); | 
                                                        |
| 845 | - }  | 
                                                        |
| 846 | -		if (!function_exists('echapper_html_suspect')) { | 
                                                        |
| 847 | -			include_spip('inc/texte_mini'); | 
                                                        |
| 848 | - }  | 
                                                        |
| 849 | -		foreach ($args as $name => $value) { | 
                                                        |
| 850 | -			if ($options['sanitize']) { | 
                                                        |
| 851 | - $value = echapper_html_suspect($value);  | 
                                                        |
| 852 | - $value = interdire_scripts($value, -1);  | 
                                                        |
| 853 | - }  | 
                                                        |
| 854 | -			if (!empty($options['class'])) { | 
                                                        |
| 855 | - $value = "<span class='".$options['class']."'>$value</span>";  | 
                                                        |
| 856 | - }  | 
                                                        |
| 857 | -			$t = str_replace("@$name@", $value, $text); | 
                                                        |
| 858 | -			if ($text !== $t) { | 
                                                        |
| 859 | - unset($args[$name]);  | 
                                                        |
| 860 | - $text = $t;  | 
                                                        |
| 861 | - }  | 
                                                        |
| 862 | - }  | 
                                                        |
| 863 | - // Si des variables n'ont pas ete inserees, le signaler  | 
                                                        |
| 864 | - // (chaines de langues pas a jour)  | 
                                                        |
| 865 | -		if ($args) { | 
                                                        |
| 866 | -			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); | 
                                                        |
| 867 | - }  | 
                                                        |
| 868 | - }  | 
                                                        |
| 869 | -  | 
                                                        |
| 870 | -	if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { | 
                                                        |
| 871 | - return "<span class=debug-traduction-erreur>$text</span>";  | 
                                                        |
| 872 | -	} else { | 
                                                        |
| 873 | - return $text;  | 
                                                        |
| 874 | - }  | 
                                                        |
| 826 | + $f = $text;  | 
                                                        |
| 827 | + $defaut_options = array(  | 
                                                        |
| 828 | + 'class' => null,  | 
                                                        |
| 829 | + 'sanitize' => true,  | 
                                                        |
| 830 | + );  | 
                                                        |
| 831 | + // support de l'ancien argument $class  | 
                                                        |
| 832 | +    if ($options and is_string($options)) { | 
                                                        |
| 833 | +        $options = array('class' => $options); | 
                                                        |
| 834 | + }  | 
                                                        |
| 835 | +    if (is_array($options)) { | 
                                                        |
| 836 | + $options += $defaut_options;  | 
                                                        |
| 837 | +    } else { | 
                                                        |
| 838 | + $options = $defaut_options;  | 
                                                        |
| 839 | + }  | 
                                                        |
| 840 | +  | 
                                                        |
| 841 | +    if (is_array($args)) { | 
                                                        |
| 842 | +        if (!function_exists('interdire_scripts')) { | 
                                                        |
| 843 | +            include_spip('inc/texte'); | 
                                                        |
| 844 | + }  | 
                                                        |
| 845 | +        if (!function_exists('echapper_html_suspect')) { | 
                                                        |
| 846 | +            include_spip('inc/texte_mini'); | 
                                                        |
| 847 | + }  | 
                                                        |
| 848 | +        foreach ($args as $name => $value) { | 
                                                        |
| 849 | +            if ($options['sanitize']) { | 
                                                        |
| 850 | + $value = echapper_html_suspect($value);  | 
                                                        |
| 851 | + $value = interdire_scripts($value, -1);  | 
                                                        |
| 852 | + }  | 
                                                        |
| 853 | +            if (!empty($options['class'])) { | 
                                                        |
| 854 | + $value = "<span class='".$options['class']."'>$value</span>";  | 
                                                        |
| 855 | + }  | 
                                                        |
| 856 | +            $t = str_replace("@$name@", $value, $text); | 
                                                        |
| 857 | +            if ($text !== $t) { | 
                                                        |
| 858 | + unset($args[$name]);  | 
                                                        |
| 859 | + $text = $t;  | 
                                                        |
| 860 | + }  | 
                                                        |
| 861 | + }  | 
                                                        |
| 862 | + // Si des variables n'ont pas ete inserees, le signaler  | 
                                                        |
| 863 | + // (chaines de langues pas a jour)  | 
                                                        |
| 864 | +        if ($args) { | 
                                                        |
| 865 | +            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG); | 
                                                        |
| 866 | + }  | 
                                                        |
| 867 | + }  | 
                                                        |
| 868 | +  | 
                                                        |
| 869 | +    if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { | 
                                                        |
| 870 | + return "<span class=debug-traduction-erreur>$text</span>";  | 
                                                        |
| 871 | +    } else { | 
                                                        |
| 872 | + return $text;  | 
                                                        |
| 873 | + }  | 
                                                        |
| 875 | 874 | }  | 
                                                        
| 876 | 875 | |
| 877 | 876 | |
@@ -885,13 +884,13 @@ discard block  | 
                                                    ||
| 885 | 884 | * @return string  | 
                                                        
| 886 | 885 | */  | 
                                                        
| 887 | 886 |  function joli_repertoire($rep) { | 
                                                        
| 888 | - $a = substr($rep, 0, 1);  | 
                                                        |
| 889 | -	if ($a <> '.' and $a <> '/') { | 
                                                        |
| 890 | - $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;  | 
                                                        |
| 891 | - }  | 
                                                        |
| 892 | -	$rep = preg_replace(',(^\.\.\/),', '', $rep); | 
                                                        |
| 887 | + $a = substr($rep, 0, 1);  | 
                                                        |
| 888 | +    if ($a <> '.' and $a <> '/') { | 
                                                        |
| 889 | + $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;  | 
                                                        |
| 890 | + }  | 
                                                        |
| 891 | +    $rep = preg_replace(',(^\.\.\/),', '', $rep); | 
                                                        |
| 893 | 892 | |
| 894 | - return $rep;  | 
                                                        |
| 893 | + return $rep;  | 
                                                        |
| 895 | 894 | }  | 
                                                        
| 896 | 895 | |
| 897 | 896 | |
@@ -916,33 +915,33 @@ discard block  | 
                                                    ||
| 916 | 915 | * @return float|int|string|void  | 
                                                        
| 917 | 916 | */  | 
                                                        
| 918 | 917 |  function spip_timer($t = 'rien', $raw = false) { | 
                                                        
| 919 | - static $time;  | 
                                                        |
| 920 | - $a = time();  | 
                                                        |
| 921 | - $b = microtime();  | 
                                                        |
| 922 | - // microtime peut contenir les microsecondes et le temps  | 
                                                        |
| 923 | -	$b = explode(' ', $b); | 
                                                        |
| 924 | -	if (count($b) == 2) { | 
                                                        |
| 925 | - $a = end($b);  | 
                                                        |
| 926 | - } // plus precis !  | 
                                                        |
| 927 | - $b = reset($b);  | 
                                                        |
| 928 | -	if (!isset($time[$t])) { | 
                                                        |
| 929 | - $time[$t] = $a + $b;  | 
                                                        |
| 930 | -	} else { | 
                                                        |
| 931 | - $p = ($a + $b - $time[$t]) * 1000;  | 
                                                        |
| 932 | - unset($time[$t]);  | 
                                                        |
| 918 | + static $time;  | 
                                                        |
| 919 | + $a = time();  | 
                                                        |
| 920 | + $b = microtime();  | 
                                                        |
| 921 | + // microtime peut contenir les microsecondes et le temps  | 
                                                        |
| 922 | +    $b = explode(' ', $b); | 
                                                        |
| 923 | +    if (count($b) == 2) { | 
                                                        |
| 924 | + $a = end($b);  | 
                                                        |
| 925 | + } // plus precis !  | 
                                                        |
| 926 | + $b = reset($b);  | 
                                                        |
| 927 | +    if (!isset($time[$t])) { | 
                                                        |
| 928 | + $time[$t] = $a + $b;  | 
                                                        |
| 929 | +    } else { | 
                                                        |
| 930 | + $p = ($a + $b - $time[$t]) * 1000;  | 
                                                        |
| 931 | + unset($time[$t]);  | 
                                                        |
| 933 | 932 | # echo "'$p'";exit;  | 
                                                        
| 934 | -		if ($raw) { | 
                                                        |
| 935 | - return $p;  | 
                                                        |
| 936 | - }  | 
                                                        |
| 937 | -		if ($p < 1000) { | 
                                                        |
| 938 | - $s = '';  | 
                                                        |
| 939 | -		} else { | 
                                                        |
| 940 | -			$s = sprintf("%d ", $x = floor($p / 1000)); | 
                                                        |
| 941 | - $p -= ($x * 1000);  | 
                                                        |
| 942 | - }  | 
                                                        |
| 933 | +        if ($raw) { | 
                                                        |
| 934 | + return $p;  | 
                                                        |
| 935 | + }  | 
                                                        |
| 936 | +        if ($p < 1000) { | 
                                                        |
| 937 | + $s = '';  | 
                                                        |
| 938 | +        } else { | 
                                                        |
| 939 | +            $s = sprintf("%d ", $x = floor($p / 1000)); | 
                                                        |
| 940 | + $p -= ($x * 1000);  | 
                                                        |
| 941 | + }  | 
                                                        |
| 943 | 942 | |
| 944 | - return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);  | 
                                                        |
| 945 | - }  | 
                                                        |
| 943 | + return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);  | 
                                                        |
| 944 | + }  | 
                                                        |
| 946 | 945 | }  | 
                                                        
| 947 | 946 | |
| 948 | 947 | |
@@ -950,21 +949,21 @@ discard block  | 
                                                    ||
| 950 | 949 | // sinon renvoie True et le date sauf si ca n'est pas souhaite  | 
                                                        
| 951 | 950 | // http://code.spip.net/@spip_touch  | 
                                                        
| 952 | 951 |  function spip_touch($fichier, $duree = 0, $touch = true) { | 
                                                        
| 953 | -	if ($duree) { | 
                                                        |
| 954 | - clearstatcache();  | 
                                                        |
| 955 | -		if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { | 
                                                        |
| 956 | - return false;  | 
                                                        |
| 957 | - }  | 
                                                        |
| 958 | - }  | 
                                                        |
| 959 | -	if ($touch !== false) { | 
                                                        |
| 960 | -		if (!@touch($fichier)) { | 
                                                        |
| 961 | - spip_unlink($fichier);  | 
                                                        |
| 962 | - @touch($fichier);  | 
                                                        |
| 963 | - };  | 
                                                        |
| 964 | - @chmod($fichier, _SPIP_CHMOD & ~0111);  | 
                                                        |
| 965 | - }  | 
                                                        |
| 952 | +    if ($duree) { | 
                                                        |
| 953 | + clearstatcache();  | 
                                                        |
| 954 | +        if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) { | 
                                                        |
| 955 | + return false;  | 
                                                        |
| 956 | + }  | 
                                                        |
| 957 | + }  | 
                                                        |
| 958 | +    if ($touch !== false) { | 
                                                        |
| 959 | +        if (!@touch($fichier)) { | 
                                                        |
| 960 | + spip_unlink($fichier);  | 
                                                        |
| 961 | + @touch($fichier);  | 
                                                        |
| 962 | + };  | 
                                                        |
| 963 | + @chmod($fichier, _SPIP_CHMOD & ~0111);  | 
                                                        |
| 964 | + }  | 
                                                        |
| 966 | 965 | |
| 967 | - return true;  | 
                                                        |
| 966 | + return true;  | 
                                                        |
| 968 | 967 | }  | 
                                                        
| 969 | 968 | |
| 970 | 969 | |
@@ -976,11 +975,11 @@ discard block  | 
                                                    ||
| 976 | 975 | * @uses cron()  | 
                                                        
| 977 | 976 | **/  | 
                                                        
| 978 | 977 |  function action_cron() { | 
                                                        
| 979 | -	include_spip('inc/headers'); | 
                                                        |
| 980 | - http_status(204); // No Content  | 
                                                        |
| 981 | -	header("Connection: close"); | 
                                                        |
| 982 | -	define('_DIRECT_CRON_FORCE', true); | 
                                                        |
| 983 | - cron();  | 
                                                        |
| 978 | +    include_spip('inc/headers'); | 
                                                        |
| 979 | + http_status(204); // No Content  | 
                                                        |
| 980 | +    header("Connection: close"); | 
                                                        |
| 981 | +    define('_DIRECT_CRON_FORCE', true); | 
                                                        |
| 982 | + cron();  | 
                                                        |
| 984 | 983 | }  | 
                                                        
| 985 | 984 | |
| 986 | 985 | /**  | 
                                                        
@@ -996,26 +995,26 @@ discard block  | 
                                                    ||
| 996 | 995 | * True si la tache a pu être effectuée  | 
                                                        
| 997 | 996 | */  | 
                                                        
| 998 | 997 |  function cron($taches = array(), $taches_old = array()) { | 
                                                        
| 999 | - // si pas en mode cron force, laisser tomber.  | 
                                                        |
| 1000 | -	if (!defined('_DIRECT_CRON_FORCE')) { | 
                                                        |
| 1001 | - return false;  | 
                                                        |
| 1002 | - }  | 
                                                        |
| 1003 | -	if (!is_array($taches)) { | 
                                                        |
| 1004 | - $taches = $taches_old;  | 
                                                        |
| 1005 | - } // compat anciens appels  | 
                                                        |
| 1006 | - // si taches a inserer en base et base inaccessible, laisser tomber  | 
                                                        |
| 1007 | - // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve  | 
                                                        |
| 1008 | - // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire  | 
                                                        |
| 1009 | - // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)  | 
                                                        |
| 1010 | -	if ($taches and count($taches) and !spip_connect()) { | 
                                                        |
| 1011 | - return false;  | 
                                                        |
| 1012 | - }  | 
                                                        |
| 1013 | -	spip_log("cron !", 'jq' . _LOG_DEBUG); | 
                                                        |
| 1014 | -	if ($genie = charger_fonction('genie', 'inc', true)) { | 
                                                        |
| 1015 | - return $genie($taches);  | 
                                                        |
| 1016 | - }  | 
                                                        |
| 1017 | -  | 
                                                        |
| 1018 | - return false;  | 
                                                        |
| 998 | + // si pas en mode cron force, laisser tomber.  | 
                                                        |
| 999 | +    if (!defined('_DIRECT_CRON_FORCE')) { | 
                                                        |
| 1000 | + return false;  | 
                                                        |
| 1001 | + }  | 
                                                        |
| 1002 | +    if (!is_array($taches)) { | 
                                                        |
| 1003 | + $taches = $taches_old;  | 
                                                        |
| 1004 | + } // compat anciens appels  | 
                                                        |
| 1005 | + // si taches a inserer en base et base inaccessible, laisser tomber  | 
                                                        |
| 1006 | + // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve  | 
                                                        |
| 1007 | + // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire  | 
                                                        |
| 1008 | + // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)  | 
                                                        |
| 1009 | +    if ($taches and count($taches) and !spip_connect()) { | 
                                                        |
| 1010 | + return false;  | 
                                                        |
| 1011 | + }  | 
                                                        |
| 1012 | +    spip_log("cron !", 'jq' . _LOG_DEBUG); | 
                                                        |
| 1013 | +    if ($genie = charger_fonction('genie', 'inc', true)) { | 
                                                        |
| 1014 | + return $genie($taches);  | 
                                                        |
| 1015 | + }  | 
                                                        |
| 1016 | +  | 
                                                        |
| 1017 | + return false;  | 
                                                        |
| 1019 | 1018 | }  | 
                                                        
| 1020 | 1019 | |
| 1021 | 1020 | /**  | 
                                                        
@@ -1047,17 +1046,17 @@ discard block  | 
                                                    ||
| 1047 | 1046 | * Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.  | 
                                                        
| 1048 | 1047 | */  | 
                                                        
| 1049 | 1048 | function job_queue_add(  | 
                                                        
| 1050 | - $function,  | 
                                                        |
| 1051 | - $description,  | 
                                                        |
| 1052 | - $arguments = array(),  | 
                                                        |
| 1053 | - $file = '',  | 
                                                        |
| 1054 | - $no_duplicate = false,  | 
                                                        |
| 1055 | - $time = 0,  | 
                                                        |
| 1056 | - $priority = 0  | 
                                                        |
| 1049 | + $function,  | 
                                                        |
| 1050 | + $description,  | 
                                                        |
| 1051 | + $arguments = array(),  | 
                                                        |
| 1052 | + $file = '',  | 
                                                        |
| 1053 | + $no_duplicate = false,  | 
                                                        |
| 1054 | + $time = 0,  | 
                                                        |
| 1055 | + $priority = 0  | 
                                                        |
| 1057 | 1056 |  ) { | 
                                                        
| 1058 | -	include_spip('inc/queue'); | 
                                                        |
| 1057 | +    include_spip('inc/queue'); | 
                                                        |
| 1059 | 1058 | |
| 1060 | - return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);  | 
                                                        |
| 1059 | + return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);  | 
                                                        |
| 1061 | 1060 | }  | 
                                                        
| 1062 | 1061 | |
| 1063 | 1062 | /**  | 
                                                        
@@ -1068,9 +1067,9 @@ discard block  | 
                                                    ||
| 1068 | 1067 | * @return bool  | 
                                                        
| 1069 | 1068 | */  | 
                                                        
| 1070 | 1069 |  function job_queue_remove($id_job) { | 
                                                        
| 1071 | -	include_spip('inc/queue'); | 
                                                        |
| 1070 | +    include_spip('inc/queue'); | 
                                                        |
| 1072 | 1071 | |
| 1073 | - return queue_remove_job($id_job);  | 
                                                        |
| 1072 | + return queue_remove_job($id_job);  | 
                                                        |
| 1074 | 1073 | }  | 
                                                        
| 1075 | 1074 | |
| 1076 | 1075 | /**  | 
                                                        
@@ -1083,9 +1082,9 @@ discard block  | 
                                                    ||
| 1083 | 1082 | * or an array of simple array to link multiples objet in one time  | 
                                                        
| 1084 | 1083 | */  | 
                                                        
| 1085 | 1084 |  function job_queue_link($id_job, $objets) { | 
                                                        
| 1086 | -	include_spip('inc/queue'); | 
                                                        |
| 1085 | +    include_spip('inc/queue'); | 
                                                        |
| 1087 | 1086 | |
| 1088 | - return queue_link_job($id_job, $objets);  | 
                                                        |
| 1087 | + return queue_link_job($id_job, $objets);  | 
                                                        |
| 1089 | 1088 | }  | 
                                                        
| 1090 | 1089 | |
| 1091 | 1090 | |
@@ -1105,36 +1104,36 @@ discard block  | 
                                                    ||
| 1105 | 1104 | * - `null` si la queue n'est pas encore initialisée  | 
                                                        
| 1106 | 1105 | */  | 
                                                        
| 1107 | 1106 |  function queue_sleep_time_to_next_job($force = null) { | 
                                                        
| 1108 | - static $queue_next_job_time = -1;  | 
                                                        |
| 1109 | -	if ($force === true) { | 
                                                        |
| 1110 | - $queue_next_job_time = -1;  | 
                                                        |
| 1111 | -	} elseif ($force) { | 
                                                        |
| 1112 | - $queue_next_job_time = $force;  | 
                                                        |
| 1113 | - }  | 
                                                        |
| 1114 | -  | 
                                                        |
| 1115 | -	if ($queue_next_job_time == -1) { | 
                                                        |
| 1116 | -		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { | 
                                                        |
| 1117 | -			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); | 
                                                        |
| 1118 | - }  | 
                                                        |
| 1119 | - // utiliser un cache memoire si dispo  | 
                                                        |
| 1120 | -		if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { | 
                                                        |
| 1121 | - $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);  | 
                                                        |
| 1122 | -		} else { | 
                                                        |
| 1123 | - $queue_next_job_time = null;  | 
                                                        |
| 1124 | -			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { | 
                                                        |
| 1125 | - $queue_next_job_time = intval($contenu);  | 
                                                        |
| 1126 | - }  | 
                                                        |
| 1127 | - }  | 
                                                        |
| 1128 | - }  | 
                                                        |
| 1129 | -  | 
                                                        |
| 1130 | -	if (is_null($queue_next_job_time)) { | 
                                                        |
| 1131 | - return null;  | 
                                                        |
| 1132 | - }  | 
                                                        |
| 1133 | -	if (!$_SERVER['REQUEST_TIME']) { | 
                                                        |
| 1134 | - $_SERVER['REQUEST_TIME'] = time();  | 
                                                        |
| 1135 | - }  | 
                                                        |
| 1136 | -  | 
                                                        |
| 1137 | - return $queue_next_job_time - $_SERVER['REQUEST_TIME'];  | 
                                                        |
| 1107 | + static $queue_next_job_time = -1;  | 
                                                        |
| 1108 | +    if ($force === true) { | 
                                                        |
| 1109 | + $queue_next_job_time = -1;  | 
                                                        |
| 1110 | +    } elseif ($force) { | 
                                                        |
| 1111 | + $queue_next_job_time = $force;  | 
                                                        |
| 1112 | + }  | 
                                                        |
| 1113 | +  | 
                                                        |
| 1114 | +    if ($queue_next_job_time == -1) { | 
                                                        |
| 1115 | +        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) { | 
                                                        |
| 1116 | +            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt"); | 
                                                        |
| 1117 | + }  | 
                                                        |
| 1118 | + // utiliser un cache memoire si dispo  | 
                                                        |
| 1119 | +        if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { | 
                                                        |
| 1120 | + $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);  | 
                                                        |
| 1121 | +        } else { | 
                                                        |
| 1122 | + $queue_next_job_time = null;  | 
                                                        |
| 1123 | +            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) { | 
                                                        |
| 1124 | + $queue_next_job_time = intval($contenu);  | 
                                                        |
| 1125 | + }  | 
                                                        |
| 1126 | + }  | 
                                                        |
| 1127 | + }  | 
                                                        |
| 1128 | +  | 
                                                        |
| 1129 | +    if (is_null($queue_next_job_time)) { | 
                                                        |
| 1130 | + return null;  | 
                                                        |
| 1131 | + }  | 
                                                        |
| 1132 | +    if (!$_SERVER['REQUEST_TIME']) { | 
                                                        |
| 1133 | + $_SERVER['REQUEST_TIME'] = time();  | 
                                                        |
| 1134 | + }  | 
                                                        |
| 1135 | +  | 
                                                        |
| 1136 | + return $queue_next_job_time - $_SERVER['REQUEST_TIME'];  | 
                                                        |
| 1138 | 1137 | }  | 
                                                        
| 1139 | 1138 | |
| 1140 | 1139 | |
@@ -1146,9 +1145,9 @@ discard block  | 
                                                    ||
| 1146 | 1145 | * @return string  | 
                                                        
| 1147 | 1146 | */  | 
                                                        
| 1148 | 1147 |  function quote_amp($u) { | 
                                                        
| 1149 | - return preg_replace(  | 
                                                        |
| 1150 | -		"/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", | 
                                                        |
| 1151 | - "&", $u);  | 
                                                        |
| 1148 | + return preg_replace(  | 
                                                        |
| 1149 | +        "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i", | 
                                                        |
| 1150 | + "&", $u);  | 
                                                        |
| 1152 | 1151 | }  | 
                                                        
| 1153 | 1152 | |
| 1154 | 1153 | |
@@ -1171,27 +1170,27 @@ discard block  | 
                                                    ||
| 1171 | 1170 | * Balise HTML `<script>` et son contenu  | 
                                                        
| 1172 | 1171 | **/  | 
                                                        
| 1173 | 1172 |  function http_script($script, $src = '', $noscript = '') { | 
                                                        
| 1174 | - static $done = array();  | 
                                                        |
| 1173 | + static $done = array();  | 
                                                        |
| 1175 | 1174 | |
| 1176 | -	if ($src && !isset($done[$src])) { | 
                                                        |
| 1177 | - $done[$src] = true;  | 
                                                        |
| 1178 | - $src = find_in_path($src, _JAVASCRIPT);  | 
                                                        |
| 1179 | - $src = " src='$src'";  | 
                                                        |
| 1180 | -	} else { | 
                                                        |
| 1181 | - $src = '';  | 
                                                        |
| 1182 | - }  | 
                                                        |
| 1183 | -	if ($script) { | 
                                                        |
| 1184 | -		$script = ("/*<![CDATA[*/\n" . | 
                                                        |
| 1185 | -			preg_replace(',</([^>]*)>,', '<\/\1>', $script) . | 
                                                        |
| 1186 | - "/*]]>*/");  | 
                                                        |
| 1187 | - }  | 
                                                        |
| 1188 | -	if ($noscript) { | 
                                                        |
| 1189 | - $noscript = "<noscript>\n\t$noscript\n</noscript>\n";  | 
                                                        |
| 1190 | - }  | 
                                                        |
| 1175 | +    if ($src && !isset($done[$src])) { | 
                                                        |
| 1176 | + $done[$src] = true;  | 
                                                        |
| 1177 | + $src = find_in_path($src, _JAVASCRIPT);  | 
                                                        |
| 1178 | + $src = " src='$src'";  | 
                                                        |
| 1179 | +    } else { | 
                                                        |
| 1180 | + $src = '';  | 
                                                        |
| 1181 | + }  | 
                                                        |
| 1182 | +    if ($script) { | 
                                                        |
| 1183 | +        $script = ("/*<![CDATA[*/\n" . | 
                                                        |
| 1184 | +            preg_replace(',</([^>]*)>,', '<\/\1>', $script) . | 
                                                        |
| 1185 | + "/*]]>*/");  | 
                                                        |
| 1186 | + }  | 
                                                        |
| 1187 | +    if ($noscript) { | 
                                                        |
| 1188 | + $noscript = "<noscript>\n\t$noscript\n</noscript>\n";  | 
                                                        |
| 1189 | + }  | 
                                                        |
| 1191 | 1190 | |
| 1192 | - return ($src or $script or $noscript)  | 
                                                        |
| 1193 | - ? "<script type='text/javascript'$src>$script</script>$noscript"  | 
                                                        |
| 1194 | - : '';  | 
                                                        |
| 1191 | + return ($src or $script or $noscript)  | 
                                                        |
| 1192 | + ? "<script type='text/javascript'$src>$script</script>$noscript"  | 
                                                        |
| 1193 | + : '';  | 
                                                        |
| 1195 | 1194 | }  | 
                                                        
| 1196 | 1195 | |
| 1197 | 1196 | |
@@ -1226,7 +1225,7 @@ discard block  | 
                                                    ||
| 1226 | 1225 | * Texte échappé  | 
                                                        
| 1227 | 1226 | **/  | 
                                                        
| 1228 | 1227 |  function texte_script($texte) { | 
                                                        
| 1229 | -	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); | 
                                                        |
| 1228 | +    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte)); | 
                                                        |
| 1230 | 1229 | }  | 
                                                        
| 1231 | 1230 | |
| 1232 | 1231 | |
@@ -1263,69 +1262,69 @@ discard block  | 
                                                    ||
| 1263 | 1262 | * Liste des chemins, par ordre de priorité.  | 
                                                        
| 1264 | 1263 | **/  | 
                                                        
| 1265 | 1264 |  function _chemin($dir_path = null) { | 
                                                        
| 1266 | - static $path_base = null;  | 
                                                        |
| 1267 | - static $path_full = null;  | 
                                                        |
| 1268 | -	if ($path_base == null) { | 
                                                        |
| 1269 | - // Chemin standard depuis l'espace public  | 
                                                        |
| 1270 | -		$path = defined('_SPIP_PATH') ? _SPIP_PATH : | 
                                                        |
| 1271 | - _DIR_RACINE . ':' .  | 
                                                        |
| 1272 | - _DIR_RACINE . 'squelettes-dist/:' .  | 
                                                        |
| 1273 | - _DIR_RACINE . 'prive/:' .  | 
                                                        |
| 1274 | - _DIR_RESTREINT;  | 
                                                        |
| 1275 | - // Ajouter squelettes/  | 
                                                        |
| 1276 | -		if (@is_dir(_DIR_RACINE . 'squelettes')) { | 
                                                        |
| 1277 | - $path = _DIR_RACINE . 'squelettes/:' . $path;  | 
                                                        |
| 1278 | - }  | 
                                                        |
| 1279 | -		foreach (explode(':', $path) as $dir) { | 
                                                        |
| 1280 | -			if (strlen($dir) and substr($dir, -1) != '/') { | 
                                                        |
| 1281 | - $dir .= "/";  | 
                                                        |
| 1282 | - }  | 
                                                        |
| 1283 | - $path_base[] = $dir;  | 
                                                        |
| 1284 | - }  | 
                                                        |
| 1285 | - $path_full = $path_base;  | 
                                                        |
| 1286 | - // Et le(s) dossier(s) des squelettes nommes  | 
                                                        |
| 1287 | -		if (strlen($GLOBALS['dossier_squelettes'])) { | 
                                                        |
| 1288 | -			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { | 
                                                        |
| 1289 | - array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');  | 
                                                        |
| 1290 | - }  | 
                                                        |
| 1291 | - }  | 
                                                        |
| 1292 | - $GLOBALS['path_sig'] = md5(serialize($path_full));  | 
                                                        |
| 1293 | - }  | 
                                                        |
| 1294 | -	if ($dir_path === null) { | 
                                                        |
| 1295 | - return $path_full;  | 
                                                        |
| 1296 | - }  | 
                                                        |
| 1297 | -  | 
                                                        |
| 1298 | -	if (strlen($dir_path)) { | 
                                                        |
| 1299 | - $tete = "";  | 
                                                        |
| 1300 | -		if (reset($path_base) == _DIR_RACINE . 'squelettes/') { | 
                                                        |
| 1301 | - $tete = array_shift($path_base);  | 
                                                        |
| 1302 | - }  | 
                                                        |
| 1303 | -		$dirs = array_reverse(explode(':', $dir_path)); | 
                                                        |
| 1304 | -		foreach ($dirs as $dir_path) { | 
                                                        |
| 1305 | -			#if ($dir_path{0}!='/') | 
                                                        |
| 1306 | - # $dir_path = $dir_path;  | 
                                                        |
| 1307 | -			if (substr($dir_path, -1) != '/') { | 
                                                        |
| 1308 | - $dir_path .= "/";  | 
                                                        |
| 1309 | - }  | 
                                                        |
| 1310 | -			if (!in_array($dir_path, $path_base)) { | 
                                                        |
| 1311 | - array_unshift($path_base, $dir_path);  | 
                                                        |
| 1312 | - }  | 
                                                        |
| 1313 | - }  | 
                                                        |
| 1314 | -		if (strlen($tete)) { | 
                                                        |
| 1315 | - array_unshift($path_base, $tete);  | 
                                                        |
| 1316 | - }  | 
                                                        |
| 1317 | - }  | 
                                                        |
| 1318 | - $path_full = $path_base;  | 
                                                        |
| 1319 | - // Et le(s) dossier(s) des squelettes nommes  | 
                                                        |
| 1320 | -	if (strlen($GLOBALS['dossier_squelettes'])) { | 
                                                        |
| 1321 | -		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { | 
                                                        |
| 1322 | - array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');  | 
                                                        |
| 1323 | - }  | 
                                                        |
| 1324 | - }  | 
                                                        |
| 1325 | -  | 
                                                        |
| 1326 | - $GLOBALS['path_sig'] = md5(serialize($path_full));  | 
                                                        |
| 1327 | -  | 
                                                        |
| 1328 | - return $path_full;  | 
                                                        |
| 1265 | + static $path_base = null;  | 
                                                        |
| 1266 | + static $path_full = null;  | 
                                                        |
| 1267 | +    if ($path_base == null) { | 
                                                        |
| 1268 | + // Chemin standard depuis l'espace public  | 
                                                        |
| 1269 | +        $path = defined('_SPIP_PATH') ? _SPIP_PATH : | 
                                                        |
| 1270 | + _DIR_RACINE . ':' .  | 
                                                        |
| 1271 | + _DIR_RACINE . 'squelettes-dist/:' .  | 
                                                        |
| 1272 | + _DIR_RACINE . 'prive/:' .  | 
                                                        |
| 1273 | + _DIR_RESTREINT;  | 
                                                        |
| 1274 | + // Ajouter squelettes/  | 
                                                        |
| 1275 | +        if (@is_dir(_DIR_RACINE . 'squelettes')) { | 
                                                        |
| 1276 | + $path = _DIR_RACINE . 'squelettes/:' . $path;  | 
                                                        |
| 1277 | + }  | 
                                                        |
| 1278 | +        foreach (explode(':', $path) as $dir) { | 
                                                        |
| 1279 | +            if (strlen($dir) and substr($dir, -1) != '/') { | 
                                                        |
| 1280 | + $dir .= "/";  | 
                                                        |
| 1281 | + }  | 
                                                        |
| 1282 | + $path_base[] = $dir;  | 
                                                        |
| 1283 | + }  | 
                                                        |
| 1284 | + $path_full = $path_base;  | 
                                                        |
| 1285 | + // Et le(s) dossier(s) des squelettes nommes  | 
                                                        |
| 1286 | +        if (strlen($GLOBALS['dossier_squelettes'])) { | 
                                                        |
| 1287 | +            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { | 
                                                        |
| 1288 | + array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');  | 
                                                        |
| 1289 | + }  | 
                                                        |
| 1290 | + }  | 
                                                        |
| 1291 | + $GLOBALS['path_sig'] = md5(serialize($path_full));  | 
                                                        |
| 1292 | + }  | 
                                                        |
| 1293 | +    if ($dir_path === null) { | 
                                                        |
| 1294 | + return $path_full;  | 
                                                        |
| 1295 | + }  | 
                                                        |
| 1296 | +  | 
                                                        |
| 1297 | +    if (strlen($dir_path)) { | 
                                                        |
| 1298 | + $tete = "";  | 
                                                        |
| 1299 | +        if (reset($path_base) == _DIR_RACINE . 'squelettes/') { | 
                                                        |
| 1300 | + $tete = array_shift($path_base);  | 
                                                        |
| 1301 | + }  | 
                                                        |
| 1302 | +        $dirs = array_reverse(explode(':', $dir_path)); | 
                                                        |
| 1303 | +        foreach ($dirs as $dir_path) { | 
                                                        |
| 1304 | +            #if ($dir_path{0}!='/') | 
                                                        |
| 1305 | + # $dir_path = $dir_path;  | 
                                                        |
| 1306 | +            if (substr($dir_path, -1) != '/') { | 
                                                        |
| 1307 | + $dir_path .= "/";  | 
                                                        |
| 1308 | + }  | 
                                                        |
| 1309 | +            if (!in_array($dir_path, $path_base)) { | 
                                                        |
| 1310 | + array_unshift($path_base, $dir_path);  | 
                                                        |
| 1311 | + }  | 
                                                        |
| 1312 | + }  | 
                                                        |
| 1313 | +        if (strlen($tete)) { | 
                                                        |
| 1314 | + array_unshift($path_base, $tete);  | 
                                                        |
| 1315 | + }  | 
                                                        |
| 1316 | + }  | 
                                                        |
| 1317 | + $path_full = $path_base;  | 
                                                        |
| 1318 | + // Et le(s) dossier(s) des squelettes nommes  | 
                                                        |
| 1319 | +    if (strlen($GLOBALS['dossier_squelettes'])) { | 
                                                        |
| 1320 | +        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) { | 
                                                        |
| 1321 | + array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');  | 
                                                        |
| 1322 | + }  | 
                                                        |
| 1323 | + }  | 
                                                        |
| 1324 | +  | 
                                                        |
| 1325 | + $GLOBALS['path_sig'] = md5(serialize($path_full));  | 
                                                        |
| 1326 | +  | 
                                                        |
| 1327 | + return $path_full;  | 
                                                        |
| 1329 | 1328 | }  | 
                                                        
| 1330 | 1329 | |
| 1331 | 1330 | /**  | 
                                                        
@@ -1338,63 +1337,63 @@ discard block  | 
                                                    ||
| 1338 | 1337 | * @return array Liste de chemins  | 
                                                        
| 1339 | 1338 | **/  | 
                                                        
| 1340 | 1339 |  function creer_chemin() { | 
                                                        
| 1341 | - $path_a = _chemin();  | 
                                                        |
| 1342 | - static $c = '';  | 
                                                        |
| 1340 | + $path_a = _chemin();  | 
                                                        |
| 1341 | + static $c = '';  | 
                                                        |
| 1343 | 1342 | |
| 1344 | - // on calcule le chemin si le dossier skel a change  | 
                                                        |
| 1345 | -	if ($c != $GLOBALS['dossier_squelettes']) { | 
                                                        |
| 1346 | - // assurer le non plantage lors de la montee de version :  | 
                                                        |
| 1347 | - $c = $GLOBALS['dossier_squelettes'];  | 
                                                        |
| 1348 | -		$path_a = _chemin(''); // forcer un recalcul du chemin | 
                                                        |
| 1349 | - }  | 
                                                        |
| 1343 | + // on calcule le chemin si le dossier skel a change  | 
                                                        |
| 1344 | +    if ($c != $GLOBALS['dossier_squelettes']) { | 
                                                        |
| 1345 | + // assurer le non plantage lors de la montee de version :  | 
                                                        |
| 1346 | + $c = $GLOBALS['dossier_squelettes'];  | 
                                                        |
| 1347 | +        $path_a = _chemin(''); // forcer un recalcul du chemin | 
                                                        |
| 1348 | + }  | 
                                                        |
| 1350 | 1349 | |
| 1351 | - return $path_a;  | 
                                                        |
| 1350 | + return $path_a;  | 
                                                        |
| 1352 | 1351 | }  | 
                                                        
| 1353 | 1352 | |
| 1354 | 1353 | |
| 1355 | 1354 |  function lister_themes_prives() { | 
                                                        
| 1356 | - static $themes = null;  | 
                                                        |
| 1357 | -	if (is_null($themes)) { | 
                                                        |
| 1358 | - // si pas encore definie  | 
                                                        |
| 1359 | -		if (!defined('_SPIP_THEME_PRIVE')) { | 
                                                        |
| 1360 | -			define('_SPIP_THEME_PRIVE', 'spip'); | 
                                                        |
| 1361 | - }  | 
                                                        |
| 1362 | - $themes = array(_SPIP_THEME_PRIVE);  | 
                                                        |
| 1363 | - // lors d'une installation neuve, prefs n'est pas definie.  | 
                                                        |
| 1364 | -		if (isset($GLOBALS['visiteur_session']['prefs'])) { | 
                                                        |
| 1365 | - $prefs = $GLOBALS['visiteur_session']['prefs'];  | 
                                                        |
| 1366 | -		} else { | 
                                                        |
| 1367 | - $prefs = array();  | 
                                                        |
| 1368 | - }  | 
                                                        |
| 1369 | -		if (is_string($prefs)) { | 
                                                        |
| 1370 | - $prefs = unserialize($GLOBALS['visiteur_session']['prefs']);  | 
                                                        |
| 1371 | - }  | 
                                                        |
| 1372 | - if (  | 
                                                        |
| 1373 | - ((isset($prefs['theme']) and $theme = $prefs['theme'])  | 
                                                        |
| 1374 | - or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))  | 
                                                        |
| 1375 | - and $theme != _SPIP_THEME_PRIVE  | 
                                                        |
| 1376 | -		) { | 
                                                        |
| 1377 | - array_unshift($themes, $theme);  | 
                                                        |
| 1378 | - } // placer le theme choisi en tete  | 
                                                        |
| 1379 | - }  | 
                                                        |
| 1380 | -  | 
                                                        |
| 1381 | - return $themes;  | 
                                                        |
| 1355 | + static $themes = null;  | 
                                                        |
| 1356 | +    if (is_null($themes)) { | 
                                                        |
| 1357 | + // si pas encore definie  | 
                                                        |
| 1358 | +        if (!defined('_SPIP_THEME_PRIVE')) { | 
                                                        |
| 1359 | +            define('_SPIP_THEME_PRIVE', 'spip'); | 
                                                        |
| 1360 | + }  | 
                                                        |
| 1361 | + $themes = array(_SPIP_THEME_PRIVE);  | 
                                                        |
| 1362 | + // lors d'une installation neuve, prefs n'est pas definie.  | 
                                                        |
| 1363 | +        if (isset($GLOBALS['visiteur_session']['prefs'])) { | 
                                                        |
| 1364 | + $prefs = $GLOBALS['visiteur_session']['prefs'];  | 
                                                        |
| 1365 | +        } else { | 
                                                        |
| 1366 | + $prefs = array();  | 
                                                        |
| 1367 | + }  | 
                                                        |
| 1368 | +        if (is_string($prefs)) { | 
                                                        |
| 1369 | + $prefs = unserialize($GLOBALS['visiteur_session']['prefs']);  | 
                                                        |
| 1370 | + }  | 
                                                        |
| 1371 | + if (  | 
                                                        |
| 1372 | + ((isset($prefs['theme']) and $theme = $prefs['theme'])  | 
                                                        |
| 1373 | + or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))  | 
                                                        |
| 1374 | + and $theme != _SPIP_THEME_PRIVE  | 
                                                        |
| 1375 | +        ) { | 
                                                        |
| 1376 | + array_unshift($themes, $theme);  | 
                                                        |
| 1377 | + } // placer le theme choisi en tete  | 
                                                        |
| 1378 | + }  | 
                                                        |
| 1379 | +  | 
                                                        |
| 1380 | + return $themes;  | 
                                                        |
| 1382 | 1381 | }  | 
                                                        
| 1383 | 1382 | |
| 1384 | 1383 |  function find_in_theme($file, $subdir = '', $include = false) { | 
                                                        
| 1385 | - static $themefiles = array();  | 
                                                        |
| 1386 | -	if (isset($themefiles["$subdir$file"])) { | 
                                                        |
| 1387 | - return $themefiles["$subdir$file"];  | 
                                                        |
| 1388 | - }  | 
                                                        |
| 1389 | - $themes = lister_themes_prives();  | 
                                                        |
| 1390 | -	foreach ($themes as $theme) { | 
                                                        |
| 1391 | -		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { | 
                                                        |
| 1392 | - return $themefiles["$subdir$file"] = $f;  | 
                                                        |
| 1393 | - }  | 
                                                        |
| 1394 | - }  | 
                                                        |
| 1395 | -	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); | 
                                                        |
| 1384 | + static $themefiles = array();  | 
                                                        |
| 1385 | +    if (isset($themefiles["$subdir$file"])) { | 
                                                        |
| 1386 | + return $themefiles["$subdir$file"];  | 
                                                        |
| 1387 | + }  | 
                                                        |
| 1388 | + $themes = lister_themes_prives();  | 
                                                        |
| 1389 | +    foreach ($themes as $theme) { | 
                                                        |
| 1390 | +        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) { | 
                                                        |
| 1391 | + return $themefiles["$subdir$file"] = $f;  | 
                                                        |
| 1392 | + }  | 
                                                        |
| 1393 | + }  | 
                                                        |
| 1394 | +    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme'); | 
                                                        |
| 1396 | 1395 | |
| 1397 | - return $themefiles["$subdir$file"] = "";  | 
                                                        |
| 1396 | + return $themefiles["$subdir$file"] = "";  | 
                                                        |
| 1398 | 1397 | }  | 
                                                        
| 1399 | 1398 | |
| 1400 | 1399 | |
@@ -1418,28 +1417,28 @@ discard block  | 
                                                    ||
| 1418 | 1417 | * sinon chaîne vide.  | 
                                                        
| 1419 | 1418 | **/  | 
                                                        
| 1420 | 1419 |  function chemin_image($icone) { | 
                                                        
| 1421 | - static $icone_renommer;  | 
                                                        |
| 1422 | - // gerer le cas d'un double appel en evitant de refaire le travail inutilement  | 
                                                        |
| 1423 | -	if (strpos($icone, "/") !== false and file_exists($icone)) { | 
                                                        |
| 1424 | - return $icone;  | 
                                                        |
| 1425 | - }  | 
                                                        |
| 1426 | -  | 
                                                        |
| 1427 | - // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct  | 
                                                        |
| 1428 | -	if (preg_match(',[.](png|gif|jpg)$,', $icone) and $f = find_in_theme("images/$icone")) { | 
                                                        |
| 1429 | - return $f;  | 
                                                        |
| 1430 | - }  | 
                                                        |
| 1431 | - // sinon passer par le module de renommage  | 
                                                        |
| 1432 | -	if (is_null($icone_renommer)) { | 
                                                        |
| 1433 | -		$icone_renommer = charger_fonction('icone_renommer', 'inc', true); | 
                                                        |
| 1434 | - }  | 
                                                        |
| 1435 | -	if ($icone_renommer) { | 
                                                        |
| 1436 | - list($icone, $fonction) = $icone_renommer($icone, "");  | 
                                                        |
| 1437 | -		if (file_exists($icone)) { | 
                                                        |
| 1438 | - return $icone;  | 
                                                        |
| 1439 | - }  | 
                                                        |
| 1440 | - }  | 
                                                        |
| 1441 | -  | 
                                                        |
| 1442 | - return find_in_path($icone, _NOM_IMG_PACK);  | 
                                                        |
| 1420 | + static $icone_renommer;  | 
                                                        |
| 1421 | + // gerer le cas d'un double appel en evitant de refaire le travail inutilement  | 
                                                        |
| 1422 | +    if (strpos($icone, "/") !== false and file_exists($icone)) { | 
                                                        |
| 1423 | + return $icone;  | 
                                                        |
| 1424 | + }  | 
                                                        |
| 1425 | +  | 
                                                        |
| 1426 | + // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct  | 
                                                        |
| 1427 | +    if (preg_match(',[.](png|gif|jpg)$,', $icone) and $f = find_in_theme("images/$icone")) { | 
                                                        |
| 1428 | + return $f;  | 
                                                        |
| 1429 | + }  | 
                                                        |
| 1430 | + // sinon passer par le module de renommage  | 
                                                        |
| 1431 | +    if (is_null($icone_renommer)) { | 
                                                        |
| 1432 | +        $icone_renommer = charger_fonction('icone_renommer', 'inc', true); | 
                                                        |
| 1433 | + }  | 
                                                        |
| 1434 | +    if ($icone_renommer) { | 
                                                        |
| 1435 | + list($icone, $fonction) = $icone_renommer($icone, "");  | 
                                                        |
| 1436 | +        if (file_exists($icone)) { | 
                                                        |
| 1437 | + return $icone;  | 
                                                        |
| 1438 | + }  | 
                                                        |
| 1439 | + }  | 
                                                        |
| 1440 | +  | 
                                                        |
| 1441 | + return find_in_path($icone, _NOM_IMG_PACK);  | 
                                                        |
| 1443 | 1442 | }  | 
                                                        
| 1444 | 1443 | |
| 1445 | 1444 | //  | 
                                                        
@@ -1477,123 +1476,123 @@ discard block  | 
                                                    ||
| 1477 | 1476 | * - false : fichier introuvable  | 
                                                        
| 1478 | 1477 | **/  | 
                                                        
| 1479 | 1478 |  function find_in_path($file, $dirname = '', $include = false) { | 
                                                        
| 1480 | - static $dirs = array();  | 
                                                        |
| 1481 | - static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743  | 
                                                        |
| 1482 | - static $c = '';  | 
                                                        |
| 1483 | -  | 
                                                        |
| 1484 | - // on calcule le chemin si le dossier skel a change  | 
                                                        |
| 1485 | -	if ($c != $GLOBALS['dossier_squelettes']) { | 
                                                        |
| 1486 | - // assurer le non plantage lors de la montee de version :  | 
                                                        |
| 1487 | - $c = $GLOBALS['dossier_squelettes'];  | 
                                                        |
| 1488 | - creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig  | 
                                                        |
| 1489 | - }  | 
                                                        |
| 1490 | -  | 
                                                        |
| 1491 | -	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { | 
                                                        |
| 1492 | -		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { | 
                                                        |
| 1493 | - return false;  | 
                                                        |
| 1494 | - }  | 
                                                        |
| 1495 | -		if ($include and !isset($inc[$dirname][$file])) { | 
                                                        |
| 1496 | - include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];  | 
                                                        |
| 1497 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;  | 
                                                        |
| 1498 | - }  | 
                                                        |
| 1499 | -  | 
                                                        |
| 1500 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];  | 
                                                        |
| 1501 | - }  | 
                                                        |
| 1502 | -  | 
                                                        |
| 1503 | - $a = strrpos($file, '/');  | 
                                                        |
| 1504 | -	if ($a !== false) { | 
                                                        |
| 1505 | - $dirname .= substr($file, 0, ++$a);  | 
                                                        |
| 1506 | - $file = substr($file, $a);  | 
                                                        |
| 1507 | - }  | 
                                                        |
| 1508 | -  | 
                                                        |
| 1509 | -	foreach (creer_chemin() as $dir) { | 
                                                        |
| 1510 | -		if (!isset($dirs[$a = $dir . $dirname])) { | 
                                                        |
| 1511 | - $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);  | 
                                                        |
| 1512 | - }  | 
                                                        |
| 1513 | -		if ($dirs[$a]) { | 
                                                        |
| 1514 | -			if (file_exists(_ROOT_CWD . ($a .= $file))) { | 
                                                        |
| 1515 | -				if ($include and !isset($inc[$dirname][$file])) { | 
                                                        |
| 1516 | - include_once _ROOT_CWD . $a;  | 
                                                        |
| 1517 | - $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;  | 
                                                        |
| 1518 | - }  | 
                                                        |
| 1519 | -				if (!defined('_SAUVER_CHEMIN')) { | 
                                                        |
| 1520 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher  | 
                                                        |
| 1521 | -					if (is_null($GLOBALS['path_files'])) { | 
                                                        |
| 1522 | - return $a;  | 
                                                        |
| 1523 | - }  | 
                                                        |
| 1524 | -					define('_SAUVER_CHEMIN', true); | 
                                                        |
| 1525 | - }  | 
                                                        |
| 1526 | -  | 
                                                        |
| 1527 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;  | 
                                                        |
| 1528 | - }  | 
                                                        |
| 1529 | - }  | 
                                                        |
| 1530 | - }  | 
                                                        |
| 1531 | -  | 
                                                        |
| 1532 | -	if ($include) { | 
                                                        |
| 1533 | -		spip_log("include_spip $dirname$file non trouve"); | 
                                                        |
| 1534 | -		if ($include === 'required') { | 
                                                        |
| 1535 | - echo '<pre>',  | 
                                                        |
| 1536 | - "<strong>Erreur Fatale</strong><br />";  | 
                                                        |
| 1537 | -			if (function_exists('debug_print_backtrace')) { | 
                                                        |
| 1538 | - echo debug_print_backtrace();  | 
                                                        |
| 1539 | - }  | 
                                                        |
| 1540 | - echo '</pre>';  | 
                                                        |
| 1541 | -			die("Erreur interne: ne peut inclure $dirname$file"); | 
                                                        |
| 1542 | - }  | 
                                                        |
| 1543 | - }  | 
                                                        |
| 1544 | -  | 
                                                        |
| 1545 | -	if (!defined('_SAUVER_CHEMIN')) { | 
                                                        |
| 1546 | - // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher  | 
                                                        |
| 1547 | -		if (is_null($GLOBALS['path_files'])) { | 
                                                        |
| 1548 | - return false;  | 
                                                        |
| 1549 | - }  | 
                                                        |
| 1550 | -		define('_SAUVER_CHEMIN', true); | 
                                                        |
| 1551 | - }  | 
                                                        |
| 1552 | -  | 
                                                        |
| 1553 | - return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;  | 
                                                        |
| 1479 | + static $dirs = array();  | 
                                                        |
| 1480 | + static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743  | 
                                                        |
| 1481 | + static $c = '';  | 
                                                        |
| 1482 | +  | 
                                                        |
| 1483 | + // on calcule le chemin si le dossier skel a change  | 
                                                        |
| 1484 | +    if ($c != $GLOBALS['dossier_squelettes']) { | 
                                                        |
| 1485 | + // assurer le non plantage lors de la montee de version :  | 
                                                        |
| 1486 | + $c = $GLOBALS['dossier_squelettes'];  | 
                                                        |
| 1487 | + creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig  | 
                                                        |
| 1488 | + }  | 
                                                        |
| 1489 | +  | 
                                                        |
| 1490 | +    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) { | 
                                                        |
| 1491 | +        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) { | 
                                                        |
| 1492 | + return false;  | 
                                                        |
| 1493 | + }  | 
                                                        |
| 1494 | +        if ($include and !isset($inc[$dirname][$file])) { | 
                                                        |
| 1495 | + include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];  | 
                                                        |
| 1496 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;  | 
                                                        |
| 1497 | + }  | 
                                                        |
| 1498 | +  | 
                                                        |
| 1499 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];  | 
                                                        |
| 1500 | + }  | 
                                                        |
| 1501 | +  | 
                                                        |
| 1502 | + $a = strrpos($file, '/');  | 
                                                        |
| 1503 | +    if ($a !== false) { | 
                                                        |
| 1504 | + $dirname .= substr($file, 0, ++$a);  | 
                                                        |
| 1505 | + $file = substr($file, $a);  | 
                                                        |
| 1506 | + }  | 
                                                        |
| 1507 | +  | 
                                                        |
| 1508 | +    foreach (creer_chemin() as $dir) { | 
                                                        |
| 1509 | +        if (!isset($dirs[$a = $dir . $dirname])) { | 
                                                        |
| 1510 | + $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);  | 
                                                        |
| 1511 | + }  | 
                                                        |
| 1512 | +        if ($dirs[$a]) { | 
                                                        |
| 1513 | +            if (file_exists(_ROOT_CWD . ($a .= $file))) { | 
                                                        |
| 1514 | +                if ($include and !isset($inc[$dirname][$file])) { | 
                                                        |
| 1515 | + include_once _ROOT_CWD . $a;  | 
                                                        |
| 1516 | + $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;  | 
                                                        |
| 1517 | + }  | 
                                                        |
| 1518 | +                if (!defined('_SAUVER_CHEMIN')) { | 
                                                        |
| 1519 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher  | 
                                                        |
| 1520 | +                    if (is_null($GLOBALS['path_files'])) { | 
                                                        |
| 1521 | + return $a;  | 
                                                        |
| 1522 | + }  | 
                                                        |
| 1523 | +                    define('_SAUVER_CHEMIN', true); | 
                                                        |
| 1524 | + }  | 
                                                        |
| 1525 | +  | 
                                                        |
| 1526 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;  | 
                                                        |
| 1527 | + }  | 
                                                        |
| 1528 | + }  | 
                                                        |
| 1529 | + }  | 
                                                        |
| 1530 | +  | 
                                                        |
| 1531 | +    if ($include) { | 
                                                        |
| 1532 | +        spip_log("include_spip $dirname$file non trouve"); | 
                                                        |
| 1533 | +        if ($include === 'required') { | 
                                                        |
| 1534 | + echo '<pre>',  | 
                                                        |
| 1535 | + "<strong>Erreur Fatale</strong><br />";  | 
                                                        |
| 1536 | +            if (function_exists('debug_print_backtrace')) { | 
                                                        |
| 1537 | + echo debug_print_backtrace();  | 
                                                        |
| 1538 | + }  | 
                                                        |
| 1539 | + echo '</pre>';  | 
                                                        |
| 1540 | +            die("Erreur interne: ne peut inclure $dirname$file"); | 
                                                        |
| 1541 | + }  | 
                                                        |
| 1542 | + }  | 
                                                        |
| 1543 | +  | 
                                                        |
| 1544 | +    if (!defined('_SAUVER_CHEMIN')) { | 
                                                        |
| 1545 | + // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher  | 
                                                        |
| 1546 | +        if (is_null($GLOBALS['path_files'])) { | 
                                                        |
| 1547 | + return false;  | 
                                                        |
| 1548 | + }  | 
                                                        |
| 1549 | +        define('_SAUVER_CHEMIN', true); | 
                                                        |
| 1550 | + }  | 
                                                        |
| 1551 | +  | 
                                                        |
| 1552 | + return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;  | 
                                                        |
| 1554 | 1553 | }  | 
                                                        
| 1555 | 1554 | |
| 1556 | 1555 |  function clear_path_cache() { | 
                                                        
| 1557 | - $GLOBALS['path_files'] = array();  | 
                                                        |
| 1558 | - spip_unlink(_CACHE_CHEMIN);  | 
                                                        |
| 1556 | + $GLOBALS['path_files'] = array();  | 
                                                        |
| 1557 | + spip_unlink(_CACHE_CHEMIN);  | 
                                                        |
| 1559 | 1558 | }  | 
                                                        
| 1560 | 1559 | |
| 1561 | 1560 |  function load_path_cache() { | 
                                                        
| 1562 | - // charger le path des plugins  | 
                                                        |
| 1563 | -	if (@is_readable(_CACHE_PLUGINS_PATH)) { | 
                                                        |
| 1564 | - include_once(_CACHE_PLUGINS_PATH);  | 
                                                        |
| 1565 | - }  | 
                                                        |
| 1566 | - $GLOBALS['path_files'] = array();  | 
                                                        |
| 1567 | - // si le visiteur est admin,  | 
                                                        |
| 1568 | - // on ne recharge pas le cache pour forcer sa mise a jour  | 
                                                        |
| 1569 | - if (  | 
                                                        |
| 1570 | - // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier  | 
                                                        |
| 1571 | - //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')  | 
                                                        |
| 1572 | - // utiliser le cookie est un pis aller qui marche 'en general'  | 
                                                        |
| 1573 | - // on blinde par un second test au moment de la lecture de la session  | 
                                                        |
| 1574 | - // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])  | 
                                                        |
| 1575 | - // et en ignorant ce cache en cas de recalcul explicite  | 
                                                        |
| 1576 | -	!_request('var_mode') | 
                                                        |
| 1577 | -	) { | 
                                                        |
| 1578 | - // on essaye de lire directement sans verrou pour aller plus vite  | 
                                                        |
| 1579 | -		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { | 
                                                        |
| 1580 | - // mais si semble corrompu on relit avec un verrou  | 
                                                        |
| 1581 | -			if (!$GLOBALS['path_files'] = unserialize($contenu)) { | 
                                                        |
| 1582 | - lire_fichier(_CACHE_CHEMIN, $contenu);  | 
                                                        |
| 1583 | -				if (!$GLOBALS['path_files'] = unserialize($contenu)) { | 
                                                        |
| 1584 | - $GLOBALS['path_files'] = array();  | 
                                                        |
| 1585 | - }  | 
                                                        |
| 1586 | - }  | 
                                                        |
| 1587 | - }  | 
                                                        |
| 1588 | - }  | 
                                                        |
| 1561 | + // charger le path des plugins  | 
                                                        |
| 1562 | +    if (@is_readable(_CACHE_PLUGINS_PATH)) { | 
                                                        |
| 1563 | + include_once(_CACHE_PLUGINS_PATH);  | 
                                                        |
| 1564 | + }  | 
                                                        |
| 1565 | + $GLOBALS['path_files'] = array();  | 
                                                        |
| 1566 | + // si le visiteur est admin,  | 
                                                        |
| 1567 | + // on ne recharge pas le cache pour forcer sa mise a jour  | 
                                                        |
| 1568 | + if (  | 
                                                        |
| 1569 | + // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier  | 
                                                        |
| 1570 | + //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')  | 
                                                        |
| 1571 | + // utiliser le cookie est un pis aller qui marche 'en general'  | 
                                                        |
| 1572 | + // on blinde par un second test au moment de la lecture de la session  | 
                                                        |
| 1573 | + // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])  | 
                                                        |
| 1574 | + // et en ignorant ce cache en cas de recalcul explicite  | 
                                                        |
| 1575 | +    !_request('var_mode') | 
                                                        |
| 1576 | +    ) { | 
                                                        |
| 1577 | + // on essaye de lire directement sans verrou pour aller plus vite  | 
                                                        |
| 1578 | +        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) { | 
                                                        |
| 1579 | + // mais si semble corrompu on relit avec un verrou  | 
                                                        |
| 1580 | +            if (!$GLOBALS['path_files'] = unserialize($contenu)) { | 
                                                        |
| 1581 | + lire_fichier(_CACHE_CHEMIN, $contenu);  | 
                                                        |
| 1582 | +                if (!$GLOBALS['path_files'] = unserialize($contenu)) { | 
                                                        |
| 1583 | + $GLOBALS['path_files'] = array();  | 
                                                        |
| 1584 | + }  | 
                                                        |
| 1585 | + }  | 
                                                        |
| 1586 | + }  | 
                                                        |
| 1587 | + }  | 
                                                        |
| 1589 | 1588 | }  | 
                                                        
| 1590 | 1589 | |
| 1591 | 1590 |  function save_path_cache() { | 
                                                        
| 1592 | -	if (defined('_SAUVER_CHEMIN') | 
                                                        |
| 1593 | - and _SAUVER_CHEMIN  | 
                                                        |
| 1594 | -	) { | 
                                                        |
| 1595 | - ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));  | 
                                                        |
| 1596 | - }  | 
                                                        |
| 1591 | +    if (defined('_SAUVER_CHEMIN') | 
                                                        |
| 1592 | + and _SAUVER_CHEMIN  | 
                                                        |
| 1593 | +    ) { | 
                                                        |
| 1594 | + ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));  | 
                                                        |
| 1595 | + }  | 
                                                        |
| 1597 | 1596 | }  | 
                                                        
| 1598 | 1597 | |
| 1599 | 1598 | |
@@ -1613,33 +1612,33 @@ discard block  | 
                                                    ||
| 1613 | 1612 | * @return array  | 
                                                        
| 1614 | 1613 | */  | 
                                                        
| 1615 | 1614 |  function find_all_in_path($dir, $pattern, $recurs = false) { | 
                                                        
| 1616 | - $liste_fichiers = array();  | 
                                                        |
| 1617 | - $maxfiles = 10000;  | 
                                                        |
| 1618 | -  | 
                                                        |
| 1619 | - // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue  | 
                                                        |
| 1620 | - // on a pas encore inclus flock.php  | 
                                                        |
| 1621 | -	if (!function_exists('preg_files')) { | 
                                                        |
| 1622 | - include_once _ROOT_RESTREINT . 'inc/flock.php';  | 
                                                        |
| 1623 | - }  | 
                                                        |
| 1624 | -  | 
                                                        |
| 1625 | - // Parcourir le chemin  | 
                                                        |
| 1626 | -	foreach (creer_chemin() as $d) { | 
                                                        |
| 1627 | - $f = $d . $dir;  | 
                                                        |
| 1628 | -		if (@is_dir($f)) { | 
                                                        |
| 1629 | - $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);  | 
                                                        |
| 1630 | -			foreach ($liste as $chemin) { | 
                                                        |
| 1631 | - $nom = basename($chemin);  | 
                                                        |
| 1632 | - // ne prendre que les fichiers pas deja trouves  | 
                                                        |
| 1633 | - // car find_in_path prend le premier qu'il trouve,  | 
                                                        |
| 1634 | - // les autres sont donc masques  | 
                                                        |
| 1635 | -				if (!isset($liste_fichiers[$nom])) { | 
                                                        |
| 1636 | - $liste_fichiers[$nom] = $chemin;  | 
                                                        |
| 1637 | - }  | 
                                                        |
| 1638 | - }  | 
                                                        |
| 1639 | - }  | 
                                                        |
| 1640 | - }  | 
                                                        |
| 1641 | -  | 
                                                        |
| 1642 | - return $liste_fichiers;  | 
                                                        |
| 1615 | + $liste_fichiers = array();  | 
                                                        |
| 1616 | + $maxfiles = 10000;  | 
                                                        |
| 1617 | +  | 
                                                        |
| 1618 | + // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue  | 
                                                        |
| 1619 | + // on a pas encore inclus flock.php  | 
                                                        |
| 1620 | +    if (!function_exists('preg_files')) { | 
                                                        |
| 1621 | + include_once _ROOT_RESTREINT . 'inc/flock.php';  | 
                                                        |
| 1622 | + }  | 
                                                        |
| 1623 | +  | 
                                                        |
| 1624 | + // Parcourir le chemin  | 
                                                        |
| 1625 | +    foreach (creer_chemin() as $d) { | 
                                                        |
| 1626 | + $f = $d . $dir;  | 
                                                        |
| 1627 | +        if (@is_dir($f)) { | 
                                                        |
| 1628 | + $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);  | 
                                                        |
| 1629 | +            foreach ($liste as $chemin) { | 
                                                        |
| 1630 | + $nom = basename($chemin);  | 
                                                        |
| 1631 | + // ne prendre que les fichiers pas deja trouves  | 
                                                        |
| 1632 | + // car find_in_path prend le premier qu'il trouve,  | 
                                                        |
| 1633 | + // les autres sont donc masques  | 
                                                        |
| 1634 | +                if (!isset($liste_fichiers[$nom])) { | 
                                                        |
| 1635 | + $liste_fichiers[$nom] = $chemin;  | 
                                                        |
| 1636 | + }  | 
                                                        |
| 1637 | + }  | 
                                                        |
| 1638 | + }  | 
                                                        |
| 1639 | + }  | 
                                                        |
| 1640 | +  | 
                                                        |
| 1641 | + return $liste_fichiers;  | 
                                                        |
| 1643 | 1642 | }  | 
                                                        
| 1644 | 1643 | |
| 1645 | 1644 | /**  | 
                                                        
@@ -1648,10 +1647,10 @@ discard block  | 
                                                    ||
| 1648 | 1647 | * @return bool  | 
                                                        
| 1649 | 1648 | */  | 
                                                        
| 1650 | 1649 |  function autoriser_sans_cookie($nom) { | 
                                                        
| 1651 | -	static $autsanscookie = array('install', 'base_repair'); | 
                                                        |
| 1652 | -	$nom = preg_replace('/.php[3]?$/', '', basename($nom)); | 
                                                        |
| 1650 | +    static $autsanscookie = array('install', 'base_repair'); | 
                                                        |
| 1651 | +    $nom = preg_replace('/.php[3]?$/', '', basename($nom)); | 
                                                        |
| 1653 | 1652 | |
| 1654 | - return in_array($nom, $autsanscookie);  | 
                                                        |
| 1653 | + return in_array($nom, $autsanscookie);  | 
                                                        |
| 1655 | 1654 | }  | 
                                                        
| 1656 | 1655 | |
| 1657 | 1656 | /**  | 
                                                        
@@ -1677,99 +1676,99 @@ discard block  | 
                                                    ||
| 1677 | 1676 | * (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip)  | 
                                                        
| 1678 | 1677 | */  | 
                                                        
| 1679 | 1678 |  function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) { | 
                                                        
| 1680 | -	if ($public === null) { | 
                                                        |
| 1681 | - $public = !test_espace_prive();  | 
                                                        |
| 1682 | - }  | 
                                                        |
| 1683 | - $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...  | 
                                                        |
| 1684 | -  | 
                                                        |
| 1685 | -	if (!$public) { | 
                                                        |
| 1686 | -		if (!$entite) { | 
                                                        |
| 1687 | - return '';  | 
                                                        |
| 1688 | - }  | 
                                                        |
| 1689 | -		if (!function_exists('generer_url_ecrire_objet')) { | 
                                                        |
| 1690 | -			include_spip('inc/urls'); | 
                                                        |
| 1691 | - }  | 
                                                        |
| 1692 | - $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);  | 
                                                        |
| 1693 | -	} else { | 
                                                        |
| 1694 | -		if ($type === null) { | 
                                                        |
| 1695 | - $type = (isset($GLOBALS['type_urls']))  | 
                                                        |
| 1696 | - ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options  | 
                                                        |
| 1697 | - : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues  | 
                                                        |
| 1698 | - ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut  | 
                                                        |
| 1699 | - }  | 
                                                        |
| 1700 | -  | 
                                                        |
| 1701 | - $f = charger_fonction($type, 'urls', true);  | 
                                                        |
| 1702 | - // se rabattre sur les urls page si les urls perso non dispo  | 
                                                        |
| 1703 | -		if (!$f) { | 
                                                        |
| 1704 | -			$f = charger_fonction('page', 'urls', true); | 
                                                        |
| 1705 | - }  | 
                                                        |
| 1706 | -  | 
                                                        |
| 1707 | - // si $entite='', on veut la fonction de passage URL ==> id  | 
                                                        |
| 1708 | - // sinon on veut effectuer le passage id ==> URL  | 
                                                        |
| 1709 | -		if (!$entite) { | 
                                                        |
| 1710 | - return $f;  | 
                                                        |
| 1711 | - }  | 
                                                        |
| 1712 | -  | 
                                                        |
| 1713 | - // mais d'abord il faut tester le cas des urls sur une  | 
                                                        |
| 1714 | - // base distante  | 
                                                        |
| 1715 | - if (is_string($public)  | 
                                                        |
| 1716 | -			and $g = charger_fonction('connect', 'urls', true) | 
                                                        |
| 1717 | -		) { | 
                                                        |
| 1718 | - $f = $g;  | 
                                                        |
| 1719 | - }  | 
                                                        |
| 1720 | -  | 
                                                        |
| 1721 | - $res = $f(intval($id), $entite, $args, $ancre, $public);  | 
                                                        |
| 1722 | -  | 
                                                        |
| 1723 | - }  | 
                                                        |
| 1724 | -	if ($res) { | 
                                                        |
| 1725 | - return $res;  | 
                                                        |
| 1726 | - }  | 
                                                        |
| 1727 | - // Sinon c'est un raccourci ou compat SPIP < 2  | 
                                                        |
| 1728 | -	if (!function_exists($f = 'generer_url_' . $entite)) { | 
                                                        |
| 1729 | -		if (!function_exists($f .= '_dist')) { | 
                                                        |
| 1730 | - $f = '';  | 
                                                        |
| 1731 | - }  | 
                                                        |
| 1732 | - }  | 
                                                        |
| 1733 | -	if ($f) { | 
                                                        |
| 1734 | - $url = $f($id, $args, $ancre);  | 
                                                        |
| 1735 | -		if (strlen($args)) { | 
                                                        |
| 1736 | - $url .= strstr($url, '?')  | 
                                                        |
| 1737 | - ? '&' . $args  | 
                                                        |
| 1738 | - : '?' . $args;  | 
                                                        |
| 1739 | - }  | 
                                                        |
| 1740 | -  | 
                                                        |
| 1741 | - return $url;  | 
                                                        |
| 1742 | - }  | 
                                                        |
| 1743 | - // On a ete gentil mais la ....  | 
                                                        |
| 1744 | -	spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); | 
                                                        |
| 1745 | -  | 
                                                        |
| 1746 | - return '';  | 
                                                        |
| 1679 | +    if ($public === null) { | 
                                                        |
| 1680 | + $public = !test_espace_prive();  | 
                                                        |
| 1681 | + }  | 
                                                        |
| 1682 | + $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...  | 
                                                        |
| 1683 | +  | 
                                                        |
| 1684 | +    if (!$public) { | 
                                                        |
| 1685 | +        if (!$entite) { | 
                                                        |
| 1686 | + return '';  | 
                                                        |
| 1687 | + }  | 
                                                        |
| 1688 | +        if (!function_exists('generer_url_ecrire_objet')) { | 
                                                        |
| 1689 | +            include_spip('inc/urls'); | 
                                                        |
| 1690 | + }  | 
                                                        |
| 1691 | + $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);  | 
                                                        |
| 1692 | +    } else { | 
                                                        |
| 1693 | +        if ($type === null) { | 
                                                        |
| 1694 | + $type = (isset($GLOBALS['type_urls']))  | 
                                                        |
| 1695 | + ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options  | 
                                                        |
| 1696 | + : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues  | 
                                                        |
| 1697 | + ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut  | 
                                                        |
| 1698 | + }  | 
                                                        |
| 1699 | +  | 
                                                        |
| 1700 | + $f = charger_fonction($type, 'urls', true);  | 
                                                        |
| 1701 | + // se rabattre sur les urls page si les urls perso non dispo  | 
                                                        |
| 1702 | +        if (!$f) { | 
                                                        |
| 1703 | +            $f = charger_fonction('page', 'urls', true); | 
                                                        |
| 1704 | + }  | 
                                                        |
| 1705 | +  | 
                                                        |
| 1706 | + // si $entite='', on veut la fonction de passage URL ==> id  | 
                                                        |
| 1707 | + // sinon on veut effectuer le passage id ==> URL  | 
                                                        |
| 1708 | +        if (!$entite) { | 
                                                        |
| 1709 | + return $f;  | 
                                                        |
| 1710 | + }  | 
                                                        |
| 1711 | +  | 
                                                        |
| 1712 | + // mais d'abord il faut tester le cas des urls sur une  | 
                                                        |
| 1713 | + // base distante  | 
                                                        |
| 1714 | + if (is_string($public)  | 
                                                        |
| 1715 | +            and $g = charger_fonction('connect', 'urls', true) | 
                                                        |
| 1716 | +        ) { | 
                                                        |
| 1717 | + $f = $g;  | 
                                                        |
| 1718 | + }  | 
                                                        |
| 1719 | +  | 
                                                        |
| 1720 | + $res = $f(intval($id), $entite, $args, $ancre, $public);  | 
                                                        |
| 1721 | +  | 
                                                        |
| 1722 | + }  | 
                                                        |
| 1723 | +    if ($res) { | 
                                                        |
| 1724 | + return $res;  | 
                                                        |
| 1725 | + }  | 
                                                        |
| 1726 | + // Sinon c'est un raccourci ou compat SPIP < 2  | 
                                                        |
| 1727 | +    if (!function_exists($f = 'generer_url_' . $entite)) { | 
                                                        |
| 1728 | +        if (!function_exists($f .= '_dist')) { | 
                                                        |
| 1729 | + $f = '';  | 
                                                        |
| 1730 | + }  | 
                                                        |
| 1731 | + }  | 
                                                        |
| 1732 | +    if ($f) { | 
                                                        |
| 1733 | + $url = $f($id, $args, $ancre);  | 
                                                        |
| 1734 | +        if (strlen($args)) { | 
                                                        |
| 1735 | + $url .= strstr($url, '?')  | 
                                                        |
| 1736 | + ? '&' . $args  | 
                                                        |
| 1737 | + : '?' . $args;  | 
                                                        |
| 1738 | + }  | 
                                                        |
| 1739 | +  | 
                                                        |
| 1740 | + return $url;  | 
                                                        |
| 1741 | + }  | 
                                                        |
| 1742 | + // On a ete gentil mais la ....  | 
                                                        |
| 1743 | +    spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public"); | 
                                                        |
| 1744 | +  | 
                                                        |
| 1745 | + return '';  | 
                                                        |
| 1747 | 1746 | }  | 
                                                        
| 1748 | 1747 | |
| 1749 | 1748 |  function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') { | 
                                                        
| 1750 | - $exec = objet_info($entite, 'url_edit');  | 
                                                        |
| 1751 | - $url = generer_url_ecrire($exec, $args);  | 
                                                        |
| 1752 | -	if (intval($id)) { | 
                                                        |
| 1753 | - $url = parametre_url($url, id_table_objet($entite), $id);  | 
                                                        |
| 1754 | -	} else { | 
                                                        |
| 1755 | - $url = parametre_url($url, 'new', 'oui');  | 
                                                        |
| 1756 | - }  | 
                                                        |
| 1757 | -	if ($ancre) { | 
                                                        |
| 1758 | - $url = ancre_url($url, $ancre);  | 
                                                        |
| 1759 | - }  | 
                                                        |
| 1749 | + $exec = objet_info($entite, 'url_edit');  | 
                                                        |
| 1750 | + $url = generer_url_ecrire($exec, $args);  | 
                                                        |
| 1751 | +    if (intval($id)) { | 
                                                        |
| 1752 | + $url = parametre_url($url, id_table_objet($entite), $id);  | 
                                                        |
| 1753 | +    } else { | 
                                                        |
| 1754 | + $url = parametre_url($url, 'new', 'oui');  | 
                                                        |
| 1755 | + }  | 
                                                        |
| 1756 | +    if ($ancre) { | 
                                                        |
| 1757 | + $url = ancre_url($url, $ancre);  | 
                                                        |
| 1758 | + }  | 
                                                        |
| 1760 | 1759 | |
| 1761 | - return $url;  | 
                                                        |
| 1760 | + return $url;  | 
                                                        |
| 1762 | 1761 | }  | 
                                                        
| 1763 | 1762 | |
| 1764 | 1763 | // http://code.spip.net/@urls_connect_dist  | 
                                                        
| 1765 | 1764 |  function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) { | 
                                                        
| 1766 | -	include_spip('base/connect_sql'); | 
                                                        |
| 1767 | - $id_type = id_table_objet($entite, $public);  | 
                                                        |
| 1765 | +    include_spip('base/connect_sql'); | 
                                                        |
| 1766 | + $id_type = id_table_objet($entite, $public);  | 
                                                        |
| 1768 | 1767 | |
| 1769 | -	return _DIR_RACINE . get_spip_script('./') | 
                                                        |
| 1770 | - . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"  | 
                                                        |
| 1771 | - . (!$args ? '' : "&$args")  | 
                                                        |
| 1772 | - . (!$ancre ? '' : "#$ancre");  | 
                                                        |
| 1768 | +    return _DIR_RACINE . get_spip_script('./') | 
                                                        |
| 1769 | + . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"  | 
                                                        |
| 1770 | + . (!$args ? '' : "&$args")  | 
                                                        |
| 1771 | + . (!$ancre ? '' : "#$ancre");  | 
                                                        |
| 1773 | 1772 | }  | 
                                                        
| 1774 | 1773 | |
| 1775 | 1774 | |
@@ -1780,32 +1779,32 @@ discard block  | 
                                                    ||
| 1780 | 1779 | * @return string  | 
                                                        
| 1781 | 1780 | */  | 
                                                        
| 1782 | 1781 |  function urlencode_1738($url) { | 
                                                        
| 1783 | -	if (preg_match(',[^\x00-\x7E],sS', $url)) { | 
                                                        |
| 1784 | - $uri = '';  | 
                                                        |
| 1785 | -		for ($i = 0; $i < strlen($url); $i++) { | 
                                                        |
| 1786 | -			if (ord($a = $url[$i]) > 127) { | 
                                                        |
| 1787 | - $a = rawurlencode($a);  | 
                                                        |
| 1788 | - }  | 
                                                        |
| 1789 | - $uri .= $a;  | 
                                                        |
| 1790 | - }  | 
                                                        |
| 1791 | - $url = $uri;  | 
                                                        |
| 1792 | - }  | 
                                                        |
| 1782 | +    if (preg_match(',[^\x00-\x7E],sS', $url)) { | 
                                                        |
| 1783 | + $uri = '';  | 
                                                        |
| 1784 | +        for ($i = 0; $i < strlen($url); $i++) { | 
                                                        |
| 1785 | +            if (ord($a = $url[$i]) > 127) { | 
                                                        |
| 1786 | + $a = rawurlencode($a);  | 
                                                        |
| 1787 | + }  | 
                                                        |
| 1788 | + $uri .= $a;  | 
                                                        |
| 1789 | + }  | 
                                                        |
| 1790 | + $url = $uri;  | 
                                                        |
| 1791 | + }  | 
                                                        |
| 1793 | 1792 | |
| 1794 | - return quote_amp($url);  | 
                                                        |
| 1793 | + return quote_amp($url);  | 
                                                        |
| 1795 | 1794 | }  | 
                                                        
| 1796 | 1795 | |
| 1797 | 1796 | // http://code.spip.net/@generer_url_entite_absolue  | 
                                                        
| 1798 | 1797 |  function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) { | 
                                                        
| 1799 | -	if (!$connect) { | 
                                                        |
| 1800 | - $connect = true;  | 
                                                        |
| 1801 | - }  | 
                                                        |
| 1802 | - $h = generer_url_entite($id, $entite, $args, $ancre, $connect);  | 
                                                        |
| 1803 | -	if (!preg_match(',^\w+:,', $h)) { | 
                                                        |
| 1804 | -		include_spip('inc/filtres_mini'); | 
                                                        |
| 1805 | - $h = url_absolue($h);  | 
                                                        |
| 1806 | - }  | 
                                                        |
| 1798 | +    if (!$connect) { | 
                                                        |
| 1799 | + $connect = true;  | 
                                                        |
| 1800 | + }  | 
                                                        |
| 1801 | + $h = generer_url_entite($id, $entite, $args, $ancre, $connect);  | 
                                                        |
| 1802 | +    if (!preg_match(',^\w+:,', $h)) { | 
                                                        |
| 1803 | +        include_spip('inc/filtres_mini'); | 
                                                        |
| 1804 | + $h = url_absolue($h);  | 
                                                        |
| 1805 | + }  | 
                                                        |
| 1807 | 1806 | |
| 1808 | - return $h;  | 
                                                        |
| 1807 | + return $h;  | 
                                                        |
| 1809 | 1808 | }  | 
                                                        
| 1810 | 1809 | |
| 1811 | 1810 | |
@@ -1821,11 +1820,11 @@ discard block  | 
                                                    ||
| 1821 | 1820 | * true si la valeur est considérée active ; false sinon.  | 
                                                        
| 1822 | 1821 | **/  | 
                                                        
| 1823 | 1822 |  function test_valeur_serveur($truc) { | 
                                                        
| 1824 | -	if (!$truc) { | 
                                                        |
| 1825 | - return false;  | 
                                                        |
| 1826 | - }  | 
                                                        |
| 1823 | +    if (!$truc) { | 
                                                        |
| 1824 | + return false;  | 
                                                        |
| 1825 | + }  | 
                                                        |
| 1827 | 1826 | |
| 1828 | - return (strtolower($truc) !== 'off');  | 
                                                        |
| 1827 | + return (strtolower($truc) !== 'off');  | 
                                                        |
| 1829 | 1828 | }  | 
                                                        
| 1830 | 1829 | |
| 1831 | 1830 | //  | 
                                                        
@@ -1853,80 +1852,80 @@ discard block  | 
                                                    ||
| 1853 | 1852 | */  | 
                                                        
| 1854 | 1853 |  function url_de_base($profondeur = null) { | 
                                                        
| 1855 | 1854 | |
| 1856 | - static $url = array();  | 
                                                        |
| 1857 | -	if (is_array($profondeur)) { | 
                                                        |
| 1858 | - return $url = $profondeur;  | 
                                                        |
| 1859 | - }  | 
                                                        |
| 1860 | -	if ($profondeur === false) { | 
                                                        |
| 1861 | - return $url;  | 
                                                        |
| 1862 | - }  | 
                                                        |
| 1863 | -  | 
                                                        |
| 1864 | -	if (is_null($profondeur)) { | 
                                                        |
| 1865 | - $profondeur = $GLOBALS['profondeur_url'];  | 
                                                        |
| 1866 | - }  | 
                                                        |
| 1867 | -  | 
                                                        |
| 1868 | -	if (isset($url[$profondeur])) { | 
                                                        |
| 1869 | - return $url[$profondeur];  | 
                                                        |
| 1870 | - }  | 
                                                        |
| 1871 | -  | 
                                                        |
| 1872 | - $http = 'http';  | 
                                                        |
| 1873 | -  | 
                                                        |
| 1874 | - if (  | 
                                                        |
| 1875 | - isset($_SERVER["SCRIPT_URI"])  | 
                                                        |
| 1876 | - and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https'  | 
                                                        |
| 1877 | -	) { | 
                                                        |
| 1878 | - $http = 'https';  | 
                                                        |
| 1879 | - } elseif (  | 
                                                        |
| 1880 | - isset($_SERVER['HTTPS'])  | 
                                                        |
| 1881 | - and test_valeur_serveur($_SERVER['HTTPS'])  | 
                                                        |
| 1882 | -	) { | 
                                                        |
| 1883 | - $http = 'https';  | 
                                                        |
| 1884 | - }  | 
                                                        |
| 1885 | -  | 
                                                        |
| 1886 | - // note : HTTP_HOST contient le :port si necessaire  | 
                                                        |
| 1887 | - $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;  | 
                                                        |
| 1888 | - // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback  | 
                                                        |
| 1889 | -	if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { | 
                                                        |
| 1890 | - $host = $GLOBALS['meta']['adresse_site'];  | 
                                                        |
| 1891 | -		if ($scheme = parse_url($host, PHP_URL_SCHEME)) { | 
                                                        |
| 1892 | - $http = $scheme;  | 
                                                        |
| 1893 | -			$host = str_replace("{$scheme}://", '', $host); | 
                                                        |
| 1894 | - }  | 
                                                        |
| 1895 | - }  | 
                                                        |
| 1896 | - if (isset($_SERVER['SERVER_PORT'])  | 
                                                        |
| 1897 | - and $port = $_SERVER['SERVER_PORT']  | 
                                                        |
| 1898 | - and strpos($host, ":") == false  | 
                                                        |
| 1899 | -	) { | 
                                                        |
| 1900 | -		if (!defined('_PORT_HTTP_STANDARD')) { | 
                                                        |
| 1901 | -			define('_PORT_HTTP_STANDARD', '80'); | 
                                                        |
| 1902 | - }  | 
                                                        |
| 1903 | -		if (!defined('_PORT_HTTPS_STANDARD')) { | 
                                                        |
| 1904 | -			define('_PORT_HTTPS_STANDARD', '443'); | 
                                                        |
| 1905 | - }  | 
                                                        |
| 1906 | -		if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { | 
                                                        |
| 1907 | - $host .= ":$port";  | 
                                                        |
| 1908 | - }  | 
                                                        |
| 1909 | -		if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { | 
                                                        |
| 1910 | - $host .= ":$port";  | 
                                                        |
| 1911 | - }  | 
                                                        |
| 1912 | - }  | 
                                                        |
| 1913 | -  | 
                                                        |
| 1914 | -	if (!$GLOBALS['REQUEST_URI']) { | 
                                                        |
| 1915 | -		if (isset($_SERVER['REQUEST_URI'])) { | 
                                                        |
| 1916 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];  | 
                                                        |
| 1917 | -		} else { | 
                                                        |
| 1918 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';  | 
                                                        |
| 1919 | - if (!empty($_SERVER['QUERY_STRING'])  | 
                                                        |
| 1920 | - and !strpos($_SERVER['REQUEST_URI'], '?')  | 
                                                        |
| 1921 | -			) { | 
                                                        |
| 1922 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];  | 
                                                        |
| 1923 | - }  | 
                                                        |
| 1924 | - }  | 
                                                        |
| 1925 | - }  | 
                                                        |
| 1926 | -  | 
                                                        |
| 1927 | - $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);  | 
                                                        |
| 1928 | -  | 
                                                        |
| 1929 | - return $url[$profondeur];  | 
                                                        |
| 1855 | + static $url = array();  | 
                                                        |
| 1856 | +    if (is_array($profondeur)) { | 
                                                        |
| 1857 | + return $url = $profondeur;  | 
                                                        |
| 1858 | + }  | 
                                                        |
| 1859 | +    if ($profondeur === false) { | 
                                                        |
| 1860 | + return $url;  | 
                                                        |
| 1861 | + }  | 
                                                        |
| 1862 | +  | 
                                                        |
| 1863 | +    if (is_null($profondeur)) { | 
                                                        |
| 1864 | + $profondeur = $GLOBALS['profondeur_url'];  | 
                                                        |
| 1865 | + }  | 
                                                        |
| 1866 | +  | 
                                                        |
| 1867 | +    if (isset($url[$profondeur])) { | 
                                                        |
| 1868 | + return $url[$profondeur];  | 
                                                        |
| 1869 | + }  | 
                                                        |
| 1870 | +  | 
                                                        |
| 1871 | + $http = 'http';  | 
                                                        |
| 1872 | +  | 
                                                        |
| 1873 | + if (  | 
                                                        |
| 1874 | + isset($_SERVER["SCRIPT_URI"])  | 
                                                        |
| 1875 | + and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https'  | 
                                                        |
| 1876 | +    ) { | 
                                                        |
| 1877 | + $http = 'https';  | 
                                                        |
| 1878 | + } elseif (  | 
                                                        |
| 1879 | + isset($_SERVER['HTTPS'])  | 
                                                        |
| 1880 | + and test_valeur_serveur($_SERVER['HTTPS'])  | 
                                                        |
| 1881 | +    ) { | 
                                                        |
| 1882 | + $http = 'https';  | 
                                                        |
| 1883 | + }  | 
                                                        |
| 1884 | +  | 
                                                        |
| 1885 | + // note : HTTP_HOST contient le :port si necessaire  | 
                                                        |
| 1886 | + $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;  | 
                                                        |
| 1887 | + // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback  | 
                                                        |
| 1888 | +    if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) { | 
                                                        |
| 1889 | + $host = $GLOBALS['meta']['adresse_site'];  | 
                                                        |
| 1890 | +        if ($scheme = parse_url($host, PHP_URL_SCHEME)) { | 
                                                        |
| 1891 | + $http = $scheme;  | 
                                                        |
| 1892 | +            $host = str_replace("{$scheme}://", '', $host); | 
                                                        |
| 1893 | + }  | 
                                                        |
| 1894 | + }  | 
                                                        |
| 1895 | + if (isset($_SERVER['SERVER_PORT'])  | 
                                                        |
| 1896 | + and $port = $_SERVER['SERVER_PORT']  | 
                                                        |
| 1897 | + and strpos($host, ":") == false  | 
                                                        |
| 1898 | +    ) { | 
                                                        |
| 1899 | +        if (!defined('_PORT_HTTP_STANDARD')) { | 
                                                        |
| 1900 | +            define('_PORT_HTTP_STANDARD', '80'); | 
                                                        |
| 1901 | + }  | 
                                                        |
| 1902 | +        if (!defined('_PORT_HTTPS_STANDARD')) { | 
                                                        |
| 1903 | +            define('_PORT_HTTPS_STANDARD', '443'); | 
                                                        |
| 1904 | + }  | 
                                                        |
| 1905 | +        if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) { | 
                                                        |
| 1906 | + $host .= ":$port";  | 
                                                        |
| 1907 | + }  | 
                                                        |
| 1908 | +        if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) { | 
                                                        |
| 1909 | + $host .= ":$port";  | 
                                                        |
| 1910 | + }  | 
                                                        |
| 1911 | + }  | 
                                                        |
| 1912 | +  | 
                                                        |
| 1913 | +    if (!$GLOBALS['REQUEST_URI']) { | 
                                                        |
| 1914 | +        if (isset($_SERVER['REQUEST_URI'])) { | 
                                                        |
| 1915 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];  | 
                                                        |
| 1916 | +        } else { | 
                                                        |
| 1917 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';  | 
                                                        |
| 1918 | + if (!empty($_SERVER['QUERY_STRING'])  | 
                                                        |
| 1919 | + and !strpos($_SERVER['REQUEST_URI'], '?')  | 
                                                        |
| 1920 | +            ) { | 
                                                        |
| 1921 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];  | 
                                                        |
| 1922 | + }  | 
                                                        |
| 1923 | + }  | 
                                                        |
| 1924 | + }  | 
                                                        |
| 1925 | +  | 
                                                        |
| 1926 | + $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);  | 
                                                        |
| 1927 | +  | 
                                                        |
| 1928 | + return $url[$profondeur];  | 
                                                        |
| 1930 | 1929 | }  | 
                                                        
| 1931 | 1930 | |
| 1932 | 1931 | /**  | 
                                                        
@@ -1939,26 +1938,26 @@ discard block  | 
                                                    ||
| 1939 | 1938 | * @return string  | 
                                                        
| 1940 | 1939 | */  | 
                                                        
| 1941 | 1940 |  function url_de_($http, $host, $request, $prof = 0) { | 
                                                        
| 1942 | - $prof = max($prof, 0);  | 
                                                        |
| 1941 | + $prof = max($prof, 0);  | 
                                                        |
| 1943 | 1942 | |
| 1944 | - $myself = ltrim($request, '/');  | 
                                                        |
| 1945 | - # supprimer la chaine de GET  | 
                                                        |
| 1946 | -	list($myself) = explode('?', $myself); | 
                                                        |
| 1947 | - // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte  | 
                                                        |
| 1948 | - // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]  | 
                                                        |
| 1949 | -	if (strpos($myself,'://') !== false) { | 
                                                        |
| 1950 | -		$myself = explode('://',$myself); | 
                                                        |
| 1951 | - array_shift($myself);  | 
                                                        |
| 1952 | -		$myself = implode('://',$myself); | 
                                                        |
| 1953 | -		$myself = explode('/',$myself); | 
                                                        |
| 1954 | - array_shift($myself);  | 
                                                        |
| 1955 | -		$myself = implode('/',$myself); | 
                                                        |
| 1956 | - }  | 
                                                        |
| 1957 | -	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; | 
                                                        |
| 1943 | + $myself = ltrim($request, '/');  | 
                                                        |
| 1944 | + # supprimer la chaine de GET  | 
                                                        |
| 1945 | +    list($myself) = explode('?', $myself); | 
                                                        |
| 1946 | + // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte  | 
                                                        |
| 1947 | + // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]  | 
                                                        |
| 1948 | +    if (strpos($myself,'://') !== false) { | 
                                                        |
| 1949 | +        $myself = explode('://',$myself); | 
                                                        |
| 1950 | + array_shift($myself);  | 
                                                        |
| 1951 | +        $myself = implode('://',$myself); | 
                                                        |
| 1952 | +        $myself = explode('/',$myself); | 
                                                        |
| 1953 | + array_shift($myself);  | 
                                                        |
| 1954 | +        $myself = implode('/',$myself); | 
                                                        |
| 1955 | + }  | 
                                                        |
| 1956 | +    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/'; | 
                                                        |
| 1958 | 1957 | |
| 1959 | - $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');  | 
                                                        |
| 1958 | + $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');  | 
                                                        |
| 1960 | 1959 | |
| 1961 | - return $url;  | 
                                                        |
| 1960 | + return $url;  | 
                                                        |
| 1962 | 1961 | }  | 
                                                        
| 1963 | 1962 | |
| 1964 | 1963 | |
@@ -1993,26 +1992,26 @@ discard block  | 
                                                    ||
| 1993 | 1992 | * @return string URL  | 
                                                        
| 1994 | 1993 | **/  | 
                                                        
| 1995 | 1994 |  function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) { | 
                                                        
| 1996 | -	if (!$rel) { | 
                                                        |
| 1997 | - $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;  | 
                                                        |
| 1998 | -	} else { | 
                                                        |
| 1999 | -		if (!is_string($rel)) { | 
                                                        |
| 2000 | - $rel = _DIR_RESTREINT ? _DIR_RESTREINT :  | 
                                                        |
| 2001 | -				('./' . _SPIP_ECRIRE_SCRIPT); | 
                                                        |
| 2002 | - }  | 
                                                        |
| 2003 | - }  | 
                                                        |
| 2004 | -  | 
                                                        |
| 2005 | -	list($script, $ancre) = array_pad(explode('#', $script), 2, null); | 
                                                        |
| 2006 | -	if ($script and ($script <> 'accueil' or $rel)) { | 
                                                        |
| 2007 | - $args = "?exec=$script" . (!$args ? '' : "&$args");  | 
                                                        |
| 2008 | -	} elseif ($args) { | 
                                                        |
| 2009 | - $args = "?$args";  | 
                                                        |
| 2010 | - }  | 
                                                        |
| 2011 | -	if ($ancre) { | 
                                                        |
| 2012 | - $args .= "#$ancre";  | 
                                                        |
| 2013 | - }  | 
                                                        |
| 2014 | -  | 
                                                        |
| 2015 | -	return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); | 
                                                        |
| 1995 | +    if (!$rel) { | 
                                                        |
| 1996 | + $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;  | 
                                                        |
| 1997 | +    } else { | 
                                                        |
| 1998 | +        if (!is_string($rel)) { | 
                                                        |
| 1999 | + $rel = _DIR_RESTREINT ? _DIR_RESTREINT :  | 
                                                        |
| 2000 | +                ('./' . _SPIP_ECRIRE_SCRIPT); | 
                                                        |
| 2001 | + }  | 
                                                        |
| 2002 | + }  | 
                                                        |
| 2003 | +  | 
                                                        |
| 2004 | +    list($script, $ancre) = array_pad(explode('#', $script), 2, null); | 
                                                        |
| 2005 | +    if ($script and ($script <> 'accueil' or $rel)) { | 
                                                        |
| 2006 | + $args = "?exec=$script" . (!$args ? '' : "&$args");  | 
                                                        |
| 2007 | +    } elseif ($args) { | 
                                                        |
| 2008 | + $args = "?$args";  | 
                                                        |
| 2009 | + }  | 
                                                        |
| 2010 | +    if ($ancre) { | 
                                                        |
| 2011 | + $args .= "#$ancre";  | 
                                                        |
| 2012 | + }  | 
                                                        |
| 2013 | +  | 
                                                        |
| 2014 | +    return $rel . ($no_entities ? $args : str_replace('&', '&', $args)); | 
                                                        |
| 2016 | 2015 | }  | 
                                                        
| 2017 | 2016 | |
| 2018 | 2017 | //  | 
                                                        
@@ -2034,12 +2033,12 @@ discard block  | 
                                                    ||
| 2034 | 2033 | * Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut  | 
                                                        
| 2035 | 2034 | **/  | 
                                                        
| 2036 | 2035 |  function get_spip_script($default = '') { | 
                                                        
| 2037 | -	# cas define('_SPIP_SCRIPT', ''); | 
                                                        |
| 2038 | -	if (_SPIP_SCRIPT) { | 
                                                        |
| 2039 | - return _SPIP_SCRIPT;  | 
                                                        |
| 2040 | -	} else { | 
                                                        |
| 2041 | - return $default;  | 
                                                        |
| 2042 | - }  | 
                                                        |
| 2036 | +    # cas define('_SPIP_SCRIPT', ''); | 
                                                        |
| 2037 | +    if (_SPIP_SCRIPT) { | 
                                                        |
| 2038 | + return _SPIP_SCRIPT;  | 
                                                        |
| 2039 | +    } else { | 
                                                        |
| 2040 | + return $default;  | 
                                                        |
| 2041 | + }  | 
                                                        |
| 2043 | 2042 | }  | 
                                                        
| 2044 | 2043 | |
| 2045 | 2044 | /**  | 
                                                        
@@ -2068,39 +2067,39 @@ discard block  | 
                                                    ||
| 2068 | 2067 | * @return string URL  | 
                                                        
| 2069 | 2068 | **/  | 
                                                        
| 2070 | 2069 |  function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') { | 
                                                        
| 2071 | - // si le script est une action (spip_pass, spip_inscription),  | 
                                                        |
| 2072 | - // standardiser vers la nouvelle API  | 
                                                        |
| 2073 | -  | 
                                                        |
| 2074 | -	if (!$action) { | 
                                                        |
| 2075 | - $action = get_spip_script();  | 
                                                        |
| 2076 | - }  | 
                                                        |
| 2077 | -	if ($script) { | 
                                                        |
| 2078 | - $action = parametre_url($action, _SPIP_PAGE, $script, '&');  | 
                                                        |
| 2079 | - }  | 
                                                        |
| 2080 | -  | 
                                                        |
| 2081 | -	if ($args) { | 
                                                        |
| 2082 | -		if (is_array($args)) { | 
                                                        |
| 2083 | - $r = '';  | 
                                                        |
| 2084 | -			foreach ($args as $k => $v) { | 
                                                        |
| 2085 | - $r .= '&' . $k . '=' . $v;  | 
                                                        |
| 2086 | - }  | 
                                                        |
| 2087 | - $args = substr($r, 1);  | 
                                                        |
| 2088 | - }  | 
                                                        |
| 2089 | - $action .=  | 
                                                        |
| 2090 | - (strpos($action, '?') !== false ? '&' : '?') . $args;  | 
                                                        |
| 2091 | - }  | 
                                                        |
| 2092 | -	if (!$no_entities) { | 
                                                        |
| 2093 | - $action = quote_amp($action);  | 
                                                        |
| 2094 | - }  | 
                                                        |
| 2095 | -  | 
                                                        |
| 2096 | - // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide  | 
                                                        |
| 2097 | -	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); | 
                                                        |
| 2070 | + // si le script est une action (spip_pass, spip_inscription),  | 
                                                        |
| 2071 | + // standardiser vers la nouvelle API  | 
                                                        |
| 2072 | +  | 
                                                        |
| 2073 | +    if (!$action) { | 
                                                        |
| 2074 | + $action = get_spip_script();  | 
                                                        |
| 2075 | + }  | 
                                                        |
| 2076 | +    if ($script) { | 
                                                        |
| 2077 | + $action = parametre_url($action, _SPIP_PAGE, $script, '&');  | 
                                                        |
| 2078 | + }  | 
                                                        |
| 2079 | +  | 
                                                        |
| 2080 | +    if ($args) { | 
                                                        |
| 2081 | +        if (is_array($args)) { | 
                                                        |
| 2082 | + $r = '';  | 
                                                        |
| 2083 | +            foreach ($args as $k => $v) { | 
                                                        |
| 2084 | + $r .= '&' . $k . '=' . $v;  | 
                                                        |
| 2085 | + }  | 
                                                        |
| 2086 | + $args = substr($r, 1);  | 
                                                        |
| 2087 | + }  | 
                                                        |
| 2088 | + $action .=  | 
                                                        |
| 2089 | + (strpos($action, '?') !== false ? '&' : '?') . $args;  | 
                                                        |
| 2090 | + }  | 
                                                        |
| 2091 | +    if (!$no_entities) { | 
                                                        |
| 2092 | + $action = quote_amp($action);  | 
                                                        |
| 2093 | + }  | 
                                                        |
| 2094 | +  | 
                                                        |
| 2095 | + // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide  | 
                                                        |
| 2096 | +    return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action")); | 
                                                        |
| 2098 | 2097 | }  | 
                                                        
| 2099 | 2098 | |
| 2100 | 2099 | // http://code.spip.net/@generer_url_prive  | 
                                                        
| 2101 | 2100 |  function generer_url_prive($script, $args = "", $no_entities = false) { | 
                                                        
| 2102 | 2101 | |
| 2103 | - return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');  | 
                                                        |
| 2102 | + return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');  | 
                                                        |
| 2104 | 2103 | }  | 
                                                        
| 2105 | 2104 | |
| 2106 | 2105 | // Pour les formulaires en methode POST,  | 
                                                        
@@ -2125,19 +2124,19 @@ discard block  | 
                                                    ||
| 2125 | 2124 | **/  | 
                                                        
| 2126 | 2125 |  function generer_form_ecrire($script, $corps, $atts = '', $submit = '') { | 
                                                        
| 2127 | 2126 | |
| 2128 | -	$script1 = explode('&', $script); | 
                                                        |
| 2129 | - $script1 = reset($script1);  | 
                                                        |
| 2127 | +    $script1 = explode('&', $script); | 
                                                        |
| 2128 | + $script1 = reset($script1);  | 
                                                        |
| 2130 | 2129 | |
| 2131 | - return "<form action='"  | 
                                                        |
| 2132 | - . ($script ? generer_url_ecrire($script) : '')  | 
                                                        |
| 2133 | - . "' "  | 
                                                        |
| 2134 | - . ($atts ? $atts : " method='post'")  | 
                                                        |
| 2135 | - . "><div>\n"  | 
                                                        |
| 2136 | - . "<input type='hidden' name='exec' value='$script1' />"  | 
                                                        |
| 2137 | - . $corps  | 
                                                        |
| 2138 | - . (!$submit ? '' :  | 
                                                        |
| 2139 | -		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) | 
                                                        |
| 2140 | - . "</div></form>\n";  | 
                                                        |
| 2130 | + return "<form action='"  | 
                                                        |
| 2131 | + . ($script ? generer_url_ecrire($script) : '')  | 
                                                        |
| 2132 | + . "' "  | 
                                                        |
| 2133 | + . ($atts ? $atts : " method='post'")  | 
                                                        |
| 2134 | + . "><div>\n"  | 
                                                        |
| 2135 | + . "<input type='hidden' name='exec' value='$script1' />"  | 
                                                        |
| 2136 | + . $corps  | 
                                                        |
| 2137 | + . (!$submit ? '' :  | 
                                                        |
| 2138 | +        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>")) | 
                                                        |
| 2139 | + . "</div></form>\n";  | 
                                                        |
| 2141 | 2140 | }  | 
                                                        
| 2142 | 2141 | |
| 2143 | 2142 | /**  | 
                                                        
@@ -2154,22 +2153,22 @@ discard block  | 
                                                    ||
| 2154 | 2153 | * @return string  | 
                                                        
| 2155 | 2154 | */  | 
                                                        
| 2156 | 2155 |  function generer_form_action($script, $corps, $atts = '', $public = false) { | 
                                                        
| 2157 | - // si l'on est dans l'espace prive, on garde dans l'url  | 
                                                        |
| 2158 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire  | 
                                                        |
| 2159 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple)  | 
                                                        |
| 2160 | - $h = (_DIR_RACINE and !$public)  | 
                                                        |
| 2161 | -		? generer_url_ecrire(_request('exec')) | 
                                                        |
| 2162 | - : generer_url_public();  | 
                                                        |
| 2156 | + // si l'on est dans l'espace prive, on garde dans l'url  | 
                                                        |
| 2157 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire  | 
                                                        |
| 2158 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple)  | 
                                                        |
| 2159 | + $h = (_DIR_RACINE and !$public)  | 
                                                        |
| 2160 | +        ? generer_url_ecrire(_request('exec')) | 
                                                        |
| 2161 | + : generer_url_public();  | 
                                                        |
| 2163 | 2162 | |
| 2164 | - return "\n<form action='" .  | 
                                                        |
| 2165 | - $h .  | 
                                                        |
| 2166 | - "'" .  | 
                                                        |
| 2167 | - $atts .  | 
                                                        |
| 2168 | - ">\n" .  | 
                                                        |
| 2169 | - "<div>" .  | 
                                                        |
| 2170 | - "\n<input type='hidden' name='action' value='$script' />" .  | 
                                                        |
| 2171 | - $corps .  | 
                                                        |
| 2172 | - "</div></form>";  | 
                                                        |
| 2163 | + return "\n<form action='" .  | 
                                                        |
| 2164 | + $h .  | 
                                                        |
| 2165 | + "'" .  | 
                                                        |
| 2166 | + $atts .  | 
                                                        |
| 2167 | + ">\n" .  | 
                                                        |
| 2168 | + "<div>" .  | 
                                                        |
| 2169 | + "\n<input type='hidden' name='action' value='$script' />" .  | 
                                                        |
| 2170 | + $corps .  | 
                                                        |
| 2171 | + "</div></form>";  | 
                                                        |
| 2173 | 2172 | }  | 
                                                        
| 2174 | 2173 | |
| 2175 | 2174 | /**  | 
                                                        
@@ -2188,22 +2187,22 @@ discard block  | 
                                                    ||
| 2188 | 2187 | * URL  | 
                                                        
| 2189 | 2188 | */  | 
                                                        
| 2190 | 2189 |  function generer_url_action($script, $args = "", $no_entities = false, $public = false) { | 
                                                        
| 2191 | - // si l'on est dans l'espace prive, on garde dans l'url  | 
                                                        |
| 2192 | - // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire  | 
                                                        |
| 2193 | - // ou non de proceder a l'authentification (cas typique de l'install par exemple)  | 
                                                        |
| 2194 | - $url = (_DIR_RACINE and !$public)  | 
                                                        |
| 2195 | -		? generer_url_ecrire(_request('exec')) | 
                                                        |
| 2196 | -		: generer_url_public('', '', false, false); | 
                                                        |
| 2197 | - $url = parametre_url($url, 'action', $script);  | 
                                                        |
| 2198 | -	if ($args) { | 
                                                        |
| 2199 | -		$url .= quote_amp('&' . $args); | 
                                                        |
| 2200 | - }  | 
                                                        |
| 2190 | + // si l'on est dans l'espace prive, on garde dans l'url  | 
                                                        |
| 2191 | + // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire  | 
                                                        |
| 2192 | + // ou non de proceder a l'authentification (cas typique de l'install par exemple)  | 
                                                        |
| 2193 | + $url = (_DIR_RACINE and !$public)  | 
                                                        |
| 2194 | +        ? generer_url_ecrire(_request('exec')) | 
                                                        |
| 2195 | +        : generer_url_public('', '', false, false); | 
                                                        |
| 2196 | + $url = parametre_url($url, 'action', $script);  | 
                                                        |
| 2197 | +    if ($args) { | 
                                                        |
| 2198 | +        $url .= quote_amp('&' . $args); | 
                                                        |
| 2199 | + }  | 
                                                        |
| 2201 | 2200 | |
| 2202 | -	if ($no_entities) { | 
                                                        |
| 2203 | -		$url = str_replace('&', '&', $url); | 
                                                        |
| 2204 | - }  | 
                                                        |
| 2201 | +    if ($no_entities) { | 
                                                        |
| 2202 | +        $url = str_replace('&', '&', $url); | 
                                                        |
| 2203 | + }  | 
                                                        |
| 2205 | 2204 | |
| 2206 | - return $url;  | 
                                                        |
| 2205 | + return $url;  | 
                                                        |
| 2207 | 2206 | }  | 
                                                        
| 2208 | 2207 | |
| 2209 | 2208 | |
@@ -2216,8 +2215,8 @@ discard block  | 
                                                    ||
| 2216 | 2215 | * @param string $ta Répertoire temporaire accessible  | 
                                                        
| 2217 | 2216 | */  | 
                                                        
| 2218 | 2217 |  function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) { | 
                                                        
| 2219 | - spip_initialisation_core($pi, $pa, $ti, $ta);  | 
                                                        |
| 2220 | - spip_initialisation_suite();  | 
                                                        |
| 2218 | + spip_initialisation_core($pi, $pa, $ti, $ta);  | 
                                                        |
| 2219 | + spip_initialisation_suite();  | 
                                                        |
| 2221 | 2220 | }  | 
                                                        
| 2222 | 2221 | |
| 2223 | 2222 | /**  | 
                                                        
@@ -2237,315 +2236,315 @@ discard block  | 
                                                    ||
| 2237 | 2236 | * @param string $ta Répertoire temporaire accessible  | 
                                                        
| 2238 | 2237 | */  | 
                                                        
| 2239 | 2238 |  function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) { | 
                                                        
| 2240 | - static $too_late = 0;  | 
                                                        |
| 2241 | -	if ($too_late++) { | 
                                                        |
| 2242 | - return;  | 
                                                        |
| 2243 | - }  | 
                                                        |
| 2244 | -  | 
                                                        |
| 2245 | - // Declaration des repertoires  | 
                                                        |
| 2246 | -  | 
                                                        |
| 2247 | - // le nom du repertoire plugins/ activables/desactivables  | 
                                                        |
| 2248 | -	if (!defined('_DIR_PLUGINS')) { | 
                                                        |
| 2249 | -		define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); | 
                                                        |
| 2250 | - }  | 
                                                        |
| 2251 | -  | 
                                                        |
| 2252 | - // le nom du repertoire des extensions/ permanentes du core, toujours actives  | 
                                                        |
| 2253 | -	if (!defined('_DIR_PLUGINS_DIST')) { | 
                                                        |
| 2254 | -		define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); | 
                                                        |
| 2255 | - }  | 
                                                        |
| 2256 | -  | 
                                                        |
| 2257 | - // le nom du repertoire des librairies  | 
                                                        |
| 2258 | -	if (!defined('_DIR_LIB')) { | 
                                                        |
| 2259 | -		define('_DIR_LIB', _DIR_RACINE . "lib/"); | 
                                                        |
| 2260 | - }  | 
                                                        |
| 2261 | -  | 
                                                        |
| 2262 | -	if (!defined('_DIR_IMG')) { | 
                                                        |
| 2263 | -		define('_DIR_IMG', $pa); | 
                                                        |
| 2264 | - }  | 
                                                        |
| 2265 | -	if (!defined('_DIR_LOGOS')) { | 
                                                        |
| 2266 | -		define('_DIR_LOGOS', $pa); | 
                                                        |
| 2267 | - }  | 
                                                        |
| 2268 | -	if (!defined('_DIR_IMG_ICONES')) { | 
                                                        |
| 2269 | -		define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); | 
                                                        |
| 2270 | - }  | 
                                                        |
| 2271 | -  | 
                                                        |
| 2272 | -	if (!defined('_DIR_DUMP')) { | 
                                                        |
| 2273 | -		define('_DIR_DUMP', $ti . "dump/"); | 
                                                        |
| 2274 | - }  | 
                                                        |
| 2275 | -	if (!defined('_DIR_SESSIONS')) { | 
                                                        |
| 2276 | -		define('_DIR_SESSIONS', $ti . "sessions/"); | 
                                                        |
| 2277 | - }  | 
                                                        |
| 2278 | -	if (!defined('_DIR_TRANSFERT')) { | 
                                                        |
| 2279 | -		define('_DIR_TRANSFERT', $ti . "upload/"); | 
                                                        |
| 2280 | - }  | 
                                                        |
| 2281 | -	if (!defined('_DIR_CACHE')) { | 
                                                        |
| 2282 | -		define('_DIR_CACHE', $ti . "cache/"); | 
                                                        |
| 2283 | - }  | 
                                                        |
| 2284 | -	if (!defined('_DIR_CACHE_XML')) { | 
                                                        |
| 2285 | -		define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); | 
                                                        |
| 2286 | - }  | 
                                                        |
| 2287 | -	if (!defined('_DIR_SKELS')) { | 
                                                        |
| 2288 | -		define('_DIR_SKELS', _DIR_CACHE . "skel/"); | 
                                                        |
| 2289 | - }  | 
                                                        |
| 2290 | -	if (!defined('_DIR_AIDE')) { | 
                                                        |
| 2291 | -		define('_DIR_AIDE', _DIR_CACHE . "aide/"); | 
                                                        |
| 2292 | - }  | 
                                                        |
| 2293 | -	if (!defined('_DIR_TMP')) { | 
                                                        |
| 2294 | -		define('_DIR_TMP', $ti); | 
                                                        |
| 2295 | - }  | 
                                                        |
| 2296 | -  | 
                                                        |
| 2297 | -	if (!defined('_DIR_VAR')) { | 
                                                        |
| 2298 | -		define('_DIR_VAR', $ta); | 
                                                        |
| 2299 | - }  | 
                                                        |
| 2300 | -  | 
                                                        |
| 2301 | -	if (!defined('_DIR_ETC')) { | 
                                                        |
| 2302 | -		define('_DIR_ETC', $pi); | 
                                                        |
| 2303 | - }  | 
                                                        |
| 2304 | -	if (!defined('_DIR_CONNECT')) { | 
                                                        |
| 2305 | -		define('_DIR_CONNECT', $pi); | 
                                                        |
| 2306 | - }  | 
                                                        |
| 2307 | -	if (!defined('_DIR_CHMOD')) { | 
                                                        |
| 2308 | -		define('_DIR_CHMOD', $pi); | 
                                                        |
| 2309 | - }  | 
                                                        |
| 2310 | -  | 
                                                        |
| 2311 | - if (!isset($GLOBALS['test_dirs']))  | 
                                                        |
| 2312 | - // Pas $pi car il est bon de le mettre hors ecriture apres intstall  | 
                                                        |
| 2313 | - // il sera rajoute automatiquement si besoin a l'etape 2 de l'install  | 
                                                        |
| 2314 | -	{ | 
                                                        |
| 2315 | - $GLOBALS['test_dirs'] = array($pa, $ti, $ta);  | 
                                                        |
| 2316 | - }  | 
                                                        |
| 2317 | -  | 
                                                        |
| 2318 | - // Declaration des fichiers  | 
                                                        |
| 2319 | -  | 
                                                        |
| 2320 | -	if (!defined('_CACHE_PLUGINS_PATH')) { | 
                                                        |
| 2321 | -		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); | 
                                                        |
| 2322 | - }  | 
                                                        |
| 2323 | -	if (!defined('_CACHE_PLUGINS_OPT')) { | 
                                                        |
| 2324 | -		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); | 
                                                        |
| 2325 | - }  | 
                                                        |
| 2326 | -	if (!defined('_CACHE_PLUGINS_FCT')) { | 
                                                        |
| 2327 | -		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); | 
                                                        |
| 2328 | - }  | 
                                                        |
| 2329 | -	if (!defined('_CACHE_PIPELINES')) { | 
                                                        |
| 2330 | -		define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); | 
                                                        |
| 2331 | - }  | 
                                                        |
| 2332 | -	if (!defined('_CACHE_CHEMIN')) { | 
                                                        |
| 2333 | -		define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); | 
                                                        |
| 2334 | - }  | 
                                                        |
| 2335 | -  | 
                                                        |
| 2336 | - # attention .php obligatoire pour ecrire_fichier_securise  | 
                                                        |
| 2337 | -	if (!defined('_FILE_META')) { | 
                                                        |
| 2338 | -		define('_FILE_META', $ti . 'meta_cache.php'); | 
                                                        |
| 2339 | - }  | 
                                                        |
| 2340 | -	if (!defined('_DIR_LOG')) { | 
                                                        |
| 2341 | -		define('_DIR_LOG', _DIR_TMP . 'log/'); | 
                                                        |
| 2342 | - }  | 
                                                        |
| 2343 | -	if (!defined('_FILE_LOG')) { | 
                                                        |
| 2344 | -		define('_FILE_LOG', 'spip'); | 
                                                        |
| 2345 | - }  | 
                                                        |
| 2346 | -	if (!defined('_FILE_LOG_SUFFIX')) { | 
                                                        |
| 2347 | -		define('_FILE_LOG_SUFFIX', '.log'); | 
                                                        |
| 2348 | - }  | 
                                                        |
| 2349 | -  | 
                                                        |
| 2350 | - // Le fichier de connexion a la base de donnees  | 
                                                        |
| 2351 | - // tient compte des anciennes versions (inc_connect...)  | 
                                                        |
| 2352 | -	if (!defined('_FILE_CONNECT_INS')) { | 
                                                        |
| 2353 | -		define('_FILE_CONNECT_INS', 'connect'); | 
                                                        |
| 2354 | - }  | 
                                                        |
| 2355 | -	if (!defined('_FILE_CONNECT')) { | 
                                                        |
| 2356 | -		define('_FILE_CONNECT', | 
                                                        |
| 2357 | - (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f  | 
                                                        |
| 2358 | - : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f  | 
                                                        |
| 2359 | - : false)));  | 
                                                        |
| 2360 | - }  | 
                                                        |
| 2361 | -  | 
                                                        |
| 2362 | - // Le fichier de reglages des droits  | 
                                                        |
| 2363 | -	if (!defined('_FILE_CHMOD_INS')) { | 
                                                        |
| 2364 | -		define('_FILE_CHMOD_INS', 'chmod'); | 
                                                        |
| 2365 | - }  | 
                                                        |
| 2366 | -	if (!defined('_FILE_CHMOD')) { | 
                                                        |
| 2367 | -		define('_FILE_CHMOD', | 
                                                        |
| 2368 | - (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f  | 
                                                        |
| 2369 | - : false));  | 
                                                        |
| 2370 | - }  | 
                                                        |
| 2371 | -  | 
                                                        |
| 2372 | -	if (!defined('_FILE_LDAP')) { | 
                                                        |
| 2373 | -		define('_FILE_LDAP', 'ldap.php'); | 
                                                        |
| 2374 | - }  | 
                                                        |
| 2375 | -  | 
                                                        |
| 2376 | -	if (!defined('_FILE_TMP_SUFFIX')) { | 
                                                        |
| 2377 | -		define('_FILE_TMP_SUFFIX', '.tmp.php'); | 
                                                        |
| 2378 | - }  | 
                                                        |
| 2379 | -	if (!defined('_FILE_CONNECT_TMP')) { | 
                                                        |
| 2380 | -		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); | 
                                                        |
| 2381 | - }  | 
                                                        |
| 2382 | -	if (!defined('_FILE_CHMOD_TMP')) { | 
                                                        |
| 2383 | -		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); | 
                                                        |
| 2384 | - }  | 
                                                        |
| 2385 | -  | 
                                                        |
| 2386 | - // Definition des droits d'acces en ecriture  | 
                                                        |
| 2387 | -	if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { | 
                                                        |
| 2388 | - include_once _FILE_CHMOD;  | 
                                                        |
| 2389 | - }  | 
                                                        |
| 2390 | -  | 
                                                        |
| 2391 | - // Se mefier des fichiers mal remplis!  | 
                                                        |
| 2392 | -	if (!defined('_SPIP_CHMOD')) { | 
                                                        |
| 2393 | -		define('_SPIP_CHMOD', 0777); | 
                                                        |
| 2394 | - }  | 
                                                        |
| 2395 | -  | 
                                                        |
| 2396 | -	if (!defined('_DEFAULT_CHARSET')) { | 
                                                        |
| 2397 | - /** Le charset par défaut lors de l'installation */  | 
                                                        |
| 2398 | -		define('_DEFAULT_CHARSET', 'utf-8'); | 
                                                        |
| 2399 | - }  | 
                                                        |
| 2400 | -	if (!defined('_ROOT_PLUGINS')) { | 
                                                        |
| 2401 | -		define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); | 
                                                        |
| 2402 | - }  | 
                                                        |
| 2403 | -	if (!defined('_ROOT_PLUGINS_DIST')) { | 
                                                        |
| 2404 | -		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); | 
                                                        |
| 2405 | - }  | 
                                                        |
| 2406 | -	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { | 
                                                        |
| 2407 | -		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); | 
                                                        |
| 2408 | - }  | 
                                                        |
| 2409 | -  | 
                                                        |
| 2410 | - // La taille des Log  | 
                                                        |
| 2411 | -	if (!defined('_MAX_LOG')) { | 
                                                        |
| 2412 | -		define('_MAX_LOG', 100); | 
                                                        |
| 2413 | - }  | 
                                                        |
| 2414 | -  | 
                                                        |
| 2415 | - // Sommes-nous dans l'empire du Mal ?  | 
                                                        |
| 2416 | - // (ou sous le signe du Pingouin, ascendant GNU ?)  | 
                                                        |
| 2417 | -	if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { | 
                                                        |
| 2418 | -		if (!defined('_OS_SERVEUR')) { | 
                                                        |
| 2419 | -			define('_OS_SERVEUR', 'windows'); | 
                                                        |
| 2420 | - }  | 
                                                        |
| 2421 | -		if (!defined('_SPIP_LOCK_MODE')) { | 
                                                        |
| 2422 | -			define('_SPIP_LOCK_MODE', 1); | 
                                                        |
| 2423 | - } // utiliser le flock php  | 
                                                        |
| 2424 | -	} else { | 
                                                        |
| 2425 | -		if (!defined('_OS_SERVEUR')) { | 
                                                        |
| 2426 | -			define('_OS_SERVEUR', ''); | 
                                                        |
| 2427 | - }  | 
                                                        |
| 2428 | -		if (!defined('_SPIP_LOCK_MODE')) { | 
                                                        |
| 2429 | -			define('_SPIP_LOCK_MODE', 1); | 
                                                        |
| 2430 | - } // utiliser le flock php  | 
                                                        |
| 2431 | -		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite | 
                                                        |
| 2432 | - }  | 
                                                        |
| 2433 | -  | 
                                                        |
| 2434 | - // Langue par defaut  | 
                                                        |
| 2435 | -	if (!defined('_LANGUE_PAR_DEFAUT')) { | 
                                                        |
| 2436 | -		define('_LANGUE_PAR_DEFAUT', 'fr'); | 
                                                        |
| 2437 | - }  | 
                                                        |
| 2438 | -  | 
                                                        |
| 2439 | - //  | 
                                                        |
| 2440 | - // Module de lecture/ecriture/suppression de fichiers utilisant flock()  | 
                                                        |
| 2441 | - // (non surchargeable en l'etat ; attention si on utilise include_spip()  | 
                                                        |
| 2442 | - // pour le rendre surchargeable, on va provoquer un reecriture  | 
                                                        |
| 2443 | - // systematique du noyau ou une baisse de perfs => a etudier)  | 
                                                        |
| 2444 | - include_once _ROOT_RESTREINT . 'inc/flock.php';  | 
                                                        |
| 2445 | -  | 
                                                        |
| 2446 | - // charger tout de suite le path et son cache  | 
                                                        |
| 2447 | - load_path_cache();  | 
                                                        |
| 2448 | -  | 
                                                        |
| 2449 | - // *********** traiter les variables ************  | 
                                                        |
| 2450 | -  | 
                                                        |
| 2451 | - //  | 
                                                        |
| 2452 | - // Securite  | 
                                                        |
| 2453 | - //  | 
                                                        |
| 2454 | -  | 
                                                        |
| 2455 | - // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto  | 
                                                        |
| 2456 | -	if (isset($_REQUEST['GLOBALS'])) { | 
                                                        |
| 2457 | - die();  | 
                                                        |
| 2458 | - }  | 
                                                        |
| 2459 | - // nettoyer les magic quotes \' et les caracteres nuls %00  | 
                                                        |
| 2460 | - spip_desinfecte($_GET);  | 
                                                        |
| 2461 | - spip_desinfecte($_POST);  | 
                                                        |
| 2462 | - spip_desinfecte($_COOKIE);  | 
                                                        |
| 2463 | - spip_desinfecte($_REQUEST);  | 
                                                        |
| 2464 | -  | 
                                                        |
| 2465 | - // appliquer le cookie_prefix  | 
                                                        |
| 2466 | -	if ($GLOBALS['cookie_prefix'] != 'spip') { | 
                                                        |
| 2467 | -		include_spip('inc/cookie'); | 
                                                        |
| 2468 | - recuperer_cookies_spip($GLOBALS['cookie_prefix']);  | 
                                                        |
| 2469 | - }  | 
                                                        |
| 2470 | -  | 
                                                        |
| 2471 | - //  | 
                                                        |
| 2472 | - // Capacites php (en fonction de la version)  | 
                                                        |
| 2473 | - //  | 
                                                        |
| 2474 | -	$GLOBALS['flag_ob'] = (function_exists("ob_start") | 
                                                        |
| 2475 | -		&& function_exists("ini_get") | 
                                                        |
| 2476 | -		&& !strstr(@ini_get('disable_functions'), 'ob_')); | 
                                                        |
| 2477 | -	$GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); | 
                                                        |
| 2478 | -	$GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); | 
                                                        |
| 2479 | - $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||  | 
                                                        |
| 2480 | -		(get_cfg_var('upload_max_filesize') > 0)); | 
                                                        |
| 2481 | -  | 
                                                        |
| 2482 | -  | 
                                                        |
| 2483 | - // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI  | 
                                                        |
| 2484 | -	if (isset($_SERVER['REQUEST_URI'])) { | 
                                                        |
| 2485 | - $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];  | 
                                                        |
| 2486 | -	} else { | 
                                                        |
| 2487 | - $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';  | 
                                                        |
| 2488 | - if (!empty($_SERVER['QUERY_STRING'])  | 
                                                        |
| 2489 | - and !strpos($_SERVER['REQUEST_URI'], '?')  | 
                                                        |
| 2490 | -		) { | 
                                                        |
| 2491 | - $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];  | 
                                                        |
| 2492 | - }  | 
                                                        |
| 2493 | - }  | 
                                                        |
| 2494 | -  | 
                                                        |
| 2495 | - // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.  | 
                                                        |
| 2496 | -	if (!defined('_RENOUVELLE_ALEA')) { | 
                                                        |
| 2497 | -		define('_RENOUVELLE_ALEA', 12 * 3600); | 
                                                        |
| 2498 | - }  | 
                                                        |
| 2499 | -	if (!defined('_DUREE_COOKIE_ADMIN')) { | 
                                                        |
| 2500 | -		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); | 
                                                        |
| 2501 | - }  | 
                                                        |
| 2502 | -  | 
                                                        |
| 2503 | - // charger les meta si possible et renouveller l'alea au besoin  | 
                                                        |
| 2504 | - // charge aussi effacer_meta et ecrire_meta  | 
                                                        |
| 2505 | -	$inc_meta = charger_fonction('meta', 'inc'); | 
                                                        |
| 2506 | - $inc_meta();  | 
                                                        |
| 2507 | -  | 
                                                        |
| 2508 | - // nombre de repertoires depuis la racine  | 
                                                        |
| 2509 | - // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]  | 
                                                        |
| 2510 | - // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse  | 
                                                        |
| 2511 | - // le calcul est faux)  | 
                                                        |
| 2512 | -	if (!_DIR_RESTREINT) { | 
                                                        |
| 2513 | - $GLOBALS['profondeur_url'] = 1;  | 
                                                        |
| 2514 | -	} else { | 
                                                        |
| 2515 | -		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; | 
                                                        |
| 2516 | - $uri_ref = $_SERVER["SCRIPT_NAME"];  | 
                                                        |
| 2517 | - if (!$uri_ref  | 
                                                        |
| 2518 | - // si on est appele avec un autre ti, on est sans doute en mutu  | 
                                                        |
| 2519 | - // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie  | 
                                                        |
| 2520 | - // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer  | 
                                                        |
| 2521 | - // s'en remettre a l'adresse du site. alea jacta est.  | 
                                                        |
| 2522 | - or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES  | 
                                                        |
| 2523 | -		) { | 
                                                        |
| 2524 | -  | 
                                                        |
| 2525 | -			if (isset($GLOBALS['meta']['adresse_site'])) { | 
                                                        |
| 2526 | - $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);  | 
                                                        |
| 2527 | - $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';  | 
                                                        |
| 2528 | -			} else { | 
                                                        |
| 2529 | - $uri_ref = "";  | 
                                                        |
| 2530 | - }  | 
                                                        |
| 2531 | - }  | 
                                                        |
| 2532 | -		if (!$uri or !$uri_ref) { | 
                                                        |
| 2533 | - $GLOBALS['profondeur_url'] = 0;  | 
                                                        |
| 2534 | -		} else { | 
                                                        |
| 2535 | - $GLOBALS['profondeur_url'] = max(0,  | 
                                                        |
| 2536 | - substr_count($uri[0], '/')  | 
                                                        |
| 2537 | - - substr_count($uri_ref, '/'));  | 
                                                        |
| 2538 | - }  | 
                                                        |
| 2539 | - }  | 
                                                        |
| 2540 | - // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session  | 
                                                        |
| 2541 | -	if (_FILE_CONNECT) { | 
                                                        |
| 2542 | - if (verifier_visiteur() == '0minirezo'  | 
                                                        |
| 2543 | - // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !  | 
                                                        |
| 2544 | - and !isset($_COOKIE['spip_admin'])  | 
                                                        |
| 2545 | -		) { | 
                                                        |
| 2546 | - clear_path_cache();  | 
                                                        |
| 2547 | - }  | 
                                                        |
| 2548 | - }  | 
                                                        |
| 2239 | + static $too_late = 0;  | 
                                                        |
| 2240 | +    if ($too_late++) { | 
                                                        |
| 2241 | + return;  | 
                                                        |
| 2242 | + }  | 
                                                        |
| 2243 | +  | 
                                                        |
| 2244 | + // Declaration des repertoires  | 
                                                        |
| 2245 | +  | 
                                                        |
| 2246 | + // le nom du repertoire plugins/ activables/desactivables  | 
                                                        |
| 2247 | +    if (!defined('_DIR_PLUGINS')) { | 
                                                        |
| 2248 | +        define('_DIR_PLUGINS', _DIR_RACINE . "plugins/"); | 
                                                        |
| 2249 | + }  | 
                                                        |
| 2250 | +  | 
                                                        |
| 2251 | + // le nom du repertoire des extensions/ permanentes du core, toujours actives  | 
                                                        |
| 2252 | +    if (!defined('_DIR_PLUGINS_DIST')) { | 
                                                        |
| 2253 | +        define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/"); | 
                                                        |
| 2254 | + }  | 
                                                        |
| 2255 | +  | 
                                                        |
| 2256 | + // le nom du repertoire des librairies  | 
                                                        |
| 2257 | +    if (!defined('_DIR_LIB')) { | 
                                                        |
| 2258 | +        define('_DIR_LIB', _DIR_RACINE . "lib/"); | 
                                                        |
| 2259 | + }  | 
                                                        |
| 2260 | +  | 
                                                        |
| 2261 | +    if (!defined('_DIR_IMG')) { | 
                                                        |
| 2262 | +        define('_DIR_IMG', $pa); | 
                                                        |
| 2263 | + }  | 
                                                        |
| 2264 | +    if (!defined('_DIR_LOGOS')) { | 
                                                        |
| 2265 | +        define('_DIR_LOGOS', $pa); | 
                                                        |
| 2266 | + }  | 
                                                        |
| 2267 | +    if (!defined('_DIR_IMG_ICONES')) { | 
                                                        |
| 2268 | +        define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/"); | 
                                                        |
| 2269 | + }  | 
                                                        |
| 2270 | +  | 
                                                        |
| 2271 | +    if (!defined('_DIR_DUMP')) { | 
                                                        |
| 2272 | +        define('_DIR_DUMP', $ti . "dump/"); | 
                                                        |
| 2273 | + }  | 
                                                        |
| 2274 | +    if (!defined('_DIR_SESSIONS')) { | 
                                                        |
| 2275 | +        define('_DIR_SESSIONS', $ti . "sessions/"); | 
                                                        |
| 2276 | + }  | 
                                                        |
| 2277 | +    if (!defined('_DIR_TRANSFERT')) { | 
                                                        |
| 2278 | +        define('_DIR_TRANSFERT', $ti . "upload/"); | 
                                                        |
| 2279 | + }  | 
                                                        |
| 2280 | +    if (!defined('_DIR_CACHE')) { | 
                                                        |
| 2281 | +        define('_DIR_CACHE', $ti . "cache/"); | 
                                                        |
| 2282 | + }  | 
                                                        |
| 2283 | +    if (!defined('_DIR_CACHE_XML')) { | 
                                                        |
| 2284 | +        define('_DIR_CACHE_XML', _DIR_CACHE . "xml/"); | 
                                                        |
| 2285 | + }  | 
                                                        |
| 2286 | +    if (!defined('_DIR_SKELS')) { | 
                                                        |
| 2287 | +        define('_DIR_SKELS', _DIR_CACHE . "skel/"); | 
                                                        |
| 2288 | + }  | 
                                                        |
| 2289 | +    if (!defined('_DIR_AIDE')) { | 
                                                        |
| 2290 | +        define('_DIR_AIDE', _DIR_CACHE . "aide/"); | 
                                                        |
| 2291 | + }  | 
                                                        |
| 2292 | +    if (!defined('_DIR_TMP')) { | 
                                                        |
| 2293 | +        define('_DIR_TMP', $ti); | 
                                                        |
| 2294 | + }  | 
                                                        |
| 2295 | +  | 
                                                        |
| 2296 | +    if (!defined('_DIR_VAR')) { | 
                                                        |
| 2297 | +        define('_DIR_VAR', $ta); | 
                                                        |
| 2298 | + }  | 
                                                        |
| 2299 | +  | 
                                                        |
| 2300 | +    if (!defined('_DIR_ETC')) { | 
                                                        |
| 2301 | +        define('_DIR_ETC', $pi); | 
                                                        |
| 2302 | + }  | 
                                                        |
| 2303 | +    if (!defined('_DIR_CONNECT')) { | 
                                                        |
| 2304 | +        define('_DIR_CONNECT', $pi); | 
                                                        |
| 2305 | + }  | 
                                                        |
| 2306 | +    if (!defined('_DIR_CHMOD')) { | 
                                                        |
| 2307 | +        define('_DIR_CHMOD', $pi); | 
                                                        |
| 2308 | + }  | 
                                                        |
| 2309 | +  | 
                                                        |
| 2310 | + if (!isset($GLOBALS['test_dirs']))  | 
                                                        |
| 2311 | + // Pas $pi car il est bon de le mettre hors ecriture apres intstall  | 
                                                        |
| 2312 | + // il sera rajoute automatiquement si besoin a l'etape 2 de l'install  | 
                                                        |
| 2313 | +    { | 
                                                        |
| 2314 | + $GLOBALS['test_dirs'] = array($pa, $ti, $ta);  | 
                                                        |
| 2315 | + }  | 
                                                        |
| 2316 | +  | 
                                                        |
| 2317 | + // Declaration des fichiers  | 
                                                        |
| 2318 | +  | 
                                                        |
| 2319 | +    if (!defined('_CACHE_PLUGINS_PATH')) { | 
                                                        |
| 2320 | +        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php"); | 
                                                        |
| 2321 | + }  | 
                                                        |
| 2322 | +    if (!defined('_CACHE_PLUGINS_OPT')) { | 
                                                        |
| 2323 | +        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php"); | 
                                                        |
| 2324 | + }  | 
                                                        |
| 2325 | +    if (!defined('_CACHE_PLUGINS_FCT')) { | 
                                                        |
| 2326 | +        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php"); | 
                                                        |
| 2327 | + }  | 
                                                        |
| 2328 | +    if (!defined('_CACHE_PIPELINES')) { | 
                                                        |
| 2329 | +        define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php"); | 
                                                        |
| 2330 | + }  | 
                                                        |
| 2331 | +    if (!defined('_CACHE_CHEMIN')) { | 
                                                        |
| 2332 | +        define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt"); | 
                                                        |
| 2333 | + }  | 
                                                        |
| 2334 | +  | 
                                                        |
| 2335 | + # attention .php obligatoire pour ecrire_fichier_securise  | 
                                                        |
| 2336 | +    if (!defined('_FILE_META')) { | 
                                                        |
| 2337 | +        define('_FILE_META', $ti . 'meta_cache.php'); | 
                                                        |
| 2338 | + }  | 
                                                        |
| 2339 | +    if (!defined('_DIR_LOG')) { | 
                                                        |
| 2340 | +        define('_DIR_LOG', _DIR_TMP . 'log/'); | 
                                                        |
| 2341 | + }  | 
                                                        |
| 2342 | +    if (!defined('_FILE_LOG')) { | 
                                                        |
| 2343 | +        define('_FILE_LOG', 'spip'); | 
                                                        |
| 2344 | + }  | 
                                                        |
| 2345 | +    if (!defined('_FILE_LOG_SUFFIX')) { | 
                                                        |
| 2346 | +        define('_FILE_LOG_SUFFIX', '.log'); | 
                                                        |
| 2347 | + }  | 
                                                        |
| 2348 | +  | 
                                                        |
| 2349 | + // Le fichier de connexion a la base de donnees  | 
                                                        |
| 2350 | + // tient compte des anciennes versions (inc_connect...)  | 
                                                        |
| 2351 | +    if (!defined('_FILE_CONNECT_INS')) { | 
                                                        |
| 2352 | +        define('_FILE_CONNECT_INS', 'connect'); | 
                                                        |
| 2353 | + }  | 
                                                        |
| 2354 | +    if (!defined('_FILE_CONNECT')) { | 
                                                        |
| 2355 | +        define('_FILE_CONNECT', | 
                                                        |
| 2356 | + (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f  | 
                                                        |
| 2357 | + : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f  | 
                                                        |
| 2358 | + : false)));  | 
                                                        |
| 2359 | + }  | 
                                                        |
| 2360 | +  | 
                                                        |
| 2361 | + // Le fichier de reglages des droits  | 
                                                        |
| 2362 | +    if (!defined('_FILE_CHMOD_INS')) { | 
                                                        |
| 2363 | +        define('_FILE_CHMOD_INS', 'chmod'); | 
                                                        |
| 2364 | + }  | 
                                                        |
| 2365 | +    if (!defined('_FILE_CHMOD')) { | 
                                                        |
| 2366 | +        define('_FILE_CHMOD', | 
                                                        |
| 2367 | + (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f  | 
                                                        |
| 2368 | + : false));  | 
                                                        |
| 2369 | + }  | 
                                                        |
| 2370 | +  | 
                                                        |
| 2371 | +    if (!defined('_FILE_LDAP')) { | 
                                                        |
| 2372 | +        define('_FILE_LDAP', 'ldap.php'); | 
                                                        |
| 2373 | + }  | 
                                                        |
| 2374 | +  | 
                                                        |
| 2375 | +    if (!defined('_FILE_TMP_SUFFIX')) { | 
                                                        |
| 2376 | +        define('_FILE_TMP_SUFFIX', '.tmp.php'); | 
                                                        |
| 2377 | + }  | 
                                                        |
| 2378 | +    if (!defined('_FILE_CONNECT_TMP')) { | 
                                                        |
| 2379 | +        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX); | 
                                                        |
| 2380 | + }  | 
                                                        |
| 2381 | +    if (!defined('_FILE_CHMOD_TMP')) { | 
                                                        |
| 2382 | +        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX); | 
                                                        |
| 2383 | + }  | 
                                                        |
| 2384 | +  | 
                                                        |
| 2385 | + // Definition des droits d'acces en ecriture  | 
                                                        |
| 2386 | +    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) { | 
                                                        |
| 2387 | + include_once _FILE_CHMOD;  | 
                                                        |
| 2388 | + }  | 
                                                        |
| 2389 | +  | 
                                                        |
| 2390 | + // Se mefier des fichiers mal remplis!  | 
                                                        |
| 2391 | +    if (!defined('_SPIP_CHMOD')) { | 
                                                        |
| 2392 | +        define('_SPIP_CHMOD', 0777); | 
                                                        |
| 2393 | + }  | 
                                                        |
| 2394 | +  | 
                                                        |
| 2395 | +    if (!defined('_DEFAULT_CHARSET')) { | 
                                                        |
| 2396 | + /** Le charset par défaut lors de l'installation */  | 
                                                        |
| 2397 | +        define('_DEFAULT_CHARSET', 'utf-8'); | 
                                                        |
| 2398 | + }  | 
                                                        |
| 2399 | +    if (!defined('_ROOT_PLUGINS')) { | 
                                                        |
| 2400 | +        define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/"); | 
                                                        |
| 2401 | + }  | 
                                                        |
| 2402 | +    if (!defined('_ROOT_PLUGINS_DIST')) { | 
                                                        |
| 2403 | +        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/"); | 
                                                        |
| 2404 | + }  | 
                                                        |
| 2405 | +    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { | 
                                                        |
| 2406 | +        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL)); | 
                                                        |
| 2407 | + }  | 
                                                        |
| 2408 | +  | 
                                                        |
| 2409 | + // La taille des Log  | 
                                                        |
| 2410 | +    if (!defined('_MAX_LOG')) { | 
                                                        |
| 2411 | +        define('_MAX_LOG', 100); | 
                                                        |
| 2412 | + }  | 
                                                        |
| 2413 | +  | 
                                                        |
| 2414 | + // Sommes-nous dans l'empire du Mal ?  | 
                                                        |
| 2415 | + // (ou sous le signe du Pingouin, ascendant GNU ?)  | 
                                                        |
| 2416 | +    if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) { | 
                                                        |
| 2417 | +        if (!defined('_OS_SERVEUR')) { | 
                                                        |
| 2418 | +            define('_OS_SERVEUR', 'windows'); | 
                                                        |
| 2419 | + }  | 
                                                        |
| 2420 | +        if (!defined('_SPIP_LOCK_MODE')) { | 
                                                        |
| 2421 | +            define('_SPIP_LOCK_MODE', 1); | 
                                                        |
| 2422 | + } // utiliser le flock php  | 
                                                        |
| 2423 | +    } else { | 
                                                        |
| 2424 | +        if (!defined('_OS_SERVEUR')) { | 
                                                        |
| 2425 | +            define('_OS_SERVEUR', ''); | 
                                                        |
| 2426 | + }  | 
                                                        |
| 2427 | +        if (!defined('_SPIP_LOCK_MODE')) { | 
                                                        |
| 2428 | +            define('_SPIP_LOCK_MODE', 1); | 
                                                        |
| 2429 | + } // utiliser le flock php  | 
                                                        |
| 2430 | +        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite | 
                                                        |
| 2431 | + }  | 
                                                        |
| 2432 | +  | 
                                                        |
| 2433 | + // Langue par defaut  | 
                                                        |
| 2434 | +    if (!defined('_LANGUE_PAR_DEFAUT')) { | 
                                                        |
| 2435 | +        define('_LANGUE_PAR_DEFAUT', 'fr'); | 
                                                        |
| 2436 | + }  | 
                                                        |
| 2437 | +  | 
                                                        |
| 2438 | + //  | 
                                                        |
| 2439 | + // Module de lecture/ecriture/suppression de fichiers utilisant flock()  | 
                                                        |
| 2440 | + // (non surchargeable en l'etat ; attention si on utilise include_spip()  | 
                                                        |
| 2441 | + // pour le rendre surchargeable, on va provoquer un reecriture  | 
                                                        |
| 2442 | + // systematique du noyau ou une baisse de perfs => a etudier)  | 
                                                        |
| 2443 | + include_once _ROOT_RESTREINT . 'inc/flock.php';  | 
                                                        |
| 2444 | +  | 
                                                        |
| 2445 | + // charger tout de suite le path et son cache  | 
                                                        |
| 2446 | + load_path_cache();  | 
                                                        |
| 2447 | +  | 
                                                        |
| 2448 | + // *********** traiter les variables ************  | 
                                                        |
| 2449 | +  | 
                                                        |
| 2450 | + //  | 
                                                        |
| 2451 | + // Securite  | 
                                                        |
| 2452 | + //  | 
                                                        |
| 2453 | +  | 
                                                        |
| 2454 | + // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto  | 
                                                        |
| 2455 | +    if (isset($_REQUEST['GLOBALS'])) { | 
                                                        |
| 2456 | + die();  | 
                                                        |
| 2457 | + }  | 
                                                        |
| 2458 | + // nettoyer les magic quotes \' et les caracteres nuls %00  | 
                                                        |
| 2459 | + spip_desinfecte($_GET);  | 
                                                        |
| 2460 | + spip_desinfecte($_POST);  | 
                                                        |
| 2461 | + spip_desinfecte($_COOKIE);  | 
                                                        |
| 2462 | + spip_desinfecte($_REQUEST);  | 
                                                        |
| 2463 | +  | 
                                                        |
| 2464 | + // appliquer le cookie_prefix  | 
                                                        |
| 2465 | +    if ($GLOBALS['cookie_prefix'] != 'spip') { | 
                                                        |
| 2466 | +        include_spip('inc/cookie'); | 
                                                        |
| 2467 | + recuperer_cookies_spip($GLOBALS['cookie_prefix']);  | 
                                                        |
| 2468 | + }  | 
                                                        |
| 2469 | +  | 
                                                        |
| 2470 | + //  | 
                                                        |
| 2471 | + // Capacites php (en fonction de la version)  | 
                                                        |
| 2472 | + //  | 
                                                        |
| 2473 | +    $GLOBALS['flag_ob'] = (function_exists("ob_start") | 
                                                        |
| 2474 | +        && function_exists("ini_get") | 
                                                        |
| 2475 | +        && !strstr(@ini_get('disable_functions'), 'ob_')); | 
                                                        |
| 2476 | +    $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name"); | 
                                                        |
| 2477 | +    $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != ""); | 
                                                        |
| 2478 | + $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||  | 
                                                        |
| 2479 | +        (get_cfg_var('upload_max_filesize') > 0)); | 
                                                        |
| 2480 | +  | 
                                                        |
| 2481 | +  | 
                                                        |
| 2482 | + // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI  | 
                                                        |
| 2483 | +    if (isset($_SERVER['REQUEST_URI'])) { | 
                                                        |
| 2484 | + $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];  | 
                                                        |
| 2485 | +    } else { | 
                                                        |
| 2486 | + $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';  | 
                                                        |
| 2487 | + if (!empty($_SERVER['QUERY_STRING'])  | 
                                                        |
| 2488 | + and !strpos($_SERVER['REQUEST_URI'], '?')  | 
                                                        |
| 2489 | +        ) { | 
                                                        |
| 2490 | + $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];  | 
                                                        |
| 2491 | + }  | 
                                                        |
| 2492 | + }  | 
                                                        |
| 2493 | +  | 
                                                        |
| 2494 | + // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.  | 
                                                        |
| 2495 | +    if (!defined('_RENOUVELLE_ALEA')) { | 
                                                        |
| 2496 | +        define('_RENOUVELLE_ALEA', 12 * 3600); | 
                                                        |
| 2497 | + }  | 
                                                        |
| 2498 | +    if (!defined('_DUREE_COOKIE_ADMIN')) { | 
                                                        |
| 2499 | +        define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600); | 
                                                        |
| 2500 | + }  | 
                                                        |
| 2501 | +  | 
                                                        |
| 2502 | + // charger les meta si possible et renouveller l'alea au besoin  | 
                                                        |
| 2503 | + // charge aussi effacer_meta et ecrire_meta  | 
                                                        |
| 2504 | +    $inc_meta = charger_fonction('meta', 'inc'); | 
                                                        |
| 2505 | + $inc_meta();  | 
                                                        |
| 2506 | +  | 
                                                        |
| 2507 | + // nombre de repertoires depuis la racine  | 
                                                        |
| 2508 | + // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]  | 
                                                        |
| 2509 | + // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse  | 
                                                        |
| 2510 | + // le calcul est faux)  | 
                                                        |
| 2511 | +    if (!_DIR_RESTREINT) { | 
                                                        |
| 2512 | + $GLOBALS['profondeur_url'] = 1;  | 
                                                        |
| 2513 | +    } else { | 
                                                        |
| 2514 | +        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : ''; | 
                                                        |
| 2515 | + $uri_ref = $_SERVER["SCRIPT_NAME"];  | 
                                                        |
| 2516 | + if (!$uri_ref  | 
                                                        |
| 2517 | + // si on est appele avec un autre ti, on est sans doute en mutu  | 
                                                        |
| 2518 | + // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie  | 
                                                        |
| 2519 | + // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer  | 
                                                        |
| 2520 | + // s'en remettre a l'adresse du site. alea jacta est.  | 
                                                        |
| 2521 | + or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES  | 
                                                        |
| 2522 | +        ) { | 
                                                        |
| 2523 | +  | 
                                                        |
| 2524 | +            if (isset($GLOBALS['meta']['adresse_site'])) { | 
                                                        |
| 2525 | + $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);  | 
                                                        |
| 2526 | + $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';  | 
                                                        |
| 2527 | +            } else { | 
                                                        |
| 2528 | + $uri_ref = "";  | 
                                                        |
| 2529 | + }  | 
                                                        |
| 2530 | + }  | 
                                                        |
| 2531 | +        if (!$uri or !$uri_ref) { | 
                                                        |
| 2532 | + $GLOBALS['profondeur_url'] = 0;  | 
                                                        |
| 2533 | +        } else { | 
                                                        |
| 2534 | + $GLOBALS['profondeur_url'] = max(0,  | 
                                                        |
| 2535 | + substr_count($uri[0], '/')  | 
                                                        |
| 2536 | + - substr_count($uri_ref, '/'));  | 
                                                        |
| 2537 | + }  | 
                                                        |
| 2538 | + }  | 
                                                        |
| 2539 | + // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session  | 
                                                        |
| 2540 | +    if (_FILE_CONNECT) { | 
                                                        |
| 2541 | + if (verifier_visiteur() == '0minirezo'  | 
                                                        |
| 2542 | + // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !  | 
                                                        |
| 2543 | + and !isset($_COOKIE['spip_admin'])  | 
                                                        |
| 2544 | +        ) { | 
                                                        |
| 2545 | + clear_path_cache();  | 
                                                        |
| 2546 | + }  | 
                                                        |
| 2547 | + }  | 
                                                        |
| 2549 | 2548 | |
| 2550 | 2549 | }  | 
                                                        
| 2551 | 2550 | |
@@ -2555,172 +2554,172 @@ discard block  | 
                                                    ||
| 2555 | 2554 | *  | 
                                                        
| 2556 | 2555 | */  | 
                                                        
| 2557 | 2556 |  function spip_initialisation_suite() { | 
                                                        
| 2558 | - static $too_late = 0;  | 
                                                        |
| 2559 | -	if ($too_late++) { | 
                                                        |
| 2560 | - return;  | 
                                                        |
| 2561 | - }  | 
                                                        |
| 2562 | -  | 
                                                        |
| 2563 | - // taille mini des login  | 
                                                        |
| 2564 | -	if (!defined('_LOGIN_TROP_COURT')) { | 
                                                        |
| 2565 | -		define('_LOGIN_TROP_COURT', 4); | 
                                                        |
| 2566 | - }  | 
                                                        |
| 2567 | -  | 
                                                        |
| 2568 | - // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)  | 
                                                        |
| 2569 | -	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko | 
                                                        |
| 2570 | -	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels | 
                                                        |
| 2571 | -	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels | 
                                                        |
| 2572 | -  | 
                                                        |
| 2573 | - // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)  | 
                                                        |
| 2574 | -	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko | 
                                                        |
| 2575 | -	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko | 
                                                        |
| 2576 | -	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels | 
                                                        |
| 2577 | -	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels | 
                                                        |
| 2578 | -  | 
                                                        |
| 2579 | -	if (!defined('_PASS_LONGUEUR_MINI')) { | 
                                                        |
| 2580 | -		define('_PASS_LONGUEUR_MINI', 6); | 
                                                        |
| 2581 | - }  | 
                                                        |
| 2582 | -  | 
                                                        |
| 2583 | -  | 
                                                        |
| 2584 | - // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)  | 
                                                        |
| 2585 | -	if (!defined('_IMG_QUALITE')) { | 
                                                        |
| 2586 | -		define('_IMG_QUALITE', 85); | 
                                                        |
| 2587 | - } # valeur par defaut  | 
                                                        |
| 2588 | -	if (!defined('_IMG_GD_QUALITE')) { | 
                                                        |
| 2589 | -		define('_IMG_GD_QUALITE', _IMG_QUALITE); | 
                                                        |
| 2590 | - } # surcharge pour la lib GD  | 
                                                        |
| 2591 | -	if (!defined('_IMG_CONVERT_QUALITE')) { | 
                                                        |
| 2592 | -		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); | 
                                                        |
| 2593 | - } # surcharge pour imagick en ligne de commande  | 
                                                        |
| 2594 | - // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE  | 
                                                        |
| 2595 | -	if (!defined('_IMG_IMAGICK_QUALITE')) { | 
                                                        |
| 2596 | -		define('_IMG_IMAGICK_QUALITE', 75); | 
                                                        |
| 2597 | - } # surcharge pour imagick en PHP  | 
                                                        |
| 2598 | -  | 
                                                        |
| 2599 | -	if (!defined('_COPIE_LOCALE_MAX_SIZE')) { | 
                                                        |
| 2600 | -		define('_COPIE_LOCALE_MAX_SIZE', 33554432); | 
                                                        |
| 2601 | - } // poids en octet  | 
                                                        |
| 2602 | -  | 
                                                        |
| 2603 | - // qq chaines standard  | 
                                                        |
| 2604 | -	if (!defined('_ACCESS_FILE_NAME')) { | 
                                                        |
| 2605 | -		define('_ACCESS_FILE_NAME', '.htaccess'); | 
                                                        |
| 2606 | - }  | 
                                                        |
| 2607 | -	if (!defined('_AUTH_USER_FILE')) { | 
                                                        |
| 2608 | -		define('_AUTH_USER_FILE', '.htpasswd'); | 
                                                        |
| 2609 | - }  | 
                                                        |
| 2610 | -	if (!defined('_SPIP_DUMP')) { | 
                                                        |
| 2611 | -		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); | 
                                                        |
| 2612 | - }  | 
                                                        |
| 2613 | -	if (!defined('_CACHE_RUBRIQUES')) { | 
                                                        |
| 2614 | - /** Fichier cache pour le navigateur de rubrique du bandeau */  | 
                                                        |
| 2615 | -		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); | 
                                                        |
| 2616 | - }  | 
                                                        |
| 2617 | -	if (!defined('_CACHE_RUBRIQUES_MAX')) { | 
                                                        |
| 2618 | - /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */  | 
                                                        |
| 2619 | -		define('_CACHE_RUBRIQUES_MAX', 500); | 
                                                        |
| 2620 | - }  | 
                                                        |
| 2621 | -  | 
                                                        |
| 2622 | -	if (!defined('_EXTENSION_SQUELETTES')) { | 
                                                        |
| 2623 | -		define('_EXTENSION_SQUELETTES', 'html'); | 
                                                        |
| 2624 | - }  | 
                                                        |
| 2625 | -  | 
                                                        |
| 2626 | -	if (!defined('_DOCTYPE_ECRIRE')) { | 
                                                        |
| 2627 | - /** Définit le doctype de l’espace privé */  | 
                                                        |
| 2628 | -		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); | 
                                                        |
| 2629 | - }  | 
                                                        |
| 2630 | -	if (!defined('_DOCTYPE_AIDE')) { | 
                                                        |
| 2631 | - /** Définit le doctype de l’aide en ligne */  | 
                                                        |
| 2632 | -		define('_DOCTYPE_AIDE', | 
                                                        |
| 2633 | - "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>");  | 
                                                        |
| 2634 | - }  | 
                                                        |
| 2635 | -  | 
                                                        |
| 2636 | -	if (!defined('_SPIP_SCRIPT')) { | 
                                                        |
| 2637 | - /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par  | 
                                                        |
| 2638 | - * le script de l'espace public, alias index.php */  | 
                                                        |
| 2639 | -		define('_SPIP_SCRIPT', 'spip.php'); | 
                                                        |
| 2640 | - }  | 
                                                        |
| 2641 | -	if (!defined('_SPIP_PAGE')) { | 
                                                        |
| 2642 | - /** Argument page, personalisable en cas de conflit avec un autre script */  | 
                                                        |
| 2643 | -		define('_SPIP_PAGE', 'page'); | 
                                                        |
| 2644 | - }  | 
                                                        |
| 2645 | -  | 
                                                        |
| 2646 | - // le script de l'espace prive  | 
                                                        |
| 2647 | - // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:  | 
                                                        |
| 2648 | - // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)  | 
                                                        |
| 2649 | - // meme pb sur thttpd cf. http://forum.spip.net/fr_184153.html  | 
                                                        |
| 2650 | -	if (!defined('_SPIP_ECRIRE_SCRIPT')) { | 
                                                        |
| 2651 | -		define('_SPIP_ECRIRE_SCRIPT', (empty($_SERVER['SERVER_SOFTWARE']) ? '' : | 
                                                        |
| 2652 | -			preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE']) ? | 
                                                        |
| 2653 | - 'index.php' : ''));  | 
                                                        |
| 2654 | - }  | 
                                                        |
| 2655 | -  | 
                                                        |
| 2656 | -  | 
                                                        |
| 2657 | -	if (!defined('_SPIP_AJAX')) { | 
                                                        |
| 2658 | -		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) | 
                                                        |
| 2659 | - ? 1  | 
                                                        |
| 2660 | - : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));  | 
                                                        |
| 2661 | - }  | 
                                                        |
| 2662 | -  | 
                                                        |
| 2663 | - // La requete est-elle en ajax ?  | 
                                                        |
| 2664 | -	if (!defined('_AJAX')) { | 
                                                        |
| 2665 | -		define('_AJAX', | 
                                                        |
| 2666 | - (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery  | 
                                                        |
| 2667 | - or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery  | 
                                                        |
| 2668 | - or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins  | 
                                                        |
| 2669 | - or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip  | 
                                                        |
| 2670 | - )  | 
                                                        |
| 2671 | - and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient  | 
                                                        |
| 2672 | - );  | 
                                                        |
| 2673 | - }  | 
                                                        |
| 2674 | -  | 
                                                        |
| 2675 | - # nombre de pixels maxi pour calcul de la vignette avec gd  | 
                                                        |
| 2676 | - # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation  | 
                                                        |
| 2677 | - # les configurations limitees en memoire ont un seuil plutot vers 1MPixel  | 
                                                        |
| 2678 | -	if (!defined('_IMG_GD_MAX_PIXELS')) { | 
                                                        |
| 2679 | -		define('_IMG_GD_MAX_PIXELS', | 
                                                        |
| 2680 | - (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])  | 
                                                        |
| 2681 | - ? $GLOBALS['meta']['max_taille_vignettes']  | 
                                                        |
| 2682 | - : 0);  | 
                                                        |
| 2683 | - }  | 
                                                        |
| 2684 | -  | 
                                                        |
| 2685 | -	if (!defined('_MEMORY_LIMIT_MIN')) { | 
                                                        |
| 2686 | -		define('_MEMORY_LIMIT_MIN', 16); | 
                                                        |
| 2687 | - } // en Mo  | 
                                                        |
| 2688 | - // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)  | 
                                                        |
| 2689 | - // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche  | 
                                                        |
| 2690 | - // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche  | 
                                                        |
| 2691 | -	if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { | 
                                                        |
| 2692 | -		if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { | 
                                                        |
| 2693 | - $unit = strtolower(substr($memory, -1));  | 
                                                        |
| 2694 | - $memory = substr($memory, 0, -1);  | 
                                                        |
| 2695 | -			switch ($unit) { | 
                                                        |
| 2696 | - // Le modifieur 'G' est disponible depuis PHP 5.1.0  | 
                                                        |
| 2697 | - case 'g':  | 
                                                        |
| 2698 | - $memory *= 1024;  | 
                                                        |
| 2699 | - case 'm':  | 
                                                        |
| 2700 | - $memory *= 1024;  | 
                                                        |
| 2701 | - case 'k':  | 
                                                        |
| 2702 | - $memory *= 1024;  | 
                                                        |
| 2703 | - }  | 
                                                        |
| 2704 | -			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { | 
                                                        |
| 2705 | -				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); | 
                                                        |
| 2706 | -				if (trim(ini_get('memory_limit')) != $m) { | 
                                                        |
| 2707 | -					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { | 
                                                        |
| 2708 | -						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); | 
                                                        |
| 2709 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit  | 
                                                        |
| 2710 | - }  | 
                                                        |
| 2711 | - }  | 
                                                        |
| 2712 | -		} else { | 
                                                        |
| 2713 | -			if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { | 
                                                        |
| 2714 | -				define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); | 
                                                        |
| 2715 | - }  | 
                                                        |
| 2716 | - } // evite une page blanche car on ne saura pas calculer la css dans ce hit  | 
                                                        |
| 2717 | - }  | 
                                                        |
| 2718 | - // Protocoles a normaliser dans les chaines de langues  | 
                                                        |
| 2719 | -	if (!defined('_PROTOCOLES_STD')) { | 
                                                        |
| 2720 | -		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); | 
                                                        |
| 2721 | - }  | 
                                                        |
| 2722 | -  | 
                                                        |
| 2723 | - init_var_mode();  | 
                                                        |
| 2557 | + static $too_late = 0;  | 
                                                        |
| 2558 | +    if ($too_late++) { | 
                                                        |
| 2559 | + return;  | 
                                                        |
| 2560 | + }  | 
                                                        |
| 2561 | +  | 
                                                        |
| 2562 | + // taille mini des login  | 
                                                        |
| 2563 | +    if (!defined('_LOGIN_TROP_COURT')) { | 
                                                        |
| 2564 | +        define('_LOGIN_TROP_COURT', 4); | 
                                                        |
| 2565 | + }  | 
                                                        |
| 2566 | +  | 
                                                        |
| 2567 | + // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)  | 
                                                        |
| 2568 | +    #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko | 
                                                        |
| 2569 | +    #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels | 
                                                        |
| 2570 | +    #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels | 
                                                        |
| 2571 | +  | 
                                                        |
| 2572 | + // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)  | 
                                                        |
| 2573 | +    #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko | 
                                                        |
| 2574 | +    #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko | 
                                                        |
| 2575 | +    #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels | 
                                                        |
| 2576 | +    #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels | 
                                                        |
| 2577 | +  | 
                                                        |
| 2578 | +    if (!defined('_PASS_LONGUEUR_MINI')) { | 
                                                        |
| 2579 | +        define('_PASS_LONGUEUR_MINI', 6); | 
                                                        |
| 2580 | + }  | 
                                                        |
| 2581 | +  | 
                                                        |
| 2582 | +  | 
                                                        |
| 2583 | + // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)  | 
                                                        |
| 2584 | +    if (!defined('_IMG_QUALITE')) { | 
                                                        |
| 2585 | +        define('_IMG_QUALITE', 85); | 
                                                        |
| 2586 | + } # valeur par defaut  | 
                                                        |
| 2587 | +    if (!defined('_IMG_GD_QUALITE')) { | 
                                                        |
| 2588 | +        define('_IMG_GD_QUALITE', _IMG_QUALITE); | 
                                                        |
| 2589 | + } # surcharge pour la lib GD  | 
                                                        |
| 2590 | +    if (!defined('_IMG_CONVERT_QUALITE')) { | 
                                                        |
| 2591 | +        define('_IMG_CONVERT_QUALITE', _IMG_QUALITE); | 
                                                        |
| 2592 | + } # surcharge pour imagick en ligne de commande  | 
                                                        |
| 2593 | + // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE  | 
                                                        |
| 2594 | +    if (!defined('_IMG_IMAGICK_QUALITE')) { | 
                                                        |
| 2595 | +        define('_IMG_IMAGICK_QUALITE', 75); | 
                                                        |
| 2596 | + } # surcharge pour imagick en PHP  | 
                                                        |
| 2597 | +  | 
                                                        |
| 2598 | +    if (!defined('_COPIE_LOCALE_MAX_SIZE')) { | 
                                                        |
| 2599 | +        define('_COPIE_LOCALE_MAX_SIZE', 33554432); | 
                                                        |
| 2600 | + } // poids en octet  | 
                                                        |
| 2601 | +  | 
                                                        |
| 2602 | + // qq chaines standard  | 
                                                        |
| 2603 | +    if (!defined('_ACCESS_FILE_NAME')) { | 
                                                        |
| 2604 | +        define('_ACCESS_FILE_NAME', '.htaccess'); | 
                                                        |
| 2605 | + }  | 
                                                        |
| 2606 | +    if (!defined('_AUTH_USER_FILE')) { | 
                                                        |
| 2607 | +        define('_AUTH_USER_FILE', '.htpasswd'); | 
                                                        |
| 2608 | + }  | 
                                                        |
| 2609 | +    if (!defined('_SPIP_DUMP')) { | 
                                                        |
| 2610 | +        define('_SPIP_DUMP', 'dump@nom_site@@[email protected]'); | 
                                                        |
| 2611 | + }  | 
                                                        |
| 2612 | +    if (!defined('_CACHE_RUBRIQUES')) { | 
                                                        |
| 2613 | + /** Fichier cache pour le navigateur de rubrique du bandeau */  | 
                                                        |
| 2614 | +        define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt'); | 
                                                        |
| 2615 | + }  | 
                                                        |
| 2616 | +    if (!defined('_CACHE_RUBRIQUES_MAX')) { | 
                                                        |
| 2617 | + /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */  | 
                                                        |
| 2618 | +        define('_CACHE_RUBRIQUES_MAX', 500); | 
                                                        |
| 2619 | + }  | 
                                                        |
| 2620 | +  | 
                                                        |
| 2621 | +    if (!defined('_EXTENSION_SQUELETTES')) { | 
                                                        |
| 2622 | +        define('_EXTENSION_SQUELETTES', 'html'); | 
                                                        |
| 2623 | + }  | 
                                                        |
| 2624 | +  | 
                                                        |
| 2625 | +    if (!defined('_DOCTYPE_ECRIRE')) { | 
                                                        |
| 2626 | + /** Définit le doctype de l’espace privé */  | 
                                                        |
| 2627 | +        define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n"); | 
                                                        |
| 2628 | + }  | 
                                                        |
| 2629 | +    if (!defined('_DOCTYPE_AIDE')) { | 
                                                        |
| 2630 | + /** Définit le doctype de l’aide en ligne */  | 
                                                        |
| 2631 | +        define('_DOCTYPE_AIDE', | 
                                                        |
| 2632 | + "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>");  | 
                                                        |
| 2633 | + }  | 
                                                        |
| 2634 | +  | 
                                                        |
| 2635 | +    if (!defined('_SPIP_SCRIPT')) { | 
                                                        |
| 2636 | + /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par  | 
                                                        |
| 2637 | + * le script de l'espace public, alias index.php */  | 
                                                        |
| 2638 | +        define('_SPIP_SCRIPT', 'spip.php'); | 
                                                        |
| 2639 | + }  | 
                                                        |
| 2640 | +    if (!defined('_SPIP_PAGE')) { | 
                                                        |
| 2641 | + /** Argument page, personalisable en cas de conflit avec un autre script */  | 
                                                        |
| 2642 | +        define('_SPIP_PAGE', 'page'); | 
                                                        |
| 2643 | + }  | 
                                                        |
| 2644 | +  | 
                                                        |
| 2645 | + // le script de l'espace prive  | 
                                                        |
| 2646 | + // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:  | 
                                                        |
| 2647 | + // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)  | 
                                                        |
| 2648 | + // meme pb sur thttpd cf. http://forum.spip.net/fr_184153.html  | 
                                                        |
| 2649 | +    if (!defined('_SPIP_ECRIRE_SCRIPT')) { | 
                                                        |
| 2650 | +        define('_SPIP_ECRIRE_SCRIPT', (empty($_SERVER['SERVER_SOFTWARE']) ? '' : | 
                                                        |
| 2651 | +            preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE']) ? | 
                                                        |
| 2652 | + 'index.php' : ''));  | 
                                                        |
| 2653 | + }  | 
                                                        |
| 2654 | +  | 
                                                        |
| 2655 | +  | 
                                                        |
| 2656 | +    if (!defined('_SPIP_AJAX')) { | 
                                                        |
| 2657 | +        define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax'])) | 
                                                        |
| 2658 | + ? 1  | 
                                                        |
| 2659 | + : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));  | 
                                                        |
| 2660 | + }  | 
                                                        |
| 2661 | +  | 
                                                        |
| 2662 | + // La requete est-elle en ajax ?  | 
                                                        |
| 2663 | +    if (!defined('_AJAX')) { | 
                                                        |
| 2664 | +        define('_AJAX', | 
                                                        |
| 2665 | + (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery  | 
                                                        |
| 2666 | + or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery  | 
                                                        |
| 2667 | + or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins  | 
                                                        |
| 2668 | + or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip  | 
                                                        |
| 2669 | + )  | 
                                                        |
| 2670 | + and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient  | 
                                                        |
| 2671 | + );  | 
                                                        |
| 2672 | + }  | 
                                                        |
| 2673 | +  | 
                                                        |
| 2674 | + # nombre de pixels maxi pour calcul de la vignette avec gd  | 
                                                        |
| 2675 | + # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation  | 
                                                        |
| 2676 | + # les configurations limitees en memoire ont un seuil plutot vers 1MPixel  | 
                                                        |
| 2677 | +    if (!defined('_IMG_GD_MAX_PIXELS')) { | 
                                                        |
| 2678 | +        define('_IMG_GD_MAX_PIXELS', | 
                                                        |
| 2679 | + (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])  | 
                                                        |
| 2680 | + ? $GLOBALS['meta']['max_taille_vignettes']  | 
                                                        |
| 2681 | + : 0);  | 
                                                        |
| 2682 | + }  | 
                                                        |
| 2683 | +  | 
                                                        |
| 2684 | +    if (!defined('_MEMORY_LIMIT_MIN')) { | 
                                                        |
| 2685 | +        define('_MEMORY_LIMIT_MIN', 16); | 
                                                        |
| 2686 | + } // en Mo  | 
                                                        |
| 2687 | + // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)  | 
                                                        |
| 2688 | + // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche  | 
                                                        |
| 2689 | + // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche  | 
                                                        |
| 2690 | +    if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) { | 
                                                        |
| 2691 | +        if ($memory = trim(ini_get('memory_limit')) and $memory != -1) { | 
                                                        |
| 2692 | + $unit = strtolower(substr($memory, -1));  | 
                                                        |
| 2693 | + $memory = substr($memory, 0, -1);  | 
                                                        |
| 2694 | +            switch ($unit) { | 
                                                        |
| 2695 | + // Le modifieur 'G' est disponible depuis PHP 5.1.0  | 
                                                        |
| 2696 | + case 'g':  | 
                                                        |
| 2697 | + $memory *= 1024;  | 
                                                        |
| 2698 | + case 'm':  | 
                                                        |
| 2699 | + $memory *= 1024;  | 
                                                        |
| 2700 | + case 'k':  | 
                                                        |
| 2701 | + $memory *= 1024;  | 
                                                        |
| 2702 | + }  | 
                                                        |
| 2703 | +            if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) { | 
                                                        |
| 2704 | +                @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M'); | 
                                                        |
| 2705 | +                if (trim(ini_get('memory_limit')) != $m) { | 
                                                        |
| 2706 | +                    if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { | 
                                                        |
| 2707 | +                        define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); | 
                                                        |
| 2708 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit  | 
                                                        |
| 2709 | + }  | 
                                                        |
| 2710 | + }  | 
                                                        |
| 2711 | +        } else { | 
                                                        |
| 2712 | +            if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) { | 
                                                        |
| 2713 | +                define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true); | 
                                                        |
| 2714 | + }  | 
                                                        |
| 2715 | + } // evite une page blanche car on ne saura pas calculer la css dans ce hit  | 
                                                        |
| 2716 | + }  | 
                                                        |
| 2717 | + // Protocoles a normaliser dans les chaines de langues  | 
                                                        |
| 2718 | +    if (!defined('_PROTOCOLES_STD')) { | 
                                                        |
| 2719 | +        define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal'); | 
                                                        |
| 2720 | + }  | 
                                                        |
| 2721 | +  | 
                                                        |
| 2722 | + init_var_mode();  | 
                                                        |
| 2724 | 2723 | }  | 
                                                        
| 2725 | 2724 | |
| 2726 | 2725 | /**  | 
                                                        
@@ -2754,129 +2753,129 @@ discard block  | 
                                                    ||
| 2754 | 2753 | * ` var_mode` (calcul ou recalcul).  | 
                                                        
| 2755 | 2754 | */  | 
                                                        
| 2756 | 2755 |  function init_var_mode() { | 
                                                        
| 2757 | - static $done = false;  | 
                                                        |
| 2758 | -	if (!$done) { | 
                                                        |
| 2759 | -  | 
                                                        |
| 2760 | -		if (isset($_GET['var_mode'])) { | 
                                                        |
| 2761 | -			$var_mode = explode(',', $_GET['var_mode']); | 
                                                        |
| 2762 | - // tout le monde peut calcul/recalcul  | 
                                                        |
| 2763 | -			if (!defined('_VAR_MODE')) { | 
                                                        |
| 2764 | -				if (in_array('recalcul', $var_mode)) { | 
                                                        |
| 2765 | -					define('_VAR_MODE', 'recalcul'); | 
                                                        |
| 2766 | -				} elseif (in_array('calcul', $var_mode)) { | 
                                                        |
| 2767 | -					define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2768 | - }  | 
                                                        |
| 2769 | - }  | 
                                                        |
| 2770 | -			$var_mode = array_diff($var_mode, array('calcul', 'recalcul')); | 
                                                        |
| 2771 | -			if ($var_mode) { | 
                                                        |
| 2772 | -				include_spip('inc/autoriser'); | 
                                                        |
| 2773 | - // autoriser preview si preview seulement, et sinon autoriser debug  | 
                                                        |
| 2774 | - if (autoriser(  | 
                                                        |
| 2775 | - ($_GET['var_mode'] == 'preview')  | 
                                                        |
| 2776 | - ? 'previsualiser'  | 
                                                        |
| 2777 | - : 'debug'  | 
                                                        |
| 2778 | -				)) { | 
                                                        |
| 2779 | -					if (in_array('traduction', $var_mode)) { | 
                                                        |
| 2780 | - // forcer le calcul pour passer dans traduire  | 
                                                        |
| 2781 | -						if (!defined('_VAR_MODE')) { | 
                                                        |
| 2782 | -							define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2783 | - }  | 
                                                        |
| 2784 | - // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages  | 
                                                        |
| 2785 | -						if (!defined('_VAR_NOCACHE')) { | 
                                                        |
| 2786 | -							define('_VAR_NOCACHE', true); | 
                                                        |
| 2787 | - }  | 
                                                        |
| 2788 | -						$var_mode = array_diff($var_mode, array('traduction')); | 
                                                        |
| 2789 | - }  | 
                                                        |
| 2790 | -					if (in_array('preview', $var_mode)) { | 
                                                        |
| 2791 | - // basculer sur les criteres de preview dans les boucles  | 
                                                        |
| 2792 | -						if (!defined('_VAR_PREVIEW')) { | 
                                                        |
| 2793 | -							define('_VAR_PREVIEW', true); | 
                                                        |
| 2794 | - }  | 
                                                        |
| 2795 | - // forcer le calcul  | 
                                                        |
| 2796 | -						if (!defined('_VAR_MODE')) { | 
                                                        |
| 2797 | -							define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2798 | - }  | 
                                                        |
| 2799 | - // et ne pas enregistrer de cache  | 
                                                        |
| 2800 | -						if (!defined('_VAR_NOCACHE')) { | 
                                                        |
| 2801 | -							define('_VAR_NOCACHE', true); | 
                                                        |
| 2802 | - }  | 
                                                        |
| 2803 | -						$var_mode = array_diff($var_mode, array('preview')); | 
                                                        |
| 2804 | - }  | 
                                                        |
| 2805 | -					if (in_array('inclure', $var_mode)) { | 
                                                        |
| 2806 | - // forcer le compilo et ignorer les caches existants  | 
                                                        |
| 2807 | -						if (!defined('_VAR_MODE')) { | 
                                                        |
| 2808 | -							define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2809 | - }  | 
                                                        |
| 2810 | -						if (!defined('_VAR_INCLURE')) { | 
                                                        |
| 2811 | -							define('_VAR_INCLURE', true); | 
                                                        |
| 2812 | - }  | 
                                                        |
| 2813 | - // et ne pas enregistrer de cache  | 
                                                        |
| 2814 | -						if (!defined('_VAR_NOCACHE')) { | 
                                                        |
| 2815 | -							define('_VAR_NOCACHE', true); | 
                                                        |
| 2816 | - }  | 
                                                        |
| 2817 | -						$var_mode = array_diff($var_mode, array('inclure')); | 
                                                        |
| 2818 | - }  | 
                                                        |
| 2819 | -					if (in_array('urls', $var_mode)) { | 
                                                        |
| 2820 | - // forcer le compilo et ignorer les caches existants  | 
                                                        |
| 2821 | -						if (!defined('_VAR_MODE')) { | 
                                                        |
| 2822 | -							define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2823 | - }  | 
                                                        |
| 2824 | -						if (!defined('_VAR_URLS')) { | 
                                                        |
| 2825 | -							define('_VAR_URLS', true); | 
                                                        |
| 2826 | - }  | 
                                                        |
| 2827 | -						$var_mode = array_diff($var_mode, array('urls')); | 
                                                        |
| 2828 | - }  | 
                                                        |
| 2829 | -					if (in_array('images', $var_mode)) { | 
                                                        |
| 2830 | - // forcer le compilo et ignorer les caches existants  | 
                                                        |
| 2831 | -						if (!defined('_VAR_MODE')) { | 
                                                        |
| 2832 | -							define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2833 | - }  | 
                                                        |
| 2834 | - // indiquer qu'on doit recalculer les images  | 
                                                        |
| 2835 | -						if (!defined('_VAR_IMAGES')) { | 
                                                        |
| 2836 | -							define('_VAR_IMAGES', true); | 
                                                        |
| 2837 | - }  | 
                                                        |
| 2838 | -						$var_mode = array_diff($var_mode, array('images')); | 
                                                        |
| 2839 | - }  | 
                                                        |
| 2840 | -					if (in_array('debug', $var_mode)) { | 
                                                        |
| 2841 | -						if (!defined('_VAR_MODE')) { | 
                                                        |
| 2842 | -							define('_VAR_MODE', 'debug'); | 
                                                        |
| 2843 | - }  | 
                                                        |
| 2844 | - // et ne pas enregistrer de cache  | 
                                                        |
| 2845 | -						if (!defined('_VAR_NOCACHE')) { | 
                                                        |
| 2846 | -							define('_VAR_NOCACHE', true); | 
                                                        |
| 2847 | - }  | 
                                                        |
| 2848 | -						$var_mode = array_diff($var_mode, array('debug')); | 
                                                        |
| 2849 | - }  | 
                                                        |
| 2850 | -					if (count($var_mode) and !defined('_VAR_MODE')) { | 
                                                        |
| 2851 | -						define('_VAR_MODE', reset($var_mode)); | 
                                                        |
| 2852 | - }  | 
                                                        |
| 2853 | -					if (isset($GLOBALS['visiteur_session']['nom'])) { | 
                                                        |
| 2854 | - spip_log($GLOBALS['visiteur_session']['nom']  | 
                                                        |
| 2855 | - . " " . _VAR_MODE);  | 
                                                        |
| 2856 | - }  | 
                                                        |
| 2857 | - } // pas autorise ?  | 
                                                        |
| 2858 | -				else { | 
                                                        |
| 2859 | - // si on n'est pas connecte on se redirige  | 
                                                        |
| 2860 | -					if (!$GLOBALS['visiteur_session']) { | 
                                                        |
| 2861 | -						include_spip('inc/headers'); | 
                                                        |
| 2862 | -						redirige_par_entete(generer_url_public('login', | 
                                                        |
| 2863 | - 'url=' . rawurlencode(  | 
                                                        |
| 2864 | - parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')  | 
                                                        |
| 2865 | - ), true));  | 
                                                        |
| 2866 | - }  | 
                                                        |
| 2867 | - // sinon tant pis  | 
                                                        |
| 2868 | - }  | 
                                                        |
| 2869 | - }  | 
                                                        |
| 2870 | - }  | 
                                                        |
| 2871 | -		if (!defined('_VAR_MODE')) { | 
                                                        |
| 2872 | - /**  | 
                                                        |
| 2873 | - * Indique le mode de calcul ou d'affichage de la page.  | 
                                                        |
| 2874 | - * @see init_var_mode()  | 
                                                        |
| 2875 | - */  | 
                                                        |
| 2876 | -			define('_VAR_MODE', false); | 
                                                        |
| 2877 | - }  | 
                                                        |
| 2878 | - $done = true;  | 
                                                        |
| 2879 | - }  | 
                                                        |
| 2756 | + static $done = false;  | 
                                                        |
| 2757 | +    if (!$done) { | 
                                                        |
| 2758 | +  | 
                                                        |
| 2759 | +        if (isset($_GET['var_mode'])) { | 
                                                        |
| 2760 | +            $var_mode = explode(',', $_GET['var_mode']); | 
                                                        |
| 2761 | + // tout le monde peut calcul/recalcul  | 
                                                        |
| 2762 | +            if (!defined('_VAR_MODE')) { | 
                                                        |
| 2763 | +                if (in_array('recalcul', $var_mode)) { | 
                                                        |
| 2764 | +                    define('_VAR_MODE', 'recalcul'); | 
                                                        |
| 2765 | +                } elseif (in_array('calcul', $var_mode)) { | 
                                                        |
| 2766 | +                    define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2767 | + }  | 
                                                        |
| 2768 | + }  | 
                                                        |
| 2769 | +            $var_mode = array_diff($var_mode, array('calcul', 'recalcul')); | 
                                                        |
| 2770 | +            if ($var_mode) { | 
                                                        |
| 2771 | +                include_spip('inc/autoriser'); | 
                                                        |
| 2772 | + // autoriser preview si preview seulement, et sinon autoriser debug  | 
                                                        |
| 2773 | + if (autoriser(  | 
                                                        |
| 2774 | + ($_GET['var_mode'] == 'preview')  | 
                                                        |
| 2775 | + ? 'previsualiser'  | 
                                                        |
| 2776 | + : 'debug'  | 
                                                        |
| 2777 | +                )) { | 
                                                        |
| 2778 | +                    if (in_array('traduction', $var_mode)) { | 
                                                        |
| 2779 | + // forcer le calcul pour passer dans traduire  | 
                                                        |
| 2780 | +                        if (!defined('_VAR_MODE')) { | 
                                                        |
| 2781 | +                            define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2782 | + }  | 
                                                        |
| 2783 | + // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages  | 
                                                        |
| 2784 | +                        if (!defined('_VAR_NOCACHE')) { | 
                                                        |
| 2785 | +                            define('_VAR_NOCACHE', true); | 
                                                        |
| 2786 | + }  | 
                                                        |
| 2787 | +                        $var_mode = array_diff($var_mode, array('traduction')); | 
                                                        |
| 2788 | + }  | 
                                                        |
| 2789 | +                    if (in_array('preview', $var_mode)) { | 
                                                        |
| 2790 | + // basculer sur les criteres de preview dans les boucles  | 
                                                        |
| 2791 | +                        if (!defined('_VAR_PREVIEW')) { | 
                                                        |
| 2792 | +                            define('_VAR_PREVIEW', true); | 
                                                        |
| 2793 | + }  | 
                                                        |
| 2794 | + // forcer le calcul  | 
                                                        |
| 2795 | +                        if (!defined('_VAR_MODE')) { | 
                                                        |
| 2796 | +                            define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2797 | + }  | 
                                                        |
| 2798 | + // et ne pas enregistrer de cache  | 
                                                        |
| 2799 | +                        if (!defined('_VAR_NOCACHE')) { | 
                                                        |
| 2800 | +                            define('_VAR_NOCACHE', true); | 
                                                        |
| 2801 | + }  | 
                                                        |
| 2802 | +                        $var_mode = array_diff($var_mode, array('preview')); | 
                                                        |
| 2803 | + }  | 
                                                        |
| 2804 | +                    if (in_array('inclure', $var_mode)) { | 
                                                        |
| 2805 | + // forcer le compilo et ignorer les caches existants  | 
                                                        |
| 2806 | +                        if (!defined('_VAR_MODE')) { | 
                                                        |
| 2807 | +                            define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2808 | + }  | 
                                                        |
| 2809 | +                        if (!defined('_VAR_INCLURE')) { | 
                                                        |
| 2810 | +                            define('_VAR_INCLURE', true); | 
                                                        |
| 2811 | + }  | 
                                                        |
| 2812 | + // et ne pas enregistrer de cache  | 
                                                        |
| 2813 | +                        if (!defined('_VAR_NOCACHE')) { | 
                                                        |
| 2814 | +                            define('_VAR_NOCACHE', true); | 
                                                        |
| 2815 | + }  | 
                                                        |
| 2816 | +                        $var_mode = array_diff($var_mode, array('inclure')); | 
                                                        |
| 2817 | + }  | 
                                                        |
| 2818 | +                    if (in_array('urls', $var_mode)) { | 
                                                        |
| 2819 | + // forcer le compilo et ignorer les caches existants  | 
                                                        |
| 2820 | +                        if (!defined('_VAR_MODE')) { | 
                                                        |
| 2821 | +                            define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2822 | + }  | 
                                                        |
| 2823 | +                        if (!defined('_VAR_URLS')) { | 
                                                        |
| 2824 | +                            define('_VAR_URLS', true); | 
                                                        |
| 2825 | + }  | 
                                                        |
| 2826 | +                        $var_mode = array_diff($var_mode, array('urls')); | 
                                                        |
| 2827 | + }  | 
                                                        |
| 2828 | +                    if (in_array('images', $var_mode)) { | 
                                                        |
| 2829 | + // forcer le compilo et ignorer les caches existants  | 
                                                        |
| 2830 | +                        if (!defined('_VAR_MODE')) { | 
                                                        |
| 2831 | +                            define('_VAR_MODE', 'calcul'); | 
                                                        |
| 2832 | + }  | 
                                                        |
| 2833 | + // indiquer qu'on doit recalculer les images  | 
                                                        |
| 2834 | +                        if (!defined('_VAR_IMAGES')) { | 
                                                        |
| 2835 | +                            define('_VAR_IMAGES', true); | 
                                                        |
| 2836 | + }  | 
                                                        |
| 2837 | +                        $var_mode = array_diff($var_mode, array('images')); | 
                                                        |
| 2838 | + }  | 
                                                        |
| 2839 | +                    if (in_array('debug', $var_mode)) { | 
                                                        |
| 2840 | +                        if (!defined('_VAR_MODE')) { | 
                                                        |
| 2841 | +                            define('_VAR_MODE', 'debug'); | 
                                                        |
| 2842 | + }  | 
                                                        |
| 2843 | + // et ne pas enregistrer de cache  | 
                                                        |
| 2844 | +                        if (!defined('_VAR_NOCACHE')) { | 
                                                        |
| 2845 | +                            define('_VAR_NOCACHE', true); | 
                                                        |
| 2846 | + }  | 
                                                        |
| 2847 | +                        $var_mode = array_diff($var_mode, array('debug')); | 
                                                        |
| 2848 | + }  | 
                                                        |
| 2849 | +                    if (count($var_mode) and !defined('_VAR_MODE')) { | 
                                                        |
| 2850 | +                        define('_VAR_MODE', reset($var_mode)); | 
                                                        |
| 2851 | + }  | 
                                                        |
| 2852 | +                    if (isset($GLOBALS['visiteur_session']['nom'])) { | 
                                                        |
| 2853 | + spip_log($GLOBALS['visiteur_session']['nom']  | 
                                                        |
| 2854 | + . " " . _VAR_MODE);  | 
                                                        |
| 2855 | + }  | 
                                                        |
| 2856 | + } // pas autorise ?  | 
                                                        |
| 2857 | +                else { | 
                                                        |
| 2858 | + // si on n'est pas connecte on se redirige  | 
                                                        |
| 2859 | +                    if (!$GLOBALS['visiteur_session']) { | 
                                                        |
| 2860 | +                        include_spip('inc/headers'); | 
                                                        |
| 2861 | +                        redirige_par_entete(generer_url_public('login', | 
                                                        |
| 2862 | + 'url=' . rawurlencode(  | 
                                                        |
| 2863 | + parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')  | 
                                                        |
| 2864 | + ), true));  | 
                                                        |
| 2865 | + }  | 
                                                        |
| 2866 | + // sinon tant pis  | 
                                                        |
| 2867 | + }  | 
                                                        |
| 2868 | + }  | 
                                                        |
| 2869 | + }  | 
                                                        |
| 2870 | +        if (!defined('_VAR_MODE')) { | 
                                                        |
| 2871 | + /**  | 
                                                        |
| 2872 | + * Indique le mode de calcul ou d'affichage de la page.  | 
                                                        |
| 2873 | + * @see init_var_mode()  | 
                                                        |
| 2874 | + */  | 
                                                        |
| 2875 | +            define('_VAR_MODE', false); | 
                                                        |
| 2876 | + }  | 
                                                        |
| 2877 | + $done = true;  | 
                                                        |
| 2878 | + }  | 
                                                        |
| 2880 | 2879 | }  | 
                                                        
| 2881 | 2880 | |
| 2882 | 2881 | // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ;  | 
                                                        
@@ -2884,93 +2883,93 @@ discard block  | 
                                                    ||
| 2884 | 2883 |  // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal') | 
                                                        
| 2885 | 2884 | // http://code.spip.net/@spip_desinfecte  | 
                                                        
| 2886 | 2885 |  function spip_desinfecte(&$t, $deep = true) { | 
                                                        
| 2887 | - static $magic_quotes;  | 
                                                        |
| 2888 | -	if (!isset($magic_quotes)) { | 
                                                        |
| 2889 | - $magic_quotes = @get_magic_quotes_gpc();  | 
                                                        |
| 2890 | - }  | 
                                                        |
| 2891 | -  | 
                                                        |
| 2892 | -	foreach ($t as $key => $val) { | 
                                                        |
| 2893 | -		if (is_string($t[$key])) { | 
                                                        |
| 2894 | -			if ($magic_quotes) { | 
                                                        |
| 2895 | - $t[$key] = stripslashes($t[$key]);  | 
                                                        |
| 2896 | - }  | 
                                                        |
| 2897 | - $t[$key] = str_replace(chr(0), '-', $t[$key]);  | 
                                                        |
| 2898 | - } // traiter aussi les "texte_plus" de article_edit  | 
                                                        |
| 2899 | -		else { | 
                                                        |
| 2900 | -			if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { | 
                                                        |
| 2901 | - spip_desinfecte($t[$key], $deep);  | 
                                                        |
| 2902 | - }  | 
                                                        |
| 2903 | - }  | 
                                                        |
| 2904 | - }  | 
                                                        |
| 2886 | + static $magic_quotes;  | 
                                                        |
| 2887 | +    if (!isset($magic_quotes)) { | 
                                                        |
| 2888 | + $magic_quotes = @get_magic_quotes_gpc();  | 
                                                        |
| 2889 | + }  | 
                                                        |
| 2890 | +  | 
                                                        |
| 2891 | +    foreach ($t as $key => $val) { | 
                                                        |
| 2892 | +        if (is_string($t[$key])) { | 
                                                        |
| 2893 | +            if ($magic_quotes) { | 
                                                        |
| 2894 | + $t[$key] = stripslashes($t[$key]);  | 
                                                        |
| 2895 | + }  | 
                                                        |
| 2896 | + $t[$key] = str_replace(chr(0), '-', $t[$key]);  | 
                                                        |
| 2897 | + } // traiter aussi les "texte_plus" de article_edit  | 
                                                        |
| 2898 | +        else { | 
                                                        |
| 2899 | +            if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') { | 
                                                        |
| 2900 | + spip_desinfecte($t[$key], $deep);  | 
                                                        |
| 2901 | + }  | 
                                                        |
| 2902 | + }  | 
                                                        |
| 2903 | + }  | 
                                                        |
| 2905 | 2904 | }  | 
                                                        
| 2906 | 2905 | |
| 2907 | 2906 | // retourne le statut du visiteur s'il s'annonce  | 
                                                        
| 2908 | 2907 | |
| 2909 | 2908 | // http://code.spip.net/@verifier_visiteur  | 
                                                        
| 2910 | 2909 |  function verifier_visiteur() { | 
                                                        
| 2911 | - // Rq: pour que cette fonction marche depuis mes_options  | 
                                                        |
| 2912 | - // il faut forcer l'init si ce n'est fait  | 
                                                        |
| 2913 | - // mais on risque de perturber des plugins en initialisant trop tot  | 
                                                        |
| 2914 | - // certaines constantes  | 
                                                        |
| 2915 | - @spip_initialisation_core(  | 
                                                        |
| 2916 | - (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),  | 
                                                        |
| 2917 | - (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),  | 
                                                        |
| 2918 | - (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),  | 
                                                        |
| 2919 | - (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)  | 
                                                        |
| 2920 | - );  | 
                                                        |
| 2921 | -  | 
                                                        |
| 2922 | - // Demarrer une session NON AUTHENTIFIEE si on donne son nom  | 
                                                        |
| 2923 | - // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)  | 
                                                        |
| 2924 | - // Attention on separe bien session_nom et nom, pour eviter  | 
                                                        |
| 2925 | - // les melanges entre donnees SQL et variables plus aleatoires  | 
                                                        |
| 2926 | -	$variables_session = array('session_nom', 'session_email'); | 
                                                        |
| 2927 | -	foreach ($variables_session as $var) { | 
                                                        |
| 2928 | -		if (_request($var) !== null) { | 
                                                        |
| 2929 | - $init = true;  | 
                                                        |
| 2930 | - break;  | 
                                                        |
| 2931 | - }  | 
                                                        |
| 2932 | - }  | 
                                                        |
| 2933 | -	if (isset($init)) { | 
                                                        |
| 2934 | - #@spip_initialisation_suite();  | 
                                                        |
| 2935 | -		$session = charger_fonction('session', 'inc'); | 
                                                        |
| 2936 | - $session();  | 
                                                        |
| 2937 | -		include_spip('inc/texte'); | 
                                                        |
| 2938 | -		foreach ($variables_session as $var) { | 
                                                        |
| 2939 | -			if (($a = _request($var)) !== null) { | 
                                                        |
| 2940 | - $GLOBALS['visiteur_session'][$var] = safehtml($a);  | 
                                                        |
| 2941 | - }  | 
                                                        |
| 2942 | - }  | 
                                                        |
| 2943 | -		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { | 
                                                        |
| 2944 | - $GLOBALS['visiteur_session']['id_auteur'] = 0;  | 
                                                        |
| 2945 | - }  | 
                                                        |
| 2946 | - $session($GLOBALS['visiteur_session']);  | 
                                                        |
| 2947 | -  | 
                                                        |
| 2948 | - return 0;  | 
                                                        |
| 2949 | - }  | 
                                                        |
| 2950 | -  | 
                                                        |
| 2951 | - $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);  | 
                                                        |
| 2952 | -	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { | 
                                                        |
| 2953 | -  | 
                                                        |
| 2954 | -		$session = charger_fonction('session', 'inc'); | 
                                                        |
| 2955 | -		if ($session()) { | 
                                                        |
| 2956 | - return $GLOBALS['visiteur_session']['statut'];  | 
                                                        |
| 2957 | - }  | 
                                                        |
| 2958 | -		if ($h and isset($_SERVER['PHP_AUTH_PW'])) { | 
                                                        |
| 2959 | -			include_spip('inc/auth'); | 
                                                        |
| 2960 | - $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);  | 
                                                        |
| 2961 | - }  | 
                                                        |
| 2962 | -		if ($h) { | 
                                                        |
| 2963 | - $GLOBALS['visiteur_session'] = $h;  | 
                                                        |
| 2964 | -  | 
                                                        |
| 2965 | - return $GLOBALS['visiteur_session']['statut'];  | 
                                                        |
| 2966 | - }  | 
                                                        |
| 2967 | - }  | 
                                                        |
| 2968 | -  | 
                                                        |
| 2969 | - // au moins son navigateur nous dit la langue preferee de cet inconnu  | 
                                                        |
| 2970 | -	include_spip('inc/lang'); | 
                                                        |
| 2971 | - utiliser_langue_visiteur();  | 
                                                        |
| 2972 | -  | 
                                                        |
| 2973 | - return false;  | 
                                                        |
| 2910 | + // Rq: pour que cette fonction marche depuis mes_options  | 
                                                        |
| 2911 | + // il faut forcer l'init si ce n'est fait  | 
                                                        |
| 2912 | + // mais on risque de perturber des plugins en initialisant trop tot  | 
                                                        |
| 2913 | + // certaines constantes  | 
                                                        |
| 2914 | + @spip_initialisation_core(  | 
                                                        |
| 2915 | + (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),  | 
                                                        |
| 2916 | + (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),  | 
                                                        |
| 2917 | + (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),  | 
                                                        |
| 2918 | + (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)  | 
                                                        |
| 2919 | + );  | 
                                                        |
| 2920 | +  | 
                                                        |
| 2921 | + // Demarrer une session NON AUTHENTIFIEE si on donne son nom  | 
                                                        |
| 2922 | + // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)  | 
                                                        |
| 2923 | + // Attention on separe bien session_nom et nom, pour eviter  | 
                                                        |
| 2924 | + // les melanges entre donnees SQL et variables plus aleatoires  | 
                                                        |
| 2925 | +    $variables_session = array('session_nom', 'session_email'); | 
                                                        |
| 2926 | +    foreach ($variables_session as $var) { | 
                                                        |
| 2927 | +        if (_request($var) !== null) { | 
                                                        |
| 2928 | + $init = true;  | 
                                                        |
| 2929 | + break;  | 
                                                        |
| 2930 | + }  | 
                                                        |
| 2931 | + }  | 
                                                        |
| 2932 | +    if (isset($init)) { | 
                                                        |
| 2933 | + #@spip_initialisation_suite();  | 
                                                        |
| 2934 | +        $session = charger_fonction('session', 'inc'); | 
                                                        |
| 2935 | + $session();  | 
                                                        |
| 2936 | +        include_spip('inc/texte'); | 
                                                        |
| 2937 | +        foreach ($variables_session as $var) { | 
                                                        |
| 2938 | +            if (($a = _request($var)) !== null) { | 
                                                        |
| 2939 | + $GLOBALS['visiteur_session'][$var] = safehtml($a);  | 
                                                        |
| 2940 | + }  | 
                                                        |
| 2941 | + }  | 
                                                        |
| 2942 | +        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) { | 
                                                        |
| 2943 | + $GLOBALS['visiteur_session']['id_auteur'] = 0;  | 
                                                        |
| 2944 | + }  | 
                                                        |
| 2945 | + $session($GLOBALS['visiteur_session']);  | 
                                                        |
| 2946 | +  | 
                                                        |
| 2947 | + return 0;  | 
                                                        |
| 2948 | + }  | 
                                                        |
| 2949 | +  | 
                                                        |
| 2950 | + $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);  | 
                                                        |
| 2951 | +    if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) { | 
                                                        |
| 2952 | +  | 
                                                        |
| 2953 | +        $session = charger_fonction('session', 'inc'); | 
                                                        |
| 2954 | +        if ($session()) { | 
                                                        |
| 2955 | + return $GLOBALS['visiteur_session']['statut'];  | 
                                                        |
| 2956 | + }  | 
                                                        |
| 2957 | +        if ($h and isset($_SERVER['PHP_AUTH_PW'])) { | 
                                                        |
| 2958 | +            include_spip('inc/auth'); | 
                                                        |
| 2959 | + $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);  | 
                                                        |
| 2960 | + }  | 
                                                        |
| 2961 | +        if ($h) { | 
                                                        |
| 2962 | + $GLOBALS['visiteur_session'] = $h;  | 
                                                        |
| 2963 | +  | 
                                                        |
| 2964 | + return $GLOBALS['visiteur_session']['statut'];  | 
                                                        |
| 2965 | + }  | 
                                                        |
| 2966 | + }  | 
                                                        |
| 2967 | +  | 
                                                        |
| 2968 | + // au moins son navigateur nous dit la langue preferee de cet inconnu  | 
                                                        |
| 2969 | +    include_spip('inc/lang'); | 
                                                        |
| 2970 | + utiliser_langue_visiteur();  | 
                                                        |
| 2971 | +  | 
                                                        |
| 2972 | + return false;  | 
                                                        |
| 2974 | 2973 | }  | 
                                                        
| 2975 | 2974 | |
| 2976 | 2975 | |
@@ -2993,21 +2992,21 @@ discard block  | 
                                                    ||
| 2993 | 2992 | * - string Langue utilisée.  | 
                                                        
| 2994 | 2993 | **/  | 
                                                        
| 2995 | 2994 |  function lang_select($lang = null) { | 
                                                        
| 2996 | - static $pile_langues = array();  | 
                                                        |
| 2997 | -	if (!function_exists('changer_langue')) { | 
                                                        |
| 2998 | -		include_spip('inc/lang'); | 
                                                        |
| 2999 | - }  | 
                                                        |
| 3000 | -	if ($lang === null) { | 
                                                        |
| 3001 | - $lang = array_pop($pile_langues);  | 
                                                        |
| 3002 | -	} else { | 
                                                        |
| 3003 | - array_push($pile_langues, $GLOBALS['spip_lang']);  | 
                                                        |
| 3004 | - }  | 
                                                        |
| 3005 | -	if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { | 
                                                        |
| 3006 | - return $lang;  | 
                                                        |
| 3007 | - }  | 
                                                        |
| 3008 | - changer_langue($lang);  | 
                                                        |
| 2995 | + static $pile_langues = array();  | 
                                                        |
| 2996 | +    if (!function_exists('changer_langue')) { | 
                                                        |
| 2997 | +        include_spip('inc/lang'); | 
                                                        |
| 2998 | + }  | 
                                                        |
| 2999 | +    if ($lang === null) { | 
                                                        |
| 3000 | + $lang = array_pop($pile_langues);  | 
                                                        |
| 3001 | +    } else { | 
                                                        |
| 3002 | + array_push($pile_langues, $GLOBALS['spip_lang']);  | 
                                                        |
| 3003 | + }  | 
                                                        |
| 3004 | +    if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) { | 
                                                        |
| 3005 | + return $lang;  | 
                                                        |
| 3006 | + }  | 
                                                        |
| 3007 | + changer_langue($lang);  | 
                                                        |
| 3009 | 3008 | |
| 3010 | - return $lang;  | 
                                                        |
| 3009 | + return $lang;  | 
                                                        |
| 3011 | 3010 | }  | 
                                                        
| 3012 | 3011 | |
| 3013 | 3012 | /**  | 
                                                        
@@ -3024,19 +3023,19 @@ discard block  | 
                                                    ||
| 3024 | 3023 | * Identifiant de la session  | 
                                                        
| 3025 | 3024 | **/  | 
                                                        
| 3026 | 3025 |  function spip_session($force = false) { | 
                                                        
| 3027 | - static $session;  | 
                                                        |
| 3028 | -	if ($force or !isset($session)) { | 
                                                        |
| 3029 | -		$s = pipeline('definir_session', | 
                                                        |
| 3030 | - $GLOBALS['visiteur_session']  | 
                                                        |
| 3031 | - ? serialize($GLOBALS['visiteur_session'])  | 
                                                        |
| 3032 | - . '_' . @$_COOKIE['spip_session']  | 
                                                        |
| 3033 | - : ''  | 
                                                        |
| 3034 | - );  | 
                                                        |
| 3035 | - $session = $s ? substr(md5($s), 0, 8) : '';  | 
                                                        |
| 3036 | - }  | 
                                                        |
| 3026 | + static $session;  | 
                                                        |
| 3027 | +    if ($force or !isset($session)) { | 
                                                        |
| 3028 | +        $s = pipeline('definir_session', | 
                                                        |
| 3029 | + $GLOBALS['visiteur_session']  | 
                                                        |
| 3030 | + ? serialize($GLOBALS['visiteur_session'])  | 
                                                        |
| 3031 | + . '_' . @$_COOKIE['spip_session']  | 
                                                        |
| 3032 | + : ''  | 
                                                        |
| 3033 | + );  | 
                                                        |
| 3034 | + $session = $s ? substr(md5($s), 0, 8) : '';  | 
                                                        |
| 3035 | + }  | 
                                                        |
| 3037 | 3036 | |
| 3038 | -	#spip_log('session: '.$session); | 
                                                        |
| 3039 | - return $session;  | 
                                                        |
| 3037 | +    #spip_log('session: '.$session); | 
                                                        |
| 3038 | + return $session;  | 
                                                        |
| 3040 | 3039 | }  | 
                                                        
| 3041 | 3040 | |
| 3042 | 3041 | |
@@ -3055,9 +3054,9 @@ discard block  | 
                                                    ||
| 3055 | 3054 | * Lien sur une icone d'aide  | 
                                                        
| 3056 | 3055 | **/  | 
                                                        
| 3057 | 3056 |  function aider($aide = '', $distante = false) { | 
                                                        
| 3058 | -	$aider = charger_fonction('aide', 'inc', true); | 
                                                        |
| 3057 | +    $aider = charger_fonction('aide', 'inc', true); | 
                                                        |
| 3059 | 3058 | |
| 3060 | - return $aider ? $aider($aide, '', array(), $distante) : '';  | 
                                                        |
| 3059 | + return $aider ? $aider($aide, '', array(), $distante) : '';  | 
                                                        |
| 3061 | 3060 | }  | 
                                                        
| 3062 | 3061 | |
| 3063 | 3062 | /**  | 
                                                        
@@ -3067,13 +3066,13 @@ discard block  | 
                                                    ||
| 3067 | 3066 | */  | 
                                                        
| 3068 | 3067 |  function exec_info_dist() { | 
                                                        
| 3069 | 3068 | |
| 3070 | -	include_spip('inc/autoriser'); | 
                                                        |
| 3071 | -	if (autoriser('webmestre')) { | 
                                                        |
| 3072 | - phpinfo();  | 
                                                        |
| 3073 | -	} else { | 
                                                        |
| 3074 | -		include_spip('inc/filtres'); | 
                                                        |
| 3075 | - sinon_interdire_acces();  | 
                                                        |
| 3076 | - }  | 
                                                        |
| 3069 | +    include_spip('inc/autoriser'); | 
                                                        |
| 3070 | +    if (autoriser('webmestre')) { | 
                                                        |
| 3071 | + phpinfo();  | 
                                                        |
| 3072 | +    } else { | 
                                                        |
| 3073 | +        include_spip('inc/filtres'); | 
                                                        |
| 3074 | + sinon_interdire_acces();  | 
                                                        |
| 3075 | + }  | 
                                                        |
| 3077 | 3076 | }  | 
                                                        
| 3078 | 3077 | |
| 3079 | 3078 | /**  | 
                                                        
@@ -3093,13 +3092,13 @@ discard block  | 
                                                    ||
| 3093 | 3092 | * - string si $message à false.  | 
                                                        
| 3094 | 3093 | **/  | 
                                                        
| 3095 | 3094 |  function erreur_squelette($message = '', $lieu = '') { | 
                                                        
| 3096 | -	$debusquer = charger_fonction('debusquer', 'public'); | 
                                                        |
| 3097 | -	if (is_array($lieu)) { | 
                                                        |
| 3098 | -		include_spip('public/compiler'); | 
                                                        |
| 3099 | - $lieu = reconstruire_contexte_compil($lieu);  | 
                                                        |
| 3100 | - }  | 
                                                        |
| 3095 | +    $debusquer = charger_fonction('debusquer', 'public'); | 
                                                        |
| 3096 | +    if (is_array($lieu)) { | 
                                                        |
| 3097 | +        include_spip('public/compiler'); | 
                                                        |
| 3098 | + $lieu = reconstruire_contexte_compil($lieu);  | 
                                                        |
| 3099 | + }  | 
                                                        |
| 3101 | 3100 | |
| 3102 | - return $debusquer($message, $lieu);  | 
                                                        |
| 3101 | + return $debusquer($message, $lieu);  | 
                                                        |
| 3103 | 3102 | }  | 
                                                        
| 3104 | 3103 | |
| 3105 | 3104 | /**  | 
                                                        
@@ -3136,110 +3135,110 @@ discard block  | 
                                                    ||
| 3136 | 3135 | * - ou tableau d'information sur le squelette.  | 
                                                        
| 3137 | 3136 | */  | 
                                                        
| 3138 | 3137 |  function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') { | 
                                                        
| 3139 | -	if (!function_exists('evaluer_fond')) { | 
                                                        |
| 3140 | -		include_spip('public/assembler'); | 
                                                        |
| 3141 | - }  | 
                                                        |
| 3142 | - // assurer la compat avec l'ancienne syntaxe  | 
                                                        |
| 3143 | - // (trim etait le 3eme argument, par defaut a true)  | 
                                                        |
| 3144 | -	if (!is_array($options)) { | 
                                                        |
| 3145 | -		$options = array('trim' => $options); | 
                                                        |
| 3146 | - }  | 
                                                        |
| 3147 | -	if (!isset($options['trim'])) { | 
                                                        |
| 3148 | - $options['trim'] = true;  | 
                                                        |
| 3149 | - }  | 
                                                        |
| 3150 | -  | 
                                                        |
| 3151 | -	if (isset($contexte['connect'])) { | 
                                                        |
| 3152 | - $connect = $contexte['connect'];  | 
                                                        |
| 3153 | - unset($contexte['connect']);  | 
                                                        |
| 3154 | - }  | 
                                                        |
| 3155 | -  | 
                                                        |
| 3156 | - $texte = "";  | 
                                                        |
| 3157 | - $pages = array();  | 
                                                        |
| 3158 | - $lang_select = '';  | 
                                                        |
| 3159 | -	if (!isset($options['etoile']) or !$options['etoile']) { | 
                                                        |
| 3160 | - // Si on a inclus sans fixer le critere de lang, on prend la langue courante  | 
                                                        |
| 3161 | -		if (!isset($contexte['lang'])) { | 
                                                        |
| 3162 | - $contexte['lang'] = $GLOBALS['spip_lang'];  | 
                                                        |
| 3163 | - }  | 
                                                        |
| 3164 | -  | 
                                                        |
| 3165 | -		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { | 
                                                        |
| 3166 | - $lang_select = lang_select($contexte['lang']);  | 
                                                        |
| 3167 | - }  | 
                                                        |
| 3168 | - }  | 
                                                        |
| 3169 | -  | 
                                                        |
| 3170 | -	if (!isset($GLOBALS['_INC_PUBLIC'])) { | 
                                                        |
| 3171 | - $GLOBALS['_INC_PUBLIC'] = 0;  | 
                                                        |
| 3172 | - }  | 
                                                        |
| 3173 | -  | 
                                                        |
| 3174 | - $GLOBALS['_INC_PUBLIC']++;  | 
                                                        |
| 3175 | -  | 
                                                        |
| 3176 | - // fix #4235  | 
                                                        |
| 3177 | - // On mémorise l'état initial du sessionnement du contexte incluant  | 
                                                        |
| 3178 | - $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);  | 
                                                        |
| 3179 | -  | 
                                                        |
| 3180 | -  | 
                                                        |
| 3181 | -	foreach (is_array($fond) ? $fond : array($fond) as $f) { | 
                                                        |
| 3138 | +    if (!function_exists('evaluer_fond')) { | 
                                                        |
| 3139 | +        include_spip('public/assembler'); | 
                                                        |
| 3140 | + }  | 
                                                        |
| 3141 | + // assurer la compat avec l'ancienne syntaxe  | 
                                                        |
| 3142 | + // (trim etait le 3eme argument, par defaut a true)  | 
                                                        |
| 3143 | +    if (!is_array($options)) { | 
                                                        |
| 3144 | +        $options = array('trim' => $options); | 
                                                        |
| 3145 | + }  | 
                                                        |
| 3146 | +    if (!isset($options['trim'])) { | 
                                                        |
| 3147 | + $options['trim'] = true;  | 
                                                        |
| 3148 | + }  | 
                                                        |
| 3149 | +  | 
                                                        |
| 3150 | +    if (isset($contexte['connect'])) { | 
                                                        |
| 3151 | + $connect = $contexte['connect'];  | 
                                                        |
| 3152 | + unset($contexte['connect']);  | 
                                                        |
| 3153 | + }  | 
                                                        |
| 3154 | +  | 
                                                        |
| 3155 | + $texte = "";  | 
                                                        |
| 3156 | + $pages = array();  | 
                                                        |
| 3157 | + $lang_select = '';  | 
                                                        |
| 3158 | +    if (!isset($options['etoile']) or !$options['etoile']) { | 
                                                        |
| 3159 | + // Si on a inclus sans fixer le critere de lang, on prend la langue courante  | 
                                                        |
| 3160 | +        if (!isset($contexte['lang'])) { | 
                                                        |
| 3161 | + $contexte['lang'] = $GLOBALS['spip_lang'];  | 
                                                        |
| 3162 | + }  | 
                                                        |
| 3163 | +  | 
                                                        |
| 3164 | +        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) { | 
                                                        |
| 3165 | + $lang_select = lang_select($contexte['lang']);  | 
                                                        |
| 3166 | + }  | 
                                                        |
| 3167 | + }  | 
                                                        |
| 3168 | +  | 
                                                        |
| 3169 | +    if (!isset($GLOBALS['_INC_PUBLIC'])) { | 
                                                        |
| 3170 | + $GLOBALS['_INC_PUBLIC'] = 0;  | 
                                                        |
| 3171 | + }  | 
                                                        |
| 3172 | +  | 
                                                        |
| 3173 | + $GLOBALS['_INC_PUBLIC']++;  | 
                                                        |
| 3174 | +  | 
                                                        |
| 3175 | + // fix #4235  | 
                                                        |
| 3176 | + // On mémorise l'état initial du sessionnement du contexte incluant  | 
                                                        |
| 3177 | + $cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);  | 
                                                        |
| 3178 | +  | 
                                                        |
| 3179 | +  | 
                                                        |
| 3180 | +    foreach (is_array($fond) ? $fond : array($fond) as $f) { | 
                                                        |
| 3182 | 3181 | |
| 3183 | - unset($GLOBALS['cache_utilise_session']); // fix #4235 : Chaque inclusion commence sans sessionnement préallable  | 
                                                        |
| 3182 | + unset($GLOBALS['cache_utilise_session']); // fix #4235 : Chaque inclusion commence sans sessionnement préallable  | 
                                                        |
| 3184 | 3183 | |
| 3185 | 3184 | |
| 3186 | - $page = evaluer_fond($f, $contexte, $connect);  | 
                                                        |
| 3187 | -		if ($page === '') { | 
                                                        |
| 3188 | - $c = isset($options['compil']) ? $options['compil'] : '';  | 
                                                        |
| 3189 | -			$a = array('fichier' => $f); | 
                                                        |
| 3190 | -			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable | 
                                                        |
| 3191 | - erreur_squelette($erreur, $c);  | 
                                                        |
| 3192 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4  | 
                                                        |
| 3193 | -			$page = array('texte' => '', 'erreur' => $erreur); | 
                                                        |
| 3194 | - }  | 
                                                        |
| 3195 | -  | 
                                                        |
| 3196 | -		$page = pipeline('recuperer_fond', array( | 
                                                        |
| 3197 | -			'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), | 
                                                        |
| 3198 | - 'data' => $page  | 
                                                        |
| 3199 | - ));  | 
                                                        |
| 3200 | -		if (isset($options['ajax']) and $options['ajax']) { | 
                                                        |
| 3201 | -			if (!function_exists('encoder_contexte_ajax')) { | 
                                                        |
| 3202 | -				include_spip('inc/filtres'); | 
                                                        |
| 3203 | - }  | 
                                                        |
| 3204 | - $page['texte'] = encoder_contexte_ajax(  | 
                                                        |
| 3205 | - array_merge(  | 
                                                        |
| 3206 | - $contexte,  | 
                                                        |
| 3207 | -					array('fond' => $f), | 
                                                        |
| 3208 | -					($connect ? array('connect' => $connect) : array()) | 
                                                        |
| 3209 | - ),  | 
                                                        |
| 3210 | - '',  | 
                                                        |
| 3211 | - $page['texte'],  | 
                                                        |
| 3212 | - $options['ajax']  | 
                                                        |
| 3213 | - );  | 
                                                        |
| 3214 | - }  | 
                                                        |
| 3215 | -  | 
                                                        |
| 3216 | -		if (isset($options['raw']) and $options['raw']) { | 
                                                        |
| 3217 | - $pages[] = $page;  | 
                                                        |
| 3218 | -		} else { | 
                                                        |
| 3219 | - $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];  | 
                                                        |
| 3220 | - }  | 
                                                        |
| 3185 | + $page = evaluer_fond($f, $contexte, $connect);  | 
                                                        |
| 3186 | +        if ($page === '') { | 
                                                        |
| 3187 | + $c = isset($options['compil']) ? $options['compil'] : '';  | 
                                                        |
| 3188 | +            $a = array('fichier' => $f); | 
                                                        |
| 3189 | +            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable | 
                                                        |
| 3190 | + erreur_squelette($erreur, $c);  | 
                                                        |
| 3191 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4  | 
                                                        |
| 3192 | +            $page = array('texte' => '', 'erreur' => $erreur); | 
                                                        |
| 3193 | + }  | 
                                                        |
| 3194 | +  | 
                                                        |
| 3195 | +        $page = pipeline('recuperer_fond', array( | 
                                                        |
| 3196 | +            'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect), | 
                                                        |
| 3197 | + 'data' => $page  | 
                                                        |
| 3198 | + ));  | 
                                                        |
| 3199 | +        if (isset($options['ajax']) and $options['ajax']) { | 
                                                        |
| 3200 | +            if (!function_exists('encoder_contexte_ajax')) { | 
                                                        |
| 3201 | +                include_spip('inc/filtres'); | 
                                                        |
| 3202 | + }  | 
                                                        |
| 3203 | + $page['texte'] = encoder_contexte_ajax(  | 
                                                        |
| 3204 | + array_merge(  | 
                                                        |
| 3205 | + $contexte,  | 
                                                        |
| 3206 | +                    array('fond' => $f), | 
                                                        |
| 3207 | +                    ($connect ? array('connect' => $connect) : array()) | 
                                                        |
| 3208 | + ),  | 
                                                        |
| 3209 | + '',  | 
                                                        |
| 3210 | + $page['texte'],  | 
                                                        |
| 3211 | + $options['ajax']  | 
                                                        |
| 3212 | + );  | 
                                                        |
| 3213 | + }  | 
                                                        |
| 3214 | +  | 
                                                        |
| 3215 | +        if (isset($options['raw']) and $options['raw']) { | 
                                                        |
| 3216 | + $pages[] = $page;  | 
                                                        |
| 3217 | +        } else { | 
                                                        |
| 3218 | + $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];  | 
                                                        |
| 3219 | + }  | 
                                                        |
| 3221 | 3220 | |
| 3222 | - // fix #4235 : contamination de la session appelante, pour les inclusions statiques  | 
                                                        |
| 3223 | - if (isset($options['sessionnement_contaminant'])  | 
                                                        |
| 3224 | - and isset($page['invalideurs']['session']))  | 
                                                        |
| 3225 | - $cache_utilise_session_appelant = $page['invalideurs']['session'];  | 
                                                        |
| 3226 | - }  | 
                                                        |
| 3227 | -  | 
                                                        |
| 3228 | - // fix #4235 : restaurer le sessionnement du contexte appelant,  | 
                                                        |
| 3229 | - // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée  | 
                                                        |
| 3230 | - $GLOBALS['cache_utilise_session']  | 
                                                        |
| 3231 | - = (isset($cache_utilise_session_appelant) ? $cache_utilise_session_appelant : null);  | 
                                                        |
| 3221 | + // fix #4235 : contamination de la session appelante, pour les inclusions statiques  | 
                                                        |
| 3222 | + if (isset($options['sessionnement_contaminant'])  | 
                                                        |
| 3223 | + and isset($page['invalideurs']['session']))  | 
                                                        |
| 3224 | + $cache_utilise_session_appelant = $page['invalideurs']['session'];  | 
                                                        |
| 3225 | + }  | 
                                                        |
| 3226 | +  | 
                                                        |
| 3227 | + // fix #4235 : restaurer le sessionnement du contexte appelant,  | 
                                                        |
| 3228 | + // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée  | 
                                                        |
| 3229 | + $GLOBALS['cache_utilise_session']  | 
                                                        |
| 3230 | + = (isset($cache_utilise_session_appelant) ? $cache_utilise_session_appelant : null);  | 
                                                        |
| 3232 | 3231 | |
| 3233 | - $GLOBALS['_INC_PUBLIC']--;  | 
                                                        |
| 3232 | + $GLOBALS['_INC_PUBLIC']--;  | 
                                                        |
| 3234 | 3233 | |
| 3235 | -	if ($lang_select) { | 
                                                        |
| 3236 | - lang_select();  | 
                                                        |
| 3237 | - }  | 
                                                        |
| 3238 | -	if (isset($options['raw']) and $options['raw']) { | 
                                                        |
| 3239 | - return is_array($fond) ? $pages : reset($pages);  | 
                                                        |
| 3240 | -	} else { | 
                                                        |
| 3241 | - return $options['trim'] ? ltrim($texte) : $texte;  | 
                                                        |
| 3242 | - }  | 
                                                        |
| 3234 | +    if ($lang_select) { | 
                                                        |
| 3235 | + lang_select();  | 
                                                        |
| 3236 | + }  | 
                                                        |
| 3237 | +    if (isset($options['raw']) and $options['raw']) { | 
                                                        |
| 3238 | + return is_array($fond) ? $pages : reset($pages);  | 
                                                        |
| 3239 | +    } else { | 
                                                        |
| 3240 | + return $options['trim'] ? ltrim($texte) : $texte;  | 
                                                        |
| 3241 | + }  | 
                                                        |
| 3243 | 3242 | }  | 
                                                        
| 3244 | 3243 | |
| 3245 | 3244 | /**  | 
                                                        
@@ -3249,7 +3248,7 @@ discard block  | 
                                                    ||
| 3249 | 3248 | * @return string  | 
                                                        
| 3250 | 3249 | */  | 
                                                        
| 3251 | 3250 |  function trouve_modele($nom) { | 
                                                        
| 3252 | - return trouver_fond($nom, 'modeles/');  | 
                                                        |
| 3251 | + return trouver_fond($nom, 'modeles/');  | 
                                                        |
| 3253 | 3252 | }  | 
                                                        
| 3254 | 3253 | |
| 3255 | 3254 | /**  | 
                                                        
@@ -3265,21 +3264,21 @@ discard block  | 
                                                    ||
| 3265 | 3264 | * @return array|string  | 
                                                        
| 3266 | 3265 | */  | 
                                                        
| 3267 | 3266 |  function trouver_fond($nom, $dir = '', $pathinfo = false) { | 
                                                        
| 3268 | - $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');  | 
                                                        |
| 3269 | -	if (!$pathinfo) { | 
                                                        |
| 3270 | - return $f;  | 
                                                        |
| 3271 | - }  | 
                                                        |
| 3272 | - // renvoyer un tableau detaille si $pathinfo==true  | 
                                                        |
| 3273 | - $p = pathinfo($f);  | 
                                                        |
| 3274 | -	if (!isset($p['extension']) or !$p['extension']) { | 
                                                        |
| 3275 | - $p['extension'] = _EXTENSION_SQUELETTES;  | 
                                                        |
| 3276 | - }  | 
                                                        |
| 3277 | -	if (!isset($p['extension']) or !$p['filename']) { | 
                                                        |
| 3278 | - $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');  | 
                                                        |
| 3279 | - }  | 
                                                        |
| 3280 | - $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');  | 
                                                        |
| 3267 | + $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');  | 
                                                        |
| 3268 | +    if (!$pathinfo) { | 
                                                        |
| 3269 | + return $f;  | 
                                                        |
| 3270 | + }  | 
                                                        |
| 3271 | + // renvoyer un tableau detaille si $pathinfo==true  | 
                                                        |
| 3272 | + $p = pathinfo($f);  | 
                                                        |
| 3273 | +    if (!isset($p['extension']) or !$p['extension']) { | 
                                                        |
| 3274 | + $p['extension'] = _EXTENSION_SQUELETTES;  | 
                                                        |
| 3275 | + }  | 
                                                        |
| 3276 | +    if (!isset($p['extension']) or !$p['filename']) { | 
                                                        |
| 3277 | + $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');  | 
                                                        |
| 3278 | + }  | 
                                                        |
| 3279 | + $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');  | 
                                                        |
| 3281 | 3280 | |
| 3282 | - return $p;  | 
                                                        |
| 3281 | + return $p;  | 
                                                        |
| 3283 | 3282 | }  | 
                                                        
| 3284 | 3283 | |
| 3285 | 3284 | /**  | 
                                                        
@@ -3300,24 +3299,24 @@ discard block  | 
                                                    ||
| 3300 | 3299 | * Nom de l'exec, sinon chaîne vide.  | 
                                                        
| 3301 | 3300 | **/  | 
                                                        
| 3302 | 3301 |  function tester_url_ecrire($nom) { | 
                                                        
| 3303 | - static $exec = array();  | 
                                                        |
| 3304 | -	if (isset($exec[$nom])) { | 
                                                        |
| 3305 | - return $exec[$nom];  | 
                                                        |
| 3306 | - }  | 
                                                        |
| 3307 | - // tester si c'est une page en squelette  | 
                                                        |
| 3308 | -	if (trouver_fond($nom, 'prive/squelettes/contenu/')) { | 
                                                        |
| 3309 | - return $exec[$nom] = 'fond';  | 
                                                        |
| 3310 | - } // compat skels orthogonaux version precedente  | 
                                                        |
| 3311 | -	elseif (trouver_fond($nom, 'prive/exec/')) { | 
                                                        |
| 3312 | - return $exec[$nom] = 'fond_monobloc';  | 
                                                        |
| 3313 | - } // echafaudage d'un fond !  | 
                                                        |
| 3314 | -	elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { | 
                                                        |
| 3315 | - return $exec[$nom] = 'fond';  | 
                                                        |
| 3316 | - }  | 
                                                        |
| 3317 | - // attention, il ne faut pas inclure l'exec ici  | 
                                                        |
| 3318 | - // car sinon #URL_ECRIRE provoque des inclusions  | 
                                                        |
| 3319 | - // et des define intrusifs potentiels  | 
                                                        |
| 3320 | -	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); | 
                                                        |
| 3302 | + static $exec = array();  | 
                                                        |
| 3303 | +    if (isset($exec[$nom])) { | 
                                                        |
| 3304 | + return $exec[$nom];  | 
                                                        |
| 3305 | + }  | 
                                                        |
| 3306 | + // tester si c'est une page en squelette  | 
                                                        |
| 3307 | +    if (trouver_fond($nom, 'prive/squelettes/contenu/')) { | 
                                                        |
| 3308 | + return $exec[$nom] = 'fond';  | 
                                                        |
| 3309 | + } // compat skels orthogonaux version precedente  | 
                                                        |
| 3310 | +    elseif (trouver_fond($nom, 'prive/exec/')) { | 
                                                        |
| 3311 | + return $exec[$nom] = 'fond_monobloc';  | 
                                                        |
| 3312 | + } // echafaudage d'un fond !  | 
                                                        |
| 3313 | +    elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) { | 
                                                        |
| 3314 | + return $exec[$nom] = 'fond';  | 
                                                        |
| 3315 | + }  | 
                                                        |
| 3316 | + // attention, il ne faut pas inclure l'exec ici  | 
                                                        |
| 3317 | + // car sinon #URL_ECRIRE provoque des inclusions  | 
                                                        |
| 3318 | + // et des define intrusifs potentiels  | 
                                                        |
| 3319 | +    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : ''); | 
                                                        |
| 3321 | 3320 | }  | 
                                                        
| 3322 | 3321 | |
| 3323 | 3322 | |
@@ -3333,10 +3332,10 @@ discard block  | 
                                                    ||
| 3333 | 3332 | * @return bool true si le module est chargé  | 
                                                        
| 3334 | 3333 | **/  | 
                                                        
| 3335 | 3334 |  function charger_php_extension($module) { | 
                                                        
| 3336 | -	if (extension_loaded($module)) { | 
                                                        |
| 3337 | - return true;  | 
                                                        |
| 3338 | - }  | 
                                                        |
| 3339 | - return false;  | 
                                                        |
| 3335 | +    if (extension_loaded($module)) { | 
                                                        |
| 3336 | + return true;  | 
                                                        |
| 3337 | + }  | 
                                                        |
| 3338 | + return false;  | 
                                                        |
| 3340 | 3339 | }  | 
                                                        
| 3341 | 3340 | |
| 3342 | 3341 | |
@@ -3347,8 +3346,8 @@ discard block  | 
                                                    ||
| 3347 | 3346 | * true si et seulement si la configuration autorise le code HTML5 sur le site public  | 
                                                        
| 3348 | 3347 | **/  | 
                                                        
| 3349 | 3348 |  function html5_permis() { | 
                                                        
| 3350 | - return (isset($GLOBALS['meta']['version_html_max'])  | 
                                                        |
| 3351 | -		and ('html5' == $GLOBALS['meta']['version_html_max'])); | 
                                                        |
| 3349 | + return (isset($GLOBALS['meta']['version_html_max'])  | 
                                                        |
| 3350 | +        and ('html5' == $GLOBALS['meta']['version_html_max'])); | 
                                                        |
| 3352 | 3351 | }  | 
                                                        
| 3353 | 3352 | |
| 3354 | 3353 | /*  | 
                                                        
@@ -3366,7 +3365,7 @@ discard block  | 
                                                    ||
| 3366 | 3365 | * @return mixed Valeur de la meta.  | 
                                                        
| 3367 | 3366 | **/  | 
                                                        
| 3368 | 3367 |  function lire_meta($nom) { | 
                                                        
| 3369 | - return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null;  | 
                                                        |
| 3368 | + return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null;  | 
                                                        |
| 3370 | 3369 | }  | 
                                                        
| 3371 | 3370 | |
| 3372 | 3371 | |
@@ -3388,128 +3387,128 @@ discard block  | 
                                                    ||
| 3388 | 3387 | * @param string $statut  | 
                                                        
| 3389 | 3388 | */  | 
                                                        
| 3390 | 3389 |  function avertir_auteurs($nom, $message, $statut = '') { | 
                                                        
| 3391 | - $alertes = $GLOBALS['meta']['message_alertes_auteurs'];  | 
                                                        |
| 3392 | - if (!$alertes  | 
                                                        |
| 3393 | - or !is_array($alertes = unserialize($alertes))  | 
                                                        |
| 3394 | -	) { | 
                                                        |
| 3395 | - $alertes = array();  | 
                                                        |
| 3396 | - }  | 
                                                        |
| 3390 | + $alertes = $GLOBALS['meta']['message_alertes_auteurs'];  | 
                                                        |
| 3391 | + if (!$alertes  | 
                                                        |
| 3392 | + or !is_array($alertes = unserialize($alertes))  | 
                                                        |
| 3393 | +    ) { | 
                                                        |
| 3394 | + $alertes = array();  | 
                                                        |
| 3395 | + }  | 
                                                        |
| 3397 | 3396 | |
| 3398 | -	if (!isset($alertes[$statut])) { | 
                                                        |
| 3399 | - $alertes[$statut] = array();  | 
                                                        |
| 3400 | - }  | 
                                                        |
| 3401 | - $alertes[$statut][$nom] = $message;  | 
                                                        |
| 3402 | -	ecrire_meta("message_alertes_auteurs", serialize($alertes)); | 
                                                        |
| 3397 | +    if (!isset($alertes[$statut])) { | 
                                                        |
| 3398 | + $alertes[$statut] = array();  | 
                                                        |
| 3399 | + }  | 
                                                        |
| 3400 | + $alertes[$statut][$nom] = $message;  | 
                                                        |
| 3401 | +    ecrire_meta("message_alertes_auteurs", serialize($alertes)); | 
                                                        |
| 3403 | 3402 | }  | 
                                                        
| 3404 | 3403 | |
| 3405 | 3404 |  if (PHP_VERSION_ID < 50500) { | 
                                                        
| 3406 | -	if (!function_exists('array_column')) { | 
                                                        |
| 3407 | - /**  | 
                                                        |
| 3408 | - * Returns the values from a single column of the input array, identified by  | 
                                                        |
| 3409 | - * the $columnKey.  | 
                                                        |
| 3410 | - *  | 
                                                        |
| 3411 | - * Optionally, you may provide an $indexKey to index the values in the returned  | 
                                                        |
| 3412 | - * array by the values from the $indexKey column in the input array.  | 
                                                        |
| 3413 | - *  | 
                                                        |
| 3414 | - * @link http://php.net/manual/fr/function.array-column.php  | 
                                                        |
| 3415 | - * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php  | 
                                                        |
| 3416 | - * @copyright Copyright (c) Ben Ramsey (http://benramsey.com)  | 
                                                        |
| 3417 | - * @license http://opensource.org/licenses/MIT MIT  | 
                                                        |
| 3418 | - *  | 
                                                        |
| 3419 | - * @param array $input A multi-dimensional array (record set) from which to pull  | 
                                                        |
| 3420 | - * a column of values.  | 
                                                        |
| 3421 | - * @param mixed $columnKey The column of values to return. This value may be the  | 
                                                        |
| 3422 | - * integer key of the column you wish to retrieve, or it  | 
                                                        |
| 3423 | - * may be the string key name for an associative array.  | 
                                                        |
| 3424 | - * @param mixed $indexKey (Optional.) The column to use as the index/keys for  | 
                                                        |
| 3425 | - * the returned array. This value may be the integer key  | 
                                                        |
| 3426 | - * of the column, or it may be the string key name.  | 
                                                        |
| 3427 | - * @return array  | 
                                                        |
| 3428 | - */  | 
                                                        |
| 3429 | - function array_column($input = null, $columnKey = null, $indexKey = null)  | 
                                                        |
| 3430 | -		{ | 
                                                        |
| 3431 | - // Using func_get_args() in order to check for proper number of  | 
                                                        |
| 3432 | - // parameters and trigger errors exactly as the built-in array_column()  | 
                                                        |
| 3433 | - // does in PHP 5.5.  | 
                                                        |
| 3434 | - $argc = func_num_args();  | 
                                                        |
| 3435 | - $params = func_get_args();  | 
                                                        |
| 3436 | -  | 
                                                        |
| 3437 | -			if ($argc < 2) { | 
                                                        |
| 3438 | -				trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); | 
                                                        |
| 3439 | - return null;  | 
                                                        |
| 3440 | - }  | 
                                                        |
| 3441 | -  | 
                                                        |
| 3442 | -			if (!is_array($params[0])) { | 
                                                        |
| 3443 | - trigger_error(  | 
                                                        |
| 3444 | - 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',  | 
                                                        |
| 3445 | - E_USER_WARNING  | 
                                                        |
| 3446 | - );  | 
                                                        |
| 3447 | - return null;  | 
                                                        |
| 3448 | - }  | 
                                                        |
| 3449 | -  | 
                                                        |
| 3450 | - if (!is_int($params[1])  | 
                                                        |
| 3451 | - && !is_float($params[1])  | 
                                                        |
| 3452 | - && !is_string($params[1])  | 
                                                        |
| 3453 | - && $params[1] !== null  | 
                                                        |
| 3454 | - && !(is_object($params[1]) && method_exists($params[1], '__toString'))  | 
                                                        |
| 3455 | -			) { | 
                                                        |
| 3456 | -				trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); | 
                                                        |
| 3457 | - return false;  | 
                                                        |
| 3458 | - }  | 
                                                        |
| 3459 | -  | 
                                                        |
| 3460 | - if (isset($params[2])  | 
                                                        |
| 3461 | - && !is_int($params[2])  | 
                                                        |
| 3462 | - && !is_float($params[2])  | 
                                                        |
| 3463 | - && !is_string($params[2])  | 
                                                        |
| 3464 | - && !(is_object($params[2]) && method_exists($params[2], '__toString'))  | 
                                                        |
| 3465 | -			) { | 
                                                        |
| 3466 | -				trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); | 
                                                        |
| 3467 | - return false;  | 
                                                        |
| 3468 | - }  | 
                                                        |
| 3469 | -  | 
                                                        |
| 3470 | - $paramsInput = $params[0];  | 
                                                        |
| 3471 | - $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;  | 
                                                        |
| 3472 | -  | 
                                                        |
| 3473 | - $paramsIndexKey = null;  | 
                                                        |
| 3474 | -			if (isset($params[2])) { | 
                                                        |
| 3475 | -				if (is_float($params[2]) || is_int($params[2])) { | 
                                                        |
| 3476 | - $paramsIndexKey = (int) $params[2];  | 
                                                        |
| 3477 | -				} else { | 
                                                        |
| 3478 | - $paramsIndexKey = (string) $params[2];  | 
                                                        |
| 3479 | - }  | 
                                                        |
| 3480 | - }  | 
                                                        |
| 3481 | -  | 
                                                        |
| 3482 | - $resultArray = array();  | 
                                                        |
| 3483 | -  | 
                                                        |
| 3484 | -			foreach ($paramsInput as $row) { | 
                                                        |
| 3485 | - $key = $value = null;  | 
                                                        |
| 3486 | - $keySet = $valueSet = false;  | 
                                                        |
| 3487 | -  | 
                                                        |
| 3488 | -				if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { | 
                                                        |
| 3489 | - $keySet = true;  | 
                                                        |
| 3490 | - $key = (string) $row[$paramsIndexKey];  | 
                                                        |
| 3491 | - }  | 
                                                        |
| 3492 | -  | 
                                                        |
| 3493 | -				if ($paramsColumnKey === null) { | 
                                                        |
| 3494 | - $valueSet = true;  | 
                                                        |
| 3495 | - $value = $row;  | 
                                                        |
| 3496 | -				} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { | 
                                                        |
| 3497 | - $valueSet = true;  | 
                                                        |
| 3498 | - $value = $row[$paramsColumnKey];  | 
                                                        |
| 3499 | - }  | 
                                                        |
| 3500 | -  | 
                                                        |
| 3501 | -				if ($valueSet) { | 
                                                        |
| 3502 | -					if ($keySet) { | 
                                                        |
| 3503 | - $resultArray[$key] = $value;  | 
                                                        |
| 3504 | -					} else { | 
                                                        |
| 3505 | - $resultArray[] = $value;  | 
                                                        |
| 3506 | - }  | 
                                                        |
| 3507 | - }  | 
                                                        |
| 3508 | -  | 
                                                        |
| 3509 | - }  | 
                                                        |
| 3510 | -  | 
                                                        |
| 3511 | - return $resultArray;  | 
                                                        |
| 3512 | - }  | 
                                                        |
| 3513 | -  | 
                                                        |
| 3514 | - }  | 
                                                        |
| 3405 | +    if (!function_exists('array_column')) { | 
                                                        |
| 3406 | + /**  | 
                                                        |
| 3407 | + * Returns the values from a single column of the input array, identified by  | 
                                                        |
| 3408 | + * the $columnKey.  | 
                                                        |
| 3409 | + *  | 
                                                        |
| 3410 | + * Optionally, you may provide an $indexKey to index the values in the returned  | 
                                                        |
| 3411 | + * array by the values from the $indexKey column in the input array.  | 
                                                        |
| 3412 | + *  | 
                                                        |
| 3413 | + * @link http://php.net/manual/fr/function.array-column.php  | 
                                                        |
| 3414 | + * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php  | 
                                                        |
| 3415 | + * @copyright Copyright (c) Ben Ramsey (http://benramsey.com)  | 
                                                        |
| 3416 | + * @license http://opensource.org/licenses/MIT MIT  | 
                                                        |
| 3417 | + *  | 
                                                        |
| 3418 | + * @param array $input A multi-dimensional array (record set) from which to pull  | 
                                                        |
| 3419 | + * a column of values.  | 
                                                        |
| 3420 | + * @param mixed $columnKey The column of values to return. This value may be the  | 
                                                        |
| 3421 | + * integer key of the column you wish to retrieve, or it  | 
                                                        |
| 3422 | + * may be the string key name for an associative array.  | 
                                                        |
| 3423 | + * @param mixed $indexKey (Optional.) The column to use as the index/keys for  | 
                                                        |
| 3424 | + * the returned array. This value may be the integer key  | 
                                                        |
| 3425 | + * of the column, or it may be the string key name.  | 
                                                        |
| 3426 | + * @return array  | 
                                                        |
| 3427 | + */  | 
                                                        |
| 3428 | + function array_column($input = null, $columnKey = null, $indexKey = null)  | 
                                                        |
| 3429 | +        { | 
                                                        |
| 3430 | + // Using func_get_args() in order to check for proper number of  | 
                                                        |
| 3431 | + // parameters and trigger errors exactly as the built-in array_column()  | 
                                                        |
| 3432 | + // does in PHP 5.5.  | 
                                                        |
| 3433 | + $argc = func_num_args();  | 
                                                        |
| 3434 | + $params = func_get_args();  | 
                                                        |
| 3435 | +  | 
                                                        |
| 3436 | +            if ($argc < 2) { | 
                                                        |
| 3437 | +                trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING); | 
                                                        |
| 3438 | + return null;  | 
                                                        |
| 3439 | + }  | 
                                                        |
| 3440 | +  | 
                                                        |
| 3441 | +            if (!is_array($params[0])) { | 
                                                        |
| 3442 | + trigger_error(  | 
                                                        |
| 3443 | + 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',  | 
                                                        |
| 3444 | + E_USER_WARNING  | 
                                                        |
| 3445 | + );  | 
                                                        |
| 3446 | + return null;  | 
                                                        |
| 3447 | + }  | 
                                                        |
| 3448 | +  | 
                                                        |
| 3449 | + if (!is_int($params[1])  | 
                                                        |
| 3450 | + && !is_float($params[1])  | 
                                                        |
| 3451 | + && !is_string($params[1])  | 
                                                        |
| 3452 | + && $params[1] !== null  | 
                                                        |
| 3453 | + && !(is_object($params[1]) && method_exists($params[1], '__toString'))  | 
                                                        |
| 3454 | +            ) { | 
                                                        |
| 3455 | +                trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); | 
                                                        |
| 3456 | + return false;  | 
                                                        |
| 3457 | + }  | 
                                                        |
| 3458 | +  | 
                                                        |
| 3459 | + if (isset($params[2])  | 
                                                        |
| 3460 | + && !is_int($params[2])  | 
                                                        |
| 3461 | + && !is_float($params[2])  | 
                                                        |
| 3462 | + && !is_string($params[2])  | 
                                                        |
| 3463 | + && !(is_object($params[2]) && method_exists($params[2], '__toString'))  | 
                                                        |
| 3464 | +            ) { | 
                                                        |
| 3465 | +                trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); | 
                                                        |
| 3466 | + return false;  | 
                                                        |
| 3467 | + }  | 
                                                        |
| 3468 | +  | 
                                                        |
| 3469 | + $paramsInput = $params[0];  | 
                                                        |
| 3470 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;  | 
                                                        |
| 3471 | +  | 
                                                        |
| 3472 | + $paramsIndexKey = null;  | 
                                                        |
| 3473 | +            if (isset($params[2])) { | 
                                                        |
| 3474 | +                if (is_float($params[2]) || is_int($params[2])) { | 
                                                        |
| 3475 | + $paramsIndexKey = (int) $params[2];  | 
                                                        |
| 3476 | +                } else { | 
                                                        |
| 3477 | + $paramsIndexKey = (string) $params[2];  | 
                                                        |
| 3478 | + }  | 
                                                        |
| 3479 | + }  | 
                                                        |
| 3480 | +  | 
                                                        |
| 3481 | + $resultArray = array();  | 
                                                        |
| 3482 | +  | 
                                                        |
| 3483 | +            foreach ($paramsInput as $row) { | 
                                                        |
| 3484 | + $key = $value = null;  | 
                                                        |
| 3485 | + $keySet = $valueSet = false;  | 
                                                        |
| 3486 | +  | 
                                                        |
| 3487 | +                if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { | 
                                                        |
| 3488 | + $keySet = true;  | 
                                                        |
| 3489 | + $key = (string) $row[$paramsIndexKey];  | 
                                                        |
| 3490 | + }  | 
                                                        |
| 3491 | +  | 
                                                        |
| 3492 | +                if ($paramsColumnKey === null) { | 
                                                        |
| 3493 | + $valueSet = true;  | 
                                                        |
| 3494 | + $value = $row;  | 
                                                        |
| 3495 | +                } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { | 
                                                        |
| 3496 | + $valueSet = true;  | 
                                                        |
| 3497 | + $value = $row[$paramsColumnKey];  | 
                                                        |
| 3498 | + }  | 
                                                        |
| 3499 | +  | 
                                                        |
| 3500 | +                if ($valueSet) { | 
                                                        |
| 3501 | +                    if ($keySet) { | 
                                                        |
| 3502 | + $resultArray[$key] = $value;  | 
                                                        |
| 3503 | +                    } else { | 
                                                        |
| 3504 | + $resultArray[] = $value;  | 
                                                        |
| 3505 | + }  | 
                                                        |
| 3506 | + }  | 
                                                        |
| 3507 | +  | 
                                                        |
| 3508 | + }  | 
                                                        |
| 3509 | +  | 
                                                        |
| 3510 | + return $resultArray;  | 
                                                        |
| 3511 | + }  | 
                                                        |
| 3512 | +  | 
                                                        |
| 3513 | + }  | 
                                                        |
| 3515 | 3514 | }  | 
                                                        
@@ -26,7 +26,7 @@ discard block  | 
                                                    ||
| 26 | 26 | **/  | 
                                                        
| 27 | 27 | |
| 28 | 28 |  if (!defined('_ECRIRE_INC_VERSION')) { | 
                                                        
| 29 | - return;  | 
                                                        |
| 29 | + return;  | 
                                                        |
| 30 | 30 | }  | 
                                                        
| 31 | 31 | |
| 32 | 32 | /**  | 
                                                        
@@ -48,14 +48,14 @@ discard block  | 
                                                    ||
| 48 | 48 | * Code PHP si cet argument est présent, sinon null  | 
                                                        
| 49 | 49 | **/  | 
                                                        
| 50 | 50 |  function interprete_argument_balise($n, $p) { | 
                                                        
| 51 | -	if (($p->param) && (!$p->param[0][0]) && (count($p->param[0]) > $n)) { | 
                                                        |
| 52 | - return calculer_liste($p->param[0][$n],  | 
                                                        |
| 53 | - $p->descr,  | 
                                                        |
| 54 | - $p->boucles,  | 
                                                        |
| 55 | - $p->id_boucle);  | 
                                                        |
| 56 | -	} else { | 
                                                        |
| 57 | - return null;  | 
                                                        |
| 58 | - }  | 
                                                        |
| 51 | +    if (($p->param) && (!$p->param[0][0]) && (count($p->param[0]) > $n)) { | 
                                                        |
| 52 | + return calculer_liste($p->param[0][$n],  | 
                                                        |
| 53 | + $p->descr,  | 
                                                        |
| 54 | + $p->boucles,  | 
                                                        |
| 55 | + $p->id_boucle);  | 
                                                        |
| 56 | +    } else { | 
                                                        |
| 57 | + return null;  | 
                                                        |
| 58 | + }  | 
                                                        |
| 59 | 59 | }  | 
                                                        
| 60 | 60 | |
| 61 | 61 | |
@@ -75,10 +75,10 @@ discard block  | 
                                                    ||
| 75 | 75 | * Pile complétée par le code à générer  | 
                                                        
| 76 | 76 | **/  | 
                                                        
| 77 | 77 |  function balise_NOM_SITE_SPIP_dist($p) { | 
                                                        
| 78 | - $p->code = "\$GLOBALS['meta']['nom_site']";  | 
                                                        |
| 78 | + $p->code = "\$GLOBALS['meta']['nom_site']";  | 
                                                        |
| 79 | 79 | |
| 80 | - #$p->interdire_scripts = true;  | 
                                                        |
| 81 | - return $p;  | 
                                                        |
| 80 | + #$p->interdire_scripts = true;  | 
                                                        |
| 81 | + return $p;  | 
                                                        |
| 82 | 82 | }  | 
                                                        
| 83 | 83 | |
| 84 | 84 | /**  | 
                                                        
@@ -94,10 +94,10 @@ discard block  | 
                                                    ||
| 94 | 94 | * Pile complétée par le code à générer  | 
                                                        
| 95 | 95 | **/  | 
                                                        
| 96 | 96 |  function balise_EMAIL_WEBMASTER_dist($p) { | 
                                                        
| 97 | - $p->code = "\$GLOBALS['meta']['email_webmaster']";  | 
                                                        |
| 97 | + $p->code = "\$GLOBALS['meta']['email_webmaster']";  | 
                                                        |
| 98 | 98 | |
| 99 | - #$p->interdire_scripts = true;  | 
                                                        |
| 100 | - return $p;  | 
                                                        |
| 99 | + #$p->interdire_scripts = true;  | 
                                                        |
| 100 | + return $p;  | 
                                                        |
| 101 | 101 | }  | 
                                                        
| 102 | 102 | |
| 103 | 103 | /**  | 
                                                        
@@ -113,10 +113,10 @@ discard block  | 
                                                    ||
| 113 | 113 | * Pile complétée par le code à générer  | 
                                                        
| 114 | 114 | **/  | 
                                                        
| 115 | 115 |  function balise_DESCRIPTIF_SITE_SPIP_dist($p) { | 
                                                        
| 116 | - $p->code = "\$GLOBALS['meta']['descriptif_site']";  | 
                                                        |
| 116 | + $p->code = "\$GLOBALS['meta']['descriptif_site']";  | 
                                                        |
| 117 | 117 | |
| 118 | - #$p->interdire_scripts = true;  | 
                                                        |
| 119 | - return $p;  | 
                                                        |
| 118 | + #$p->interdire_scripts = true;  | 
                                                        |
| 119 | + return $p;  | 
                                                        |
| 120 | 120 | }  | 
                                                        
| 121 | 121 | |
| 122 | 122 | |
@@ -137,10 +137,10 @@ discard block  | 
                                                    ||
| 137 | 137 | * Pile complétée par le code à générer  | 
                                                        
| 138 | 138 | **/  | 
                                                        
| 139 | 139 |  function balise_CHARSET_dist($p) { | 
                                                        
| 140 | - $p->code = "\$GLOBALS['meta']['charset']";  | 
                                                        |
| 140 | + $p->code = "\$GLOBALS['meta']['charset']";  | 
                                                        |
| 141 | 141 | |
| 142 | - #$p->interdire_scripts = true;  | 
                                                        |
| 143 | - return $p;  | 
                                                        |
| 142 | + #$p->interdire_scripts = true;  | 
                                                        |
| 143 | + return $p;  | 
                                                        |
| 144 | 144 | }  | 
                                                        
| 145 | 145 | |
| 146 | 146 | /**  | 
                                                        
@@ -165,11 +165,11 @@ discard block  | 
                                                    ||
| 165 | 165 | * Pile complétée par le code à générer  | 
                                                        
| 166 | 166 | **/  | 
                                                        
| 167 | 167 |  function balise_LANG_LEFT_dist($p) { | 
                                                        
| 168 | -	$_lang = champ_sql('lang', $p); | 
                                                        |
| 169 | - $p->code = "lang_dir($_lang, 'left','right')";  | 
                                                        |
| 170 | - $p->interdire_scripts = false;  | 
                                                        |
| 168 | +    $_lang = champ_sql('lang', $p); | 
                                                        |
| 169 | + $p->code = "lang_dir($_lang, 'left','right')";  | 
                                                        |
| 170 | + $p->interdire_scripts = false;  | 
                                                        |
| 171 | 171 | |
| 172 | - return $p;  | 
                                                        |
| 172 | + return $p;  | 
                                                        |
| 173 | 173 | }  | 
                                                        
| 174 | 174 | |
| 175 | 175 | /**  | 
                                                        
@@ -189,11 +189,11 @@ discard block  | 
                                                    ||
| 189 | 189 | * Pile complétée par le code à générer  | 
                                                        
| 190 | 190 | **/  | 
                                                        
| 191 | 191 |  function balise_LANG_RIGHT_dist($p) { | 
                                                        
| 192 | -	$_lang = champ_sql('lang', $p); | 
                                                        |
| 193 | - $p->code = "lang_dir($_lang, 'right','left')";  | 
                                                        |
| 194 | - $p->interdire_scripts = false;  | 
                                                        |
| 192 | +    $_lang = champ_sql('lang', $p); | 
                                                        |
| 193 | + $p->code = "lang_dir($_lang, 'right','left')";  | 
                                                        |
| 194 | + $p->interdire_scripts = false;  | 
                                                        |
| 195 | 195 | |
| 196 | - return $p;  | 
                                                        |
| 196 | + return $p;  | 
                                                        |
| 197 | 197 | }  | 
                                                        
| 198 | 198 | |
| 199 | 199 | /**  | 
                                                        
@@ -218,11 +218,11 @@ discard block  | 
                                                    ||
| 218 | 218 | * Pile complétée par le code à générer  | 
                                                        
| 219 | 219 | **/  | 
                                                        
| 220 | 220 |  function balise_LANG_DIR_dist($p) { | 
                                                        
| 221 | -	$_lang = champ_sql('lang', $p); | 
                                                        |
| 222 | - $p->code = "lang_dir($_lang, 'ltr','rtl')";  | 
                                                        |
| 223 | - $p->interdire_scripts = false;  | 
                                                        |
| 221 | +    $_lang = champ_sql('lang', $p); | 
                                                        |
| 222 | + $p->code = "lang_dir($_lang, 'ltr','rtl')";  | 
                                                        |
| 223 | + $p->interdire_scripts = false;  | 
                                                        |
| 224 | 224 | |
| 225 | - return $p;  | 
                                                        |
| 225 | + return $p;  | 
                                                        |
| 226 | 226 | }  | 
                                                        
| 227 | 227 | |
| 228 | 228 | |
@@ -239,10 +239,10 @@ discard block  | 
                                                    ||
| 239 | 239 | * Pile complétée par le code à générer  | 
                                                        
| 240 | 240 | **/  | 
                                                        
| 241 | 241 |  function balise_PUCE_dist($p) { | 
                                                        
| 242 | - $p->code = "definir_puce()";  | 
                                                        |
| 243 | - $p->interdire_scripts = false;  | 
                                                        |
| 242 | + $p->code = "definir_puce()";  | 
                                                        |
| 243 | + $p->interdire_scripts = false;  | 
                                                        |
| 244 | 244 | |
| 245 | - return $p;  | 
                                                        |
| 245 | + return $p;  | 
                                                        |
| 246 | 246 | }  | 
                                                        
| 247 | 247 | |
| 248 | 248 | |
@@ -266,12 +266,12 @@ discard block  | 
                                                    ||
| 266 | 266 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 267 | 267 | */  | 
                                                        
| 268 | 268 |  function balise_DATE_dist($p) { | 
                                                        
| 269 | -	$d = champ_sql('date', $p); | 
                                                        |
| 269 | +    $d = champ_sql('date', $p); | 
                                                        |
| 270 | 270 | # if ($d === "@\$Pile[0]['date']")  | 
                                                        
| 271 | 271 | # $d = "isset(\$Pile[0]['date']) ? $d : time()";  | 
                                                        
| 272 | - $p->code = $d;  | 
                                                        |
| 272 | + $p->code = $d;  | 
                                                        |
| 273 | 273 | |
| 274 | - return $p;  | 
                                                        |
| 274 | + return $p;  | 
                                                        |
| 275 | 275 | }  | 
                                                        
| 276 | 276 | |
| 277 | 277 | |
@@ -291,13 +291,13 @@ discard block  | 
                                                    ||
| 291 | 291 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 292 | 292 | */  | 
                                                        
| 293 | 293 |  function balise_DATE_REDAC_dist($p) { | 
                                                        
| 294 | -	$d = champ_sql('date_redac', $p); | 
                                                        |
| 294 | +    $d = champ_sql('date_redac', $p); | 
                                                        |
| 295 | 295 | # if ($d === "@\$Pile[0]['date_redac']")  | 
                                                        
| 296 | 296 | # $d = "isset(\$Pile[0]['date_redac']) ? $d : time()";  | 
                                                        
| 297 | - $p->code = $d;  | 
                                                        |
| 298 | - $p->interdire_scripts = false;  | 
                                                        |
| 297 | + $p->code = $d;  | 
                                                        |
| 298 | + $p->interdire_scripts = false;  | 
                                                        |
| 299 | 299 | |
| 300 | - return $p;  | 
                                                        |
| 300 | + return $p;  | 
                                                        |
| 301 | 301 | }  | 
                                                        
| 302 | 302 | |
| 303 | 303 | /**  | 
                                                        
@@ -316,10 +316,10 @@ discard block  | 
                                                    ||
| 316 | 316 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 317 | 317 | */  | 
                                                        
| 318 | 318 |  function balise_DATE_MODIF_dist($p) { | 
                                                        
| 319 | -	$p->code = champ_sql('date_modif', $p); | 
                                                        |
| 320 | - $p->interdire_scripts = false;  | 
                                                        |
| 319 | +    $p->code = champ_sql('date_modif', $p); | 
                                                        |
| 320 | + $p->interdire_scripts = false;  | 
                                                        |
| 321 | 321 | |
| 322 | - return $p;  | 
                                                        |
| 322 | + return $p;  | 
                                                        |
| 323 | 323 | }  | 
                                                        
| 324 | 324 | |
| 325 | 325 | /**  | 
                                                        
@@ -337,13 +337,13 @@ discard block  | 
                                                    ||
| 337 | 337 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 338 | 338 | */  | 
                                                        
| 339 | 339 |  function balise_DATE_NOUVEAUTES_dist($p) { | 
                                                        
| 340 | - $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui'  | 
                                                        |
| 340 | + $p->code = "((\$GLOBALS['meta']['quoi_de_neuf'] == 'oui'  | 
                                                        |
| 341 | 341 | AND isset(\$GLOBALS['meta']['dernier_envoi_neuf'])) ?  | 
                                                        
| 342 | 342 | \$GLOBALS['meta']['dernier_envoi_neuf'] :  | 
                                                        
| 343 | 343 | \"'0000-00-00'\")";  | 
                                                        
| 344 | - $p->interdire_scripts = false;  | 
                                                        |
| 344 | + $p->interdire_scripts = false;  | 
                                                        |
| 345 | 345 | |
| 346 | - return $p;  | 
                                                        |
| 346 | + return $p;  | 
                                                        |
| 347 | 347 | }  | 
                                                        
| 348 | 348 | |
| 349 | 349 | |
@@ -362,11 +362,11 @@ discard block  | 
                                                    ||
| 362 | 362 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 363 | 363 | */  | 
                                                        
| 364 | 364 |  function balise_DOSSIER_SQUELETTE_dist($p) { | 
                                                        
| 365 | - $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE));  | 
                                                        |
| 366 | - $p->code = "_DIR_RACINE . '$code'" .  | 
                                                        |
| 367 | - $p->interdire_scripts = false;  | 
                                                        |
| 365 | + $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE));  | 
                                                        |
| 366 | + $p->code = "_DIR_RACINE . '$code'" .  | 
                                                        |
| 367 | + $p->interdire_scripts = false;  | 
                                                        |
| 368 | 368 | |
| 369 | - return $p;  | 
                                                        |
| 369 | + return $p;  | 
                                                        |
| 370 | 370 | }  | 
                                                        
| 371 | 371 | |
| 372 | 372 | /**  | 
                                                        
@@ -381,11 +381,11 @@ discard block  | 
                                                    ||
| 381 | 381 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 382 | 382 | */  | 
                                                        
| 383 | 383 |  function balise_SQUELETTE_dist($p) { | 
                                                        
| 384 | - $code = addslashes($p->descr['sourcefile']);  | 
                                                        |
| 385 | - $p->code = "'$code'" .  | 
                                                        |
| 386 | - $p->interdire_scripts = false;  | 
                                                        |
| 384 | + $code = addslashes($p->descr['sourcefile']);  | 
                                                        |
| 385 | + $p->code = "'$code'" .  | 
                                                        |
| 386 | + $p->interdire_scripts = false;  | 
                                                        |
| 387 | 387 | |
| 388 | - return $p;  | 
                                                        |
| 388 | + return $p;  | 
                                                        |
| 389 | 389 | }  | 
                                                        
| 390 | 390 | |
| 391 | 391 | /**  | 
                                                        
@@ -404,10 +404,10 @@ discard block  | 
                                                    ||
| 404 | 404 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 405 | 405 | */  | 
                                                        
| 406 | 406 |  function balise_SPIP_VERSION_dist($p) { | 
                                                        
| 407 | - $p->code = "spip_version()";  | 
                                                        |
| 408 | - $p->interdire_scripts = false;  | 
                                                        |
| 407 | + $p->code = "spip_version()";  | 
                                                        |
| 408 | + $p->interdire_scripts = false;  | 
                                                        |
| 409 | 409 | |
| 410 | - return $p;  | 
                                                        |
| 410 | + return $p;  | 
                                                        |
| 411 | 411 | }  | 
                                                        
| 412 | 412 | |
| 413 | 413 | |
@@ -433,18 +433,18 @@ discard block  | 
                                                    ||
| 433 | 433 | * Pile complétée par le code à générer  | 
                                                        
| 434 | 434 | **/  | 
                                                        
| 435 | 435 |  function balise_NOM_SITE_dist($p) { | 
                                                        
| 436 | -	if (!$p->etoile) { | 
                                                        |
| 437 | -		$p->code = "supprimer_numero(calculer_url(" . | 
                                                        |
| 438 | -			champ_sql('url_site', $p) . "," . | 
                                                        |
| 439 | -			champ_sql('nom_site', $p) . | 
                                                        |
| 440 | - ", 'titre', \$connect, false))";  | 
                                                        |
| 441 | -	} else { | 
                                                        |
| 442 | -		$p->code = champ_sql('nom_site', $p); | 
                                                        |
| 443 | - }  | 
                                                        |
| 436 | +    if (!$p->etoile) { | 
                                                        |
| 437 | +        $p->code = "supprimer_numero(calculer_url(" . | 
                                                        |
| 438 | +            champ_sql('url_site', $p) . "," . | 
                                                        |
| 439 | +            champ_sql('nom_site', $p) . | 
                                                        |
| 440 | + ", 'titre', \$connect, false))";  | 
                                                        |
| 441 | +    } else { | 
                                                        |
| 442 | +        $p->code = champ_sql('nom_site', $p); | 
                                                        |
| 443 | + }  | 
                                                        |
| 444 | 444 | |
| 445 | - $p->interdire_scripts = true;  | 
                                                        |
| 445 | + $p->interdire_scripts = true;  | 
                                                        |
| 446 | 446 | |
| 447 | - return $p;  | 
                                                        |
| 447 | + return $p;  | 
                                                        |
| 448 | 448 | }  | 
                                                        
| 449 | 449 | |
| 450 | 450 | |
@@ -461,11 +461,11 @@ discard block  | 
                                                    ||
| 461 | 461 | * Pile complétée par le code à générer  | 
                                                        
| 462 | 462 | **/  | 
                                                        
| 463 | 463 |  function balise_NOTES_dist($p) { | 
                                                        
| 464 | - // Recuperer les notes  | 
                                                        |
| 465 | - $p->code = 'calculer_notes()';  | 
                                                        |
| 464 | + // Recuperer les notes  | 
                                                        |
| 465 | + $p->code = 'calculer_notes()';  | 
                                                        |
| 466 | 466 | |
| 467 | - #$p->interdire_scripts = true;  | 
                                                        |
| 468 | - return $p;  | 
                                                        |
| 467 | + #$p->interdire_scripts = true;  | 
                                                        |
| 468 | + return $p;  | 
                                                        |
| 469 | 469 | }  | 
                                                        
| 470 | 470 | |
| 471 | 471 | |
@@ -487,10 +487,10 @@ discard block  | 
                                                    ||
| 487 | 487 | * Pile complétée par le code à générer  | 
                                                        
| 488 | 488 | **/  | 
                                                        
| 489 | 489 |  function balise_RECHERCHE_dist($p) { | 
                                                        
| 490 | -	$p->code = 'entites_html(_request("recherche"))'; | 
                                                        |
| 491 | - $p->interdire_scripts = false;  | 
                                                        |
| 490 | +    $p->code = 'entites_html(_request("recherche"))'; | 
                                                        |
| 491 | + $p->interdire_scripts = false;  | 
                                                        |
| 492 | 492 | |
| 493 | - return $p;  | 
                                                        |
| 493 | + return $p;  | 
                                                        |
| 494 | 494 | }  | 
                                                        
| 495 | 495 | |
| 496 | 496 | |
@@ -508,20 +508,20 @@ discard block  | 
                                                    ||
| 508 | 508 | * Pile complétée par le code à générer  | 
                                                        
| 509 | 509 | **/  | 
                                                        
| 510 | 510 |  function balise_COMPTEUR_BOUCLE_dist($p) { | 
                                                        
| 511 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];  | 
                                                        |
| 512 | -	if ($b === '') { | 
                                                        |
| 513 | - $msg = array(  | 
                                                        |
| 514 | - 'zbug_champ_hors_boucle',  | 
                                                        |
| 515 | -			array('champ' => '#COMPTEUR_BOUCLE') | 
                                                        |
| 516 | - );  | 
                                                        |
| 517 | - erreur_squelette($msg, $p);  | 
                                                        |
| 518 | -	} else { | 
                                                        |
| 519 | - $p->code = "\$Numrows['$b']['compteur_boucle']";  | 
                                                        |
| 520 | - $p->boucles[$b]->cptrows = true;  | 
                                                        |
| 521 | - $p->interdire_scripts = false;  | 
                                                        |
| 511 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];  | 
                                                        |
| 512 | +    if ($b === '') { | 
                                                        |
| 513 | + $msg = array(  | 
                                                        |
| 514 | + 'zbug_champ_hors_boucle',  | 
                                                        |
| 515 | +            array('champ' => '#COMPTEUR_BOUCLE') | 
                                                        |
| 516 | + );  | 
                                                        |
| 517 | + erreur_squelette($msg, $p);  | 
                                                        |
| 518 | +    } else { | 
                                                        |
| 519 | + $p->code = "\$Numrows['$b']['compteur_boucle']";  | 
                                                        |
| 520 | + $p->boucles[$b]->cptrows = true;  | 
                                                        |
| 521 | + $p->interdire_scripts = false;  | 
                                                        |
| 522 | 522 | |
| 523 | - return $p;  | 
                                                        |
| 524 | - }  | 
                                                        |
| 523 | + return $p;  | 
                                                        |
| 524 | + }  | 
                                                        |
| 525 | 525 | }  | 
                                                        
| 526 | 526 | |
| 527 | 527 | /**  | 
                                                        
@@ -539,20 +539,20 @@ discard block  | 
                                                    ||
| 539 | 539 | * Pile complétée par le code à générer  | 
                                                        
| 540 | 540 | **/  | 
                                                        
| 541 | 541 |  function balise_TOTAL_BOUCLE_dist($p) { | 
                                                        
| 542 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];  | 
                                                        |
| 543 | -	if ($b === '' || !isset($p->boucles[$b])) { | 
                                                        |
| 544 | - $msg = array(  | 
                                                        |
| 545 | - 'zbug_champ_hors_boucle',  | 
                                                        |
| 546 | -			array('champ' => "#$b" . 'TOTAL_BOUCLE') | 
                                                        |
| 547 | - );  | 
                                                        |
| 548 | - erreur_squelette($msg, $p);  | 
                                                        |
| 549 | -	} else { | 
                                                        |
| 550 | - $p->code = "\$Numrows['$b']['total']";  | 
                                                        |
| 551 | - $p->boucles[$b]->numrows = true;  | 
                                                        |
| 552 | - $p->interdire_scripts = false;  | 
                                                        |
| 553 | - }  | 
                                                        |
| 542 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];  | 
                                                        |
| 543 | +    if ($b === '' || !isset($p->boucles[$b])) { | 
                                                        |
| 544 | + $msg = array(  | 
                                                        |
| 545 | + 'zbug_champ_hors_boucle',  | 
                                                        |
| 546 | +            array('champ' => "#$b" . 'TOTAL_BOUCLE') | 
                                                        |
| 547 | + );  | 
                                                        |
| 548 | + erreur_squelette($msg, $p);  | 
                                                        |
| 549 | +    } else { | 
                                                        |
| 550 | + $p->code = "\$Numrows['$b']['total']";  | 
                                                        |
| 551 | + $p->boucles[$b]->numrows = true;  | 
                                                        |
| 552 | + $p->interdire_scripts = false;  | 
                                                        |
| 553 | + }  | 
                                                        |
| 554 | 554 | |
| 555 | - return $p;  | 
                                                        |
| 555 | + return $p;  | 
                                                        |
| 556 | 556 | }  | 
                                                        
| 557 | 557 | |
| 558 | 558 | |
@@ -572,7 +572,7 @@ discard block  | 
                                                    ||
| 572 | 572 | * Pile complétée par le code à générer  | 
                                                        
| 573 | 573 | **/  | 
                                                        
| 574 | 574 |  function balise_POINTS_dist($p) { | 
                                                        
| 575 | - return rindex_pile($p, 'points', 'recherche');  | 
                                                        |
| 575 | + return rindex_pile($p, 'points', 'recherche');  | 
                                                        |
| 576 | 576 | }  | 
                                                        
| 577 | 577 | |
| 578 | 578 | |
@@ -593,12 +593,12 @@ discard block  | 
                                                    ||
| 593 | 593 | * Pile complétée par le code à générer  | 
                                                        
| 594 | 594 | **/  | 
                                                        
| 595 | 595 |  function balise_POPULARITE_ABSOLUE_dist($p) { | 
                                                        
| 596 | -	$p->code = 'ceil(' . | 
                                                        |
| 597 | -		champ_sql('popularite', $p) . | 
                                                        |
| 598 | - ')';  | 
                                                        |
| 599 | - $p->interdire_scripts = false;  | 
                                                        |
| 596 | +    $p->code = 'ceil(' . | 
                                                        |
| 597 | +        champ_sql('popularite', $p) . | 
                                                        |
| 598 | + ')';  | 
                                                        |
| 599 | + $p->interdire_scripts = false;  | 
                                                        |
| 600 | 600 | |
| 601 | - return $p;  | 
                                                        |
| 601 | + return $p;  | 
                                                        |
| 602 | 602 | }  | 
                                                        
| 603 | 603 | |
| 604 | 604 | /**  | 
                                                        
@@ -618,10 +618,10 @@ discard block  | 
                                                    ||
| 618 | 618 | * Pile complétée par le code à générer  | 
                                                        
| 619 | 619 | **/  | 
                                                        
| 620 | 620 |  function balise_POPULARITE_SITE_dist($p) { | 
                                                        
| 621 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])';  | 
                                                        |
| 622 | - $p->interdire_scripts = false;  | 
                                                        |
| 621 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_total\'])';  | 
                                                        |
| 622 | + $p->interdire_scripts = false;  | 
                                                        |
| 623 | 623 | |
| 624 | - return $p;  | 
                                                        |
| 624 | + return $p;  | 
                                                        |
| 625 | 625 | }  | 
                                                        
| 626 | 626 | |
| 627 | 627 | /**  | 
                                                        
@@ -642,10 +642,10 @@ discard block  | 
                                                    ||
| 642 | 642 | * Pile complétée par le code à générer  | 
                                                        
| 643 | 643 | **/  | 
                                                        
| 644 | 644 |  function balise_POPULARITE_MAX_dist($p) { | 
                                                        
| 645 | - $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])';  | 
                                                        |
| 646 | - $p->interdire_scripts = false;  | 
                                                        |
| 645 | + $p->code = 'ceil($GLOBALS["meta"][\'popularite_max\'])';  | 
                                                        |
| 646 | + $p->interdire_scripts = false;  | 
                                                        |
| 647 | 647 | |
| 648 | - return $p;  | 
                                                        |
| 648 | + return $p;  | 
                                                        |
| 649 | 649 | }  | 
                                                        
| 650 | 650 | |
| 651 | 651 | |
@@ -671,14 +671,14 @@ discard block  | 
                                                    ||
| 671 | 671 | * Pile complétée par le code à générer  | 
                                                        
| 672 | 672 | **/  | 
                                                        
| 673 | 673 |  function balise_VALEUR_dist($p) { | 
                                                        
| 674 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;  | 
                                                        |
| 675 | - $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);;  | 
                                                        |
| 676 | -	if (($v = interprete_argument_balise(1, $p)) !== null) { | 
                                                        |
| 677 | -		$p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; | 
                                                        |
| 678 | - }  | 
                                                        |
| 679 | - $p->interdire_scripts = true;  | 
                                                        |
| 674 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;  | 
                                                        |
| 675 | + $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);;  | 
                                                        |
| 676 | +    if (($v = interprete_argument_balise(1, $p)) !== null) { | 
                                                        |
| 677 | +        $p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; | 
                                                        |
| 678 | + }  | 
                                                        |
| 679 | + $p->interdire_scripts = true;  | 
                                                        |
| 680 | 680 | |
| 681 | - return $p;  | 
                                                        |
| 681 | + return $p;  | 
                                                        |
| 682 | 682 | }  | 
                                                        
| 683 | 683 | |
| 684 | 684 | /**  | 
                                                        
@@ -707,17 +707,17 @@ discard block  | 
                                                    ||
| 707 | 707 | * Pile complétée par le code à générer  | 
                                                        
| 708 | 708 | **/  | 
                                                        
| 709 | 709 |  function balise_EXPOSE_dist($p) { | 
                                                        
| 710 | - $on = "'on'";  | 
                                                        |
| 711 | - $off = "''";  | 
                                                        |
| 712 | -	if (($v = interprete_argument_balise(1, $p)) !== null) { | 
                                                        |
| 713 | - $on = $v;  | 
                                                        |
| 714 | -		if (($v = interprete_argument_balise(2, $p)) !== null) { | 
                                                        |
| 715 | - $off = $v;  | 
                                                        |
| 716 | - }  | 
                                                        |
| 710 | + $on = "'on'";  | 
                                                        |
| 711 | + $off = "''";  | 
                                                        |
| 712 | +    if (($v = interprete_argument_balise(1, $p)) !== null) { | 
                                                        |
| 713 | + $on = $v;  | 
                                                        |
| 714 | +        if (($v = interprete_argument_balise(2, $p)) !== null) { | 
                                                        |
| 715 | + $off = $v;  | 
                                                        |
| 716 | + }  | 
                                                        |
| 717 | 717 | |
| 718 | - }  | 
                                                        |
| 718 | + }  | 
                                                        |
| 719 | 719 | |
| 720 | - return calculer_balise_expose($p, $on, $off);  | 
                                                        |
| 720 | + return calculer_balise_expose($p, $on, $off);  | 
                                                        |
| 721 | 721 | }  | 
                                                        
| 722 | 722 | |
| 723 | 723 | /**  | 
                                                        
@@ -735,36 +735,36 @@ discard block  | 
                                                    ||
| 735 | 735 | * Pile complétée par le code à générer  | 
                                                        
| 736 | 736 | **/  | 
                                                        
| 737 | 737 |  function calculer_balise_expose($p, $on, $off) { | 
                                                        
| 738 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;  | 
                                                        |
| 739 | -	if (empty($p->boucles[$b]->primary)) { | 
                                                        |
| 740 | -		$msg = array('zbug_champ_hors_boucle', array('champ' => '#EXPOSER')); | 
                                                        |
| 741 | - erreur_squelette($msg, $p);  | 
                                                        |
| 742 | -	} else { | 
                                                        |
| 738 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;  | 
                                                        |
| 739 | +    if (empty($p->boucles[$b]->primary)) { | 
                                                        |
| 740 | +        $msg = array('zbug_champ_hors_boucle', array('champ' => '#EXPOSER')); | 
                                                        |
| 741 | + erreur_squelette($msg, $p);  | 
                                                        |
| 742 | +    } else { | 
                                                        |
| 743 | 743 | |
| 744 | - $key = $p->boucles[$b]->primary;  | 
                                                        |
| 745 | - $type = $p->boucles[$p->id_boucle]->primary;  | 
                                                        |
| 746 | - $desc = $p->boucles[$b]->show;  | 
                                                        |
| 747 | - $connect = sql_quote($p->boucles[$b]->sql_serveur);  | 
                                                        |
| 744 | + $key = $p->boucles[$b]->primary;  | 
                                                        |
| 745 | + $type = $p->boucles[$p->id_boucle]->primary;  | 
                                                        |
| 746 | + $desc = $p->boucles[$b]->show;  | 
                                                        |
| 747 | + $connect = sql_quote($p->boucles[$b]->sql_serveur);  | 
                                                        |
| 748 | 748 | |
| 749 | - // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite  | 
                                                        |
| 750 | - $c = index_pile($p->id_boucle, $type, $p->boucles);  | 
                                                        |
| 749 | + // Ne pas utiliser champ_sql, on jongle avec le nom boucle explicite  | 
                                                        |
| 750 | + $c = index_pile($p->id_boucle, $type, $p->boucles);  | 
                                                        |
| 751 | 751 | |
| 752 | -		if (isset($desc['field']['id_parent'])) { | 
                                                        |
| 753 | - $parent = 0; // pour if (!$parent) dans calculer_expose  | 
                                                        |
| 754 | -		} elseif (isset($desc['field']['id_rubrique'])) { | 
                                                        |
| 755 | - $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b);  | 
                                                        |
| 756 | -		} elseif (isset($desc['field']['id_groupe'])) { | 
                                                        |
| 757 | - $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b);  | 
                                                        |
| 758 | -		} else { | 
                                                        |
| 759 | - $parent = "''";  | 
                                                        |
| 760 | - }  | 
                                                        |
| 752 | +        if (isset($desc['field']['id_parent'])) { | 
                                                        |
| 753 | + $parent = 0; // pour if (!$parent) dans calculer_expose  | 
                                                        |
| 754 | +        } elseif (isset($desc['field']['id_rubrique'])) { | 
                                                        |
| 755 | + $parent = index_pile($p->id_boucle, 'id_rubrique', $p->boucles, $b);  | 
                                                        |
| 756 | +        } elseif (isset($desc['field']['id_groupe'])) { | 
                                                        |
| 757 | + $parent = index_pile($p->id_boucle, 'id_groupe', $p->boucles, $b);  | 
                                                        |
| 758 | +        } else { | 
                                                        |
| 759 | + $parent = "''";  | 
                                                        |
| 760 | + }  | 
                                                        |
| 761 | 761 | |
| 762 | - $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)";  | 
                                                        |
| 763 | - }  | 
                                                        |
| 762 | + $p->code = "(calcul_exposer($c, '$type', \$Pile[0], $parent, '$key', $connect) ? $on : $off)";  | 
                                                        |
| 763 | + }  | 
                                                        |
| 764 | 764 | |
| 765 | - $p->interdire_scripts = false;  | 
                                                        |
| 765 | + $p->interdire_scripts = false;  | 
                                                        |
| 766 | 766 | |
| 767 | - return $p;  | 
                                                        |
| 767 | + return $p;  | 
                                                        |
| 768 | 768 | }  | 
                                                        
| 769 | 769 | |
| 770 | 770 | |
@@ -802,47 +802,47 @@ discard block  | 
                                                    ||
| 802 | 802 | **/  | 
                                                        
| 803 | 803 |  function balise_INTRODUCTION_dist($p) { | 
                                                        
| 804 | 804 | |
| 805 | - $type = $p->type_requete;  | 
                                                        |
| 806 | -  | 
                                                        |
| 807 | -	$_texte = champ_sql('texte', $p); | 
                                                        |
| 808 | -	$trouver_table = charger_fonction('trouver_table', 'base'); | 
                                                        |
| 809 | - $desc = $trouver_table(table_objet_sql($type));  | 
                                                        |
| 810 | - $_descriptif = "''";  | 
                                                        |
| 811 | -	if ($desc and isset($desc['field']['descriptif'])) { | 
                                                        |
| 812 | - // notamment articles et rubriques mais aussi tout nouvel objet concerne  | 
                                                        |
| 813 | -		$_descriptif = champ_sql('descriptif', $p); | 
                                                        |
| 814 | - }  | 
                                                        |
| 815 | -  | 
                                                        |
| 816 | - // notamment les articles mais aussi tout nouvel objet concerne  | 
                                                        |
| 817 | -	if ($desc and isset($desc['field']['chapo'])) { | 
                                                        |
| 818 | -		$_chapo = champ_sql('chapo', $p); | 
                                                        |
| 819 | - $_texte = "(strlen($_descriptif))  | 
                                                        |
| 805 | + $type = $p->type_requete;  | 
                                                        |
| 806 | +  | 
                                                        |
| 807 | +    $_texte = champ_sql('texte', $p); | 
                                                        |
| 808 | +    $trouver_table = charger_fonction('trouver_table', 'base'); | 
                                                        |
| 809 | + $desc = $trouver_table(table_objet_sql($type));  | 
                                                        |
| 810 | + $_descriptif = "''";  | 
                                                        |
| 811 | +    if ($desc and isset($desc['field']['descriptif'])) { | 
                                                        |
| 812 | + // notamment articles et rubriques mais aussi tout nouvel objet concerne  | 
                                                        |
| 813 | +        $_descriptif = champ_sql('descriptif', $p); | 
                                                        |
| 814 | + }  | 
                                                        |
| 815 | +  | 
                                                        |
| 816 | + // notamment les articles mais aussi tout nouvel objet concerne  | 
                                                        |
| 817 | +    if ($desc and isset($desc['field']['chapo'])) { | 
                                                        |
| 818 | +        $_chapo = champ_sql('chapo', $p); | 
                                                        |
| 819 | + $_texte = "(strlen($_descriptif))  | 
                                                        |
| 820 | 820 | ? ''  | 
                                                        
| 821 | 821 | : $_chapo . \"\\n\\n\" . $_texte";  | 
                                                        
| 822 | - }  | 
                                                        |
| 822 | + }  | 
                                                        |
| 823 | 823 | |
| 824 | - // longueur en parametre, ou valeur par defaut  | 
                                                        |
| 825 | - $longueur_defaut = objet_info($type, 'introduction_longueur');  | 
                                                        |
| 826 | -	if (!$longueur_defaut) { | 
                                                        |
| 827 | - $longueur_defaut = 600;  | 
                                                        |
| 828 | - }  | 
                                                        |
| 824 | + // longueur en parametre, ou valeur par defaut  | 
                                                        |
| 825 | + $longueur_defaut = objet_info($type, 'introduction_longueur');  | 
                                                        |
| 826 | +    if (!$longueur_defaut) { | 
                                                        |
| 827 | + $longueur_defaut = 600;  | 
                                                        |
| 828 | + }  | 
                                                        |
| 829 | 829 | |
| 830 | - $_suite = 'null';  | 
                                                        |
| 831 | - $_longueur = $longueur_defaut;  | 
                                                        |
| 832 | -	if (($v = interprete_argument_balise(1, $p)) !== null) { | 
                                                        |
| 833 | -		$_longueur = 'is_numeric(' . $v . ')?intval(' . $v . '):' . $longueur_defaut; | 
                                                        |
| 834 | -		$_suite = '!is_numeric(' . $v . ')?' . $v . ':null'; | 
                                                        |
| 835 | - }  | 
                                                        |
| 836 | -	if (($v2 = interprete_argument_balise(2, $p)) !== null) { | 
                                                        |
| 837 | - $_suite = $v2;  | 
                                                        |
| 838 | - }  | 
                                                        |
| 830 | + $_suite = 'null';  | 
                                                        |
| 831 | + $_longueur = $longueur_defaut;  | 
                                                        |
| 832 | +    if (($v = interprete_argument_balise(1, $p)) !== null) { | 
                                                        |
| 833 | +        $_longueur = 'is_numeric(' . $v . ')?intval(' . $v . '):' . $longueur_defaut; | 
                                                        |
| 834 | +        $_suite = '!is_numeric(' . $v . ')?' . $v . ':null'; | 
                                                        |
| 835 | + }  | 
                                                        |
| 836 | +    if (($v2 = interprete_argument_balise(2, $p)) !== null) { | 
                                                        |
| 837 | + $_suite = $v2;  | 
                                                        |
| 838 | + }  | 
                                                        |
| 839 | 839 | |
| 840 | -	$f = chercher_filtre('introduction'); | 
                                                        |
| 841 | - $p->code = "$f($_descriptif, $_texte, $_longueur, \$connect, $_suite)";  | 
                                                        |
| 840 | +    $f = chercher_filtre('introduction'); | 
                                                        |
| 841 | + $p->code = "$f($_descriptif, $_texte, $_longueur, \$connect, $_suite)";  | 
                                                        |
| 842 | 842 | |
| 843 | - #$p->interdire_scripts = true;  | 
                                                        |
| 844 | - $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro  | 
                                                        |
| 845 | - return $p;  | 
                                                        |
| 843 | + #$p->interdire_scripts = true;  | 
                                                        |
| 844 | + $p->etoile = '*'; // propre est deja fait dans le calcul de l'intro  | 
                                                        |
| 845 | + return $p;  | 
                                                        |
| 846 | 846 | }  | 
                                                        
| 847 | 847 | |
| 848 | 848 | |
@@ -862,15 +862,15 @@ discard block  | 
                                                    ||
| 862 | 862 | * Pile complétée par le code à générer  | 
                                                        
| 863 | 863 | **/  | 
                                                        
| 864 | 864 |  function balise_LANG_dist($p) { | 
                                                        
| 865 | -	$_lang = champ_sql('lang', $p); | 
                                                        |
| 866 | -	if (!$p->etoile) { | 
                                                        |
| 867 | - $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])";  | 
                                                        |
| 868 | -	} else { | 
                                                        |
| 869 | - $p->code = "spip_htmlentities($_lang)";  | 
                                                        |
| 870 | - }  | 
                                                        |
| 871 | - $p->interdire_scripts = false;  | 
                                                        |
| 865 | +    $_lang = champ_sql('lang', $p); | 
                                                        |
| 866 | +    if (!$p->etoile) { | 
                                                        |
| 867 | + $p->code = "spip_htmlentities($_lang ? $_lang : \$GLOBALS['spip_lang'])";  | 
                                                        |
| 868 | +    } else { | 
                                                        |
| 869 | + $p->code = "spip_htmlentities($_lang)";  | 
                                                        |
| 870 | + }  | 
                                                        |
| 871 | + $p->interdire_scripts = false;  | 
                                                        |
| 872 | 872 | |
| 873 | - return $p;  | 
                                                        |
| 873 | + return $p;  | 
                                                        |
| 874 | 874 | }  | 
                                                        
| 875 | 875 | |
| 876 | 876 | /**  | 
                                                        
@@ -892,44 +892,44 @@ discard block  | 
                                                    ||
| 892 | 892 | * Pile complétée par le code à générer  | 
                                                        
| 893 | 893 | */  | 
                                                        
| 894 | 894 |  function balise_LESAUTEURS_dist($p) { | 
                                                        
| 895 | - // Cherche le champ 'lesauteurs' dans la pile  | 
                                                        |
| 896 | -	$_lesauteurs = champ_sql('lesauteurs', $p, false); | 
                                                        |
| 897 | -  | 
                                                        |
| 898 | - // Si le champ n'existe pas (cas de spip_articles), on applique  | 
                                                        |
| 899 | - // le modele lesauteurs.html en passant id_article dans le contexte;  | 
                                                        |
| 900 | - // dans le cas contraire on prend le champ 'lesauteurs'  | 
                                                        |
| 901 | - // (cf extension sites/)  | 
                                                        |
| 902 | - if ($_lesauteurs  | 
                                                        |
| 903 | - and $_lesauteurs != '@$Pile[0][\'lesauteurs\']'  | 
                                                        |
| 904 | -	) { | 
                                                        |
| 905 | - $p->code = "safehtml($_lesauteurs)";  | 
                                                        |
| 906 | - // $p->interdire_scripts = true;  | 
                                                        |
| 907 | -	} else { | 
                                                        |
| 908 | -		if (!$p->id_boucle) { | 
                                                        |
| 909 | - $connect = '';  | 
                                                        |
| 910 | - $objet = 'article';  | 
                                                        |
| 911 | - $id_table_objet = 'id_article';  | 
                                                        |
| 912 | -		} else { | 
                                                        |
| 913 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;  | 
                                                        |
| 914 | - $connect = $p->boucles[$b]->sql_serveur;  | 
                                                        |
| 915 | - $type_boucle = $p->boucles[$b]->type_requete;  | 
                                                        |
| 916 | - $objet = objet_type($type_boucle);  | 
                                                        |
| 917 | - $id_table_objet = id_table_objet($type_boucle);  | 
                                                        |
| 918 | - }  | 
                                                        |
| 919 | - $c = memoriser_contexte_compil($p);  | 
                                                        |
| 920 | -  | 
                                                        |
| 921 | - $p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'",  | 
                                                        |
| 922 | -			"array('objet'=>'" . $objet . | 
                                                        |
| 923 | - "','id_objet' => " . champ_sql($id_table_objet, $p) .  | 
                                                        |
| 924 | - ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) .  | 
                                                        |
| 925 | -			($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) . | 
                                                        |
| 926 | - ")",  | 
                                                        |
| 927 | - "'trim'=>true, 'compil'=>array($c)",  | 
                                                        |
| 928 | - _q($connect));  | 
                                                        |
| 929 | - $p->interdire_scripts = false; // securite apposee par recuperer_fond()  | 
                                                        |
| 930 | - }  | 
                                                        |
| 931 | -  | 
                                                        |
| 932 | - return $p;  | 
                                                        |
| 895 | + // Cherche le champ 'lesauteurs' dans la pile  | 
                                                        |
| 896 | +    $_lesauteurs = champ_sql('lesauteurs', $p, false); | 
                                                        |
| 897 | +  | 
                                                        |
| 898 | + // Si le champ n'existe pas (cas de spip_articles), on applique  | 
                                                        |
| 899 | + // le modele lesauteurs.html en passant id_article dans le contexte;  | 
                                                        |
| 900 | + // dans le cas contraire on prend le champ 'lesauteurs'  | 
                                                        |
| 901 | + // (cf extension sites/)  | 
                                                        |
| 902 | + if ($_lesauteurs  | 
                                                        |
| 903 | + and $_lesauteurs != '@$Pile[0][\'lesauteurs\']'  | 
                                                        |
| 904 | +    ) { | 
                                                        |
| 905 | + $p->code = "safehtml($_lesauteurs)";  | 
                                                        |
| 906 | + // $p->interdire_scripts = true;  | 
                                                        |
| 907 | +    } else { | 
                                                        |
| 908 | +        if (!$p->id_boucle) { | 
                                                        |
| 909 | + $connect = '';  | 
                                                        |
| 910 | + $objet = 'article';  | 
                                                        |
| 911 | + $id_table_objet = 'id_article';  | 
                                                        |
| 912 | +        } else { | 
                                                        |
| 913 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;  | 
                                                        |
| 914 | + $connect = $p->boucles[$b]->sql_serveur;  | 
                                                        |
| 915 | + $type_boucle = $p->boucles[$b]->type_requete;  | 
                                                        |
| 916 | + $objet = objet_type($type_boucle);  | 
                                                        |
| 917 | + $id_table_objet = id_table_objet($type_boucle);  | 
                                                        |
| 918 | + }  | 
                                                        |
| 919 | + $c = memoriser_contexte_compil($p);  | 
                                                        |
| 920 | +  | 
                                                        |
| 921 | + $p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'",  | 
                                                        |
| 922 | +            "array('objet'=>'" . $objet . | 
                                                        |
| 923 | + "','id_objet' => " . champ_sql($id_table_objet, $p) .  | 
                                                        |
| 924 | + ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) .  | 
                                                        |
| 925 | +            ($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) . | 
                                                        |
| 926 | + ")",  | 
                                                        |
| 927 | + "'trim'=>true, 'compil'=>array($c)",  | 
                                                        |
| 928 | + _q($connect));  | 
                                                        |
| 929 | + $p->interdire_scripts = false; // securite apposee par recuperer_fond()  | 
                                                        |
| 930 | + }  | 
                                                        |
| 931 | +  | 
                                                        |
| 932 | + return $p;  | 
                                                        |
| 933 | 933 | }  | 
                                                        
| 934 | 934 | |
| 935 | 935 | |
@@ -956,62 +956,62 @@ discard block  | 
                                                    ||
| 956 | 956 | * Pile complétée par le code à générer  | 
                                                        
| 957 | 957 | */  | 
                                                        
| 958 | 958 |  function balise_RANG_dist($p) { | 
                                                        
| 959 | - $b = index_boucle($p);  | 
                                                        |
| 960 | -	if ($b === '') { | 
                                                        |
| 961 | - $msg = array(  | 
                                                        |
| 962 | - 'zbug_champ_hors_boucle',  | 
                                                        |
| 963 | -			array('champ' => '#RANG') | 
                                                        |
| 964 | - );  | 
                                                        |
| 965 | - erreur_squelette($msg, $p);  | 
                                                        |
| 966 | -	} else { | 
                                                        |
| 967 | - // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql)  | 
                                                        |
| 968 | - // dans la boucle immediatement englobante uniquement  | 
                                                        |
| 969 | - // sinon on compose le champ calcule  | 
                                                        |
| 970 | -		$_rang = champ_sql('rang', $p, '', false); | 
                                                        |
| 971 | -  | 
                                                        |
| 972 | - // si pas trouve de champ sql rang :  | 
                                                        |
| 973 | -		if (!$_rang or $_rang == "''") { | 
                                                        |
| 974 | - $boucle = &$p->boucles[$b];  | 
                                                        |
| 975 | -			$trouver_table = charger_fonction('trouver_table', 'base'); | 
                                                        |
| 976 | - $desc = $trouver_table($boucle->id_table);  | 
                                                        |
| 977 | - $_titre = ''; # où extraire le numero ?  | 
                                                        |
| 959 | + $b = index_boucle($p);  | 
                                                        |
| 960 | +    if ($b === '') { | 
                                                        |
| 961 | + $msg = array(  | 
                                                        |
| 962 | + 'zbug_champ_hors_boucle',  | 
                                                        |
| 963 | +            array('champ' => '#RANG') | 
                                                        |
| 964 | + );  | 
                                                        |
| 965 | + erreur_squelette($msg, $p);  | 
                                                        |
| 966 | +    } else { | 
                                                        |
| 967 | + // chercher d'abord un champ sql rang (mais pas dans le env : defaut '' si on trouve pas de champ sql)  | 
                                                        |
| 968 | + // dans la boucle immediatement englobante uniquement  | 
                                                        |
| 969 | + // sinon on compose le champ calcule  | 
                                                        |
| 970 | +        $_rang = champ_sql('rang', $p, '', false); | 
                                                        |
| 971 | +  | 
                                                        |
| 972 | + // si pas trouve de champ sql rang :  | 
                                                        |
| 973 | +        if (!$_rang or $_rang == "''") { | 
                                                        |
| 974 | + $boucle = &$p->boucles[$b];  | 
                                                        |
| 975 | +            $trouver_table = charger_fonction('trouver_table', 'base'); | 
                                                        |
| 976 | + $desc = $trouver_table($boucle->id_table);  | 
                                                        |
| 977 | + $_titre = ''; # où extraire le numero ?  | 
                                                        |
| 978 | 978 | |
| 979 | -			if (isset($desc['titre'])) { | 
                                                        |
| 980 | - $t = $desc['titre'];  | 
                                                        |
| 981 | - if (  | 
                                                        |
| 982 | - // Soit on trouve avec la déclaration de la lang AVANT  | 
                                                        |
| 983 | -					preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) | 
                                                        |
| 984 | - // Soit on prend depuis le début  | 
                                                        |
| 985 | -					or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) | 
                                                        |
| 986 | -				) { | 
                                                        |
| 987 | -					$m = preg_replace(',as\s+titre$,i', '', $m[1]); | 
                                                        |
| 988 | - $m = trim($m);  | 
                                                        |
| 989 | -					if ($m != "''") { | 
                                                        |
| 990 | -						if (!preg_match(",\W,", $m)) { | 
                                                        |
| 991 | - $m = $boucle->id_table . ".$m";  | 
                                                        |
| 992 | - }  | 
                                                        |
| 979 | +            if (isset($desc['titre'])) { | 
                                                        |
| 980 | + $t = $desc['titre'];  | 
                                                        |
| 981 | + if (  | 
                                                        |
| 982 | + // Soit on trouve avec la déclaration de la lang AVANT  | 
                                                        |
| 983 | +                    preg_match(';(?:lang\s*,)\s*(.*?titre)\s*(,|$);', $t, $m) | 
                                                        |
| 984 | + // Soit on prend depuis le début  | 
                                                        |
| 985 | +                    or preg_match(';^(.*?titre)\s*(,|$);', $t, $m) | 
                                                        |
| 986 | +                ) { | 
                                                        |
| 987 | +                    $m = preg_replace(',as\s+titre$,i', '', $m[1]); | 
                                                        |
| 988 | + $m = trim($m);  | 
                                                        |
| 989 | +                    if ($m != "''") { | 
                                                        |
| 990 | +                        if (!preg_match(",\W,", $m)) { | 
                                                        |
| 991 | + $m = $boucle->id_table . ".$m";  | 
                                                        |
| 992 | + }  | 
                                                        |
| 993 | 993 | |
| 994 | - $m .= " AS titre_rang";  | 
                                                        |
| 994 | + $m .= " AS titre_rang";  | 
                                                        |
| 995 | 995 | |
| 996 | - $boucle->select[] = $m;  | 
                                                        |
| 997 | - $_titre = '$Pile[$SP][\'titre_rang\']';  | 
                                                        |
| 998 | - }  | 
                                                        |
| 999 | - }  | 
                                                        |
| 1000 | - }  | 
                                                        |
| 996 | + $boucle->select[] = $m;  | 
                                                        |
| 997 | + $_titre = '$Pile[$SP][\'titre_rang\']';  | 
                                                        |
| 998 | + }  | 
                                                        |
| 999 | + }  | 
                                                        |
| 1000 | + }  | 
                                                        |
| 1001 | 1001 | |
| 1002 | - // si on n'a rien trouvé, on utilise le champ titre classique  | 
                                                        |
| 1003 | -			if (!$_titre) { | 
                                                        |
| 1004 | -				$_titre = champ_sql('titre', $p); | 
                                                        |
| 1005 | - }  | 
                                                        |
| 1002 | + // si on n'a rien trouvé, on utilise le champ titre classique  | 
                                                        |
| 1003 | +            if (!$_titre) { | 
                                                        |
| 1004 | +                $_titre = champ_sql('titre', $p); | 
                                                        |
| 1005 | + }  | 
                                                        |
| 1006 | 1006 | |
| 1007 | - $_rang = "recuperer_numero($_titre)";  | 
                                                        |
| 1008 | - }  | 
                                                        |
| 1007 | + $_rang = "recuperer_numero($_titre)";  | 
                                                        |
| 1008 | + }  | 
                                                        |
| 1009 | 1009 | |
| 1010 | - $p->code = $_rang;  | 
                                                        |
| 1011 | - $p->interdire_scripts = false;  | 
                                                        |
| 1012 | - }  | 
                                                        |
| 1010 | + $p->code = $_rang;  | 
                                                        |
| 1011 | + $p->interdire_scripts = false;  | 
                                                        |
| 1012 | + }  | 
                                                        |
| 1013 | 1013 | |
| 1014 | - return $p;  | 
                                                        |
| 1014 | + return $p;  | 
                                                        |
| 1015 | 1015 | }  | 
                                                        
| 1016 | 1016 | |
| 1017 | 1017 | |
@@ -1033,12 +1033,12 @@ discard block  | 
                                                    ||
| 1033 | 1033 | * Pile complétée par le code à générer  | 
                                                        
| 1034 | 1034 | **/  | 
                                                        
| 1035 | 1035 |  function balise_POPULARITE_dist($p) { | 
                                                        
| 1036 | -	$_popularite = champ_sql('popularite', $p); | 
                                                        |
| 1037 | - $p->code = "(ceil(min(100, 100 * $_popularite  | 
                                                        |
| 1036 | +    $_popularite = champ_sql('popularite', $p); | 
                                                        |
| 1037 | + $p->code = "(ceil(min(100, 100 * $_popularite  | 
                                                        |
| 1038 | 1038 | / max(1 , 0 + \$GLOBALS['meta']['popularite_max']))))";  | 
                                                        
| 1039 | - $p->interdire_scripts = false;  | 
                                                        |
| 1039 | + $p->interdire_scripts = false;  | 
                                                        |
| 1040 | 1040 | |
| 1041 | - return $p;  | 
                                                        |
| 1041 | + return $p;  | 
                                                        |
| 1042 | 1042 | }  | 
                                                        
| 1043 | 1043 | |
| 1044 | 1044 | /**  | 
                                                        
@@ -1085,65 +1085,65 @@ discard block  | 
                                                    ||
| 1085 | 1085 | * Pile complétée par le code à générer  | 
                                                        
| 1086 | 1086 | */  | 
                                                        
| 1087 | 1087 |  function balise_PAGINATION_dist($p, $liste = 'true') { | 
                                                        
| 1088 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];  | 
                                                        |
| 1089 | -  | 
                                                        |
| 1090 | - // s'il n'y a pas de nom de boucle, on ne peut pas paginer  | 
                                                        |
| 1091 | -	if ($b === '') { | 
                                                        |
| 1092 | - $msg = array(  | 
                                                        |
| 1093 | - 'zbug_champ_hors_boucle',  | 
                                                        |
| 1094 | -			array('champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION') | 
                                                        |
| 1095 | - );  | 
                                                        |
| 1096 | - erreur_squelette($msg, $p);  | 
                                                        |
| 1097 | -  | 
                                                        |
| 1098 | - return $p;  | 
                                                        |
| 1099 | - }  | 
                                                        |
| 1100 | -  | 
                                                        |
| 1101 | - // s'il n'y a pas de mode_partie, c'est qu'on se trouve  | 
                                                        |
| 1102 | -	// dans un boucle recursive ou qu'on a oublie le critere {pagination} | 
                                                        |
| 1103 | -	if (!$p->boucles[$b]->mode_partie) { | 
                                                        |
| 1104 | -		if (!$p->boucles[$b]->table_optionnelle) { | 
                                                        |
| 1105 | - $msg = array(  | 
                                                        |
| 1106 | - 'zbug_pagination_sans_critere',  | 
                                                        |
| 1107 | -				array('champ' => '#PAGINATION') | 
                                                        |
| 1108 | - );  | 
                                                        |
| 1109 | - erreur_squelette($msg, $p);  | 
                                                        |
| 1110 | - }  | 
                                                        |
| 1111 | -  | 
                                                        |
| 1112 | - return $p;  | 
                                                        |
| 1113 | - }  | 
                                                        |
| 1114 | -  | 
                                                        |
| 1115 | - // a priori true  | 
                                                        |
| 1116 | - // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise  | 
                                                        |
| 1117 | - // si true, les arguments simples (sans truc=chose) vont degager  | 
                                                        |
| 1118 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false);  | 
                                                        |
| 1119 | -	if (count($_contexte)) { | 
                                                        |
| 1120 | - $key = key($_contexte);  | 
                                                        |
| 1121 | -		if (is_numeric($key)) { | 
                                                        |
| 1122 | - array_shift($_contexte);  | 
                                                        |
| 1123 | - $__modele = interprete_argument_balise(1, $p);  | 
                                                        |
| 1124 | - }  | 
                                                        |
| 1125 | - }  | 
                                                        |
| 1126 | -  | 
                                                        |
| 1127 | -	if (count($_contexte)) { | 
                                                        |
| 1128 | -		$code_contexte = implode(',', $_contexte); | 
                                                        |
| 1129 | -	} else { | 
                                                        |
| 1130 | - $code_contexte = '';  | 
                                                        |
| 1131 | - }  | 
                                                        |
| 1132 | -  | 
                                                        |
| 1133 | - $connect = $p->boucles[$b]->sql_serveur;  | 
                                                        |
| 1134 | - $pas = $p->boucles[$b]->total_parties;  | 
                                                        |
| 1135 | -	$f_pagination = chercher_filtre('pagination'); | 
                                                        |
| 1136 | - $type = $p->boucles[$b]->modificateur['debut_nom'];  | 
                                                        |
| 1137 | - $modif = ($type[0] !== "'") ? "'debut'.$type"  | 
                                                        |
| 1138 | -		: ("'debut" . substr($type, 1)); | 
                                                        |
| 1139 | -  | 
                                                        |
| 1140 | - $p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste,  | 
                                                        |
| 1141 | - ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte);  | 
                                                        |
| 1142 | -  | 
                                                        |
| 1143 | - $p->boucles[$b]->numrows = true;  | 
                                                        |
| 1144 | - $p->interdire_scripts = false;  | 
                                                        |
| 1145 | -  | 
                                                        |
| 1146 | - return $p;  | 
                                                        |
| 1088 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];  | 
                                                        |
| 1089 | +  | 
                                                        |
| 1090 | + // s'il n'y a pas de nom de boucle, on ne peut pas paginer  | 
                                                        |
| 1091 | +    if ($b === '') { | 
                                                        |
| 1092 | + $msg = array(  | 
                                                        |
| 1093 | + 'zbug_champ_hors_boucle',  | 
                                                        |
| 1094 | +            array('champ' => $liste ? 'PAGINATION' : 'ANCRE_PAGINATION') | 
                                                        |
| 1095 | + );  | 
                                                        |
| 1096 | + erreur_squelette($msg, $p);  | 
                                                        |
| 1097 | +  | 
                                                        |
| 1098 | + return $p;  | 
                                                        |
| 1099 | + }  | 
                                                        |
| 1100 | +  | 
                                                        |
| 1101 | + // s'il n'y a pas de mode_partie, c'est qu'on se trouve  | 
                                                        |
| 1102 | +    // dans un boucle recursive ou qu'on a oublie le critere {pagination} | 
                                                        |
| 1103 | +    if (!$p->boucles[$b]->mode_partie) { | 
                                                        |
| 1104 | +        if (!$p->boucles[$b]->table_optionnelle) { | 
                                                        |
| 1105 | + $msg = array(  | 
                                                        |
| 1106 | + 'zbug_pagination_sans_critere',  | 
                                                        |
| 1107 | +                array('champ' => '#PAGINATION') | 
                                                        |
| 1108 | + );  | 
                                                        |
| 1109 | + erreur_squelette($msg, $p);  | 
                                                        |
| 1110 | + }  | 
                                                        |
| 1111 | +  | 
                                                        |
| 1112 | + return $p;  | 
                                                        |
| 1113 | + }  | 
                                                        |
| 1114 | +  | 
                                                        |
| 1115 | + // a priori true  | 
                                                        |
| 1116 | + // si false, le compilo va bloquer sur des syntaxes avec un filtre sans argument qui suit la balise  | 
                                                        |
| 1117 | + // si true, les arguments simples (sans truc=chose) vont degager  | 
                                                        |
| 1118 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false, false);  | 
                                                        |
| 1119 | +    if (count($_contexte)) { | 
                                                        |
| 1120 | + $key = key($_contexte);  | 
                                                        |
| 1121 | +        if (is_numeric($key)) { | 
                                                        |
| 1122 | + array_shift($_contexte);  | 
                                                        |
| 1123 | + $__modele = interprete_argument_balise(1, $p);  | 
                                                        |
| 1124 | + }  | 
                                                        |
| 1125 | + }  | 
                                                        |
| 1126 | +  | 
                                                        |
| 1127 | +    if (count($_contexte)) { | 
                                                        |
| 1128 | +        $code_contexte = implode(',', $_contexte); | 
                                                        |
| 1129 | +    } else { | 
                                                        |
| 1130 | + $code_contexte = '';  | 
                                                        |
| 1131 | + }  | 
                                                        |
| 1132 | +  | 
                                                        |
| 1133 | + $connect = $p->boucles[$b]->sql_serveur;  | 
                                                        |
| 1134 | + $pas = $p->boucles[$b]->total_parties;  | 
                                                        |
| 1135 | +    $f_pagination = chercher_filtre('pagination'); | 
                                                        |
| 1136 | + $type = $p->boucles[$b]->modificateur['debut_nom'];  | 
                                                        |
| 1137 | + $modif = ($type[0] !== "'") ? "'debut'.$type"  | 
                                                        |
| 1138 | +        : ("'debut" . substr($type, 1)); | 
                                                        |
| 1139 | +  | 
                                                        |
| 1140 | + $p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste,  | 
                                                        |
| 1141 | + ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte);  | 
                                                        |
| 1142 | +  | 
                                                        |
| 1143 | + $p->boucles[$b]->numrows = true;  | 
                                                        |
| 1144 | + $p->interdire_scripts = false;  | 
                                                        |
| 1145 | +  | 
                                                        |
| 1146 | + return $p;  | 
                                                        |
| 1147 | 1147 | }  | 
                                                        
| 1148 | 1148 | |
| 1149 | 1149 | |
@@ -1170,11 +1170,11 @@ discard block  | 
                                                    ||
| 1170 | 1170 | * Pile complétée par le code à générer  | 
                                                        
| 1171 | 1171 | **/  | 
                                                        
| 1172 | 1172 |  function balise_ANCRE_PAGINATION_dist($p) { | 
                                                        
| 1173 | -	if ($f = charger_fonction('PAGINATION', 'balise', true)) { | 
                                                        |
| 1174 | - return $f($p, $liste = 'false');  | 
                                                        |
| 1175 | -	} else { | 
                                                        |
| 1176 | - return null;  | 
                                                        |
| 1177 | - } // ou une erreur ?  | 
                                                        |
| 1173 | +    if ($f = charger_fonction('PAGINATION', 'balise', true)) { | 
                                                        |
| 1174 | + return $f($p, $liste = 'false');  | 
                                                        |
| 1175 | +    } else { | 
                                                        |
| 1176 | + return null;  | 
                                                        |
| 1177 | + } // ou une erreur ?  | 
                                                        |
| 1178 | 1178 | }  | 
                                                        
| 1179 | 1179 | |
| 1180 | 1180 | |
@@ -1195,21 +1195,21 @@ discard block  | 
                                                    ||
| 1195 | 1195 | * Pile complétée par le code à générer  | 
                                                        
| 1196 | 1196 | **/  | 
                                                        
| 1197 | 1197 |  function balise_GRAND_TOTAL_dist($p) { | 
                                                        
| 1198 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];  | 
                                                        |
| 1199 | -	if ($b === '' || !isset($p->boucles[$b])) { | 
                                                        |
| 1200 | - $msg = array(  | 
                                                        |
| 1201 | - 'zbug_champ_hors_boucle',  | 
                                                        |
| 1202 | -			array('champ' => "#$b" . 'TOTAL_BOUCLE') | 
                                                        |
| 1203 | - );  | 
                                                        |
| 1204 | - erreur_squelette($msg, $p);  | 
                                                        |
| 1205 | -	} else { | 
                                                        |
| 1206 | - $p->code = "(isset(\$Numrows['$b']['grand_total'])  | 
                                                        |
| 1198 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];  | 
                                                        |
| 1199 | +    if ($b === '' || !isset($p->boucles[$b])) { | 
                                                        |
| 1200 | + $msg = array(  | 
                                                        |
| 1201 | + 'zbug_champ_hors_boucle',  | 
                                                        |
| 1202 | +            array('champ' => "#$b" . 'TOTAL_BOUCLE') | 
                                                        |
| 1203 | + );  | 
                                                        |
| 1204 | + erreur_squelette($msg, $p);  | 
                                                        |
| 1205 | +    } else { | 
                                                        |
| 1206 | + $p->code = "(isset(\$Numrows['$b']['grand_total'])  | 
                                                        |
| 1207 | 1207 | ? \$Numrows['$b']['grand_total'] : \$Numrows['$b']['total'])";  | 
                                                        
| 1208 | - $p->boucles[$b]->numrows = true;  | 
                                                        |
| 1209 | - $p->interdire_scripts = false;  | 
                                                        |
| 1210 | - }  | 
                                                        |
| 1208 | + $p->boucles[$b]->numrows = true;  | 
                                                        |
| 1209 | + $p->interdire_scripts = false;  | 
                                                        |
| 1210 | + }  | 
                                                        |
| 1211 | 1211 | |
| 1212 | - return $p;  | 
                                                        |
| 1212 | + return $p;  | 
                                                        |
| 1213 | 1213 | }  | 
                                                        
| 1214 | 1214 | |
| 1215 | 1215 | |
@@ -1237,10 +1237,10 @@ discard block  | 
                                                    ||
| 1237 | 1237 | * Pile complétée par le code à générer  | 
                                                        
| 1238 | 1238 | **/  | 
                                                        
| 1239 | 1239 |  function balise_SELF_dist($p) { | 
                                                        
| 1240 | - $p->code = 'self()';  | 
                                                        |
| 1241 | - $p->interdire_scripts = false;  | 
                                                        |
| 1240 | + $p->code = 'self()';  | 
                                                        |
| 1241 | + $p->interdire_scripts = false;  | 
                                                        |
| 1242 | 1242 | |
| 1243 | - return $p;  | 
                                                        |
| 1243 | + return $p;  | 
                                                        |
| 1244 | 1244 | }  | 
                                                        
| 1245 | 1245 | |
| 1246 | 1246 | |
@@ -1267,17 +1267,17 @@ discard block  | 
                                                    ||
| 1267 | 1267 | * Pile complétée par le code à générer  | 
                                                        
| 1268 | 1268 | **/  | 
                                                        
| 1269 | 1269 |  function balise_CHEMIN_dist($p) { | 
                                                        
| 1270 | - $arg = interprete_argument_balise(1, $p);  | 
                                                        |
| 1271 | -	if (!$arg) { | 
                                                        |
| 1272 | -		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN')); | 
                                                        |
| 1273 | - erreur_squelette($msg, $p);  | 
                                                        |
| 1274 | -	} else { | 
                                                        |
| 1275 | -		$p->code = 'find_in_path(' . $arg . ')'; | 
                                                        |
| 1276 | - }  | 
                                                        |
| 1270 | + $arg = interprete_argument_balise(1, $p);  | 
                                                        |
| 1271 | +    if (!$arg) { | 
                                                        |
| 1272 | +        $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN')); | 
                                                        |
| 1273 | + erreur_squelette($msg, $p);  | 
                                                        |
| 1274 | +    } else { | 
                                                        |
| 1275 | +        $p->code = 'find_in_path(' . $arg . ')'; | 
                                                        |
| 1276 | + }  | 
                                                        |
| 1277 | 1277 | |
| 1278 | - $p->interdire_scripts = false;  | 
                                                        |
| 1278 | + $p->interdire_scripts = false;  | 
                                                        |
| 1279 | 1279 | |
| 1280 | - return $p;  | 
                                                        |
| 1280 | + return $p;  | 
                                                        |
| 1281 | 1281 | }  | 
                                                        
| 1282 | 1282 | |
| 1283 | 1283 | /**  | 
                                                        
@@ -1302,16 +1302,16 @@ discard block  | 
                                                    ||
| 1302 | 1302 | * Pile complétée par le code à générer  | 
                                                        
| 1303 | 1303 | **/  | 
                                                        
| 1304 | 1304 |  function balise_CHEMIN_IMAGE_dist($p) { | 
                                                        
| 1305 | - $arg = interprete_argument_balise(1, $p);  | 
                                                        |
| 1306 | -	if (!$arg) { | 
                                                        |
| 1307 | -		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE')); | 
                                                        |
| 1308 | - erreur_squelette($msg, $p);  | 
                                                        |
| 1309 | -	} else { | 
                                                        |
| 1310 | -		$p->code = 'chemin_image(' . $arg . ')'; | 
                                                        |
| 1311 | - }  | 
                                                        |
| 1305 | + $arg = interprete_argument_balise(1, $p);  | 
                                                        |
| 1306 | +    if (!$arg) { | 
                                                        |
| 1307 | +        $msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE')); | 
                                                        |
| 1308 | + erreur_squelette($msg, $p);  | 
                                                        |
| 1309 | +    } else { | 
                                                        |
| 1310 | +        $p->code = 'chemin_image(' . $arg . ')'; | 
                                                        |
| 1311 | + }  | 
                                                        |
| 1312 | 1312 | |
| 1313 | - #$p->interdire_scripts = true;  | 
                                                        |
| 1314 | - return $p;  | 
                                                        |
| 1313 | + #$p->interdire_scripts = true;  | 
                                                        |
| 1314 | + return $p;  | 
                                                        |
| 1315 | 1315 | }  | 
                                                        
| 1316 | 1316 | |
| 1317 | 1317 | |
@@ -1349,36 +1349,36 @@ discard block  | 
                                                    ||
| 1349 | 1349 | **/  | 
                                                        
| 1350 | 1350 |  function balise_ENV_dist($p, $src = null) { | 
                                                        
| 1351 | 1351 | |
| 1352 | - // cle du tableau desiree  | 
                                                        |
| 1353 | - $_nom = interprete_argument_balise(1, $p);  | 
                                                        |
| 1354 | - // valeur par defaut  | 
                                                        |
| 1355 | - $_sinon = interprete_argument_balise(2, $p);  | 
                                                        |
| 1352 | + // cle du tableau desiree  | 
                                                        |
| 1353 | + $_nom = interprete_argument_balise(1, $p);  | 
                                                        |
| 1354 | + // valeur par defaut  | 
                                                        |
| 1355 | + $_sinon = interprete_argument_balise(2, $p);  | 
                                                        |
| 1356 | 1356 | |
| 1357 | - // $src est un tableau de donnees sources eventuellement transmis  | 
                                                        |
| 1358 | - // en absence, on utilise l'environnement du squelette $Pile[0]  | 
                                                        |
| 1357 | + // $src est un tableau de donnees sources eventuellement transmis  | 
                                                        |
| 1358 | + // en absence, on utilise l'environnement du squelette $Pile[0]  | 
                                                        |
| 1359 | 1359 | |
| 1360 | -	if (!$_nom) { | 
                                                        |
| 1361 | - // cas de #ENV sans argument : on retourne le serialize() du tableau  | 
                                                        |
| 1362 | - // une belle fonction [(#ENV|affiche_env)] serait pratique  | 
                                                        |
| 1363 | -		if ($src) { | 
                                                        |
| 1364 | -			$p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; | 
                                                        |
| 1365 | -		} else { | 
                                                        |
| 1366 | - $p->code = '@serialize($Pile[0])';  | 
                                                        |
| 1367 | - }  | 
                                                        |
| 1368 | -	} else { | 
                                                        |
| 1369 | -		if (!$src) { | 
                                                        |
| 1370 | - $src = '@$Pile[0]';  | 
                                                        |
| 1371 | - }  | 
                                                        |
| 1372 | -		if ($_sinon) { | 
                                                        |
| 1373 | - $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)";  | 
                                                        |
| 1374 | -		} else { | 
                                                        |
| 1375 | - $p->code = "table_valeur($src, (string)$_nom, null)";  | 
                                                        |
| 1376 | - }  | 
                                                        |
| 1377 | - }  | 
                                                        |
| 1360 | +    if (!$_nom) { | 
                                                        |
| 1361 | + // cas de #ENV sans argument : on retourne le serialize() du tableau  | 
                                                        |
| 1362 | + // une belle fonction [(#ENV|affiche_env)] serait pratique  | 
                                                        |
| 1363 | +        if ($src) { | 
                                                        |
| 1364 | +            $p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; | 
                                                        |
| 1365 | +        } else { | 
                                                        |
| 1366 | + $p->code = '@serialize($Pile[0])';  | 
                                                        |
| 1367 | + }  | 
                                                        |
| 1368 | +    } else { | 
                                                        |
| 1369 | +        if (!$src) { | 
                                                        |
| 1370 | + $src = '@$Pile[0]';  | 
                                                        |
| 1371 | + }  | 
                                                        |
| 1372 | +        if ($_sinon) { | 
                                                        |
| 1373 | + $p->code = "sinon(table_valeur($src, (string)$_nom, null), $_sinon)";  | 
                                                        |
| 1374 | +        } else { | 
                                                        |
| 1375 | + $p->code = "table_valeur($src, (string)$_nom, null)";  | 
                                                        |
| 1376 | + }  | 
                                                        |
| 1377 | + }  | 
                                                        |
| 1378 | 1378 | |
| 1379 | - #$p->interdire_scripts = true;  | 
                                                        |
| 1379 | + #$p->interdire_scripts = true;  | 
                                                        |
| 1380 | 1380 | |
| 1381 | - return $p;  | 
                                                        |
| 1381 | + return $p;  | 
                                                        |
| 1382 | 1382 | }  | 
                                                        
| 1383 | 1383 | |
| 1384 | 1384 | /**  | 
                                                        
@@ -1408,16 +1408,16 @@ discard block  | 
                                                    ||
| 1408 | 1408 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 1409 | 1409 | */  | 
                                                        
| 1410 | 1410 |  function balise_CONFIG_dist($p) { | 
                                                        
| 1411 | -	if (!$arg = interprete_argument_balise(1, $p)) { | 
                                                        |
| 1412 | - $arg = "''";  | 
                                                        |
| 1413 | - }  | 
                                                        |
| 1414 | - $_sinon = interprete_argument_balise(2, $p);  | 
                                                        |
| 1415 | - $_unserialize = sinon(interprete_argument_balise(3, $p), "false");  | 
                                                        |
| 1411 | +    if (!$arg = interprete_argument_balise(1, $p)) { | 
                                                        |
| 1412 | + $arg = "''";  | 
                                                        |
| 1413 | + }  | 
                                                        |
| 1414 | + $_sinon = interprete_argument_balise(2, $p);  | 
                                                        |
| 1415 | + $_unserialize = sinon(interprete_argument_balise(3, $p), "false");  | 
                                                        |
| 1416 | 1416 | |
| 1417 | -	$p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . | 
                                                        |
| 1418 | - ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')";  | 
                                                        |
| 1417 | +    $p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . | 
                                                        |
| 1418 | + ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')";  | 
                                                        |
| 1419 | 1419 | |
| 1420 | - return $p;  | 
                                                        |
| 1420 | + return $p;  | 
                                                        |
| 1421 | 1421 | }  | 
                                                        
| 1422 | 1422 | |
| 1423 | 1423 | |
@@ -1440,10 +1440,10 @@ discard block  | 
                                                    ||
| 1440 | 1440 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 1441 | 1441 | */  | 
                                                        
| 1442 | 1442 |  function balise_CONNECT_dist($p) { | 
                                                        
| 1443 | - $p->code = '($connect ? $connect : NULL)';  | 
                                                        |
| 1444 | - $p->interdire_scripts = false;  | 
                                                        |
| 1443 | + $p->code = '($connect ? $connect : NULL)';  | 
                                                        |
| 1444 | + $p->interdire_scripts = false;  | 
                                                        |
| 1445 | 1445 | |
| 1446 | - return $p;  | 
                                                        |
| 1446 | + return $p;  | 
                                                        |
| 1447 | 1447 | }  | 
                                                        
| 1448 | 1448 | |
| 1449 | 1449 | |
@@ -1471,15 +1471,15 @@ discard block  | 
                                                    ||
| 1471 | 1471 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 1472 | 1472 | **/  | 
                                                        
| 1473 | 1473 |  function balise_SESSION_dist($p) { | 
                                                        
| 1474 | - $p->descr['session'] = true;  | 
                                                        |
| 1474 | + $p->descr['session'] = true;  | 
                                                        |
| 1475 | 1475 | |
| 1476 | -	$f = function_exists('balise_ENV') | 
                                                        |
| 1477 | - ? 'balise_ENV'  | 
                                                        |
| 1478 | - : 'balise_ENV_dist';  | 
                                                        |
| 1476 | +    $f = function_exists('balise_ENV') | 
                                                        |
| 1477 | + ? 'balise_ENV'  | 
                                                        |
| 1478 | + : 'balise_ENV_dist';  | 
                                                        |
| 1479 | 1479 | |
| 1480 | - $p = $f($p, '$GLOBALS["visiteur_session"]');  | 
                                                        |
| 1480 | + $p = $f($p, '$GLOBALS["visiteur_session"]');  | 
                                                        |
| 1481 | 1481 | |
| 1482 | - return $p;  | 
                                                        |
| 1482 | + return $p;  | 
                                                        |
| 1483 | 1483 | }  | 
                                                        
| 1484 | 1484 | |
| 1485 | 1485 | |
@@ -1502,18 +1502,18 @@ discard block  | 
                                                    ||
| 1502 | 1502 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 1503 | 1503 | **/  | 
                                                        
| 1504 | 1504 |  function balise_SESSION_SET_dist($p) { | 
                                                        
| 1505 | - $_nom = interprete_argument_balise(1, $p);  | 
                                                        |
| 1506 | - $_val = interprete_argument_balise(2, $p);  | 
                                                        |
| 1507 | -	if (!$_nom or !$_val) { | 
                                                        |
| 1508 | -		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET')); | 
                                                        |
| 1509 | - erreur_squelette($err_b_s_a, $p);  | 
                                                        |
| 1510 | -	} else { | 
                                                        |
| 1511 | -		$p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; | 
                                                        |
| 1512 | - }  | 
                                                        |
| 1505 | + $_nom = interprete_argument_balise(1, $p);  | 
                                                        |
| 1506 | + $_val = interprete_argument_balise(2, $p);  | 
                                                        |
| 1507 | +    if (!$_nom or !$_val) { | 
                                                        |
| 1508 | +        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET')); | 
                                                        |
| 1509 | + erreur_squelette($err_b_s_a, $p);  | 
                                                        |
| 1510 | +    } else { | 
                                                        |
| 1511 | +        $p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; | 
                                                        |
| 1512 | + }  | 
                                                        |
| 1513 | 1513 | |
| 1514 | - $p->interdire_scripts = false;  | 
                                                        |
| 1514 | + $p->interdire_scripts = false;  | 
                                                        |
| 1515 | 1515 | |
| 1516 | - return $p;  | 
                                                        |
| 1516 | + return $p;  | 
                                                        |
| 1517 | 1517 | }  | 
                                                        
| 1518 | 1518 | |
| 1519 | 1519 | |
@@ -1544,25 +1544,25 @@ discard block  | 
                                                    ||
| 1544 | 1544 | * Pile completée du code PHP d'exécution de la balise  | 
                                                        
| 1545 | 1545 | **/  | 
                                                        
| 1546 | 1546 |  function balise_EVAL_dist($p) { | 
                                                        
| 1547 | - $php = interprete_argument_balise(1, $p);  | 
                                                        |
| 1548 | -	if ($php) { | 
                                                        |
| 1549 | -		# optimisation sur les #EVAL{une expression sans #BALISE} | 
                                                        |
| 1550 | - # attention au commentaire "// x signes" qui precede  | 
                                                        |
| 1551 | -		if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", | 
                                                        |
| 1552 | -			$php, $r)) { | 
                                                        |
| 1553 | - $p->code = /* $r[1]. */  | 
                                                        |
| 1554 | -				'(' . $r[2] . ')'; | 
                                                        |
| 1555 | -		} else { | 
                                                        |
| 1556 | -			$p->code = "eval('return '.$php.';')"; | 
                                                        |
| 1557 | - }  | 
                                                        |
| 1558 | -	} else { | 
                                                        |
| 1559 | -		$msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL')); | 
                                                        |
| 1560 | - erreur_squelette($msg, $p);  | 
                                                        |
| 1561 | - }  | 
                                                        |
| 1547 | + $php = interprete_argument_balise(1, $p);  | 
                                                        |
| 1548 | +    if ($php) { | 
                                                        |
| 1549 | +        # optimisation sur les #EVAL{une expression sans #BALISE} | 
                                                        |
| 1550 | + # attention au commentaire "// x signes" qui precede  | 
                                                        |
| 1551 | +        if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", | 
                                                        |
| 1552 | +            $php, $r)) { | 
                                                        |
| 1553 | + $p->code = /* $r[1]. */  | 
                                                        |
| 1554 | +                '(' . $r[2] . ')'; | 
                                                        |
| 1555 | +        } else { | 
                                                        |
| 1556 | +            $p->code = "eval('return '.$php.';')"; | 
                                                        |
| 1557 | + }  | 
                                                        |
| 1558 | +    } else { | 
                                                        |
| 1559 | +        $msg = array('zbug_balise_sans_argument', array('balise' => ' EVAL')); | 
                                                        |
| 1560 | + erreur_squelette($msg, $p);  | 
                                                        |
| 1561 | + }  | 
                                                        |
| 1562 | 1562 | |
| 1563 | - #$p->interdire_scripts = true;  | 
                                                        |
| 1563 | + #$p->interdire_scripts = true;  | 
                                                        |
| 1564 | 1564 | |
| 1565 | - return $p;  | 
                                                        |
| 1565 | + return $p;  | 
                                                        |
| 1566 | 1566 | }  | 
                                                        
| 1567 | 1567 | |
| 1568 | 1568 | |
@@ -1592,18 +1592,18 @@ discard block  | 
                                                    ||
| 1592 | 1592 | **/  | 
                                                        
| 1593 | 1593 |  function balise_CHAMP_SQL_dist($p) { | 
                                                        
| 1594 | 1594 | |
| 1595 | - if ($p->param  | 
                                                        |
| 1596 | - and isset($p->param[0][1][0])  | 
                                                        |
| 1597 | - and $champ = ($p->param[0][1][0]->texte)  | 
                                                        |
| 1598 | -	) { | 
                                                        |
| 1599 | - $p->code = champ_sql($champ, $p);  | 
                                                        |
| 1600 | -	} else { | 
                                                        |
| 1601 | -		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL')); | 
                                                        |
| 1602 | - erreur_squelette($err_b_s_a, $p);  | 
                                                        |
| 1603 | - }  | 
                                                        |
| 1595 | + if ($p->param  | 
                                                        |
| 1596 | + and isset($p->param[0][1][0])  | 
                                                        |
| 1597 | + and $champ = ($p->param[0][1][0]->texte)  | 
                                                        |
| 1598 | +    ) { | 
                                                        |
| 1599 | + $p->code = champ_sql($champ, $p);  | 
                                                        |
| 1600 | +    } else { | 
                                                        |
| 1601 | +        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => ' CHAMP_SQL')); | 
                                                        |
| 1602 | + erreur_squelette($err_b_s_a, $p);  | 
                                                        |
| 1603 | + }  | 
                                                        |
| 1604 | 1604 | |
| 1605 | - #$p->interdire_scripts = true;  | 
                                                        |
| 1606 | - return $p;  | 
                                                        |
| 1605 | + #$p->interdire_scripts = true;  | 
                                                        |
| 1606 | + return $p;  | 
                                                        |
| 1607 | 1607 | }  | 
                                                        
| 1608 | 1608 | |
| 1609 | 1609 | /**  | 
                                                        
@@ -1629,13 +1629,13 @@ discard block  | 
                                                    ||
| 1629 | 1629 | * Pile complétée par le code à générer  | 
                                                        
| 1630 | 1630 | **/  | 
                                                        
| 1631 | 1631 |  function balise_VAL_dist($p) { | 
                                                        
| 1632 | - $p->code = interprete_argument_balise(1, $p);  | 
                                                        |
| 1633 | -	if (!strlen($p->code)) { | 
                                                        |
| 1634 | - $p->code = "''";  | 
                                                        |
| 1635 | - }  | 
                                                        |
| 1636 | - $p->interdire_scripts = false;  | 
                                                        |
| 1632 | + $p->code = interprete_argument_balise(1, $p);  | 
                                                        |
| 1633 | +    if (!strlen($p->code)) { | 
                                                        |
| 1634 | + $p->code = "''";  | 
                                                        |
| 1635 | + }  | 
                                                        |
| 1636 | + $p->interdire_scripts = false;  | 
                                                        |
| 1637 | 1637 | |
| 1638 | - return $p;  | 
                                                        |
| 1638 | + return $p;  | 
                                                        |
| 1639 | 1639 | }  | 
                                                        
| 1640 | 1640 | |
| 1641 | 1641 | /**  | 
                                                        
@@ -1681,10 +1681,10 @@ discard block  | 
                                                    ||
| 1681 | 1681 | * Pile complétée par le code à générer  | 
                                                        
| 1682 | 1682 | **/  | 
                                                        
| 1683 | 1683 |  function balise_REM_dist($p) { | 
                                                        
| 1684 | - $p->code = "''";  | 
                                                        |
| 1685 | - $p->interdire_scripts = false;  | 
                                                        |
| 1684 | + $p->code = "''";  | 
                                                        |
| 1685 | + $p->interdire_scripts = false;  | 
                                                        |
| 1686 | 1686 | |
| 1687 | - return $p;  | 
                                                        |
| 1687 | + return $p;  | 
                                                        |
| 1688 | 1688 | }  | 
                                                        
| 1689 | 1689 | |
| 1690 | 1690 | |
@@ -1708,18 +1708,18 @@ discard block  | 
                                                    ||
| 1708 | 1708 | **/  | 
                                                        
| 1709 | 1709 |  function balise_HTTP_HEADER_dist($p) { | 
                                                        
| 1710 | 1710 | |
| 1711 | - $header = interprete_argument_balise(1, $p);  | 
                                                        |
| 1712 | -	if (!$header) { | 
                                                        |
| 1713 | -		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'HTTP_HEADER')); | 
                                                        |
| 1714 | - erreur_squelette($err_b_s_a, $p);  | 
                                                        |
| 1715 | -	} else { | 
                                                        |
| 1716 | -		$p->code = "'<'.'?php header(' . _q(" | 
                                                        |
| 1717 | - . $header  | 
                                                        |
| 1718 | - . ") . '); ?'.'>'";  | 
                                                        |
| 1719 | - }  | 
                                                        |
| 1720 | - $p->interdire_scripts = false;  | 
                                                        |
| 1711 | + $header = interprete_argument_balise(1, $p);  | 
                                                        |
| 1712 | +    if (!$header) { | 
                                                        |
| 1713 | +        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'HTTP_HEADER')); | 
                                                        |
| 1714 | + erreur_squelette($err_b_s_a, $p);  | 
                                                        |
| 1715 | +    } else { | 
                                                        |
| 1716 | +        $p->code = "'<'.'?php header(' . _q(" | 
                                                        |
| 1717 | + . $header  | 
                                                        |
| 1718 | + . ") . '); ?'.'>'";  | 
                                                        |
| 1719 | + }  | 
                                                        |
| 1720 | + $p->interdire_scripts = false;  | 
                                                        |
| 1721 | 1721 | |
| 1722 | - return $p;  | 
                                                        |
| 1722 | + return $p;  | 
                                                        |
| 1723 | 1723 | }  | 
                                                        
| 1724 | 1724 | |
| 1725 | 1725 | |
@@ -1744,20 +1744,20 @@ discard block  | 
                                                    ||
| 1744 | 1744 | * Pile complétée par le code à générer  | 
                                                        
| 1745 | 1745 | **/  | 
                                                        
| 1746 | 1746 |  function balise_FILTRE_dist($p) { | 
                                                        
| 1747 | -	if ($p->param) { | 
                                                        |
| 1748 | - $args = array();  | 
                                                        |
| 1749 | -		foreach ($p->param as $i => $ignore) { | 
                                                        |
| 1750 | - $args[] = interprete_argument_balise($i + 1, $p);  | 
                                                        |
| 1751 | - }  | 
                                                        |
| 1752 | - $p->code = "'<' . '"  | 
                                                        |
| 1753 | -			. '?php header("X-Spip-Filtre: \'.' | 
                                                        |
| 1754 | -			. join('.\'|\'.', $args) | 
                                                        |
| 1755 | - . " . '\"); ?'.'>'";  | 
                                                        |
| 1747 | +    if ($p->param) { | 
                                                        |
| 1748 | + $args = array();  | 
                                                        |
| 1749 | +        foreach ($p->param as $i => $ignore) { | 
                                                        |
| 1750 | + $args[] = interprete_argument_balise($i + 1, $p);  | 
                                                        |
| 1751 | + }  | 
                                                        |
| 1752 | + $p->code = "'<' . '"  | 
                                                        |
| 1753 | +            . '?php header("X-Spip-Filtre: \'.' | 
                                                        |
| 1754 | +            . join('.\'|\'.', $args) | 
                                                        |
| 1755 | + . " . '\"); ?'.'>'";  | 
                                                        |
| 1756 | 1756 | |
| 1757 | - $p->interdire_scripts = false;  | 
                                                        |
| 1757 | + $p->interdire_scripts = false;  | 
                                                        |
| 1758 | 1758 | |
| 1759 | - return $p;  | 
                                                        |
| 1760 | - }  | 
                                                        |
| 1759 | + return $p;  | 
                                                        |
| 1760 | + }  | 
                                                        |
| 1761 | 1761 | }  | 
                                                        
| 1762 | 1762 | |
| 1763 | 1763 | |
@@ -1793,53 +1793,53 @@ discard block  | 
                                                    ||
| 1793 | 1793 | **/  | 
                                                        
| 1794 | 1794 |  function balise_CACHE_dist($p) { | 
                                                        
| 1795 | 1795 | |
| 1796 | -	if ($p->param) { | 
                                                        |
| 1797 | - $duree = valeur_numerique($p->param[0][1][0]->texte);  | 
                                                        |
| 1798 | -  | 
                                                        |
| 1799 | - // noter la duree du cache dans un entete proprietaire  | 
                                                        |
| 1800 | -  | 
                                                        |
| 1801 | -		$code = "'<'.'" . '?php header("X-Spip-Cache: ' | 
                                                        |
| 1802 | - . $duree  | 
                                                        |
| 1803 | - . '"); ?' . "'.'>'";  | 
                                                        |
| 1804 | -  | 
                                                        |
| 1805 | - // Remplir le header Cache-Control  | 
                                                        |
| 1806 | -		// cas #CACHE{0} | 
                                                        |
| 1807 | -		if ($duree == 0) { | 
                                                        |
| 1808 | - $code .= ".'<'.'"  | 
                                                        |
| 1809 | -				. '?php header("Cache-Control: no-cache, must-revalidate"); ?' | 
                                                        |
| 1810 | - . "'.'><'.'"  | 
                                                        |
| 1811 | -				. '?php header("Pragma: no-cache"); ?' | 
                                                        |
| 1812 | - . "'.'>'";  | 
                                                        |
| 1813 | - }  | 
                                                        |
| 1814 | -  | 
                                                        |
| 1815 | - // recuperer les parametres suivants  | 
                                                        |
| 1816 | - $i = 1;  | 
                                                        |
| 1817 | -		while (isset($p->param[0][++$i])) { | 
                                                        |
| 1818 | - $pa = ($p->param[0][$i][0]->texte);  | 
                                                        |
| 1819 | -  | 
                                                        |
| 1820 | - if ($pa == 'cache-client'  | 
                                                        |
| 1821 | - and $duree > 0  | 
                                                        |
| 1822 | -			) { | 
                                                        |
| 1823 | -				$code .= ".'<'.'" . '?php header("Cache-Control: max-age=' | 
                                                        |
| 1824 | - . $duree  | 
                                                        |
| 1825 | - . '"); ?' . "'.'>'";  | 
                                                        |
| 1826 | - // il semble logique, si on cache-client, de ne pas invalider  | 
                                                        |
| 1827 | - $pa = 'statique';  | 
                                                        |
| 1828 | - }  | 
                                                        |
| 1829 | -  | 
                                                        |
| 1830 | - if ($pa == 'statique'  | 
                                                        |
| 1831 | - and $duree > 0  | 
                                                        |
| 1832 | -			) { | 
                                                        |
| 1833 | -				$code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; | 
                                                        |
| 1834 | - }  | 
                                                        |
| 1835 | - }  | 
                                                        |
| 1836 | -	} else { | 
                                                        |
| 1837 | - $code = "''";  | 
                                                        |
| 1838 | - }  | 
                                                        |
| 1839 | - $p->code = $code;  | 
                                                        |
| 1840 | - $p->interdire_scripts = false;  | 
                                                        |
| 1841 | -  | 
                                                        |
| 1842 | - return $p;  | 
                                                        |
| 1796 | +    if ($p->param) { | 
                                                        |
| 1797 | + $duree = valeur_numerique($p->param[0][1][0]->texte);  | 
                                                        |
| 1798 | +  | 
                                                        |
| 1799 | + // noter la duree du cache dans un entete proprietaire  | 
                                                        |
| 1800 | +  | 
                                                        |
| 1801 | +        $code = "'<'.'" . '?php header("X-Spip-Cache: ' | 
                                                        |
| 1802 | + . $duree  | 
                                                        |
| 1803 | + . '"); ?' . "'.'>'";  | 
                                                        |
| 1804 | +  | 
                                                        |
| 1805 | + // Remplir le header Cache-Control  | 
                                                        |
| 1806 | +        // cas #CACHE{0} | 
                                                        |
| 1807 | +        if ($duree == 0) { | 
                                                        |
| 1808 | + $code .= ".'<'.'"  | 
                                                        |
| 1809 | +                . '?php header("Cache-Control: no-cache, must-revalidate"); ?' | 
                                                        |
| 1810 | + . "'.'><'.'"  | 
                                                        |
| 1811 | +                . '?php header("Pragma: no-cache"); ?' | 
                                                        |
| 1812 | + . "'.'>'";  | 
                                                        |
| 1813 | + }  | 
                                                        |
| 1814 | +  | 
                                                        |
| 1815 | + // recuperer les parametres suivants  | 
                                                        |
| 1816 | + $i = 1;  | 
                                                        |
| 1817 | +        while (isset($p->param[0][++$i])) { | 
                                                        |
| 1818 | + $pa = ($p->param[0][$i][0]->texte);  | 
                                                        |
| 1819 | +  | 
                                                        |
| 1820 | + if ($pa == 'cache-client'  | 
                                                        |
| 1821 | + and $duree > 0  | 
                                                        |
| 1822 | +            ) { | 
                                                        |
| 1823 | +                $code .= ".'<'.'" . '?php header("Cache-Control: max-age=' | 
                                                        |
| 1824 | + . $duree  | 
                                                        |
| 1825 | + . '"); ?' . "'.'>'";  | 
                                                        |
| 1826 | + // il semble logique, si on cache-client, de ne pas invalider  | 
                                                        |
| 1827 | + $pa = 'statique';  | 
                                                        |
| 1828 | + }  | 
                                                        |
| 1829 | +  | 
                                                        |
| 1830 | + if ($pa == 'statique'  | 
                                                        |
| 1831 | + and $duree > 0  | 
                                                        |
| 1832 | +            ) { | 
                                                        |
| 1833 | +                $code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; | 
                                                        |
| 1834 | + }  | 
                                                        |
| 1835 | + }  | 
                                                        |
| 1836 | +    } else { | 
                                                        |
| 1837 | + $code = "''";  | 
                                                        |
| 1838 | + }  | 
                                                        |
| 1839 | + $p->code = $code;  | 
                                                        |
| 1840 | + $p->interdire_scripts = false;  | 
                                                        |
| 1841 | +  | 
                                                        |
| 1842 | + return $p;  | 
                                                        |
| 1843 | 1843 | }  | 
                                                        
| 1844 | 1844 | |
| 1845 | 1845 | |
@@ -1871,13 +1871,13 @@ discard block  | 
                                                    ||
| 1871 | 1871 | * Pile complétée par le code à générer  | 
                                                        
| 1872 | 1872 | */  | 
                                                        
| 1873 | 1873 |  function balise_INSERT_HEAD_dist($p) { | 
                                                        
| 1874 | - $p->code = "'<'.'"  | 
                                                        |
| 1875 | -		. '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?' | 
                                                        |
| 1876 | - . "'.'>'";  | 
                                                        |
| 1877 | -	$p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; | 
                                                        |
| 1878 | - $p->interdire_scripts = false;  | 
                                                        |
| 1874 | + $p->code = "'<'.'"  | 
                                                        |
| 1875 | +        . '?php header("X-Spip-Filtre: insert_head_css_conditionnel"); ?' | 
                                                        |
| 1876 | + . "'.'>'";  | 
                                                        |
| 1877 | +    $p->code .= ". pipeline('insert_head','<!-- insert_head -->')"; | 
                                                        |
| 1878 | + $p->interdire_scripts = false;  | 
                                                        |
| 1879 | 1879 | |
| 1880 | - return $p;  | 
                                                        |
| 1880 | + return $p;  | 
                                                        |
| 1881 | 1881 | }  | 
                                                        
| 1882 | 1882 | |
| 1883 | 1883 | /**  | 
                                                        
@@ -1895,10 +1895,10 @@ discard block  | 
                                                    ||
| 1895 | 1895 | * Pile complétée par le code à générer  | 
                                                        
| 1896 | 1896 | */  | 
                                                        
| 1897 | 1897 |  function balise_INSERT_HEAD_CSS_dist($p) { | 
                                                        
| 1898 | -	$p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; | 
                                                        |
| 1899 | - $p->interdire_scripts = false;  | 
                                                        |
| 1898 | +    $p->code = "pipeline('insert_head_css','<!-- insert_head_css -->')"; | 
                                                        |
| 1899 | + $p->interdire_scripts = false;  | 
                                                        |
| 1900 | 1900 | |
| 1901 | - return $p;  | 
                                                        |
| 1901 | + return $p;  | 
                                                        |
| 1902 | 1902 | }  | 
                                                        
| 1903 | 1903 | |
| 1904 | 1904 | /**  | 
                                                        
@@ -1913,11 +1913,11 @@ discard block  | 
                                                    ||
| 1913 | 1913 | * Pile complétée par le code à générer  | 
                                                        
| 1914 | 1914 | **/  | 
                                                        
| 1915 | 1915 |  function balise_INCLUDE_dist($p) { | 
                                                        
| 1916 | -	if (function_exists('balise_INCLURE')) { | 
                                                        |
| 1917 | - return balise_INCLURE($p);  | 
                                                        |
| 1918 | -	} else { | 
                                                        |
| 1919 | - return balise_INCLURE_dist($p);  | 
                                                        |
| 1920 | - }  | 
                                                        |
| 1916 | +    if (function_exists('balise_INCLURE')) { | 
                                                        |
| 1917 | + return balise_INCLURE($p);  | 
                                                        |
| 1918 | +    } else { | 
                                                        |
| 1919 | + return balise_INCLURE_dist($p);  | 
                                                        |
| 1920 | + }  | 
                                                        |
| 1921 | 1921 | }  | 
                                                        
| 1922 | 1922 | |
| 1923 | 1923 | /**  | 
                                                        
@@ -1951,72 +1951,72 @@ discard block  | 
                                                    ||
| 1951 | 1951 | * Pile complétée par le code à générer  | 
                                                        
| 1952 | 1952 | **/  | 
                                                        
| 1953 | 1953 |  function balise_INCLURE_dist($p) { | 
                                                        
| 1954 | - $id_boucle = $p->id_boucle;  | 
                                                        |
| 1955 | - // la lang n'est pas passe de facon automatique par argumenter  | 
                                                        |
| 1956 | - // mais le sera pas recuperer_fond, sauf si etoile=>true est passe  | 
                                                        |
| 1957 | - // en option  | 
                                                        |
| 1954 | + $id_boucle = $p->id_boucle;  | 
                                                        |
| 1955 | + // la lang n'est pas passe de facon automatique par argumenter  | 
                                                        |
| 1956 | + // mais le sera pas recuperer_fond, sauf si etoile=>true est passe  | 
                                                        |
| 1957 | + // en option  | 
                                                        |
| 1958 | 1958 | |
| 1959 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false);  | 
                                                        |
| 1959 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $id_boucle, false, false);  | 
                                                        |
| 1960 | 1960 | |
| 1961 | - // erreur de syntaxe = fond absent  | 
                                                        |
| 1962 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP  | 
                                                        |
| 1963 | -	if (!$_contexte) { | 
                                                        |
| 1964 | - $contexte = array();  | 
                                                        |
| 1965 | - }  | 
                                                        |
| 1961 | + // erreur de syntaxe = fond absent  | 
                                                        |
| 1962 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP  | 
                                                        |
| 1963 | +    if (!$_contexte) { | 
                                                        |
| 1964 | + $contexte = array();  | 
                                                        |
| 1965 | + }  | 
                                                        |
| 1966 | 1966 | |
| 1967 | -	if (isset($_contexte['fond'])) { | 
                                                        |
| 1967 | +    if (isset($_contexte['fond'])) { | 
                                                        |
| 1968 | 1968 | |
| 1969 | - $f = $_contexte['fond'];  | 
                                                        |
| 1970 | - // toujours vrai :  | 
                                                        |
| 1971 | -		if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { | 
                                                        |
| 1972 | - $f = $r[1];  | 
                                                        |
| 1973 | - unset($_contexte['fond']);  | 
                                                        |
| 1974 | -		} else { | 
                                                        |
| 1975 | -			spip_log("compilation de #INCLURE a revoir"); | 
                                                        |
| 1976 | - }  | 
                                                        |
| 1969 | + $f = $_contexte['fond'];  | 
                                                        |
| 1970 | + // toujours vrai :  | 
                                                        |
| 1971 | +        if (preg_match('/^.fond.\s*=>(.*)$/s', $f, $r)) { | 
                                                        |
| 1972 | + $f = $r[1];  | 
                                                        |
| 1973 | + unset($_contexte['fond']);  | 
                                                        |
| 1974 | +        } else { | 
                                                        |
| 1975 | +            spip_log("compilation de #INCLURE a revoir"); | 
                                                        |
| 1976 | + }  | 
                                                        |
| 1977 | 1977 | |
| 1978 | -		// #INCLURE{doublons} | 
                                                        |
| 1979 | -		if (isset($_contexte['doublons'])) { | 
                                                        |
| 1980 | - $_contexte['doublons'] = "'doublons' => \$doublons";  | 
                                                        |
| 1981 | - }  | 
                                                        |
| 1978 | +        // #INCLURE{doublons} | 
                                                        |
| 1979 | +        if (isset($_contexte['doublons'])) { | 
                                                        |
| 1980 | + $_contexte['doublons'] = "'doublons' => \$doublons";  | 
                                                        |
| 1981 | + }  | 
                                                        |
| 1982 | 1982 | |
| 1983 | -		// Critere d'inclusion {env} (et {self} pour compatibilite ascendante) | 
                                                        |
| 1984 | - $flag_env = false;  | 
                                                        |
| 1985 | -		if (isset($_contexte['env']) or isset($_contexte['self'])) { | 
                                                        |
| 1986 | - $flag_env = true;  | 
                                                        |
| 1987 | - unset($_contexte['env']);  | 
                                                        |
| 1988 | - }  | 
                                                        |
| 1983 | +        // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) | 
                                                        |
| 1984 | + $flag_env = false;  | 
                                                        |
| 1985 | +        if (isset($_contexte['env']) or isset($_contexte['self'])) { | 
                                                        |
| 1986 | + $flag_env = true;  | 
                                                        |
| 1987 | + unset($_contexte['env']);  | 
                                                        |
| 1988 | + }  | 
                                                        |
| 1989 | 1989 | |
| 1990 | - $_options = array();  | 
                                                        |
| 1990 | + $_options = array();  | 
                                                        |
| 1991 | 1991 | |
| 1992 | - // Fix #4235 : sessionner le contexte appelant si cette inclusion statique est sessionnée  | 
                                                        |
| 1993 | - $_options[] = "'sessionnement_contaminant'=>true";  | 
                                                        |
| 1992 | + // Fix #4235 : sessionner le contexte appelant si cette inclusion statique est sessionnée  | 
                                                        |
| 1993 | + $_options[] = "'sessionnement_contaminant'=>true";  | 
                                                        |
| 1994 | 1994 | |
| 1995 | -		if (isset($_contexte['ajax'])) { | 
                                                        |
| 1996 | -			$_options[] = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); | 
                                                        |
| 1997 | - unset($_contexte['ajax']);  | 
                                                        |
| 1998 | - }  | 
                                                        |
| 1999 | -		if ($p->etoile) { | 
                                                        |
| 2000 | - $_options[] = "'etoile'=>true";  | 
                                                        |
| 2001 | - }  | 
                                                        |
| 2002 | -		$_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")"; | 
                                                        |
| 1995 | +        if (isset($_contexte['ajax'])) { | 
                                                        |
| 1996 | +            $_options[] = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); | 
                                                        |
| 1997 | + unset($_contexte['ajax']);  | 
                                                        |
| 1998 | + }  | 
                                                        |
| 1999 | +        if ($p->etoile) { | 
                                                        |
| 2000 | + $_options[] = "'etoile'=>true";  | 
                                                        |
| 2001 | + }  | 
                                                        |
| 2002 | +        $_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")"; | 
                                                        |
| 2003 | 2003 | |
| 2004 | -		$_l = 'array(' . join(",\n\t", $_contexte) . ')'; | 
                                                        |
| 2005 | -		if ($flag_env) { | 
                                                        |
| 2006 | - $_l = "array_merge(\$Pile[0],$_l)";  | 
                                                        |
| 2007 | - }  | 
                                                        |
| 2004 | +        $_l = 'array(' . join(",\n\t", $_contexte) . ')'; | 
                                                        |
| 2005 | +        if ($flag_env) { | 
                                                        |
| 2006 | + $_l = "array_merge(\$Pile[0],$_l)";  | 
                                                        |
| 2007 | + }  | 
                                                        |
| 2008 | 2008 | |
| 2009 | -		$p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect')"); | 
                                                        |
| 2009 | +        $p->code = sprintf(CODE_RECUPERER_FOND, $f, $_l, join(',', $_options), "_request('connect')"); | 
                                                        |
| 2010 | 2010 | |
| 2011 | -	} elseif (!isset($_contexte[1])) { | 
                                                        |
| 2012 | -		$msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE')); | 
                                                        |
| 2013 | - erreur_squelette($msg, $p);  | 
                                                        |
| 2014 | -	} else { | 
                                                        |
| 2015 | -		$p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; | 
                                                        |
| 2016 | - }  | 
                                                        |
| 2011 | +    } elseif (!isset($_contexte[1])) { | 
                                                        |
| 2012 | +        $msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE')); | 
                                                        |
| 2013 | + erreur_squelette($msg, $p);  | 
                                                        |
| 2014 | +    } else { | 
                                                        |
| 2015 | +        $p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; | 
                                                        |
| 2016 | + }  | 
                                                        |
| 2017 | 2017 | |
| 2018 | - $p->interdire_scripts = false; // la securite est assuree par recuperer_fond  | 
                                                        |
| 2019 | - return $p;  | 
                                                        |
| 2018 | + $p->interdire_scripts = false; // la securite est assuree par recuperer_fond  | 
                                                        |
| 2019 | + return $p;  | 
                                                        |
| 2020 | 2020 | }  | 
                                                        
| 2021 | 2021 | |
| 2022 | 2022 | |
@@ -2044,71 +2044,71 @@ discard block  | 
                                                    ||
| 2044 | 2044 | **/  | 
                                                        
| 2045 | 2045 |  function balise_MODELE_dist($p) { | 
                                                        
| 2046 | 2046 | |
| 2047 | - $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false);  | 
                                                        |
| 2048 | -  | 
                                                        |
| 2049 | - // erreur de syntaxe = fond absent  | 
                                                        |
| 2050 | - // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP  | 
                                                        |
| 2051 | -	if (!$_contexte) { | 
                                                        |
| 2052 | - $_contexte = array();  | 
                                                        |
| 2053 | - }  | 
                                                        |
| 2054 | -  | 
                                                        |
| 2055 | -	if (!isset($_contexte[1])) { | 
                                                        |
| 2056 | -		$msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE')); | 
                                                        |
| 2057 | - erreur_squelette($msg, $p);  | 
                                                        |
| 2058 | -	} else { | 
                                                        |
| 2059 | - $nom = $_contexte[1];  | 
                                                        |
| 2060 | - unset($_contexte[1]);  | 
                                                        |
| 2061 | -  | 
                                                        |
| 2062 | -		if (preg_match("/^\s*'[^']*'/s", $nom)) { | 
                                                        |
| 2063 | - $nom = "'modeles/" . substr($nom, 1);  | 
                                                        |
| 2064 | -		} else { | 
                                                        |
| 2065 | - $nom = "'modeles/' . $nom";  | 
                                                        |
| 2066 | - }  | 
                                                        |
| 2067 | -  | 
                                                        |
| 2068 | - $flag_env = false;  | 
                                                        |
| 2069 | -		if (isset($_contexte['env'])) { | 
                                                        |
| 2070 | - $flag_env = true;  | 
                                                        |
| 2071 | - unset($_contexte['env']);  | 
                                                        |
| 2072 | - }  | 
                                                        |
| 2073 | -  | 
                                                        |
| 2074 | - // Incoherence dans la syntaxe du contexte. A revoir.  | 
                                                        |
| 2075 | - // Reserver la cle primaire de la boucle courante si elle existe  | 
                                                        |
| 2076 | -		if (isset($p->boucles[$p->id_boucle]->primary)) { | 
                                                        |
| 2077 | - $primary = $p->boucles[$p->id_boucle]->primary;  | 
                                                        |
| 2078 | -			if (!strpos($primary, ',')) { | 
                                                        |
| 2079 | - $id = champ_sql($primary, $p);  | 
                                                        |
| 2080 | - $_contexte[] = "'$primary'=>" . $id;  | 
                                                        |
| 2081 | - $_contexte[] = "'id'=>" . $id;  | 
                                                        |
| 2082 | - }  | 
                                                        |
| 2083 | - }  | 
                                                        |
| 2084 | - $_contexte[] = "'recurs'=>(++\$recurs)";  | 
                                                        |
| 2085 | - $connect = '';  | 
                                                        |
| 2086 | -		if (isset($p->boucles[$p->id_boucle])) { | 
                                                        |
| 2087 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur;  | 
                                                        |
| 2088 | - }  | 
                                                        |
| 2089 | -  | 
                                                        |
| 2090 | - $_options = memoriser_contexte_compil($p);  | 
                                                        |
| 2091 | - // Fix #4235 : sessionner le contexte appelant si ce modèle est sessionné  | 
                                                        |
| 2092 | - $_options = "'compil'=>array($_options), 'trim'=>true, 'sessionnement_contaminant'=>true";  | 
                                                        |
| 2047 | + $_contexte = argumenter_inclure($p->param, true, $p, $p->boucles, $p->id_boucle, false);  | 
                                                        |
| 2048 | +  | 
                                                        |
| 2049 | + // erreur de syntaxe = fond absent  | 
                                                        |
| 2050 | + // (2 messages d'erreur SPIP pour le prix d'un, mais pas d'erreur PHP  | 
                                                        |
| 2051 | +    if (!$_contexte) { | 
                                                        |
| 2052 | + $_contexte = array();  | 
                                                        |
| 2053 | + }  | 
                                                        |
| 2054 | +  | 
                                                        |
| 2055 | +    if (!isset($_contexte[1])) { | 
                                                        |
| 2056 | +        $msg = array('zbug_balise_sans_argument', array('balise' => ' MODELE')); | 
                                                        |
| 2057 | + erreur_squelette($msg, $p);  | 
                                                        |
| 2058 | +    } else { | 
                                                        |
| 2059 | + $nom = $_contexte[1];  | 
                                                        |
| 2060 | + unset($_contexte[1]);  | 
                                                        |
| 2061 | +  | 
                                                        |
| 2062 | +        if (preg_match("/^\s*'[^']*'/s", $nom)) { | 
                                                        |
| 2063 | + $nom = "'modeles/" . substr($nom, 1);  | 
                                                        |
| 2064 | +        } else { | 
                                                        |
| 2065 | + $nom = "'modeles/' . $nom";  | 
                                                        |
| 2066 | + }  | 
                                                        |
| 2067 | +  | 
                                                        |
| 2068 | + $flag_env = false;  | 
                                                        |
| 2069 | +        if (isset($_contexte['env'])) { | 
                                                        |
| 2070 | + $flag_env = true;  | 
                                                        |
| 2071 | + unset($_contexte['env']);  | 
                                                        |
| 2072 | + }  | 
                                                        |
| 2073 | +  | 
                                                        |
| 2074 | + // Incoherence dans la syntaxe du contexte. A revoir.  | 
                                                        |
| 2075 | + // Reserver la cle primaire de la boucle courante si elle existe  | 
                                                        |
| 2076 | +        if (isset($p->boucles[$p->id_boucle]->primary)) { | 
                                                        |
| 2077 | + $primary = $p->boucles[$p->id_boucle]->primary;  | 
                                                        |
| 2078 | +            if (!strpos($primary, ',')) { | 
                                                        |
| 2079 | + $id = champ_sql($primary, $p);  | 
                                                        |
| 2080 | + $_contexte[] = "'$primary'=>" . $id;  | 
                                                        |
| 2081 | + $_contexte[] = "'id'=>" . $id;  | 
                                                        |
| 2082 | + }  | 
                                                        |
| 2083 | + }  | 
                                                        |
| 2084 | + $_contexte[] = "'recurs'=>(++\$recurs)";  | 
                                                        |
| 2085 | + $connect = '';  | 
                                                        |
| 2086 | +        if (isset($p->boucles[$p->id_boucle])) { | 
                                                        |
| 2087 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur;  | 
                                                        |
| 2088 | + }  | 
                                                        |
| 2089 | +  | 
                                                        |
| 2090 | + $_options = memoriser_contexte_compil($p);  | 
                                                        |
| 2091 | + // Fix #4235 : sessionner le contexte appelant si ce modèle est sessionné  | 
                                                        |
| 2092 | + $_options = "'compil'=>array($_options), 'trim'=>true, 'sessionnement_contaminant'=>true";  | 
                                                        |
| 2093 | 2093 | |
| 2094 | -		if (isset($_contexte['ajax'])) { | 
                                                        |
| 2095 | -			$_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); | 
                                                        |
| 2096 | - unset($_contexte['ajax']);  | 
                                                        |
| 2097 | - }  | 
                                                        |
| 2094 | +        if (isset($_contexte['ajax'])) { | 
                                                        |
| 2095 | +            $_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); | 
                                                        |
| 2096 | + unset($_contexte['ajax']);  | 
                                                        |
| 2097 | + }  | 
                                                        |
| 2098 | 2098 | |
| 2099 | -		$_l = 'array(' . join(",\n\t", $_contexte) . ')'; | 
                                                        |
| 2100 | -		if ($flag_env) { | 
                                                        |
| 2101 | - $_l = "array_merge(\$Pile[0],$_l)";  | 
                                                        |
| 2102 | - }  | 
                                                        |
| 2099 | +        $_l = 'array(' . join(",\n\t", $_contexte) . ')'; | 
                                                        |
| 2100 | +        if ($flag_env) { | 
                                                        |
| 2101 | + $_l = "array_merge(\$Pile[0],$_l)";  | 
                                                        |
| 2102 | + }  | 
                                                        |
| 2103 | 2103 | |
| 2104 | - $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect));  | 
                                                        |
| 2104 | + $page = sprintf(CODE_RECUPERER_FOND, $nom, $_l, $_options, _q($connect));  | 
                                                        |
| 2105 | 2105 | |
| 2106 | - $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n";  | 
                                                        |
| 2106 | + $p->code = "\n\t(((\$recurs=(isset(\$Pile[0]['recurs'])?\$Pile[0]['recurs']:0))>=5)? '' :\n\t$page)\n";  | 
                                                        |
| 2107 | 2107 | |
| 2108 | - $p->interdire_scripts = false; // securite assuree par le squelette  | 
                                                        |
| 2109 | - }  | 
                                                        |
| 2108 | + $p->interdire_scripts = false; // securite assuree par le squelette  | 
                                                        |
| 2109 | + }  | 
                                                        |
| 2110 | 2110 | |
| 2111 | - return $p;  | 
                                                        |
| 2111 | + return $p;  | 
                                                        |
| 2112 | 2112 | }  | 
                                                        
| 2113 | 2113 | |
| 2114 | 2114 | |
@@ -2132,21 +2132,21 @@ discard block  | 
                                                    ||
| 2132 | 2132 | * Pile complétée par le code à générer  | 
                                                        
| 2133 | 2133 | **/  | 
                                                        
| 2134 | 2134 |  function balise_SET_dist($p) { | 
                                                        
| 2135 | - $_nom = interprete_argument_balise(1, $p);  | 
                                                        |
| 2136 | - $_val = interprete_argument_balise(2, $p);  | 
                                                        |
| 2135 | + $_nom = interprete_argument_balise(1, $p);  | 
                                                        |
| 2136 | + $_val = interprete_argument_balise(2, $p);  | 
                                                        |
| 2137 | 2137 | |
| 2138 | -	if (!$_nom or !$_val) { | 
                                                        |
| 2139 | -		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET')); | 
                                                        |
| 2140 | - erreur_squelette($err_b_s_a, $p);  | 
                                                        |
| 2141 | - }  | 
                                                        |
| 2142 | - // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4  | 
                                                        |
| 2143 | - // cf https://bugs.php.net/bug.php?id=65845  | 
                                                        |
| 2144 | -	else { | 
                                                        |
| 2145 | - $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)";  | 
                                                        |
| 2146 | - }  | 
                                                        |
| 2138 | +    if (!$_nom or !$_val) { | 
                                                        |
| 2139 | +        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SET')); | 
                                                        |
| 2140 | + erreur_squelette($err_b_s_a, $p);  | 
                                                        |
| 2141 | + }  | 
                                                        |
| 2142 | + // affectation $_zzz inutile, mais permet de contourner un bug OpCode cache sous PHP 5.5.4  | 
                                                        |
| 2143 | + // cf https://bugs.php.net/bug.php?id=65845  | 
                                                        |
| 2144 | +    else { | 
                                                        |
| 2145 | + $p->code = "vide(\$Pile['vars'][\$_zzz=(string)$_nom] = $_val)";  | 
                                                        |
| 2146 | + }  | 
                                                        |
| 2147 | 2147 | |
| 2148 | - $p->interdire_scripts = false; // la balise ne renvoie rien  | 
                                                        |
| 2149 | - return $p;  | 
                                                        |
| 2148 | + $p->interdire_scripts = false; // la balise ne renvoie rien  | 
                                                        |
| 2149 | + return $p;  | 
                                                        |
| 2150 | 2150 | }  | 
                                                        
| 2151 | 2151 | |
| 2152 | 2152 | |
@@ -2176,12 +2176,12 @@ discard block  | 
                                                    ||
| 2176 | 2176 | * Pile complétée par le code à générer  | 
                                                        
| 2177 | 2177 | **/  | 
                                                        
| 2178 | 2178 |  function balise_GET_dist($p) { | 
                                                        
| 2179 | - $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance  | 
                                                        |
| 2180 | -	if (function_exists('balise_ENV')) { | 
                                                        |
| 2181 | - return balise_ENV($p, '$Pile["vars"]');  | 
                                                        |
| 2182 | -	} else { | 
                                                        |
| 2183 | - return balise_ENV_dist($p, '$Pile["vars"]');  | 
                                                        |
| 2184 | - }  | 
                                                        |
| 2179 | + $p->interdire_scripts = false; // le contenu vient de #SET, donc il est de confiance  | 
                                                        |
| 2180 | +    if (function_exists('balise_ENV')) { | 
                                                        |
| 2181 | + return balise_ENV($p, '$Pile["vars"]');  | 
                                                        |
| 2182 | +    } else { | 
                                                        |
| 2183 | + return balise_ENV_dist($p, '$Pile["vars"]');  | 
                                                        |
| 2184 | + }  | 
                                                        |
| 2185 | 2185 | }  | 
                                                        
| 2186 | 2186 | |
| 2187 | 2187 | |
@@ -2204,22 +2204,22 @@ discard block  | 
                                                    ||
| 2204 | 2204 | * Pile complétée par le code à générer  | 
                                                        
| 2205 | 2205 | **/  | 
                                                        
| 2206 | 2206 |  function balise_DOUBLONS_dist($p) { | 
                                                        
| 2207 | -	if ($type = interprete_argument_balise(1, $p)) { | 
                                                        |
| 2208 | -		if ($famille = interprete_argument_balise(2, $p)) { | 
                                                        |
| 2209 | - $type .= '.' . $famille;  | 
                                                        |
| 2210 | - }  | 
                                                        |
| 2211 | - $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")';  | 
                                                        |
| 2212 | -		if (!$p->etoile) { | 
                                                        |
| 2213 | -			$p->code = 'array_filter(array_map("intval",explode(",",' | 
                                                        |
| 2214 | - . $p->code . ')))';  | 
                                                        |
| 2215 | - }  | 
                                                        |
| 2216 | -	} else { | 
                                                        |
| 2217 | - $p->code = '$doublons';  | 
                                                        |
| 2218 | - }  | 
                                                        |
| 2207 | +    if ($type = interprete_argument_balise(1, $p)) { | 
                                                        |
| 2208 | +        if ($famille = interprete_argument_balise(2, $p)) { | 
                                                        |
| 2209 | + $type .= '.' . $famille;  | 
                                                        |
| 2210 | + }  | 
                                                        |
| 2211 | + $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")';  | 
                                                        |
| 2212 | +        if (!$p->etoile) { | 
                                                        |
| 2213 | +            $p->code = 'array_filter(array_map("intval",explode(",",' | 
                                                        |
| 2214 | + . $p->code . ')))';  | 
                                                        |
| 2215 | + }  | 
                                                        |
| 2216 | +    } else { | 
                                                        |
| 2217 | + $p->code = '$doublons';  | 
                                                        |
| 2218 | + }  | 
                                                        |
| 2219 | 2219 | |
| 2220 | - $p->interdire_scripts = false;  | 
                                                        |
| 2220 | + $p->interdire_scripts = false;  | 
                                                        |
| 2221 | 2221 | |
| 2222 | - return $p;  | 
                                                        |
| 2222 | + return $p;  | 
                                                        |
| 2223 | 2223 | }  | 
                                                        
| 2224 | 2224 | |
| 2225 | 2225 | |
@@ -2242,18 +2242,18 @@ discard block  | 
                                                    ||
| 2242 | 2242 | * Pile complétée par le code à générer  | 
                                                        
| 2243 | 2243 | **/  | 
                                                        
| 2244 | 2244 |  function balise_PIPELINE_dist($p) { | 
                                                        
| 2245 | - $_pipe = interprete_argument_balise(1, $p);  | 
                                                        |
| 2246 | -	if (!$_pipe) { | 
                                                        |
| 2247 | -		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE')); | 
                                                        |
| 2248 | - erreur_squelette($err_b_s_a, $p);  | 
                                                        |
| 2249 | -	} else { | 
                                                        |
| 2250 | - $_flux = interprete_argument_balise(2, $p);  | 
                                                        |
| 2251 | - $_flux = $_flux ? $_flux : "''";  | 
                                                        |
| 2252 | - $p->code = "pipeline( $_pipe , $_flux )";  | 
                                                        |
| 2253 | - $p->interdire_scripts = false;  | 
                                                        |
| 2254 | - }  | 
                                                        |
| 2245 | + $_pipe = interprete_argument_balise(1, $p);  | 
                                                        |
| 2246 | +    if (!$_pipe) { | 
                                                        |
| 2247 | +        $err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'PIPELINE')); | 
                                                        |
| 2248 | + erreur_squelette($err_b_s_a, $p);  | 
                                                        |
| 2249 | +    } else { | 
                                                        |
| 2250 | + $_flux = interprete_argument_balise(2, $p);  | 
                                                        |
| 2251 | + $_flux = $_flux ? $_flux : "''";  | 
                                                        |
| 2252 | + $p->code = "pipeline( $_pipe , $_flux )";  | 
                                                        |
| 2253 | + $p->interdire_scripts = false;  | 
                                                        |
| 2254 | + }  | 
                                                        |
| 2255 | 2255 | |
| 2256 | - return $p;  | 
                                                        |
| 2256 | + return $p;  | 
                                                        |
| 2257 | 2257 | }  | 
                                                        
| 2258 | 2258 | |
| 2259 | 2259 | |
@@ -2278,10 +2278,10 @@ discard block  | 
                                                    ||
| 2278 | 2278 | * Pile complétée par le code à générer  | 
                                                        
| 2279 | 2279 | **/  | 
                                                        
| 2280 | 2280 |  function balise_EDIT_dist($p) { | 
                                                        
| 2281 | - $p->code = "''";  | 
                                                        |
| 2282 | - $p->interdire_scripts = false;  | 
                                                        |
| 2281 | + $p->code = "''";  | 
                                                        |
| 2282 | + $p->interdire_scripts = false;  | 
                                                        |
| 2283 | 2283 | |
| 2284 | - return $p;  | 
                                                        |
| 2284 | + return $p;  | 
                                                        |
| 2285 | 2285 | }  | 
                                                        
| 2286 | 2286 | |
| 2287 | 2287 | |
@@ -2304,11 +2304,11 @@ discard block  | 
                                                    ||
| 2304 | 2304 | * Pile complétée par le code à générer  | 
                                                        
| 2305 | 2305 | **/  | 
                                                        
| 2306 | 2306 |  function balise_TOTAL_UNIQUE_dist($p) { | 
                                                        
| 2307 | - $_famille = interprete_argument_balise(1, $p);  | 
                                                        |
| 2308 | - $_famille = $_famille ? $_famille : "''";  | 
                                                        |
| 2309 | -	$p->code = "unique('', $_famille, true)"; | 
                                                        |
| 2307 | + $_famille = interprete_argument_balise(1, $p);  | 
                                                        |
| 2308 | + $_famille = $_famille ? $_famille : "''";  | 
                                                        |
| 2309 | +    $p->code = "unique('', $_famille, true)"; | 
                                                        |
| 2310 | 2310 | |
| 2311 | - return $p;  | 
                                                        |
| 2311 | + return $p;  | 
                                                        |
| 2312 | 2312 | }  | 
                                                        
| 2313 | 2313 | |
| 2314 | 2314 | /**  | 
                                                        
@@ -2331,19 +2331,19 @@ discard block  | 
                                                    ||
| 2331 | 2331 | * Pile complétée par le code à générer  | 
                                                        
| 2332 | 2332 | **/  | 
                                                        
| 2333 | 2333 |  function balise_ARRAY_dist($p) { | 
                                                        
| 2334 | - $_code = array();  | 
                                                        |
| 2335 | - $n = 1;  | 
                                                        |
| 2336 | -	do { | 
                                                        |
| 2337 | - $_key = interprete_argument_balise($n++, $p);  | 
                                                        |
| 2338 | - $_val = interprete_argument_balise($n++, $p);  | 
                                                        |
| 2339 | -		if ($_key and $_val) { | 
                                                        |
| 2340 | - $_code[] = "$_key => $_val";  | 
                                                        |
| 2341 | - }  | 
                                                        |
| 2342 | - } while ($_key && $_val);  | 
                                                        |
| 2343 | -	$p->code = 'array(' . join(', ', $_code) . ')'; | 
                                                        |
| 2344 | - $p->interdire_scripts = false;  | 
                                                        |
| 2334 | + $_code = array();  | 
                                                        |
| 2335 | + $n = 1;  | 
                                                        |
| 2336 | +    do { | 
                                                        |
| 2337 | + $_key = interprete_argument_balise($n++, $p);  | 
                                                        |
| 2338 | + $_val = interprete_argument_balise($n++, $p);  | 
                                                        |
| 2339 | +        if ($_key and $_val) { | 
                                                        |
| 2340 | + $_code[] = "$_key => $_val";  | 
                                                        |
| 2341 | + }  | 
                                                        |
| 2342 | + } while ($_key && $_val);  | 
                                                        |
| 2343 | +    $p->code = 'array(' . join(', ', $_code) . ')'; | 
                                                        |
| 2344 | + $p->interdire_scripts = false;  | 
                                                        |
| 2345 | 2345 | |
| 2346 | - return $p;  | 
                                                        |
| 2346 | + return $p;  | 
                                                        |
| 2347 | 2347 | }  | 
                                                        
| 2348 | 2348 | |
| 2349 | 2349 | /**  | 
                                                        
@@ -2362,15 +2362,15 @@ discard block  | 
                                                    ||
| 2362 | 2362 | * Pile complétée par le code à générer  | 
                                                        
| 2363 | 2363 | */  | 
                                                        
| 2364 | 2364 |  function balise_LISTE_dist($p) { | 
                                                        
| 2365 | - $_code = array();  | 
                                                        |
| 2366 | - $n = 1;  | 
                                                        |
| 2367 | -	while ($_val = interprete_argument_balise($n++, $p)) { | 
                                                        |
| 2368 | - $_code[] = $_val;  | 
                                                        |
| 2369 | - }  | 
                                                        |
| 2370 | -	$p->code = 'array(' . join(', ', $_code) . ')'; | 
                                                        |
| 2371 | - $p->interdire_scripts = false;  | 
                                                        |
| 2365 | + $_code = array();  | 
                                                        |
| 2366 | + $n = 1;  | 
                                                        |
| 2367 | +    while ($_val = interprete_argument_balise($n++, $p)) { | 
                                                        |
| 2368 | + $_code[] = $_val;  | 
                                                        |
| 2369 | + }  | 
                                                        |
| 2370 | +    $p->code = 'array(' . join(', ', $_code) . ')'; | 
                                                        |
| 2371 | + $p->interdire_scripts = false;  | 
                                                        |
| 2372 | 2372 | |
| 2373 | - return $p;  | 
                                                        |
| 2373 | + return $p;  | 
                                                        |
| 2374 | 2374 | }  | 
                                                        
| 2375 | 2375 | |
| 2376 | 2376 | |
@@ -2404,19 +2404,19 @@ discard block  | 
                                                    ||
| 2404 | 2404 | * Pile complétée par le code à générer  | 
                                                        
| 2405 | 2405 | **/  | 
                                                        
| 2406 | 2406 |  function balise_AUTORISER_dist($p) { | 
                                                        
| 2407 | - $_code = array();  | 
                                                        |
| 2408 | - $p->descr['session'] = true; // faire un cache par session  | 
                                                        |
| 2407 | + $_code = array();  | 
                                                        |
| 2408 | + $p->descr['session'] = true; // faire un cache par session  | 
                                                        |
| 2409 | 2409 | |
| 2410 | - $n = 1;  | 
                                                        |
| 2411 | -	while ($_v = interprete_argument_balise($n++, $p)) { | 
                                                        |
| 2412 | - $_code[] = $_v;  | 
                                                        |
| 2413 | - }  | 
                                                        |
| 2410 | + $n = 1;  | 
                                                        |
| 2411 | +    while ($_v = interprete_argument_balise($n++, $p)) { | 
                                                        |
| 2412 | + $_code[] = $_v;  | 
                                                        |
| 2413 | + }  | 
                                                        |
| 2414 | 2414 | |
| 2415 | -	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ', | 
                                                        |
| 2416 | - $_code) . ')?" ":"")';  | 
                                                        |
| 2417 | - $p->interdire_scripts = false;  | 
                                                        |
| 2415 | +    $p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ', | 
                                                        |
| 2416 | + $_code) . ')?" ":"")';  | 
                                                        |
| 2417 | + $p->interdire_scripts = false;  | 
                                                        |
| 2418 | 2418 | |
| 2419 | - return $p;  | 
                                                        |
| 2419 | + return $p;  | 
                                                        |
| 2420 | 2420 | }  | 
                                                        
| 2421 | 2421 | |
| 2422 | 2422 | |
@@ -2440,15 +2440,15 @@ discard block  | 
                                                    ||
| 2440 | 2440 | * Pile complétée par le code à générer  | 
                                                        
| 2441 | 2441 | **/  | 
                                                        
| 2442 | 2442 |  function balise_PLUGIN_dist($p) { | 
                                                        
| 2443 | - $plugin = interprete_argument_balise(1, $p);  | 
                                                        |
| 2444 | -	$plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; | 
                                                        |
| 2445 | - $type_info = interprete_argument_balise(2, $p);  | 
                                                        |
| 2446 | -	$type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; | 
                                                        |
| 2443 | + $plugin = interprete_argument_balise(1, $p);  | 
                                                        |
| 2444 | +    $plugin = isset($plugin) ? str_replace('\'', '"', $plugin) : '""'; | 
                                                        |
| 2445 | + $type_info = interprete_argument_balise(2, $p);  | 
                                                        |
| 2446 | +    $type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; | 
                                                        |
| 2447 | 2447 | |
| 2448 | -	$f = chercher_filtre('info_plugin'); | 
                                                        |
| 2449 | -	$p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; | 
                                                        |
| 2448 | +    $f = chercher_filtre('info_plugin'); | 
                                                        |
| 2449 | +    $p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; | 
                                                        |
| 2450 | 2450 | |
| 2451 | - return $p;  | 
                                                        |
| 2451 | + return $p;  | 
                                                        |
| 2452 | 2452 | }  | 
                                                        
| 2453 | 2453 | |
| 2454 | 2454 | /**  | 
                                                        
@@ -2469,11 +2469,11 @@ discard block  | 
                                                    ||
| 2469 | 2469 | * Pile complétée par le code à générer  | 
                                                        
| 2470 | 2470 | **/  | 
                                                        
| 2471 | 2471 |  function balise_AIDER_dist($p) { | 
                                                        
| 2472 | - $_motif = interprete_argument_balise(1, $p);  | 
                                                        |
| 2473 | - $s = "'" . addslashes($p->descr['sourcefile']) . "'";  | 
                                                        |
| 2474 | -	$p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif,$s, \$Pile[0]):'')"; | 
                                                        |
| 2472 | + $_motif = interprete_argument_balise(1, $p);  | 
                                                        |
| 2473 | + $s = "'" . addslashes($p->descr['sourcefile']) . "'";  | 
                                                        |
| 2474 | +    $p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif,$s, \$Pile[0]):'')"; | 
                                                        |
| 2475 | 2475 | |
| 2476 | - return $p;  | 
                                                        |
| 2476 | + return $p;  | 
                                                        |
| 2477 | 2477 | }  | 
                                                        
| 2478 | 2478 | |
| 2479 | 2479 | /**  | 
                                                        
@@ -2499,16 +2499,16 @@ discard block  | 
                                                    ||
| 2499 | 2499 | * Pile complétée par le code à générer  | 
                                                        
| 2500 | 2500 | **/  | 
                                                        
| 2501 | 2501 |  function balise_ACTION_FORMULAIRE($p) { | 
                                                        
| 2502 | -	if (!$_url = interprete_argument_balise(1, $p)) { | 
                                                        |
| 2503 | - $_url = "@\$Pile[0]['action']";  | 
                                                        |
| 2504 | - }  | 
                                                        |
| 2505 | -	if (!$_form = interprete_argument_balise(2, $p)) { | 
                                                        |
| 2506 | - $_form = "@\$Pile[0]['form']";  | 
                                                        |
| 2507 | - }  | 
                                                        |
| 2508 | -  | 
                                                        |
| 2509 | - // envoyer le nom du formulaire que l'on traite  | 
                                                        |
| 2510 | - // transmettre les eventuels args de la balise formulaire  | 
                                                        |
| 2511 | - $p->code = " '<div>' .  | 
                                                        |
| 2502 | +    if (!$_url = interprete_argument_balise(1, $p)) { | 
                                                        |
| 2503 | + $_url = "@\$Pile[0]['action']";  | 
                                                        |
| 2504 | + }  | 
                                                        |
| 2505 | +    if (!$_form = interprete_argument_balise(2, $p)) { | 
                                                        |
| 2506 | + $_form = "@\$Pile[0]['form']";  | 
                                                        |
| 2507 | + }  | 
                                                        |
| 2508 | +  | 
                                                        |
| 2509 | + // envoyer le nom du formulaire que l'on traite  | 
                                                        |
| 2510 | + // transmettre les eventuels args de la balise formulaire  | 
                                                        |
| 2511 | + $p->code = " '<div>' .  | 
                                                        |
| 2512 | 2512 | form_hidden($_url) .  | 
                                                        
| 2513 | 2513 | '<input name=\'formulaire_action\' type=\'hidden\'  | 
                                                        
| 2514 | 2514 | value=\'' . $_form . '\' />' .  | 
                                                        
@@ -2517,9 +2517,9 @@ discard block  | 
                                                    ||
| 2517 | 2517 | (!empty(\$Pile[0]['_hidden']) ? @\$Pile[0]['_hidden'] : '') .  | 
                                                        
| 2518 | 2518 | '</div>'";  | 
                                                        
| 2519 | 2519 | |
| 2520 | - $p->interdire_scripts = false;  | 
                                                        |
| 2520 | + $p->interdire_scripts = false;  | 
                                                        |
| 2521 | 2521 | |
| 2522 | - return $p;  | 
                                                        |
| 2522 | + return $p;  | 
                                                        |
| 2523 | 2523 | }  | 
                                                        
| 2524 | 2524 | |
| 2525 | 2525 | |
@@ -2549,25 +2549,25 @@ discard block  | 
                                                    ||
| 2549 | 2549 | */  | 
                                                        
| 2550 | 2550 |  function balise_BOUTON_ACTION_dist($p) { | 
                                                        
| 2551 | 2551 | |
| 2552 | - $args = array();  | 
                                                        |
| 2553 | -	for ($k = 1; $k <= 6; $k++) { | 
                                                        |
| 2554 | - $_a = interprete_argument_balise($k, $p);  | 
                                                        |
| 2555 | -		if (!$_a) { | 
                                                        |
| 2556 | - $_a = "''";  | 
                                                        |
| 2557 | - }  | 
                                                        |
| 2558 | - $args[] = $_a;  | 
                                                        |
| 2559 | - }  | 
                                                        |
| 2560 | - // supprimer les args vides  | 
                                                        |
| 2561 | -	while (end($args) == "''" and count($args) > 2) { | 
                                                        |
| 2562 | - array_pop($args);  | 
                                                        |
| 2563 | - }  | 
                                                        |
| 2564 | -	$args = implode(",", $args); | 
                                                        |
| 2552 | + $args = array();  | 
                                                        |
| 2553 | +    for ($k = 1; $k <= 6; $k++) { | 
                                                        |
| 2554 | + $_a = interprete_argument_balise($k, $p);  | 
                                                        |
| 2555 | +        if (!$_a) { | 
                                                        |
| 2556 | + $_a = "''";  | 
                                                        |
| 2557 | + }  | 
                                                        |
| 2558 | + $args[] = $_a;  | 
                                                        |
| 2559 | + }  | 
                                                        |
| 2560 | + // supprimer les args vides  | 
                                                        |
| 2561 | +    while (end($args) == "''" and count($args) > 2) { | 
                                                        |
| 2562 | + array_pop($args);  | 
                                                        |
| 2563 | + }  | 
                                                        |
| 2564 | +    $args = implode(",", $args); | 
                                                        |
| 2565 | 2565 | |
| 2566 | -	$bouton_action = chercher_filtre("bouton_action"); | 
                                                        |
| 2567 | - $p->code = "$bouton_action($args)";  | 
                                                        |
| 2568 | - $p->interdire_scripts = false;  | 
                                                        |
| 2566 | +    $bouton_action = chercher_filtre("bouton_action"); | 
                                                        |
| 2567 | + $p->code = "$bouton_action($args)";  | 
                                                        |
| 2568 | + $p->interdire_scripts = false;  | 
                                                        |
| 2569 | 2569 | |
| 2570 | - return $p;  | 
                                                        |
| 2570 | + return $p;  | 
                                                        |
| 2571 | 2571 | }  | 
                                                        
| 2572 | 2572 | |
| 2573 | 2573 | |
@@ -2586,10 +2586,10 @@ discard block  | 
                                                    ||
| 2586 | 2586 | * Pile complétée par le code à générer  | 
                                                        
| 2587 | 2587 | */  | 
                                                        
| 2588 | 2588 |  function balise_SLOGAN_SITE_SPIP_dist($p) { | 
                                                        
| 2589 | - $p->code = "\$GLOBALS['meta']['slogan_site']";  | 
                                                        |
| 2589 | + $p->code = "\$GLOBALS['meta']['slogan_site']";  | 
                                                        |
| 2590 | 2590 | |
| 2591 | - #$p->interdire_scripts = true;  | 
                                                        |
| 2592 | - return $p;  | 
                                                        |
| 2591 | + #$p->interdire_scripts = true;  | 
                                                        |
| 2592 | + return $p;  | 
                                                        |
| 2593 | 2593 | }  | 
                                                        
| 2594 | 2594 | |
| 2595 | 2595 | |
@@ -2613,10 +2613,10 @@ discard block  | 
                                                    ||
| 2613 | 2613 | * Pile complétée par le code à générer  | 
                                                        
| 2614 | 2614 | */  | 
                                                        
| 2615 | 2615 |  function balise_HTML5_dist($p) { | 
                                                        
| 2616 | - $p->code = html5_permis() ? "' '" : "''";  | 
                                                        |
| 2617 | - $p->interdire_scripts = false;  | 
                                                        |
| 2616 | + $p->code = html5_permis() ? "' '" : "''";  | 
                                                        |
| 2617 | + $p->interdire_scripts = false;  | 
                                                        |
| 2618 | 2618 | |
| 2619 | - return $p;  | 
                                                        |
| 2619 | + return $p;  | 
                                                        |
| 2620 | 2620 | }  | 
                                                        
| 2621 | 2621 | |
| 2622 | 2622 | |
@@ -2642,63 +2642,63 @@ discard block  | 
                                                    ||
| 2642 | 2642 | * Pile complétée par le code à générer  | 
                                                        
| 2643 | 2643 | */  | 
                                                        
| 2644 | 2644 |  function balise_TRI_dist($p, $liste = 'true') { | 
                                                        
| 2645 | - $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];  | 
                                                        |
| 2645 | + $b = $p->nom_boucle ? $p->nom_boucle : $p->descr['id_mere'];  | 
                                                        |
| 2646 | 2646 | |
| 2647 | - // s'il n'y a pas de nom de boucle, on ne peut pas trier  | 
                                                        |
| 2648 | -	if ($b === '') { | 
                                                        |
| 2649 | - erreur_squelette(  | 
                                                        |
| 2650 | -			_T('zbug_champ_hors_boucle', | 
                                                        |
| 2651 | -				array('champ' => '#TRI') | 
                                                        |
| 2652 | - ), $p->id_boucle);  | 
                                                        |
| 2653 | - $p->code = "''";  | 
                                                        |
| 2647 | + // s'il n'y a pas de nom de boucle, on ne peut pas trier  | 
                                                        |
| 2648 | +    if ($b === '') { | 
                                                        |
| 2649 | + erreur_squelette(  | 
                                                        |
| 2650 | +            _T('zbug_champ_hors_boucle', | 
                                                        |
| 2651 | +                array('champ' => '#TRI') | 
                                                        |
| 2652 | + ), $p->id_boucle);  | 
                                                        |
| 2653 | + $p->code = "''";  | 
                                                        |
| 2654 | 2654 | |
| 2655 | - return $p;  | 
                                                        |
| 2656 | - }  | 
                                                        |
| 2657 | - $boucle = $p->boucles[$b];  | 
                                                        |
| 2655 | + return $p;  | 
                                                        |
| 2656 | + }  | 
                                                        |
| 2657 | + $boucle = $p->boucles[$b];  | 
                                                        |
| 2658 | 2658 | |
| 2659 | - // s'il n'y a pas de tri_champ, c'est qu'on se trouve  | 
                                                        |
| 2660 | -	// dans un boucle recursive ou qu'on a oublie le critere {tri} | 
                                                        |
| 2661 | -	if (!isset($boucle->modificateur['tri_champ'])) { | 
                                                        |
| 2662 | - erreur_squelette(  | 
                                                        |
| 2663 | -			_T('zbug_tri_sans_critere', | 
                                                        |
| 2664 | -				array('champ' => '#TRI') | 
                                                        |
| 2665 | - ), $p->id_boucle);  | 
                                                        |
| 2666 | - $p->code = "''";  | 
                                                        |
| 2659 | + // s'il n'y a pas de tri_champ, c'est qu'on se trouve  | 
                                                        |
| 2660 | +    // dans un boucle recursive ou qu'on a oublie le critere {tri} | 
                                                        |
| 2661 | +    if (!isset($boucle->modificateur['tri_champ'])) { | 
                                                        |
| 2662 | + erreur_squelette(  | 
                                                        |
| 2663 | +            _T('zbug_tri_sans_critere', | 
                                                        |
| 2664 | +                array('champ' => '#TRI') | 
                                                        |
| 2665 | + ), $p->id_boucle);  | 
                                                        |
| 2666 | + $p->code = "''";  | 
                                                        |
| 2667 | 2667 | |
| 2668 | - return $p;  | 
                                                        |
| 2669 | - }  | 
                                                        |
| 2668 | + return $p;  | 
                                                        |
| 2669 | + }  | 
                                                        |
| 2670 | 2670 | |
| 2671 | - $_champ = interprete_argument_balise(1, $p);  | 
                                                        |
| 2672 | - // si pas de champ, renvoyer le critere de tri utilise  | 
                                                        |
| 2673 | -	if (!$_champ) { | 
                                                        |
| 2674 | - $p->code = $boucle->modificateur['tri_champ'];  | 
                                                        |
| 2671 | + $_champ = interprete_argument_balise(1, $p);  | 
                                                        |
| 2672 | + // si pas de champ, renvoyer le critere de tri utilise  | 
                                                        |
| 2673 | +    if (!$_champ) { | 
                                                        |
| 2674 | + $p->code = $boucle->modificateur['tri_champ'];  | 
                                                        |
| 2675 | 2675 | |
| 2676 | - return $p;  | 
                                                        |
| 2677 | - }  | 
                                                        |
| 2678 | - // forcer la jointure si besoin, et si le champ est statique  | 
                                                        |
| 2679 | -	if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) { | 
                                                        |
| 2680 | - index_pile($b, $m[1], $p->boucles, '', null, true, false);  | 
                                                        |
| 2681 | - }  | 
                                                        |
| 2676 | + return $p;  | 
                                                        |
| 2677 | + }  | 
                                                        |
| 2678 | + // forcer la jointure si besoin, et si le champ est statique  | 
                                                        |
| 2679 | +    if (preg_match(",^'([\w.]+)'$,i", $_champ, $m)) { | 
                                                        |
| 2680 | + index_pile($b, $m[1], $p->boucles, '', null, true, false);  | 
                                                        |
| 2681 | + }  | 
                                                        |
| 2682 | 2682 | |
| 2683 | - $_libelle = interprete_argument_balise(2, $p);  | 
                                                        |
| 2684 | - $_libelle = $_libelle ? $_libelle : $_champ;  | 
                                                        |
| 2683 | + $_libelle = interprete_argument_balise(2, $p);  | 
                                                        |
| 2684 | + $_libelle = $_libelle ? $_libelle : $_champ;  | 
                                                        |
| 2685 | 2685 | |
| 2686 | - $_class = interprete_argument_balise(3, $p);  | 
                                                        |
| 2687 | - // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1  | 
                                                        |
| 2688 | - // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1  | 
                                                        |
| 2689 | -	$_issens = "in_array($_champ,array('>','<'))"; | 
                                                        |
| 2690 | -	$_sens = "(strpos('< >',$_champ)-1)"; | 
                                                        |
| 2686 | + $_class = interprete_argument_balise(3, $p);  | 
                                                        |
| 2687 | + // si champ = ">" c'est un lien vers le tri croissant : de gauche a droite ==> 1  | 
                                                        |
| 2688 | + // si champ = "<" c'est un lien vers le tri decroissant : (sens inverse) == -1  | 
                                                        |
| 2689 | +    $_issens = "in_array($_champ,array('>','<'))"; | 
                                                        |
| 2690 | +    $_sens = "(strpos('< >',$_champ)-1)"; | 
                                                        |
| 2691 | 2691 | |
| 2692 | - $_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom'];  | 
                                                        |
| 2693 | - $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)";  | 
                                                        |
| 2694 | -	$_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')"; | 
                                                        |
| 2695 | -	$_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)"; | 
                                                        |
| 2692 | + $_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom'];  | 
                                                        |
| 2693 | + $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)";  | 
                                                        |
| 2694 | +    $_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')"; | 
                                                        |
| 2695 | +    $_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)"; | 
                                                        |
| 2696 | 2696 | |
| 2697 | - $p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")";  | 
                                                        |
| 2698 | - //$p->code = "''";  | 
                                                        |
| 2699 | - $p->interdire_scripts = false;  | 
                                                        |
| 2697 | + $p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")";  | 
                                                        |
| 2698 | + //$p->code = "''";  | 
                                                        |
| 2699 | + $p->interdire_scripts = false;  | 
                                                        |
| 2700 | 2700 | |
| 2701 | - return $p;  | 
                                                        |
| 2701 | + return $p;  | 
                                                        |
| 2702 | 2702 | }  | 
                                                        
| 2703 | 2703 | |
| 2704 | 2704 | |
@@ -2719,22 +2719,22 @@ discard block  | 
                                                    ||
| 2719 | 2719 | * Pile complétée par le code à générer  | 
                                                        
| 2720 | 2720 | */  | 
                                                        
| 2721 | 2721 |  function balise_SAUTER_dist($p) { | 
                                                        
| 2722 | - $id_boucle = $p->id_boucle;  | 
                                                        |
| 2722 | + $id_boucle = $p->id_boucle;  | 
                                                        |
| 2723 | 2723 | |
| 2724 | -	if (empty($p->boucles[$id_boucle])) { | 
                                                        |
| 2725 | -		$msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER')); | 
                                                        |
| 2726 | - erreur_squelette($msg, $p);  | 
                                                        |
| 2727 | -	} else { | 
                                                        |
| 2728 | - $boucle = $p->boucles[$id_boucle];  | 
                                                        |
| 2729 | - $_saut = interprete_argument_balise(1, $p);  | 
                                                        |
| 2730 | - $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']";  | 
                                                        |
| 2731 | - $_total = "\$Numrows['$id_boucle']['total']";  | 
                                                        |
| 2724 | +    if (empty($p->boucles[$id_boucle])) { | 
                                                        |
| 2725 | +        $msg = array('zbug_champ_hors_boucle', array('champ' => '#SAUTER')); | 
                                                        |
| 2726 | + erreur_squelette($msg, $p);  | 
                                                        |
| 2727 | +    } else { | 
                                                        |
| 2728 | + $boucle = $p->boucles[$id_boucle];  | 
                                                        |
| 2729 | + $_saut = interprete_argument_balise(1, $p);  | 
                                                        |
| 2730 | + $_compteur = "\$Numrows['$id_boucle']['compteur_boucle']";  | 
                                                        |
| 2731 | + $_total = "\$Numrows['$id_boucle']['total']";  | 
                                                        |
| 2732 | 2732 | |
| 2733 | - $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))";  | 
                                                        |
| 2734 | - }  | 
                                                        |
| 2735 | - $p->interdire_scripts = false;  | 
                                                        |
| 2733 | + $p->code = "vide($_compteur=\$iter->skip($_saut,$_total))";  | 
                                                        |
| 2734 | + }  | 
                                                        |
| 2735 | + $p->interdire_scripts = false;  | 
                                                        |
| 2736 | 2736 | |
| 2737 | - return $p;  | 
                                                        |
| 2737 | + return $p;  | 
                                                        |
| 2738 | 2738 | }  | 
                                                        
| 2739 | 2739 | |
| 2740 | 2740 | |
@@ -2756,22 +2756,22 @@ discard block  | 
                                                    ||
| 2756 | 2756 | * Pile complétée par le code à générer  | 
                                                        
| 2757 | 2757 | */  | 
                                                        
| 2758 | 2758 |  function balise_PUBLIE_dist($p) { | 
                                                        
| 2759 | -	if (!$_type = interprete_argument_balise(1, $p)) { | 
                                                        |
| 2760 | - $_type = _q($p->type_requete);  | 
                                                        |
| 2761 | - $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p);  | 
                                                        |
| 2762 | -	} else { | 
                                                        |
| 2763 | - $_id = interprete_argument_balise(2, $p);  | 
                                                        |
| 2764 | - }  | 
                                                        |
| 2759 | +    if (!$_type = interprete_argument_balise(1, $p)) { | 
                                                        |
| 2760 | + $_type = _q($p->type_requete);  | 
                                                        |
| 2761 | + $_id = champ_sql($p->boucles[$p->id_boucle]->primary, $p);  | 
                                                        |
| 2762 | +    } else { | 
                                                        |
| 2763 | + $_id = interprete_argument_balise(2, $p);  | 
                                                        |
| 2764 | + }  | 
                                                        |
| 2765 | 2765 | |
| 2766 | - $connect = '';  | 
                                                        |
| 2767 | -	if (isset($p->boucles[$p->id_boucle])) { | 
                                                        |
| 2768 | - $connect = $p->boucles[$p->id_boucle]->sql_serveur;  | 
                                                        |
| 2769 | - }  | 
                                                        |
| 2766 | + $connect = '';  | 
                                                        |
| 2767 | +    if (isset($p->boucles[$p->id_boucle])) { | 
                                                        |
| 2768 | + $connect = $p->boucles[$p->id_boucle]->sql_serveur;  | 
                                                        |
| 2769 | + }  | 
                                                        |
| 2770 | 2770 | |
| 2771 | -	$p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')"; | 
                                                        |
| 2772 | - $p->interdire_scripts = false;  | 
                                                        |
| 2771 | +    $p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')"; | 
                                                        |
| 2772 | + $p->interdire_scripts = false;  | 
                                                        |
| 2773 | 2773 | |
| 2774 | - return $p;  | 
                                                        |
| 2774 | + return $p;  | 
                                                        |
| 2775 | 2775 | }  | 
                                                        
| 2776 | 2776 | |
| 2777 | 2777 | /**  | 
                                                        
@@ -2800,12 +2800,12 @@ discard block  | 
                                                    ||
| 2800 | 2800 | * Pile complétée par le code à générer  | 
                                                        
| 2801 | 2801 | */  | 
                                                        
| 2802 | 2802 |  function balise_PRODUIRE_dist($p) { | 
                                                        
| 2803 | -	$balise_inclure = charger_fonction('INCLURE', 'balise'); | 
                                                        |
| 2804 | - $p = $balise_inclure($p);  | 
                                                        |
| 2803 | +    $balise_inclure = charger_fonction('INCLURE', 'balise'); | 
                                                        |
| 2804 | + $p = $balise_inclure($p);  | 
                                                        |
| 2805 | 2805 | |
| 2806 | -	$p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); | 
                                                        |
| 2806 | +    $p->code = str_replace('recuperer_fond(', 'produire_fond_statique(', $p->code); | 
                                                        |
| 2807 | 2807 | |
| 2808 | - return $p;  | 
                                                        |
| 2808 | + return $p;  | 
                                                        |
| 2809 | 2809 | }  | 
                                                        
| 2810 | 2810 | |
| 2811 | 2811 | /**  | 
                                                        
@@ -2824,13 +2824,13 @@ discard block  | 
                                                    ||
| 2824 | 2824 | * Pile complétée par le code à générer  | 
                                                        
| 2825 | 2825 | */  | 
                                                        
| 2826 | 2826 |  function balise_LARGEUR_ECRAN_dist($p) { | 
                                                        
| 2827 | - $_class = interprete_argument_balise(1, $p);  | 
                                                        |
| 2828 | -	if (!$_class) { | 
                                                        |
| 2829 | - $_class = 'null';  | 
                                                        |
| 2830 | - }  | 
                                                        |
| 2831 | - $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))";  | 
                                                        |
| 2827 | + $_class = interprete_argument_balise(1, $p);  | 
                                                        |
| 2828 | +    if (!$_class) { | 
                                                        |
| 2829 | + $_class = 'null';  | 
                                                        |
| 2830 | + }  | 
                                                        |
| 2831 | + $p->code = "(is_string($_class)?vide(\$GLOBALS['largeur_ecran']=$_class):(isset(\$GLOBALS['largeur_ecran'])?\$GLOBALS['largeur_ecran']:''))";  | 
                                                        |
| 2832 | 2832 | |
| 2833 | - return $p;  | 
                                                        |
| 2833 | + return $p;  | 
                                                        |
| 2834 | 2834 | }  | 
                                                        
| 2835 | 2835 | |
| 2836 | 2836 | |
@@ -2846,14 +2846,14 @@ discard block  | 
                                                    ||
| 2846 | 2846 | * Pile complétée par le code à générer  | 
                                                        
| 2847 | 2847 | **/  | 
                                                        
| 2848 | 2848 |  function balise_CONST_dist($p) { | 
                                                        
| 2849 | - $_const = interprete_argument_balise(1, $p);  | 
                                                        |
| 2850 | -	if (!strlen($_const)) { | 
                                                        |
| 2851 | - $p->code = "''";  | 
                                                        |
| 2852 | - }  | 
                                                        |
| 2853 | -	else { | 
                                                        |
| 2854 | - $p->code = "(defined($_const)?constant($_const):'')";  | 
                                                        |
| 2855 | - }  | 
                                                        |
| 2856 | - $p->interdire_scripts = false;  | 
                                                        |
| 2857 | -  | 
                                                        |
| 2858 | - return $p;  | 
                                                        |
| 2849 | + $_const = interprete_argument_balise(1, $p);  | 
                                                        |
| 2850 | +    if (!strlen($_const)) { | 
                                                        |
| 2851 | + $p->code = "''";  | 
                                                        |
| 2852 | + }  | 
                                                        |
| 2853 | +    else { | 
                                                        |
| 2854 | + $p->code = "(defined($_const)?constant($_const):'')";  | 
                                                        |
| 2855 | + }  | 
                                                        |
| 2856 | + $p->interdire_scripts = false;  | 
                                                        |
| 2857 | +  | 
                                                        |
| 2858 | + return $p;  | 
                                                        |
| 2859 | 2859 | }  | 
                                                        
@@ -363,7 +363,7 @@ discard block  | 
                                                    ||
| 363 | 363 | */  | 
                                                        
| 364 | 364 |  function balise_DOSSIER_SQUELETTE_dist($p) { | 
                                                        
| 365 | 365 | $code = substr(addslashes(dirname($p->descr['sourcefile'])), strlen(_DIR_RACINE));  | 
                                                        
| 366 | - $p->code = "_DIR_RACINE . '$code'" .  | 
                                                        |
| 366 | + $p->code = "_DIR_RACINE . '$code'".  | 
                                                        |
| 367 | 367 | $p->interdire_scripts = false;  | 
                                                        
| 368 | 368 | |
| 369 | 369 | return $p;  | 
                                                        
@@ -382,7 +382,7 @@ discard block  | 
                                                    ||
| 382 | 382 | */  | 
                                                        
| 383 | 383 |  function balise_SQUELETTE_dist($p) { | 
                                                        
| 384 | 384 | $code = addslashes($p->descr['sourcefile']);  | 
                                                        
| 385 | - $p->code = "'$code'" .  | 
                                                        |
| 385 | + $p->code = "'$code'".  | 
                                                        |
| 386 | 386 | $p->interdire_scripts = false;  | 
                                                        
| 387 | 387 | |
| 388 | 388 | return $p;  | 
                                                        
@@ -434,9 +434,9 @@ discard block  | 
                                                    ||
| 434 | 434 | **/  | 
                                                        
| 435 | 435 |  function balise_NOM_SITE_dist($p) { | 
                                                        
| 436 | 436 |  	if (!$p->etoile) { | 
                                                        
| 437 | -		$p->code = "supprimer_numero(calculer_url(" . | 
                                                        |
| 438 | -			champ_sql('url_site', $p) . "," . | 
                                                        |
| 439 | -			champ_sql('nom_site', $p) . | 
                                                        |
| 437 | +		$p->code = "supprimer_numero(calculer_url(". | 
                                                        |
| 438 | +			champ_sql('url_site', $p).",". | 
                                                        |
| 439 | +			champ_sql('nom_site', $p). | 
                                                        |
| 440 | 440 | ", 'titre', \$connect, false))";  | 
                                                        
| 441 | 441 |  	} else { | 
                                                        
| 442 | 442 |  		$p->code = champ_sql('nom_site', $p); | 
                                                        
@@ -543,7 +543,7 @@ discard block  | 
                                                    ||
| 543 | 543 |  	if ($b === '' || !isset($p->boucles[$b])) { | 
                                                        
| 544 | 544 | $msg = array(  | 
                                                        
| 545 | 545 | 'zbug_champ_hors_boucle',  | 
                                                        
| 546 | -			array('champ' => "#$b" . 'TOTAL_BOUCLE') | 
                                                        |
| 546 | +			array('champ' => "#$b".'TOTAL_BOUCLE') | 
                                                        |
| 547 | 547 | );  | 
                                                        
| 548 | 548 | erreur_squelette($msg, $p);  | 
                                                        
| 549 | 549 |  	} else { | 
                                                        
@@ -593,8 +593,8 @@ discard block  | 
                                                    ||
| 593 | 593 | * Pile complétée par le code à générer  | 
                                                        
| 594 | 594 | **/  | 
                                                        
| 595 | 595 |  function balise_POPULARITE_ABSOLUE_dist($p) { | 
                                                        
| 596 | -	$p->code = 'ceil(' . | 
                                                        |
| 597 | -		champ_sql('popularite', $p) . | 
                                                        |
| 596 | +	$p->code = 'ceil('. | 
                                                        |
| 597 | +		champ_sql('popularite', $p). | 
                                                        |
| 598 | 598 | ')';  | 
                                                        
| 599 | 599 | $p->interdire_scripts = false;  | 
                                                        
| 600 | 600 | |
@@ -672,9 +672,9 @@ discard block  | 
                                                    ||
| 672 | 672 | **/  | 
                                                        
| 673 | 673 |  function balise_VALEUR_dist($p) { | 
                                                        
| 674 | 674 | $b = $p->nom_boucle ? $p->nom_boucle : $p->id_boucle;  | 
                                                        
| 675 | - $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b);;  | 
                                                        |
| 675 | + $p->code = index_pile($p->id_boucle, 'valeur', $p->boucles, $b); ;  | 
                                                        |
| 676 | 676 |  	if (($v = interprete_argument_balise(1, $p)) !== null) { | 
                                                        
| 677 | -		$p->code = 'table_valeur(' . $p->code . ', ' . $v . ')'; | 
                                                        |
| 677 | +		$p->code = 'table_valeur('.$p->code.', '.$v.')'; | 
                                                        |
| 678 | 678 | }  | 
                                                        
| 679 | 679 | $p->interdire_scripts = true;  | 
                                                        
| 680 | 680 | |
@@ -830,8 +830,8 @@ discard block  | 
                                                    ||
| 830 | 830 | $_suite = 'null';  | 
                                                        
| 831 | 831 | $_longueur = $longueur_defaut;  | 
                                                        
| 832 | 832 |  	if (($v = interprete_argument_balise(1, $p)) !== null) { | 
                                                        
| 833 | -		$_longueur = 'is_numeric(' . $v . ')?intval(' . $v . '):' . $longueur_defaut; | 
                                                        |
| 834 | -		$_suite = '!is_numeric(' . $v . ')?' . $v . ':null'; | 
                                                        |
| 833 | +		$_longueur = 'is_numeric('.$v.')?intval('.$v.'):'.$longueur_defaut; | 
                                                        |
| 834 | +		$_suite = '!is_numeric('.$v.')?'.$v.':null'; | 
                                                        |
| 835 | 835 | }  | 
                                                        
| 836 | 836 |  	if (($v2 = interprete_argument_balise(2, $p)) !== null) { | 
                                                        
| 837 | 837 | $_suite = $v2;  | 
                                                        
@@ -919,10 +919,10 @@ discard block  | 
                                                    ||
| 919 | 919 | $c = memoriser_contexte_compil($p);  | 
                                                        
| 920 | 920 | |
| 921 | 921 | $p->code = sprintf(CODE_RECUPERER_FOND, "'modeles/lesauteurs'",  | 
                                                        
| 922 | -			"array('objet'=>'" . $objet . | 
                                                        |
| 923 | - "','id_objet' => " . champ_sql($id_table_objet, $p) .  | 
                                                        |
| 924 | - ",'$id_table_objet' => " . champ_sql($id_table_objet, $p) .  | 
                                                        |
| 925 | -			($objet == 'article' ? "" : ",'id_article' => " . champ_sql('id_article', $p)) . | 
                                                        |
| 922 | +			"array('objet'=>'".$objet. | 
                                                        |
| 923 | + "','id_objet' => ".champ_sql($id_table_objet, $p).  | 
                                                        |
| 924 | + ",'$id_table_objet' => ".champ_sql($id_table_objet, $p).  | 
                                                        |
| 925 | +			($objet == 'article' ? "" : ",'id_article' => ".champ_sql('id_article', $p)). | 
                                                        |
| 926 | 926 | ")",  | 
                                                        
| 927 | 927 | "'trim'=>true, 'compil'=>array($c)",  | 
                                                        
| 928 | 928 | _q($connect));  | 
                                                        
@@ -988,7 +988,7 @@ discard block  | 
                                                    ||
| 988 | 988 | $m = trim($m);  | 
                                                        
| 989 | 989 |  					if ($m != "''") { | 
                                                        
| 990 | 990 |  						if (!preg_match(",\W,", $m)) { | 
                                                        
| 991 | - $m = $boucle->id_table . ".$m";  | 
                                                        |
| 991 | + $m = $boucle->id_table.".$m";  | 
                                                        |
| 992 | 992 | }  | 
                                                        
| 993 | 993 | |
| 994 | 994 | $m .= " AS titre_rang";  | 
                                                        
@@ -1135,7 +1135,7 @@ discard block  | 
                                                    ||
| 1135 | 1135 |  	$f_pagination = chercher_filtre('pagination'); | 
                                                        
| 1136 | 1136 | $type = $p->boucles[$b]->modificateur['debut_nom'];  | 
                                                        
| 1137 | 1137 | $modif = ($type[0] !== "'") ? "'debut'.$type"  | 
                                                        
| 1138 | -		: ("'debut" . substr($type, 1)); | 
                                                        |
| 1138 | +		: ("'debut".substr($type, 1)); | 
                                                        |
| 1139 | 1139 | |
| 1140 | 1140 | $p->code = sprintf(CODE_PAGINATION, $f_pagination, $b, $type, $modif, $pas, $liste,  | 
                                                        
| 1141 | 1141 | ((isset($__modele) and $__modele) ? $__modele : "''"), _q($connect), $code_contexte);  | 
                                                        
@@ -1199,7 +1199,7 @@ discard block  | 
                                                    ||
| 1199 | 1199 |  	if ($b === '' || !isset($p->boucles[$b])) { | 
                                                        
| 1200 | 1200 | $msg = array(  | 
                                                        
| 1201 | 1201 | 'zbug_champ_hors_boucle',  | 
                                                        
| 1202 | -			array('champ' => "#$b" . 'TOTAL_BOUCLE') | 
                                                        |
| 1202 | +			array('champ' => "#$b".'TOTAL_BOUCLE') | 
                                                        |
| 1203 | 1203 | );  | 
                                                        
| 1204 | 1204 | erreur_squelette($msg, $p);  | 
                                                        
| 1205 | 1205 |  	} else { | 
                                                        
@@ -1272,7 +1272,7 @@ discard block  | 
                                                    ||
| 1272 | 1272 |  		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN')); | 
                                                        
| 1273 | 1273 | erreur_squelette($msg, $p);  | 
                                                        
| 1274 | 1274 |  	} else { | 
                                                        
| 1275 | -		$p->code = 'find_in_path(' . $arg . ')'; | 
                                                        |
| 1275 | +		$p->code = 'find_in_path('.$arg.')'; | 
                                                        |
| 1276 | 1276 | }  | 
                                                        
| 1277 | 1277 | |
| 1278 | 1278 | $p->interdire_scripts = false;  | 
                                                        
@@ -1307,7 +1307,7 @@ discard block  | 
                                                    ||
| 1307 | 1307 |  		$msg = array('zbug_balise_sans_argument', array('balise' => ' CHEMIN_IMAGE')); | 
                                                        
| 1308 | 1308 | erreur_squelette($msg, $p);  | 
                                                        
| 1309 | 1309 |  	} else { | 
                                                        
| 1310 | -		$p->code = 'chemin_image(' . $arg . ')'; | 
                                                        |
| 1310 | +		$p->code = 'chemin_image('.$arg.')'; | 
                                                        |
| 1311 | 1311 | }  | 
                                                        
| 1312 | 1312 | |
| 1313 | 1313 | #$p->interdire_scripts = true;  | 
                                                        
@@ -1361,7 +1361,7 @@ discard block  | 
                                                    ||
| 1361 | 1361 | // cas de #ENV sans argument : on retourne le serialize() du tableau  | 
                                                        
| 1362 | 1362 | // une belle fonction [(#ENV|affiche_env)] serait pratique  | 
                                                        
| 1363 | 1363 |  		if ($src) { | 
                                                        
| 1364 | -			$p->code = '(is_array($a = (' . $src . ')) ? serialize($a) : "")'; | 
                                                        |
| 1364 | +			$p->code = '(is_array($a = ('.$src.')) ? serialize($a) : "")'; | 
                                                        |
| 1365 | 1365 |  		} else { | 
                                                        
| 1366 | 1366 | $p->code = '@serialize($Pile[0])';  | 
                                                        
| 1367 | 1367 | }  | 
                                                        
@@ -1414,8 +1414,8 @@ discard block  | 
                                                    ||
| 1414 | 1414 | $_sinon = interprete_argument_balise(2, $p);  | 
                                                        
| 1415 | 1415 | $_unserialize = sinon(interprete_argument_balise(3, $p), "false");  | 
                                                        
| 1416 | 1416 | |
| 1417 | -	$p->code = '(include_spip(\'inc/config\')?lire_config(' . $arg . ',' . | 
                                                        |
| 1418 | - ($_sinon && $_sinon != "''" ? $_sinon : 'null') . ',' . $_unserialize . "):'')";  | 
                                                        |
| 1417 | +	$p->code = '(include_spip(\'inc/config\')?lire_config('.$arg.','. | 
                                                        |
| 1418 | + ($_sinon && $_sinon != "''" ? $_sinon : 'null').','.$_unserialize."):'')";  | 
                                                        |
| 1419 | 1419 | |
| 1420 | 1420 | return $p;  | 
                                                        
| 1421 | 1421 | }  | 
                                                        
@@ -1508,7 +1508,7 @@ discard block  | 
                                                    ||
| 1508 | 1508 |  		$err_b_s_a = array('zbug_balise_sans_argument', array('balise' => 'SESSION_SET')); | 
                                                        
| 1509 | 1509 | erreur_squelette($err_b_s_a, $p);  | 
                                                        
| 1510 | 1510 |  	} else { | 
                                                        
| 1511 | -		$p->code = '(include_spip("inc/session") AND session_set(' . $_nom . ',' . $_val . '))'; | 
                                                        |
| 1511 | +		$p->code = '(include_spip("inc/session") AND session_set('.$_nom.','.$_val.'))'; | 
                                                        |
| 1512 | 1512 | }  | 
                                                        
| 1513 | 1513 | |
| 1514 | 1514 | $p->interdire_scripts = false;  | 
                                                        
@@ -1551,7 +1551,7 @@ discard block  | 
                                                    ||
| 1551 | 1551 |  		if (preg_match(",^([[:space:]]*//[^\n]*\n)'([^']+)'$,ms", | 
                                                        
| 1552 | 1552 |  			$php, $r)) { | 
                                                        
| 1553 | 1553 | $p->code = /* $r[1]. */  | 
                                                        
| 1554 | -				'(' . $r[2] . ')'; | 
                                                        |
| 1554 | +				'('.$r[2].')'; | 
                                                        |
| 1555 | 1555 |  		} else { | 
                                                        
| 1556 | 1556 |  			$p->code = "eval('return '.$php.';')"; | 
                                                        
| 1557 | 1557 | }  | 
                                                        
@@ -1798,9 +1798,9 @@ discard block  | 
                                                    ||
| 1798 | 1798 | |
| 1799 | 1799 | // noter la duree du cache dans un entete proprietaire  | 
                                                        
| 1800 | 1800 | |
| 1801 | -		$code = "'<'.'" . '?php header("X-Spip-Cache: ' | 
                                                        |
| 1801 | +		$code = "'<'.'".'?php header("X-Spip-Cache: ' | 
                                                        |
| 1802 | 1802 | . $duree  | 
                                                        
| 1803 | - . '"); ?' . "'.'>'";  | 
                                                        |
| 1803 | + . '"); ?'."'.'>'";  | 
                                                        |
| 1804 | 1804 | |
| 1805 | 1805 | // Remplir le header Cache-Control  | 
                                                        
| 1806 | 1806 |  		// cas #CACHE{0} | 
                                                        
@@ -1820,9 +1820,9 @@ discard block  | 
                                                    ||
| 1820 | 1820 | if ($pa == 'cache-client'  | 
                                                        
| 1821 | 1821 | and $duree > 0  | 
                                                        
| 1822 | 1822 |  			) { | 
                                                        
| 1823 | -				$code .= ".'<'.'" . '?php header("Cache-Control: max-age=' | 
                                                        |
| 1823 | +				$code .= ".'<'.'".'?php header("Cache-Control: max-age=' | 
                                                        |
| 1824 | 1824 | . $duree  | 
                                                        
| 1825 | - . '"); ?' . "'.'>'";  | 
                                                        |
| 1825 | + . '"); ?'."'.'>'";  | 
                                                        |
| 1826 | 1826 | // il semble logique, si on cache-client, de ne pas invalider  | 
                                                        
| 1827 | 1827 | $pa = 'statique';  | 
                                                        
| 1828 | 1828 | }  | 
                                                        
@@ -1830,7 +1830,7 @@ discard block  | 
                                                    ||
| 1830 | 1830 | if ($pa == 'statique'  | 
                                                        
| 1831 | 1831 | and $duree > 0  | 
                                                        
| 1832 | 1832 |  			) { | 
                                                        
| 1833 | -				$code .= ".'<'.'" . '?php header("X-Spip-Statique: oui"); ?' . "'.'>'"; | 
                                                        |
| 1833 | +				$code .= ".'<'.'".'?php header("X-Spip-Statique: oui"); ?'."'.'>'"; | 
                                                        |
| 1834 | 1834 | }  | 
                                                        
| 1835 | 1835 | }  | 
                                                        
| 1836 | 1836 |  	} else { | 
                                                        
@@ -1999,9 +1999,9 @@ discard block  | 
                                                    ||
| 1999 | 1999 |  		if ($p->etoile) { | 
                                                        
| 2000 | 2000 | $_options[] = "'etoile'=>true";  | 
                                                        
| 2001 | 2001 | }  | 
                                                        
| 2002 | -		$_options[] = "'compil'=>array(" . memoriser_contexte_compil($p) . ")"; | 
                                                        |
| 2002 | +		$_options[] = "'compil'=>array(".memoriser_contexte_compil($p).")"; | 
                                                        |
| 2003 | 2003 | |
| 2004 | -		$_l = 'array(' . join(",\n\t", $_contexte) . ')'; | 
                                                        |
| 2004 | +		$_l = 'array('.join(",\n\t", $_contexte).')'; | 
                                                        |
| 2005 | 2005 |  		if ($flag_env) { | 
                                                        
| 2006 | 2006 | $_l = "array_merge(\$Pile[0],$_l)";  | 
                                                        
| 2007 | 2007 | }  | 
                                                        
@@ -2012,7 +2012,7 @@ discard block  | 
                                                    ||
| 2012 | 2012 |  		$msg = array('zbug_balise_sans_argument', array('balise' => ' INCLURE')); | 
                                                        
| 2013 | 2013 | erreur_squelette($msg, $p);  | 
                                                        
| 2014 | 2014 |  	} else { | 
                                                        
| 2015 | -		$p->code = 'charge_scripts(' . $_contexte[1] . ',false)'; | 
                                                        |
| 2015 | +		$p->code = 'charge_scripts('.$_contexte[1].',false)'; | 
                                                        |
| 2016 | 2016 | }  | 
                                                        
| 2017 | 2017 | |
| 2018 | 2018 | $p->interdire_scripts = false; // la securite est assuree par recuperer_fond  | 
                                                        
@@ -2060,7 +2060,7 @@ discard block  | 
                                                    ||
| 2060 | 2060 | unset($_contexte[1]);  | 
                                                        
| 2061 | 2061 | |
| 2062 | 2062 |  		if (preg_match("/^\s*'[^']*'/s", $nom)) { | 
                                                        
| 2063 | - $nom = "'modeles/" . substr($nom, 1);  | 
                                                        |
| 2063 | + $nom = "'modeles/".substr($nom, 1);  | 
                                                        |
| 2064 | 2064 |  		} else { | 
                                                        
| 2065 | 2065 | $nom = "'modeles/' . $nom";  | 
                                                        
| 2066 | 2066 | }  | 
                                                        
@@ -2077,8 +2077,8 @@ discard block  | 
                                                    ||
| 2077 | 2077 | $primary = $p->boucles[$p->id_boucle]->primary;  | 
                                                        
| 2078 | 2078 |  			if (!strpos($primary, ',')) { | 
                                                        
| 2079 | 2079 | $id = champ_sql($primary, $p);  | 
                                                        
| 2080 | - $_contexte[] = "'$primary'=>" . $id;  | 
                                                        |
| 2081 | - $_contexte[] = "'id'=>" . $id;  | 
                                                        |
| 2080 | + $_contexte[] = "'$primary'=>".$id;  | 
                                                        |
| 2081 | + $_contexte[] = "'id'=>".$id;  | 
                                                        |
| 2082 | 2082 | }  | 
                                                        
| 2083 | 2083 | }  | 
                                                        
| 2084 | 2084 | $_contexte[] = "'recurs'=>(++\$recurs)";  | 
                                                        
@@ -2092,11 +2092,11 @@ discard block  | 
                                                    ||
| 2092 | 2092 | $_options = "'compil'=>array($_options), 'trim'=>true, 'sessionnement_contaminant'=>true";  | 
                                                        
| 2093 | 2093 | |
| 2094 | 2094 |  		if (isset($_contexte['ajax'])) { | 
                                                        
| 2095 | -			$_options .= ", " . preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); | 
                                                        |
| 2095 | +			$_options .= ", ".preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); | 
                                                        |
| 2096 | 2096 | unset($_contexte['ajax']);  | 
                                                        
| 2097 | 2097 | }  | 
                                                        
| 2098 | 2098 | |
| 2099 | -		$_l = 'array(' . join(",\n\t", $_contexte) . ')'; | 
                                                        |
| 2099 | +		$_l = 'array('.join(",\n\t", $_contexte).')'; | 
                                                        |
| 2100 | 2100 |  		if ($flag_env) { | 
                                                        
| 2101 | 2101 | $_l = "array_merge(\$Pile[0],$_l)";  | 
                                                        
| 2102 | 2102 | }  | 
                                                        
@@ -2206,12 +2206,12 @@ discard block  | 
                                                    ||
| 2206 | 2206 |  function balise_DOUBLONS_dist($p) { | 
                                                        
| 2207 | 2207 |  	if ($type = interprete_argument_balise(1, $p)) { | 
                                                        
| 2208 | 2208 |  		if ($famille = interprete_argument_balise(2, $p)) { | 
                                                        
| 2209 | - $type .= '.' . $famille;  | 
                                                        |
| 2209 | + $type .= '.'.$famille;  | 
                                                        |
| 2210 | 2210 | }  | 
                                                        
| 2211 | - $p->code = '(isset($doublons[' . $type . ']) ? $doublons[' . $type . '] : "")';  | 
                                                        |
| 2211 | + $p->code = '(isset($doublons['.$type.']) ? $doublons['.$type.'] : "")';  | 
                                                        |
| 2212 | 2212 |  		if (!$p->etoile) { | 
                                                        
| 2213 | 2213 |  			$p->code = 'array_filter(array_map("intval",explode(",",' | 
                                                        
| 2214 | - . $p->code . ')))';  | 
                                                        |
| 2214 | + . $p->code.')))';  | 
                                                        |
| 2215 | 2215 | }  | 
                                                        
| 2216 | 2216 |  	} else { | 
                                                        
| 2217 | 2217 | $p->code = '$doublons';  | 
                                                        
@@ -2340,7 +2340,7 @@ discard block  | 
                                                    ||
| 2340 | 2340 | $_code[] = "$_key => $_val";  | 
                                                        
| 2341 | 2341 | }  | 
                                                        
| 2342 | 2342 | } while ($_key && $_val);  | 
                                                        
| 2343 | -	$p->code = 'array(' . join(', ', $_code) . ')'; | 
                                                        |
| 2343 | +	$p->code = 'array('.join(', ', $_code).')'; | 
                                                        |
| 2344 | 2344 | $p->interdire_scripts = false;  | 
                                                        
| 2345 | 2345 | |
| 2346 | 2346 | return $p;  | 
                                                        
@@ -2367,7 +2367,7 @@ discard block  | 
                                                    ||
| 2367 | 2367 |  	while ($_val = interprete_argument_balise($n++, $p)) { | 
                                                        
| 2368 | 2368 | $_code[] = $_val;  | 
                                                        
| 2369 | 2369 | }  | 
                                                        
| 2370 | -	$p->code = 'array(' . join(', ', $_code) . ')'; | 
                                                        |
| 2370 | +	$p->code = 'array('.join(', ', $_code).')'; | 
                                                        |
| 2371 | 2371 | $p->interdire_scripts = false;  | 
                                                        
| 2372 | 2372 | |
| 2373 | 2373 | return $p;  | 
                                                        
@@ -2412,8 +2412,8 @@ discard block  | 
                                                    ||
| 2412 | 2412 | $_code[] = $_v;  | 
                                                        
| 2413 | 2413 | }  | 
                                                        
| 2414 | 2414 | |
| 2415 | -	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser(' . join(', ', | 
                                                        |
| 2416 | - $_code) . ')?" ":"")';  | 
                                                        |
| 2415 | +	$p->code = '((function_exists("autoriser")||include_spip("inc/autoriser"))&&autoriser('.join(', ', | 
                                                        |
| 2416 | + $_code).')?" ":"")';  | 
                                                        |
| 2417 | 2417 | $p->interdire_scripts = false;  | 
                                                        
| 2418 | 2418 | |
| 2419 | 2419 | return $p;  | 
                                                        
@@ -2446,7 +2446,7 @@ discard block  | 
                                                    ||
| 2446 | 2446 |  	$type_info = isset($type_info) ? str_replace('\'', '"', $type_info) : '"est_actif"'; | 
                                                        
| 2447 | 2447 | |
| 2448 | 2448 |  	$f = chercher_filtre('info_plugin'); | 
                                                        
| 2449 | -	$p->code = $f . '(' . $plugin . ', ' . $type_info . ')'; | 
                                                        |
| 2449 | +	$p->code = $f.'('.$plugin.', '.$type_info.')'; | 
                                                        |
| 2450 | 2450 | |
| 2451 | 2451 | return $p;  | 
                                                        
| 2452 | 2452 | }  | 
                                                        
@@ -2470,7 +2470,7 @@ discard block  | 
                                                    ||
| 2470 | 2470 | **/  | 
                                                        
| 2471 | 2471 |  function balise_AIDER_dist($p) { | 
                                                        
| 2472 | 2472 | $_motif = interprete_argument_balise(1, $p);  | 
                                                        
| 2473 | - $s = "'" . addslashes($p->descr['sourcefile']) . "'";  | 
                                                        |
| 2473 | + $s = "'".addslashes($p->descr['sourcefile'])."'";  | 
                                                        |
| 2474 | 2474 |  	$p->code = "((\$aider=charger_fonction('aide','inc',true))?\$aider($_motif,$s, \$Pile[0]):'')"; | 
                                                        
| 2475 | 2475 | |
| 2476 | 2476 | return $p;  | 
                                                        
@@ -2689,12 +2689,12 @@ discard block  | 
                                                    ||
| 2689 | 2689 |  	$_issens = "in_array($_champ,array('>','<'))"; | 
                                                        
| 2690 | 2690 |  	$_sens = "(strpos('< >',$_champ)-1)"; | 
                                                        
| 2691 | 2691 | |
| 2692 | - $_variable = "((\$s=$_issens)?'sens':'tri')." . $boucle->modificateur['tri_nom'];  | 
                                                        |
| 2692 | + $_variable = "((\$s=$_issens)?'sens':'tri').".$boucle->modificateur['tri_nom'];  | 
                                                        |
| 2693 | 2693 | $_url = "parametre_url(self(),$_variable,\$s?$_sens:$_champ)";  | 
                                                        
| 2694 | -	$_url = "parametre_url($_url,'var_memotri',strncmp(" . $boucle->modificateur['tri_nom'] . ",'session',7)==0?$_variable:'')"; | 
                                                        |
| 2695 | -	$_on = "\$s?(" . $boucle->modificateur['tri_sens'] . "==$_sens" . '):(' . $boucle->modificateur['tri_champ'] . "==$_champ)"; | 
                                                        |
| 2694 | +	$_url = "parametre_url($_url,'var_memotri',strncmp(".$boucle->modificateur['tri_nom'].",'session',7)==0?$_variable:'')"; | 
                                                        |
| 2695 | +	$_on = "\$s?(".$boucle->modificateur['tri_sens']."==$_sens".'):('.$boucle->modificateur['tri_champ']."==$_champ)"; | 
                                                        |
| 2696 | 2696 | |
| 2697 | - $p->code = "lien_ou_expose($_url,$_libelle,$_on" . ($_class ? ",$_class" : "") . ")";  | 
                                                        |
| 2697 | + $p->code = "lien_ou_expose($_url,$_libelle,$_on".($_class ? ",$_class" : "").")";  | 
                                                        |
| 2698 | 2698 | //$p->code = "''";  | 
                                                        
| 2699 | 2699 | $p->interdire_scripts = false;  | 
                                                        
| 2700 | 2700 | |
@@ -2768,7 +2768,7 @@ discard block  | 
                                                    ||
| 2768 | 2768 | $connect = $p->boucles[$p->id_boucle]->sql_serveur;  | 
                                                        
| 2769 | 2769 | }  | 
                                                        
| 2770 | 2770 | |
| 2771 | -	$p->code = "(objet_test_si_publie(" . $_type . ",intval(" . $_id . ")," . _q($connect) . ")?' ':'')"; | 
                                                        |
| 2771 | +	$p->code = "(objet_test_si_publie(".$_type.",intval(".$_id."),"._q($connect).")?' ':'')"; | 
                                                        |
| 2772 | 2772 | $p->interdire_scripts = false;  | 
                                                        
| 2773 | 2773 | |
| 2774 | 2774 | return $p;  | 
                                                        
@@ -20,155 +20,155 @@ discard block  | 
                                                    ||
| 20 | 20 | **/  | 
                                                        
| 21 | 21 | |
| 22 | 22 |  if (!defined('_ECRIRE_INC_VERSION')) { | 
                                                        
| 23 | - return;  | 
                                                        |
| 23 | + return;  | 
                                                        |
| 24 | 24 | }  | 
                                                        
| 25 | 25 | |
| 26 | 26 | // En cas de modification, il faut aussi actualiser la regexp de nettoyer_uri_var() dans inc/utils.php  | 
                                                        
| 27 | 27 |  if (!defined('_CONTEXTE_IGNORE_VARIABLES')) { | 
                                                        
| 28 | -	define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$|^fbclid$|^utm_)/"); | 
                                                        |
| 28 | +    define('_CONTEXTE_IGNORE_VARIABLES', "/(^var_|^PHPSESSID$|^fbclid$|^utm_)/"); | 
                                                        |
| 29 | 29 | }  | 
                                                        
| 30 | 30 | |
| 31 | 31 | // http://code.spip.net/@assembler  | 
                                                        
| 32 | 32 |  function assembler($fond, $connect = '') { | 
                                                        
| 33 | 33 | |
| 34 | - // flag_preserver est modifie ici, et utilise en globale  | 
                                                        |
| 35 | - // use_cache sert a informer le bouton d'admin pr savoir s'il met un *  | 
                                                        |
| 36 | - // contexte est utilise en globale dans le formulaire d'admin  | 
                                                        |
| 37 | -  | 
                                                        |
| 38 | - $GLOBALS['contexte'] = calculer_contexte();  | 
                                                        |
| 39 | -	$page = array('contexte_implicite' => calculer_contexte_implicite()); | 
                                                        |
| 40 | -	$page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', | 
                                                        |
| 41 | -			preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); | 
                                                        |
| 42 | - // Cette fonction est utilisee deux fois  | 
                                                        |
| 43 | -	$cacher = charger_fonction('cacher', 'public', true); | 
                                                        |
| 44 | - // Les quatre derniers parametres sont modifies par la fonction:  | 
                                                        |
| 45 | - // emplacement, validite, et, s'il est valide, contenu & age  | 
                                                        |
| 46 | -	if ($cacher) { | 
                                                        |
| 47 | - $res = $cacher($GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, $page, $lastmodified);  | 
                                                        |
| 48 | -	} else { | 
                                                        |
| 49 | - $GLOBALS['use_cache'] = -1;  | 
                                                        |
| 50 | - }  | 
                                                        |
| 51 | - // Si un resultat est retourne, c'est un message d'impossibilite  | 
                                                        |
| 52 | -	if ($res) { | 
                                                        |
| 53 | -		return array('texte' => $res); | 
                                                        |
| 54 | - }  | 
                                                        |
| 55 | -  | 
                                                        |
| 56 | -	if (!$chemin_cache || !$lastmodified) { | 
                                                        |
| 57 | - $lastmodified = time();  | 
                                                        |
| 58 | - }  | 
                                                        |
| 59 | -  | 
                                                        |
| 60 | - $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD');  | 
                                                        |
| 61 | - $calculer_page = true;  | 
                                                        |
| 62 | -  | 
                                                        |
| 63 | -	// Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) | 
                                                        |
| 64 | - // une perennite valide a meme reponse qu'une requete HEAD (par defaut les  | 
                                                        |
| 65 | - // pages sont dynamiques)  | 
                                                        |
| 66 | - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])  | 
                                                        |
| 67 | -		and (!defined('_VAR_MODE') or !_VAR_MODE) | 
                                                        |
| 68 | - and $chemin_cache  | 
                                                        |
| 69 | - and isset($page['entetes'])  | 
                                                        |
| 70 | - and isset($page['entetes']['Cache-Control'])  | 
                                                        |
| 71 | - and strstr($page['entetes']['Cache-Control'], 'max-age=')  | 
                                                        |
| 72 | - and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')  | 
                                                        |
| 73 | -	) { | 
                                                        |
| 74 | -		$since = preg_replace('/;.*/', '', | 
                                                        |
| 75 | - $_SERVER['HTTP_IF_MODIFIED_SINCE']);  | 
                                                        |
| 76 | -		$since = str_replace('GMT', '', $since); | 
                                                        |
| 77 | -		if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) { | 
                                                        |
| 78 | - $page['status'] = 304;  | 
                                                        |
| 79 | - $headers_only = true;  | 
                                                        |
| 80 | - $calculer_page = false;  | 
                                                        |
| 81 | - }  | 
                                                        |
| 82 | - }  | 
                                                        |
| 83 | -  | 
                                                        |
| 84 | - // Si requete HEAD ou Last-modified compatible, ignorer le texte  | 
                                                        |
| 85 | - // et pas de content-type (pour contrer le bouton admin de inc-public)  | 
                                                        |
| 86 | -	if (!$calculer_page) { | 
                                                        |
| 87 | - $page['texte'] = "";  | 
                                                        |
| 88 | -	} else { | 
                                                        |
| 89 | - // si la page est prise dans le cache  | 
                                                        |
| 90 | -		if (!$GLOBALS['use_cache']) { | 
                                                        |
| 91 | - // Informer les boutons d'admin du contexte  | 
                                                        |
| 92 | - // (fourni par urls_decoder_url ci-dessous lors de la mise en cache)  | 
                                                        |
| 93 | - $GLOBALS['contexte'] = $page['contexte'];  | 
                                                        |
| 94 | -  | 
                                                        |
| 95 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas  | 
                                                        |
| 96 | - // d'inversion url => objet  | 
                                                        |
| 97 | - // plus necessaire si on utilise bien la fonction urls_decoder_url  | 
                                                        |
| 98 | - #unset($_SERVER['REDIRECT_url_propre']);  | 
                                                        |
| 99 | - #unset($_ENV['url_propre']);  | 
                                                        |
| 100 | -		} else { | 
                                                        |
| 101 | - // Compat ascendante :  | 
                                                        |
| 102 | - // 1. $contexte est global  | 
                                                        |
| 103 | - // (a evacuer car urls_decoder_url gere ce probleme ?)  | 
                                                        |
| 104 | - // et calculer la page  | 
                                                        |
| 105 | -			if (!test_espace_prive()) { | 
                                                        |
| 106 | -				include_spip('inc/urls'); | 
                                                        |
| 107 | - list($fond, $GLOBALS['contexte'], $url_redirect) = urls_decoder_url(nettoyer_uri(), $fond, $GLOBALS['contexte'],  | 
                                                        |
| 108 | - true);  | 
                                                        |
| 109 | - }  | 
                                                        |
| 110 | - // squelette par defaut  | 
                                                        |
| 111 | -			if (!strlen($fond)) { | 
                                                        |
| 112 | - $fond = 'sommaire';  | 
                                                        |
| 113 | - }  | 
                                                        |
| 114 | -  | 
                                                        |
| 115 | - // produire la page : peut mettre a jour $lastmodified  | 
                                                        |
| 116 | -			$produire_page = charger_fonction('produire_page', 'public'); | 
                                                        |
| 117 | - $page = $produire_page($fond, $GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, null, $page,  | 
                                                        |
| 118 | - $lastmodified, $connect);  | 
                                                        |
| 119 | -			if ($page === '') { | 
                                                        |
| 120 | -				$erreur = _T('info_erreur_squelette2', | 
                                                        |
| 121 | -					array('fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES)); | 
                                                        |
| 122 | - erreur_squelette($erreur);  | 
                                                        |
| 123 | - // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4  | 
                                                        |
| 124 | -				$page = array('texte' => '', 'erreur' => $erreur); | 
                                                        |
| 125 | - }  | 
                                                        |
| 126 | - }  | 
                                                        |
| 127 | -  | 
                                                        |
| 128 | -		if ($page and $chemin_cache) { | 
                                                        |
| 129 | - $page['cache'] = $chemin_cache;  | 
                                                        |
| 130 | - }  | 
                                                        |
| 131 | -  | 
                                                        |
| 132 | - auto_content_type($page);  | 
                                                        |
| 133 | -  | 
                                                        |
| 134 | - $GLOBALS['flag_preserver'] |= headers_sent();  | 
                                                        |
| 135 | -  | 
                                                        |
| 136 | - // Definir les entetes si ce n'est fait  | 
                                                        |
| 137 | -		if (!$GLOBALS['flag_preserver']) { | 
                                                        |
| 138 | -			if ($GLOBALS['flag_ob']) { | 
                                                        |
| 139 | - // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions  | 
                                                        |
| 140 | - if (trim($page['texte']) === ''  | 
                                                        |
| 141 | - and _VAR_MODE != 'debug'  | 
                                                        |
| 142 | - and !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur  | 
                                                        |
| 143 | -				) { | 
                                                        |
| 144 | - $GLOBALS['contexte']['fond_erreur'] = $fond;  | 
                                                        |
| 145 | - $page = message_page_indisponible($page, $GLOBALS['contexte']);  | 
                                                        |
| 146 | - }  | 
                                                        |
| 147 | - // pas de cache client en mode 'observation'  | 
                                                        |
| 148 | -				if (defined('_VAR_MODE') and _VAR_MODE) { | 
                                                        |
| 149 | - $page['entetes']["Cache-Control"] = "no-cache,must-revalidate";  | 
                                                        |
| 150 | - $page['entetes']["Pragma"] = "no-cache";  | 
                                                        |
| 151 | - }  | 
                                                        |
| 152 | - }  | 
                                                        |
| 153 | - }  | 
                                                        |
| 154 | - }  | 
                                                        |
| 155 | -  | 
                                                        |
| 156 | - // Entete Last-Modified:  | 
                                                        |
| 157 | - // eviter d'etre incoherent en envoyant un lastmodified identique  | 
                                                        |
| 158 | - // a celui qu'on a refuse d'honorer plus haut (cf. #655)  | 
                                                        |
| 159 | - if ($lastmodified  | 
                                                        |
| 160 | - and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])  | 
                                                        |
| 161 | - and !isset($page['entetes']["Last-Modified"])  | 
                                                        |
| 162 | -	) { | 
                                                        |
| 163 | -		$page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"; | 
                                                        |
| 164 | - }  | 
                                                        |
| 165 | -  | 
                                                        |
| 166 | - // fermer la connexion apres les headers si requete HEAD  | 
                                                        |
| 167 | -	if ($headers_only) { | 
                                                        |
| 168 | - $page['entetes']["Connection"] = "close";  | 
                                                        |
| 169 | - }  | 
                                                        |
| 170 | -  | 
                                                        |
| 171 | - return $page;  | 
                                                        |
| 34 | + // flag_preserver est modifie ici, et utilise en globale  | 
                                                        |
| 35 | + // use_cache sert a informer le bouton d'admin pr savoir s'il met un *  | 
                                                        |
| 36 | + // contexte est utilise en globale dans le formulaire d'admin  | 
                                                        |
| 37 | +  | 
                                                        |
| 38 | + $GLOBALS['contexte'] = calculer_contexte();  | 
                                                        |
| 39 | +    $page = array('contexte_implicite' => calculer_contexte_implicite()); | 
                                                        |
| 40 | +    $page['contexte_implicite']['cache'] = $fond . preg_replace(',\.[a-zA-Z0-9]*$,', '', | 
                                                        |
| 41 | +            preg_replace('/[?].*$/', '', $GLOBALS['REQUEST_URI'])); | 
                                                        |
| 42 | + // Cette fonction est utilisee deux fois  | 
                                                        |
| 43 | +    $cacher = charger_fonction('cacher', 'public', true); | 
                                                        |
| 44 | + // Les quatre derniers parametres sont modifies par la fonction:  | 
                                                        |
| 45 | + // emplacement, validite, et, s'il est valide, contenu & age  | 
                                                        |
| 46 | +    if ($cacher) { | 
                                                        |
| 47 | + $res = $cacher($GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, $page, $lastmodified);  | 
                                                        |
| 48 | +    } else { | 
                                                        |
| 49 | + $GLOBALS['use_cache'] = -1;  | 
                                                        |
| 50 | + }  | 
                                                        |
| 51 | + // Si un resultat est retourne, c'est un message d'impossibilite  | 
                                                        |
| 52 | +    if ($res) { | 
                                                        |
| 53 | +        return array('texte' => $res); | 
                                                        |
| 54 | + }  | 
                                                        |
| 55 | +  | 
                                                        |
| 56 | +    if (!$chemin_cache || !$lastmodified) { | 
                                                        |
| 57 | + $lastmodified = time();  | 
                                                        |
| 58 | + }  | 
                                                        |
| 59 | +  | 
                                                        |
| 60 | + $headers_only = ($_SERVER['REQUEST_METHOD'] == 'HEAD');  | 
                                                        |
| 61 | + $calculer_page = true;  | 
                                                        |
| 62 | +  | 
                                                        |
| 63 | +    // Pour les pages non-dynamiques (indiquees par #CACHE{duree,cache-client}) | 
                                                        |
| 64 | + // une perennite valide a meme reponse qu'une requete HEAD (par defaut les  | 
                                                        |
| 65 | + // pages sont dynamiques)  | 
                                                        |
| 66 | + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])  | 
                                                        |
| 67 | +        and (!defined('_VAR_MODE') or !_VAR_MODE) | 
                                                        |
| 68 | + and $chemin_cache  | 
                                                        |
| 69 | + and isset($page['entetes'])  | 
                                                        |
| 70 | + and isset($page['entetes']['Cache-Control'])  | 
                                                        |
| 71 | + and strstr($page['entetes']['Cache-Control'], 'max-age=')  | 
                                                        |
| 72 | + and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')  | 
                                                        |
| 73 | +    ) { | 
                                                        |
| 74 | +        $since = preg_replace('/;.*/', '', | 
                                                        |
| 75 | + $_SERVER['HTTP_IF_MODIFIED_SINCE']);  | 
                                                        |
| 76 | +        $since = str_replace('GMT', '', $since); | 
                                                        |
| 77 | +        if (trim($since) == gmdate("D, d M Y H:i:s", $lastmodified)) { | 
                                                        |
| 78 | + $page['status'] = 304;  | 
                                                        |
| 79 | + $headers_only = true;  | 
                                                        |
| 80 | + $calculer_page = false;  | 
                                                        |
| 81 | + }  | 
                                                        |
| 82 | + }  | 
                                                        |
| 83 | +  | 
                                                        |
| 84 | + // Si requete HEAD ou Last-modified compatible, ignorer le texte  | 
                                                        |
| 85 | + // et pas de content-type (pour contrer le bouton admin de inc-public)  | 
                                                        |
| 86 | +    if (!$calculer_page) { | 
                                                        |
| 87 | + $page['texte'] = "";  | 
                                                        |
| 88 | +    } else { | 
                                                        |
| 89 | + // si la page est prise dans le cache  | 
                                                        |
| 90 | +        if (!$GLOBALS['use_cache']) { | 
                                                        |
| 91 | + // Informer les boutons d'admin du contexte  | 
                                                        |
| 92 | + // (fourni par urls_decoder_url ci-dessous lors de la mise en cache)  | 
                                                        |
| 93 | + $GLOBALS['contexte'] = $page['contexte'];  | 
                                                        |
| 94 | +  | 
                                                        |
| 95 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas  | 
                                                        |
| 96 | + // d'inversion url => objet  | 
                                                        |
| 97 | + // plus necessaire si on utilise bien la fonction urls_decoder_url  | 
                                                        |
| 98 | + #unset($_SERVER['REDIRECT_url_propre']);  | 
                                                        |
| 99 | + #unset($_ENV['url_propre']);  | 
                                                        |
| 100 | +        } else { | 
                                                        |
| 101 | + // Compat ascendante :  | 
                                                        |
| 102 | + // 1. $contexte est global  | 
                                                        |
| 103 | + // (a evacuer car urls_decoder_url gere ce probleme ?)  | 
                                                        |
| 104 | + // et calculer la page  | 
                                                        |
| 105 | +            if (!test_espace_prive()) { | 
                                                        |
| 106 | +                include_spip('inc/urls'); | 
                                                        |
| 107 | + list($fond, $GLOBALS['contexte'], $url_redirect) = urls_decoder_url(nettoyer_uri(), $fond, $GLOBALS['contexte'],  | 
                                                        |
| 108 | + true);  | 
                                                        |
| 109 | + }  | 
                                                        |
| 110 | + // squelette par defaut  | 
                                                        |
| 111 | +            if (!strlen($fond)) { | 
                                                        |
| 112 | + $fond = 'sommaire';  | 
                                                        |
| 113 | + }  | 
                                                        |
| 114 | +  | 
                                                        |
| 115 | + // produire la page : peut mettre a jour $lastmodified  | 
                                                        |
| 116 | +            $produire_page = charger_fonction('produire_page', 'public'); | 
                                                        |
| 117 | + $page = $produire_page($fond, $GLOBALS['contexte'], $GLOBALS['use_cache'], $chemin_cache, null, $page,  | 
                                                        |
| 118 | + $lastmodified, $connect);  | 
                                                        |
| 119 | +            if ($page === '') { | 
                                                        |
| 120 | +                $erreur = _T('info_erreur_squelette2', | 
                                                        |
| 121 | +                    array('fichier' => spip_htmlspecialchars($fond) . '.' . _EXTENSION_SQUELETTES)); | 
                                                        |
| 122 | + erreur_squelette($erreur);  | 
                                                        |
| 123 | + // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4  | 
                                                        |
| 124 | +                $page = array('texte' => '', 'erreur' => $erreur); | 
                                                        |
| 125 | + }  | 
                                                        |
| 126 | + }  | 
                                                        |
| 127 | +  | 
                                                        |
| 128 | +        if ($page and $chemin_cache) { | 
                                                        |
| 129 | + $page['cache'] = $chemin_cache;  | 
                                                        |
| 130 | + }  | 
                                                        |
| 131 | +  | 
                                                        |
| 132 | + auto_content_type($page);  | 
                                                        |
| 133 | +  | 
                                                        |
| 134 | + $GLOBALS['flag_preserver'] |= headers_sent();  | 
                                                        |
| 135 | +  | 
                                                        |
| 136 | + // Definir les entetes si ce n'est fait  | 
                                                        |
| 137 | +        if (!$GLOBALS['flag_preserver']) { | 
                                                        |
| 138 | +            if ($GLOBALS['flag_ob']) { | 
                                                        |
| 139 | + // Si la page est vide, produire l'erreur 404 ou message d'erreur pour les inclusions  | 
                                                        |
| 140 | + if (trim($page['texte']) === ''  | 
                                                        |
| 141 | + and _VAR_MODE != 'debug'  | 
                                                        |
| 142 | + and !isset($page['entetes']['Location']) // cette page realise une redirection, donc pas d'erreur  | 
                                                        |
| 143 | +                ) { | 
                                                        |
| 144 | + $GLOBALS['contexte']['fond_erreur'] = $fond;  | 
                                                        |
| 145 | + $page = message_page_indisponible($page, $GLOBALS['contexte']);  | 
                                                        |
| 146 | + }  | 
                                                        |
| 147 | + // pas de cache client en mode 'observation'  | 
                                                        |
| 148 | +                if (defined('_VAR_MODE') and _VAR_MODE) { | 
                                                        |
| 149 | + $page['entetes']["Cache-Control"] = "no-cache,must-revalidate";  | 
                                                        |
| 150 | + $page['entetes']["Pragma"] = "no-cache";  | 
                                                        |
| 151 | + }  | 
                                                        |
| 152 | + }  | 
                                                        |
| 153 | + }  | 
                                                        |
| 154 | + }  | 
                                                        |
| 155 | +  | 
                                                        |
| 156 | + // Entete Last-Modified:  | 
                                                        |
| 157 | + // eviter d'etre incoherent en envoyant un lastmodified identique  | 
                                                        |
| 158 | + // a celui qu'on a refuse d'honorer plus haut (cf. #655)  | 
                                                        |
| 159 | + if ($lastmodified  | 
                                                        |
| 160 | + and !isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])  | 
                                                        |
| 161 | + and !isset($page['entetes']["Last-Modified"])  | 
                                                        |
| 162 | +    ) { | 
                                                        |
| 163 | +        $page['entetes']["Last-Modified"] = gmdate("D, d M Y H:i:s", $lastmodified) . " GMT"; | 
                                                        |
| 164 | + }  | 
                                                        |
| 165 | +  | 
                                                        |
| 166 | + // fermer la connexion apres les headers si requete HEAD  | 
                                                        |
| 167 | +    if ($headers_only) { | 
                                                        |
| 168 | + $page['entetes']["Connection"] = "close";  | 
                                                        |
| 169 | + }  | 
                                                        |
| 170 | +  | 
                                                        |
| 171 | + return $page;  | 
                                                        |
| 172 | 172 | }  | 
                                                        
| 173 | 173 | |
| 174 | 174 | /**  | 
                                                        
@@ -187,19 +187,19 @@ discard block  | 
                                                    ||
| 187 | 187 | */  | 
                                                        
| 188 | 188 |  function calculer_contexte() { | 
                                                        
| 189 | 189 | |
| 190 | - $contexte = array();  | 
                                                        |
| 191 | -	foreach ($_GET as $var => $val) { | 
                                                        |
| 192 | -		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { | 
                                                        |
| 193 | - $contexte[$var] = $val;  | 
                                                        |
| 194 | - }  | 
                                                        |
| 195 | - }  | 
                                                        |
| 196 | -	foreach ($_POST as $var => $val) { | 
                                                        |
| 197 | -		if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { | 
                                                        |
| 198 | - $contexte[$var] = $val;  | 
                                                        |
| 199 | - }  | 
                                                        |
| 200 | - }  | 
                                                        |
| 201 | -  | 
                                                        |
| 202 | - return $contexte;  | 
                                                        |
| 190 | + $contexte = array();  | 
                                                        |
| 191 | +    foreach ($_GET as $var => $val) { | 
                                                        |
| 192 | +        if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { | 
                                                        |
| 193 | + $contexte[$var] = $val;  | 
                                                        |
| 194 | + }  | 
                                                        |
| 195 | + }  | 
                                                        |
| 196 | +    foreach ($_POST as $var => $val) { | 
                                                        |
| 197 | +        if (!preg_match(_CONTEXTE_IGNORE_VARIABLES, $var)) { | 
                                                        |
| 198 | + $contexte[$var] = $val;  | 
                                                        |
| 199 | + }  | 
                                                        |
| 200 | + }  | 
                                                        |
| 201 | +  | 
                                                        |
| 202 | + return $contexte;  | 
                                                        |
| 203 | 203 | }  | 
                                                        
| 204 | 204 | |
| 205 | 205 | /**  | 
                                                        
@@ -210,25 +210,25 @@ discard block  | 
                                                    ||
| 210 | 210 | * @return array  | 
                                                        
| 211 | 211 | */  | 
                                                        
| 212 | 212 |  function calculer_contexte_implicite() { | 
                                                        
| 213 | - static $notes = null;  | 
                                                        |
| 214 | -	if (is_null($notes)) { | 
                                                        |
| 215 | -		$notes = charger_fonction('notes', 'inc', true); | 
                                                        |
| 216 | - }  | 
                                                        |
| 217 | - $contexte_implicite = array(  | 
                                                        |
| 218 | - 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ?  | 
                                                        |
| 219 | - 'host' => (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null),  | 
                                                        |
| 220 | - 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''),  | 
                                                        |
| 221 | - 'espace' => test_espace_prive(),  | 
                                                        |
| 222 | - 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''),  | 
                                                        |
| 223 | - 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''),  | 
                                                        |
| 224 | -		'notes' => $notes ? $notes('', 'contexter_cache') : '', | 
                                                        |
| 225 | - 'spip_version_code' => $GLOBALS['spip_version_code'],  | 
                                                        |
| 226 | - );  | 
                                                        |
| 227 | -	if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { | 
                                                        |
| 228 | - $contexte_implicite['host'] .= "|" . $_SERVER['HTTP_X_FORWARDED_HOST'];  | 
                                                        |
| 229 | - }  | 
                                                        |
| 230 | -  | 
                                                        |
| 231 | - return $contexte_implicite;  | 
                                                        |
| 213 | + static $notes = null;  | 
                                                        |
| 214 | +    if (is_null($notes)) { | 
                                                        |
| 215 | +        $notes = charger_fonction('notes', 'inc', true); | 
                                                        |
| 216 | + }  | 
                                                        |
| 217 | + $contexte_implicite = array(  | 
                                                        |
| 218 | + 'squelettes' => $GLOBALS['dossier_squelettes'], // devrait etre 'chemin' => $GLOBALS['path_sig'], ?  | 
                                                        |
| 219 | + 'host' => (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null),  | 
                                                        |
| 220 | + 'https' => (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : ''),  | 
                                                        |
| 221 | + 'espace' => test_espace_prive(),  | 
                                                        |
| 222 | + 'marqueur' => (isset($GLOBALS['marqueur']) ? $GLOBALS['marqueur'] : ''),  | 
                                                        |
| 223 | + 'marqueur_skel' => (isset($GLOBALS['marqueur_skel']) ? $GLOBALS['marqueur_skel'] : ''),  | 
                                                        |
| 224 | +        'notes' => $notes ? $notes('', 'contexter_cache') : '', | 
                                                        |
| 225 | + 'spip_version_code' => $GLOBALS['spip_version_code'],  | 
                                                        |
| 226 | + );  | 
                                                        |
| 227 | +    if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { | 
                                                        |
| 228 | + $contexte_implicite['host'] .= "|" . $_SERVER['HTTP_X_FORWARDED_HOST'];  | 
                                                        |
| 229 | + }  | 
                                                        |
| 230 | +  | 
                                                        |
| 231 | + return $contexte_implicite;  | 
                                                        |
| 232 | 232 | }  | 
                                                        
| 233 | 233 | |
| 234 | 234 | //  | 
                                                        
@@ -238,50 +238,50 @@ discard block  | 
                                                    ||
| 238 | 238 | // http://code.spip.net/@auto_content_type  | 
                                                        
| 239 | 239 |  function auto_content_type($page) { | 
                                                        
| 240 | 240 | |
| 241 | -	if (!isset($GLOBALS['flag_preserver'])) { | 
                                                        |
| 242 | -		$GLOBALS['flag_preserver'] = ($page && preg_match("/header\s*\(\s*.content\-type:/isx", | 
                                                        |
| 243 | - $page['texte']) || (isset($page['entetes']['Content-Type'])));  | 
                                                        |
| 244 | - }  | 
                                                        |
| 241 | +    if (!isset($GLOBALS['flag_preserver'])) { | 
                                                        |
| 242 | +        $GLOBALS['flag_preserver'] = ($page && preg_match("/header\s*\(\s*.content\-type:/isx", | 
                                                        |
| 243 | + $page['texte']) || (isset($page['entetes']['Content-Type'])));  | 
                                                        |
| 244 | + }  | 
                                                        |
| 245 | 245 | }  | 
                                                        
| 246 | 246 | |
| 247 | 247 | // http://code.spip.net/@inclure_page  | 
                                                        
| 248 | 248 |  function inclure_page($fond, $contexte, $connect = '') { | 
                                                        
| 249 | - static $cacher, $produire_page;  | 
                                                        |
| 250 | -  | 
                                                        |
| 251 | - // enlever le fond de contexte inclus car sinon il prend la main  | 
                                                        |
| 252 | - // dans les sous inclusions -> boucle infinie d'inclusion identique  | 
                                                        |
| 253 | - // (cette precaution n'est probablement plus utile)  | 
                                                        |
| 254 | - unset($contexte['fond']);  | 
                                                        |
| 255 | -	$page = array('contexte_implicite' => calculer_contexte_implicite()); | 
                                                        |
| 256 | - $page['contexte_implicite']['cache'] = $fond;  | 
                                                        |
| 257 | -	if (is_null($cacher)) { | 
                                                        |
| 258 | -		$cacher = charger_fonction('cacher', 'public', true); | 
                                                        |
| 259 | - }  | 
                                                        |
| 260 | - // Les quatre derniers parametres sont modifies par la fonction:  | 
                                                        |
| 261 | - // emplacement, validite, et, s'il est valide, contenu & age  | 
                                                        |
| 262 | -	if ($cacher) { | 
                                                        |
| 263 | - $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude);  | 
                                                        |
| 264 | -	} else { | 
                                                        |
| 265 | - $use_cache = -1;  | 
                                                        |
| 266 | - }  | 
                                                        |
| 267 | - // $res = message d'erreur : on sort de la  | 
                                                        |
| 268 | -	if ($res) { | 
                                                        |
| 269 | -		return array('texte' => $res); | 
                                                        |
| 270 | - }  | 
                                                        |
| 271 | -  | 
                                                        |
| 272 | - // Si use_cache ne vaut pas 0, la page doit etre calculee  | 
                                                        |
| 273 | - // produire la page : peut mettre a jour $lastinclude  | 
                                                        |
| 274 | - // le contexte_cache envoye a cacher() a ete conserve et est passe a produire  | 
                                                        |
| 275 | -	if ($use_cache) { | 
                                                        |
| 276 | -		if (is_null($produire_page)) { | 
                                                        |
| 277 | -			$produire_page = charger_fonction('produire_page', 'public'); | 
                                                        |
| 278 | - }  | 
                                                        |
| 279 | - $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect);  | 
                                                        |
| 280 | - }  | 
                                                        |
| 281 | - // dans tous les cas, mettre a jour $GLOBALS['lastmodified']  | 
                                                        |
| 282 | - $GLOBALS['lastmodified'] = max((isset($GLOBALS['lastmodified']) ? $GLOBALS['lastmodified'] : 0), $lastinclude);  | 
                                                        |
| 283 | -  | 
                                                        |
| 284 | - return $page;  | 
                                                        |
| 249 | + static $cacher, $produire_page;  | 
                                                        |
| 250 | +  | 
                                                        |
| 251 | + // enlever le fond de contexte inclus car sinon il prend la main  | 
                                                        |
| 252 | + // dans les sous inclusions -> boucle infinie d'inclusion identique  | 
                                                        |
| 253 | + // (cette precaution n'est probablement plus utile)  | 
                                                        |
| 254 | + unset($contexte['fond']);  | 
                                                        |
| 255 | +    $page = array('contexte_implicite' => calculer_contexte_implicite()); | 
                                                        |
| 256 | + $page['contexte_implicite']['cache'] = $fond;  | 
                                                        |
| 257 | +    if (is_null($cacher)) { | 
                                                        |
| 258 | +        $cacher = charger_fonction('cacher', 'public', true); | 
                                                        |
| 259 | + }  | 
                                                        |
| 260 | + // Les quatre derniers parametres sont modifies par la fonction:  | 
                                                        |
| 261 | + // emplacement, validite, et, s'il est valide, contenu & age  | 
                                                        |
| 262 | +    if ($cacher) { | 
                                                        |
| 263 | + $res = $cacher($contexte, $use_cache, $chemin_cache, $page, $lastinclude);  | 
                                                        |
| 264 | +    } else { | 
                                                        |
| 265 | + $use_cache = -1;  | 
                                                        |
| 266 | + }  | 
                                                        |
| 267 | + // $res = message d'erreur : on sort de la  | 
                                                        |
| 268 | +    if ($res) { | 
                                                        |
| 269 | +        return array('texte' => $res); | 
                                                        |
| 270 | + }  | 
                                                        |
| 271 | +  | 
                                                        |
| 272 | + // Si use_cache ne vaut pas 0, la page doit etre calculee  | 
                                                        |
| 273 | + // produire la page : peut mettre a jour $lastinclude  | 
                                                        |
| 274 | + // le contexte_cache envoye a cacher() a ete conserve et est passe a produire  | 
                                                        |
| 275 | +    if ($use_cache) { | 
                                                        |
| 276 | +        if (is_null($produire_page)) { | 
                                                        |
| 277 | +            $produire_page = charger_fonction('produire_page', 'public'); | 
                                                        |
| 278 | + }  | 
                                                        |
| 279 | + $page = $produire_page($fond, $contexte, $use_cache, $chemin_cache, $contexte, $page, $lastinclude, $connect);  | 
                                                        |
| 280 | + }  | 
                                                        |
| 281 | + // dans tous les cas, mettre a jour $GLOBALS['lastmodified']  | 
                                                        |
| 282 | + $GLOBALS['lastmodified'] = max((isset($GLOBALS['lastmodified']) ? $GLOBALS['lastmodified'] : 0), $lastinclude);  | 
                                                        |
| 283 | +  | 
                                                        |
| 284 | + return $page;  | 
                                                        |
| 285 | 285 | }  | 
                                                        
| 286 | 286 | |
| 287 | 287 | /**  | 
                                                        
@@ -299,40 +299,40 @@ discard block  | 
                                                    ||
| 299 | 299 | * @return array  | 
                                                        
| 300 | 300 | */  | 
                                                        
| 301 | 301 | function public_produire_page_dist(  | 
                                                        
| 302 | - $fond,  | 
                                                        |
| 303 | - $contexte,  | 
                                                        |
| 304 | - $use_cache,  | 
                                                        |
| 305 | - $chemin_cache,  | 
                                                        |
| 306 | - $contexte_cache,  | 
                                                        |
| 307 | - &$page,  | 
                                                        |
| 308 | - &$lastinclude,  | 
                                                        |
| 309 | - $connect = ''  | 
                                                        |
| 302 | + $fond,  | 
                                                        |
| 303 | + $contexte,  | 
                                                        |
| 304 | + $use_cache,  | 
                                                        |
| 305 | + $chemin_cache,  | 
                                                        |
| 306 | + $contexte_cache,  | 
                                                        |
| 307 | + &$page,  | 
                                                        |
| 308 | + &$lastinclude,  | 
                                                        |
| 309 | + $connect = ''  | 
                                                        |
| 310 | 310 |  ) { | 
                                                        
| 311 | - static $parametrer, $cacher;  | 
                                                        |
| 312 | -	if (!$parametrer) { | 
                                                        |
| 313 | -		$parametrer = charger_fonction('parametrer', 'public'); | 
                                                        |
| 314 | - }  | 
                                                        |
| 315 | - $page = $parametrer($fond, $contexte, $chemin_cache, $connect);  | 
                                                        |
| 316 | - // et on l'enregistre sur le disque  | 
                                                        |
| 317 | - if ($chemin_cache  | 
                                                        |
| 318 | - and $use_cache > -1  | 
                                                        |
| 319 | - and is_array($page)  | 
                                                        |
| 320 | - and count($page)  | 
                                                        |
| 321 | - and isset($page['entetes']['X-Spip-Cache'])  | 
                                                        |
| 322 | - and $page['entetes']['X-Spip-Cache'] > 0  | 
                                                        |
| 323 | -	) { | 
                                                        |
| 324 | -		if (is_null($cacher)) { | 
                                                        |
| 325 | -			$cacher = charger_fonction('cacher', 'public', true); | 
                                                        |
| 326 | - }  | 
                                                        |
| 327 | - $lastinclude = time();  | 
                                                        |
| 328 | -		if ($cacher) { | 
                                                        |
| 329 | - $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude);  | 
                                                        |
| 330 | -		} else { | 
                                                        |
| 331 | - $use_cache = -1;  | 
                                                        |
| 332 | - }  | 
                                                        |
| 333 | - }  | 
                                                        |
| 334 | -  | 
                                                        |
| 335 | - return $page;  | 
                                                        |
| 311 | + static $parametrer, $cacher;  | 
                                                        |
| 312 | +    if (!$parametrer) { | 
                                                        |
| 313 | +        $parametrer = charger_fonction('parametrer', 'public'); | 
                                                        |
| 314 | + }  | 
                                                        |
| 315 | + $page = $parametrer($fond, $contexte, $chemin_cache, $connect);  | 
                                                        |
| 316 | + // et on l'enregistre sur le disque  | 
                                                        |
| 317 | + if ($chemin_cache  | 
                                                        |
| 318 | + and $use_cache > -1  | 
                                                        |
| 319 | + and is_array($page)  | 
                                                        |
| 320 | + and count($page)  | 
                                                        |
| 321 | + and isset($page['entetes']['X-Spip-Cache'])  | 
                                                        |
| 322 | + and $page['entetes']['X-Spip-Cache'] > 0  | 
                                                        |
| 323 | +    ) { | 
                                                        |
| 324 | +        if (is_null($cacher)) { | 
                                                        |
| 325 | +            $cacher = charger_fonction('cacher', 'public', true); | 
                                                        |
| 326 | + }  | 
                                                        |
| 327 | + $lastinclude = time();  | 
                                                        |
| 328 | +        if ($cacher) { | 
                                                        |
| 329 | + $cacher($contexte_cache, $use_cache, $chemin_cache, $page, $lastinclude);  | 
                                                        |
| 330 | +        } else { | 
                                                        |
| 331 | + $use_cache = -1;  | 
                                                        |
| 332 | + }  | 
                                                        |
| 333 | + }  | 
                                                        |
| 334 | +  | 
                                                        |
| 335 | + return $page;  | 
                                                        |
| 336 | 336 | }  | 
                                                        
| 337 | 337 | |
| 338 | 338 | // Fonction inseree par le compilateur dans le code compile.  | 
                                                        
@@ -346,12 +346,12 @@ discard block  | 
                                                    ||
| 346 | 346 | // 4: langue  | 
                                                        
| 347 | 347 | |
| 348 | 348 |  function inserer_balise_dynamique($contexte_exec, $contexte_compil) { | 
                                                        
| 349 | -	if (!is_array($contexte_exec)) { | 
                                                        |
| 350 | - echo $contexte_exec;  | 
                                                        |
| 351 | - } // message d'erreur etc  | 
                                                        |
| 352 | -	else { | 
                                                        |
| 353 | - inclure_balise_dynamique($contexte_exec, true, $contexte_compil);  | 
                                                        |
| 354 | - }  | 
                                                        |
| 349 | +    if (!is_array($contexte_exec)) { | 
                                                        |
| 350 | + echo $contexte_exec;  | 
                                                        |
| 351 | + } // message d'erreur etc  | 
                                                        |
| 352 | +    else { | 
                                                        |
| 353 | + inclure_balise_dynamique($contexte_exec, true, $contexte_compil);  | 
                                                        |
| 354 | + }  | 
                                                        |
| 355 | 355 | }  | 
                                                        
| 356 | 356 | |
| 357 | 357 | /**  | 
                                                        
@@ -366,124 +366,124 @@ discard block  | 
                                                    ||
| 366 | 366 | * @return string  | 
                                                        
| 367 | 367 | */  | 
                                                        
| 368 | 368 |  function inclure_balise_dynamique($texte, $echo = true, $contexte_compil = array()) { | 
                                                        
| 369 | -	if (is_array($texte)) { | 
                                                        |
| 370 | -  | 
                                                        |
| 371 | - list($fond, $delainc, $contexte_inclus) = $texte;  | 
                                                        |
| 372 | -  | 
                                                        |
| 373 | - // delais a l'ancienne, c'est pratiquement mort  | 
                                                        |
| 374 | - $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : null;  | 
                                                        |
| 375 | - $GLOBALS['delais'] = $delainc;  | 
                                                        |
| 376 | -  | 
                                                        |
| 377 | - $page = recuperer_fond($fond, $contexte_inclus,  | 
                                                        |
| 378 | -			array('trim' => false, 'raw' => true, 'compil' => $contexte_compil)); | 
                                                        |
| 379 | -  | 
                                                        |
| 380 | - $texte = $page['texte'];  | 
                                                        |
| 381 | -  | 
                                                        |
| 382 | - $GLOBALS['delais'] = $d;  | 
                                                        |
| 383 | - // Faire remonter les entetes  | 
                                                        |
| 384 | -		if (is_array($page['entetes'])) { | 
                                                        |
| 385 | - // mais pas toutes  | 
                                                        |
| 386 | - unset($page['entetes']['X-Spip-Cache']);  | 
                                                        |
| 387 | - unset($page['entetes']['Content-Type']);  | 
                                                        |
| 388 | -			if (isset($GLOBALS['page']) and is_array($GLOBALS['page'])) { | 
                                                        |
| 389 | -				if (!is_array($GLOBALS['page']['entetes'])) { | 
                                                        |
| 390 | - $GLOBALS['page']['entetes'] = array();  | 
                                                        |
| 391 | - }  | 
                                                        |
| 392 | - $GLOBALS['page']['entetes'] =  | 
                                                        |
| 393 | - array_merge($GLOBALS['page']['entetes'], $page['entetes']);  | 
                                                        |
| 394 | - }  | 
                                                        |
| 395 | - }  | 
                                                        |
| 396 | -		// _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines | 
                                                        |
| 397 | - if (isset($page['contexte']['_pipelines'])  | 
                                                        |
| 398 | - and is_array($page['contexte']['_pipelines'])  | 
                                                        |
| 399 | - and count($page['contexte']['_pipelines'])  | 
                                                        |
| 400 | -		) { | 
                                                        |
| 401 | -			foreach ($page['contexte']['_pipelines'] as $pipe => $args) { | 
                                                        |
| 402 | - $args['contexte'] = $page['contexte'];  | 
                                                        |
| 403 | - unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul  | 
                                                        |
| 404 | - $texte = pipeline(  | 
                                                        |
| 405 | - $pipe,  | 
                                                        |
| 406 | - array(  | 
                                                        |
| 407 | - 'data' => $texte,  | 
                                                        |
| 408 | - 'args' => $args  | 
                                                        |
| 409 | - ),  | 
                                                        |
| 410 | - false  | 
                                                        |
| 411 | - );  | 
                                                        |
| 412 | - }  | 
                                                        |
| 413 | - }  | 
                                                        |
| 414 | - }  | 
                                                        |
| 415 | -  | 
                                                        |
| 416 | -	if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { | 
                                                        |
| 417 | - // compatibilite : avant on donnait le numero de ligne ou rien.  | 
                                                        |
| 418 | - $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil);  | 
                                                        |
| 419 | - $GLOBALS['debug_objets']['resultat'][$ligne] = $texte;  | 
                                                        |
| 420 | - }  | 
                                                        |
| 421 | -	if ($echo) { | 
                                                        |
| 422 | - echo $texte;  | 
                                                        |
| 423 | -	} else { | 
                                                        |
| 424 | - return $texte;  | 
                                                        |
| 425 | - }  | 
                                                        |
| 369 | +    if (is_array($texte)) { | 
                                                        |
| 370 | +  | 
                                                        |
| 371 | + list($fond, $delainc, $contexte_inclus) = $texte;  | 
                                                        |
| 372 | +  | 
                                                        |
| 373 | + // delais a l'ancienne, c'est pratiquement mort  | 
                                                        |
| 374 | + $d = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : null;  | 
                                                        |
| 375 | + $GLOBALS['delais'] = $delainc;  | 
                                                        |
| 376 | +  | 
                                                        |
| 377 | + $page = recuperer_fond($fond, $contexte_inclus,  | 
                                                        |
| 378 | +            array('trim' => false, 'raw' => true, 'compil' => $contexte_compil)); | 
                                                        |
| 379 | +  | 
                                                        |
| 380 | + $texte = $page['texte'];  | 
                                                        |
| 381 | +  | 
                                                        |
| 382 | + $GLOBALS['delais'] = $d;  | 
                                                        |
| 383 | + // Faire remonter les entetes  | 
                                                        |
| 384 | +        if (is_array($page['entetes'])) { | 
                                                        |
| 385 | + // mais pas toutes  | 
                                                        |
| 386 | + unset($page['entetes']['X-Spip-Cache']);  | 
                                                        |
| 387 | + unset($page['entetes']['Content-Type']);  | 
                                                        |
| 388 | +            if (isset($GLOBALS['page']) and is_array($GLOBALS['page'])) { | 
                                                        |
| 389 | +                if (!is_array($GLOBALS['page']['entetes'])) { | 
                                                        |
| 390 | + $GLOBALS['page']['entetes'] = array();  | 
                                                        |
| 391 | + }  | 
                                                        |
| 392 | + $GLOBALS['page']['entetes'] =  | 
                                                        |
| 393 | + array_merge($GLOBALS['page']['entetes'], $page['entetes']);  | 
                                                        |
| 394 | + }  | 
                                                        |
| 395 | + }  | 
                                                        |
| 396 | +        // _pipelines au pluriel array('nom_pipeline' => $args...) avec une syntaxe permettant plusieurs pipelines | 
                                                        |
| 397 | + if (isset($page['contexte']['_pipelines'])  | 
                                                        |
| 398 | + and is_array($page['contexte']['_pipelines'])  | 
                                                        |
| 399 | + and count($page['contexte']['_pipelines'])  | 
                                                        |
| 400 | +        ) { | 
                                                        |
| 401 | +            foreach ($page['contexte']['_pipelines'] as $pipe => $args) { | 
                                                        |
| 402 | + $args['contexte'] = $page['contexte'];  | 
                                                        |
| 403 | + unset($args['contexte']['_pipelines']); // par precaution, meme si le risque de boucle infinie est a priori nul  | 
                                                        |
| 404 | + $texte = pipeline(  | 
                                                        |
| 405 | + $pipe,  | 
                                                        |
| 406 | + array(  | 
                                                        |
| 407 | + 'data' => $texte,  | 
                                                        |
| 408 | + 'args' => $args  | 
                                                        |
| 409 | + ),  | 
                                                        |
| 410 | + false  | 
                                                        |
| 411 | + );  | 
                                                        |
| 412 | + }  | 
                                                        |
| 413 | + }  | 
                                                        |
| 414 | + }  | 
                                                        |
| 415 | +  | 
                                                        |
| 416 | +    if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { | 
                                                        |
| 417 | + // compatibilite : avant on donnait le numero de ligne ou rien.  | 
                                                        |
| 418 | + $ligne = intval(isset($contexte_compil[3]) ? $contexte_compil[3] : $contexte_compil);  | 
                                                        |
| 419 | + $GLOBALS['debug_objets']['resultat'][$ligne] = $texte;  | 
                                                        |
| 420 | + }  | 
                                                        |
| 421 | +    if ($echo) { | 
                                                        |
| 422 | + echo $texte;  | 
                                                        |
| 423 | +    } else { | 
                                                        |
| 424 | + return $texte;  | 
                                                        |
| 425 | + }  | 
                                                        |
| 426 | 426 | }  | 
                                                        
| 427 | 427 | |
| 428 | 428 | // http://code.spip.net/@message_page_indisponible  | 
                                                        
| 429 | 429 |  function message_page_indisponible($page, $contexte) { | 
                                                        
| 430 | - static $deja = false;  | 
                                                        |
| 431 | -	if ($deja) { | 
                                                        |
| 432 | - return "erreur";  | 
                                                        |
| 433 | - }  | 
                                                        |
| 434 | - $codes = array(  | 
                                                        |
| 435 | - '404' => '404 Not Found',  | 
                                                        |
| 436 | - '503' => '503 Service Unavailable',  | 
                                                        |
| 437 | - );  | 
                                                        |
| 438 | -  | 
                                                        |
| 439 | - $contexte['status'] = ($page !== false) ? '404' : '503';  | 
                                                        |
| 440 | - $contexte['code'] = $codes[$contexte['status']];  | 
                                                        |
| 441 | - $contexte['fond'] = '404'; // gere les 2 erreurs  | 
                                                        |
| 442 | -	if (!isset($contexte['lang'])) { | 
                                                        |
| 443 | - $contexte['lang'] = $GLOBALS['spip_lang'];  | 
                                                        |
| 444 | - }  | 
                                                        |
| 445 | -  | 
                                                        |
| 446 | - $deja = true;  | 
                                                        |
| 447 | - // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent  | 
                                                        |
| 448 | - // ex restriction d'acces => 401  | 
                                                        |
| 449 | -	$contexte = pipeline('page_indisponible', $contexte); | 
                                                        |
| 450 | -  | 
                                                        |
| 451 | - // produire la page d'erreur  | 
                                                        |
| 452 | - $page = inclure_page($contexte['fond'], $contexte);  | 
                                                        |
| 453 | -	if (!$page) { | 
                                                        |
| 454 | -		$page = inclure_page('404', $contexte); | 
                                                        |
| 455 | - }  | 
                                                        |
| 456 | - $page['status'] = $contexte['status'];  | 
                                                        |
| 457 | -  | 
                                                        |
| 458 | - return $page;  | 
                                                        |
| 430 | + static $deja = false;  | 
                                                        |
| 431 | +    if ($deja) { | 
                                                        |
| 432 | + return "erreur";  | 
                                                        |
| 433 | + }  | 
                                                        |
| 434 | + $codes = array(  | 
                                                        |
| 435 | + '404' => '404 Not Found',  | 
                                                        |
| 436 | + '503' => '503 Service Unavailable',  | 
                                                        |
| 437 | + );  | 
                                                        |
| 438 | +  | 
                                                        |
| 439 | + $contexte['status'] = ($page !== false) ? '404' : '503';  | 
                                                        |
| 440 | + $contexte['code'] = $codes[$contexte['status']];  | 
                                                        |
| 441 | + $contexte['fond'] = '404'; // gere les 2 erreurs  | 
                                                        |
| 442 | +    if (!isset($contexte['lang'])) { | 
                                                        |
| 443 | + $contexte['lang'] = $GLOBALS['spip_lang'];  | 
                                                        |
| 444 | + }  | 
                                                        |
| 445 | +  | 
                                                        |
| 446 | + $deja = true;  | 
                                                        |
| 447 | + // passer aux plugins qui peuvent decider d'une page d'erreur plus pertinent  | 
                                                        |
| 448 | + // ex restriction d'acces => 401  | 
                                                        |
| 449 | +    $contexte = pipeline('page_indisponible', $contexte); | 
                                                        |
| 450 | +  | 
                                                        |
| 451 | + // produire la page d'erreur  | 
                                                        |
| 452 | + $page = inclure_page($contexte['fond'], $contexte);  | 
                                                        |
| 453 | +    if (!$page) { | 
                                                        |
| 454 | +        $page = inclure_page('404', $contexte); | 
                                                        |
| 455 | + }  | 
                                                        |
| 456 | + $page['status'] = $contexte['status'];  | 
                                                        |
| 457 | +  | 
                                                        |
| 458 | + return $page;  | 
                                                        |
| 459 | 459 | }  | 
                                                        
| 460 | 460 | |
| 461 | 461 | // temporairement ici : a mettre dans le futur inc/modeles  | 
                                                        
| 462 | 462 |  // creer_contexte_de_modele('left', 'autostart=true', ...) renvoie un array() | 
                                                        
| 463 | 463 | // http://code.spip.net/@creer_contexte_de_modele  | 
                                                        
| 464 | 464 |  function creer_contexte_de_modele($args) { | 
                                                        
| 465 | - $contexte = array();  | 
                                                        |
| 466 | -	foreach ($args as $var => $val) { | 
                                                        |
| 467 | -		if (is_int($var)) { // argument pas formate | 
                                                        |
| 468 | -			if (in_array($val, array('left', 'right', 'center'))) { | 
                                                        |
| 469 | - $var = 'align';  | 
                                                        |
| 470 | - $contexte[$var] = $val;  | 
                                                        |
| 471 | -			} else { | 
                                                        |
| 472 | -				$args = explode('=', $val); | 
                                                        |
| 473 | - if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args  | 
                                                        |
| 474 | -				{ | 
                                                        |
| 475 | - $contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1);  | 
                                                        |
| 476 | - } else // notation abregee  | 
                                                        |
| 477 | -				{ | 
                                                        |
| 478 | - $contexte[trim($val)] = trim($val);  | 
                                                        |
| 479 | - }  | 
                                                        |
| 480 | - }  | 
                                                        |
| 481 | -		} else { | 
                                                        |
| 482 | - $contexte[$var] = $val;  | 
                                                        |
| 483 | - }  | 
                                                        |
| 484 | - }  | 
                                                        |
| 485 | -  | 
                                                        |
| 486 | - return $contexte;  | 
                                                        |
| 465 | + $contexte = array();  | 
                                                        |
| 466 | +    foreach ($args as $var => $val) { | 
                                                        |
| 467 | +        if (is_int($var)) { // argument pas formate | 
                                                        |
| 468 | +            if (in_array($val, array('left', 'right', 'center'))) { | 
                                                        |
| 469 | + $var = 'align';  | 
                                                        |
| 470 | + $contexte[$var] = $val;  | 
                                                        |
| 471 | +            } else { | 
                                                        |
| 472 | +                $args = explode('=', $val); | 
                                                        |
| 473 | + if (count($args) >= 2) // Flashvars=arg1=machin&arg2=truc genere plus de deux args  | 
                                                        |
| 474 | +                { | 
                                                        |
| 475 | + $contexte[trim($args[0])] = substr($val, strlen($args[0]) + 1);  | 
                                                        |
| 476 | + } else // notation abregee  | 
                                                        |
| 477 | +                { | 
                                                        |
| 478 | + $contexte[trim($val)] = trim($val);  | 
                                                        |
| 479 | + }  | 
                                                        |
| 480 | + }  | 
                                                        |
| 481 | +        } else { | 
                                                        |
| 482 | + $contexte[$var] = $val;  | 
                                                        |
| 483 | + }  | 
                                                        |
| 484 | + }  | 
                                                        |
| 485 | +  | 
                                                        |
| 486 | + return $contexte;  | 
                                                        |
| 487 | 487 | }  | 
                                                        
| 488 | 488 | |
| 489 | 489 | /**  | 
                                                        
@@ -502,95 +502,95 @@ discard block  | 
                                                    ||
| 502 | 502 | */  | 
                                                        
| 503 | 503 |  function inclure_modele($type, $id, $params, $lien, $connect = '', $env = array()) { | 
                                                        
| 504 | 504 | |
| 505 | - static $compteur;  | 
                                                        |
| 506 | -	if (++$compteur > 10) { | 
                                                        |
| 507 | - return '';  | 
                                                        |
| 508 | - } # ne pas boucler indefiniment  | 
                                                        |
| 509 | -  | 
                                                        |
| 510 | - $type = strtolower($type);  | 
                                                        |
| 511 | -  | 
                                                        |
| 512 | - $fond = $class = '';  | 
                                                        |
| 513 | -  | 
                                                        |
| 514 | -	$params = array_filter(explode('|', $params)); | 
                                                        |
| 515 | -	if ($params) { | 
                                                        |
| 516 | - $soustype = current($params);  | 
                                                        |
| 517 | - $soustype = strtolower(trim($soustype));  | 
                                                        |
| 518 | -		if (in_array($soustype, array('left', 'right', 'center', 'ajax'))) { | 
                                                        |
| 519 | - $soustype = next($params);  | 
                                                        |
| 520 | - $soustype = strtolower($soustype);  | 
                                                        |
| 521 | - }  | 
                                                        |
| 522 | -  | 
                                                        |
| 523 | -		if (preg_match(',^[a-z0-9_]+$,', $soustype)) { | 
                                                        |
| 524 | -			if (!trouve_modele($fond = ($type . '_' . $soustype))) { | 
                                                        |
| 525 | - $fond = '';  | 
                                                        |
| 526 | - $class = $soustype;  | 
                                                        |
| 527 | - }  | 
                                                        |
| 528 | - // enlever le sous type des params  | 
                                                        |
| 529 | - $params = array_diff($params, array($soustype));  | 
                                                        |
| 530 | - }  | 
                                                        |
| 531 | - }  | 
                                                        |
| 532 | -  | 
                                                        |
| 533 | - // Si ca marche pas en precisant le sous-type, prendre le type  | 
                                                        |
| 534 | -	if (!$fond and !trouve_modele($fond = $type)) { | 
                                                        |
| 535 | -		spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE); | 
                                                        |
| 536 | -  | 
                                                        |
| 537 | - return false;  | 
                                                        |
| 538 | - }  | 
                                                        |
| 539 | - $fond = 'modeles/' . $fond;  | 
                                                        |
| 540 | - // Creer le contexte  | 
                                                        |
| 541 | - $contexte = $env;  | 
                                                        |
| 542 | - $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte  | 
                                                        |
| 543 | -  | 
                                                        |
| 544 | - // Le numero du modele est mis dans l'environnement  | 
                                                        |
| 545 | - // d'une part sous l'identifiant "id"  | 
                                                        |
| 546 | - // et d'autre part sous l'identifiant de la cle primaire  | 
                                                        |
| 547 | - // par la fonction id_table_objet,  | 
                                                        |
| 548 | - // (<article1> =>> article =>> id_article =>> id_article=1)  | 
                                                        |
| 549 | - $_id = id_table_objet($type);  | 
                                                        |
| 550 | - $contexte['id'] = $contexte[$_id] = $id;  | 
                                                        |
| 551 | -  | 
                                                        |
| 552 | -	if (isset($class)) { | 
                                                        |
| 553 | - $contexte['class'] = $class;  | 
                                                        |
| 554 | - }  | 
                                                        |
| 555 | -  | 
                                                        |
| 556 | -	// Si un lien a ete passe en parametre, ex: [<modele1>->url] ou [<modele1|title_du_lien{hreflang}->url] | 
                                                        |
| 557 | -	if ($lien) { | 
                                                        |
| 558 | -		# un eventuel guillemet (") sera reechappe par #ENV | 
                                                        |
| 559 | -		$contexte['lien'] = str_replace(""", '"', $lien['href']); | 
                                                        |
| 560 | - $contexte['lien_class'] = $lien['class'];  | 
                                                        |
| 561 | - $contexte['lien_mime'] = $lien['mime'];  | 
                                                        |
| 562 | - $contexte['lien_title'] = $lien['title'];  | 
                                                        |
| 563 | - $contexte['lien_hreflang'] = $lien['hreflang'];  | 
                                                        |
| 564 | - }  | 
                                                        |
| 565 | -  | 
                                                        |
| 566 | - // Traiter les parametres  | 
                                                        |
| 567 | - // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en>  | 
                                                        |
| 568 | - $arg_list = creer_contexte_de_modele($params);  | 
                                                        |
| 569 | - $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args  | 
                                                        |
| 570 | - $contexte = array_merge($contexte, $arg_list);  | 
                                                        |
| 571 | -  | 
                                                        |
| 572 | - // Appliquer le modele avec le contexte  | 
                                                        |
| 573 | - // et provoquer le sessionnement du squelette appelant si le modèle et sessionné  | 
                                                        |
| 574 | -	$retour = recuperer_fond($fond, $contexte, array('sessionnement_contaminant'=>true), $connect); | 
                                                        |
| 575 | -  | 
                                                        |
| 576 | - // Regarder si le modele tient compte des liens (il *doit* alors indiquer  | 
                                                        |
| 577 | - // spip_lien_ok dans les classes de son conteneur de premier niveau ;  | 
                                                        |
| 578 | - // sinon, s'il y a un lien, on l'ajoute classiquement  | 
                                                        |
| 579 | -	if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')) . ' ', | 
                                                        |
| 580 | -		'spip_lien_ok')) { | 
                                                        |
| 581 | - $retour = inserer_attribut($retour, 'class',  | 
                                                        |
| 582 | -			trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); | 
                                                        |
| 583 | -	} else { | 
                                                        |
| 584 | -		if ($lien) { | 
                                                        |
| 585 | - $retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . "</a>";  | 
                                                        |
| 586 | - }  | 
                                                        |
| 587 | - }  | 
                                                        |
| 588 | -  | 
                                                        |
| 589 | - $compteur--;  | 
                                                        |
| 590 | -  | 
                                                        |
| 591 | - return (isset($arg_list['ajax']) and $arg_list['ajax'] == 'ajax')  | 
                                                        |
| 592 | - ? encoder_contexte_ajax($contexte, '', $retour)  | 
                                                        |
| 593 | - : $retour;  | 
                                                        |
| 505 | + static $compteur;  | 
                                                        |
| 506 | +    if (++$compteur > 10) { | 
                                                        |
| 507 | + return '';  | 
                                                        |
| 508 | + } # ne pas boucler indefiniment  | 
                                                        |
| 509 | +  | 
                                                        |
| 510 | + $type = strtolower($type);  | 
                                                        |
| 511 | +  | 
                                                        |
| 512 | + $fond = $class = '';  | 
                                                        |
| 513 | +  | 
                                                        |
| 514 | +    $params = array_filter(explode('|', $params)); | 
                                                        |
| 515 | +    if ($params) { | 
                                                        |
| 516 | + $soustype = current($params);  | 
                                                        |
| 517 | + $soustype = strtolower(trim($soustype));  | 
                                                        |
| 518 | +        if (in_array($soustype, array('left', 'right', 'center', 'ajax'))) { | 
                                                        |
| 519 | + $soustype = next($params);  | 
                                                        |
| 520 | + $soustype = strtolower($soustype);  | 
                                                        |
| 521 | + }  | 
                                                        |
| 522 | +  | 
                                                        |
| 523 | +        if (preg_match(',^[a-z0-9_]+$,', $soustype)) { | 
                                                        |
| 524 | +            if (!trouve_modele($fond = ($type . '_' . $soustype))) { | 
                                                        |
| 525 | + $fond = '';  | 
                                                        |
| 526 | + $class = $soustype;  | 
                                                        |
| 527 | + }  | 
                                                        |
| 528 | + // enlever le sous type des params  | 
                                                        |
| 529 | + $params = array_diff($params, array($soustype));  | 
                                                        |
| 530 | + }  | 
                                                        |
| 531 | + }  | 
                                                        |
| 532 | +  | 
                                                        |
| 533 | + // Si ca marche pas en precisant le sous-type, prendre le type  | 
                                                        |
| 534 | +    if (!$fond and !trouve_modele($fond = $type)) { | 
                                                        |
| 535 | +        spip_log("Modele $type introuvable", _LOG_INFO_IMPORTANTE); | 
                                                        |
| 536 | +  | 
                                                        |
| 537 | + return false;  | 
                                                        |
| 538 | + }  | 
                                                        |
| 539 | + $fond = 'modeles/' . $fond;  | 
                                                        |
| 540 | + // Creer le contexte  | 
                                                        |
| 541 | + $contexte = $env;  | 
                                                        |
| 542 | + $contexte['dir_racine'] = _DIR_RACINE; # eviter de mixer un cache racine et un cache ecrire (meme si pour l'instant les modeles ne sont pas caches, le resultat etant different il faut que le contexte en tienne compte  | 
                                                        |
| 543 | +  | 
                                                        |
| 544 | + // Le numero du modele est mis dans l'environnement  | 
                                                        |
| 545 | + // d'une part sous l'identifiant "id"  | 
                                                        |
| 546 | + // et d'autre part sous l'identifiant de la cle primaire  | 
                                                        |
| 547 | + // par la fonction id_table_objet,  | 
                                                        |
| 548 | + // (<article1> =>> article =>> id_article =>> id_article=1)  | 
                                                        |
| 549 | + $_id = id_table_objet($type);  | 
                                                        |
| 550 | + $contexte['id'] = $contexte[$_id] = $id;  | 
                                                        |
| 551 | +  | 
                                                        |
| 552 | +    if (isset($class)) { | 
                                                        |
| 553 | + $contexte['class'] = $class;  | 
                                                        |
| 554 | + }  | 
                                                        |
| 555 | +  | 
                                                        |
| 556 | +    // Si un lien a ete passe en parametre, ex: [<modele1>->url] ou [<modele1|title_du_lien{hreflang}->url] | 
                                                        |
| 557 | +    if ($lien) { | 
                                                        |
| 558 | +        # un eventuel guillemet (") sera reechappe par #ENV | 
                                                        |
| 559 | +        $contexte['lien'] = str_replace(""", '"', $lien['href']); | 
                                                        |
| 560 | + $contexte['lien_class'] = $lien['class'];  | 
                                                        |
| 561 | + $contexte['lien_mime'] = $lien['mime'];  | 
                                                        |
| 562 | + $contexte['lien_title'] = $lien['title'];  | 
                                                        |
| 563 | + $contexte['lien_hreflang'] = $lien['hreflang'];  | 
                                                        |
| 564 | + }  | 
                                                        |
| 565 | +  | 
                                                        |
| 566 | + // Traiter les parametres  | 
                                                        |
| 567 | + // par exemple : <img1|center>, <emb12|autostart=true> ou <doc1|lang=en>  | 
                                                        |
| 568 | + $arg_list = creer_contexte_de_modele($params);  | 
                                                        |
| 569 | + $contexte['args'] = $arg_list; // on passe la liste des arguments du modeles dans une variable args  | 
                                                        |
| 570 | + $contexte = array_merge($contexte, $arg_list);  | 
                                                        |
| 571 | +  | 
                                                        |
| 572 | + // Appliquer le modele avec le contexte  | 
                                                        |
| 573 | + // et provoquer le sessionnement du squelette appelant si le modèle et sessionné  | 
                                                        |
| 574 | +    $retour = recuperer_fond($fond, $contexte, array('sessionnement_contaminant'=>true), $connect); | 
                                                        |
| 575 | +  | 
                                                        |
| 576 | + // Regarder si le modele tient compte des liens (il *doit* alors indiquer  | 
                                                        |
| 577 | + // spip_lien_ok dans les classes de son conteneur de premier niveau ;  | 
                                                        |
| 578 | + // sinon, s'il y a un lien, on l'ajoute classiquement  | 
                                                        |
| 579 | +    if (strstr(' ' . ($classes = extraire_attribut($retour, 'class')) . ' ', | 
                                                        |
| 580 | +        'spip_lien_ok')) { | 
                                                        |
| 581 | + $retour = inserer_attribut($retour, 'class',  | 
                                                        |
| 582 | +            trim(str_replace(' spip_lien_ok ', ' ', " $classes "))); | 
                                                        |
| 583 | +    } else { | 
                                                        |
| 584 | +        if ($lien) { | 
                                                        |
| 585 | + $retour = "<a href='" . $lien['href'] . "' class='" . $lien['class'] . "'>" . $retour . "</a>";  | 
                                                        |
| 586 | + }  | 
                                                        |
| 587 | + }  | 
                                                        |
| 588 | +  | 
                                                        |
| 589 | + $compteur--;  | 
                                                        |
| 590 | +  | 
                                                        |
| 591 | + return (isset($arg_list['ajax']) and $arg_list['ajax'] == 'ajax')  | 
                                                        |
| 592 | + ? encoder_contexte_ajax($contexte, '', $retour)  | 
                                                        |
| 593 | + : $retour;  | 
                                                        |
| 594 | 594 | }  | 
                                                        
| 595 | 595 | |
| 596 | 596 | // Un inclure_page qui marche aussi pour l'espace prive  | 
                                                        
@@ -600,92 +600,92 @@ discard block  | 
                                                    ||
| 600 | 600 | // http://code.spip.net/@evaluer_fond  | 
                                                        
| 601 | 601 |  function evaluer_fond($fond, $contexte = array(), $connect = null) { | 
                                                        
| 602 | 602 | |
| 603 | - $page = inclure_page($fond, $contexte, $connect);  | 
                                                        |
| 604 | -  | 
                                                        |
| 605 | -	if (!$page) { | 
                                                        |
| 606 | - return $page;  | 
                                                        |
| 607 | - }  | 
                                                        |
| 608 | - // eval $page et affecte $res  | 
                                                        |
| 609 | - include _ROOT_RESTREINT . "public/evaluer_page.php";  | 
                                                        |
| 610 | -  | 
                                                        |
| 611 | - // Lever un drapeau (global) si le fond utilise #SESSION  | 
                                                        |
| 612 | - // a destination de public/parametrer  | 
                                                        |
| 613 | - // pour remonter vers les inclusions appelantes  | 
                                                        |
| 614 | - // il faut bien lever ce drapeau apres avoir evalue le fond  | 
                                                        |
| 615 | - // pour ne pas faire descendre le flag vers les inclusions appelees  | 
                                                        |
| 616 | - if (isset($page['invalideurs'])  | 
                                                        |
| 617 | - and isset($page['invalideurs']['session'])  | 
                                                        |
| 618 | -	) { | 
                                                        |
| 619 | - $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session'];  | 
                                                        |
| 620 | - }  | 
                                                        |
| 621 | -  | 
                                                        |
| 622 | - return $page;  | 
                                                        |
| 603 | + $page = inclure_page($fond, $contexte, $connect);  | 
                                                        |
| 604 | +  | 
                                                        |
| 605 | +    if (!$page) { | 
                                                        |
| 606 | + return $page;  | 
                                                        |
| 607 | + }  | 
                                                        |
| 608 | + // eval $page et affecte $res  | 
                                                        |
| 609 | + include _ROOT_RESTREINT . "public/evaluer_page.php";  | 
                                                        |
| 610 | +  | 
                                                        |
| 611 | + // Lever un drapeau (global) si le fond utilise #SESSION  | 
                                                        |
| 612 | + // a destination de public/parametrer  | 
                                                        |
| 613 | + // pour remonter vers les inclusions appelantes  | 
                                                        |
| 614 | + // il faut bien lever ce drapeau apres avoir evalue le fond  | 
                                                        |
| 615 | + // pour ne pas faire descendre le flag vers les inclusions appelees  | 
                                                        |
| 616 | + if (isset($page['invalideurs'])  | 
                                                        |
| 617 | + and isset($page['invalideurs']['session'])  | 
                                                        |
| 618 | +    ) { | 
                                                        |
| 619 | + $GLOBALS['cache_utilise_session'] = $page['invalideurs']['session'];  | 
                                                        |
| 620 | + }  | 
                                                        |
| 621 | +  | 
                                                        |
| 622 | + return $page;  | 
                                                        |
| 623 | 623 | }  | 
                                                        
| 624 | 624 | |
| 625 | 625 | |
| 626 | 626 | // http://code.spip.net/@page_base_href  | 
                                                        
| 627 | 627 |  function page_base_href(&$texte) { | 
                                                        
| 628 | - static $set_html_base = null;  | 
                                                        |
| 629 | -	if (is_null($set_html_base)) { | 
                                                        |
| 630 | -		if (!defined('_SET_HTML_BASE')) | 
                                                        |
| 631 | - // si la profondeur est superieure a 1  | 
                                                        |
| 632 | - // est que ce n'est pas une url page ni une url action  | 
                                                        |
| 633 | - // activer par defaut  | 
                                                        |
| 634 | -		{ | 
                                                        |
| 635 | - $set_html_base = ((  | 
                                                        |
| 636 | - $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)  | 
                                                        |
| 637 | - and _request(_SPIP_PAGE) !== 'login'  | 
                                                        |
| 638 | -				and !_request('action')) ? true : false); | 
                                                        |
| 639 | -		} else { | 
                                                        |
| 640 | - $set_html_base = _SET_HTML_BASE;  | 
                                                        |
| 641 | - }  | 
                                                        |
| 642 | - }  | 
                                                        |
| 643 | -  | 
                                                        |
| 644 | - if ($set_html_base  | 
                                                        |
| 645 | - and isset($GLOBALS['html']) and $GLOBALS['html']  | 
                                                        |
| 646 | - and $GLOBALS['profondeur_url'] > 0  | 
                                                        |
| 647 | - and ($poshead = strpos($texte, '</head>')) !== false  | 
                                                        |
| 648 | -	) { | 
                                                        |
| 649 | - $head = substr($texte, 0, $poshead);  | 
                                                        |
| 650 | - $insert = false;  | 
                                                        |
| 651 | -		if (strpos($head, '<base') === false) { | 
                                                        |
| 652 | - $insert = true;  | 
                                                        |
| 653 | -		} else { | 
                                                        |
| 654 | - // si aucun <base ...> n'a de href c'est bon quand meme !  | 
                                                        |
| 655 | - $insert = true;  | 
                                                        |
| 656 | -			include_spip('inc/filtres'); | 
                                                        |
| 657 | - $bases = extraire_balises($head, 'base');  | 
                                                        |
| 658 | -			foreach ($bases as $base) { | 
                                                        |
| 659 | -				if (extraire_attribut($base, 'href')) { | 
                                                        |
| 660 | - $insert = false;  | 
                                                        |
| 661 | - }  | 
                                                        |
| 662 | - }  | 
                                                        |
| 663 | - }  | 
                                                        |
| 664 | -		if ($insert) { | 
                                                        |
| 665 | -			include_spip('inc/filtres_mini'); | 
                                                        |
| 666 | - // ajouter un base qui reglera tous les liens relatifs  | 
                                                        |
| 667 | -			$base = url_absolue('./'); | 
                                                        |
| 668 | - $bbase = "\n<base href=\"$base\" />";  | 
                                                        |
| 669 | -			if (($pos = strpos($head, '<head>')) !== false) { | 
                                                        |
| 670 | - $head = substr_replace($head, $bbase, $pos + 6, 0);  | 
                                                        |
| 671 | -			} elseif (preg_match(",<head[^>]*>,i", $head, $r)) { | 
                                                        |
| 672 | - $head = str_replace($r[0], $r[0] . $bbase, $head);  | 
                                                        |
| 673 | - }  | 
                                                        |
| 674 | - $texte = $head . substr($texte, $poshead);  | 
                                                        |
| 675 | - // gerer les ancres  | 
                                                        |
| 676 | - $base = $_SERVER['REQUEST_URI'];  | 
                                                        |
| 677 | - // pas de guillemets ni < dans l'URL qu'on insere dans le HTML  | 
                                                        |
| 678 | -			if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) { | 
                                                        |
| 679 | -				$base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base); | 
                                                        |
| 680 | - }  | 
                                                        |
| 681 | -			if (strpos($texte, "href='#") !== false) { | 
                                                        |
| 682 | -				$texte = str_replace("href='#", "href='$base#", $texte); | 
                                                        |
| 683 | - }  | 
                                                        |
| 684 | -			if (strpos($texte, "href=\"#") !== false) { | 
                                                        |
| 685 | -				$texte = str_replace("href=\"#", "href=\"$base#", $texte); | 
                                                        |
| 686 | - }  | 
                                                        |
| 687 | - }  | 
                                                        |
| 688 | - }  | 
                                                        |
| 628 | + static $set_html_base = null;  | 
                                                        |
| 629 | +    if (is_null($set_html_base)) { | 
                                                        |
| 630 | +        if (!defined('_SET_HTML_BASE')) | 
                                                        |
| 631 | + // si la profondeur est superieure a 1  | 
                                                        |
| 632 | + // est que ce n'est pas une url page ni une url action  | 
                                                        |
| 633 | + // activer par defaut  | 
                                                        |
| 634 | +        { | 
                                                        |
| 635 | + $set_html_base = ((  | 
                                                        |
| 636 | + $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)  | 
                                                        |
| 637 | + and _request(_SPIP_PAGE) !== 'login'  | 
                                                        |
| 638 | +                and !_request('action')) ? true : false); | 
                                                        |
| 639 | +        } else { | 
                                                        |
| 640 | + $set_html_base = _SET_HTML_BASE;  | 
                                                        |
| 641 | + }  | 
                                                        |
| 642 | + }  | 
                                                        |
| 643 | +  | 
                                                        |
| 644 | + if ($set_html_base  | 
                                                        |
| 645 | + and isset($GLOBALS['html']) and $GLOBALS['html']  | 
                                                        |
| 646 | + and $GLOBALS['profondeur_url'] > 0  | 
                                                        |
| 647 | + and ($poshead = strpos($texte, '</head>')) !== false  | 
                                                        |
| 648 | +    ) { | 
                                                        |
| 649 | + $head = substr($texte, 0, $poshead);  | 
                                                        |
| 650 | + $insert = false;  | 
                                                        |
| 651 | +        if (strpos($head, '<base') === false) { | 
                                                        |
| 652 | + $insert = true;  | 
                                                        |
| 653 | +        } else { | 
                                                        |
| 654 | + // si aucun <base ...> n'a de href c'est bon quand meme !  | 
                                                        |
| 655 | + $insert = true;  | 
                                                        |
| 656 | +            include_spip('inc/filtres'); | 
                                                        |
| 657 | + $bases = extraire_balises($head, 'base');  | 
                                                        |
| 658 | +            foreach ($bases as $base) { | 
                                                        |
| 659 | +                if (extraire_attribut($base, 'href')) { | 
                                                        |
| 660 | + $insert = false;  | 
                                                        |
| 661 | + }  | 
                                                        |
| 662 | + }  | 
                                                        |
| 663 | + }  | 
                                                        |
| 664 | +        if ($insert) { | 
                                                        |
| 665 | +            include_spip('inc/filtres_mini'); | 
                                                        |
| 666 | + // ajouter un base qui reglera tous les liens relatifs  | 
                                                        |
| 667 | +            $base = url_absolue('./'); | 
                                                        |
| 668 | + $bbase = "\n<base href=\"$base\" />";  | 
                                                        |
| 669 | +            if (($pos = strpos($head, '<head>')) !== false) { | 
                                                        |
| 670 | + $head = substr_replace($head, $bbase, $pos + 6, 0);  | 
                                                        |
| 671 | +            } elseif (preg_match(",<head[^>]*>,i", $head, $r)) { | 
                                                        |
| 672 | + $head = str_replace($r[0], $r[0] . $bbase, $head);  | 
                                                        |
| 673 | + }  | 
                                                        |
| 674 | + $texte = $head . substr($texte, $poshead);  | 
                                                        |
| 675 | + // gerer les ancres  | 
                                                        |
| 676 | + $base = $_SERVER['REQUEST_URI'];  | 
                                                        |
| 677 | + // pas de guillemets ni < dans l'URL qu'on insere dans le HTML  | 
                                                        |
| 678 | +            if (strpos($base,"'") or strpos($base,'"') or strpos($base,'<')) { | 
                                                        |
| 679 | +                $base = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $base); | 
                                                        |
| 680 | + }  | 
                                                        |
| 681 | +            if (strpos($texte, "href='#") !== false) { | 
                                                        |
| 682 | +                $texte = str_replace("href='#", "href='$base#", $texte); | 
                                                        |
| 683 | + }  | 
                                                        |
| 684 | +            if (strpos($texte, "href=\"#") !== false) { | 
                                                        |
| 685 | +                $texte = str_replace("href=\"#", "href=\"$base#", $texte); | 
                                                        |
| 686 | + }  | 
                                                        |
| 687 | + }  | 
                                                        |
| 688 | + }  | 
                                                        |
| 689 | 689 | }  | 
                                                        
| 690 | 690 | |
| 691 | 691 | |
@@ -693,8 +693,8 @@ discard block  | 
                                                    ||
| 693 | 693 | // et demarrent par X-Spip-...  | 
                                                        
| 694 | 694 | // http://code.spip.net/@envoyer_entetes  | 
                                                        
| 695 | 695 |  function envoyer_entetes($entetes) { | 
                                                        
| 696 | - foreach ($entetes as $k => $v) # if (strncmp($k, 'X-Spip-', 7))  | 
                                                        |
| 697 | -	{ | 
                                                        |
| 698 | - @header(strlen($v) ? "$k: $v" : $k);  | 
                                                        |
| 699 | - }  | 
                                                        |
| 696 | + foreach ($entetes as $k => $v) # if (strncmp($k, 'X-Spip-', 7))  | 
                                                        |
| 697 | +    { | 
                                                        |
| 698 | + @header(strlen($v) ? "$k: $v" : $k);  | 
                                                        |
| 699 | + }  | 
                                                        |
| 700 | 700 | }  |