forked from phlane/openCad
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdashboard.php
More file actions
205 lines (186 loc) · 5.46 KB
/
dashboard.php
File metadata and controls
205 lines (186 loc) · 5.46 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
session_start();
if (empty($_SESSION['logged_in']))
{
header('Location: ./index.php');
die("Not logged in");
}
/*
The purpose of this page is to simply determine if the user has multiple roles.
If they do, provide them the option to go where they want to go.
Else, redirect to the only place they can go.
*/
require("./oc-config.php");
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (!$link) {
die('Could not connect: ' .mysql_error());
}
$id = $_SESSION['id'];
$sql = "SELECT * from user_departments WHERE user_id = \"$id\"";
$result=mysqli_query($link, $sql);
$adminButton = "";
$dispatchButton = "";
$highwayButton = "";
$fireButton = "";
$emsButton = "";
$sheriffButton = "";
$policeButton = "";
$civilianButton = "";
$num_rows = $result->num_rows;
// This loop will auto redirect the user if they only have one option
// TODO: Add the rest of the headers
if($num_rows < 2)
{
while($row = mysqli_fetch_array($result, MYSQLI_BOTH))
{
if ($row[1] == "0")
{
$_SESSION['admin'] = 'YES';
header("Location:./oc-admin/admin.php");
}
else if ($row[1] == "1")
{
$_SESSION['dispatch'] = 'YES';
header("Location:./cad.php");
}
else if ($row[1] == "2")
{
$_SESSION['ems'] = 'YES';
header("Location:./mdt.php");
}
else if ($row[1] == "3")
{
$_SESSION['fire'] = 'YES';
header("Location:./mdt.php");
}
else if ($row[1] == "4")
{
$_SESSION['highway'] = 'YES';
header("Location:./mdt.php");
}
else if ($row[1] == "5")
{
$_SESSION['police'] = 'YES';
header("Location:./mdt.php");
}
else if ($row[1] == "6")
{
$_SESSION['sheriff'] = 'YES';
header("Location:./mdt.php");
}
else if ($row[1] == "7")
{
$_SESSION['civilian'] = 'YES';
header("Location:./civillian.php");
}
}
}
else
{
while($row = mysqli_fetch_array($result, MYSQLI_BOTH))
{
if ($row[1] == 0)
{
$adminButton = "<a href=\"./oc-admin/admin.php\" class=\"btn btn-primary btn-lg\">Administration</a>";
$_SESSION['admin'] = 'YES';
}
if ($row[1] == 1)
{
$_SESSION['dispatch'] = 'YES';
$dispatchButton = "<a href=\"./cad.php\" class=\"btn btn-primary btn-lg\">Dispatch</a>";
}
if ($row[1] == "2")
{
$_SESSION['ems'] = 'YES';
$emsButton = "<a href=\"./mdt.php\" class=\"btn btn-primary btn-lg\">EMS</a>";
}
if ($row[1] == "3")
{
$_SESSION['fire'] = 'YES';
$fireButton = "<a href=\"./mdt.php?fire=true\" class=\"btn btn-primary btn-lg\">Fire Department</a>";
}
if ($row[1] == "4")
{
$_SESSION['highway'] = 'YES';
$highwayButton = "<a href=\"./mdt.php\" class=\"btn btn-primary btn-lg\">Highway Patrol</a>";
}
if ($row[1] == "5")
{
$_SESSION['police'] = 'YES';
$policeButton = "<a href=\"./mdt.php\" class=\"btn btn-primary btn-lg\">Police Department</a>";
}
if ($row[1] == "6")
{
$_SESSION['sheriff'] = 'YES';
$sheriffButton = "<a href=\"./mdt.php\" class=\"btn btn-primary btn-lg\">Sheriff's Office</a>";
}
if ($row[1] == "7")
{
$_SESSION['civillian'] = 'YES';
$civilianButton = "<a href=\"./civilian.php\" class=\"btn btn-primary btn-lg\">Civilian</a>";
}
}
}
mysqli_close($link);
?>
<html lang="en">
<!DOCTYPE html>
<head>
<!-- CSS -->
<!-- Bootstrap Core CSS -->
<link rel="stylesheet" href="./css/bootstrap.css">
<style>
#cadWelcome {
height:20px;
width:50px;
margin: 50%px 50%px;
position:relative;
top:90%;
left:45%;
text-align:center;
}
</style>
<title>CAD/MDT Launcher</title>
<link rel="icon" href="./images/favicon.ico" />
</head>
<body>
<?php echo "<h3> PHP List All Session Variables</h3>";
foreach ($_SESSION as $key=>$val)
echo $key." ".$val."<br/>"; ?>
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header" style="text-align:center;">Select console to laucnh:</h1>
</div>
<!-- ./ col-lg-12 -->
</div>
<!-- ./ row -->
</div class="row">
<div class="col-lg-12" id="cadWelcome">
<?php echo $adminButton;?><br/><br/>
<?php echo $dispatchButton;?>
<?php echo $sheriffButton;?>
<?php echo $highwayButton;?>
<?php echo $policeButton;?>
<?php echo $fireButton;?>
<?php echo $civilianButton;?>
</div>
<!-- ./ col-lg-12 -->
</div>
<!-- ./ row -->
</div>
<!-- ./ container-fluid -->
</div>
<!-- ./ page-wrapper -->
</body>
</html>