@@ -57,7 +57,8 @@ discard block |
||
| 57 | 57 | //Set View |
| 58 | 58 | if(isset($_GET['view'])) |
| 59 | 59 | { |
| 60 | - switch ($_GET['view']) { |
|
| 60 | + switch ($_GET['view']) |
|
| 61 | + { |
|
| 61 | 62 | case 'comment': |
| 62 | 63 | $view = 'comment'; |
| 63 | 64 | break; |
@@ -219,7 +220,8 @@ discard block |
||
| 219 | 220 | |
| 220 | 221 | $posts[0] = $data; |
| 221 | 222 | |
| 222 | - if(array_key_exists('children', $data)) { |
|
| 223 | + if(array_key_exists('children', $data)) |
|
| 224 | + { |
|
| 223 | 225 | foreach($data['children'] as $key => $child) |
| 224 | 226 | { |
| 225 | 227 | |
@@ -357,7 +359,11 @@ discard block |
||
| 357 | 359 | |
| 358 | 360 | <div id="location_mobile" class="hidden-sm-up"> |
| 359 | 361 | <form method="get"> |
| 360 | - <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
| 362 | + <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
| 363 | +{ |
|
| 364 | + echo $newPositionStatus; |
|
| 365 | +} |
|
| 366 | +?>" required> |
|
| 361 | 367 | |
| 362 | 368 | <input type="submit" id="submit_mobile" class="fa" value="" /> |
| 363 | 369 | </form> |
@@ -384,7 +390,9 @@ discard block |
||
| 384 | 390 | |
| 385 | 391 | </content> |
| 386 | 392 | |
| 387 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 393 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
| 394 | +{ |
|
| 395 | +?> |
|
| 388 | 396 | <p id="loading"> |
| 389 | 397 | Loading… |
| 390 | 398 | </p> |
@@ -397,7 +405,11 @@ discard block |
||
| 397 | 405 | <div> |
| 398 | 406 | <h2>Position / Hashtag</h2> |
| 399 | 407 | <form method="get"> |
| 400 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
| 408 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
| 409 | +{ |
|
| 410 | + echo $newPositionStatus; |
|
| 411 | +} |
|
| 412 | +?>" required> |
|
| 401 | 413 | <label>try: #jhj</label><br> |
| 402 | 414 | <input type="submit" value="Set Location" /> |
| 403 | 415 | </form> |
@@ -413,7 +425,9 @@ discard block |
||
| 413 | 425 | |
| 414 | 426 | <article> |
| 415 | 427 | <div> |
| 416 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
| 428 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
| 429 | +{ |
|
| 430 | +?> |
|
| 417 | 431 | <h2>Comment on Jodel</h2> |
| 418 | 432 | <form method="POST"> |
| 419 | 433 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
@@ -421,7 +435,10 @@ discard block |
||
| 421 | 435 | <br /> |
| 422 | 436 | <input type="submit" value="SEND" /> |
| 423 | 437 | </form> |
| 424 | - <?php } else { ?> |
|
| 438 | + <?php } |
|
| 439 | +else |
|
| 440 | +{ |
|
| 441 | +?> |
|
| 425 | 442 | <h2>New Jodel</h2> |
| 426 | 443 | <form method="POST"> |
| 427 | 444 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -453,13 +470,25 @@ discard block |
||
| 453 | 470 | <div class="col-xs-12"> |
| 454 | 471 | <div class="row"> |
| 455 | 472 | <div class="col-xs-3"> |
| 456 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 473 | + <a href="index.php" <?php if($view=='time') |
|
| 474 | +{ |
|
| 475 | + echo 'class="active"'; |
|
| 476 | +} |
|
| 477 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 457 | 478 | </div> |
| 458 | 479 | <div class="col-xs-3"> |
| 459 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 480 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
| 481 | +{ |
|
| 482 | + echo 'class="active"'; |
|
| 483 | +} |
|
| 484 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 460 | 485 | </div> |
| 461 | 486 | <div class="col-xs-3"> |
| 462 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 487 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
| 488 | +{ |
|
| 489 | + echo 'class="active"'; |
|
| 490 | +} |
|
| 491 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 463 | 492 | </div> |
| 464 | 493 | <div class="col-xs-3"> |
| 465 | 494 | <nav> |
@@ -500,7 +529,9 @@ discard block |
||
| 500 | 529 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
| 501 | 530 | } |
| 502 | 531 | |
| 503 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 532 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
| 533 | +{ |
|
| 534 | +?> |
|
| 504 | 535 | |
| 505 | 536 | |
| 506 | 537 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | if(substr($_GET['city'], 0, 1) === '#') |
| 84 | 84 | { |
| 85 | 85 | return htmlspecialchars($_GET['city']) . " " . $cityName; |
| 86 | - } |
|
| 86 | + } |
|
| 87 | 87 | else |
| 88 | 88 | { |
| 89 | 89 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
@@ -187,7 +187,8 @@ discard block |
||
| 187 | 187 | if(isset($_POST['color'])) |
| 188 | 188 | { |
| 189 | 189 | $color = $_POST['color']; |
| 190 | - switch ($color) { |
|
| 190 | + switch ($color) |
|
| 191 | + { |
|
| 191 | 192 | case '8ABDB0': |
| 192 | 193 | $color = '8ABDB0'; |
| 193 | 194 | break; |
@@ -261,7 +262,8 @@ discard block |
||
| 261 | 262 | if ($result->num_rows > 0) |
| 262 | 263 | { |
| 263 | 264 | // output data of each row |
| 264 | - while($row = $result->fetch_assoc()) { |
|
| 265 | + while($row = $result->fetch_assoc()) |
|
| 266 | + { |
|
| 265 | 267 | //$access_token = $row["access_token"]; |
| 266 | 268 | $expiration_date = $row["expiration_date"]; |
| 267 | 269 | $deviceUid = $row["device_uid"]; |
@@ -273,7 +275,8 @@ discard block |
||
| 273 | 275 | echo '0 results'; |
| 274 | 276 | } |
| 275 | 277 | |
| 276 | - if($expiration_date <= time()) { |
|
| 278 | + if($expiration_date <= time()) |
|
| 279 | + { |
|
| 277 | 280 | $accountCreator = new CreateUser(); |
| 278 | 281 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
| 279 | 282 | $accountCreator->setDeviceUid($deviceUid); |
@@ -290,7 +293,8 @@ discard block |
||
| 290 | 293 | expiration_date='" . $expiration_date . "' |
| 291 | 294 | WHERE device_uid='" . $device_uid . "'"); |
| 292 | 295 | |
| 293 | - if($result === false){ |
|
| 296 | + if($result === false) |
|
| 297 | + { |
|
| 294 | 298 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 295 | 299 | } |
| 296 | 300 | } |
@@ -306,7 +310,8 @@ discard block |
||
| 306 | 310 | if ($result->num_rows > 0) |
| 307 | 311 | { |
| 308 | 312 | // output data of each row |
| 309 | - while($row = $result->fetch_assoc()) { |
|
| 313 | + while($row = $result->fetch_assoc()) |
|
| 314 | + { |
|
| 310 | 315 | //$access_token = $row["access_token"]; |
| 311 | 316 | $expiration_date = $row["expiration_date"]; |
| 312 | 317 | $deviceUid = $row["device_uid"]; |
@@ -318,7 +323,8 @@ discard block |
||
| 318 | 323 | echo '0 results'; |
| 319 | 324 | } |
| 320 | 325 | |
| 321 | - if($expiration_date <= time()) { |
|
| 326 | + if($expiration_date <= time()) |
|
| 327 | + { |
|
| 322 | 328 | $accountCreator = new CreateUser(); |
| 323 | 329 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
| 324 | 330 | $accountCreator->setDeviceUid($deviceUid); |
@@ -335,7 +341,8 @@ discard block |
||
| 335 | 341 | expiration_date='" . $expiration_date . "' |
| 336 | 342 | WHERE device_uid='" . $device_uid . "'"); |
| 337 | 343 | |
| 338 | - if($result === false){ |
|
| 344 | + if($result === false) |
|
| 345 | + { |
|
| 339 | 346 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 340 | 347 | } |
| 341 | 348 | } |
@@ -353,7 +360,8 @@ discard block |
||
| 353 | 360 | if ($result->num_rows > 0) |
| 354 | 361 | { |
| 355 | 362 | // output data of each row |
| 356 | - while($row = $result->fetch_assoc()) { |
|
| 363 | + while($row = $result->fetch_assoc()) |
|
| 364 | + { |
|
| 357 | 365 | //$access_token = $row["access_token"]; |
| 358 | 366 | $expiration_date = $row["expiration_date"]; |
| 359 | 367 | $deviceUid = $row["device_uid"]; |
@@ -365,7 +373,8 @@ discard block |
||
| 365 | 373 | echo '0 results'; |
| 366 | 374 | } |
| 367 | 375 | |
| 368 | - if($expiration_date <= time()) { |
|
| 376 | + if($expiration_date <= time()) |
|
| 377 | + { |
|
| 369 | 378 | $accountCreator = new CreateUser(); |
| 370 | 379 | $accountCreator->setAccessToken($access_token); |
| 371 | 380 | $accountCreator->setDeviceUid($deviceUid); |
@@ -382,7 +391,8 @@ discard block |
||
| 382 | 391 | expiration_date='" . $expiration_date . "' |
| 383 | 392 | WHERE device_uid='" . $device_uid . "'"); |
| 384 | 393 | |
| 385 | - if($result === false){ |
|
| 394 | + if($result === false) |
|
| 395 | + { |
|
| 386 | 396 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 387 | 397 | } |
| 388 | 398 | } |
@@ -538,14 +548,16 @@ discard block |
||
| 538 | 548 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 539 | 549 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
| 540 | 550 | |
| 541 | - if($result === false){ |
|
| 551 | + if($result === false) |
|
| 552 | + { |
|
| 542 | 553 | $error = db_error(); |
| 543 | 554 | echo $error; |
| 544 | 555 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
| 545 | 556 | } |
| 546 | 557 | } |
| 547 | 558 | |
| 548 | -function registerAccount(Location $location) { |
|
| 559 | +function registerAccount(Location $location) |
|
| 560 | +{ |
|
| 549 | 561 | $accountCreator = new CreateUser(); |
| 550 | 562 | $accountCreator->setLocation($location); |
| 551 | 563 | $data = $accountCreator->execute(); |
@@ -570,7 +582,8 @@ discard block |
||
| 570 | 582 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 571 | 583 | |
| 572 | 584 | $success = TRUE; |
| 573 | - if($result === false){ |
|
| 585 | + if($result === false) |
|
| 586 | + { |
|
| 574 | 587 | $error = db_error(); |
| 575 | 588 | echo $error; |
| 576 | 589 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -581,7 +594,7 @@ discard block |
||
| 581 | 594 | } |
| 582 | 595 | |
| 583 | 596 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
| 584 | -{ |
|
| 597 | +{ |
|
| 585 | 598 | $accountCreator = new GetPosts(); |
| 586 | 599 | $accountCreator->setLastPostId($lastPostId); |
| 587 | 600 | $accountCreator->setAccessToken($accessToken); |
@@ -670,7 +683,8 @@ discard block |
||
| 670 | 683 | } |
| 671 | 684 | |
| 672 | 685 | function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE) |
| 673 | -{ //ToDO |
|
| 686 | +{ |
|
| 687 | +//ToDO |
|
| 674 | 688 | //Replace # with link |
| 675 | 689 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
| 676 | 690 | |
@@ -726,7 +740,8 @@ discard block |
||
| 726 | 740 | |
| 727 | 741 | echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
| 728 | 742 | } |
| 729 | - else { |
|
| 743 | + else |
|
| 744 | + { |
|
| 730 | 745 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
| 731 | 746 | } |
| 732 | 747 | ?> |
@@ -734,11 +749,13 @@ discard block |
||
| 734 | 749 | <aside> |
| 735 | 750 | <?php |
| 736 | 751 | if($isDetailedView) |
| 737 | - {?> |
|
| 752 | + { |
|
| 753 | +?> |
|
| 738 | 754 | <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
| 739 | 755 | <?php } |
| 740 | - else |
|
| 741 | - {?> |
|
| 756 | +else |
|
| 757 | + { |
|
| 758 | +?> |
|
| 742 | 759 | <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
| 743 | 760 | <?php } ?> |
| 744 | 761 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -747,11 +764,13 @@ discard block |
||
| 747 | 764 | <?php echo $post["vote_count"];?><br /> |
| 748 | 765 | <?php |
| 749 | 766 | if($isDetailedView) |
| 750 | - {?> |
|
| 767 | + { |
|
| 768 | +?> |
|
| 751 | 769 | <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
| 752 | 770 | <?php } |
| 753 | - else |
|
| 754 | - {?> |
|
| 771 | +else |
|
| 772 | + { |
|
| 773 | +?> |
|
| 755 | 774 | <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
| 756 | 775 | <?php } ?> |
| 757 | 776 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -769,13 +788,19 @@ discard block |
||
| 769 | 788 | </span> |
| 770 | 789 | </td> |
| 771 | 790 | <td class="comments"> |
| 772 | - <?php if(!$isDetailedView) {?> |
|
| 791 | + <?php if(!$isDetailedView) |
|
| 792 | +{ |
|
| 793 | +?> |
|
| 773 | 794 | <span data-tooltip="Comments"> |
| 774 | 795 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
| 775 | 796 | <i class="fa fa-commenting-o"></i> |
| 776 | - <?php if(array_key_exists("child_count", $post)) { |
|
| 797 | + <?php if(array_key_exists("child_count", $post)) |
|
| 798 | +{ |
|
| 777 | 799 | echo $post["child_count"]; |
| 778 | - } else echo "0"; |
|
| 800 | + } |
|
| 801 | + else { |
|
| 802 | + echo "0"; |
|
| 803 | + } |
|
| 779 | 804 | ?> |
| 780 | 805 | </a> |
| 781 | 806 | </span> |