Skip to content

Commit 91c842b

Browse files
author
Florian Schaal
committed
changed hard-coded conversion to formatBytes for web-traffic stats
1 parent ad24a14 commit 91c842b

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

interface/web/sites/templates/web_sites_stats_list.htm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ <h2><tmpl_var name="list_head_txt"></h2>
3030
<tmpl_loop name="records">
3131
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
3232
<td class="tbl_col_domain"><a target="_blank" href="http://{tmpl_var name="domain"}/stats">{tmpl_var name="domain"}</a></td>
33-
<td class="tbl_col_this_month"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_month"} MB</a></td>
34-
<td class="tbl_col_last_month"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_month"} MB</a></td>
35-
<td class="tbl_col_this_year"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_year"} MB</a></td>
36-
<td class="tbl_col_last_year"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_year"} MB</a></td>
33+
<td class="tbl_col_this_month"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_month"}</a></td>
34+
<td class="tbl_col_last_month"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_month"}</a></td>
35+
<td class="tbl_col_this_year"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_year"}</a></td>
36+
<td class="tbl_col_last_year"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_year"}</a></td>
3737
<td class="tbl_col_buttons"></td>
3838
</tr>
3939
</tmpl_loop>
@@ -60,4 +60,4 @@ <h2><tmpl_var name="list_head_txt"></h2>
6060
</fieldset>
6161
</div>
6262

63-
</div>
63+
</div>

interface/web/sites/web_sites_stats.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
//* Check permissions for module
1616
$app->auth->check_module_permissions('sites');
1717

18+
$app->uses('functions');
19+
1820
$app->load('listform_actions');
1921

2022
class list_action extends listform_actions {
@@ -39,26 +41,35 @@ function prepareDataRow($rec)
3941
$tmp_year = date('Y');
4042
$tmp_month = date('m');
4143
$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'");
42-
$rec['this_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
43-
$this->sum_this_month += ($tmp_rec['t']/1024/1024);
44+
// $rec['this_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
45+
// $this->sum_this_month += ($tmp_rec['t']/1024/1024);
46+
$rec['this_month'] = $app->functions->formatBytes($tmp_rec['t']);
47+
$this->sum_this_month += $app->functions->formatBytes($tmp_rec['t']);
48+
4449

4550
//** Traffic of the current year
4651
$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'");
47-
$rec['this_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
48-
$this->sum_this_year += ($tmp_rec['t']/1024/1024);
52+
// $rec['this_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
53+
// $this->sum_this_year += ($tmp_rec['t']/1024/1024);
54+
$rec['this_year'] = $app->functions->formatBytes($tmp_rec['t']);
55+
$this->sum_this_year += $app->functions->formatBytes($tmp_rec['t']);
4956

5057
//** Traffic of the last month
5158
$tmp_year = date('Y', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
5259
$tmp_month = date('m', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
5360
$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'");
54-
$rec['last_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
55-
$this->sum_last_month += ($tmp_rec['t']/1024/1024);
61+
// $rec['last_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
62+
// $this->sum_last_month += ($tmp_rec['t']/1024/1024);
63+
$rec['last_month'] = $app->functions->formatBytes($tmp_rec['t']);
64+
$this->sum_last_month += $app->functions->formatBytes($tmp_rec['t']);
5665

5766
//** Traffic of the last year
5867
$tmp_year = date('Y', mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
5968
$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'");
60-
$rec['last_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
61-
$this->sum_last_year += ($tmp_rec['t']/1024/1024);
69+
// $rec['last_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
70+
// $this->sum_last_year += ($tmp_rec['t']/1024/1024);
71+
$rec['last_year'] = $app->functions->formatBytes($tmp_rec['t']);
72+
$this->sum_last_year += $app->functions->formatBytes($tmp_rec['t']);
6273

6374
//* The variable "id" contains always the index variable
6475
$rec['id'] = $rec[$this->idx_key];

0 commit comments

Comments
 (0)