FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Stats.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Rsi\Fred\Worker\Job;
4 
5 abstract class Stats extends \Rsi\Fred\Worker\Job{
6 
7  abstract protected function stats($id,$delta,$time,$addr,$user_agent);
8 
9  public function execute(){
10  if($this->_worker->component('stats')->path)
11  foreach(glob($this->_worker->component('stats')->path . '*' . $this->_worker->component('stats')->ext) as $filename) try{
12  if($stats = \Rsi\File::unserialize($filename)) foreach($stats['stats'] as $stat)
13  $this->stats($stat['id'],$stat['delta'],$stat['time'],$stats['addr'],$stats['ua']);
14  \Rsi\File::unlink($filename);
15  }
16  catch(\Exception $e){
17  $this->_worker->component('log')->error('Could not process stats file',['filename' => $filename,'error' => $e->getMessage()]);
18  rename($filename,$filename . '.error');
19  }
20  }
21 
22 }
stats($id, $delta, $time, $addr, $user_agent)