@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 | } |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($db->real_escape_string($_COOKIE['JodelDeviceId']))) |
40 | 40 | { |
41 | 41 | $deviceUid = createAccount(); |
42 | - setcookie('JodelDeviceId', $deviceUid, time()+60*60*24*365*10); |
|
43 | - error_log('Created account with JodelDeviceId:' . $deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
42 | + setcookie('JodelDeviceId', $deviceUid, time() + 60 * 60 * 24 * 365 * 10); |
|
43 | + error_log('Created account with JodelDeviceId:' . $deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | else |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | //Set View |
62 | 62 | if(isset($_GET['view'])) |
63 | 63 | { |
64 | - switch ($_GET['view']) { |
|
64 | + switch($_GET['view']) { |
|
65 | 65 | case 'comment': |
66 | 66 | $view = 'comment'; |
67 | 67 | break; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | else |
120 | 120 | { |
121 | 121 | $newPositionStatus = $name; |
122 | - error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
122 | + error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | if(isset($_POST['color'])) |
173 | 173 | { |
174 | 174 | $color = $_POST['color']; |
175 | - switch ($color) { |
|
175 | + switch($color) { |
|
176 | 176 | case '8ABDB0': |
177 | 177 | $color = '8ABDB0'; |
178 | 178 | break; |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | else |
268 | 268 | { |
269 | 269 | $version = 'v2'; |
270 | - if($view=='comment') |
|
270 | + if($view == 'comment') |
|
271 | 271 | { |
272 | 272 | $url = "/v2/posts/location/discussed/"; |
273 | 273 | } |
274 | 274 | else |
275 | 275 | { |
276 | - if($view=='upVote') |
|
276 | + if($view == 'upVote') |
|
277 | 277 | { |
278 | 278 | $url = "/v2/posts/location/popular/"; |
279 | 279 | } |
@@ -299,13 +299,13 @@ discard block |
||
299 | 299 | <!DOCTYPE html> |
300 | 300 | <html lang="en"> |
301 | 301 | <head> |
302 | - <title><?php echo getTitle($posts[0], $view, $isDetailedView);?></title> |
|
302 | + <title><?php echo getTitle($posts[0], $view, $isDetailedView); ?></title> |
|
303 | 303 | |
304 | 304 | <meta charset="utf-8"> |
305 | 305 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
306 | 306 | <meta http-equiv="x-ua-compatible" content="ie=edge"> |
307 | 307 | |
308 | - <meta name="description" content="<?php echo getMetaDescription($posts[0], $view, $isDetailedView);?>"> |
|
308 | + <meta name="description" content="<?php echo getMetaDescription($posts[0], $view, $isDetailedView); ?>"> |
|
309 | 309 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app"> |
310 | 310 | |
311 | 311 | <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous"> |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | |
387 | 387 | <content id="posts"> |
388 | 388 | <?php |
389 | - for($i = 0; $i<$loops; $i++) |
|
389 | + for($i = 0; $i < $loops; $i++) |
|
390 | 390 | { |
391 | 391 | if(array_key_exists($i, $posts) && array_key_exists('post_id', $posts[$i]) && isset($posts[$i]['post_id'])) |
392 | 392 | { |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
431 | 431 | <h2>Comment on Jodel</h2> |
432 | 432 | <form method="POST"> |
433 | - <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
|
433 | + <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" /> |
|
434 | 434 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
435 | 435 | <br /> |
436 | 436 | <input type="submit" value="SEND" /> |
@@ -467,13 +467,13 @@ discard block |
||
467 | 467 | <div class="col-xs-12"> |
468 | 468 | <div class="row"> |
469 | 469 | <div class="col-xs-3"> |
470 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
470 | + <a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
471 | 471 | </div> |
472 | 472 | <div class="col-xs-3"> |
473 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
473 | + <a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
474 | 474 | </div> |
475 | 475 | <div class="col-xs-3"> |
476 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
476 | + <a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
477 | 477 | </div> |
478 | 478 | <div class="col-xs-3"> |
479 | 479 | <nav> |
@@ -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') |
@@ -172,7 +174,8 @@ discard block |
||
172 | 174 | if(isset($_POST['color'])) |
173 | 175 | { |
174 | 176 | $color = $_POST['color']; |
175 | - switch ($color) { |
|
177 | + switch ($color) |
|
178 | + { |
|
176 | 179 | case '8ABDB0': |
177 | 180 | $color = '8ABDB0'; |
178 | 181 | break; |
@@ -235,7 +238,8 @@ discard block |
||
235 | 238 | $data = $accountCreator->execute(); |
236 | 239 | |
237 | 240 | $posts[0] = $data; |
238 | - if(array_key_exists('children', $data)) { |
|
241 | + if(array_key_exists('children', $data)) |
|
242 | + { |
|
239 | 243 | foreach($data['children'] as $key => $child) |
240 | 244 | { |
241 | 245 | |
@@ -371,7 +375,11 @@ discard block |
||
371 | 375 | |
372 | 376 | <div id="location_mobile" class="hidden-sm-up"> |
373 | 377 | <form method="get"> |
374 | - <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
378 | + <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
379 | +{ |
|
380 | + echo $newPositionStatus; |
|
381 | +} |
|
382 | +?>" required> |
|
375 | 383 | |
376 | 384 | <input type="submit" id="submit_mobile" class="fa" value="" /> |
377 | 385 | </form> |
@@ -398,7 +406,9 @@ discard block |
||
398 | 406 | |
399 | 407 | </content> |
400 | 408 | |
401 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
409 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
410 | +{ |
|
411 | +?> |
|
402 | 412 | <p id="loading"> |
403 | 413 | Loading… |
404 | 414 | </p> |
@@ -411,7 +421,11 @@ discard block |
||
411 | 421 | <div> |
412 | 422 | <h2>Position</h2> |
413 | 423 | <form method="get"> |
414 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
424 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
425 | +{ |
|
426 | + echo $newPositionStatus; |
|
427 | +} |
|
428 | +?>" required> |
|
415 | 429 | |
416 | 430 | <input type="submit" value="Set Location" /> |
417 | 431 | </form> |
@@ -427,7 +441,9 @@ discard block |
||
427 | 441 | |
428 | 442 | <article> |
429 | 443 | <div> |
430 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
444 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
445 | +{ |
|
446 | +?> |
|
431 | 447 | <h2>Comment on Jodel</h2> |
432 | 448 | <form method="POST"> |
433 | 449 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
@@ -435,7 +451,10 @@ discard block |
||
435 | 451 | <br /> |
436 | 452 | <input type="submit" value="SEND" /> |
437 | 453 | </form> |
438 | - <?php } else { ?> |
|
454 | + <?php } |
|
455 | +else |
|
456 | +{ |
|
457 | +?> |
|
439 | 458 | <h2>New Jodel</h2> |
440 | 459 | <form method="POST"> |
441 | 460 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -467,13 +486,25 @@ discard block |
||
467 | 486 | <div class="col-xs-12"> |
468 | 487 | <div class="row"> |
469 | 488 | <div class="col-xs-3"> |
470 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
489 | + <a href="index.php" <?php if($view=='time') |
|
490 | +{ |
|
491 | + echo 'class="active"'; |
|
492 | +} |
|
493 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
471 | 494 | </div> |
472 | 495 | <div class="col-xs-3"> |
473 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
496 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
497 | +{ |
|
498 | + echo 'class="active"'; |
|
499 | +} |
|
500 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
474 | 501 | </div> |
475 | 502 | <div class="col-xs-3"> |
476 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
503 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
504 | +{ |
|
505 | + echo 'class="active"'; |
|
506 | +} |
|
507 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
477 | 508 | </div> |
478 | 509 | <div class="col-xs-3"> |
479 | 510 | <nav> |
@@ -516,7 +547,9 @@ discard block |
||
516 | 547 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
517 | 548 | } |
518 | 549 | |
519 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
550 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
551 | +{ |
|
552 | +?> |
|
520 | 553 | |
521 | 554 | |
522 | 555 |
@@ -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 { |
@@ -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,15 +24,15 @@ 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: |
|
35 | - /* |
|
31 | + if ($this->getAccessToken()) { |
|
32 | + $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
33 | + } |
|
34 | + //Comment out to debug the Request: |
|
35 | + /* |
|
36 | 36 | printf("URL: "); |
37 | 37 | var_dump($url); |
38 | 38 | echo "<br />"; |
@@ -43,82 +43,82 @@ discard block |
||
43 | 43 | var_dump($this->payLoad); |
44 | 44 | echo "<br />"; |
45 | 45 | */ |
46 | - /* |
|
46 | + /* |
|
47 | 47 | $options = array( |
48 | 48 | 'timeout' => 100, |
49 | 49 | 'connect_timeout' => 100, |
50 | 50 | 'proxy' => '186.103.169.165:8080', |
51 | 51 | );*/ |
52 | 52 | |
53 | - switch ($this->getMethod()) { |
|
54 | - case 'POST': |
|
55 | - $result = Requests::post($url, $header, $this->payLoad); |
|
56 | - break; |
|
57 | - case 'GET': |
|
58 | - if($this->version == 'v3') |
|
59 | - { |
|
60 | - $result = Requests::get($url, $header); |
|
61 | - } |
|
62 | - else |
|
63 | - { |
|
64 | - $result = Requests::get($url, $header); |
|
65 | - } |
|
66 | - break; |
|
67 | - case 'PUT': |
|
68 | - $result = Requests::put($url, $header, $this->payLoad); |
|
69 | - break; |
|
70 | - } |
|
71 | - switch ($result->status_code) { |
|
72 | - case 200: |
|
73 | - $result = json_decode($result->body, true); |
|
74 | - break; |
|
75 | - case 204: |
|
76 | - $result = "Success"; |
|
77 | - break; |
|
78 | - case 401: |
|
53 | + switch ($this->getMethod()) { |
|
54 | + case 'POST': |
|
55 | + $result = Requests::post($url, $header, $this->payLoad); |
|
56 | + break; |
|
57 | + case 'GET': |
|
58 | + if($this->version == 'v3') |
|
59 | + { |
|
60 | + $result = Requests::get($url, $header); |
|
61 | + } |
|
62 | + else |
|
63 | + { |
|
64 | + $result = Requests::get($url, $header); |
|
65 | + } |
|
66 | + break; |
|
67 | + case 'PUT': |
|
68 | + $result = Requests::put($url, $header, $this->payLoad); |
|
69 | + break; |
|
70 | + } |
|
71 | + switch ($result->status_code) { |
|
72 | + case 200: |
|
73 | + $result = json_decode($result->body, true); |
|
74 | + break; |
|
75 | + case 204: |
|
76 | + $result = "Success"; |
|
77 | + break; |
|
78 | + case 401: |
|
79 | 79 | //throw new \Exception('Unauthorized'); |
80 | - error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
81 | - break; |
|
82 | - case 404: |
|
83 | - //echo "Es wurde bereits gevoted"; |
|
84 | - error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid); |
|
80 | + error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
81 | + break; |
|
82 | + case 404: |
|
83 | + //echo "Es wurde bereits gevoted"; |
|
84 | + error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid); |
|
85 | 85 | case 477: |
86 | - //echo "Es wurde bereits gevoted"; |
|
87 | - //throw new \Exception('Signing failed!'); |
|
88 | - error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid); |
|
89 | - break; |
|
90 | - case 429: |
|
91 | - error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid); |
|
92 | - exit("Error 429: Too Many Requests"); |
|
93 | - break; |
|
94 | - case 403: |
|
95 | - error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid); |
|
96 | - exit("Error 403: Access denied"); |
|
97 | - break; |
|
98 | - default: |
|
99 | - error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
100 | - //throw new \Exception('Unknown Error: '.$result->status_code); |
|
101 | - } |
|
86 | + //echo "Es wurde bereits gevoted"; |
|
87 | + //throw new \Exception('Signing failed!'); |
|
88 | + error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid); |
|
89 | + break; |
|
90 | + case 429: |
|
91 | + error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid); |
|
92 | + exit("Error 429: Too Many Requests"); |
|
93 | + break; |
|
94 | + case 403: |
|
95 | + error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid); |
|
96 | + exit("Error 403: Access denied"); |
|
97 | + break; |
|
98 | + default: |
|
99 | + error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
100 | + //throw new \Exception('Unknown Error: '.$result->status_code); |
|
101 | + } |
|
102 | 102 | |
103 | - if($device_uid != '') |
|
104 | - { |
|
103 | + if($device_uid != '') |
|
104 | + { |
|
105 | 105 | $result[0] = $result; |
106 | 106 | $result[1] = $device_uid; |
107 | 107 | } |
108 | 108 | |
109 | - /* |
|
109 | + /* |
|
110 | 110 | var_dump($result); |
111 | 111 | */ |
112 | 112 | |
113 | - return $result; |
|
114 | - } |
|
115 | - abstract function getPayload(); |
|
116 | - /** |
|
117 | - * Gets Sign headers |
|
118 | - * @return array headers |
|
119 | - */ |
|
120 | - private function getSignHeaders() |
|
121 | - { |
|
113 | + return $result; |
|
114 | + } |
|
115 | + abstract function getPayload(); |
|
116 | + /** |
|
117 | + * Gets Sign headers |
|
118 | + * @return array headers |
|
119 | + */ |
|
120 | + private function getSignHeaders() |
|
121 | + { |
|
122 | 122 | if($this->getAccessToken() == null) { |
123 | 123 | $payload_accessToken = ""; |
124 | 124 | } |
@@ -127,54 +127,54 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | - $headers = array( |
|
131 | - "Connection" => "keep-alive", |
|
132 | - "Accept-Encoding" => "gzip", |
|
133 | - "Content-Type" => "application/json; charset=UTF-8", |
|
134 | - "User-Agent" => self::USERAGENT |
|
135 | - ); |
|
136 | - $timestamp = new DateTime(); |
|
137 | - $timestamp = $timestamp->format(DateTime::ATOM); |
|
138 | - $timestamp = substr($timestamp, 0, -6); |
|
139 | - $timestamp .= "Z"; |
|
140 | - $urlParts = parse_url($this->getFullUrl()); |
|
141 | - $url2 = ""; |
|
142 | - $req = [$this->getMethod(), |
|
143 | - $urlParts['host'], |
|
144 | - "443", |
|
145 | - $urlParts['path'], |
|
146 | - $payload_accessToken, |
|
147 | - $timestamp, |
|
148 | - $url2, |
|
149 | - $this->payLoad]; |
|
150 | - $reqString = implode("%", $req); |
|
151 | - $secret = self::SECRET; |
|
152 | - $signature = hash_hmac('sha1', $reqString, $secret); |
|
153 | - $signature = strtoupper($signature); |
|
154 | - $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
155 | - $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
156 | - $headers['X-Timestamp'] = $timestamp; |
|
157 | - $headers['X-Api-Version'] = '0.2'; |
|
158 | - return $headers; |
|
159 | - } |
|
160 | - private function getFullUrl() |
|
161 | - { |
|
162 | - return self::APIURL . $this->getApiEndPoint(); |
|
163 | - } |
|
164 | - abstract function getApiEndPoint(); |
|
165 | - abstract function getMethod(); |
|
166 | - /** |
|
167 | - * @return string |
|
168 | - */ |
|
169 | - private function getAccessToken() |
|
170 | - { |
|
171 | - return $this->accessToken; |
|
172 | - } |
|
173 | - /** |
|
174 | - * @param string $accessToken |
|
175 | - */ |
|
176 | - public function setAccessToken($accessToken) |
|
177 | - { |
|
178 | - $this->accessToken = $accessToken; |
|
179 | - } |
|
130 | + $headers = array( |
|
131 | + "Connection" => "keep-alive", |
|
132 | + "Accept-Encoding" => "gzip", |
|
133 | + "Content-Type" => "application/json; charset=UTF-8", |
|
134 | + "User-Agent" => self::USERAGENT |
|
135 | + ); |
|
136 | + $timestamp = new DateTime(); |
|
137 | + $timestamp = $timestamp->format(DateTime::ATOM); |
|
138 | + $timestamp = substr($timestamp, 0, -6); |
|
139 | + $timestamp .= "Z"; |
|
140 | + $urlParts = parse_url($this->getFullUrl()); |
|
141 | + $url2 = ""; |
|
142 | + $req = [$this->getMethod(), |
|
143 | + $urlParts['host'], |
|
144 | + "443", |
|
145 | + $urlParts['path'], |
|
146 | + $payload_accessToken, |
|
147 | + $timestamp, |
|
148 | + $url2, |
|
149 | + $this->payLoad]; |
|
150 | + $reqString = implode("%", $req); |
|
151 | + $secret = self::SECRET; |
|
152 | + $signature = hash_hmac('sha1', $reqString, $secret); |
|
153 | + $signature = strtoupper($signature); |
|
154 | + $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
155 | + $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
156 | + $headers['X-Timestamp'] = $timestamp; |
|
157 | + $headers['X-Api-Version'] = '0.2'; |
|
158 | + return $headers; |
|
159 | + } |
|
160 | + private function getFullUrl() |
|
161 | + { |
|
162 | + return self::APIURL . $this->getApiEndPoint(); |
|
163 | + } |
|
164 | + abstract function getApiEndPoint(); |
|
165 | + abstract function getMethod(); |
|
166 | + /** |
|
167 | + * @return string |
|
168 | + */ |
|
169 | + private function getAccessToken() |
|
170 | + { |
|
171 | + return $this->accessToken; |
|
172 | + } |
|
173 | + /** |
|
174 | + * @param string $accessToken |
|
175 | + */ |
|
176 | + public function setAccessToken($accessToken) |
|
177 | + { |
|
178 | + $this->accessToken = $accessToken; |
|
179 | + } |
|
180 | 180 | } |
@@ -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: |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | 'proxy' => '186.103.169.165:8080', |
51 | 51 | );*/ |
52 | 52 | |
53 | - switch ($this->getMethod()) { |
|
53 | + switch($this->getMethod()) { |
|
54 | 54 | case 'POST': |
55 | 55 | $result = Requests::post($url, $header, $this->payLoad); |
56 | 56 | break; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $result = Requests::put($url, $header, $this->payLoad); |
69 | 69 | break; |
70 | 70 | } |
71 | - switch ($result->status_code) { |
|
71 | + switch($result->status_code) { |
|
72 | 72 | case 200: |
73 | 73 | $result = json_decode($result->body, true); |
74 | 74 | break; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | exit("Error 403: Access denied"); |
97 | 97 | break; |
98 | 98 | default: |
99 | - error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
99 | + error_log('Error ' . $result->status_code . ' - Unauthorized'); // - JodelDeviceId:' . $deviceUid); |
|
100 | 100 | //throw new \Exception('Unknown Error: '.$result->status_code); |
101 | 101 | } |
102 | 102 |
@@ -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) |
@@ -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 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | FROM votes |
289 | 289 | WHERE (postId = '" . $postId . "' AND device_uid = '" . $deviceUid . "')"); |
290 | 290 | |
291 | - if($result === false) |
|
291 | + if($result === FALSE) |
|
292 | 292 | { |
293 | 293 | $error = db_error(); |
294 | 294 | echo $error; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
320 | 320 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
321 | 321 | |
322 | - if($result === false){ |
|
322 | + if($result === FALSE){ |
|
323 | 323 | $error = db_error(); |
324 | 324 | echo $error; |
325 | 325 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
353 | 353 | |
354 | 354 | $success = TRUE; |
355 | - if($result === false){ |
|
355 | + if($result === FALSE){ |
|
356 | 356 | $error = db_error(); |
357 | 357 | echo $error; |
358 | 358 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | { |
399 | 399 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
400 | 400 | |
401 | - return (isset($matches[0])) ? true : false; |
|
401 | + return (isset($matches[0])) ? TRUE : FALSE; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | function botDeviceUidIsSet($config) |
@@ -278,6 +278,9 @@ |
||
278 | 278 | return $data["karma"]; |
279 | 279 | } |
280 | 280 | |
281 | +/** |
|
282 | + * @param string $postId |
|
283 | + */ |
|
281 | 284 | function deviceUidHasVotedThisPostId($deviceUid, $postId) |
282 | 285 | { |
283 | 286 | $db = new DatabaseConnect(); |
@@ -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()) |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
321 | 321 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
322 | 322 | |
323 | - if($result === false){ |
|
323 | + if($result === false) { |
|
324 | 324 | $error = db_error(); |
325 | 325 | echo $error; |
326 | 326 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -348,11 +348,11 @@ discard block |
||
348 | 348 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
349 | 349 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
350 | 350 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
351 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
351 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
352 | 352 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
353 | 353 | |
354 | 354 | $success = TRUE; |
355 | - if($result === false){ |
|
355 | + if($result === false) { |
|
356 | 356 | $error = db_error(); |
357 | 357 | echo $error; |
358 | 358 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | { |
399 | 399 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
400 | 400 | |
401 | - return (isset($matches[0])) ? true : false; |
|
401 | + return (isset($matches[0]))?true : false; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | function botDeviceUidIsSet($config) |
@@ -467,25 +467,25 @@ discard block |
||
467 | 467 | $timediff_inDays = (string)$timediff->format('%d'); |
468 | 468 | $timediff_inMonth = (string)$timediff->format('%m'); |
469 | 469 | |
470 | - if($timediff_inMonth!=0) |
|
470 | + if($timediff_inMonth != 0) |
|
471 | 471 | { |
472 | 472 | $timediff = $timediff_inMonth . "m"; |
473 | 473 | } |
474 | 474 | else |
475 | 475 | { |
476 | - if($timediff_inDays!=0) |
|
476 | + if($timediff_inDays != 0) |
|
477 | 477 | { |
478 | 478 | $timediff = $timediff_inDays . "d"; |
479 | 479 | } |
480 | 480 | else |
481 | 481 | { |
482 | - if($timediff_inHours!=0) |
|
482 | + if($timediff_inHours != 0) |
|
483 | 483 | { |
484 | 484 | $timediff = $timediff_inHours . "h"; |
485 | 485 | } |
486 | 486 | else |
487 | 487 | { |
488 | - if($timediff_inMinutes!=0) |
|
488 | + if($timediff_inMinutes != 0) |
|
489 | 489 | { |
490 | 490 | $timediff = $timediff_inMinutes . "m"; |
491 | 491 | } |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | |
500 | 500 | |
501 | 501 | ?> |
502 | - <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;"> |
|
502 | + <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"]; ?>;"> |
|
503 | 503 | <content> |
504 | 504 | <?php |
505 | 505 | if(isset($post["image_url"])) { |
@@ -514,24 +514,24 @@ discard block |
||
514 | 514 | <?php |
515 | 515 | if($isDetailedView) |
516 | 516 | {?> |
517 | - <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
|
517 | + <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>" rel="nofollow"> |
|
518 | 518 | <?php } |
519 | 519 | else |
520 | 520 | {?> |
521 | - <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
521 | + <a href="index.php?vote=up&postID=<?php echo $post['post_id']; ?>" rel="nofollow"> |
|
522 | 522 | <?php } ?> |
523 | 523 | <i class="fa fa-angle-up fa-3x"></i> |
524 | 524 | </a> |
525 | 525 | <br /> |
526 | - <?php echo $post["vote_count"];?><br /> |
|
526 | + <?php echo $post["vote_count"]; ?><br /> |
|
527 | 527 | <?php |
528 | 528 | if($isDetailedView) |
529 | 529 | {?> |
530 | - <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
|
530 | + <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>" rel="nofollow"> |
|
531 | 531 | <?php } |
532 | 532 | else |
533 | 533 | {?> |
534 | - <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
534 | + <a href="index.php?vote=down&postID=<?php echo $post['post_id']; ?>" rel="nofollow"> |
|
535 | 535 | <?php } ?> |
536 | 536 | <i class="fa fa-angle-down fa-3x"></i> |
537 | 537 | </a> |
@@ -543,14 +543,14 @@ discard block |
||
543 | 543 | <td class="time"> |
544 | 544 | <span class="tip" data-tooltip="Time"> |
545 | 545 | <i class="fa fa-clock-o"></i> |
546 | - <?php echo $timediff;?> |
|
547 | - <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
|
546 | + <?php echo $timediff; ?> |
|
547 | + <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span> |
|
548 | 548 | </span> |
549 | 549 | </td> |
550 | 550 | <td class="comments"> |
551 | 551 | <?php if(!$isDetailedView) {?> |
552 | 552 | <span data-tooltip="Comments"> |
553 | - <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
|
553 | + <a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $post["post_id"]; ?>"> |
|
554 | 554 | <i class="fa fa-commenting-o"></i> |
555 | 555 | <?php if(array_key_exists("child_count", $post)) { |
556 | 556 | echo $post["child_count"]; |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | { |
580 | 580 | ?> |
581 | 581 | <span data-tooltip="Author"> |
582 | - <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
|
582 | + <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> | |
|
583 | 583 | </span> |
584 | 584 | <?php |
585 | 585 | } |
@@ -589,8 +589,8 @@ discard block |
||
589 | 589 | |
590 | 590 | <span class="tip" data-tooltip="Distance"> |
591 | 591 | <i class="fa fa-map-marker"></i> |
592 | - <?php echo $post['distance'];?> km |
|
593 | - <span class="tiptext"><?php echo $post['location']['name'];?></span> |
|
592 | + <?php echo $post['distance']; ?> km |
|
593 | + <span class="tiptext"><?php echo $post['location']['name']; ?></span> |
|
594 | 594 | </span> |
595 | 595 | </td> |
596 | 596 | </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 | } |
@@ -320,14 +329,16 @@ discard block |
||
320 | 329 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
321 | 330 | VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')"); |
322 | 331 | |
323 | - if($result === false){ |
|
332 | + if($result === false) |
|
333 | + { |
|
324 | 334 | $error = db_error(); |
325 | 335 | echo $error; |
326 | 336 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
327 | 337 | } |
328 | 338 | } |
329 | 339 | |
330 | -function registerAccount(Location $location) { |
|
340 | +function registerAccount(Location $location) |
|
341 | +{ |
|
331 | 342 | $accountCreator = new CreateUser(); |
332 | 343 | $accountCreator->setLocation($location); |
333 | 344 | $data = $accountCreator->execute(); |
@@ -352,7 +363,8 @@ discard block |
||
352 | 363 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
353 | 364 | |
354 | 365 | $success = TRUE; |
355 | - if($result === false){ |
|
366 | + if($result === false) |
|
367 | + { |
|
356 | 368 | $error = db_error(); |
357 | 369 | echo $error; |
358 | 370 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -363,7 +375,7 @@ discard block |
||
363 | 375 | } |
364 | 376 | |
365 | 377 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
366 | -{ |
|
378 | +{ |
|
367 | 379 | $accountCreator = new GetPosts(); |
368 | 380 | $accountCreator->setLastPostId($lastPostId); |
369 | 381 | $accountCreator->setAccessToken($accessToken); |
@@ -452,7 +464,8 @@ discard block |
||
452 | 464 | } |
453 | 465 | |
454 | 466 | function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE) |
455 | -{ //ToDO |
|
467 | +{ |
|
468 | +//ToDO |
|
456 | 469 | //Replace # with link |
457 | 470 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
458 | 471 | |
@@ -502,10 +515,12 @@ discard block |
||
502 | 515 | <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;"> |
503 | 516 | <content> |
504 | 517 | <?php |
505 | - if(isset($post["image_url"])) { |
|
518 | + if(isset($post["image_url"])) |
|
519 | + { |
|
506 | 520 | echo '<img src="' . $post["image_url"] . '">'; |
507 | 521 | } |
508 | - else { |
|
522 | + else |
|
523 | + { |
|
509 | 524 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post["message"]))); |
510 | 525 | } |
511 | 526 | ?> |
@@ -513,11 +528,13 @@ discard block |
||
513 | 528 | <aside> |
514 | 529 | <?php |
515 | 530 | if($isDetailedView) |
516 | - {?> |
|
531 | + { |
|
532 | +?> |
|
517 | 533 | <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
518 | 534 | <?php } |
519 | - else |
|
520 | - {?> |
|
535 | +else |
|
536 | + { |
|
537 | +?> |
|
521 | 538 | <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
522 | 539 | <?php } ?> |
523 | 540 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -526,11 +543,13 @@ discard block |
||
526 | 543 | <?php echo $post["vote_count"];?><br /> |
527 | 544 | <?php |
528 | 545 | if($isDetailedView) |
529 | - {?> |
|
546 | + { |
|
547 | +?> |
|
530 | 548 | <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow"> |
531 | 549 | <?php } |
532 | - else |
|
533 | - {?> |
|
550 | +else |
|
551 | + { |
|
552 | +?> |
|
534 | 553 | <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow"> |
535 | 554 | <?php } ?> |
536 | 555 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -548,13 +567,19 @@ discard block |
||
548 | 567 | </span> |
549 | 568 | </td> |
550 | 569 | <td class="comments"> |
551 | - <?php if(!$isDetailedView) {?> |
|
570 | + <?php if(!$isDetailedView) |
|
571 | +{ |
|
572 | +?> |
|
552 | 573 | <span data-tooltip="Comments"> |
553 | 574 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
554 | 575 | <i class="fa fa-commenting-o"></i> |
555 | - <?php if(array_key_exists("child_count", $post)) { |
|
576 | + <?php if(array_key_exists("child_count", $post)) |
|
577 | +{ |
|
556 | 578 | echo $post["child_count"]; |
557 | - } else echo "0"; |
|
579 | + } |
|
580 | + else { |
|
581 | + echo "0"; |
|
582 | + } |
|
558 | 583 | ?> |
559 | 584 | </a> |
560 | 585 | </span> |