From 20f39fbb373537f38e4c2e014d342f4606c07800 Mon Sep 17 00:00:00 2001
From: ARNO* <arno@rezo.net>
Date: Wed, 31 Aug 2005 18:59:48 +0000
Subject: [PATCH] Nettoyer table spip_ajax_fonc (toutes les 2 heures?)

---
 .gitattributes       |  1 +
 ecrire/inc_ajax.php3 | 26 ++++++++++++++++++++++++++
 ecrire/inc_cron.php3 | 11 ++++++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 ecrire/inc_ajax.php3

diff --git a/.gitattributes b/.gitattributes
index 0918629cb7..f7977d3799 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -246,6 +246,7 @@ ecrire/img_pack/visiter-48_rtl.png -text
 ecrire/img_pack/warning-24.gif -text
 ecrire/img_pack/warning.gif -text
 ecrire/img_pack/xml.gif -text
+ecrire/inc_ajax.php3 -text
 ecrire/inc_barre.php3 -text
 ecrire/inc_mini_nav.php -text
 ecrire/polices/dustismo-license.txt -text svneol=unset#application/octet-stream
diff --git a/ecrire/inc_ajax.php3 b/ecrire/inc_ajax.php3
new file mode 100644
index 0000000000..48b6d007e0
--- /dev/null
+++ b/ecrire/inc_ajax.php3
@@ -0,0 +1,26 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2005                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+
+//
+// Ce fichier ne sera execute qu'une fois
+if (defined("_ECRIRE_INC_AJAX")) return;
+define("_ECRIRE_INC_AJAX", "1");
+
+function nettoyer_ajax() {
+	$query = "DELETE FROM spip_ajax_fonc  WHERE date < DATE_SUB(NOW(), INTERVAL 2 HOUR)";
+	$res = spip_query($query);
+}
+
+
+
+?>
\ No newline at end of file
diff --git a/ecrire/inc_cron.php3 b/ecrire/inc_cron.php3
index c0be45e201..a25bf6c851 100644
--- a/ecrire/inc_cron.php3
+++ b/ecrire/inc_cron.php3
@@ -138,6 +138,9 @@ function taches_generales() {
 	// indexation
 	if (lire_meta("activer_moteur") == "oui") 
 		$taches_generales[]= 'index';
+		
+	// ajax
+		$taches_generales[] = 'ajax';
 
 	return $taches_generales;
 }
@@ -158,7 +161,8 @@ $frequence_taches = array(
 			  'popularites' => 1800,
 			  'sites' => 90,
 			  'index' => 60,
-			  'optimiser' => 3600 * 48
+			  'optimiser' => 3600 * 48,
+			  'ajax' => 3600 * 2
 );
 
 // Fonctions effectivement appelees.
@@ -263,6 +267,11 @@ function cron_mail($t) {
 	return 1;
 }
 
+function cron_ajax ($t) {
+	nettoyer_ajax();
+	return 1;
+}
+
 function cron_invalideur($t) {
 	//
 	// menage des vieux fichiers du cache
-- 
GitLab