@@ -1,21 +1,21 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Upvote extends AbstractRequest { |
| 3 | 3 | |
| 4 | - public $postId; |
|
| 4 | + public $postId; |
|
| 5 | 5 | |
| 6 | - function getApiEndPoint() |
|
| 7 | - { |
|
| 8 | - return '/v2/posts/' . $this->postId . '/upvote'; |
|
| 9 | - } |
|
| 10 | - function getPayload() |
|
| 11 | - { |
|
| 12 | - return array( |
|
| 6 | + function getApiEndPoint() |
|
| 7 | + { |
|
| 8 | + return '/v2/posts/' . $this->postId . '/upvote'; |
|
| 9 | + } |
|
| 10 | + function getPayload() |
|
| 11 | + { |
|
| 12 | + return array( |
|
| 13 | 13 | "reason_code" => -1, |
| 14 | - ); |
|
| 15 | - } |
|
| 16 | - function getMethod() |
|
| 17 | - { |
|
| 18 | - return 'PUT'; |
|
| 19 | - } |
|
| 14 | + ); |
|
| 15 | + } |
|
| 16 | + function getMethod() |
|
| 17 | + { |
|
| 18 | + return 'PUT'; |
|
| 19 | + } |
|
| 20 | 20 | } |
| 21 | 21 | |
@@ -1,5 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | -class Upvote extends AbstractRequest { |
|
| 2 | +class Upvote extends AbstractRequest |
|
| 3 | +{ |
|
| 3 | 4 | |
| 4 | 5 | public $postId; |
| 5 | 6 | |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | $config = parse_ini_file('config/config.ini.php'); |
| 4 | 4 | if(!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) |
| 5 | 5 | { |
| 6 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on admin.php'); |
|
| 6 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on admin.php'); |
|
| 7 | 7 | die(); |
| 8 | 8 | } |
| 9 | 9 | |
@@ -40,10 +40,12 @@ |
||
| 40 | 40 | $accessToken = isTokenFreshByAccessToken($location, $accessToken); |
| 41 | 41 | |
| 42 | 42 | |
| 43 | - if($_POST['vote'] == "up") { |
|
| 43 | + if($_POST['vote'] == "up") |
|
| 44 | + { |
|
| 44 | 45 | $accountCreator = new Upvote(); |
| 45 | 46 | } |
| 46 | - else if($_POST['vote'] == "down") { |
|
| 47 | + else if($_POST['vote'] == "down") |
|
| 48 | + { |
|
| 47 | 49 | $accountCreator = new Downvote(); |
| 48 | 50 | } |
| 49 | 51 | |
@@ -80,15 +80,15 @@ discard block |
||
| 80 | 80 | if(isset($_GET['city'])) { |
| 81 | 81 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
| 82 | 82 | $result = Requests::post($url); |
| 83 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
| 83 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
| 84 | 84 | { |
| 85 | 85 | $newPositionStatus = "0 results"; |
| 86 | 86 | } |
| 87 | 87 | else |
| 88 | 88 | { |
| 89 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
| 90 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
| 91 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
| 89 | + $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name']; |
|
| 90 | + $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']; |
|
| 91 | + $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']; |
|
| 92 | 92 | |
| 93 | 93 | $location = new Location(); |
| 94 | 94 | $location->setLat($lat); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | lng='" . $lng . "' |
| 109 | 109 | WHERE access_token='" . $accessToken . "'"); |
| 110 | 110 | |
| 111 | - if($result === false) |
|
| 111 | + if($result === FALSE) |
|
| 112 | 112 | { |
| 113 | 113 | echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
| 114 | 114 | } |
@@ -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 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($db->real_escape_string($_COOKIE['JodelDeviceId']))) |
| 41 | 41 | { |
| 42 | 42 | $deviceUid = createAccount(); |
| 43 | - setcookie('JodelDeviceId', $deviceUid, time()+60*60*24*365*10); |
|
| 44 | - error_log('Created account with JodelDeviceId:' . $deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 43 | + setcookie('JodelDeviceId', $deviceUid, time() + 60 * 60 * 24 * 365 * 10); |
|
| 44 | + error_log('Created account with JodelDeviceId:' . $deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | else |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | //Set View |
| 63 | 63 | if(isset($_GET['view'])) |
| 64 | 64 | { |
| 65 | - switch ($_GET['view']) { |
|
| 65 | + switch($_GET['view']) { |
|
| 66 | 66 | case 'comment': |
| 67 | 67 | $view = 'comment'; |
| 68 | 68 | break; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | else |
| 121 | 121 | { |
| 122 | 122 | $newPositionStatus = $name; |
| 123 | - error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 123 | + error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | if(isset($_POST['color'])) |
| 168 | 168 | { |
| 169 | 169 | $color = $_POST['color']; |
| 170 | - switch ($color) { |
|
| 170 | + switch($color) { |
|
| 171 | 171 | case '8ABDB0': |
| 172 | 172 | $color = '8ABDB0'; |
| 173 | 173 | break; |
@@ -353,13 +353,13 @@ discard block |
||
| 353 | 353 | else |
| 354 | 354 | { |
| 355 | 355 | $version = 'v2'; |
| 356 | - if($view=='comment') |
|
| 356 | + if($view == 'comment') |
|
| 357 | 357 | { |
| 358 | 358 | $url = "/v2/posts/location/discussed/"; |
| 359 | 359 | } |
| 360 | 360 | else |
| 361 | 361 | { |
| 362 | - if($view=='upVote') |
|
| 362 | + if($view == 'upVote') |
|
| 363 | 363 | { |
| 364 | 364 | $url = "/v2/posts/location/popular/"; |
| 365 | 365 | } |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | |
| 386 | - for($i = 0; $i<$loops; $i++) |
|
| 386 | + for($i = 0; $i < $loops; $i++) |
|
| 387 | 387 | { |
| 388 | 388 | if(array_key_exists($i, $posts) && array_key_exists('post_id', $posts[$i]) && isset($posts[$i]['post_id'])) |
| 389 | 389 | { |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
| 428 | 428 | <h2>Comment on Jodel</h2> |
| 429 | 429 | <form method="POST"> |
| 430 | - <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
|
| 430 | + <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" /> |
|
| 431 | 431 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
| 432 | 432 | <br /> |
| 433 | 433 | <input type="submit" value="SEND" /> |
@@ -464,13 +464,13 @@ discard block |
||
| 464 | 464 | <div class="col-xs-12"> |
| 465 | 465 | <div class="row"> |
| 466 | 466 | <div class="col-xs-3"> |
| 467 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 467 | + <a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
| 468 | 468 | </div> |
| 469 | 469 | <div class="col-xs-3"> |
| 470 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 470 | + <a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
| 471 | 471 | </div> |
| 472 | 472 | <div class="col-xs-3"> |
| 473 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 473 | + <a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
| 474 | 474 | </div> |
| 475 | 475 | <div class="col-xs-3"> |
| 476 | 476 | <nav> |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $header = $this->getSignHeaders(); |
| 29 | 29 | $url = $this->getFullUrl(); |
| 30 | 30 | |
| 31 | - if ($this->getAccessToken()) { |
|
| 31 | + if($this->getAccessToken()) { |
|
| 32 | 32 | $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
| 33 | 33 | } |
| 34 | 34 | //Comment out to debug the Request: |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | 'proxy' => '186.103.169.165:8080', |
| 46 | 46 | );*/ |
| 47 | 47 | |
| 48 | - switch ($this->getMethod()) { |
|
| 48 | + switch($this->getMethod()) { |
|
| 49 | 49 | case 'POST': |
| 50 | 50 | $result = Requests::post($url, $header, $this->payLoad); |
| 51 | 51 | break; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $result = Requests::put($url, $header, $this->payLoad); |
| 64 | 64 | break; |
| 65 | 65 | } |
| 66 | - switch ($result->status_code) { |
|
| 66 | + switch($result->status_code) { |
|
| 67 | 67 | case 200: |
| 68 | 68 | $result = json_decode($result->body, true); |
| 69 | 69 | break; |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | exit("Error 403: Access denied"); |
| 92 | 92 | break; |
| 93 | 93 | default: |
| 94 | - error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 95 | - throw new \Exception('Unknown Error: '.$result->status_code); |
|
| 94 | + error_log('Error ' . $result->status_code . ' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 95 | + throw new \Exception('Unknown Error: ' . $result->status_code); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | if($device_uid != '') |
@@ -2,19 +2,19 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | abstract class AbstractRequest |
| 4 | 4 | { |
| 5 | - const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
| 6 | - const APIURL = 'https://api.go-tellm.com/api'; |
|
| 7 | - const SECRET = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG'; |
|
| 8 | - const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
| 9 | - const CLIENT_TYPE = 'android_4.32.2'; |
|
| 5 | + const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
| 6 | + const APIURL = 'https://api.go-tellm.com/api'; |
|
| 7 | + const SECRET = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG'; |
|
| 8 | + const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
| 9 | + const CLIENT_TYPE = 'android_4.32.2'; |
|
| 10 | 10 | |
| 11 | - private $accessToken = null; |
|
| 12 | - private $payLoad; |
|
| 13 | - public $expects = ''; |
|
| 14 | - public $version = 'v2'; |
|
| 11 | + private $accessToken = null; |
|
| 12 | + private $payLoad; |
|
| 13 | + public $expects = ''; |
|
| 14 | + public $version = 'v2'; |
|
| 15 | 15 | |
| 16 | - public function execute() |
|
| 17 | - { |
|
| 16 | + public function execute() |
|
| 17 | + { |
|
| 18 | 18 | $result = new \stdClass(); |
| 19 | 19 | |
| 20 | 20 | $this->payLoad = $this->getPayload(); |
@@ -24,96 +24,96 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - $this->payLoad = json_encode($this->payLoad); |
|
| 28 | - $header = $this->getSignHeaders(); |
|
| 29 | - $url = $this->getFullUrl(); |
|
| 27 | + $this->payLoad = json_encode($this->payLoad); |
|
| 28 | + $header = $this->getSignHeaders(); |
|
| 29 | + $url = $this->getFullUrl(); |
|
| 30 | 30 | |
| 31 | - if ($this->getAccessToken()) { |
|
| 32 | - $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
| 33 | - } |
|
| 34 | - //Comment out to debug the Request: |
|
| 31 | + if ($this->getAccessToken()) { |
|
| 32 | + $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
| 33 | + } |
|
| 34 | + //Comment out to debug the Request: |
|
| 35 | 35 | |
| 36 | - /* |
|
| 36 | + /* |
|
| 37 | 37 | var_dump($url); |
| 38 | 38 | var_dump($header); |
| 39 | 39 | var_dump($this->payLoad); |
| 40 | 40 | */ |
| 41 | - /* |
|
| 41 | + /* |
|
| 42 | 42 | $options = array( |
| 43 | 43 | 'timeout' => 100, |
| 44 | 44 | 'connect_timeout' => 100, |
| 45 | 45 | 'proxy' => '186.103.169.165:8080', |
| 46 | 46 | );*/ |
| 47 | 47 | |
| 48 | - switch ($this->getMethod()) { |
|
| 49 | - case 'POST': |
|
| 50 | - $result = Requests::post($url, $header, $this->payLoad); |
|
| 51 | - break; |
|
| 52 | - case 'GET': |
|
| 53 | - if($this->version == 'v3') |
|
| 54 | - { |
|
| 55 | - $result = Requests::get($url, $header); |
|
| 56 | - } |
|
| 57 | - else |
|
| 58 | - { |
|
| 59 | - $result = Requests::get($url, $header); |
|
| 60 | - } |
|
| 61 | - break; |
|
| 62 | - case 'PUT': |
|
| 63 | - $result = Requests::put($url, $header, $this->payLoad); |
|
| 64 | - break; |
|
| 65 | - } |
|
| 66 | - switch ($result->status_code) { |
|
| 67 | - case 200: |
|
| 68 | - $result = json_decode($result->body, true); |
|
| 69 | - break; |
|
| 70 | - case 204: |
|
| 71 | - $result = "Success"; |
|
| 72 | - break; |
|
| 73 | - case 401: |
|
| 48 | + switch ($this->getMethod()) { |
|
| 49 | + case 'POST': |
|
| 50 | + $result = Requests::post($url, $header, $this->payLoad); |
|
| 51 | + break; |
|
| 52 | + case 'GET': |
|
| 53 | + if($this->version == 'v3') |
|
| 54 | + { |
|
| 55 | + $result = Requests::get($url, $header); |
|
| 56 | + } |
|
| 57 | + else |
|
| 58 | + { |
|
| 59 | + $result = Requests::get($url, $header); |
|
| 60 | + } |
|
| 61 | + break; |
|
| 62 | + case 'PUT': |
|
| 63 | + $result = Requests::put($url, $header, $this->payLoad); |
|
| 64 | + break; |
|
| 65 | + } |
|
| 66 | + switch ($result->status_code) { |
|
| 67 | + case 200: |
|
| 68 | + $result = json_decode($result->body, true); |
|
| 69 | + break; |
|
| 70 | + case 204: |
|
| 71 | + $result = "Success"; |
|
| 72 | + break; |
|
| 73 | + case 401: |
|
| 74 | 74 | //throw new \Exception('Unauthorized'); |
| 75 | - error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 76 | - break; |
|
| 77 | - case 404: |
|
| 78 | - //echo "Es wurde bereits gevoted"; |
|
| 79 | - error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid); |
|
| 75 | + error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 76 | + break; |
|
| 77 | + case 404: |
|
| 78 | + //echo "Es wurde bereits gevoted"; |
|
| 79 | + error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid); |
|
| 80 | 80 | case 477: |
| 81 | - //echo "Es wurde bereits gevoted"; |
|
| 82 | - //throw new \Exception('Signing failed!'); |
|
| 83 | - error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid); |
|
| 84 | - break; |
|
| 85 | - case 429: |
|
| 86 | - error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid); |
|
| 87 | - exit("Error 429: Too Many Requests"); |
|
| 88 | - break; |
|
| 89 | - case 403: |
|
| 90 | - error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid); |
|
| 91 | - exit("Error 403: Access denied"); |
|
| 92 | - break; |
|
| 93 | - default: |
|
| 94 | - error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 95 | - throw new \Exception('Unknown Error: '.$result->status_code); |
|
| 96 | - } |
|
| 81 | + //echo "Es wurde bereits gevoted"; |
|
| 82 | + //throw new \Exception('Signing failed!'); |
|
| 83 | + error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid); |
|
| 84 | + break; |
|
| 85 | + case 429: |
|
| 86 | + error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid); |
|
| 87 | + exit("Error 429: Too Many Requests"); |
|
| 88 | + break; |
|
| 89 | + case 403: |
|
| 90 | + error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid); |
|
| 91 | + exit("Error 403: Access denied"); |
|
| 92 | + break; |
|
| 93 | + default: |
|
| 94 | + error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
| 95 | + throw new \Exception('Unknown Error: '.$result->status_code); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - if($device_uid != '') |
|
| 99 | - { |
|
| 98 | + if($device_uid != '') |
|
| 99 | + { |
|
| 100 | 100 | $result[0] = $result; |
| 101 | 101 | $result[1] = $device_uid; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
| 105 | - /*var_dump($result);*/ |
|
| 105 | + /*var_dump($result);*/ |
|
| 106 | 106 | |
| 107 | 107 | |
| 108 | - return $result; |
|
| 109 | - } |
|
| 110 | - abstract function getPayload(); |
|
| 111 | - /** |
|
| 112 | - * Gets Sign headers |
|
| 113 | - * @return array headers |
|
| 114 | - */ |
|
| 115 | - private function getSignHeaders() |
|
| 116 | - { |
|
| 108 | + return $result; |
|
| 109 | + } |
|
| 110 | + abstract function getPayload(); |
|
| 111 | + /** |
|
| 112 | + * Gets Sign headers |
|
| 113 | + * @return array headers |
|
| 114 | + */ |
|
| 115 | + private function getSignHeaders() |
|
| 116 | + { |
|
| 117 | 117 | if($this->getAccessToken() == null) { |
| 118 | 118 | $payload_accessToken = ""; |
| 119 | 119 | } |
@@ -122,54 +122,54 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | |
| 125 | - $headers = array( |
|
| 126 | - "Connection" => "keep-alive", |
|
| 127 | - "Accept-Encoding" => "gzip", |
|
| 128 | - "Content-Type" => "application/json; charset=UTF-8", |
|
| 129 | - "User-Agent" => self::USERAGENT |
|
| 130 | - ); |
|
| 131 | - $timestamp = new DateTime(); |
|
| 132 | - $timestamp = $timestamp->format(DateTime::ATOM); |
|
| 133 | - $timestamp = substr($timestamp, 0, -6); |
|
| 134 | - $timestamp .= "Z"; |
|
| 135 | - $urlParts = parse_url($this->getFullUrl()); |
|
| 136 | - $url2 = ""; |
|
| 137 | - $req = [$this->getMethod(), |
|
| 138 | - $urlParts['host'], |
|
| 139 | - "443", |
|
| 140 | - $urlParts['path'], |
|
| 141 | - $payload_accessToken, |
|
| 142 | - $timestamp, |
|
| 143 | - $url2, |
|
| 144 | - $this->payLoad]; |
|
| 145 | - $reqString = implode("%", $req); |
|
| 146 | - $secret = self::SECRET; |
|
| 147 | - $signature = hash_hmac('sha1', $reqString, $secret); |
|
| 148 | - $signature = strtoupper($signature); |
|
| 149 | - $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
| 150 | - $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
| 151 | - $headers['X-Timestamp'] = $timestamp; |
|
| 152 | - $headers['X-Api-Version'] = '0.2'; |
|
| 153 | - return $headers; |
|
| 154 | - } |
|
| 155 | - private function getFullUrl() |
|
| 156 | - { |
|
| 157 | - return self::APIURL . $this->getApiEndPoint(); |
|
| 158 | - } |
|
| 159 | - abstract function getApiEndPoint(); |
|
| 160 | - abstract function getMethod(); |
|
| 161 | - /** |
|
| 162 | - * @return string |
|
| 163 | - */ |
|
| 164 | - private function getAccessToken() |
|
| 165 | - { |
|
| 166 | - return $this->accessToken; |
|
| 167 | - } |
|
| 168 | - /** |
|
| 169 | - * @param string $accessToken |
|
| 170 | - */ |
|
| 171 | - public function setAccessToken($accessToken) |
|
| 172 | - { |
|
| 173 | - $this->accessToken = $accessToken; |
|
| 174 | - } |
|
| 125 | + $headers = array( |
|
| 126 | + "Connection" => "keep-alive", |
|
| 127 | + "Accept-Encoding" => "gzip", |
|
| 128 | + "Content-Type" => "application/json; charset=UTF-8", |
|
| 129 | + "User-Agent" => self::USERAGENT |
|
| 130 | + ); |
|
| 131 | + $timestamp = new DateTime(); |
|
| 132 | + $timestamp = $timestamp->format(DateTime::ATOM); |
|
| 133 | + $timestamp = substr($timestamp, 0, -6); |
|
| 134 | + $timestamp .= "Z"; |
|
| 135 | + $urlParts = parse_url($this->getFullUrl()); |
|
| 136 | + $url2 = ""; |
|
| 137 | + $req = [$this->getMethod(), |
|
| 138 | + $urlParts['host'], |
|
| 139 | + "443", |
|
| 140 | + $urlParts['path'], |
|
| 141 | + $payload_accessToken, |
|
| 142 | + $timestamp, |
|
| 143 | + $url2, |
|
| 144 | + $this->payLoad]; |
|
| 145 | + $reqString = implode("%", $req); |
|
| 146 | + $secret = self::SECRET; |
|
| 147 | + $signature = hash_hmac('sha1', $reqString, $secret); |
|
| 148 | + $signature = strtoupper($signature); |
|
| 149 | + $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
| 150 | + $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
| 151 | + $headers['X-Timestamp'] = $timestamp; |
|
| 152 | + $headers['X-Api-Version'] = '0.2'; |
|
| 153 | + return $headers; |
|
| 154 | + } |
|
| 155 | + private function getFullUrl() |
|
| 156 | + { |
|
| 157 | + return self::APIURL . $this->getApiEndPoint(); |
|
| 158 | + } |
|
| 159 | + abstract function getApiEndPoint(); |
|
| 160 | + abstract function getMethod(); |
|
| 161 | + /** |
|
| 162 | + * @return string |
|
| 163 | + */ |
|
| 164 | + private function getAccessToken() |
|
| 165 | + { |
|
| 166 | + return $this->accessToken; |
|
| 167 | + } |
|
| 168 | + /** |
|
| 169 | + * @param string $accessToken |
|
| 170 | + */ |
|
| 171 | + public function setAccessToken($accessToken) |
|
| 172 | + { |
|
| 173 | + $this->accessToken = $accessToken; |
|
| 174 | + } |
|
| 175 | 175 | } |
@@ -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 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
| 9 | 9 | const CLIENT_TYPE = 'android_4.32.2'; |
| 10 | 10 | |
| 11 | - private $accessToken = null; |
|
| 11 | + private $accessToken = NULL; |
|
| 12 | 12 | private $payLoad; |
| 13 | 13 | public $expects = ''; |
| 14 | 14 | public $version = 'v2'; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | switch ($result->status_code) { |
| 67 | 67 | case 200: |
| 68 | - $result = json_decode($result->body, true); |
|
| 68 | + $result = json_decode($result->body, TRUE); |
|
| 69 | 69 | break; |
| 70 | 70 | case 204: |
| 71 | 71 | $result = "Success"; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | private function getSignHeaders() |
| 116 | 116 | { |
| 117 | - if($this->getAccessToken() == null) { |
|
| 117 | + if($this->getAccessToken() == NULL) { |
|
| 118 | 118 | $payload_accessToken = ""; |
| 119 | 119 | } |
| 120 | 120 | else { |
@@ -294,11 +294,11 @@ discard block |
||
| 294 | 294 | |
| 295 | 295 | if($result->num_rows == 0) |
| 296 | 296 | { |
| 297 | - return FALSE; |
|
| 297 | + return FALSE; |
|
| 298 | 298 | } |
| 299 | 299 | else |
| 300 | 300 | { |
| 301 | - return TRUE; |
|
| 301 | + return TRUE; |
|
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | { |
| 393 | 393 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 394 | 394 | |
| 395 | - return (isset($matches[0])) ? true : false; |
|
| 395 | + return (isset($matches[0])) ? true : false; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | function botDeviceUidIsSet($config) |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | function isDeviceUidInDatabase($deviceUid) |
| 22 | 22 | { |
| 23 | 23 | $db = new DatabaseConnect(); |
| 24 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 24 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 25 | 25 | |
| 26 | - if ($result->num_rows > 0) |
|
| 26 | + if($result->num_rows > 0) |
|
| 27 | 27 | { |
| 28 | 28 | return TRUE; |
| 29 | 29 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $access_token; |
| 42 | 42 | |
| 43 | - if ($result->num_rows > 0) |
|
| 43 | + if($result->num_rows > 0) |
|
| 44 | 44 | { |
| 45 | 45 | // output data of each row |
| 46 | 46 | while($row = $result->fetch_assoc()) { |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | if($expiration_date <= time()) { |
| 59 | 59 | $accountCreator = new CreateUser(); |
| 60 | - $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
|
| 60 | + $accountCreator->setAccessToken($access_token); //$accountData->getAccessToken()); |
|
| 61 | 61 | $accountCreator->setDeviceUid($deviceUid); |
| 62 | 62 | $accountCreator->setLocation($location); |
| 63 | 63 | $data = $accountCreator->execute(); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | expiration_date='" . $expiration_date . "' |
| 73 | 73 | WHERE device_uid='" . $device_uid . "'"); |
| 74 | 74 | |
| 75 | - if($result === false){ |
|
| 75 | + if($result === false) { |
|
| 76 | 76 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | $db = new DatabaseConnect(); |
| 86 | 86 | $result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'"); |
| 87 | 87 | |
| 88 | - if ($result->num_rows > 0) |
|
| 88 | + if($result->num_rows > 0) |
|
| 89 | 89 | { |
| 90 | 90 | // output data of each row |
| 91 | 91 | while($row = $result->fetch_assoc()) { |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | if($expiration_date <= time()) { |
| 104 | 104 | $accountCreator = new CreateUser(); |
| 105 | - $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
|
| 105 | + $accountCreator->setAccessToken($access_token); //$accountData->getAccessToken()); |
|
| 106 | 106 | $accountCreator->setDeviceUid($deviceUid); |
| 107 | 107 | $accountCreator->setLocation($location); |
| 108 | 108 | $data = $accountCreator->execute(); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | expiration_date='" . $expiration_date . "' |
| 118 | 118 | WHERE device_uid='" . $device_uid . "'"); |
| 119 | 119 | |
| 120 | - if($result === false){ |
|
| 120 | + if($result === false) { |
|
| 121 | 121 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $access_token; |
| 134 | 134 | |
| 135 | - if ($result->num_rows > 0) |
|
| 135 | + if($result->num_rows > 0) |
|
| 136 | 136 | { |
| 137 | 137 | // output data of each row |
| 138 | 138 | while($row = $result->fetch_assoc()) { |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | expiration_date='" . $expiration_date . "' |
| 165 | 165 | WHERE device_uid='" . $device_uid . "'"); |
| 166 | 166 | |
| 167 | - if($result === false){ |
|
| 167 | + if($result === false) { |
|
| 168 | 168 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | function getLocationByAccessToken($accessToken) |
| 176 | 176 | { |
| 177 | 177 | $db = new DatabaseConnect(); |
| 178 | - $result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'"); |
|
| 178 | + $result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'"); |
|
| 179 | 179 | |
| 180 | 180 | $location = new Location(); |
| 181 | 181 | |
| 182 | - if ($result->num_rows > 0) |
|
| 182 | + if($result->num_rows > 0) |
|
| 183 | 183 | { |
| 184 | 184 | // output data of each row |
| 185 | 185 | while($row = $result->fetch_assoc()) |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | function getLocationByDeviceUid($deviceUid) |
| 201 | 201 | { |
| 202 | 202 | $db = new DatabaseConnect(); |
| 203 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 203 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 204 | 204 | |
| 205 | 205 | $location = new Location(); |
| 206 | 206 | |
| 207 | - if ($result->num_rows > 0) |
|
| 207 | + if($result->num_rows > 0) |
|
| 208 | 208 | { |
| 209 | 209 | // output data of each row |
| 210 | 210 | while($row = $result->fetch_assoc()) |
@@ -225,11 +225,11 @@ discard block |
||
| 225 | 225 | function getDeviceUidByAccessToken($accesstoken) |
| 226 | 226 | { |
| 227 | 227 | $db = new DatabaseConnect(); |
| 228 | - $result = $db->query("SELECT device_uid FROM accounts WHERE access_token='" . $accesstoken . "'"); |
|
| 228 | + $result = $db->query("SELECT device_uid FROM accounts WHERE access_token='" . $accesstoken . "'"); |
|
| 229 | 229 | |
| 230 | 230 | $deviceUid; |
| 231 | 231 | |
| 232 | - if ($result->num_rows > 0) |
|
| 232 | + if($result->num_rows > 0) |
|
| 233 | 233 | { |
| 234 | 234 | // output data of each row |
| 235 | 235 | while($row = $result->fetch_assoc()) |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | function getAccessTokenByDeviceUid($deviceUid) |
| 249 | 249 | { |
| 250 | 250 | $db = new DatabaseConnect(); |
| 251 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 251 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 252 | 252 | |
| 253 | 253 | $accessToken; |
| 254 | 254 | |
| 255 | - if ($result->num_rows > 0) |
|
| 255 | + if($result->num_rows > 0) |
|
| 256 | 256 | { |
| 257 | 257 | // output data of each row |
| 258 | 258 | while($row = $result->fetch_assoc()) |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | $result = $db->query("INSERT INTO votes (device_uid, postId) |
| 314 | 314 | VALUES ('" . $device_uid . "','" . $postId . "') "); |
| 315 | 315 | |
| 316 | - if($result === false){ |
|
| 316 | + if($result === false) { |
|
| 317 | 317 | $error = db_error(); |
| 318 | 318 | echo $error; |
| 319 | 319 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
| 343 | 343 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
| 344 | 344 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
| 345 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 345 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 346 | 346 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 347 | 347 | |
| 348 | 348 | $success = TRUE; |
| 349 | - if($result === false){ |
|
| 349 | + if($result === false) { |
|
| 350 | 350 | $error = db_error(); |
| 351 | 351 | echo $error; |
| 352 | 352 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | { |
| 393 | 393 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 394 | 394 | |
| 395 | - return (isset($matches[0])) ? true : false; |
|
| 395 | + return (isset($matches[0]))?true : false; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | function botDeviceUidIsSet($config) |
@@ -423,25 +423,25 @@ discard block |
||
| 423 | 423 | $timediff_inDays = (string)$timediff->format('%d'); |
| 424 | 424 | $timediff_inMonth = (string)$timediff->format('%m'); |
| 425 | 425 | |
| 426 | - if($timediff_inMonth!=0) |
|
| 426 | + if($timediff_inMonth != 0) |
|
| 427 | 427 | { |
| 428 | 428 | $timediff = $timediff_inMonth . "m"; |
| 429 | 429 | } |
| 430 | 430 | else |
| 431 | 431 | { |
| 432 | - if($timediff_inDays!=0) |
|
| 432 | + if($timediff_inDays != 0) |
|
| 433 | 433 | { |
| 434 | 434 | $timediff = $timediff_inDays . "d"; |
| 435 | 435 | } |
| 436 | 436 | else |
| 437 | 437 | { |
| 438 | - if($timediff_inHours!=0) |
|
| 438 | + if($timediff_inHours != 0) |
|
| 439 | 439 | { |
| 440 | 440 | $timediff = $timediff_inHours . "h"; |
| 441 | 441 | } |
| 442 | 442 | else |
| 443 | 443 | { |
| 444 | - if($timediff_inMinutes!=0) |
|
| 444 | + if($timediff_inMinutes != 0) |
|
| 445 | 445 | { |
| 446 | 446 | $timediff = $timediff_inMinutes . "m"; |
| 447 | 447 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | |
| 456 | 456 | |
| 457 | 457 | ?> |
| 458 | - <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;"> |
|
| 458 | + <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"]; ?>;"> |
|
| 459 | 459 | <content> |
| 460 | 460 | <?php |
| 461 | 461 | if(isset($post["image_url"])) { |
@@ -470,24 +470,24 @@ discard block |
||
| 470 | 470 | <?php |
| 471 | 471 | if($isDetailedView) |
| 472 | 472 | {?> |
| 473 | - <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>"> |
|
| 473 | + <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>"> |
|
| 474 | 474 | <?php } |
| 475 | 475 | else |
| 476 | 476 | {?> |
| 477 | - <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>"> |
|
| 477 | + <a href="index.php?vote=up&postID=<?php echo $post['post_id']; ?>"> |
|
| 478 | 478 | <?php } ?> |
| 479 | 479 | <i class="fa fa-angle-up fa-3x"></i> |
| 480 | 480 | </a> |
| 481 | 481 | <br /> |
| 482 | - <?php echo $post["vote_count"];?><br /> |
|
| 482 | + <?php echo $post["vote_count"]; ?><br /> |
|
| 483 | 483 | <?php |
| 484 | 484 | if($isDetailedView) |
| 485 | 485 | {?> |
| 486 | - <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>"> |
|
| 486 | + <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>"> |
|
| 487 | 487 | <?php } |
| 488 | 488 | else |
| 489 | 489 | {?> |
| 490 | - <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>"> |
|
| 490 | + <a href="index.php?vote=down&postID=<?php echo $post['post_id']; ?>"> |
|
| 491 | 491 | <?php } ?> |
| 492 | 492 | <i class="fa fa-angle-down fa-3x"></i> |
| 493 | 493 | </a> |
@@ -499,14 +499,14 @@ discard block |
||
| 499 | 499 | <td class="time"> |
| 500 | 500 | <span class="tip" data-tooltip="Time"> |
| 501 | 501 | <i class="fa fa-clock-o"></i> |
| 502 | - <?php echo $timediff;?> |
|
| 503 | - <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
|
| 502 | + <?php echo $timediff; ?> |
|
| 503 | + <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span> |
|
| 504 | 504 | </span> |
| 505 | 505 | </td> |
| 506 | 506 | <td class="comments"> |
| 507 | 507 | <?php if(!$isDetailedView) {?> |
| 508 | 508 | <span data-tooltip="Comments"> |
| 509 | - <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
|
| 509 | + <a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $post["post_id"]; ?>"> |
|
| 510 | 510 | <i class="fa fa-commenting-o"></i> |
| 511 | 511 | <?php if(array_key_exists("child_count", $post)) { |
| 512 | 512 | echo $post["child_count"]; |
@@ -535,7 +535,7 @@ discard block |
||
| 535 | 535 | { |
| 536 | 536 | ?> |
| 537 | 537 | <span data-tooltip="Author"> |
| 538 | - <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
|
| 538 | + <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> | |
|
| 539 | 539 | </span> |
| 540 | 540 | <?php |
| 541 | 541 | } |
@@ -545,8 +545,8 @@ discard block |
||
| 545 | 545 | |
| 546 | 546 | <span class="tip" data-tooltip="Distance"> |
| 547 | 547 | <i class="fa fa-map-marker"></i> |
| 548 | - <?php echo $post['distance'];?> km |
|
| 549 | - <span class="tiptext"><?php echo $post['location']['name'];?></span> |
|
| 548 | + <?php echo $post['distance']; ?> km |
|
| 549 | + <span class="tiptext"><?php echo $post['location']['name']; ?></span> |
|
| 550 | 550 | </span> |
| 551 | 551 | </td> |
| 552 | 552 | </tr> |
@@ -43,7 +43,8 @@ discard block |
||
| 43 | 43 | if ($result->num_rows > 0) |
| 44 | 44 | { |
| 45 | 45 | // output data of each row |
| 46 | - while($row = $result->fetch_assoc()) { |
|
| 46 | + while($row = $result->fetch_assoc()) |
|
| 47 | + { |
|
| 47 | 48 | //$access_token = $row["access_token"]; |
| 48 | 49 | $expiration_date = $row["expiration_date"]; |
| 49 | 50 | $deviceUid = $row["device_uid"]; |
@@ -55,7 +56,8 @@ discard block |
||
| 55 | 56 | echo '0 results'; |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | - if($expiration_date <= time()) { |
|
| 59 | + if($expiration_date <= time()) |
|
| 60 | + { |
|
| 59 | 61 | $accountCreator = new CreateUser(); |
| 60 | 62 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
| 61 | 63 | $accountCreator->setDeviceUid($deviceUid); |
@@ -72,7 +74,8 @@ discard block |
||
| 72 | 74 | expiration_date='" . $expiration_date . "' |
| 73 | 75 | WHERE device_uid='" . $device_uid . "'"); |
| 74 | 76 | |
| 75 | - if($result === false){ |
|
| 77 | + if($result === false) |
|
| 78 | + { |
|
| 76 | 79 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 77 | 80 | } |
| 78 | 81 | } |
@@ -88,7 +91,8 @@ discard block |
||
| 88 | 91 | if ($result->num_rows > 0) |
| 89 | 92 | { |
| 90 | 93 | // output data of each row |
| 91 | - while($row = $result->fetch_assoc()) { |
|
| 94 | + while($row = $result->fetch_assoc()) |
|
| 95 | + { |
|
| 92 | 96 | //$access_token = $row["access_token"]; |
| 93 | 97 | $expiration_date = $row["expiration_date"]; |
| 94 | 98 | $deviceUid = $row["device_uid"]; |
@@ -100,7 +104,8 @@ discard block |
||
| 100 | 104 | echo '0 results'; |
| 101 | 105 | } |
| 102 | 106 | |
| 103 | - if($expiration_date <= time()) { |
|
| 107 | + if($expiration_date <= time()) |
|
| 108 | + { |
|
| 104 | 109 | $accountCreator = new CreateUser(); |
| 105 | 110 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
| 106 | 111 | $accountCreator->setDeviceUid($deviceUid); |
@@ -117,7 +122,8 @@ discard block |
||
| 117 | 122 | expiration_date='" . $expiration_date . "' |
| 118 | 123 | WHERE device_uid='" . $device_uid . "'"); |
| 119 | 124 | |
| 120 | - if($result === false){ |
|
| 125 | + if($result === false) |
|
| 126 | + { |
|
| 121 | 127 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 122 | 128 | } |
| 123 | 129 | } |
@@ -135,7 +141,8 @@ discard block |
||
| 135 | 141 | if ($result->num_rows > 0) |
| 136 | 142 | { |
| 137 | 143 | // output data of each row |
| 138 | - while($row = $result->fetch_assoc()) { |
|
| 144 | + while($row = $result->fetch_assoc()) |
|
| 145 | + { |
|
| 139 | 146 | //$access_token = $row["access_token"]; |
| 140 | 147 | $expiration_date = $row["expiration_date"]; |
| 141 | 148 | $deviceUid = $row["device_uid"]; |
@@ -147,7 +154,8 @@ discard block |
||
| 147 | 154 | echo '0 results'; |
| 148 | 155 | } |
| 149 | 156 | |
| 150 | - if($expiration_date <= time()) { |
|
| 157 | + if($expiration_date <= time()) |
|
| 158 | + { |
|
| 151 | 159 | $accountCreator = new CreateUser(); |
| 152 | 160 | $accountCreator->setAccessToken($access_token); |
| 153 | 161 | $accountCreator->setDeviceUid($deviceUid); |
@@ -164,7 +172,8 @@ discard block |
||
| 164 | 172 | expiration_date='" . $expiration_date . "' |
| 165 | 173 | WHERE device_uid='" . $device_uid . "'"); |
| 166 | 174 | |
| 167 | - if($result === false){ |
|
| 175 | + if($result === false) |
|
| 176 | + { |
|
| 168 | 177 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 169 | 178 | } |
| 170 | 179 | } |
@@ -313,7 +322,8 @@ discard block |
||
| 313 | 322 | $result = $db->query("INSERT INTO votes (device_uid, postId) |
| 314 | 323 | VALUES ('" . $device_uid . "','" . $postId . "') "); |
| 315 | 324 | |
| 316 | - if($result === false){ |
|
| 325 | + if($result === false) |
|
| 326 | + { |
|
| 317 | 327 | $error = db_error(); |
| 318 | 328 | echo $error; |
| 319 | 329 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -321,7 +331,8 @@ discard block |
||
| 321 | 331 | |
| 322 | 332 | } |
| 323 | 333 | |
| 324 | -function registerAccount(Location $location) { |
|
| 334 | +function registerAccount(Location $location) |
|
| 335 | +{ |
|
| 325 | 336 | $accountCreator = new CreateUser(); |
| 326 | 337 | $accountCreator->setLocation($location); |
| 327 | 338 | $data = $accountCreator->execute(); |
@@ -346,7 +357,8 @@ discard block |
||
| 346 | 357 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 347 | 358 | |
| 348 | 359 | $success = TRUE; |
| 349 | - if($result === false){ |
|
| 360 | + if($result === false) |
|
| 361 | + { |
|
| 350 | 362 | $error = db_error(); |
| 351 | 363 | echo $error; |
| 352 | 364 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -357,7 +369,7 @@ discard block |
||
| 357 | 369 | } |
| 358 | 370 | |
| 359 | 371 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
| 360 | -{ |
|
| 372 | +{ |
|
| 361 | 373 | $accountCreator = new GetPosts(); |
| 362 | 374 | $accountCreator->setLastPostId($lastPostId); |
| 363 | 375 | $accountCreator->setAccessToken($accessToken); |
@@ -408,7 +420,8 @@ discard block |
||
| 408 | 420 | } |
| 409 | 421 | |
| 410 | 422 | function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE) |
| 411 | -{ //ToDO |
|
| 423 | +{ |
|
| 424 | +//ToDO |
|
| 412 | 425 | //Replace # with link |
| 413 | 426 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
| 414 | 427 | |
@@ -458,10 +471,12 @@ discard block |
||
| 458 | 471 | <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;"> |
| 459 | 472 | <content> |
| 460 | 473 | <?php |
| 461 | - if(isset($post["image_url"])) { |
|
| 474 | + if(isset($post["image_url"])) |
|
| 475 | + { |
|
| 462 | 476 | echo '<img src="' . $post["image_url"] . '">'; |
| 463 | 477 | } |
| 464 | - else { |
|
| 478 | + else |
|
| 479 | + { |
|
| 465 | 480 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post["message"]))); |
| 466 | 481 | } |
| 467 | 482 | ?> |
@@ -469,11 +484,13 @@ discard block |
||
| 469 | 484 | <aside> |
| 470 | 485 | <?php |
| 471 | 486 | if($isDetailedView) |
| 472 | - {?> |
|
| 487 | + { |
|
| 488 | +?> |
|
| 473 | 489 | <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>"> |
| 474 | 490 | <?php } |
| 475 | - else |
|
| 476 | - {?> |
|
| 491 | +else |
|
| 492 | + { |
|
| 493 | +?> |
|
| 477 | 494 | <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>"> |
| 478 | 495 | <?php } ?> |
| 479 | 496 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -482,11 +499,13 @@ discard block |
||
| 482 | 499 | <?php echo $post["vote_count"];?><br /> |
| 483 | 500 | <?php |
| 484 | 501 | if($isDetailedView) |
| 485 | - {?> |
|
| 502 | + { |
|
| 503 | +?> |
|
| 486 | 504 | <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>"> |
| 487 | 505 | <?php } |
| 488 | - else |
|
| 489 | - {?> |
|
| 506 | +else |
|
| 507 | + { |
|
| 508 | +?> |
|
| 490 | 509 | <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>"> |
| 491 | 510 | <?php } ?> |
| 492 | 511 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -504,13 +523,19 @@ discard block |
||
| 504 | 523 | </span> |
| 505 | 524 | </td> |
| 506 | 525 | <td class="comments"> |
| 507 | - <?php if(!$isDetailedView) {?> |
|
| 526 | + <?php if(!$isDetailedView) |
|
| 527 | +{ |
|
| 528 | +?> |
|
| 508 | 529 | <span data-tooltip="Comments"> |
| 509 | 530 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
| 510 | 531 | <i class="fa fa-commenting-o"></i> |
| 511 | - <?php if(array_key_exists("child_count", $post)) { |
|
| 532 | + <?php if(array_key_exists("child_count", $post)) |
|
| 533 | +{ |
|
| 512 | 534 | echo $post["child_count"]; |
| 513 | - } else echo "0"; |
|
| 535 | + } |
|
| 536 | + else { |
|
| 537 | + echo "0"; |
|
| 538 | + } |
|
| 514 | 539 | ?> |
| 515 | 540 | </a> |
| 516 | 541 | </span> |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | expiration_date='" . $expiration_date . "' |
| 73 | 73 | WHERE device_uid='" . $device_uid . "'"); |
| 74 | 74 | |
| 75 | - if($result === false){ |
|
| 75 | + if($result === FALSE){ |
|
| 76 | 76 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | expiration_date='" . $expiration_date . "' |
| 118 | 118 | WHERE device_uid='" . $device_uid . "'"); |
| 119 | 119 | |
| 120 | - if($result === false){ |
|
| 120 | + if($result === FALSE){ |
|
| 121 | 121 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | expiration_date='" . $expiration_date . "' |
| 165 | 165 | WHERE device_uid='" . $device_uid . "'"); |
| 166 | 166 | |
| 167 | - if($result === false){ |
|
| 167 | + if($result === FALSE){ |
|
| 168 | 168 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | FROM votes |
| 286 | 286 | WHERE (postId = '" . $postId . "' AND device_uid = '" . $deviceUid . "')"); |
| 287 | 287 | |
| 288 | - if($result === false) |
|
| 288 | + if($result === FALSE) |
|
| 289 | 289 | { |
| 290 | 290 | $error = db_error(); |
| 291 | 291 | echo $error; |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | $result = $db->query("INSERT INTO votes (device_uid, postId) |
| 314 | 314 | VALUES ('" . $device_uid . "','" . $postId . "') "); |
| 315 | 315 | |
| 316 | - if($result === false){ |
|
| 316 | + if($result === FALSE){ |
|
| 317 | 317 | $error = db_error(); |
| 318 | 318 | echo $error; |
| 319 | 319 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 347 | 347 | |
| 348 | 348 | $success = TRUE; |
| 349 | - if($result === false){ |
|
| 349 | + if($result === FALSE){ |
|
| 350 | 350 | $error = db_error(); |
| 351 | 351 | echo $error; |
| 352 | 352 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | { |
| 393 | 393 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 394 | 394 | |
| 395 | - return (isset($matches[0])) ? true : false; |
|
| 395 | + return (isset($matches[0])) ? TRUE : FALSE; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | function botDeviceUidIsSet($config) |