summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics_reporting/hooks/cron.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics_reporting/hooks/cron.inc.php')
-rw-r--r--modules-available/statistics_reporting/hooks/cron.inc.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/modules-available/statistics_reporting/hooks/cron.inc.php b/modules-available/statistics_reporting/hooks/cron.inc.php
new file mode 100644
index 00000000..a48f74c2
--- /dev/null
+++ b/modules-available/statistics_reporting/hooks/cron.inc.php
@@ -0,0 +1,23 @@
+<?php
+
+if (RemoteReport::isReportingEnabled()) {
+ $nextReporting = RemoteReport::getReportingTimestamp();
+
+ // It's time to generate a new report
+ if ($nextReporting <= time()) {
+ RemoteReport::writeNextReportingTimestamp();
+
+ $from = strtotime("-7 days", $nextReporting);
+ $to = $nextReporting;
+
+ $statisticsReport = json_encode(RemoteReport::generateReport($from, $to));
+
+ $params = array("action" => "statistics", "data" => $statisticsReport);
+
+ $result = Download::asStringPost(CONFIG_REPORTING_URL, $params, 30, $code);
+
+ if ($code != 200) {
+ EventLog::warning("Statistics Reporting failed: " . $code, $result);
+ }
+ }
+} \ No newline at end of file