@@ -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 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class GetCaptcha extends AbstractRequest |
| 3 | -{ |
|
| 3 | +{ |
|
| 4 | 4 | function getApiEndPoint() |
| 5 | 5 | { |
| 6 | 6 | return '/v3/user/verification/imageCaptcha/'; |
@@ -169,7 +169,8 @@ discard block |
||
| 169 | 169 | if(isset($_POST['color'])) |
| 170 | 170 | { |
| 171 | 171 | $color = $_POST['color']; |
| 172 | - switch ($color) { |
|
| 172 | + switch ($color) |
|
| 173 | + { |
|
| 173 | 174 | case '8ABDB0': |
| 174 | 175 | $color = '8ABDB0'; |
| 175 | 176 | break; |
@@ -243,7 +244,8 @@ discard block |
||
| 243 | 244 | if ($result->num_rows > 0) |
| 244 | 245 | { |
| 245 | 246 | // output data of each row |
| 246 | - while($row = $result->fetch_assoc()) { |
|
| 247 | + while($row = $result->fetch_assoc()) |
|
| 248 | + { |
|
| 247 | 249 | //$access_token = $row["access_token"]; |
| 248 | 250 | $expiration_date = $row["expiration_date"]; |
| 249 | 251 | $deviceUid = $row["device_uid"]; |
@@ -255,7 +257,8 @@ discard block |
||
| 255 | 257 | echo '0 results'; |
| 256 | 258 | } |
| 257 | 259 | |
| 258 | - if($expiration_date <= time()) { |
|
| 260 | + if($expiration_date <= time()) |
|
| 261 | + { |
|
| 259 | 262 | $accountCreator = new CreateUser(); |
| 260 | 263 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
| 261 | 264 | $accountCreator->setDeviceUid($deviceUid); |
@@ -272,7 +275,8 @@ discard block |
||
| 272 | 275 | expiration_date='" . $expiration_date . "' |
| 273 | 276 | WHERE device_uid='" . $device_uid . "'"); |
| 274 | 277 | |
| 275 | - if($result === false){ |
|
| 278 | + if($result === false) |
|
| 279 | + { |
|
| 276 | 280 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 277 | 281 | } |
| 278 | 282 | } |
@@ -288,7 +292,8 @@ discard block |
||
| 288 | 292 | if ($result->num_rows > 0) |
| 289 | 293 | { |
| 290 | 294 | // output data of each row |
| 291 | - while($row = $result->fetch_assoc()) { |
|
| 295 | + while($row = $result->fetch_assoc()) |
|
| 296 | + { |
|
| 292 | 297 | //$access_token = $row["access_token"]; |
| 293 | 298 | $expiration_date = $row["expiration_date"]; |
| 294 | 299 | $deviceUid = $row["device_uid"]; |
@@ -300,7 +305,8 @@ discard block |
||
| 300 | 305 | echo '0 results'; |
| 301 | 306 | } |
| 302 | 307 | |
| 303 | - if($expiration_date <= time()) { |
|
| 308 | + if($expiration_date <= time()) |
|
| 309 | + { |
|
| 304 | 310 | $accountCreator = new CreateUser(); |
| 305 | 311 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
| 306 | 312 | $accountCreator->setDeviceUid($deviceUid); |
@@ -317,7 +323,8 @@ discard block |
||
| 317 | 323 | expiration_date='" . $expiration_date . "' |
| 318 | 324 | WHERE device_uid='" . $device_uid . "'"); |
| 319 | 325 | |
| 320 | - if($result === false){ |
|
| 326 | + if($result === false) |
|
| 327 | + { |
|
| 321 | 328 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 322 | 329 | } |
| 323 | 330 | } |
@@ -335,7 +342,8 @@ discard block |
||
| 335 | 342 | if ($result->num_rows > 0) |
| 336 | 343 | { |
| 337 | 344 | // output data of each row |
| 338 | - while($row = $result->fetch_assoc()) { |
|
| 345 | + while($row = $result->fetch_assoc()) |
|
| 346 | + { |
|
| 339 | 347 | //$access_token = $row["access_token"]; |
| 340 | 348 | $expiration_date = $row["expiration_date"]; |
| 341 | 349 | $deviceUid = $row["device_uid"]; |
@@ -347,7 +355,8 @@ discard block |
||
| 347 | 355 | echo '0 results'; |
| 348 | 356 | } |
| 349 | 357 | |
| 350 | - if($expiration_date <= time()) { |
|
| 358 | + if($expiration_date <= time()) |
|
| 359 | + { |
|
| 351 | 360 | $accountCreator = new CreateUser(); |
| 352 | 361 | $accountCreator->setAccessToken($access_token); |
| 353 | 362 | $accountCreator->setDeviceUid($deviceUid); |
@@ -364,7 +373,8 @@ discard block |
||
| 364 | 373 | expiration_date='" . $expiration_date . "' |
| 365 | 374 | WHERE device_uid='" . $device_uid . "'"); |
| 366 | 375 | |
| 367 | - if($result === false){ |
|
| 376 | + if($result === false) |
|
| 377 | + { |
|
| 368 | 378 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 369 | 379 | } |
| 370 | 380 | } |
@@ -520,14 +530,16 @@ discard block |
||
| 520 | 530 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 521 | 531 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
| 522 | 532 | |
| 523 | - if($result === false){ |
|
| 533 | + if($result === false) |
|
| 534 | + { |
|
| 524 | 535 | $error = db_error(); |
| 525 | 536 | echo $error; |
| 526 | 537 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
| 527 | 538 | } |
| 528 | 539 | } |
| 529 | 540 | |
| 530 | -function registerAccount(Location $location) { |
|
| 541 | +function registerAccount(Location $location) |
|
| 542 | +{ |
|
| 531 | 543 | $accountCreator = new CreateUser(); |
| 532 | 544 | $accountCreator->setLocation($location); |
| 533 | 545 | $data = $accountCreator->execute(); |
@@ -552,7 +564,8 @@ discard block |
||
| 552 | 564 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 553 | 565 | |
| 554 | 566 | $success = TRUE; |
| 555 | - if($result === false){ |
|
| 567 | + if($result === false) |
|
| 568 | + { |
|
| 556 | 569 | $error = db_error(); |
| 557 | 570 | echo $error; |
| 558 | 571 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -563,7 +576,7 @@ discard block |
||
| 563 | 576 | } |
| 564 | 577 | |
| 565 | 578 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
| 566 | -{ |
|
| 579 | +{ |
|
| 567 | 580 | $accountCreator = new GetPosts(); |
| 568 | 581 | $accountCreator->setLastPostId($lastPostId); |
| 569 | 582 | $accountCreator->setAccessToken($accessToken); |
@@ -652,7 +665,8 @@ discard block |
||
| 652 | 665 | } |
| 653 | 666 | |
| 654 | 667 | function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE) |
| 655 | -{ //ToDO |
|
| 668 | +{ |
|
| 669 | +//ToDO |
|
| 656 | 670 | //Replace # with link |
| 657 | 671 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
| 658 | 672 | |
@@ -708,7 +722,8 @@ discard block |
||
| 708 | 722 | |
| 709 | 723 | echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
| 710 | 724 | } |
| 711 | - else { |
|
| 725 | + else |
|
| 726 | + { |
|
| 712 | 727 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
| 713 | 728 | } |
| 714 | 729 | ?> |
@@ -716,11 +731,13 @@ discard block |
||
| 716 | 731 | <aside> |
| 717 | 732 | <?php |
| 718 | 733 | if($isDetailedView) |
| 719 | - {?> |
|
| 734 | + { |
|
| 735 | +?> |
|
| 720 | 736 | <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
| 721 | 737 | <?php } |
| 722 | - else |
|
| 723 | - {?> |
|
| 738 | +else |
|
| 739 | + { |
|
| 740 | +?> |
|
| 724 | 741 | <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
| 725 | 742 | <?php } ?> |
| 726 | 743 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -729,11 +746,13 @@ discard block |
||
| 729 | 746 | <?php echo $post["vote_count"];?><br /> |
| 730 | 747 | <?php |
| 731 | 748 | if($isDetailedView) |
| 732 | - {?> |
|
| 749 | + { |
|
| 750 | +?> |
|
| 733 | 751 | <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
| 734 | 752 | <?php } |
| 735 | - else |
|
| 736 | - {?> |
|
| 753 | +else |
|
| 754 | + { |
|
| 755 | +?> |
|
| 737 | 756 | <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
| 738 | 757 | <?php } ?> |
| 739 | 758 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -751,13 +770,19 @@ discard block |
||
| 751 | 770 | </span> |
| 752 | 771 | </td> |
| 753 | 772 | <td class="comments"> |
| 754 | - <?php if(!$isDetailedView) {?> |
|
| 773 | + <?php if(!$isDetailedView) |
|
| 774 | +{ |
|
| 775 | +?> |
|
| 755 | 776 | <span data-tooltip="Comments"> |
| 756 | 777 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
| 757 | 778 | <i class="fa fa-commenting-o"></i> |
| 758 | - <?php if(array_key_exists("child_count", $post)) { |
|
| 779 | + <?php if(array_key_exists("child_count", $post)) |
|
| 780 | +{ |
|
| 759 | 781 | echo $post["child_count"]; |
| 760 | - } else echo "0"; |
|
| 782 | + } |
|
| 783 | + else { |
|
| 784 | + echo "0"; |
|
| 785 | + } |
|
| 761 | 786 | ?> |
| 762 | 787 | </a> |
| 763 | 788 | </span> |
@@ -40,17 +40,20 @@ discard block |
||
| 40 | 40 | $token = $accessToken; |
| 41 | 41 | $success = false; |
| 42 | 42 | } |
| 43 | - else { |
|
| 43 | + else |
|
| 44 | + { |
|
| 44 | 45 | |
| 45 | 46 | $location = getLocationByAccessToken($accessToken); |
| 46 | 47 | |
| 47 | 48 | $accessToken = isTokenFreshByAccessToken($location, $accessToken); |
| 48 | 49 | |
| 49 | 50 | |
| 50 | - if($_POST['vote'] == "up") { |
|
| 51 | + if($_POST['vote'] == "up") |
|
| 52 | + { |
|
| 51 | 53 | $accountCreator = new Upvote(); |
| 52 | 54 | } |
| 53 | - else if($_POST['vote'] == "down") { |
|
| 55 | + else if($_POST['vote'] == "down") |
|
| 56 | + { |
|
| 54 | 57 | $accountCreator = new Downvote(); |
| 55 | 58 | } |
| 56 | 59 | |
@@ -74,7 +77,7 @@ discard block |
||
| 74 | 77 | { |
| 75 | 78 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "accessToken" => $token); |
| 76 | 79 | } |
| 77 | -else |
|
| 80 | +else |
|
| 78 | 81 | { |
| 79 | 82 | $response = array("success" => $success, "message" => $message); |
| 80 | 83 | } |
@@ -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; |
@@ -416,104 +417,4 @@ discard block |
||
| 416 | 417 | |
| 417 | 418 | var win = $(window); |
| 418 | 419 | var lastPostId = "<?php echo $lastPostId; ?>"; |
| 419 | - var view = "<?php echo $view; ?>" |
|
| 420 | - var old_lastPostId = ""; |
|
| 421 | - var morePostsAvailable = true; |
|
| 422 | - |
|
| 423 | - if(window.location.hash) |
|
| 424 | - { |
|
| 425 | - var hash = window.location.hash.slice(1); |
|
| 426 | - |
|
| 427 | - if(!$("article[id='"+ hash +"']").length) |
|
| 428 | - { |
|
| 429 | - for (var i = 5; i >= 0; i--) |
|
| 430 | - { |
|
| 431 | - if(!$("article[id='"+ hash +"']").length) |
|
| 432 | - { |
|
| 433 | - $.ajax({ |
|
| 434 | - url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view, |
|
| 435 | - dataType: 'html', |
|
| 436 | - async: false, |
|
| 437 | - success: function(html) { |
|
| 438 | - var div = document.createElement('div'); |
|
| 439 | - div.innerHTML = html; |
|
| 440 | - var elements = div.childNodes; |
|
| 441 | - old_lastPostId = lastPostId; |
|
| 442 | - lastPostId = elements[3].textContent; |
|
| 443 | - lastPostId = lastPostId.replace(/\s+/g, ''); |
|
| 444 | - //alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId); |
|
| 445 | - if(lastPostId == old_lastPostId) { |
|
| 446 | - |
|
| 447 | - //morePostsAvailable = false; |
|
| 448 | - } |
|
| 449 | - else { |
|
| 450 | - //alert(elements[3].textContent); |
|
| 451 | - $('#posts').append(elements[1].innerHTML); |
|
| 452 | - $('#posts').hide().show(0); |
|
| 453 | - } |
|
| 454 | - $('#loading').hide(); |
|
| 455 | - } |
|
| 456 | - }); |
|
| 457 | - |
|
| 458 | - $('.jodel > content').Emoji(); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - } |
|
| 462 | - scrollToAnchor(hash); |
|
| 463 | - |
|
| 464 | - } |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - // Each time the user scrolls |
|
| 468 | - win.scroll(function() { |
|
| 469 | - |
|
| 470 | - |
|
| 471 | - // End of the document reached? |
|
| 472 | - if ($(window).scrollTop() + $(window).height() > $(document).height() - 100 && morePostsAvailable) |
|
| 473 | - { |
|
| 474 | - $('#loading').show(); |
|
| 475 | - |
|
| 476 | - $.ajax({ |
|
| 477 | - url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view, |
|
| 478 | - dataType: 'html', |
|
| 479 | - async: false, |
|
| 480 | - success: function(html) { |
|
| 481 | - var div = document.createElement('div'); |
|
| 482 | - div.innerHTML = html; |
|
| 483 | - var elements = div.childNodes; |
|
| 484 | - old_lastPostId = lastPostId; |
|
| 485 | - lastPostId = elements[3].textContent; |
|
| 486 | - lastPostId = lastPostId.replace(/\s+/g, ''); |
|
| 487 | - //alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId); |
|
| 488 | - if(lastPostId == old_lastPostId) |
|
| 489 | - { |
|
| 490 | - |
|
| 491 | - //morePostsAvailable = false; |
|
| 492 | - } |
|
| 493 | - else |
|
| 494 | - { |
|
| 495 | - //alert(elements[3].textContent); |
|
| 496 | - $('#posts').append(elements[1].innerHTML); |
|
| 497 | - } |
|
| 498 | - $('#loading').hide(); |
|
| 499 | - } |
|
| 500 | - }); |
|
| 501 | - |
|
| 502 | - $('.jodel > content').Emoji(); |
|
| 503 | - } |
|
| 504 | - }); |
|
| 505 | - <?php } ?> |
|
| 506 | - }); |
|
| 507 | - |
|
| 508 | - </script> |
|
| 509 | - |
|
| 510 | - <?php |
|
| 511 | - if(is_file('./piwik-script.html')) |
|
| 512 | - { |
|
| 513 | - require_once('./piwik-script.html'); |
|
| 514 | - } |
|
| 515 | - ?> |
|
| 516 | - |
|
| 517 | - </body> |
|
| 518 | -</html> |
|
| 519 | - |
|
| 420 | + var view = "<?php echo $view |
|
| 520 | 421 | \ No newline at end of file |