From 91c842be76f7f7ac693577f61fb579728ad2e5d8 Mon Sep 17 00:00:00 2001
From: Florian Schaal <florian@schaal-24.de>
Date: Fri, 27 Dec 2013 15:15:05 -0500
Subject: [PATCH] changed hard-coded conversion to formatBytes for web-traffic stats

---
 interface/web/sites/web_sites_stats.php |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/interface/web/sites/web_sites_stats.php b/interface/web/sites/web_sites_stats.php
index f5eb927..9bf96cb 100644
--- a/interface/web/sites/web_sites_stats.php
+++ b/interface/web/sites/web_sites_stats.php
@@ -15,6 +15,8 @@
 //* Check permissions for module
 $app->auth->check_module_permissions('sites');
 
+$app->uses('functions');
+
 $app->load('listform_actions');
 
 class list_action extends listform_actions {
@@ -39,26 +41,35 @@
 		$tmp_year = date('Y');
 		$tmp_month = date('m');
 		$tmp_rec = $app->db->queryOneRecord("SELECT SUM(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$app->db->quote($rec['domain'])."' AND YEAR(traffic_date) = '$tmp_year' AND MONTH(traffic_date) = '$tmp_month'");
-		$rec['this_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
-		$this->sum_this_month += ($tmp_rec['t']/1024/1024);
+//		$rec['this_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
+//		$this->sum_this_month += ($tmp_rec['t']/1024/1024);
+		$rec['this_month'] = $app->functions->formatBytes($tmp_rec['t']);
+		$this->sum_this_month += $app->functions->formatBytes($tmp_rec['t']);
+
 
 		//** Traffic of the current year
 		$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$app->db->quote($rec['domain'])."' AND YEAR(traffic_date) = '$tmp_year'");
-		$rec['this_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
-		$this->sum_this_year += ($tmp_rec['t']/1024/1024);
+//		$rec['this_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
+//		$this->sum_this_year += ($tmp_rec['t']/1024/1024);
+		$rec['this_year'] = $app->functions->formatBytes($tmp_rec['t']);
+		$this->sum_this_year += $app->functions->formatBytes($tmp_rec['t']);
 
 		//** Traffic of the last month
 		$tmp_year = date('Y', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
 		$tmp_month = date('m', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
 		$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$app->db->quote($rec['domain'])."' AND YEAR(traffic_date) = '$tmp_year' AND MONTH(traffic_date) = '$tmp_month'");
-		$rec['last_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
-		$this->sum_last_month += ($tmp_rec['t']/1024/1024);
+//		$rec['last_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
+//		$this->sum_last_month += ($tmp_rec['t']/1024/1024);
+		$rec['last_month'] = $app->functions->formatBytes($tmp_rec['t']);
+		$this->sum_last_month += $app->functions->formatBytes($tmp_rec['t']);
 
 		//** Traffic of the last year
 		$tmp_year = date('Y', mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
 		$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$app->db->quote($rec['domain'])."' AND YEAR(traffic_date) = '$tmp_year'");
-		$rec['last_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
-		$this->sum_last_year += ($tmp_rec['t']/1024/1024);
+//		$rec['last_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
+//		$this->sum_last_year += ($tmp_rec['t']/1024/1024);
+		$rec['last_year'] = $app->functions->formatBytes($tmp_rec['t']);
+		$this->sum_last_year += $app->functions->formatBytes($tmp_rec['t']);
 
 		//* The variable "id" contains always the index variable
 		$rec['id'] = $rec[$this->idx_key];

--
Gitblit v1.9.1