@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $accessToken; |
15 | 15 | $newPositionStatus; |
16 | 16 | |
17 | - if ($result->num_rows > 0) |
|
17 | + if($result->num_rows > 0) |
|
18 | 18 | { |
19 | 19 | // output data of each row |
20 | 20 | while($row = $result->fetch_assoc()) |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | if(isset($_POST['color'])) |
80 | 80 | { |
81 | 81 | $color = $_POST['color']; |
82 | - switch ($color) { |
|
82 | + switch($color) { |
|
83 | 83 | case '8ABDB0': |
84 | 84 | $color = '8ABDB0'; |
85 | 85 | break; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | //Set View |
175 | 175 | if(isset($_GET['view'])) |
176 | 176 | { |
177 | - switch ($_GET['view']) { |
|
177 | + switch($_GET['view']) { |
|
178 | 178 | case 'comment': |
179 | 179 | $view = 'comment'; |
180 | 180 | break; |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | //Get Posts |
214 | 214 | else |
215 | 215 | { |
216 | - if($view=='comment') |
|
216 | + if($view == 'comment') |
|
217 | 217 | { |
218 | 218 | $url = "/v2/posts/location/discussed/"; |
219 | 219 | } |
220 | 220 | else |
221 | 221 | { |
222 | - if($view=='upVote') |
|
222 | + if($view == 'upVote') |
|
223 | 223 | { |
224 | 224 | $url = "/v2/posts/location/popular/"; |
225 | 225 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | |
238 | - for($i = 0; $i<$loops; $i++) { |
|
238 | + for($i = 0; $i < $loops; $i++) { |
|
239 | 239 | |
240 | 240 | if(isset($posts[$i])) { |
241 | 241 | $lastPostId = $posts[$i]['post_id']; |
@@ -253,24 +253,24 @@ discard block |
||
253 | 253 | $timediff_inHours = (string)$timediff->format('%h'); |
254 | 254 | $timediff_inDays = (string)$timediff->format('%d'); |
255 | 255 | $timediff_inMonth = (string)$timediff->format('%m'); |
256 | - if($timediff_inMonth!=0) { |
|
256 | + if($timediff_inMonth != 0) { |
|
257 | 257 | $timediff = $timediff_inMonth . "m"; |
258 | 258 | } |
259 | 259 | else |
260 | 260 | { |
261 | - if($timediff_inDays!=0) |
|
261 | + if($timediff_inDays != 0) |
|
262 | 262 | { |
263 | 263 | $timediff = $timediff_inDays . "d"; |
264 | 264 | } |
265 | 265 | else |
266 | 266 | { |
267 | - if($timediff_inHours!=0) |
|
267 | + if($timediff_inHours != 0) |
|
268 | 268 | { |
269 | 269 | $timediff = $timediff_inHours . "h"; |
270 | 270 | } |
271 | 271 | else |
272 | 272 | { |
273 | - if($timediff_inMinutes!=0) |
|
273 | + if($timediff_inMinutes != 0) |
|
274 | 274 | { |
275 | 275 | $timediff = $timediff_inMinutes . "m"; |
276 | 276 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | } |
284 | 284 | ?> |
285 | 285 | |
286 | - <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
|
286 | + <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"]; ?>;"> |
|
287 | 287 | <content> |
288 | 288 | <?php |
289 | 289 | if(isset($posts[$i]["image_url"])) { |
@@ -295,12 +295,12 @@ discard block |
||
295 | 295 | ?> |
296 | 296 | </content> |
297 | 297 | <aside> |
298 | - <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
298 | + <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
299 | 299 | <i class="fa fa-angle-up fa-3x"></i> |
300 | 300 | </a> |
301 | 301 | <br /> |
302 | - <?php echo $posts[$i]["vote_count"];?><br /> |
|
303 | - <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
302 | + <?php echo $posts[$i]["vote_count"]; ?><br /> |
|
303 | + <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
304 | 304 | <i class="fa fa-angle-down fa-3x"></i> |
305 | 305 | </a> |
306 | 306 | </aside> |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | <td class="time"> |
312 | 312 | <span data-tooltip="Time"> |
313 | 313 | <i class="fa fa-clock-o"></i> |
314 | - <?php echo $timediff;?> |
|
314 | + <?php echo $timediff; ?> |
|
315 | 315 | </span> |
316 | 316 | </td> |
317 | 317 | <td class="comments"> |
318 | 318 | <?php if($showCommentIcon) {?> |
319 | 319 | <span data-tooltip="Comments"> |
320 | - <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
320 | + <a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
321 | 321 | <i class="fa fa-commenting-o"></i> |
322 | 322 | <?php if(array_key_exists("child_count", $posts[$i])) { |
323 | 323 | echo $posts[$i]["child_count"]; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | <td class="distance"> |
331 | 331 | <span data-tooltip="Distance"> |
332 | 332 | <i class="fa fa-map-marker"></i> |
333 | - <?php echo $posts[$i]["distance"];?> km |
|
333 | + <?php echo $posts[$i]["distance"]; ?> km |
|
334 | 334 | </span> |
335 | 335 | </td> |
336 | 336 | </tr> |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
378 | 378 | <h2>Comment on Jodel</h2> |
379 | 379 | <form method="POST"> |
380 | - <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
|
380 | + <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" /> |
|
381 | 381 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
382 | 382 | <br /> |
383 | 383 | <input type="submit" value="SEND" /> |
@@ -414,13 +414,13 @@ discard block |
||
414 | 414 | <div class="col-sm-12"> |
415 | 415 | <div class="row"> |
416 | 416 | <div class="col-sm-3"> |
417 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
417 | + <a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
418 | 418 | </div> |
419 | 419 | <div class="col-sm-3"> |
420 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
420 | + <a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
421 | 421 | </div> |
422 | 422 | <div class="col-sm-3"> |
423 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
423 | + <a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
424 | 424 | </div> |
425 | 425 | <div class="col-sm-3"> |
426 | 426 | <nav> |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | //createAccount(); |
32 | 32 | |
33 | 33 | //Set Location |
34 | - if(isset($_GET['city'])) { |
|
34 | + if(isset($_GET['city'])) |
|
35 | + { |
|
35 | 36 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
36 | 37 | $result = Requests::post($url); |
37 | 38 | if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
@@ -52,11 +53,14 @@ discard block |
||
52 | 53 | } |
53 | 54 | |
54 | 55 | //Vote |
55 | - if(isset($_GET['vote']) && isset($_GET['postID'])) { |
|
56 | - if($_GET['vote'] == "up") { |
|
56 | + if(isset($_GET['vote']) && isset($_GET['postID'])) |
|
57 | + { |
|
58 | + if($_GET['vote'] == "up") |
|
59 | + { |
|
57 | 60 | $accountCreator = new Upvote(); |
58 | 61 | } |
59 | - else if($_GET['vote'] == "down") { |
|
62 | + else if($_GET['vote'] == "down") |
|
63 | + { |
|
60 | 64 | $accountCreator = new Downvote(); |
61 | 65 | } |
62 | 66 | $accountCreator->setAccessToken($accessToken); |
@@ -68,7 +72,8 @@ discard block |
||
68 | 72 | |
69 | 73 | |
70 | 74 | //SendJodel |
71 | - if(isset($_POST['message'])) { |
|
75 | + if(isset($_POST['message'])) |
|
76 | + { |
|
72 | 77 | $accountCreator = new SendJodel(); |
73 | 78 | |
74 | 79 | if(isset($_POST['ancestor'])) |
@@ -79,7 +84,8 @@ discard block |
||
79 | 84 | if(isset($_POST['color'])) |
80 | 85 | { |
81 | 86 | $color = $_POST['color']; |
82 | - switch ($color) { |
|
87 | + switch ($color) |
|
88 | + { |
|
83 | 89 | case '8ABDB0': |
84 | 90 | $color = '8ABDB0'; |
85 | 91 | break; |
@@ -174,7 +180,8 @@ discard block |
||
174 | 180 | //Set View |
175 | 181 | if(isset($_GET['view'])) |
176 | 182 | { |
177 | - switch ($_GET['view']) { |
|
183 | + switch ($_GET['view']) |
|
184 | + { |
|
178 | 185 | case 'comment': |
179 | 186 | $view = 'comment'; |
180 | 187 | break; |
@@ -201,13 +208,17 @@ discard block |
||
201 | 208 | $data = $accountCreator->execute(); |
202 | 209 | |
203 | 210 | $posts[0] = $data; |
204 | - if(isset($data['children'])) { |
|
205 | - foreach($data['children'] as $child) { |
|
211 | + if(isset($data['children'])) |
|
212 | + { |
|
213 | + foreach($data['children'] as $child) |
|
214 | + { |
|
206 | 215 | array_push($posts, $child); |
207 | 216 | } |
208 | 217 | $loops = $data['child_count'] + 1; |
209 | 218 | } |
210 | - else $loops = 1; |
|
219 | + else { |
|
220 | + $loops = 1; |
|
221 | + } |
|
211 | 222 | $showCommentIcon = FALSE; |
212 | 223 | } |
213 | 224 | //Get Posts |
@@ -235,9 +246,11 @@ discard block |
||
235 | 246 | } |
236 | 247 | |
237 | 248 | |
238 | - for($i = 0; $i<$loops; $i++) { |
|
249 | + for($i = 0; $i<$loops; $i++) |
|
250 | + { |
|
239 | 251 | |
240 | - if(isset($posts[$i])) { |
|
252 | + if(isset($posts[$i])) |
|
253 | + { |
|
241 | 254 | $lastPostId = $posts[$i]['post_id']; |
242 | 255 | |
243 | 256 | |
@@ -253,7 +266,8 @@ discard block |
||
253 | 266 | $timediff_inHours = (string)$timediff->format('%h'); |
254 | 267 | $timediff_inDays = (string)$timediff->format('%d'); |
255 | 268 | $timediff_inMonth = (string)$timediff->format('%m'); |
256 | - if($timediff_inMonth!=0) { |
|
269 | + if($timediff_inMonth!=0) |
|
270 | + { |
|
257 | 271 | $timediff = $timediff_inMonth . "m"; |
258 | 272 | } |
259 | 273 | else |
@@ -286,10 +300,12 @@ discard block |
||
286 | 300 | <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
287 | 301 | <content> |
288 | 302 | <?php |
289 | - if(isset($posts[$i]["image_url"])) { |
|
303 | + if(isset($posts[$i]["image_url"])) |
|
304 | + { |
|
290 | 305 | echo '<img src="' . $posts[$i]["image_url"] . '">'; |
291 | 306 | } |
292 | - else { |
|
307 | + else |
|
308 | + { |
|
293 | 309 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($posts[$i]["message"]))); |
294 | 310 | } |
295 | 311 | ?> |
@@ -315,13 +331,19 @@ discard block |
||
315 | 331 | </span> |
316 | 332 | </td> |
317 | 333 | <td class="comments"> |
318 | - <?php if($showCommentIcon) {?> |
|
334 | + <?php if($showCommentIcon) |
|
335 | +{ |
|
336 | +?> |
|
319 | 337 | <span data-tooltip="Comments"> |
320 | 338 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $posts[$i]["post_id"];?>"> |
321 | 339 | <i class="fa fa-commenting-o"></i> |
322 | - <?php if(array_key_exists("child_count", $posts[$i])) { |
|
340 | + <?php if(array_key_exists("child_count", $posts[$i])) |
|
341 | +{ |
|
323 | 342 | echo $posts[$i]["child_count"]; |
324 | - } else echo "0"; |
|
343 | + } |
|
344 | + else { |
|
345 | + echo "0"; |
|
346 | + } |
|
325 | 347 | ?> |
326 | 348 | </a> |
327 | 349 | </span> |
@@ -345,7 +367,9 @@ discard block |
||
345 | 367 | |
346 | 368 | </content> |
347 | 369 | |
348 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
370 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
371 | +{ |
|
372 | +?> |
|
349 | 373 | <p id="loading"> |
350 | 374 | Loading… |
351 | 375 | </p> |
@@ -358,7 +382,14 @@ discard block |
||
358 | 382 | <div> |
359 | 383 | <h2>Position</h2> |
360 | 384 | <form method="get"> |
361 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; else echo htmlspecialchars($posts[0]["location"]["name"]); ?>" required> |
|
385 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
386 | +{ |
|
387 | + echo $newPositionStatus; |
|
388 | +} |
|
389 | +else { |
|
390 | + echo htmlspecialchars($posts[0]["location"]["name"]); |
|
391 | +} |
|
392 | +?>" required> |
|
362 | 393 | |
363 | 394 | <input type="submit" value="Set Location" /> |
364 | 395 | </form> |
@@ -374,7 +405,9 @@ discard block |
||
374 | 405 | |
375 | 406 | <article> |
376 | 407 | <div> |
377 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
408 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
409 | +{ |
|
410 | +?> |
|
378 | 411 | <h2>Comment on Jodel</h2> |
379 | 412 | <form method="POST"> |
380 | 413 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
@@ -382,7 +415,10 @@ discard block |
||
382 | 415 | <br /> |
383 | 416 | <input type="submit" value="SEND" /> |
384 | 417 | </form> |
385 | - <?php } else { ?> |
|
418 | + <?php } |
|
419 | +else |
|
420 | +{ |
|
421 | +?> |
|
386 | 422 | <h2>New Jodel</h2> |
387 | 423 | <form method="POST"> |
388 | 424 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -414,13 +450,25 @@ discard block |
||
414 | 450 | <div class="col-sm-12"> |
415 | 451 | <div class="row"> |
416 | 452 | <div class="col-sm-3"> |
417 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
453 | + <a href="index.php" <?php if($view=='time') |
|
454 | +{ |
|
455 | + echo 'class="active"'; |
|
456 | +} |
|
457 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
418 | 458 | </div> |
419 | 459 | <div class="col-sm-3"> |
420 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
460 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
461 | +{ |
|
462 | + echo 'class="active"'; |
|
463 | +} |
|
464 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
421 | 465 | </div> |
422 | 466 | <div class="col-sm-3"> |
423 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
467 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
468 | +{ |
|
469 | + echo 'class="active"'; |
|
470 | +} |
|
471 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
424 | 472 | </div> |
425 | 473 | <div class="col-sm-3"> |
426 | 474 | <nav> |
@@ -452,7 +500,9 @@ discard block |
||
452 | 500 | } |
453 | 501 | |
454 | 502 | |
455 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
503 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
504 | +{ |
|
505 | +?> |
|
456 | 506 | $(document).ready(function() { |
457 | 507 | var win = $(window); |
458 | 508 | var lastPostId = "<?php echo $lastPostId; ?>"; |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class SendJodel extends AbstractRequest { |
4 | - public $location; |
|
5 | - public $ancestor = ""; |
|
6 | - public $color = ""; |
|
4 | + public $location; |
|
5 | + public $ancestor = ""; |
|
6 | + public $color = ""; |
|
7 | 7 | |
8 | - function getApiEndPoint() |
|
9 | - { |
|
10 | - return '/v3/posts/'; |
|
11 | - } |
|
8 | + function getApiEndPoint() |
|
9 | + { |
|
10 | + return '/v3/posts/'; |
|
11 | + } |
|
12 | 12 | |
13 | - function getPayload() |
|
14 | - { |
|
15 | - return array( |
|
13 | + function getPayload() |
|
14 | + { |
|
15 | + return array( |
|
16 | 16 | "ancestor" => $this->ancestor, |
17 | 17 | "color" => $this->color, |
18 | - "location" => $this->location->toArray(), |
|
19 | - "message" => $_POST['message'], |
|
20 | - ); |
|
21 | - } |
|
22 | - function getMethod() |
|
23 | - { |
|
24 | - return 'POST'; |
|
25 | - } |
|
18 | + "location" => $this->location->toArray(), |
|
19 | + "message" => $_POST['message'], |
|
20 | + ); |
|
21 | + } |
|
22 | + function getMethod() |
|
23 | + { |
|
24 | + return 'POST'; |
|
25 | + } |
|
26 | 26 | } |