summaryrefslogtreecommitdiff
path: root/includes/pages/guest_stats.php
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2012-12-28 22:53:05 +0100
committerPhilip Häusler <msquare@notrademark.de>2012-12-28 22:53:05 +0100
commit263edf58f2751fbd042d71a1e786f6b203e3f71a (patch)
tree59ea4b0f6a6a29fb1757375d3cdf236af8273593 /includes/pages/guest_stats.php
parent7044c07c009ccaf4a0d9f27ab24e0cddaddcbae4 (diff)
stats for infobeamer/monitor
Diffstat (limited to 'includes/pages/guest_stats.php')
-rw-r--r--includes/pages/guest_stats.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/includes/pages/guest_stats.php b/includes/pages/guest_stats.php
new file mode 100644
index 00000000..8d96bbbf
--- /dev/null
+++ b/includes/pages/guest_stats.php
@@ -0,0 +1,30 @@
+<?php
+
+function guest_stats() {
+ global $api_key;
+
+ if(isset($_REQUEST['api_key'])) {
+ if($_REQUEST['api_key'] == $api_key) {
+ $stats = array();
+
+ list($user_count) = sql_select("SELECT count(*) as `user_count` FROM `User`");
+ $stats['user_count'] = $user_count['user_count'];
+
+ list($arrived_user_count) = sql_select("SELECT count(*) as `user_count` FROM `User` WHERE `Gekommen`=1");
+ $stats['arrived_user_count'] = $arrived_user_count['user_count'];
+
+ $done_shifts_source = sql_select("SELECT `Shifts`.`start`, `Shifts`.`end` FROM `ShiftEntry` JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` WHERE `Shifts`.`end` < " . time());
+ $done_shifts_seconds = 0;
+ foreach($done_shifts_source as $done_shift)
+ $done_shifts_seconds += $done_shift['end'] - $done_shift['start'];
+ $stats['done_work_hours'] = round($done_shifts_seconds / (60*60), 0);
+
+ header("Content-Type: application/json");
+ die(json_encode($stats));
+ } else die(json_encode(array('error' => "Wrong api_key.")));
+ } else die(json_encode(array('error' => "Missing parameter api_key.")));
+
+}
+
+
+?> \ No newline at end of file