2012-02-08 23:14:28 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class ModelStatCounter extends Model {
|
|
|
|
|
2012-06-22 15:22:02 +02:00
|
|
|
public function get_counters(){
|
2012-02-08 23:14:28 +01:00
|
|
|
$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'])) {
|
2013-02-16 12:51:43 +01:00
|
|
|
if(isset($counter[MEMCACHED_PREFIX . 'size'])) { $asize = $counter[MEMCACHED_PREFIX . 'size']; }
|
2012-02-10 14:35:07 +01:00
|
|
|
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) {
|
2013-02-16 12:51:43 +01:00
|
|
|
$asize = $query->row['size'];
|
|
|
|
|
2012-02-10 14:35:07 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-22 15:22:02 +02:00
|
|
|
public function reset_counters(){
|
2012-02-08 23:14:28 +01:00
|
|
|
|
|
|
|
if(MEMCACHED_ENABLED) {
|
|
|
|
$memcache = Registry::get('memcache');
|
|
|
|
|
2012-02-10 15:08:15 +01:00
|
|
|
$c = Registry::get('counters');
|
|
|
|
unset($c[MEMCACHED_PREFIX . 'size']);
|
|
|
|
|
|
|
|
foreach ($c as $counter) {
|
2012-02-08 23:14:28 +01:00
|
|
|
$memcache->set($counter, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-05 16:42:36 +01:00
|
|
|
$query = $this->db->query("UPDATE " . TABLE_COUNTER . " SET `rcvd`=0, `virus`=0, `duplicate`=0, `ignore`=0");
|
2012-02-08 23:14:28 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|