summaryrefslogtreecommitdiff
path: root/includes/pages/guest_stats.php
diff options
context:
space:
mode:
authorBot <bot@myigel.name>2017-01-02 03:57:23 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-01-02 03:57:23 +0100
commit7313e15ce8236e19331fb6639a3a5b97c8f06ecd (patch)
tree399e5eaa403d6dd5993ca8fb6f2162319d2ed2e1 /includes/pages/guest_stats.php
parentb839e401062b294292fdcbd7e30b79bc149fab6f (diff)
PSR-2 formatting
Diffstat (limited to 'includes/pages/guest_stats.php')
-rw-r--r--includes/pages/guest_stats.php45
1 files changed, 22 insertions, 23 deletions
diff --git a/includes/pages/guest_stats.php b/includes/pages/guest_stats.php
index 71fde137..2559dd4d 100644
--- a/includes/pages/guest_stats.php
+++ b/includes/pages/guest_stats.php
@@ -1,35 +1,34 @@
<?php
-function guest_stats() {
- global $api_key;
+function guest_stats()
+{
+ global $api_key;
- if (isset($_REQUEST['api_key'])) {
- if ($_REQUEST['api_key'] == $api_key) {
- $stats = [];
+ if (isset($_REQUEST['api_key'])) {
+ if ($_REQUEST['api_key'] == $api_key) {
+ $stats = [];
- list($user_count) = sql_select("SELECT count(*) as `user_count` FROM `User`");
- $stats['user_count'] = $user_count['user_count'];
+ 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'];
+ 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_seconds = sql_select_single_cell("SELECT SUM(`Shifts`.`end` - `Shifts`.`start`) FROM `ShiftEntry` JOIN `Shifts` USING (`SID`) WHERE `Shifts`.`end` < UNIX_TIMESTAMP()");
- $stats['done_work_hours'] = round($done_shifts_seconds / (60 * 60), 0);
+ $done_shifts_seconds = sql_select_single_cell("SELECT SUM(`Shifts`.`end` - `Shifts`.`start`) FROM `ShiftEntry` JOIN `Shifts` USING (`SID`) WHERE `Shifts`.`end` < UNIX_TIMESTAMP()");
+ $stats['done_work_hours'] = round($done_shifts_seconds / (60 * 60), 0);
- $users_in_action = sql_select("SELECT `Shifts`.`start`, `Shifts`.`end` FROM `ShiftEntry` JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` WHERE UNIX_TIMESTAMP() BETWEEN `Shifts`.`start` AND `Shifts`.`end`");
- $stats['users_in_action'] = count($users_in_action);
+ $users_in_action = sql_select("SELECT `Shifts`.`start`, `Shifts`.`end` FROM `ShiftEntry` JOIN `Shifts` ON `Shifts`.`SID`=`ShiftEntry`.`SID` WHERE UNIX_TIMESTAMP() BETWEEN `Shifts`.`start` AND `Shifts`.`end`");
+ $stats['users_in_action'] = count($users_in_action);
- header("Content-Type: application/json");
- raw_output(json_encode($stats));
- return;
+ header("Content-Type: application/json");
+ raw_output(json_encode($stats));
+ return;
+ }
+ raw_output(json_encode([
+ 'error' => "Wrong api_key."
+ ]));
}
raw_output(json_encode([
- 'error' => "Wrong api_key."
- ]));
- }
- raw_output(json_encode([
- 'error' => "Missing parameter api_key."
+ 'error' => "Missing parameter api_key."
]));
}
-
-?>