@@ -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 | } |