-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
340 lines (294 loc) · 14 KB
/
index.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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require("includes/session.php"); ?>
<?php require("includes/mainConnection.php"); ?>
<?php require("includes/logIn.php"); ?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="css/main1.css">
<script src="https://kit.fontawesome.com/f262395e7c.js" crossorigin="anonymous"></script>
<title>Swap-Book</title>
</head>
<body>
<div id="wrapper">
<div class="row h-100">
<div class="col col-12 col-xs-12 col-sm-12 col-md-12 col-lg-3 col-xl-2" id="navCol">
<nav class="navbar navbar-light purple lighten-4 mb-3 navbar-inverse navbar-expand-lg navbar-expand-xl mainNav h-100 align-items-start">
<button class="navbar-toggler alwaysShowHam purple darken-3 order-lg-2 align-top" type="button" data-toggle="collapse"
data-target="#hamList" id="MainHamMenu" aria-controls="navbarSupportedContent41" aria-expanded="false"
aria-label="Toggle navigation">
<span class="white-text"><i class="fas fa-bars fa-1x"></i></span>
</button>
<div class="collapse navbar-collapse align-top h-100 order-lg-1" id="hamList">
<ul class="navbar-nav mr-auto mainNavBarNav align-top h-100">
<li class="nav-item leftNavItem">
<a class="nav-link" id="HomeButton" href="#">Home</a>
</li>
<li class="nav-item leftNavItem">
<a class="nav-link" id="AboutUsButton" href="#">About us</a>
</li>
<li class="nav-item leftNavItem">
<a class="nav-link" id="ContactUs" href="#">Contact Us</a>
</li>
<?php if(!isset( $_SESSION["loggedIn"]) || ( isset( $_SESSION["loggedIn"]) && $_SESSION["loggedIn"] == false ))
{
?>
<li class="nav-item leftNavItem">
<a class="nav-link" id="RegisterButton" href="#">Register</a>
</li>
<?php } ?>
</ul>
</div>
</nav>
</div>
<div class="col col-xs-12 col-sm-12 col-md-12 col-lg-9 col-xl-10 mh-100">
<div class="sectionTop row">
<div class="col col-xs-12 col-sm-12 col-md-9 col-lg-9 col-xl-9 ">
<h1 class="float-left img-fluid" id="PageTitle">Swap Book</h1>
<img src="images/logo.png" class="float-right logoImg " alt="Home" />
</div>
<div class="col col-xs-12 col-sm-12 col-md-3 col-lg-3 col-xl-3 ">
<div class="dropdown float-right">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img src="images/userMenu.png" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" />
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#" id="UserDDRightHomeButton">Home</a>
<a class="dropdown-item" href="#" id="UserDDRightSwapButton">User Review</a>
<a class="dropdown-item" href="#" id="UserDDRightAccountButton">Account</a>
<a class="dropdown-item" href="#" id="UserDDRightSignOutButton">Sign Out</a>
<a class="dropdown-item" href="#" id="UserDDRightSignInButton">Sign In</a>
</div>
</div>
</div>
</div>
<div id="sectionMain" class="h-100">
<?php if(isset( $_SESSION["loggedIn"]) && $_SESSION["loggedIn"] == true )
{
?>
<form id="searchForm" action="<?php $_PHP_SELF ?>" method = "POST">
<div class="sectionTop row">
<div class="input-group md-form form-sm form-2 pl-0">
<input class="form-control my-0 py-1 red-border" type="text" name="searchText" id="searchText" placeholder="Search" aria-label="Search">
<div class="input-group-append">
<span class="input-group-text red lighten-3" id="basic-text1">
<button type="submit" id="doSearch" name="doSearch" value="yes" class="btn btn-primary"><i class="fas fa-search text-grey"
aria-hidden="true"></i></button>
</span>
</div>
</div>
</div>
<div class="row radio">
<div class="col">
<label class="radio-inline">
<input type="radio" name="type" id="Radios1" value="1">
New
</label>
</div>
<div class="col">
<label class="radio-inline">
<input type="radio" name="type" id="Radios2" value="2">
Used
</label>
</div>
<div class="col">
<label class="radio-inline">
<input type="radio" name="type" id="Radios3" value="3">
E-Copy
</label>
</div>
</div>
</form>
<div class="row">
<?php
if(isset($SearchResult))
{ ?>
<table class="SearchResultTable table table-light table-bordered table-striped">
<thead>
<tr>
<th scope="col" style="display: none">ID</th><th scope="col">Type</th><th scope="col">Title</th><th scope="col">Author</th><th scope="col">Edition</th><th scope="col">Year</th><th scope="col">Condition</th>
</tr>
</thead>
<tbody>
<?php
if(isset($SearchResult))
{
if ($SearchResult->num_rows > 0) {
while($row = $SearchResult->fetch_assoc()) {
echo "<tr>";
$typeText = "None";
if ($row["type"] == "1")
$typeText = "New";
else if ($row["type"] == "2")
$typeText = "Used";
else if ($row["type"] == "2")
$typeText = "E-Copy";
echo '<td style="display: none">' . $row["book_id"]. "</td><td>" .$typeText. "</td><td>" . $row["Title"]."</td><td>". $row["Author"]."</td><td>". $row["edition"]."</td><td>". $row["year"]."</td><td>". $row["condition"]. "</td>";
echo "</tr>";
}
}
else {
echo "no records";
}
}
?>
</tbody>
</table>
<?php
} ?>
</div>
<?php } ?>
</div>
<div id="sectionAboutUs" class="h-100">
<div class="row">
<p>
Swap Book website is for Wayne State University students to swap textbooks. This site allows students to list textbooks they no longer need to swap for textbooks they will need. The system will maintain a database of textbooks based on student listings, provide search functionality, have secure login, and be mobile responsive.
</p>
<p>
This site is free for all members (Wayne State students & faculties ONLY)
</p>
<p>
Privacy Policy: You must use a "wayne.edu" email to sign up for this site. You must be a member of the Swap book in order to search for the book you are looking for. Swap Book will keep your personal information private and protected from others.
</p>
</div>
</div>
<div id="sectionRegister" class="h-100">
<iframe src="register.html" style="border: 0px;" height="1100" width="100%"></iframe>
</div>
<div id="sectionContactUs" class="h-100">
<div class="row">
<iframe src="contact.html" style="border: 0px;" height="1100" width="100%"></iframe>
</div>
</div>
<div id="sectionSwaps" class="h-100">
<div class="row">
</div>
<?php if($reviewSuccesfull)
{
echo "<div class=\"row\" style=\"color: red\"><h3>Review has been send </h3></div>";
} ?>
<div class="row">
<h3>Add Review</h3>
</div>
<div class="row">
<form id="reviewForm" action="<?php $_PHP_SELF ?>" method = "POST">
<div class="form-group">
<label for="InputEmail1">Rating</label>
<div id="Rating" class="form-control" >
<span class="fa fa-star" id="NewRatingLevel1"></span>
<span class="fa fa-star" id="NewRatingLevel2"></span>
<span class="fa fa-star" id="NewRatingLevel3" ></span>
<span class="fa fa-star" id="NewRatingLevel4"></span>
<span class="fa fa-star" id="NewRatingLevel5"></span>
</div>
<label for="bookSelect">Book</label>
<select id="bookSelect" name="bookSelect" class="form-control" >
<?php
foreach ($allBooks as $book){
if(isset($book["book_id"]))
{
echo "<option value=\"".$book["book_id"]."\" >".$book["Title"]."</option>";
}
} ?>
</select>
<label for="userSelect" name="userSelect"></label>
<select id="userSelect" name="userSelect" class="form-control" >
<?php
foreach ($allUsers as $user){
echo "<option value=\"".$user["user_id"]."\" >".$user["username"]."</option>";
} ?>
</select>
<label for="reviewDescription">Description</label>
<textarea rows="4" cols="50" id="reviewDescription" name="reviewDescription" class="form-control" placeholder="Enter Your Text" >
</textarea>
<input type="hidden" id="hiddenRatingValue" name="hiddenRatingValue" />
<input type="hidden" id="hiddenUserID" value='<?php echo $_SESSION["user_id"] ?>' name="hiddenUserID" />
<button type="submit" id="doAddReview" name="doAddReview" value="yes" class="btn btn-primary">Submit Review</button>
</div>
</form>
</div>
</div>
<div id="sectionAccount" class="h-100">
<div class="row">
<!--change account page here -->
<iframe src="account.html" style="border: 0px;" height="1100" width="100%"></iframe>
</div>
</div>
<div id="sectionSignIn" class="h-100">
<div class="row">
<p>You are Signed Out</p>
</div>
<div class="sectionTop row">
<h2>Sign In</h2>
</div>
<div class="sectionTop row">
<form id="emailForm" action="<?php $_PHP_SELF ?>" method = "POST">
<div class="form-group">
<label for="InputEmail1">Email address</label>
<input type="email" id="InputEmail1" name="InputEmail1" />
<input type="Password" id="InputPassword1" name="InputPassword1" />
<small id="emailHelp" class="form-text text-muted"></small>
</div>
<button type="submit" class="btn btn-primary">Sign In</button>
</form>
</div>
<?php
if($LogInFailed )
{
echo "<p>Invalid username or password</p>";
}
?>
</div>
<div id="sectionSignOut" class="h-100">
<div class="row">
<form id="signOutForm" action="<?php $_PHP_SELF ?>" method = "POST">
<button type="submit" id="signOut" name="signOut" value="yes" class="btn btn-primary">Sign Out</button>
</form>
</div>
</div>
</div>
</div>
<div class="social">
<h5 class="FollowUsHead">Follow Us</h5>
<a href="#"><img src="images/social/fb.png" class="socialIcon"></a>
<a href="#"><img src="images/social/ig.png" class="socialIcon"></a>
<a href="#"><img src="images/social/twit.png" class="socialIcon"></a>
<a href="#"><img src="images/social/pin.png" class="socialIcon"></a>
<a href="#"><img src="images/social/yt.png" class="socialIcon"></a>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script type = "text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>
<?php if(isset($_SESSION["lastTab"]))
{ ?>
<script type = "text/javascript" >
var lastTab = "<?php echo $_SESSION["lastTab"] ?>";
<?php if(isset( $_SESSION["loggedIn"]) && $_SESSION["loggedIn"] == true )
{
?>
var signedIn = true;
<?php }
else {
?>
var signedIn = false;
<?php } ?>
console.log("lastTab: "+lastTab);
</script>
<?php } ?>
<script src="scripts/main.js"></script>
<script src="scripts/newRating.js"></script>
<?php require("includes/hideBasedOnSession.php"); ?>
</body>
</html>
<?php require("includes/endMainConnction.php"); ?>