From 7a13782e49898724763b1638f54fc8e189a7fe2e Mon Sep 17 00:00:00 2001
From: Fil <fil@rezo.net>
Date: Tue, 21 Dec 2004 22:51:43 +0000
Subject: [PATCH] =?UTF-8?q?adaptation=20du=20spip=5Fbackground=20du=20lab,?=
 =?UTF-8?q?=20=C3=A0=20ceci=20pr=C3=A8s=20que=20je=20n'ose=20pas=20mettre?=
 =?UTF-8?q?=20le=20<div>=20de=20force=20dans=20la=20page=20produite.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/aide_index.php3       |  6 ++--
 ecrire/inc.php3              | 54 ------------------------------------
 ecrire/inc_flock.php3        |  2 --
 ecrire/inc_presentation.php3 |  8 ++++--
 ecrire/inc_version.php3      | 23 ++++++++++++++-
 ecrire/spip_style.php3       | 19 +++++--------
 inc-public-global.php3       |  9 ++----
 spip_background.php3         | 23 +++++++++++++++
 8 files changed, 62 insertions(+), 82 deletions(-)
 create mode 100644 spip_background.php3

diff --git a/ecrire/aide_index.php3 b/ecrire/aide_index.php3
index 172daba9c4..28eefc0cce 100644
--- a/ecrire/aide_index.php3
+++ b/ecrire/aide_index.php3
@@ -4,9 +4,9 @@ include ("inc_version.php3");
 include_ecrire ("inc_presentation.php3");
 
 // Eviter les calculs evitables (surtout en client/serveur sans cache !)
-#$lastmodified = filemtime("aide_index.php3");
-#$headers_only = http_last_modified($lastmodified, time() + 24 * 3600);
-#if ($headers_only) exit;
+$lastmodified = filemtime("aide_index.php3");
+$headers_only = http_last_modified($lastmodified, time() + 24 * 3600);
+if ($headers_only) exit;
 
 include_ecrire ("inc_layer.php3");
 include_ecrire ("inc_texte.php3");
diff --git a/ecrire/inc.php3 b/ecrire/inc.php3
index 04208e0b3c..e35b6aa4ef 100644
--- a/ecrire/inc.php3
+++ b/ecrire/inc.php3
@@ -113,60 +113,6 @@ $couleur_claire = $couleurs_spip[$choix_couleur]['couleur_claire'];
 $couleur_lien = $couleurs_spip[$choix_couleur]['couleur_lien'];
 $couleur_lien_off = $couleurs_spip[$choix_couleur]['couleur_lien_off'];
 
-/*
-switch ($prefs['couleur']) {
-	case 6:
-		/// Jaune
-		$couleur_foncee="#9DBA00";
-		$couleur_claire="#C5E41C";
-		$couleur_lien="#657701";
-		$couleur_lien_off="#A6C113";
-		break;
-	case 1:
-		/// Violet clair
-		$couleur_foncee="#eb68b3";
-		$couleur_claire="#ffa9e6";
-		$couleur_lien="#E95503";
-		$couleur_lien_off="#8F004D";
-		break;
-	case 2:
-		/// Orange
-		$couleur_foncee="#fa9a00";
-		$couleur_claire="#ffc000";
-		$couleur_lien="#81A0C1";
-		$couleur_lien_off="#FF5B00";
-		break;
-	case 3:
-		/// Saumon
-		$couleur_foncee="#CDA261";
-		$couleur_claire="#FFDDAA";
-		$couleur_lien="#5E0283";
-		$couleur_lien_off="#472854";
-		break;
-	case 4:
-		/// Bleu pastelle
-		$couleur_foncee="#5da7c5";
-		$couleur_claire="#97d2e1";
-		$couleur_lien="#869100";
-		$couleur_lien_off="#5B55A0";
-		break;
-	case 5:
-		/// Gris
-		$couleur_foncee="#727D87";
-		$couleur_claire="#C0CAD4";
-		$couleur_lien="#854270";
-		$couleur_lien_off="#666666";
-		break;
-	default:
-		/// Jaune
-		$couleur_foncee="#9DBA00";
-		$couleur_claire="#C5E41C";
-		$couleur_lien="#657701";
-		$couleur_lien_off="#A6C113";
-}
-*/
-
-
 //
 // Gestion de version
 //
