View Single Post
  #15  
Old 3rd August 2012, 16:06
tom123 tom123 is offline
Member
 
Join Date: Feb 2012
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The same broken query apply on mail stats calculation.
From your daily_cron.php, you are calculating mail traffic saving data to the master db:

Quote:
if($tr['traffic_id'] > 0) {
$sql = "UPDATE mail_traffic SET traffic = ".$mail_traffic." WHERE traffic_id = ".intval($tr['traffic_id']);
} else {
$sql = "INSERT INTO mail_traffic (month,mailuser_id,traffic) VALUES ('".$tstamp."', ".intval($rec['mailuser_id']).", ".$size.")";
}
echo $sql."\n";
$app->dbmaster->query($sql);
($size is one on mine customization, there is no $size in SVN code)


Now, from the interface code (mail_user_stats.php), you are quering the local server and not the master:

Code:
	function prepareDataRow($rec)
    {
		global $app;
		
		$rec = $app->listform->decode($rec);

		//* Alternating datarow colors
		$this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
		$rec['bgcolor'] = $this->DataRowColor;
		
		//* Set the statistics colums
		//** Traffic of the current month
		$tmp_date = date('Y-m');
		$tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month = '$tmp_date'");
		$rec['this_month'] = number_format(intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
		
		//** Traffic of the current year
		$tmp_date = date('Y');
		$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ".$rec['mailuser_id']." AND month like '$tmp_date%'");
		$rec['this_year'] = number_format(intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
Reply With Quote