This repository has been archived by the owner on Oct 7, 2022. It is now read-only.
/
detail_nologin.php
executable file
·256 lines (159 loc) · 5.7 KB
/
detail_nologin.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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
$actual_url = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
setcookie("referrer", $actual_url, 0, "/");
if (!isset($_COOKIE["login"])) {
setcookie("login", "", 0, "/");
$_COOKIE["login"] = "";
}
//loads required library files
require 'resources/config/config.php';
//markdown is used to display the status entries for issues and the text of updates
require $markdown_path;
require 'resources/php/functions.php';
//markdown is used to display the status entries for issues and the text of updates
require ('resources/php/markdown.php');
//load all starting session and other variables and required libraries
date_default_timezone_set('America/Detroit');
//if using native login, set the URL
if ($use_native_login == true){
$loginUrl = "login.php";
} else {
$loginUrl = $non_native_login_url;
}
//can we connect to the database? If not, display an error and cease loading the app
$db = new mysqli($db_host, $db_user, $db_pass, $db_database);
if ($db->connect_errno) {
HTML_error_message($db->connect_error);
exit;
}
//variable to track if user is logged in
$logged_in = 0;
//holds system messages we want to show to the user. By default, there are none
$userMessage = NULL;
//if the user is trying to log out, send them to the logout script with a flag set
if (isset($_GET["logout"])) {
setcookie("login", "", 0, "/");
$_COOKIE["login"] = "";
header("Location: index.php");
}
// uncomment to force a login
//$_SESSION['username'] = 'felkerk';
//you should only get to this page by following a link from index.php or by sumbitting a form on the page.
//in all cases, a type and an id for the issue or update must be passed or the page won't display
if (isset($_GET['id'])) {
$ID = $_GET['id'];
settype($ID, "integer");
} else if (isset($_POST['id'])) {
$ID = $_POST['id'];
set_type($ID, "integer");
} else {
$ID = false;
$userMessage = "<div class=\"alert alert-danger\">No system ID provided.</div>";
}
//get the type of posting (issue or update), either from GET or POST.
if (isset($_GET['type'])) {
if ($_GET['type'] == "issue") {
$type = "issue";
} else if ($_GET['type'] == "update") {
$type = "update";
} else {
$type = false;
$userMessage = "<div class=\"alert alert-danger\">Type of data not specified</div>";
}
} else if (isset($_POST['type'])) {
$ID = $_POST['type'];
set_type($ID, "integer");
} else {
$type = false;
$userMessage = "<div class=\"alert alert-danger\">Type of data not specified</div>";
}
if ($_COOKIE['login'] != "") { // User has logged in
//attempt to make a user object
$user = MakeUserArray($_COOKIE['login'],'', $db);
if (is_array($user)) {
$logged_in = 1;
} else {
//set a message for the user if they couldn't be found
$userMessage = "<div class=\"alert alert-danger\">" . $user . "</div>";
}
}
//now check to make sure we can get data for the parameters supplied-if we have deleted the entry, then we need to signal to the rest
//of the script not to show anything
if ($type == "issue") {
$issue = getIssueData($ID, $db);
if (!is_array($issue)) {
$userMessage = $issue;
$issue = false;
}
} else {
$update = getUpdateData($ID, $db);
if (!is_array($update)) {
$userMessage = $update;
$update = false;
}
}
include 'resources/php/header.php';
?>
<div id="cms-body-wrapper">
<div id="cms-body">
<div id="cms-body-inner">
<div id="cms-body-table">
<div id="cms-content">
<div class="row break">
<div class="span2 unit left">
<h2><a href="index.php"><?php echo $library_name; ?> Status</a></h2>
</div> <!-- end span -->
<div class="span1 unit right lib-horizontal-list" style="text-align: right;margin-top:.65em;overflow:visible;">
<ul>
<li style="float:right;margin-right: 8%;"><?php echo (($logged_in == 1) ? 'Hello, ' . $user["fn"] . ' // <a href="?logout" title="Log out" style="text-decoration: none; font-size: .9em;">Log out</a>' : '<a href="index.php?login" title="Log in" style="text-decoration: none; font-size: .9em;">Log in</a>'); ?></li>
</ul>
</div>
</div> <!-- end line -->
<div class="cms-clear"></div>
<div class="row break" style="margin-top: 1em;">
<?php
if ($userMessage != "") {
echo $userMessage;
echo "<P>";
}
?>
</div> <!-- end line -->
<a href="index.php">Back to Main Page</a>
<div class="row">
<P></P>
<?php
if ($ID && $type) {
if ($type == "issue" && $issue) {
echo '<div class="span3">';
displayIssue($issue);
if (is_null($issue["end_time"]) || strtotime($issue["end_time"]) > time()) {
$resolved = false;
} else {
$resolved = true;
}
$statusIDs = getStatusIDs($issue["id"], $db);
foreach ($statusIDs as $statusID) {
$statusData = getStatusData($statusID, $db);
displayStatus($statusData, $db);
}
echo "</div>";
} else if ($type == "update" && $update) {
echo '<div class="span3">';
displayUpdate($update, $db);
echo '</div>';
}
}
?>
<div class="row break footer">
<div class="span3 unit">
<p>Written by <a href="mailto:felkerk@gvsu.edu" title="K-felk">Kyle Felker</a> for <a href="http://gvsu.edu/library">Grand Valley State University Libraries</a>. Code is <a href="https://github.com/gvsulib/library-Status">available on Github</a>.</p>
</div> <!-- end span -->
</div> <!-- end line -->
</div><!-- End #cms-content -->
</div><!-- End #cms-body-table -->
</div><!-- End #cms-body-inner -->
</div><!-- end #cms-body -->
</div><!-- end #cms-body-wrapper -->
<?php include "resources/php/footer.php"; ?>
</body>
</html>