mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 00:31:58 +01:00
fixed the chart drawing
This commit is contained in:
parent
bc0fc6190e
commit
313d29c252
@ -76,7 +76,7 @@ create index `rcpt_idx2` on `rcpt`(`to`);
|
||||
|
||||
|
||||
drop view if exists `v_messages`;
|
||||
create view `v_messages` AS select `metadata`.`id` AS `id`,`metadata`.`piler_id` AS `piler_id`,`metadata`.`from` AS `from`,`metadata`.`fromdomain` AS `fromdomain`,`rcpt`.`to` AS `to`,`rcpt`.`todomain` AS `todomain`,`metadata`.`subject` AS `subject`, `metadata`.`size` AS `size`, `metadata`.`direction` AS `direction`, `metadata`.`sent` AS `sent`, `metadata`.`digest` AS `digest`, `metadata`.`bodydigest` AS `bodydigest` from (`metadata` join `rcpt`) where (`metadata`.`id` = `rcpt`.`id`);
|
||||
create view `v_messages` AS select `metadata`.`id` AS `id`,`metadata`.`piler_id` AS `piler_id`,`metadata`.`from` AS `from`,`metadata`.`fromdomain` AS `fromdomain`,`rcpt`.`to` AS `to`,`rcpt`.`todomain` AS `todomain`,`metadata`.`subject` AS `subject`, `metadata`.`size` AS `size`, `metadata`.`direction` AS `direction`, `metadata`.`sent` AS `sent`, `metadata`.`arrived` AS `arrived`, `metadata`.`digest` AS `digest`, `metadata`.`bodydigest` AS `bodydigest` from (`metadata` join `rcpt`) where (`metadata`.`id` = `rcpt`.`id`);
|
||||
|
||||
|
||||
drop table if exists `attachment`;
|
||||
|
@ -24,3 +24,9 @@ CREATE TABLE IF NOT EXISTS `counter_stats` (
|
||||
|
||||
alter table metadata drop index message_id;
|
||||
|
||||
|
||||
drop view if exists `v_messages`;
|
||||
create view `v_messages` AS select `metadata`.`id` AS `id`,`metadata`.`piler_id` AS `piler_id`,`metadata`.`from` AS `from`,`metadata`.`fromdomain` AS `fromdomain`,`rcpt`.`to` AS `to`,`rcpt`.`todomain` AS `todomain`,`metadata`.`subject` AS `subject`, `metadata`.`size` AS `size`, `metadata`.`direction` AS `direction`, `metadata`.`sent` AS `sent`, `metadata`.`arrived` AS `arrived`, `metadata`.`digest` AS `digest`, `metadata`.`bodydigest` AS `bodydigest` from (`metadata` join `rcpt`) where (`metadata`.`id` = `rcpt`.`id`);
|
||||
|
||||
|
||||
|
||||
|
@ -23,22 +23,9 @@ class ControllerStatGraph extends Controller {
|
||||
|
||||
$db->select_db($db->database);
|
||||
|
||||
$emails = "";
|
||||
|
||||
/* let the admin users see the whole statistics */
|
||||
|
||||
if(Registry::get('admin_user') == 0 && Registry::get('readonly_admin') == 0) {
|
||||
$uid = $this->model_user_user->get_uid_by_name($this->data['username']);
|
||||
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->get_emails_by_uid((int)$uid)) . "')";
|
||||
}
|
||||
else if(isset($this->request->get['uid']) && is_numeric($this->request->get['uid']) && $this->request->get['uid'] > 0){
|
||||
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->get_emails_by_uid((int)$this->request->get['uid'])) . "')";
|
||||
}
|
||||
|
||||
|
||||
$aa = new ModelStatChart();
|
||||
|
||||
$aa->lineChartHamSpam($emails, $timespan, $this->data['text_archived_messages'], SIZE_X, SIZE_Y, "");
|
||||
$aa->lineChartHamSpam($timespan, $this->data['text_archived_messages'], SIZE_X, SIZE_Y, "");
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
class ModelStatChart extends Model {
|
||||
|
||||
public function lineChartHamSpam($emails, $timespan, $title, $size_x, $size_y, $output){
|
||||
public function lineChartHamSpam($timespan, $title, $size_x, $size_y, $output){
|
||||
$ydata = array();
|
||||
$ydata2 = array();
|
||||
$dates = array();
|
||||
@ -25,13 +25,26 @@ class ModelStatChart extends Model {
|
||||
|
||||
|
||||
if($timespan == "daily"){
|
||||
$query = $this->db->query("select arrived-(arrived%3600) as ts, count(*) as num from " . TABLE_META . " where arrived > $range $emails $grouping ORDER BY ts DESC limit $limit");
|
||||
$delta = 3600;
|
||||
$date_format = "H:i";
|
||||
} else {
|
||||
$query = $this->db->query("select arrived-(arrived%86400) as ts, count(*) as num from " . TABLE_META . " where arrived > $range $emails $grouping ORDER BY ts DESC limit $limit");
|
||||
$delta = 86400;
|
||||
$date_format = "m.d.";
|
||||
}
|
||||
|
||||
if(Registry::get('admin_user') == 0) {
|
||||
|
||||
$q = '';
|
||||
foreach($_SESSION['auditdomains'] as $a) {
|
||||
if($q) { $q .= ",?"; } else { $q = "?"; }
|
||||
}
|
||||
reset($_SESSION['auditdomains']);
|
||||
$query = $this->db->query("select arrived-(arrived%$delta) as ts, count(*) as num from " . VIEW_MESSAGES . " where arrived > $range AND todomain IN ($q) $domains $grouping ORDER BY ts DESC limit $limit", $_SESSION['auditdomains']);
|
||||
} else {
|
||||
$query = $this->db->query("select arrived-(arrived%$delta) as ts, count(*) as num from " . TABLE_META . " where arrived > $range $grouping ORDER BY ts DESC limit $limit");
|
||||
}
|
||||
|
||||
|
||||
foreach ($query->rows as $q) {
|
||||
array_push($ydata, $q['num']);
|
||||
array_push($dates, date($date_format, $q['ts']));
|
||||
|
Loading…
Reference in New Issue
Block a user