2012-02-08 23:14:28 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class ModelStatCounter extends Model {
|
|
|
|
|
|
|
|
public function getCounters(){
|
|
|
|
$counter = array();
|
2012-02-10 14:35:07 +01:00
|
|
|
$asize = 0;
|
2012-02-08 23:14:28 +01:00
|
|
|
|
|
|
|
if(MEMCACHED_ENABLED) {
|
|
|
|
$memcache = Registry::get('memcache');
|
|
|
|
|
|
|
|
$counter = $memcache->get(Registry::get('counters'));
|
|
|
|
|
2012-02-10 14:35:07 +01:00
|
|
|
if(isset($counter[MEMCACHED_PREFIX . 'counters_last_update'])) {
|
|
|
|
$asize = nice_size($counter[MEMCACHED_PREFIX . 'size'], ' ');
|
|
|
|
unset($counter[MEMCACHED_PREFIX . 'size']);
|
|
|
|
|
|
|
|
return array ($asize, $counter);
|
|
|
|
}
|
2012-02-08 23:14:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$query = $this->db->query("SELECT * FROM " . TABLE_COUNTER);
|
|
|
|
|
|
|
|
if($query->num_rows == 1) {
|
2012-02-10 14:35:07 +01:00
|
|
|
$asize = nice_size($query->row['size'], ' ');
|
|
|
|
unset($query->row['size']);
|
|
|
|
|
2012-02-08 23:14:28 +01:00
|
|
|
$counter = $query->row;
|
|
|
|
}
|
|
|
|
|
2012-02-10 14:35:07 +01:00
|
|
|
return array ($asize, $counter);
|
2012-02-08 23:14:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function resetCounters(){
|
|
|
|
|
|
|
|
if(MEMCACHED_ENABLED) {
|
|
|
|
$memcache = Registry::get('memcache');
|
|
|
|
|
|
|
|
foreach (Registry::get('counters') as $counter) {
|
|
|
|
$memcache->set($counter, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$query = $this->db->query("UPDATE " . TABLE_COUNTER . " set rcvd=0, virus=0, duplicate=0, ignore=0");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|