forked from cyklokoalicia/OpenSourceBikeShare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscan.php
43 lines (39 loc) · 1.14 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
<?php
require("config.php");
require("external/rb.php");
R::setup('mysql:host='.$dbserver.';dbname='.$dbname,$dbuser,$dbpassword);
R::freeze( TRUE );
R::debug( TRUE,2 );
R::addDatabase('localdb','mysql:host='.$dbserver.';dbname='.$dbname,$dbuser,$dbpassword,TRUE);
R::begin();
require('actions-qrcode.php');
if (isset($_COOKIE["loguserid"])) $userid=$_COOKIE["loguserid"];
else $userid=0;
if (isset($_COOKIE["logsession"])) $session=$_COOKIE["logsession"];
$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 $action=""; // mangled QR code, clear action
switch($action)
{
case "rent":
logrequest($userid,$action);
checksession();
$bikenum=$parameter;
checkbikeno($bikenum);
rentbike($userid,$bikenum);
break;
case "return":
logrequest($userid,$action);
checksession();
$stand=$parameter;
checkstandname($stand);
returnbike($userid,0,$stand);
break;
default:
logrequest($userid,$action);
unrecognizedqrcode($userid);
}
R::close();
?>