Added a cron task to sessions.php that deletes old admin keys once a week
authorDan
Thu, 06 Mar 2008 20:53:26 -0500
changeset 480 d5376271f96b
parent 479 192db6ac195b
child 481 07bf15b066bc
Added a cron task to sessions.php that deletes old admin keys once a week
includes/sessions.php
--- a/includes/sessions.php	Thu Mar 06 20:52:51 2008 -0500
+++ b/includes/sessions.php	Thu Mar 06 20:53:26 2008 -0500
@@ -3568,4 +3568,21 @@
 
 register_cron_task('cron_clean_login_cache', 72);
 
+/**
+ * Cron task - clears out outdated high-auth session keys
+ */
+
+function cron_clean_old_admin_keys()
+{
+  global $db, $session, $paths, $template, $plugins; // Common objects
+  
+  $threshold = time() - ( 15 * 60 );
+  $ul_member = USER_LEVEL_MEMBER;
+  if ( !$db->sql_query('DELETE FROM ' . table_prefix . "session_keys WHERE time < $threshold AND auth_level > $ul_member;") )
+    $db->_die();
+}
+
+// Once a week
+register_cron_task('cron_clean_old_admin_keys', 168);
+
 ?>