@@ -61,7 +61,8 @@ discard block |
||
| 61 | 61 | //Set View |
| 62 | 62 | if(isset($_GET['view'])) |
| 63 | 63 | { |
| 64 | - switch ($_GET['view']) { |
|
| 64 | + switch ($_GET['view']) |
|
| 65 | + { |
|
| 65 | 66 | case 'comment': |
| 66 | 67 | $view = 'comment'; |
| 67 | 68 | break; |
@@ -81,7 +82,8 @@ discard block |
||
| 81 | 82 | } |
| 82 | 83 | |
| 83 | 84 | //Set Location |
| 84 | - if(isset($_GET['city'])) { |
|
| 85 | + if(isset($_GET['city'])) |
|
| 86 | + { |
|
| 85 | 87 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
| 86 | 88 | $result = Requests::post($url); |
| 87 | 89 | if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
@@ -165,7 +167,8 @@ discard block |
||
| 165 | 167 | if(isset($_POST['color'])) |
| 166 | 168 | { |
| 167 | 169 | $color = $_POST['color']; |
| 168 | - switch ($color) { |
|
| 170 | + switch ($color) |
|
| 171 | + { |
|
| 169 | 172 | case '8ABDB0': |
| 170 | 173 | $color = '8ABDB0'; |
| 171 | 174 | break; |
@@ -292,7 +295,11 @@ discard block |
||
| 292 | 295 | |
| 293 | 296 | <div id="location_mobile" class="hidden-sm-up"> |
| 294 | 297 | <form method="get"> |
| 295 | - <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
| 298 | + <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
| 299 | +{ |
|
| 300 | + echo $newPositionStatus; |
|
| 301 | +} |
|
| 302 | +?>" required> |
|
| 296 | 303 | |
| 297 | 304 | <input type="submit" id="submit_mobile" class="fa" value="" /> |
| 298 | 305 | </form> |
@@ -319,7 +326,8 @@ discard block |
||
| 319 | 326 | $data = $accountCreator->execute(); |
| 320 | 327 | |
| 321 | 328 | $posts[0] = $data; |
| 322 | - if(array_key_exists('children', $data)) { |
|
| 329 | + if(array_key_exists('children', $data)) |
|
| 330 | + { |
|
| 323 | 331 | foreach($data['children'] as $key => $child) |
| 324 | 332 | { |
| 325 | 333 | |
@@ -393,7 +401,9 @@ discard block |
||
| 393 | 401 | |
| 394 | 402 | </content> |
| 395 | 403 | |
| 396 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 404 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
| 405 | +{ |
|
| 406 | +?> |
|
| 397 | 407 | <p id="loading"> |
| 398 | 408 | Loading… |
| 399 | 409 | </p> |
@@ -406,7 +416,11 @@ discard block |
||
| 406 | 416 | <div> |
| 407 | 417 | <h2>Position</h2> |
| 408 | 418 | <form method="get"> |
| 409 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
| 419 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
| 420 | +{ |
|
| 421 | + echo $newPositionStatus; |
|
| 422 | +} |
|
| 423 | +?>" required> |
|
| 410 | 424 | |
| 411 | 425 | <input type="submit" value="Set Location" /> |
| 412 | 426 | </form> |
@@ -422,7 +436,9 @@ discard block |
||
| 422 | 436 | |
| 423 | 437 | <article> |
| 424 | 438 | <div> |
| 425 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
| 439 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
| 440 | +{ |
|
| 441 | +?> |
|
| 426 | 442 | <h2>Comment on Jodel</h2> |
| 427 | 443 | <form method="POST"> |
| 428 | 444 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
@@ -430,7 +446,10 @@ discard block |
||
| 430 | 446 | <br /> |
| 431 | 447 | <input type="submit" value="SEND" /> |
| 432 | 448 | </form> |
| 433 | - <?php } else { ?> |
|
| 449 | + <?php } |
|
| 450 | +else |
|
| 451 | +{ |
|
| 452 | +?> |
|
| 434 | 453 | <h2>New Jodel</h2> |
| 435 | 454 | <form method="POST"> |
| 436 | 455 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -462,13 +481,25 @@ discard block |
||
| 462 | 481 | <div class="col-xs-12"> |
| 463 | 482 | <div class="row"> |
| 464 | 483 | <div class="col-xs-3"> |
| 465 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 484 | + <a href="index.php" <?php if($view=='time') |
|
| 485 | +{ |
|
| 486 | + echo 'class="active"'; |
|
| 487 | +} |
|
| 488 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 466 | 489 | </div> |
| 467 | 490 | <div class="col-xs-3"> |
| 468 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 491 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
| 492 | +{ |
|
| 493 | + echo 'class="active"'; |
|
| 494 | +} |
|
| 495 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 469 | 496 | </div> |
| 470 | 497 | <div class="col-xs-3"> |
| 471 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 498 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
| 499 | +{ |
|
| 500 | + echo 'class="active"'; |
|
| 501 | +} |
|
| 502 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 472 | 503 | </div> |
| 473 | 504 | <div class="col-xs-3"> |
| 474 | 505 | <nav> |
@@ -511,7 +542,9 @@ discard block |
||
| 511 | 542 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
| 512 | 543 | } |
| 513 | 544 | |
| 514 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 545 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
| 546 | +{ |
|
| 547 | +?> |
|
| 515 | 548 | |
| 516 | 549 | |
| 517 | 550 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | abstract class AbstractRequest |
| 4 | -{ |
|
| 4 | +{ |
|
| 5 | 5 | const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
| 6 | 6 | const APIURL = 'https://api.go-tellm.com/api'; |
| 7 | 7 | const SECRET = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG'; |
@@ -19,7 +19,8 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | $this->payLoad = $this->getPayload(); |
| 21 | 21 | $device_uid = ''; |
| 22 | - if(isset($this->payLoad['device_uid'])) { |
|
| 22 | + if(isset($this->payLoad['device_uid'])) |
|
| 23 | + { |
|
| 23 | 24 | $device_uid = $this->payLoad['device_uid']; |
| 24 | 25 | } |
| 25 | 26 | |
@@ -28,7 +29,8 @@ discard block |
||
| 28 | 29 | $header = $this->getSignHeaders(); |
| 29 | 30 | $url = $this->getFullUrl(); |
| 30 | 31 | |
| 31 | - if ($this->getAccessToken()) { |
|
| 32 | + if ($this->getAccessToken()) |
|
| 33 | + { |
|
| 32 | 34 | $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
| 33 | 35 | } |
| 34 | 36 | //Comment out to debug the Request: |
@@ -45,7 +47,8 @@ discard block |
||
| 45 | 47 | 'proxy' => '186.103.169.165:8080', |
| 46 | 48 | );*/ |
| 47 | 49 | |
| 48 | - switch ($this->getMethod()) { |
|
| 50 | + switch ($this->getMethod()) |
|
| 51 | + { |
|
| 49 | 52 | case 'POST': |
| 50 | 53 | $result = Requests::post($url, $header, $this->payLoad); |
| 51 | 54 | break; |
@@ -63,7 +66,8 @@ discard block |
||
| 63 | 66 | $result = Requests::put($url, $header, $this->payLoad); |
| 64 | 67 | break; |
| 65 | 68 | } |
| 66 | - switch ($result->status_code) { |
|
| 69 | + switch ($result->status_code) |
|
| 70 | + { |
|
| 67 | 71 | case 200: |
| 68 | 72 | $result = json_decode($result->body, true); |
| 69 | 73 | break; |
@@ -114,10 +118,12 @@ discard block |
||
| 114 | 118 | */ |
| 115 | 119 | private function getSignHeaders() |
| 116 | 120 | { |
| 117 | - if($this->getAccessToken() == null) { |
|
| 121 | + if($this->getAccessToken() == null) |
|
| 122 | + { |
|
| 118 | 123 | $payload_accessToken = ""; |
| 119 | 124 | } |
| 120 | - else { |
|
| 125 | + else |
|
| 126 | + { |
|
| 121 | 127 | $payload_accessToken = $this->getAccessToken(); |
| 122 | 128 | } |
| 123 | 129 | |
@@ -45,7 +45,8 @@ discard block |
||
| 45 | 45 | if ($result->num_rows > 0) |
| 46 | 46 | { |
| 47 | 47 | // output data of each row |
| 48 | - while($row = $result->fetch_assoc()) { |
|
| 48 | + while($row = $result->fetch_assoc()) |
|
| 49 | + { |
|
| 49 | 50 | //$access_token = $row["access_token"]; |
| 50 | 51 | $expiration_date = $row["expiration_date"]; |
| 51 | 52 | $deviceUid = $row["device_uid"]; |
@@ -57,7 +58,8 @@ discard block |
||
| 57 | 58 | echo '0 results'; |
| 58 | 59 | } |
| 59 | 60 | |
| 60 | - if($expiration_date <= time()) { |
|
| 61 | + if($expiration_date <= time()) |
|
| 62 | + { |
|
| 61 | 63 | $accountCreator = new CreateUser(); |
| 62 | 64 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
| 63 | 65 | $accountCreator->setDeviceUid($deviceUid); |
@@ -74,7 +76,8 @@ discard block |
||
| 74 | 76 | expiration_date='" . $expiration_date . "' |
| 75 | 77 | WHERE device_uid='" . $device_uid . "'"); |
| 76 | 78 | |
| 77 | - if($result === false){ |
|
| 79 | + if($result === false) |
|
| 80 | + { |
|
| 78 | 81 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 79 | 82 | } |
| 80 | 83 | } |
@@ -90,7 +93,8 @@ discard block |
||
| 90 | 93 | if ($result->num_rows > 0) |
| 91 | 94 | { |
| 92 | 95 | // output data of each row |
| 93 | - while($row = $result->fetch_assoc()) { |
|
| 96 | + while($row = $result->fetch_assoc()) |
|
| 97 | + { |
|
| 94 | 98 | //$access_token = $row["access_token"]; |
| 95 | 99 | $expiration_date = $row["expiration_date"]; |
| 96 | 100 | $deviceUid = $row["device_uid"]; |
@@ -102,7 +106,8 @@ discard block |
||
| 102 | 106 | echo '0 results'; |
| 103 | 107 | } |
| 104 | 108 | |
| 105 | - if($expiration_date <= time()) { |
|
| 109 | + if($expiration_date <= time()) |
|
| 110 | + { |
|
| 106 | 111 | $accountCreator = new CreateUser(); |
| 107 | 112 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
| 108 | 113 | $accountCreator->setDeviceUid($deviceUid); |
@@ -119,7 +124,8 @@ discard block |
||
| 119 | 124 | expiration_date='" . $expiration_date . "' |
| 120 | 125 | WHERE device_uid='" . $device_uid . "'"); |
| 121 | 126 | |
| 122 | - if($result === false){ |
|
| 127 | + if($result === false) |
|
| 128 | + { |
|
| 123 | 129 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 124 | 130 | } |
| 125 | 131 | } |
@@ -137,7 +143,8 @@ discard block |
||
| 137 | 143 | if ($result->num_rows > 0) |
| 138 | 144 | { |
| 139 | 145 | // output data of each row |
| 140 | - while($row = $result->fetch_assoc()) { |
|
| 146 | + while($row = $result->fetch_assoc()) |
|
| 147 | + { |
|
| 141 | 148 | //$access_token = $row["access_token"]; |
| 142 | 149 | $expiration_date = $row["expiration_date"]; |
| 143 | 150 | $deviceUid = $row["device_uid"]; |
@@ -149,7 +156,8 @@ discard block |
||
| 149 | 156 | echo '0 results'; |
| 150 | 157 | } |
| 151 | 158 | |
| 152 | - if($expiration_date <= time()) { |
|
| 159 | + if($expiration_date <= time()) |
|
| 160 | + { |
|
| 153 | 161 | $accountCreator = new CreateUser(); |
| 154 | 162 | $accountCreator->setAccessToken($access_token); |
| 155 | 163 | $accountCreator->setDeviceUid($deviceUid); |
@@ -166,7 +174,8 @@ discard block |
||
| 166 | 174 | expiration_date='" . $expiration_date . "' |
| 167 | 175 | WHERE device_uid='" . $device_uid . "'"); |
| 168 | 176 | |
| 169 | - if($result === false){ |
|
| 177 | + if($result === false) |
|
| 178 | + { |
|
| 170 | 179 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 171 | 180 | } |
| 172 | 181 | } |
@@ -280,13 +289,15 @@ discard block |
||
| 280 | 289 | return $data["karma"]; |
| 281 | 290 | } |
| 282 | 291 | |
| 283 | -function addVoteWithPostIdToDeviceUid($postId, $device_uid) { |
|
| 292 | +function addVoteWithPostIdToDeviceUid($postId, $device_uid) |
|
| 293 | +{ |
|
| 284 | 294 | |
| 285 | 295 | $db = new DatabaseConnect(); |
| 286 | 296 | $result = $db->query("INSERT INTO votes (device_uid, postId) |
| 287 | 297 | VALUES ('" . $device_uid . "','" . $postId . "') "); |
| 288 | 298 | |
| 289 | - if($result === false){ |
|
| 299 | + if($result === false) |
|
| 300 | + { |
|
| 290 | 301 | $error = db_error(); |
| 291 | 302 | echo $error; |
| 292 | 303 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -294,7 +305,8 @@ discard block |
||
| 294 | 305 | |
| 295 | 306 | } |
| 296 | 307 | |
| 297 | -function registerAccount(Location $location) { |
|
| 308 | +function registerAccount(Location $location) |
|
| 309 | +{ |
|
| 298 | 310 | $accountCreator = new CreateUser(); |
| 299 | 311 | $accountCreator->setLocation($location); |
| 300 | 312 | $data = $accountCreator->execute(); |
@@ -319,7 +331,8 @@ discard block |
||
| 319 | 331 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 320 | 332 | |
| 321 | 333 | $success = TRUE; |
| 322 | - if($result === false){ |
|
| 334 | + if($result === false) |
|
| 335 | + { |
|
| 323 | 336 | $error = db_error(); |
| 324 | 337 | echo $error; |
| 325 | 338 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -330,7 +343,7 @@ discard block |
||
| 330 | 343 | } |
| 331 | 344 | |
| 332 | 345 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
| 333 | -{ |
|
| 346 | +{ |
|
| 334 | 347 | $accountCreator = new GetPosts(); |
| 335 | 348 | $accountCreator->setLastPostId($lastPostId); |
| 336 | 349 | $accountCreator->setAccessToken($accessToken); |
@@ -381,7 +394,8 @@ discard block |
||
| 381 | 394 | } |
| 382 | 395 | |
| 383 | 396 | function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE) |
| 384 | -{ //ToDO |
|
| 397 | +{ |
|
| 398 | +//ToDO |
|
| 385 | 399 | //Replace # with link |
| 386 | 400 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
| 387 | 401 | |
@@ -431,10 +445,12 @@ discard block |
||
| 431 | 445 | <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;"> |
| 432 | 446 | <content> |
| 433 | 447 | <?php |
| 434 | - if(isset($post["image_url"])) { |
|
| 448 | + if(isset($post["image_url"])) |
|
| 449 | + { |
|
| 435 | 450 | echo '<img src="' . $post["image_url"] . '">'; |
| 436 | 451 | } |
| 437 | - else { |
|
| 452 | + else |
|
| 453 | + { |
|
| 438 | 454 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post["message"]))); |
| 439 | 455 | } |
| 440 | 456 | ?> |
@@ -442,11 +458,13 @@ discard block |
||
| 442 | 458 | <aside> |
| 443 | 459 | <?php |
| 444 | 460 | if($isDetailedView) |
| 445 | - {?> |
|
| 461 | + { |
|
| 462 | +?> |
|
| 446 | 463 | <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>"> |
| 447 | 464 | <?php } |
| 448 | - else |
|
| 449 | - {?> |
|
| 465 | +else |
|
| 466 | + { |
|
| 467 | +?> |
|
| 450 | 468 | <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>"> |
| 451 | 469 | <?php } ?> |
| 452 | 470 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -455,11 +473,13 @@ discard block |
||
| 455 | 473 | <?php echo $post["vote_count"];?><br /> |
| 456 | 474 | <?php |
| 457 | 475 | if($isDetailedView) |
| 458 | - {?> |
|
| 476 | + { |
|
| 477 | +?> |
|
| 459 | 478 | <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>"> |
| 460 | 479 | <?php } |
| 461 | - else |
|
| 462 | - {?> |
|
| 480 | +else |
|
| 481 | + { |
|
| 482 | +?> |
|
| 463 | 483 | <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>"> |
| 464 | 484 | <?php } ?> |
| 465 | 485 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -477,13 +497,19 @@ discard block |
||
| 477 | 497 | </span> |
| 478 | 498 | </td> |
| 479 | 499 | <td class="comments"> |
| 480 | - <?php if(!$isDetailedView) {?> |
|
| 500 | + <?php if(!$isDetailedView) |
|
| 501 | +{ |
|
| 502 | +?> |
|
| 481 | 503 | <span data-tooltip="Comments"> |
| 482 | 504 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
| 483 | 505 | <i class="fa fa-commenting-o"></i> |
| 484 | - <?php if(array_key_exists("child_count", $post)) { |
|
| 506 | + <?php if(array_key_exists("child_count", $post)) |
|
| 507 | +{ |
|
| 485 | 508 | echo $post["child_count"]; |
| 486 | - } else echo "0"; |
|
| 509 | + } |
|
| 510 | + else { |
|
| 511 | + echo "0"; |
|
| 512 | + } |
|
| 487 | 513 | ?> |
| 488 | 514 | </a> |
| 489 | 515 | </span> |