-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathcommand.php
105 lines (99 loc) · 2.8 KB
/
command.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
use BikeShare\Rent\RentSystemInterface;
require_once 'vendor/autoload.php';
require_once 'actions-web.php';
$userid = $auth->getUserId();
/**
* @var RentSystemInterface $rentSystem
*/
$rentSystem = $rentSystemFactory->getRentSystem('web');
$action="";
if (isset($_GET["action"])) $action=trim($_GET["action"]);
switch($action)
{
case "list":
$stand=trim($_GET["stand"]);
listbikes($stand);
break;
case "rent":
logrequest($userid,$action);
$bikeno=trim($_GET["bikeno"]);
checkbikeno($bikeno);
$rentSystem->rentBike($userid,$bikeno);
break;
case "return":
logrequest($userid,$action);
$bikeno=trim($_GET["bikeno"]);
$stand=trim($_GET["stand"]);
$note="";
if (isset($_GET["note"])) $note=trim($_GET["note"]);
checkbikeno($bikeno); checkstandname($stand);
$rentSystem->returnBike($userid,$bikeno,$stand,$note);
break;
case "validatecoupon":
logrequest($userid,$action);
$coupon=trim($_GET["coupon"]);
validatecoupon($userid,$coupon);
break;
case "changecity":
logrequest($userid,$action);
$city=trim($_GET["city"]);
changecity($userid,$city);
break;
case "forcerent":
logrequest($userid,$action);
checkprivileges($userid);
$bikeno=trim($_GET["bikeno"]);
checkbikeno($bikeno);
$rentSystem->rentBike($userid,$bikeno,true);
break;
case "forcereturn":
logrequest($userid,$action);
checkprivileges($userid);
$bikeno=trim($_GET["bikeno"]);
$stand=trim($_GET["stand"]);
$note="";
if (isset($_GET["note"])) $note=trim($_GET["note"]);
checkbikeno($bikeno); checkstandname($stand);
$rentSystem->returnBike($userid, $bikeno, $stand, $note, TRUE);
break;
case "removenote":
logrequest($userid,$action);
checkprivileges($userid);
$bikeno = trim($_GET["bikeno"]);
checkbikeno($bikeno);
removenote($userid,$bikeno);
break;
case "revert":
logrequest($userid,$action);
$bikeno=trim($_GET["bikeno"]);
checkprivileges($userid);
checkbikeno($bikeno);
$rentSystem->revertBike($userid, $bikeno);
break;
case "trips":
logrequest($userid,$action);
checkprivileges($userid);
if ($_GET["bikeno"])
{
$bikeno=trim($_GET["bikeno"]);
checkbikeno($bikeno);
trips($userid,$bikeno);
}
else trips($userid);
break;
case "userbikes":
userbikes($userid);
break;
case "map:markers":
mapgetmarkers($userid);
break;
case "map:status":
mapgetlimit($userid);
break;
case "map:geolocation":
$lat=floatval(trim($_GET["lat"]));
$long=floatval(trim($_GET["long"]));
mapgeolocation($userid,$lat,$long);
break;
}