| 4 | 
           david | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           /***************************************************************************\
  | 
        
        
            | 
            | 
           4 | 
            *  SPIP, Systeme de publication pour l'internet                           *
  | 
        
        
            | 
            | 
           5 | 
            *                                                                         *
  | 
        
        
            | 
            | 
           6 | 
            *  Copyright (c) 2001-2005                                                *
  | 
        
        
            | 
            | 
           7 | 
            *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
  | 
        
        
            | 
            | 
           8 | 
            *                                                                         *
  | 
        
        
            | 
            | 
           9 | 
            *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
  | 
        
        
            | 
            | 
           10 | 
            *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
  | 
        
        
            | 
            | 
           11 | 
           \***************************************************************************/
  | 
        
        
            | 
            | 
           12 | 
              | 
        
        
            | 
            | 
           13 | 
              | 
        
        
            | 
            | 
           14 | 
           // Ce fichier ne sera execute qu'une fois
  | 
        
        
            | 
            | 
           15 | 
           if (defined("_INC_PUBLIC_GLOBAL")) return;
  | 
        
        
            | 
            | 
           16 | 
           define("_INC_PUBLIC_GLOBAL", "1");
  | 
        
        
            | 
            | 
           17 | 
              | 
        
        
            | 
            | 
           18 | 
           // fonction principale declenchant tout le service
  | 
        
        
            | 
            | 
           19 | 
           function calcule_header_et_page ($fond, $delais) {
  | 
        
        
            | 
            | 
           20 | 
           	  global $affiche_boutons_admin, $auteur_session, $flag_dynamique,
  | 
        
        
            | 
            | 
           21 | 
           	  $flag_ob, $flag_preserver, $forcer_lang, $ignore_auth_http,
  | 
        
        
            | 
            | 
           22 | 
           	  $lastmodified, $recherche, $use_cache, $var_confirm, $var_mode,
  | 
        
        
            | 
            | 
           23 | 
           	  $var_recherche, $tableau_des_erreurs;
  | 
        
        
            | 
            | 
           24 | 
           	  global $_GET, $_POST;
  | 
        
        
            | 
            | 
           25 | 
              | 
        
        
            | 
            | 
           26 | 
           	// Regler le $delais par defaut
  | 
        
        
            | 
            | 
           27 | 
           	if (!isset($delais))
  | 
        
        
            | 
            | 
           28 | 
           		$delais = 1 * 3600;
  | 
        
        
            | 
            | 
           29 | 
           	if ($recherche)
  | 
        
        
            | 
            | 
           30 | 
           		$delais = 0;
  | 
        
        
            | 
            | 
           31 | 
              | 
        
        
            | 
            | 
           32 | 
           	// authentification du visiteur
  | 
        
        
            | 
            | 
           33 | 
           	if ($GLOBALS['_COOKIE']['spip_session'] OR
  | 
        
        
            | 
            | 
           34 | 
           	($GLOBALS['_SERVER']['PHP_AUTH_USER']  AND !$ignore_auth_http)) {
  | 
        
        
            | 
            | 
           35 | 
           		include_ecrire ("inc_session.php3");
  | 
        
        
            | 
            | 
           36 | 
           		verifier_visiteur();
  | 
        
        
            | 
            | 
           37 | 
           	}
  | 
        
        
            | 
            | 
           38 | 
           	// multilinguisme
  | 
        
        
            | 
            | 
           39 | 
           	if ($forcer_lang AND ($forcer_lang!=='non') AND !count($_POST)) {
  | 
        
        
            | 
            | 
           40 | 
           		include_ecrire('inc_lang.php3');
  | 
        
        
            | 
            | 
           41 | 
           		verifier_lang_url();
  | 
        
        
            | 
            | 
           42 | 
           	}
  | 
        
        
            | 
            | 
           43 | 
           	if ($_GET['lang']) {
  | 
        
        
            | 
            | 
           44 | 
           		include_ecrire('inc_lang.php3');
  | 
        
        
            | 
            | 
           45 | 
           		lang_select($_GET['lang']);
  | 
        
        
            | 
            | 
           46 | 
           	}
  | 
        
        
            | 
            | 
           47 | 
              | 
        
        
            | 
            | 
           48 | 
           	// Si envoi pour un forum, enregistrer puis rediriger
  | 
        
        
            | 
            | 
           49 | 
              | 
        
        
            | 
            | 
           50 | 
           	if (strlen($_POST['confirmer_forum']) > 0
  | 
        
        
            | 
            | 
           51 | 
           	OR ($GLOBALS['afficher_texte']=='non' AND $_POST['ajouter_mot'])) {
  | 
        
        
            | 
            | 
           52 | 
           		include('inc-messforum.php3');
  | 
        
        
            | 
            | 
           53 | 
           		redirige_par_entete(enregistre_forum());
  | 
        
        
            | 
            | 
           54 | 
           	}
  | 
        
        
            | 
            | 
           55 | 
              | 
        
        
            | 
            | 
           56 | 
           	// si signature de petition, l'enregistrer avant d'afficher la page
  | 
        
        
            | 
            | 
           57 | 
           	// afin que celle-ci contienne la signature
  | 
        
        
            | 
            | 
           58 | 
              | 
        
        
            | 
            | 
           59 | 
           	if ($_GET['var_confirm']) {
  | 
        
        
            | 
            | 
           60 | 
           		include_local(find_in_path('inc-formulaire_signature.php3'));
  | 
        
        
            | 
            | 
           61 | 
           		reponse_confirmation($_GET['id_article'], $var_confirm);
  | 
        
        
            | 
            | 
           62 | 
           	}
  | 
        
        
            | 
            | 
           63 | 
              | 
        
        
            | 
            | 
           64 | 
           	//  refus du debug si pas dans les options generales ni admin connecte
  | 
        
        
            | 
            | 
           65 | 
           	if ($var_mode=='debug') {
  | 
        
        
            | 
            | 
           66 | 
           		if (($GLOBALS['code_activation_debug'] == 'oui')
  | 
        
        
            | 
            | 
           67 | 
           		OR $auteur_session['statut'] == '0minirezo')
  | 
        
        
            | 
            | 
           68 | 
           			spip_log('debug !');
  | 
        
        
            | 
            | 
           69 | 
           		else {
  | 
        
        
            | 
            | 
           70 | 
           			$link = new Link();
  | 
        
        
            | 
            | 
           71 | 
           			$link->addvar('var_mode', 'debug');
  | 
        
        
            | 
            | 
           72 | 
           			redirige_par_entete('spip_login.php3?url='
  | 
        
        
            | 
            | 
           73 | 
           				.urlencode($link->getUrl()));
  | 
        
        
            | 
            | 
           74 | 
           			exit;
  | 
        
        
            | 
            | 
           75 | 
           		}
  | 
        
        
            | 
            | 
           76 | 
           	}
  | 
        
        
            | 
            | 
           77 | 
              | 
        
        
            | 
            | 
           78 | 
           	// est-on admin ?
  | 
        
        
            | 
            | 
           79 | 
           	if ($affiche_boutons_admin = (
  | 
        
        
            | 
            | 
           80 | 
           	(!$flag_preserver AND $GLOBALS['_COOKIE']['spip_admin'])
  | 
        
        
            | 
            | 
           81 | 
           	OR $var_mode == 'debug'))
  | 
        
        
            | 
            | 
           82 | 
           		include_local(find_in_path('inc-formulaire_admin.php3'));
  | 
        
        
            | 
            | 
           83 | 
              | 
        
        
            | 
            | 
           84 | 
           	$tableau_des_erreurs = array();
  | 
        
        
            | 
            | 
           85 | 
           	$page = afficher_page_globale ($fond, $delais, $use_cache);
  | 
        
        
            | 
            | 
           86 | 
              | 
        
        
            | 
            | 
           87 | 
           	//
  | 
        
        
            | 
            | 
           88 | 
           	// Envoyer les entetes appropries
  | 
        
        
            | 
            | 
           89 | 
           	// a condition d'etre sur de pouvoir le faire
  | 
        
        
            | 
            | 
           90 | 
           	//
  | 
        
        
            | 
            | 
           91 | 
           	if (!headers_sent() AND !$flag_preserver) {
  | 
        
        
            | 
            | 
           92 | 
              | 
        
        
            | 
            | 
           93 | 
           		// Content-type: par defaut html+charset (poss surcharge par la suite)
  | 
        
        
            | 
            | 
           94 | 
           		header("Content-Type: text/html; charset=".lire_meta('charset'));
  | 
        
        
            | 
            | 
           95 | 
              | 
        
        
            | 
            | 
           96 | 
           		if ($flag_ob) {
  | 
        
        
            | 
            | 
           97 | 
           			// Si la page est vide, gerer l'erreur 404
  | 
        
        
            | 
            | 
           98 | 
           			if (trim($page['texte']) === ''
  | 
        
        
            | 
            | 
           99 | 
           			AND $var_mode != 'debug') {
  | 
        
        
            | 
            | 
           100 | 
           				http_status(404);
  | 
        
        
            | 
            | 
           101 | 
           				$contexte_inclus = array(
  | 
        
        
            | 
            | 
           102 | 
           					'erreur_aucun' => message_erreur_404()
  | 
        
        
            | 
            | 
           103 | 
           				);
  | 
        
        
            | 
            | 
           104 | 
           				$page = array('texte' => '<'.'?php
  | 
        
        
            | 
            | 
           105 | 
           					$contexte_inclus = array();
  | 
        
        
            | 
            | 
           106 | 
           					include(\''.addslashes(find_in_path('404.php3')).'\');
  | 
        
        
            | 
            | 
           107 | 
           					?'.'>',
  | 
        
        
            | 
            | 
           108 | 
           				'process_ins' => 'php');
  | 
        
        
            | 
            | 
           109 | 
           			}
  | 
        
        
            | 
            | 
           110 | 
           			// Interdire au client de cacher un login, un admin ou un recalcul
  | 
        
        
            | 
            | 
           111 | 
           			else if ($flag_dynamique OR $var_mode
  | 
        
        
            | 
            | 
           112 | 
           			OR $GLOBALS['_COOKIE']['spip_admin']) {
  | 
        
        
            | 
            | 
           113 | 
           				header("Cache-Control: no-cache,must-revalidate");
  | 
        
        
            | 
            | 
           114 | 
           				header("Pragma: no-cache");
  | 
        
        
            | 
            | 
           115 | 
           			}
  | 
        
        
            | 
            | 
           116 | 
           			// Pour les autres donner l'heure de modif
  | 
        
        
            | 
            | 
           117 | 
           			else if ($lastmodified) {
  | 
        
        
            | 
            | 
           118 | 
           				header("Last-Modified: ".http_gmoddate($lastmodified)." GMT");
  | 
        
        
            | 
            | 
           119 | 
           			}
  | 
        
        
            | 
            | 
           120 | 
           		}
  | 
        
        
            | 
            | 
           121 | 
           	}
  | 
        
        
            | 
            | 
           122 | 
              | 
        
        
            | 
            | 
           123 | 
           	return $page;
  | 
        
        
            | 
            | 
           124 | 
           }
  | 
        
        
            | 
            | 
           125 | 
              | 
        
        
            | 
            | 
           126 | 
              | 
        
        
            | 
            | 
           127 | 
           //
  | 
        
        
            | 
            | 
           128 | 
           // Aller chercher la page dans le cache ou pas
  | 
        
        
            | 
            | 
           129 | 
           //
  | 
        
        
            | 
            | 
           130 | 
           function obtenir_page ($contexte, $chemin_cache, $delais, &$use_cache, $fond, $inclusion=false) {
  | 
        
        
            | 
            | 
           131 | 
           	global $lastmodified;
  | 
        
        
            | 
            | 
           132 | 
              | 
        
        
            | 
            | 
           133 | 
           	if (!$use_cache) {
  | 
        
        
            | 
            | 
           134 | 
           		include_local('inc-calcul.php3');
  | 
        
        
            | 
            | 
           135 | 
              | 
        
        
            | 
            | 
           136 | 
           		// page globale ? calculer le contexte
  | 
        
        
            | 
            | 
           137 | 
           		if (!$contexte)
  | 
        
        
            | 
            | 
           138 | 
           			$contexte = calculer_contexte();
  | 
        
        
            | 
            | 
           139 | 
              | 
        
        
            | 
            | 
           140 | 
           		spip_timer('calculer_page');
  | 
        
        
            | 
            | 
           141 | 
           		$page = calculer_page($chemin_cache,
  | 
        
        
            | 
            | 
           142 | 
           			array('fond' => $fond,
  | 
        
        
            | 
            | 
           143 | 
           				'contexte' => $contexte),
  | 
        
        
            | 
            | 
           144 | 
           			$delais,
  | 
        
        
            | 
            | 
           145 | 
           			$inclusion);
  | 
        
        
            | 
            | 
           146 | 
              | 
        
        
            | 
            | 
           147 | 
           		$lastmodified = time();
  | 
        
        
            | 
            | 
           148 | 
              | 
        
        
            | 
            | 
           149 | 
           		// log
  | 
        
        
            | 
            | 
           150 | 
           		if (!$log = $chemin_cache) $log = "($fond, delais=$delais, "
  | 
        
        
            | 
            | 
           151 | 
           		. $GLOBALS['_SERVER']['REQUEST_METHOD'].")";
  | 
        
        
            | 
            | 
           152 | 
           		spip_log (($inclusion ? 'calcul inclus':'calcul').' ('
  | 
        
        
            | 
            | 
           153 | 
           		.spip_timer('calculer_page')."): $log");
  | 
        
        
            | 
            | 
           154 | 
              | 
        
        
            | 
            | 
           155 | 
           		// Nouveau cache : creer un invalideur 't' fixant la date
  | 
        
        
            | 
            | 
           156 | 
           		// d'expiration et la taille du fichier
  | 
        
        
            | 
            | 
           157 | 
           		if (@file_exists($chemin_cache)) {
  | 
        
        
            | 
            | 
           158 | 
           			// Ici on ajoute 3600s pour eviter toute concurrence
  | 
        
        
            | 
            | 
           159 | 
           			// entre un invalideur et un appel public de page
  | 
        
        
            | 
            | 
           160 | 
           			$bedtime = time() + $delais + 3600;
  | 
        
        
            | 
            | 
           161 | 
           			$taille = @filesize($chemin_cache);
  | 
        
        
            | 
            | 
           162 | 
           			$fichier = addslashes($chemin_cache);
  | 
        
        
            | 
            | 
           163 | 
           			spip_query("INSERT IGNORE INTO spip_caches (fichier,id,type,taille)
  | 
        
        
            | 
            | 
           164 | 
           			VALUES ('$fichier','$bedtime','t','$taille')");
  | 
        
        
            | 
            | 
           165 | 
           		}
  | 
        
        
            | 
            | 
           166 | 
              | 
        
        
            | 
            | 
           167 | 
           	} else {
  | 
        
        
            | 
            | 
           168 | 
              | 
        
        
            | 
            | 
           169 | 
           		//
  | 
        
        
            | 
            | 
           170 | 
           		// Lire le fichier cache
  | 
        
        
            | 
            | 
           171 | 
           		//
  | 
        
        
            | 
            | 
           172 | 
           		lire_fichier ($chemin_cache, $page['texte']);
  | 
        
        
            | 
            | 
           173 | 
           		$lastmodified = max($lastmodified, @filemtime($chemin_cache));
  | 
        
        
            | 
            | 
           174 | 
           		# spip_log ("cache $chemin_cache $lastmodified");
  | 
        
        
            | 
            | 
           175 | 
              | 
        
        
            | 
            | 
           176 | 
           		//
  | 
        
        
            | 
            | 
           177 | 
           		// Lire sa carte d'identite & fixer le contexte global
  | 
        
        
            | 
            | 
           178 | 
           		//
  | 
        
        
            | 
            | 
           179 | 
           		if (preg_match("/^<!-- ([^\n]*) -->\n(.*)/ms", $page['texte'], $match)
  | 
        
        
            | 
            | 
           180 | 
           		AND is_array($meta_donnees = unserialize($match[1]))) {
  | 
        
        
            | 
            | 
           181 | 
           			foreach ($meta_donnees as $var=>$val)
  | 
        
        
            | 
            | 
           182 | 
           				$page[$var] = $val;
  | 
        
        
            | 
            | 
           183 | 
              | 
        
        
            | 
            | 
           184 | 
           			$page['texte'] = $match[2];
  | 
        
        
            | 
            | 
           185 | 
              | 
        
        
            | 
            | 
           186 | 
           			// Remplir les globals pour les boutons d'admin
  | 
        
        
            | 
            | 
           187 | 
           			if (!$inclusion AND is_array($page['contexte']))
  | 
        
        
            | 
            | 
           188 | 
           				foreach ($page['contexte'] as $var=>$val)
  | 
        
        
            | 
            | 
           189 | 
           					$GLOBALS[$var] = $val;
  | 
        
        
            | 
            | 
           190 | 
           		}
  | 
        
        
            | 
            | 
           191 | 
              | 
        
        
            | 
            | 
           192 | 
           	}
  | 
        
        
            | 
            | 
           193 | 
              | 
        
        
            | 
            | 
           194 | 
           	return $page;
  | 
        
        
            | 
            | 
           195 | 
           }
  | 
        
        
            | 
            | 
           196 | 
              | 
        
        
            | 
            | 
           197 | 
              | 
        
        
            | 
            | 
           198 | 
           //
  | 
        
        
            | 
            | 
           199 | 
           // Appeler cette fonction pour obtenir la page principale
  | 
        
        
            | 
            | 
           200 | 
           //
  | 
        
        
            | 
            | 
           201 | 
           function afficher_page_globale ($fond, $delais, &$use_cache) {
  | 
        
        
            | 
            | 
           202 | 
           	global $flag_preserver, $flag_dynamique, $lastmodified;
  | 
        
        
            | 
            | 
           203 | 
           	global $var_preview, $var_mode, $delais;
  | 
        
        
            | 
            | 
           204 | 
           	include_local ("inc-cache.php3");
  | 
        
        
            | 
            | 
           205 | 
              | 
        
        
            | 
            | 
           206 | 
           	// demande de previsualisation ?
  | 
        
        
            | 
            | 
           207 | 
           	// -> inc-calcul.php3 n'enregistrera pas les fichiers caches
  | 
        
        
            | 
            | 
           208 | 
           	// -> inc-reqsql-squel.php3 acceptera les objets non 'publie'
  | 
        
        
            | 
            | 
           209 | 
           	if ($var_mode == 'preview') {
  | 
        
        
            | 
            | 
           210 | 
           		// Verifier qu'on a le droit de previsualisation
  | 
        
        
            | 
            | 
           211 | 
           		$statut = $GLOBALS['auteur_session']['statut'];
  | 
        
        
            | 
            | 
           212 | 
           		if ($statut=='0minirezo' OR
  | 
        
        
            | 
            | 
           213 | 
           		(lire_meta('preview')=='1comite' AND $statut=='1comite')) {
  | 
        
        
            | 
            | 
           214 | 
           			$var_mode = 'recalcul';
  | 
        
        
            | 
            | 
           215 | 
           			$delais = 0;
  | 
        
        
            | 
            | 
           216 | 
           			$var_preview = true;
  | 
        
        
            | 
            | 
           217 | 
           			spip_log('preview !');
  | 
        
        
            | 
            | 
           218 | 
           		} else
  | 
        
        
            | 
            | 
           219 | 
           			$var_preview = false;
  | 
        
        
            | 
            | 
           220 | 
           	}
  | 
        
        
            | 
            | 
           221 | 
              | 
        
        
            | 
            | 
           222 | 
           	// Calculer le chemin putatif du cache
  | 
        
        
            | 
            | 
           223 | 
           	if ($delais > 0)
  | 
        
        
            | 
            | 
           224 | 
           		$chemin_cache = generer_nom_fichier_cache('', $fond);
  | 
        
        
            | 
            | 
           225 | 
           	else
  | 
        
        
            | 
            | 
           226 | 
           		$chemin_cache = '';
  | 
        
        
            | 
            | 
           227 | 
              | 
        
        
            | 
            | 
           228 | 
           	// Faut-il effacer des pages invalidees ?
  | 
        
        
            | 
            | 
           229 | 
           	if (lire_meta('invalider')) {
  | 
        
        
            | 
            | 
           230 | 
           		include_ecrire('inc_connect.php3');
  | 
        
        
            | 
            | 
           231 | 
           		include_ecrire('inc_meta.php3');
  | 
        
        
            | 
            | 
           232 | 
           		lire_metas();
  | 
        
        
            | 
            | 
           233 | 
           		if (lire_meta('invalider') AND $GLOBALS['db_ok'])
  | 
        
        
            | 
            | 
           234 | 
           			retire_caches($chemin_cache);
  | 
        
        
            | 
            | 
           235 | 
           	}
  | 
        
        
            | 
            | 
           236 | 
              | 
        
        
            | 
            | 
           237 | 
              | 
        
        
            | 
            | 
           238 | 
           	// Peut-on utiliser un fichier cache ?
  | 
        
        
            | 
            | 
           239 | 
           	determiner_cache($delais, $use_cache, $chemin_cache);
  | 
        
        
            | 
            | 
           240 | 
              | 
        
        
            | 
            | 
           241 | 
           	// Repondre gentiment aux requetes sympas
  | 
        
        
            | 
            | 
           242 | 
           	// (ici on ne tient pas compte d'une obsolence du cache ou des
  | 
        
        
            | 
            | 
           243 | 
           	// eventuels fichiers inclus modifies depuis la date
  | 
        
        
            | 
            | 
           244 | 
           	// HTTP_IF_MODIFIED_SINCE du client)
  | 
        
        
            | 
            | 
           245 | 
           	if ($GLOBALS['HTTP_IF_MODIFIED_SINCE'] AND !$var_mode
  | 
        
        
            | 
            | 
           246 | 
           	AND $chemin_cache AND !$flag_dynamique) {
  | 
        
        
            | 
            | 
           247 | 
           		$lastmodified = @filemtime($chemin_cache);
  | 
        
        
            | 
            | 
           248 | 
           		$headers_only = http_last_modified($lastmodified);
  | 
        
        
            | 
            | 
           249 | 
           	}
  | 
        
        
            | 
            | 
           250 | 
           	$headers_only |= ($GLOBALS['_SERVER']['REQUEST_METHOD'] == 'HEAD');
  | 
        
        
            | 
            | 
           251 | 
              | 
        
        
            | 
            | 
           252 | 
           	if ($headers_only) {
  | 
        
        
            | 
            | 
           253 | 
           		if ($chemin_cache)
  | 
        
        
            | 
            | 
           254 | 
           			$t = @filemtime($chemin_cache);
  | 
        
        
            | 
            | 
           255 | 
           		else
  | 
        
        
            | 
            | 
           256 | 
           			$t = time();
  | 
        
        
            | 
            | 
           257 | 
           		@header('Last-Modified: '.http_gmoddate($t).' GMT');
  | 
        
        
            | 
            | 
           258 | 
           		@header('Connection: close');
  | 
        
        
            | 
            | 
           259 | 
           		// Pas de bouton admin pour un HEAD
  | 
        
        
            | 
            | 
           260 | 
           		$flag_preserver = true;
  | 
        
        
            | 
            | 
           261 | 
           	}
  | 
        
        
            | 
            | 
           262 | 
           	else {
  | 
        
        
            | 
            | 
           263 | 
           		// Obtenir la page
  | 
        
        
            | 
            | 
           264 | 
           		$page = obtenir_page ('', $chemin_cache, $delais, $use_cache,
  | 
        
        
            | 
            | 
           265 | 
           		$fond, false);
  | 
        
        
            | 
            | 
           266 | 
           	}
  | 
        
        
            | 
            | 
           267 | 
              | 
        
        
            | 
            | 
           268 | 
           	if ($chemin_cache) $page['cache'] = $chemin_cache;
  | 
        
        
            | 
            | 
           269 | 
              | 
        
        
            | 
            | 
           270 | 
           	if ($var_preview AND !$flag_preserver) {
  | 
        
        
            | 
            | 
           271 | 
           		include_ecrire('inc_lang.php3');
  | 
        
        
            | 
            | 
           272 | 
           		include_ecrire('inc_filtres.php3');
  | 
        
        
            | 
            | 
           273 | 
           		lang_select($GLOBALS['auteur_session']['lang']);
  | 
        
        
            | 
            | 
           274 | 
           		$x = majuscules(_T('previsualisation'));
  | 
        
        
            | 
            | 
           275 | 
           		$page['texte'] .= '<div style="
  | 
        
        
            | 
            | 
           276 | 
           		display: block;
  | 
        
        
            | 
            | 
           277 | 
           		color: #eeeeee;
  | 
        
        
            | 
            | 
           278 | 
           		background-color: #111111;
  | 
        
        
            | 
            | 
           279 | 
           		padding-right: 5px;
  | 
        
        
            | 
            | 
           280 | 
           		padding-top: 2px;
  | 
        
        
            | 
            | 
           281 | 
           		padding-bottom: 5px;
  | 
        
        
            | 
            | 
           282 | 
           		font-size: 20px;
  | 
        
        
            | 
            | 
           283 | 
           		top: 0px;
  | 
        
        
            | 
            | 
           284 | 
           		left: 0px;
  | 
        
        
            | 
            | 
           285 | 
           		position: absolute;
  | 
        
        
            | 
            | 
           286 | 
           		">'
  | 
        
        
            | 
            | 
           287 | 
           		  . http_img_pack('naviguer-site.png', $x, '')
  | 
        
        
            | 
            | 
           288 | 
           		  ." $x</div>";
  | 
        
        
            | 
            | 
           289 | 
           	}
  | 
        
        
            | 
            | 
           290 | 
              | 
        
        
            | 
            | 
           291 | 
           	return $page;
  | 
        
        
            | 
            | 
           292 | 
           }
  | 
        
        
            | 
            | 
           293 | 
              | 
        
        
            | 
            | 
           294 | 
              | 
        
        
            | 
            | 
           295 | 
           function terminer_public_global() {
  | 
        
        
            | 
            | 
           296 | 
              | 
        
        
            | 
            | 
           297 | 
           	// Gestion des statistiques du site public
  | 
        
        
            | 
            | 
           298 | 
           	if (lire_meta("activer_statistiques") != "non") {
  | 
        
        
            | 
            | 
           299 | 
           		include_local ("inc-stats.php3");
  | 
        
        
            | 
            | 
           300 | 
           		ecrire_stats();
  | 
        
        
            | 
            | 
           301 | 
           	}
  | 
        
        
            | 
            | 
           302 | 
              | 
        
        
            | 
            | 
           303 | 
           	// Effectuer une tache de fond ?
  | 
        
        
            | 
            | 
           304 | 
           	cron();
  | 
        
        
            | 
            | 
           305 | 
           }
  | 
        
        
            | 
            | 
           306 | 
              | 
        
        
            | 
            | 
           307 | 
              | 
        
        
            | 
            | 
           308 | 
           function inclure_page($fond, $delais_inclus, $contexte_inclus, $cache_incluant='') {
  | 
        
        
            | 
            | 
           309 | 
              | 
        
        
            | 
            | 
           310 | 
           	$contexte_inclus['fond'] = $fond;
  | 
        
        
            | 
            | 
           311 | 
              | 
        
        
            | 
            | 
           312 | 
           	if ($delais_inclus > 0)
  | 
        
        
            | 
            | 
           313 | 
           		$chemin_cache = generer_nom_fichier_cache($contexte_inclus, $fond);
  | 
        
        
            | 
            | 
           314 | 
           	else
  | 
        
        
            | 
            | 
           315 | 
           		$chemin_cache = '';
  | 
        
        
            | 
            | 
           316 | 
              | 
        
        
            | 
            | 
           317 | 
           	// Peut-on utiliser un fichier cache ?
  | 
        
        
            | 
            | 
           318 | 
           	determiner_cache($delais_inclus, $use_cache, $chemin_cache);
  | 
        
        
            | 
            | 
           319 | 
              | 
        
        
            | 
            | 
           320 | 
           	// Si on a inclus sans fixer le critere de lang, de deux choses l'une :
  | 
        
        
            | 
            | 
           321 | 
           	// - on est dans la langue du site, et pas besoin d'inclure inc_lang
  | 
        
        
            | 
            | 
           322 | 
           	// - on n'y est pas, et alors il faut revenir dans la langue par defaut
  | 
        
        
            | 
            | 
           323 | 
           	if (($lang = $contexte_inclus['lang'])
  | 
        
        
            | 
            | 
           324 | 
           	|| ($GLOBALS['spip_lang'] != ($lang = lire_meta('langue_site')))) {
  | 
        
        
            | 
            | 
           325 | 
           		include_ecrire('inc_lang.php3');
  | 
        
        
            | 
            | 
           326 | 
           		lang_select($lang);
  | 
        
        
            | 
            | 
           327 | 
           		$lang_select = true; // pour lang_dselect en sortie
  | 
        
        
            | 
            | 
           328 | 
           	}
  | 
        
        
            | 
            | 
           329 | 
              | 
        
        
            | 
            | 
           330 | 
           	$page = obtenir_page ($contexte_inclus, $chemin_cache, $delais_inclus,
  | 
        
        
            | 
            | 
           331 | 
           	$use_cache, $fond, true);
  | 
        
        
            | 
            | 
           332 | 
              | 
        
        
            | 
            | 
           333 | 
           	$page['lang_select'] = $lang_select;
  | 
        
        
            | 
            | 
           334 | 
              | 
        
        
            | 
            | 
           335 | 
           	// Retourner le contenu...
  | 
        
        
            | 
            | 
           336 | 
           	return $page;
  | 
        
        
            | 
            | 
           337 | 
           }
  | 
        
        
            | 
            | 
           338 | 
              | 
        
        
            | 
            | 
           339 | 
              | 
        
        
            | 
            | 
           340 | 
           # Attention, un appel explicite a cette fonction suppose certains include
  | 
        
        
            | 
            | 
           341 | 
           # (voir l'exemple de spip_inscription et spip_pass)
  | 
        
        
            | 
            | 
           342 | 
           # $r = complexe (fond, delais, contexte) ; $echo = faut-il faire echo ou return
  | 
        
        
            | 
            | 
           343 | 
           function inclure_balise_dynamique($texte, $echo=true, $ligne=0) {
  | 
        
        
            | 
            | 
           344 | 
           	global $contexte_inclus; # provisoire : c'est pour le debuggueur
  | 
        
        
            | 
            | 
           345 | 
              | 
        
        
            | 
            | 
           346 | 
           	if (!is_string($texte))
  | 
        
        
            | 
            | 
           347 | 
           	  {
  | 
        
        
            | 
            | 
           348 | 
           		list($fond, $delais, $contexte_inclus) = $texte;
  | 
        
        
            | 
            | 
           349 | 
              | 
        
        
            | 
            | 
           350 | 
           		if ((!$contexte_inclus['lang']) AND
  | 
        
        
            | 
            | 
           351 | 
           		($GLOBALS['spip_lang'] != lire_meta('langue_site')))
  | 
        
        
            | 
            | 
           352 | 
           			$contexte_inclus['lang'] = $GLOBALS['spip_lang'];
  | 
        
        
            | 
            | 
           353 | 
              | 
        
        
            | 
            | 
           354 | 
           		// Appeler la page
  | 
        
        
            | 
            | 
           355 | 
           		$page = inclure_page($fond, $delais, $contexte_inclus);
  | 
        
        
            | 
            | 
           356 | 
              | 
        
        
            | 
            | 
           357 | 
           		if ($page['process_ins'] == 'html') {
  | 
        
        
            | 
            | 
           358 | 
           				$texte = $page['texte'];
  | 
        
        
            | 
            | 
           359 | 
           		} else {
  | 
        
        
            | 
            | 
           360 | 
           				ob_start();
  | 
        
        
            | 
            | 
           361 | 
           				eval('?' . '>' . $page['texte']);
  | 
        
        
            | 
            | 
           362 | 
           				$texte = ob_get_contents();
  | 
        
        
            | 
            | 
           363 | 
           				ob_end_clean();
  | 
        
        
            | 
            | 
           364 | 
           		}
  | 
        
        
            | 
            | 
           365 | 
              | 
        
        
            | 
            | 
           366 | 
           		if ($page['lang_select'])
  | 
        
        
            | 
            | 
           367 | 
           			lang_dselect();
  | 
        
        
            | 
            | 
           368 | 
              | 
        
        
            | 
            | 
           369 | 
           	  }
  | 
        
        
            | 
            | 
           370 | 
              | 
        
        
            | 
            | 
           371 | 
           	if ($GLOBALS['var_mode'] == 'debug')
  | 
        
        
            | 
            | 
           372 | 
           	    $GLOBALS['debug_objets']['resultat'][$ligne] = $texte;
  | 
        
        
            | 
            | 
           373 | 
              | 
        
        
            | 
            | 
           374 | 
           	if ($echo)
  | 
        
        
            | 
            | 
           375 | 
           			echo $texte;
  | 
        
        
            | 
            | 
           376 | 
           	else
  | 
        
        
            | 
            | 
           377 | 
           			return $texte;
  | 
        
        
            | 
            | 
           378 | 
           }
  | 
        
        
            | 
            | 
           379 | 
              | 
        
        
            | 
            | 
           380 | 
              | 
        
        
            | 
            | 
           381 | 
           function message_erreur_404 () {
  | 
        
        
            | 
            | 
           382 | 
           	if ($GLOBALS['id_article'])
  | 
        
        
            | 
            | 
           383 | 
           		$erreur = 'public:aucun_article';
  | 
        
        
            | 
            | 
           384 | 
           	else if ($GLOBALS['id_rubrique'])
  | 
        
        
            | 
            | 
           385 | 
           		$erreur = 'public:aucune_rubrique';
  | 
        
        
            | 
            | 
           386 | 
           	else if ($GLOBALS['id_breve'])
  | 
        
        
            | 
            | 
           387 | 
           		$erreur = 'public:aucune_breve';
  | 
        
        
            | 
            | 
           388 | 
           	else if ($GLOBALS['id_auteur'])
  | 
        
        
            | 
            | 
           389 | 
           		$erreur = 'public:aucun_auteur';
  | 
        
        
            | 
            | 
           390 | 
           	else if ($GLOBALS['id_syndic'])
  | 
        
        
            | 
            | 
           391 | 
           		$erreur = 'public:aucun_site';
  | 
        
        
            | 
            | 
           392 | 
           	else
  | 
        
        
            | 
            | 
           393 | 
           		$erreur = '';
  | 
        
        
            | 
            | 
           394 | 
              | 
        
        
            | 
            | 
           395 | 
           	return _T($erreur);
  | 
        
        
            | 
            | 
           396 | 
           }
  | 
        
        
            | 
            | 
           397 | 
              | 
        
        
            | 
            | 
           398 | 
           // Renvoie le _GET ou le _POST emis par l'utilisateur
  | 
        
        
            | 
            | 
           399 | 
           function _request($var) {
  | 
        
        
            | 
            | 
           400 | 
           	global $_GET, $_POST;
  | 
        
        
            | 
            | 
           401 | 
           	if (isset($_GET[$var])) return $_GET[$var];
  | 
        
        
            | 
            | 
           402 | 
           	if (isset($_POST[$var])) return $_POST[$var];
  | 
        
        
            | 
            | 
           403 | 
           	return NULL;
  | 
        
        
            | 
            | 
           404 | 
           }
  | 
        
        
            | 
            | 
           405 | 
              | 
        
        
            | 
            | 
           406 | 
           ?>
  |