forked from opencad-community/OpenCAD-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.php
More file actions
205 lines (185 loc) · 5.92 KB
/
Copy pathdashboard.php
File metadata and controls
205 lines (185 loc) · 5.92 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
/**
Open source CAD system for RolePlaying Communities.
Copyright (C) 2017 Shane Gill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program comes with ABSOLUTELY NO WARRANTY; Use at your own risk.
**/
include("./oc-config.php");
require("./actions/api.php");
session_start();
if (empty($_SESSION['logged_in']))
{
header('Location: ./index.php');
die("Not logged in");
}
setDispatcher("1");
/*
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.
*/
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 = "";
$stateButton = "";
$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:".BASE_URL."/oc-admin/admin.php");
}
else if ($row[1] == "1")
{
$_SESSION['dispatch'] = 'YES';
header("Location:".BASE_URL."/cad.php");
}
else if ($row[1] == "2")
{
$_SESSION['ems'] = 'YES';
header("Location:".BASE_URL."/mdt.php?dep=fire");
}
else if ($row[1] == "3")
{
$_SESSION['fire'] = 'YES';
header("Location:".BASE_URL."/mdt.php?dep=fire");
}
else if ($row[1] == "4")
{
$_SESSION['highway'] = 'YES';
header("Location:".BASE_URL."/mdt.php?dep=police");
}
else if ($row[1] == "5")
{
$_SESSION['police'] = 'YES';
header("Location:".BASE_URL."/mdt.php?dep=police");
}
else if ($row[1] == "6")
{
$_SESSION['sheriff'] = 'YES';
header("Location:".BASE_URL."/mdt.php?dep=police");
}
else if ($row[1] == "7")
{
$_SESSION['civilian'] = 'YES';
header("Location:".BASE_URL."/civilian.php");
}
}
}
else
{
while($row = mysqli_fetch_array($result, MYSQLI_BOTH))
{
if ($row[1] == 0)
{
$_SESSION['admin'] = 'YES';
$adminButton = "<a href=\"".BASE_URL."/oc-admin/admin.php\" class=\"btn btn-primary btn-lg\">Admin</a>";
}
if ($row[1] == 1)
{
$_SESSION['dispatch'] = 'YES';
$dispatchButton = "<a href=\"".BASE_URL."/cad.php\" class=\"btn btn-primary btn-lg\">Dispatch</a>";
}
if ($row[1] == "2")
{
$_SESSION['ems'] = 'YES';
$emsButton = "<a href=\"".BASE_URL."/mdt.php?dep=fire\" class=\"btn btn-primary btn-lg\">EMS</a>";
}
if ($row[1] == "3")
{
$_SESSION['fire'] = 'YES';
$fireButton = "<a href=\"".BASE_URL."/mdt.php?dep=fire\" class=\"btn btn-primary btn-lg\">Fire</a>";
}
if ($row[1] == "4")
{
$_SESSION['highway'] = 'YES';
$highwayButton = "<a href=\"".BASE_URL."/mdt.php?dep=police\" class=\"btn btn-primary btn-lg\">Highway Patrol</a>";
}
if ($row[1] == "5")
{
$_SESSION['police'] = 'YES';
$policeButton = "<a href=\"".BASE_URL."/mdt.php?dep=police\" class=\"btn btn-primary btn-lg\">Police Department</a>"; }
if ($row[1] == "6")
{
$_SESSION['sheriff'] = 'YES';
$sheriffButton = "<a href=\"".BASE_URL."/mdt.php?dep=police\" class=\"btn btn-primary btn-lg\">Sheriff's Office</a>";
}
if ($row[1] == "9")
{
$_SESSION['state'] = 'YES';
$stateButton = "<a href=\"".BASE_URL."/mdt.php?dep=police\" class=\"btn btn-primary btn-lg\">State Police</a>";
}
if ($row[1] == "7")
{
$_SESSION['civillian'] = 'YES';
$civilianButton = "<a href=\"".BASE_URL."/civilian.php\" class=\"btn btn-primary btn-lg\">Civilian</a>";
}
}
}
mysqli_close($link);
?>
<html lang="en">
<!DOCTYPE html>
<?php include "./oc-includes/header.inc.php"; ?>
<body>
<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 launch:</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 $stateButton;?>
<?php echo $policeButton;?>
<?php echo $fireButton;?>
<?php echo $emsButton;?>
<?php echo $civilianButton;?>
</div>
<!-- ./ col-lg-12 -->
</div>
<!-- ./ row -->
</div>
<!-- ./ container-fluid -->
</div>
<!-- ./ page-wrapper -->
</body>
</html>