-
Notifications
You must be signed in to change notification settings - Fork 4
/
reviewgame.php
313 lines (295 loc) · 14.7 KB
/
reviewgame.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Review Game</title>
<!--style.css, favcon, bootstrap-->
<link href="style.css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<!--collapsable navbar with default design-->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
</div>
</div>
</nav>
<?php
include("db/dbconnection.php");
//make a password enter field
$gameName = $_GET['gameName'];
if (isset($_POST['Password'])) {
$password = $_POST['Password'];
} else {
$password = "";
}
//if we got the correct password, then allow us to edit. if not, then tell the user password was incorrect or to input a password!
if ($password == $reviewPassword) {
echo '
<p align="center" style="margin-top: 10px">
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#approveGame" data-name="approveGame">Approve</button>
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#denyGame" data-name="denyGame">Deny</button>
</p> ';
} elseif ($password != "") {
echo '<form align="center" method="POST" action="reviewgame.php?gameName='.$gameName.'">
Password: <input type="password" name="Password"></input>
<input type="submit" name="submit" value="Submit"></input>
</form><p style="color:red" align="center">Password was incorrect!</p>';
} else {
echo '<form align="center" method="POST" action="reviewgame.php?gameName='.$gameName.'">
Password: <input type="password" name="Password"></input>
<input type="submit" name="submit" value="Submit"></input>
</form> ';
}
?>
<?php
//now find the gamename within the database...
$gameName = $_GET["gameName"];
$recreationalGames = array();
$informationalGames = array();
$educationalGames = array();
//query through each table
$queryRecreational = "SELECT * FROM recreational_games";
$queryInformational = "SELECT * FROM informational_games";
$queryEducational = "SELECT * FROM educational_games";
$resultRecreational = mysqli_query($link, $queryRecreational);
$resultInformational = mysqli_query($link, $queryInformational);
$resultEducational = mysqli_query($link, $queryEducational);
/* iterate through games within the game type (recreational,informational,educational) */
while ($row = mysqli_fetch_array($resultRecreational)) {
//if the search result contained a string from a Game Name row, not case-sensitive
if (strtolower($row['Game_Name']) == strtolower($gameName)) {
$gameName = $row['Game_Name'];
$authorName = $row['Author_Name'];
$authorEmail = $row['Author_Email'];
$gameIcon = $row['icon'];
$game = $row['game'];
$gameDescription = $row['Game_Description'];
$gameInstructions = $row['Game_Instructions'];
$gameType = "Recreational";
if (strpos(strtolower($game), "sb2") !== false) {
//is a scratch game (sb2)
echo '
<div align="center">
<h1><b>'.$gameName.', created by '.$authorName.'</b></h1>
<object data="Scratch.swf" type="application/x-shockwave-flash" width="687" height="570">
<param name="allowscriptaccess" value="always">
<param name="flashvars" value="project='.$game.'">
</object>
<p><h3>Game Description<h3></p>
<h4>'.$gameDescription.'</h4>
<p><h3>Game Instructions<h3></p>
<h4>'.$gameInstructions.'</h4>
</div>';
} elseif (strpos(strtolower($game), "swf") !== false) {
//is a flash game (swf)
echo '
<div align="center">
<h1><b>'.$gameName.', created by '.$authorName.'</b></h1>
<object align="middle" width="800" height="580">
<param name="movie" value="'.$game.'">
<embed src="'.$game.'" width="1000" height="1000">
</embed>
</object>
<p><h3>Game Description<h3></p>
<h4>'.$gameDescription.'</h4>
<p><h3>Game Instructions<h3></p>
<h4>'.$gameInstructions.'</h4>
</div>';
} else {
//unknown game format
echo '<div align="center">
<h1><b>'.$gameName.', created by '.$authorName.'</b></h1>
<h3 style="color:red">Game contains an unknown file format!</h3>
<a href="'.$game.'"><h1>Download The Game</h1></a>
<p><h3>Game Description</h3></p>
<h4>'.$gameDescription.'</h4>
<p><h3>Game Instructions<h3></p>
<h4>'.$gameInstructions.'</h4>
</div>';
}
}
}
while ($row = mysqli_fetch_array($resultInformational)) {
//if the search result contained a string from a Game Name row, not case-sensitive
if (strtolower($row['Game_Name']) == strtolower($gameName)) {
$gameName = $row['Game_Name'];
$authorName = $row['Author_Name'];
$authorEmail = $row['Author_Email'];
$gameIcon = $row['icon'];
$game = $row['game'];
$gameDescription = $row['Game_Description'];
$gameType = "Informational";
if (strpos(strtolower($game), "sb2") !== false) {
//is a scratch game (sb2)
echo '
<div align="center">
<h1><b>'.$gameName.', created by '.$authorName.'</b></h1>
<object data="Scratch.swf" type="application/x-shockwave-flash" width="687" height="570">
<param name="allowscriptaccess" value="always">
<param name="flashvars" value="project='.$game.'">
</object>
<p><h3>Game Description<h3></p>
<h4>'.$gameDescription.'</h4>
<p><h3>Game Instructions<h3></p>
<h4>'.$gameInstructions.'</h4>
</div>';
} elseif (strpos(strtolower($game), "swf") !== false) {
//is a flash game (swf)
echo '
<div align="center">
<h1><b>'.$gameName.', created by '.$authorName.'</b></h1>
<object align="middle" width="800" height="580">
<param name="movie" value="'.$game.'">
<embed src="'.$game.'" width="1000" height="1000">
</embed>
</object>
<p><h3>Game Description<h3></p>
<h4>'.$gameDescription.'</h4>
<p><h3>Game Instructions<h3></p>
<h4>'.$gameInstructions.'</h4>
</div>';
} else {
//unknown game format
echo '<div align="center">
<h1><b>'.$gameName.', created by '.$authorName.'</b></h1>
<h3 style="color:red">Game contains an unknown file format!</h3>
<a href="'.$game.'"><h1>Download The Game</h1></a>
<p><h3>Game Description</h3></p>
<h4>'.$gameDescription.'</h4>
<p><h3>Game Instructions<h3></p>
<h4>'.$gameInstructions.'</h4>
</div>';
}
}
}
while ($row = mysqli_fetch_array($resultEducational)) {
//if the search result contained a string from a Game Name row, not case-sensitive
if (strtolower($row['Game_Name']) == strtolower($gameName)) {
$gameName = $row['Game_Name'];
$authorName = $row['Author_Name'];
$authorEmail = $row['Author_Email'];
$gameIcon = $row['icon'];
$game = $row['game'];
$gameDescription = $row['Game_Description'];
$gameType = "Educational";
if (strpos(strtolower($game), "sb2") !== false) {
//is a scratch game (sb2)
echo '
<div align="center">
<h1><b>'.$gameName.', created by '.$authorName.'</b></h1>
<object data="Scratch.swf" type="application/x-shockwave-flash" width="687" height="570">
<param name="allowscriptaccess" value="always">
<param name="flashvars" value="project='.$game.'">
</object>
<p><h3>Game Description<h3></p>
<h4>'.$gameDescription.'</h4>
<p><h3>Game Instructions<h3></p>
<h4>'.$gameInstructions.'</h4>
</div>';
} elseif (strpos(strtolower($game), "swf") !== false) {
//is a flash game (swf)
echo '
<div align="center">
<h1><b>'.$gameName.', created by '.$authorName.'</b></h1>
<object align="middle" width="800" height="580">
<param name="movie" value="'.$game.'">
<embed src="'.$game.'" width="1000" height="1000">
</embed>
</object>
<p><h3>Game Description<h3></p>
<h4>'.$gameDescription.'</h4>
<p><h3>Game Instructions<h3></p>
<h4>'.$gameInstructions.'</h4>
</div>';
} else {
//unknown game format
echo '<div align="center">
<h1><b>'.$gameName.', created by '.$authorName.'</b></h1>
<h3 style="color:red">Game contains an unknown file format!</h3>
<a href="'.$game.'"><h1>Download The Game</h1></a>
<p><h3>Game Description</h3></p>
<h4>'.$gameDescription.'</h4>
<p><h3>Game Instructions<h3></p>
<h4>'.$gameInstructions.'</h4>
</div>';
}
}
}
?>
<!--approveGame modal-->
<div class="modal fade" id="approveGame" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">Approve a Game</h4>
</div>
<div class="modal-body">
<form id="approveForm" action="db/review.php" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleTextarea">Why did you approve this game?*</label>
<textarea name="Reason" required class="form-control" id="exampleTextarea"></textarea>
</div>
<input type="hidden" value="<?php echo($gameName); ?>" name="Game_Name" />
<input type="hidden" value="<?php echo($authorEmail); ?>" name="Author_Email" />
<input type="hidden" value="<?php echo($gameType); ?>" name="Game_Type" />
<input type="hidden" value="true" name="Decision" />
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" form="approveForm" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
<!--denyGame modal-->
<div class="modal fade" id="denyGame" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">Deny a Game</h4>
</div>
<div class="modal-body">
<form id="denyForm" action="db/review.php" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="exampleTextarea">Why did you deny this game?*</label>
<textarea name="Reason" required class="form-control" id="exampleTextarea"></textarea>
</div>
<input type="hidden" value="<?php echo($gameName); ?>" name="Game_Name" />
<input type="hidden" value="<?php echo($authorEmail); ?>" name="Author_Email" />
<input type="hidden" value="<?php echo($gameType); ?>" name="Game_Type" />
<input type="hidden" value="false" name="Decision" />
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" form="denyForm" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
</body>
<!--jquery and bootstrap-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
//make the scrollbar start at the middle
window.scrollTo(
(document.body.offsetWidth - window.innerWidth) / 2,
(document.body.offsetHeight - window.innerHeight) / 2
);
</script>
</html>