From f31ecfcbd2148079cc34adeb51f75407e05b50c3 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Sun, 4 Sep 2022 13:25:05 +0200 Subject: [PATCH] Removed obsoleted chart controllers Signed-off-by: Janos SUTO --- webui/controller/stat/chart.php | 45 -------------------------- webui/controller/stat/graph.php | 34 -------------------- webui/model/stat/chart.php | 57 --------------------------------- 3 files changed, 136 deletions(-) delete mode 100644 webui/controller/stat/chart.php delete mode 100644 webui/controller/stat/graph.php diff --git a/webui/controller/stat/chart.php b/webui/controller/stat/chart.php deleted file mode 100644 index bab4a75e..00000000 --- a/webui/controller/stat/chart.php +++ /dev/null @@ -1,45 +0,0 @@ -load->model('user/user'); - - $this->load->model('stat/chart'); - - $this->load->helper('libchart/classes/libchart'); - - $this->data['username'] = Registry::get('username'); - - $timespan = @$this->request->get['timespan']; - - $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->pieChartHamSpam($emails, $timespan, $this->data['text_ham_and_spam_messages'], ""); - - } - - -} - -?> diff --git a/webui/controller/stat/graph.php b/webui/controller/stat/graph.php deleted file mode 100644 index 405afdfe..00000000 --- a/webui/controller/stat/graph.php +++ /dev/null @@ -1,34 +0,0 @@ -load->model('user/user'); - - - $this->load->model('stat/chart'); - - $this->load->helper('libchart/classes/libchart'); - - $this->data['username'] = Registry::get('username'); - - $timespan = @$this->request->get['timespan']; - - $db->select_db($db->database); - - $aa = new ModelStatChart(); - - $aa->lineChartHamSpam($timespan, $this->data['text_archived_messages'], SIZE_X, SIZE_Y, ""); - - } - -} - -?> diff --git a/webui/model/stat/chart.php b/webui/model/stat/chart.php index 987e73cc..dcd3833a 100644 --- a/webui/model/stat/chart.php +++ b/webui/model/stat/chart.php @@ -53,38 +53,6 @@ class ModelStatChart extends Model { } - public function pieChartHamSpam($emails = '', $timespan, $title, $output) { - $ham = $spam = 0; - - $range = $this->getRangeInSeconds($timespan); - - $chart = new PieChart(SIZE_X, SIZE_Y); - - $query = $this->db->query("SELECT COUNT(*) AS SPAM FROM " . TABLE_META . " WHERE $emails AND arrived > $range"); - if($query->num_rows > 0) { $spam = $query->row['SPAM']; } - - $query = $this->db->query("SELECT COUNT(*) AS HAM FROM " . TABLE_META . " WHERE $emails AND arrived > $range"); - if($query->num_rows > 0) { $ham = $query->row['HAM']; } - - if($ham > $spam) { - $chart->getPlot()->getPalette()->setPieColor(array(new Color(26, 192, 144), new Color(208, 48, 128) )); - } else { - $chart->getPlot()->getPalette()->setPieColor(array(new Color(208, 48, 128), new Color(26, 192, 144) )); - } - - - $dataSet = new XYDataSet(); - - $dataSet->addPoint(new Point("HAM ($ham)", $ham)); - $dataSet->addPoint(new Point("SPAM ($spam)", $spam)); - - $chart->setDataSet($dataSet); - $chart->setTitle($title); - - @$this->sendOutput($chart, $output); - } - - private function getRangeInSeconds($timespan) { $range = 0; @@ -95,29 +63,4 @@ class ModelStatChart extends Model { } - private function getDataPoints($timespan) { - - if($timespan == "daily") { return 24; } - if($timespan == "weekly") { return 7; } - - return 30; - } - - - private function sendOutput($chart, $output = '') { - if($output == "") { - header("Content-type: image/png"); - header("Expires: now"); - } - - if($output) { - $chart->render($output); - } - else { - $chart->render(); - } - } - } - -?>