-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathscan.php
50 lines (43 loc) · 1.3 KB
/
scan.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
44
45
46
47
48
49
50
<?php
use BikeShare\Rent\RentSystemInterface;
require_once 'vendor/autoload.php';
require_once 'actions-qrcode.php';
$userid = $auth->getUserId();
if (!$auth->isLoggedIn()) {
response("<h3>" . _('You are not logged in.') . "</h3>", ERROR);
}
/**
* @var RentSystemInterface $rentSystem
*/
$rentSystem = $rentSystemFactory->getRentSystem('qr');
$request = substr($_SERVER["REQUEST_URI"], strpos($_SERVER["REQUEST_URI"], ".php") + 5);
$request = explode("/", $request);
$action = $request[0];
if (isset($request[1])) {
$parameter = $request[1];
} else {
// mangled QR code, clear action
$action = "";
}
switch ($action) {
case "rent":
logrequest($userid, $action);
$bikeno = $parameter;
checkbikeno($bikeno);
if (!empty($_POST['rent']) && $_POST['rent'] == "yes") {
$result = $rentSystem->rentBike($userid, $bikeno);
response($result['content'], $result['error'], 0);
} else {
showrentform($userid, $bikeno);
}
break;
case "return":
logrequest($userid, $action);
$stand = $parameter;
checkstandname($stand);
$result = $rentSystem->returnBike($userid, 0, $stand);
response($result['content'], $result['error'], 0);
break;
default:
unrecognizedqrcode();
}