-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail_user_stats.php
More file actions
69 lines (51 loc) · 2.35 KB
/
mail_user_stats.php
File metadata and controls
69 lines (51 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php';
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/mail_user_stats.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('mail');
$app->uses('functions');
$app->load('listform_actions');
class list_action extends listform_actions {
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 = ? AND month = ?", $rec['mailuser_id'], $tmp_date);
$rec['this_month_sort'] = $tmp_rec['t'];
$rec['this_month'] = $app->functions->formatBytes($tmp_rec['t']);
//** 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 = ? AND month like ?", $rec['mailuser_id'], $tmp_date . '%');
$rec['this_year_sort'] = $tmp_rec['t'];
$rec['this_year'] = $app->functions->formatBytes($tmp_rec['t']);
//** Traffic of the last month
$tmp_date = date('Y-m', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
$tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ? AND month = ?", $rec['mailuser_id'], $tmp_date);
$rec['last_month_sort'] = $tmp_rec['t'];
$rec['last_month'] = $app->functions->formatBytes($tmp_rec['t']);
//** Traffic of the last year
$tmp_date = date('Y', mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ? AND month like ?", $rec['mailuser_id'], $tmp_date . '%');
$rec['last_year_sort'] = $tmp_rec['t'];
$rec['last_year'] = $app->functions->formatBytes($tmp_rec['t']);
//* The variable "id" contains always the index variable
$rec['id'] = $rec[$this->idx_key];
return $rec;
}
}
$list = new list_action;
$list->onLoad();
?>