-
Notifications
You must be signed in to change notification settings - Fork 1
/
checkin.php
43 lines (38 loc) · 1.48 KB
/
checkin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
require_once 'config.php';
require_once 'functions.php';
$sql = "INSERT INTO statistics(person, date, service, expires, checkin, code, location, activity, room)
SELECT :person, current_date, (SELECT name FROM services WHERE id = :service),
'23:59:59', now()::timestamp, :code, :location, activities.name, rooms.name FROM data
LEFT JOIN activities ON data.activity=activities.id
LEFT JOIN rooms ON data.room = rooms.id
WHERE data.id = :person;";
$dbh = db_connect();
$sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
ob_start();
include "/usr/lib/cgi-bin/secure-code.php";
$code = ob_get_clean();
function checkin($person, $service) {
global $code, $sth;
$sth->execute(array(
":person" => $person,
":service" => $service,
":code" => $code,
":location" => get_client_ip()
));
}
header('Content-type: application/json');
if (!array_key_exists("services", $_REQUEST)) {
checkin($_REQUEST["person"], $_REQUEST["service"]);
echo json_encode(array("success" => true));
} else {
$services = intval($_REQUEST["services"]);
for ($i = 0; $i < floor(log($services, 2)) + 1; $i++) {
if (($services >> $i) & 1) {
checkin($_REQUEST["person"], $i);
}
}
echo json_encode(array("success" => true));
}
//TODO http://taxidi-kiosk1.local:8888/print.php?token=foxesarepawesome&action=print&id=2243
?>