diff --git a/ecrire/inc_flock.php3 b/ecrire/inc_flock.php3
index 5ef2a57dba..34a9b771f2 100644
--- a/ecrire/inc_flock.php3
+++ b/ecrire/inc_flock.php3
@@ -91,8 +91,6 @@ function ecrire_fichier ($fichier, $contenu) {
 	if (!$ok)
 		spip_log("echec ecriture fichier $fichier");
 
-	spip_log("$fputs $fichier ".spip_timer('ecrire_fichier'));
-
 	// liberer le verrou et fermer le fichier
 	@flock($fp, LOCK_UN);
 	@fclose($fp);
diff --git a/ecrire/inc_presentation.php3 b/ecrire/inc_presentation.php3
index 336544dc9e..89354328f5 100644
--- a/ecrire/inc_presentation.php3
+++ b/ecrire/inc_presentation.php3
@@ -3172,7 +3172,10 @@ function fin_page($credits='') {
 
 	debut_grand_cadre();
 
-	echo "<div align='right' class='verdana2'>";
+	# ici on en profite pour glisser une tache de fond
+	echo "<div align='right' class='verdana2' ";
+	echo "style='background: url(\"../spip_background.php3\");' ";
+	echo ">";
 
 	if ($spip_display == 4) {
 		echo "<div><a href=\"index.php3?set_disp=2\">"._T("access_interface_graphique")."</a></div>";
@@ -3338,8 +3341,7 @@ function voir_en_ligne ($type, $id, $statut=false, $image='racine-24.gif') {
 		icone_horizontale($message, "../spip_redirect.php3?id_$type=$id&$en_ligne=oui", $image, "rien.gif");
 }
 
-function http_img_pack($img, $att)
-{
+function http_img_pack($img, $att) {
   return "<img src='" . _DIR_IMG_PACK . $img . 
     ($att ? ("' " . $att) : "'") . " />";
 }
diff --git a/ecrire/inc_version.php3 b/ecrire/inc_version.php3
index 08809da3d3..a65def1cc3 100644
--- a/ecrire/inc_version.php3
+++ b/ecrire/inc_version.php3
@@ -965,6 +965,27 @@ function spip_timer($t='rien') {
 }
 
 
+//
+// cron : verifie qu'il s'est ecoule $delai sec au moins et lance le cron
+// Note : ici on met 2 secondes par defaut entre les hits, mais
+// spip_background.php3 est plus gourmand (1 sec)... chiffres a optimiser
+// si on utilise spip_background.php3 de maniere plus complete
+//
+function cron($delai = 2) {
+	if (!$_REQUEST['forcer']) {
+		$touch = _DIR_SESSIONS.'.background';
+		if (!($exists = @file_exists($touch))
+		OR (@filemtime($touch) < time() - $delai)) {
+			touch($touch);
+			if (!$exists) chmod($touch, 0666);
+
+		include_ecrire('inc_cron.php3');
+		spip_cron();
+	}
+}
+
+}
+
 //
 // qq  fonctions service pour les 2 niveaux
 //
@@ -1018,7 +1039,7 @@ function creer_repertoire($base, $subdir) {
 //
 function redirige_par_entete($url) {
 	header("Location: $url");
-	include_ecrire('inc_cron.php3');
+#	include_ecrire('inc_cron.php3');
 #	spip_cron();
 	spip_log("redirige $url");
 	exit;
diff --git a/ecrire/spip_style.php3 b/ecrire/spip_style.php3
index be93694a0d..6ca997b99b 100644
--- a/ecrire/spip_style.php3
+++ b/ecrire/spip_style.php3
@@ -1,12 +1,14 @@
 <?php
+
 	include("inc_version.php3");
 
 	// En-tetes
 	$lastmodified = @filemtime("spip_style.php3");
 	$headers_only = http_last_modified($lastmodified, time() + 24 * 3600);
-	@Header ("Content-Type: text/css");
+	if ($headers_only) exit;
 
-if (!$headers_only) {
+
+	@Header ("Content-Type: text/css");
 
 	// parano XSS
 	eregi("^([#0-9a-z]*).*-([#0-9a-z]*).*-([0-9a-z]*).*-([0-9a-z]*).*", "$couleur_claire-$couleur_foncee-$left-$right", $regs);
@@ -32,8 +34,8 @@ if (!$headers_only) {
 body { 
 	font-family: Verdana,Arial,Sans,sans-serif; 
 	border: 0px;
-	scrollbar-face-color: white; 				
-	scrollbar-shadow-color: white; 				
+	scrollbar-face-color: white;
+	scrollbar-shadow-color: white;
 	scrollbar-highlight-color: white;
 	scrollbar-3dlight-color: <?php echo $couleur_claire; ?>;
 	scrollbar-darkshadow-color: white; 		
@@ -1375,11 +1377,4 @@ table.spip td {
 	padding: 1px;
 	text-align: left;
 	vertical-align: center;
- }
-<?php }
-if (_FILE_CONNECT) 
-  {	
-	include_ecrire('inc_cron.php3');
-	spip_cron();
-  }
-?>
+}
diff --git a/inc-public-global.php3 b/inc-public-global.php3
index 0d5779333d..888213d3ad 100644
--- a/inc-public-global.php3
+++ b/inc-public-global.php3
@@ -205,13 +205,8 @@ function terminer_public_global() {
 		ecrire_stats();
 	}
 
-	// S'il n'y a pas eu de compilation de squelette
-	// il reste du temps pour une tache de fond, 
-	// ... Les serveurs etant devenus ce qu'il sont, precaution inutile
-	#	if (empty($GLOBALS['included_files']['inc-compilo.php3'])) {
-		include_ecrire('inc_cron.php3');
-		spip_cron();
-	# }
+	// Effectuer une tache de fond ?
+	cron();
 }
 
 // Cette fonction sert au dernier ob_start() de inc-public : elle
diff --git a/spip_background.php3 b/spip_background.php3
new file mode 100644
index 0000000000..c84a02c6a3
--- /dev/null
+++ b/spip_background.php3
@@ -0,0 +1,23 @@
+<?php
+
+// Du cote de la page HTML, utiliser un background-image en feuille de style
+// plutot qu'un <img>, c'est plus discret notamment sous navigateur texte
+$image = pack("H*", "47494638396118001800800000ffffff00000021f90401000000002c0000000018001800000216848fa9cbed0fa39cb4da8bb3debcfb0f86e248965301003b");
+$size = strlen($image);
+
+Header("Content-Type: image/gif");
+Header("Content-Length: ".$size);
+Header("Cache-Control: no-cache,no-store");
+Header("Pragma: no-cache");
+Header("Connection: close");
+
+echo $image;
+
+flush();
+
+include('ecrire/inc_version.php3');
+
+cron(1);	// toutes les 1 seconde (gourmand)
+
+
+?>
\ No newline at end of file
-- 
GitLab