Skip to content

Commit 6ac26d6

Browse files
committed
Implemented: FS#2059 - Extend Traffic quota system
1 parent 441dca4 commit 6ac26d6

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

interface/lib/classes/listform_actions.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function onShow()
282282
$this->onShowEnd();
283283
}
284284

285-
private function onShowEnd()
285+
public function onShowEnd()
286286
{
287287
global $app;
288288
$app->tpl_defaults();

interface/web/sites/lib/lang/en_web_sites_stats_list.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ $wb["this_month_txt"] = 'This month';
55
$wb["last_month_txt"] = 'Last month';
66
$wb["this_year_txt"] = 'This year';
77
$wb["last_year_txt"] = 'Last year';
8+
$wb["sum_txt"] = 'Sum';
89
?>

interface/web/sites/templates/web_sites_stats_list.htm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ <h2><tmpl_var name="list_head_txt"></h2>
3838
</td>
3939
</tr>
4040
</tmpl_loop>
41+
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
42+
<td class="tbl_col_domain"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');" style="font-weight:bold;">{tmpl_var name="sum_txt"}</a></td>
43+
<td class="tbl_col_this_month"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');" style="font-weight:bold;">{tmpl_var name="sum_this_month"} MB</a></td>
44+
<td class="tbl_col_last_month"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');" style="font-weight:bold;">{tmpl_var name="sum_last_month"} MB</a></td>
45+
<td class="tbl_col_this_year"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');" style="font-weight:bold;">{tmpl_var name="sum_this_year"} MB</a></td>
46+
<td class="tbl_col_last_year"><a href="#" onClick="loadContent('sites/web_domain_edit.php?id={tmpl_var name='id'}');" style="font-weight:bold;">{tmpl_var name="sum_last_year"} MB</a></td>
47+
<td class="tbl_col_buttons">
48+
<div class="buttons icons16">
49+
</div>
50+
</td>
51+
</tr>
4152
</tbody>
4253
<tfoot>
4354
<tr>

interface/web/sites/web_sites_stats.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
class list_action extends listform_actions {
2121

22+
private $sum_this_month = 0;
23+
private $sum_this_year = 0;
24+
private $sum_last_month = 0;
25+
private $sum_last_year = 0;
26+
2227
function prepareDataRow($rec)
2328
{
2429
global $app;
@@ -35,26 +40,45 @@ function prepareDataRow($rec)
3540
$tmp_month = date('m');
3641
$tmp_rec = $app->db->queryOneRecord("SELECT SUM(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$rec['domain']."' AND YEAR(traffic_date) = '$tmp_year' AND MONTH(traffic_date) = '$tmp_month'");
3742
$rec['this_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
43+
$this->sum_this_month += ($tmp_rec['t']/1024/1024);
3844

3945
//** Traffic of the current year
4046
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$rec['domain']."' AND YEAR(traffic_date) = '$tmp_year'");
4147
$rec['this_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
48+
$this->sum_this_year += ($tmp_rec['t']/1024/1024);
4249

4350
//** Traffic of the last month
4451
$tmp_year = date('Y',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
4552
$tmp_month = date('m',mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
4653
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$rec['domain']."' AND YEAR(traffic_date) = '$tmp_year' AND MONTH(traffic_date) = '$tmp_month'");
4754
$rec['last_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
55+
$this->sum_last_month += ($tmp_rec['t']/1024/1024);
4856

4957
//** Traffic of the last year
5058
$tmp_year = date('Y',mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
5159
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$rec['domain']."' AND YEAR(traffic_date) = '$tmp_year'");
5260
$rec['last_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
61+
$this->sum_last_year += ($tmp_rec['t']/1024/1024);
5362

5463
//* The variable "id" contains always the index variable
5564
$rec['id'] = $rec[$this->idx_key];
65+
5666
return $rec;
5767
}
68+
69+
function onShowEnd()
70+
{
71+
global $app;
72+
73+
$app->tpl->setVar('sum_this_month',number_format(intval($this->sum_this_month), 0, '.', ' '));
74+
$app->tpl->setVar('sum_this_year',number_format(intval($this->sum_this_year), 0, '.', ' '));
75+
$app->tpl->setVar('sum_last_month',number_format(intval($this->sum_last_month), 0, '.', ' '));
76+
$app->tpl->setVar('sum_last_year',number_format(intval($this->sum_last_year), 0, '.', ' '));
77+
$app->tpl->setVar('sum_txt',$app->listform->lng('sum_txt'));
78+
79+
$app->tpl_defaults();
80+
$app->tpl->pparse();
81+
}
5882
}
5983

6084
$list = new list_action;

0 commit comments

Comments
 (0)