summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics_reporting/hooks
diff options
context:
space:
mode:
authorSimon Rettberg2017-01-19 16:03:06 +0100
committerSimon Rettberg2017-01-19 16:03:06 +0100
commit886e13e1af47ba6488ba3c5146d96e48e08403ad (patch)
treedd0da56ccf6f2e5ae9e4e6b1e5709b911d255164 /modules-available/statistics_reporting/hooks
parent[statistics_reporting] i18n: Move tags used in code to separate file, delete ... (diff)
downloadslx-admin-886e13e1af47ba6488ba3c5146d96e48e08403ad.tar.gz
slx-admin-886e13e1af47ba6488ba3c5146d96e48e08403ad.tar.xz
slx-admin-886e13e1af47ba6488ba3c5146d96e48e08403ad.zip
[statistics_reporting] Overhaul remote reporting structure; default to off
Diffstat (limited to 'modules-available/statistics_reporting/hooks')
-rw-r--r--modules-available/statistics_reporting/hooks/cron.inc.php37
1 files changed, 14 insertions, 23 deletions
diff --git a/modules-available/statistics_reporting/hooks/cron.inc.php b/modules-available/statistics_reporting/hooks/cron.inc.php
index bd427e64..a48f74c2 100644
--- a/modules-available/statistics_reporting/hooks/cron.inc.php
+++ b/modules-available/statistics_reporting/hooks/cron.inc.php
@@ -1,32 +1,23 @@
<?php
-$nextReporting = Property::get("nextReporting", 0);
-$time = time();
+if (RemoteReport::isReportingEnabled()) {
+ $nextReporting = RemoteReport::getReportingTimestamp();
-$allowReport = Property::get("reportingStatus", "on") == "on";
+ // It's time to generate a new report
+ if ($nextReporting <= time()) {
+ RemoteReport::writeNextReportingTimestamp();
-if ($nextReporting < $time && $allowReport) {
+ $from = strtotime("-7 days", $nextReporting);
+ $to = $nextReporting;
- Property::set("nextReporting", strtotime("Sunday 23:59:59"));
+ $statisticsReport = json_encode(RemoteReport::generateReport($from, $to));
- GetData::$from = strtotime("last sunday - 6 days");
- GetData::$to = strtotime("last sunday 23:59:59");
- GetData::$salt = bin2hex(random_bytes(20));
+ $params = array("action" => "statistics", "data" => $statisticsReport);
- $data = array_merge(GetData::total(true), array('perLocation' => array(), 'perClient' => array(), 'perUser' => array(), 'perVM' => array()));
- $data['perLocation'] = GetData::perLocation(true);
- $data['perClient'] = GetData::perClient(true);
- $data['perUser'] = GetData::perUser(true);
- $data['perVM'] = GetData::perVM(true);
+ $result = Download::asStringPost(CONFIG_REPORTING_URL, $params, 30, $code);
-
- $statisticsReport = json_encode($data);
-
- $params = array("action" => "statistics", "data" => $statisticsReport);
-
- Download::asStringPost(CONFIG_REPORTING_URL, $params, 300, $code);
-
- if ($code != 200) {
- EventLog::warning("Statistics Reporting: ".$code);
+ if ($code != 200) {
+ EventLog::warning("Statistics Reporting failed: " . $code, $result);
+ }
}
-}
+} \ No newline at end of file