From 5a49748dd5c787e5bafbf74bd9ef27c65c41778d Mon Sep 17 00:00:00 2001 From: andryyy Date: Wed, 26 Jul 2017 23:09:15 +0200 Subject: [PATCH] [Web] Add graphs and stats to JSON api --- data/web/json_api.php | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/data/web/json_api.php b/data/web/json_api.php index 71db6806..a97c20f5 100644 --- a/data/web/json_api.php +++ b/data/web/json_api.php @@ -493,6 +493,59 @@ if (isset($_SESSION['mailcow_cc_role']) || isset($_SESSION['pending_mailcow_cc_u break; case "get": switch ($category) { + case "rspamd": + switch ($object) { + case "stat": + $data = file_get_contents('http://rspamd-mailcow:11334/stat'); + if (!empty($data)) { + echo $data; + } + elseif (!isset($data) || empty($data)) { + echo '{}'; + } + break; + case "graph": + switch ($extra) { + case "hourly": + $data = file_get_contents('http://rspamd-mailcow:11334/graph?type=daily'); + if (!empty($data)) { + echo $data; + } + elseif (!isset($data) || empty($data)) { + echo '{}'; + } + break; + case "daily": + $data = file_get_contents('http://rspamd-mailcow:11334/graph?type=daily'); + if (!empty($data)) { + echo $data; + } + elseif (!isset($data) || empty($data)) { + echo '{}'; + } + break; + case "weekly": + $data = file_get_contents('http://rspamd-mailcow:11334/graph?type=daily'); + if (!empty($data)) { + echo $data; + } + elseif (!isset($data) || empty($data)) { + echo '{}'; + } + break; + case "monthly": + $data = file_get_contents('http://rspamd-mailcow:11334/graph?type=daily'); + if (!empty($data)) { + echo $data; + } + elseif (!isset($data) || empty($data)) { + echo '{}'; + } + break; + } + break; + } + break; case "domain": switch ($object) { case "all":