equal
deleted
inserted
replaced
6 $stats_prefixes = array( |
6 $stats_prefixes = array( |
7 'o' => '@', |
7 'o' => '@', |
8 'v' => '+' |
8 'v' => '+' |
9 ); |
9 ); |
10 $stats_data = array('anonymous' => array(), 'messages' => array()); |
10 $stats_data = array('anonymous' => array(), 'messages' => array()); |
11 @include('./stats-data.php'); |
11 $stats_day = gmdate('Ymd'); |
|
12 @include("./stats/stats-data-$stats_day.php"); |
12 unset($stats_data['members']); |
13 unset($stats_data['members']); |
13 $stats_data['members'] =& $stats_memberlist; |
14 $stats_data['members'] =& $stats_memberlist; |
14 |
15 |
15 eb_hook('event_self_join', 'stats_init_channel($this);'); |
16 eb_hook('event_self_join', 'stats_init_channel($this);'); |
16 eb_hook('event_raw_message', 'stats_process_message($chan, $message);'); |
17 eb_hook('event_raw_message', 'stats_process_message($chan, $message);'); |
230 stats_cron(); |
231 stats_cron(); |
231 } |
232 } |
232 |
233 |
233 function stats_cron() |
234 function stats_cron() |
234 { |
235 { |
|
236 global $stats_day; |
|
237 $stats_day = gmdate('Ymd'); |
|
238 |
235 static $commit_time = 0; |
239 static $commit_time = 0; |
236 $now = time(); |
240 $now = time(); |
237 // commit to disk every 1 minute |
241 // commit to disk every 1 minute |
238 if ( $commit_time + 60 < $now ) |
242 if ( $commit_time + 60 < $now ) |
239 { |
243 { |
242 } |
246 } |
243 } |
247 } |
244 |
248 |
245 function stats_commit() |
249 function stats_commit() |
246 { |
250 { |
247 global $stats_data; |
251 global $stats_data, $stats_day; |
248 ob_start(); |
252 ob_start(); |
249 var_export($stats_data); |
253 var_export($stats_data); |
250 $stats_data_exported = ob_get_contents(); |
254 $stats_data_exported = ob_get_contents(); |
251 ob_end_clean(); |
255 ob_end_clean(); |
252 |
256 |
253 $fp = @fopen('./stats-data.php', 'w'); |
257 $fp = @fopen("./stats/stats-data-$stats_day.php", 'w'); |
254 if ( !$fp ) |
258 if ( !$fp ) |
255 return false; |
259 return false; |
256 fwrite($fp, "<?php\n\$stats_data = $stats_data_exported;\n"); |
260 fwrite($fp, "<?php\n\$stats_data = $stats_data_exported;\n"); |
257 fclose($fp); |
261 fclose($fp); |
258 } |
262 } |