OK, *now* it should actually cycle the data once a day
authorDan
Sun, 12 Oct 2008 00:31:56 -0400
changeset 17 b07b23187b17
parent 16 01c6a003d762
child 18 07be890ef627
child 19 eb92dc5d9fb4
OK, *now* it should actually cycle the data once a day
modules/stats.php
--- a/modules/stats.php	Sat Oct 11 20:31:22 2008 -0400
+++ b/modules/stats.php	Sun Oct 12 00:31:56 2008 -0400
@@ -233,9 +233,6 @@
 
 function stats_cron()
 {
-  global $stats_day;
-  $stats_day = gmdate('Ymd');
-  
   static $commit_time = 0;
   $now = time();
   // commit to disk every 1 minute
@@ -249,6 +246,7 @@
 function stats_commit()
 {
   global $stats_data, $stats_day;
+  
   ob_start();
   var_export($stats_data);
   $stats_data_exported = ob_get_contents();
@@ -259,5 +257,16 @@
     return false;
   fwrite($fp, "<?php\n\$stats_data = $stats_data_exported;\n");
   fclose($fp);
+  
+  if ( $stats_day != gmdate('Ymd') )
+  {
+    // it's a new day! flush all our logs
+    foreach ( $stats_data['messages'] as &$data )
+    {
+      $data = array();
+    }
+  }
+  
+  $stats_day = gmdate('Ymd');
 }