@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | class GetCaptcha extends AbstractRequest |
3 | 3 | { |
4 | - function getApiEndPoint() |
|
5 | - { |
|
6 | - return '/v3/user/verification/imageCaptcha/'; |
|
7 | - } |
|
8 | - function getPayload() |
|
9 | - { |
|
10 | - return array( |
|
11 | - ); |
|
12 | - } |
|
13 | - function getMethod() |
|
14 | - { |
|
15 | - return 'GET'; |
|
16 | - } |
|
4 | + function getApiEndPoint() |
|
5 | + { |
|
6 | + return '/v3/user/verification/imageCaptcha/'; |
|
7 | + } |
|
8 | + function getPayload() |
|
9 | + { |
|
10 | + return array( |
|
11 | + ); |
|
12 | + } |
|
13 | + function getMethod() |
|
14 | + { |
|
15 | + return 'GET'; |
|
16 | + } |
|
17 | 17 | } |
18 | 18 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | class GetCaptcha extends AbstractRequest |
3 | -{ |
|
3 | +{ |
|
4 | 4 | function getApiEndPoint() |
5 | 5 | { |
6 | 6 | return '/v3/user/verification/imageCaptcha/'; |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | class Jodel |
4 | 4 | { |
5 | - public $jodel; |
|
5 | + public $jodel; |
|
6 | 6 | |
7 | 7 | |
8 | 8 | } |
9 | 9 | \ No newline at end of file |
@@ -43,7 +43,7 @@ |
||
43 | 43 | { |
44 | 44 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
45 | 45 | |
46 | - return (isset($matches[0])) ? true : false; |
|
46 | + return (isset($matches[0])) ? TRUE : FALSE; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | function configPropertyExists($config, $property) |
@@ -37,6 +37,9 @@ discard block |
||
37 | 37 | die(); |
38 | 38 | } |
39 | 39 | |
40 | +/** |
|
41 | + * @param string $msg |
|
42 | + */ |
|
40 | 43 | function user_log($msg) |
41 | 44 | { |
42 | 45 | $log = $msg . PHP_EOL; |
@@ -51,6 +54,9 @@ discard block |
||
51 | 54 | return (isset($matches[0])) ? true : false; |
52 | 55 | } |
53 | 56 | |
57 | +/** |
|
58 | + * @param string $property |
|
59 | + */ |
|
54 | 60 | function configPropertyExists($config, $property) |
55 | 61 | { |
56 | 62 | if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | function isUserVoter() |
76 | 76 | { |
77 | 77 | if(isset($_COOKIE['JodelVoterPassword'])) |
78 | - { |
|
78 | + { |
|
79 | 79 | $db = new DatabaseConnect(); |
80 | 80 | $result = $db->query("SELECT id FROM users WHERE user_token = '" . $_COOKIE['JodelVoterPassword'] . "'"); |
81 | 81 | if($result->num_rows == 0) |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | if(configPropertyExists($config, 'karmaDeviceUid')) |
150 | - { |
|
150 | + { |
|
151 | 151 | $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
152 | 152 | } |
153 | 153 | else |
@@ -220,7 +220,8 @@ discard block |
||
220 | 220 | |
221 | 221 | if(isset($_GET['view'])) |
222 | 222 | { |
223 | - switch ($_GET['view']) { |
|
223 | + switch ($_GET['view']) |
|
224 | + { |
|
224 | 225 | case 'discussed': |
225 | 226 | $view = 'discussed'; |
226 | 227 | break; |
@@ -49,27 +49,27 @@ discard block |
||
49 | 49 | |
50 | 50 | function user_log($msg) |
51 | 51 | { |
52 | - $log = $msg . PHP_EOL; |
|
53 | - file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
52 | + $log = $msg . PHP_EOL; |
|
53 | + file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | function isUserBot() |
57 | 57 | { |
58 | - preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
58 | + preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
59 | 59 | |
60 | - return (isset($matches[0])) ? true : false; |
|
60 | + return (isset($matches[0])) ? true : false; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | function configPropertyExists($config, $property) |
64 | 64 | { |
65 | - if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
66 | - { |
|
67 | - return FALSE; |
|
68 | - } |
|
69 | - else |
|
70 | - { |
|
71 | - return TRUE; |
|
72 | - } |
|
65 | + if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
66 | + { |
|
67 | + return FALSE; |
|
68 | + } |
|
69 | + else |
|
70 | + { |
|
71 | + return TRUE; |
|
72 | + } |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | function isUserVoter() |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | |
111 | 111 | function isDeviceUidInDatabase($deviceUid) |
112 | 112 | { |
113 | - $db = new DatabaseConnect(); |
|
114 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
113 | + $db = new DatabaseConnect(); |
|
114 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
115 | 115 | |
116 | - if ($result->num_rows > 0) |
|
117 | - { |
|
118 | - $db->close(); |
|
119 | - return TRUE; |
|
120 | - } |
|
121 | - else |
|
122 | - { |
|
123 | - $db->close(); |
|
124 | - return FALSE; |
|
125 | - } |
|
116 | + if ($result->num_rows > 0) |
|
117 | + { |
|
118 | + $db->close(); |
|
119 | + return TRUE; |
|
120 | + } |
|
121 | + else |
|
122 | + { |
|
123 | + $db->close(); |
|
124 | + return FALSE; |
|
125 | + } |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | //Check if it's a Spider or Google Bot |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | if(configPropertyExists($config, 'karmaDeviceUid')) |
152 | - { |
|
153 | - $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
154 | - } |
|
155 | - else |
|
156 | - { |
|
157 | - error_log("No Karma deviceUid set in config file"); |
|
152 | + { |
|
153 | + $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
154 | + } |
|
155 | + else |
|
156 | + { |
|
157 | + error_log("No Karma deviceUid set in config file"); |
|
158 | 158 | $jodelAccountForKarma = new JodelAccount($deviceUid); |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | 161 | /* |
162 | 162 | * Cunstruct View |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | function user_log($msg) |
51 | 51 | { |
52 | - $log = $msg . PHP_EOL; |
|
52 | + $log = $msg . PHP_EOL; |
|
53 | 53 | file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
54 | 54 | } |
55 | 55 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
59 | 59 | |
60 | - return (isset($matches[0])) ? true : false; |
|
60 | + return (isset($matches[0]))?true : false; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | function configPropertyExists($config, $property) |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | function isUserAdmin() |
99 | 99 | { |
100 | 100 | global $config; |
101 | - if (isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
|
101 | + if(isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
|
102 | 102 | { |
103 | 103 | return TRUE; |
104 | 104 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | function isDeviceUidInDatabase($deviceUid) |
112 | 112 | { |
113 | 113 | $db = new DatabaseConnect(); |
114 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
114 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
115 | 115 | |
116 | - if ($result->num_rows > 0) |
|
116 | + if($result->num_rows > 0) |
|
117 | 117 | { |
118 | 118 | $db->close(); |
119 | 119 | return TRUE; |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId'])) |
138 | 138 | { |
139 | 139 | $jodelAccountForView = new JodelAccount(); |
140 | - setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time()+60*60*24*365*10); |
|
141 | - user_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
140 | + setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time() + 60 * 60 * 24 * 365 * 10); |
|
141 | + user_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
142 | 142 | |
143 | 143 | } |
144 | 144 | else |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | if(isset($_GET['search'])) |
168 | 168 | { |
169 | 169 | |
170 | - user_log('User with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] searched for ' . $_GET['search']); |
|
170 | + user_log('User with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] searched for ' . $_GET['search']); |
|
171 | 171 | |
172 | 172 | if(substr($_GET['search'], 0, 1) === "#") |
173 | 173 | { |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | |
223 | 223 | if(isset($_GET['view'])) |
224 | 224 | { |
225 | - switch ($_GET['view']) { |
|
225 | + switch($_GET['view']) { |
|
226 | 226 | case 'discussed': |
227 | 227 | $view = 'discussed'; |
228 | 228 | break; |
@@ -385,6 +385,9 @@ |
||
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | + /** |
|
389 | + * @param Location $location |
|
390 | + */ |
|
388 | 391 | function registerAccount($location) { |
389 | 392 | $accountCreator = new CreateUser(); |
390 | 393 | $accountCreator->setLocation($location); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
87 | 87 | { |
88 | 88 | return TRUE; |
89 | - } |
|
89 | + } |
|
90 | 90 | else |
91 | 91 | { |
92 | 92 | return FALSE; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if(substr($_GET['city'], 0, 1) === '#') |
100 | 100 | { |
101 | 101 | return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
102 | - } |
|
102 | + } |
|
103 | 103 | else |
104 | 104 | { |
105 | 105 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
@@ -272,7 +272,8 @@ discard block |
||
272 | 272 | if(isset($_POST['color'])) |
273 | 273 | { |
274 | 274 | $color = $_POST['color']; |
275 | - switch ($color) { |
|
275 | + switch ($color) |
|
276 | + { |
|
276 | 277 | case '8ABDB0': |
277 | 278 | $color = '8ABDB0'; |
278 | 279 | break; |
@@ -369,7 +370,8 @@ discard block |
||
369 | 370 | expiration_date='" . $expiration_date . "' |
370 | 371 | WHERE device_uid='" . $device_uid . "'"); |
371 | 372 | |
372 | - if($result === false){ |
|
373 | + if($result === false) |
|
374 | + { |
|
373 | 375 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
374 | 376 | } |
375 | 377 | } |
@@ -449,14 +451,16 @@ discard block |
||
449 | 451 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
450 | 452 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
451 | 453 | |
452 | - if($result === false){ |
|
454 | + if($result === false) |
|
455 | + { |
|
453 | 456 | $error = db_error(); |
454 | 457 | echo $error; |
455 | 458 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
456 | 459 | } |
457 | 460 | } |
458 | 461 | |
459 | - function registerAccount($location) { |
|
462 | + function registerAccount($location) |
|
463 | + { |
|
460 | 464 | $accountCreator = new CreateUser(); |
461 | 465 | $accountCreator->setLocation($location); |
462 | 466 | $data = $accountCreator->execute(); |
@@ -481,7 +485,8 @@ discard block |
||
481 | 485 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
482 | 486 | |
483 | 487 | $success = TRUE; |
484 | - if($result === false){ |
|
488 | + if($result === false) |
|
489 | + { |
|
485 | 490 | $error = $db->error(); |
486 | 491 | echo $error; |
487 | 492 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $this->refreshToken(); |
37 | 37 | } |
38 | - $this->accessToken = $this->getAccessToken(); |
|
38 | + $this->accessToken = $this->getAccessToken(); |
|
39 | 39 | |
40 | 40 | /* if($this->isAccountVerified() != 1) |
41 | 41 | { |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | $db = new DatabaseConnect(); |
109 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
109 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
110 | 110 | |
111 | 111 | $location = new Location(); |
112 | 112 | |
113 | - if ($result->num_rows > 0) |
|
113 | + if($result->num_rows > 0) |
|
114 | 114 | { |
115 | 115 | // output data of each row |
116 | 116 | while($row = $result->fetch_assoc()) |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | else |
184 | 184 | { |
185 | - user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
185 | + user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | function getLocation() |
195 | 195 | { |
196 | 196 | $db = new DatabaseConnect(); |
197 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
197 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
198 | 198 | |
199 | 199 | $location = new Location(); |
200 | 200 | |
201 | - if ($result->num_rows > 0) |
|
201 | + if($result->num_rows > 0) |
|
202 | 202 | { |
203 | 203 | // output data of each row |
204 | 204 | while($row = $result->fetch_assoc()) |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | if(isset($_POST['color'])) |
322 | 322 | { |
323 | 323 | $color = $_POST['color']; |
324 | - switch ($color) { |
|
324 | + switch($color) { |
|
325 | 325 | case '8ABDB0': |
326 | 326 | $color = '8ABDB0'; |
327 | 327 | break; |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | $db = new DatabaseConnect(); |
390 | 390 | $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
391 | 391 | |
392 | - if ($result->num_rows > 0) |
|
392 | + if($result->num_rows > 0) |
|
393 | 393 | { |
394 | 394 | // output data of each row |
395 | 395 | while($row = $result->fetch_assoc()) |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | expiration_date='" . $expiration_date . "' |
429 | 429 | WHERE device_uid='" . $device_uid . "'"); |
430 | 430 | |
431 | - if($result === false){ |
|
431 | + if($result === false) { |
|
432 | 432 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
433 | 433 | } |
434 | 434 | } |
@@ -438,11 +438,11 @@ discard block |
||
438 | 438 | function getAccessToken() |
439 | 439 | { |
440 | 440 | $db = new DatabaseConnect(); |
441 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
441 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
442 | 442 | |
443 | 443 | $accessToken; |
444 | 444 | |
445 | - if ($result->num_rows > 0) |
|
445 | + if($result->num_rows > 0) |
|
446 | 446 | { |
447 | 447 | // output data of each row |
448 | 448 | while($row = $result->fetch_assoc()) |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
509 | 509 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
510 | 510 | |
511 | - if($result === false){ |
|
511 | + if($result === false) { |
|
512 | 512 | $error = db_error(); |
513 | 513 | echo $error; |
514 | 514 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -536,11 +536,11 @@ discard block |
||
536 | 536 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
537 | 537 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
538 | 538 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
539 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
539 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
540 | 540 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
541 | 541 | |
542 | 542 | $success = TRUE; |
543 | - if($result === false){ |
|
543 | + if($result === false) { |
|
544 | 544 | $error = $db->error(); |
545 | 545 | echo $error; |
546 | 546 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -93,16 +93,16 @@ discard block |
||
93 | 93 | { |
94 | 94 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
95 | 95 | $result = Requests::post($url); |
96 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
96 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
97 | 97 | { |
98 | 98 | error_log('Error locationEquals'); |
99 | 99 | return FALSE; |
100 | 100 | } |
101 | 101 | else |
102 | 102 | { |
103 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
104 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
105 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
103 | + $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name']; |
|
104 | + $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']; |
|
105 | + $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | $db = new DatabaseConnect(); |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | { |
147 | 147 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
148 | 148 | $result = Requests::post($url); |
149 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
149 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
150 | 150 | { |
151 | 151 | return "0 results"; |
152 | 152 | } |
153 | 153 | else |
154 | 154 | { |
155 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
156 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
157 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
155 | + $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name']; |
|
156 | + $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']; |
|
157 | + $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']; |
|
158 | 158 | |
159 | 159 | $location = new Location(); |
160 | 160 | $location->setLat($lat); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | lng='" . $lng . "' |
177 | 177 | WHERE access_token='" . $this->accessToken . "'"); |
178 | 178 | |
179 | - if($result === false) |
|
179 | + if($result === FALSE) |
|
180 | 180 | { |
181 | 181 | echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
182 | 182 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $accountCreator->postId = htmlspecialchars($postId); |
278 | 278 | $data = $accountCreator->execute(); |
279 | 279 | |
280 | - user_log('User voted: ' . print_r($data, true)); |
|
280 | + user_log('User voted: ' . print_r($data, TRUE)); |
|
281 | 281 | |
282 | 282 | if(array_key_exists('post', $data)) |
283 | 283 | { |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } |
291 | 291 | else |
292 | 292 | { |
293 | - error_log('Could not vote: ' . print_r($data, true)); |
|
293 | + error_log('Could not vote: ' . print_r($data, TRUE)); |
|
294 | 294 | return FALSE; |
295 | 295 | } |
296 | 296 | } |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | if($data != 'Success') |
357 | 357 | { |
358 | - error_log('Could not set location befor Post: ' . print_r($data, true)); |
|
358 | + error_log('Could not set location befor Post: ' . print_r($data, TRUE)); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | $accountCreator->location = $this->location; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | return $errorMsg; |
378 | 378 | } |
379 | 379 | |
380 | - user_log('User posted: ' . print_r($data, true)); |
|
380 | + user_log('User posted: ' . print_r($data, TRUE)); |
|
381 | 381 | |
382 | 382 | if(isset($_POST['ancestor'])) |
383 | 383 | { |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | expiration_date='" . $expiration_date . "' |
436 | 436 | WHERE device_uid='" . $device_uid . "'"); |
437 | 437 | |
438 | - if($result === false){ |
|
438 | + if($result === FALSE){ |
|
439 | 439 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
440 | 440 | } |
441 | 441 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | |
484 | 484 | $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
485 | 485 | |
486 | - if($result === false) |
|
486 | + if($result === FALSE) |
|
487 | 487 | { |
488 | 488 | $error = db_error(); |
489 | 489 | echo $error; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
516 | 516 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
517 | 517 | |
518 | - if($result === false){ |
|
518 | + if($result === FALSE){ |
|
519 | 519 | $error = db_error(); |
520 | 520 | echo $error; |
521 | 521 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
548 | 548 | |
549 | 549 | $success = TRUE; |
550 | - if($result === false){ |
|
550 | + if($result === FALSE){ |
|
551 | 551 | $error = $db->error(); |
552 | 552 | echo $error; |
553 | 553 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -2,47 +2,47 @@ discard block |
||
2 | 2 | |
3 | 3 | class JodelAccount |
4 | 4 | { |
5 | - public $accessToken; |
|
6 | - public $expirationDate; |
|
7 | - public $refreshToken; |
|
8 | - public $distinctId; |
|
9 | - public $deviceUid; |
|
10 | - |
|
11 | - //is the Account a Bot or Spider? |
|
12 | - public $isBot; |
|
5 | + public $accessToken; |
|
6 | + public $expirationDate; |
|
7 | + public $refreshToken; |
|
8 | + public $distinctId; |
|
9 | + public $deviceUid; |
|
10 | + |
|
11 | + //is the Account a Bot or Spider? |
|
12 | + public $isBot; |
|
13 | 13 | |
14 | - // array of voted Jodels |
|
15 | - public $votes; |
|
14 | + // array of voted Jodels |
|
15 | + public $votes; |
|
16 | 16 | |
17 | - //Location of the Account |
|
18 | - public $location; |
|
17 | + //Location of the Account |
|
18 | + public $location; |
|
19 | 19 | |
20 | - function __construct($deviceUid = NULL, $isBot = FALSE) |
|
21 | - { |
|
22 | - if($deviceUid == NULL) |
|
23 | - { |
|
24 | - $this->deviceUid = $this->createAccount(); |
|
25 | - } |
|
26 | - else |
|
27 | - { |
|
28 | - $this->deviceUid = $deviceUid; |
|
29 | - } |
|
20 | + function __construct($deviceUid = NULL, $isBot = FALSE) |
|
21 | + { |
|
22 | + if($deviceUid == NULL) |
|
23 | + { |
|
24 | + $this->deviceUid = $this->createAccount(); |
|
25 | + } |
|
26 | + else |
|
27 | + { |
|
28 | + $this->deviceUid = $deviceUid; |
|
29 | + } |
|
30 | 30 | |
31 | - $this->isBot = $isBot; |
|
32 | - $this->location = $this->getLocation(); |
|
31 | + $this->isBot = $isBot; |
|
32 | + $this->location = $this->getLocation(); |
|
33 | 33 | |
34 | - if(!$this->isTokenFresh()) |
|
35 | - { |
|
36 | - $this->refreshToken(); |
|
37 | - } |
|
38 | - $this->accessToken = $this->getAccessToken(); |
|
34 | + if(!$this->isTokenFresh()) |
|
35 | + { |
|
36 | + $this->refreshToken(); |
|
37 | + } |
|
38 | + $this->accessToken = $this->getAccessToken(); |
|
39 | 39 | |
40 | - /* if($this->isAccountVerified() != 1) |
|
40 | + /* if($this->isAccountVerified() != 1) |
|
41 | 41 | { |
42 | 42 | $this->showCaptcha(); |
43 | 43 | //$this->verifyCaptcha(); |
44 | 44 | }*/ |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | 47 | /* |
48 | 48 | function showCaptcha() |
@@ -71,503 +71,503 @@ discard block |
||
71 | 71 | } |
72 | 72 | */ |
73 | 73 | |
74 | - function getCaptcha() |
|
75 | - { |
|
76 | - $accountCreator = new GetCaptcha(); |
|
77 | - $accountCreator->setAccessToken($this->accessToken); |
|
78 | - $captcha = $accountCreator->execute(); |
|
74 | + function getCaptcha() |
|
75 | + { |
|
76 | + $accountCreator = new GetCaptcha(); |
|
77 | + $accountCreator->setAccessToken($this->accessToken); |
|
78 | + $captcha = $accountCreator->execute(); |
|
79 | 79 | |
80 | - return array("image_url" => $captcha['image_url'], "key" => $captcha['key']); |
|
81 | - } |
|
80 | + return array("image_url" => $captcha['image_url'], "key" => $captcha['key']); |
|
81 | + } |
|
82 | 82 | |
83 | - function isAccountVerified() |
|
84 | - { |
|
85 | - $accountCreator = new GetUserConfig(); |
|
86 | - $accountCreator->setAccessToken($this->accessToken); |
|
87 | - $data = $accountCreator->execute(); |
|
83 | + function isAccountVerified() |
|
84 | + { |
|
85 | + $accountCreator = new GetUserConfig(); |
|
86 | + $accountCreator->setAccessToken($this->accessToken); |
|
87 | + $data = $accountCreator->execute(); |
|
88 | 88 | |
89 | - //error_log(print_r($data, true)); |
|
89 | + //error_log(print_r($data, true)); |
|
90 | 90 | |
91 | - return $data['verified']; |
|
92 | - } |
|
91 | + return $data['verified']; |
|
92 | + } |
|
93 | 93 | |
94 | - function locationEquals($city) |
|
95 | - { |
|
96 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
97 | - $result = Requests::post($url); |
|
98 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
99 | - { |
|
100 | - error_log('Error locationEquals'); |
|
101 | - return FALSE; |
|
102 | - } |
|
103 | - else |
|
104 | - { |
|
105 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
106 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
107 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
108 | - } |
|
94 | + function locationEquals($city) |
|
95 | + { |
|
96 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
97 | + $result = Requests::post($url); |
|
98 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
99 | + { |
|
100 | + error_log('Error locationEquals'); |
|
101 | + return FALSE; |
|
102 | + } |
|
103 | + else |
|
104 | + { |
|
105 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
106 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
107 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
108 | + } |
|
109 | 109 | |
110 | - $db = new DatabaseConnect(); |
|
111 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
110 | + $db = new DatabaseConnect(); |
|
111 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
112 | 112 | |
113 | - $location = new Location(); |
|
113 | + $location = new Location(); |
|
114 | 114 | |
115 | - if ($result->num_rows > 0) |
|
116 | - { |
|
117 | - // output data of each row |
|
118 | - while($row = $result->fetch_assoc()) |
|
119 | - { |
|
120 | - $location->setLat($row['lat']); |
|
121 | - $location->setLng($row['lng']); |
|
122 | - $location->setCityName($row['name']); |
|
123 | - } |
|
124 | - } |
|
125 | - else |
|
126 | - { |
|
127 | - error_log("Error no Location found - getLocation"); |
|
128 | - } |
|
115 | + if ($result->num_rows > 0) |
|
116 | + { |
|
117 | + // output data of each row |
|
118 | + while($row = $result->fetch_assoc()) |
|
119 | + { |
|
120 | + $location->setLat($row['lat']); |
|
121 | + $location->setLng($row['lng']); |
|
122 | + $location->setCityName($row['name']); |
|
123 | + } |
|
124 | + } |
|
125 | + else |
|
126 | + { |
|
127 | + error_log("Error no Location found - getLocation"); |
|
128 | + } |
|
129 | 129 | |
130 | - if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
|
131 | - { |
|
132 | - return TRUE; |
|
133 | - } |
|
134 | - else |
|
135 | - { |
|
136 | - return FALSE; |
|
137 | - } |
|
138 | - } |
|
130 | + if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
|
131 | + { |
|
132 | + return TRUE; |
|
133 | + } |
|
134 | + else |
|
135 | + { |
|
136 | + return FALSE; |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - function setLocation() |
|
141 | - { |
|
142 | - //Is Channel or City |
|
143 | - if(substr($_GET['city'], 0, 1) === '#') |
|
144 | - { |
|
145 | - return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
146 | - } |
|
147 | - else |
|
148 | - { |
|
149 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
150 | - $result = Requests::post($url); |
|
151 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
152 | - { |
|
153 | - return "0 results"; |
|
154 | - } |
|
155 | - else |
|
156 | - { |
|
157 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
158 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
159 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
160 | - |
|
161 | - $location = new Location(); |
|
162 | - $location->setLat($lat); |
|
163 | - $location->setLng($lng); |
|
164 | - $location->setCityName($name); |
|
165 | - $accountCreator = new UpdateLocation(); |
|
166 | - $accountCreator->setLocation($location); |
|
167 | - $accountCreator->setAccessToken($this->accessToken); |
|
168 | - $data = $accountCreator->execute(); |
|
169 | - |
|
170 | - //safe location to db |
|
171 | - $db = new DatabaseConnect(); |
|
172 | - |
|
173 | - if($data == 'Success') |
|
174 | - { |
|
175 | - $result = $db->query("UPDATE accounts |
|
140 | + function setLocation() |
|
141 | + { |
|
142 | + //Is Channel or City |
|
143 | + if(substr($_GET['city'], 0, 1) === '#') |
|
144 | + { |
|
145 | + return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
146 | + } |
|
147 | + else |
|
148 | + { |
|
149 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
150 | + $result = Requests::post($url); |
|
151 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
152 | + { |
|
153 | + return "0 results"; |
|
154 | + } |
|
155 | + else |
|
156 | + { |
|
157 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
158 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
159 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
160 | + |
|
161 | + $location = new Location(); |
|
162 | + $location->setLat($lat); |
|
163 | + $location->setLng($lng); |
|
164 | + $location->setCityName($name); |
|
165 | + $accountCreator = new UpdateLocation(); |
|
166 | + $accountCreator->setLocation($location); |
|
167 | + $accountCreator->setAccessToken($this->accessToken); |
|
168 | + $data = $accountCreator->execute(); |
|
169 | + |
|
170 | + //safe location to db |
|
171 | + $db = new DatabaseConnect(); |
|
172 | + |
|
173 | + if($data == 'Success') |
|
174 | + { |
|
175 | + $result = $db->query("UPDATE accounts |
|
176 | 176 | SET name='" . $name . "', |
177 | 177 | lat='" . $lat . "', |
178 | 178 | lng='" . $lng . "' |
179 | 179 | WHERE access_token='" . $this->accessToken . "'"); |
180 | 180 | |
181 | - if($result === false) |
|
182 | - { |
|
183 | - echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
184 | - } |
|
185 | - else |
|
186 | - { |
|
187 | - user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - return $name; |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
181 | + if($result === false) |
|
182 | + { |
|
183 | + echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
184 | + } |
|
185 | + else |
|
186 | + { |
|
187 | + user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + return $name; |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | 195 | |
196 | - function getLocation() |
|
197 | - { |
|
198 | - $db = new DatabaseConnect(); |
|
199 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
196 | + function getLocation() |
|
197 | + { |
|
198 | + $db = new DatabaseConnect(); |
|
199 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
200 | 200 | |
201 | - $location = new Location(); |
|
201 | + $location = new Location(); |
|
202 | 202 | |
203 | - if ($result->num_rows > 0) |
|
204 | - { |
|
205 | - // output data of each row |
|
206 | - while($row = $result->fetch_assoc()) |
|
207 | - { |
|
208 | - $location->setLat($row['lat']); |
|
209 | - $location->setLng($row['lng']); |
|
210 | - $location->setCityName($row['name']); |
|
211 | - } |
|
212 | - } |
|
213 | - else |
|
214 | - { |
|
215 | - echo "Error: 0 results"; |
|
216 | - error_log("Error no Location found - getLocation"); |
|
217 | - } |
|
203 | + if ($result->num_rows > 0) |
|
204 | + { |
|
205 | + // output data of each row |
|
206 | + while($row = $result->fetch_assoc()) |
|
207 | + { |
|
208 | + $location->setLat($row['lat']); |
|
209 | + $location->setLng($row['lng']); |
|
210 | + $location->setCityName($row['name']); |
|
211 | + } |
|
212 | + } |
|
213 | + else |
|
214 | + { |
|
215 | + echo "Error: 0 results"; |
|
216 | + error_log("Error no Location found - getLocation"); |
|
217 | + } |
|
218 | 218 | |
219 | - return $location; |
|
220 | - } |
|
219 | + return $location; |
|
220 | + } |
|
221 | 221 | |
222 | - function verifyCaptcha() |
|
223 | - { |
|
224 | - if(isset($_GET['deviceUid'])) |
|
225 | - { |
|
226 | - $deviceUid = $_GET['deviceUid']; |
|
227 | - $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
228 | - } |
|
229 | - else if(isset($_POST['deviceUid'])) |
|
230 | - { |
|
231 | - $deviceUid = $_POST['deviceUid']; |
|
232 | - $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
233 | - } |
|
234 | - else |
|
235 | - { |
|
236 | - $deviceUid = $this->deviceUid; |
|
237 | - $jodelAccountForVerify = $this; |
|
238 | - } |
|
222 | + function verifyCaptcha() |
|
223 | + { |
|
224 | + if(isset($_GET['deviceUid'])) |
|
225 | + { |
|
226 | + $deviceUid = $_GET['deviceUid']; |
|
227 | + $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
228 | + } |
|
229 | + else if(isset($_POST['deviceUid'])) |
|
230 | + { |
|
231 | + $deviceUid = $_POST['deviceUid']; |
|
232 | + $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
233 | + } |
|
234 | + else |
|
235 | + { |
|
236 | + $deviceUid = $this->deviceUid; |
|
237 | + $jodelAccountForVerify = $this; |
|
238 | + } |
|
239 | 239 | |
240 | - $solution = $_GET['solution']; |
|
241 | - $solution = array_map('intval', explode('-', $solution)); |
|
240 | + $solution = $_GET['solution']; |
|
241 | + $solution = array_map('intval', explode('-', $solution)); |
|
242 | 242 | |
243 | - $accountCreator = new PostCaptcha(); |
|
244 | - $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
245 | - $accountCreator->captchaKey = $_GET['key']; |
|
246 | - $accountCreator->captchaSolution = $solution; |
|
247 | - $verified = $accountCreator->execute(); |
|
243 | + $accountCreator = new PostCaptcha(); |
|
244 | + $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
245 | + $accountCreator->captchaKey = $_GET['key']; |
|
246 | + $accountCreator->captchaSolution = $solution; |
|
247 | + $verified = $accountCreator->execute(); |
|
248 | 248 | |
249 | - if(isset($verified->status_code)) |
|
250 | - { |
|
251 | - return $verified->status_code; |
|
252 | - } |
|
253 | - return $verified['verified']; |
|
254 | - } |
|
249 | + if(isset($verified->status_code)) |
|
250 | + { |
|
251 | + return $verified->status_code; |
|
252 | + } |
|
253 | + return $verified['verified']; |
|
254 | + } |
|
255 | 255 | |
256 | - //ToDo Spider Check |
|
257 | - function votePostId($postId, $vote) |
|
258 | - { |
|
259 | - if(!$this->isBot) |
|
260 | - { |
|
261 | - if(!$this->isAccountVerified()) |
|
262 | - { |
|
256 | + //ToDo Spider Check |
|
257 | + function votePostId($postId, $vote) |
|
258 | + { |
|
259 | + if(!$this->isBot) |
|
260 | + { |
|
261 | + if(!$this->isAccountVerified()) |
|
262 | + { |
|
263 | 263 | |
264 | - } |
|
265 | - |
|
266 | - if(!$this->hasVoted($postId)) |
|
267 | - { |
|
268 | - if($vote == "up") |
|
269 | - { |
|
270 | - $accountCreator = new Upvote(); |
|
271 | - } |
|
272 | - else if($vote == "down") |
|
273 | - { |
|
274 | - $accountCreator = new Downvote(); |
|
275 | - } |
|
276 | - |
|
277 | - $accountCreator->setAccessToken($this->accessToken); |
|
278 | - $accountCreator->postId = htmlspecialchars($postId); |
|
279 | - $data = $accountCreator->execute(); |
|
280 | - |
|
281 | - user_log('User voted: ' . print_r($data, true)); |
|
282 | - |
|
283 | - if(array_key_exists('post', $data)) |
|
284 | - { |
|
285 | - $this->addVoteWithPostIdAndType($postId, $vote); |
|
286 | - return TRUE; |
|
287 | - } |
|
288 | - else if(array_key_exists('error', $data)) |
|
289 | - { |
|
290 | - error_log('Could not vote - Error: ' . $data['error']); |
|
291 | - } |
|
292 | - else |
|
293 | - { |
|
294 | - error_log('Could not vote: ' . print_r($data, true)); |
|
295 | - return FALSE; |
|
296 | - } |
|
297 | - } |
|
298 | - else |
|
299 | - { |
|
300 | - return FALSE; |
|
301 | - } |
|
302 | - } |
|
303 | - |
|
304 | - return FALSE; |
|
305 | - } |
|
264 | + } |
|
265 | + |
|
266 | + if(!$this->hasVoted($postId)) |
|
267 | + { |
|
268 | + if($vote == "up") |
|
269 | + { |
|
270 | + $accountCreator = new Upvote(); |
|
271 | + } |
|
272 | + else if($vote == "down") |
|
273 | + { |
|
274 | + $accountCreator = new Downvote(); |
|
275 | + } |
|
276 | + |
|
277 | + $accountCreator->setAccessToken($this->accessToken); |
|
278 | + $accountCreator->postId = htmlspecialchars($postId); |
|
279 | + $data = $accountCreator->execute(); |
|
280 | + |
|
281 | + user_log('User voted: ' . print_r($data, true)); |
|
282 | + |
|
283 | + if(array_key_exists('post', $data)) |
|
284 | + { |
|
285 | + $this->addVoteWithPostIdAndType($postId, $vote); |
|
286 | + return TRUE; |
|
287 | + } |
|
288 | + else if(array_key_exists('error', $data)) |
|
289 | + { |
|
290 | + error_log('Could not vote - Error: ' . $data['error']); |
|
291 | + } |
|
292 | + else |
|
293 | + { |
|
294 | + error_log('Could not vote: ' . print_r($data, true)); |
|
295 | + return FALSE; |
|
296 | + } |
|
297 | + } |
|
298 | + else |
|
299 | + { |
|
300 | + return FALSE; |
|
301 | + } |
|
302 | + } |
|
306 | 303 | |
307 | - //ToDo Spider Check |
|
308 | - function sendJodel($location, $view) |
|
309 | - { |
|
310 | - if($this->isAccountVerified() != 1) |
|
311 | - { |
|
312 | - $this->showCaptcha(); |
|
313 | - //$this->verifyCaptcha(); |
|
314 | - } |
|
304 | + return FALSE; |
|
305 | + } |
|
315 | 306 | |
316 | - $accountCreator = new SendJodel(); |
|
307 | + //ToDo Spider Check |
|
308 | + function sendJodel($location, $view) |
|
309 | + { |
|
310 | + if($this->isAccountVerified() != 1) |
|
311 | + { |
|
312 | + $this->showCaptcha(); |
|
313 | + //$this->verifyCaptcha(); |
|
314 | + } |
|
317 | 315 | |
318 | - if(isset($_POST['ancestor'])) |
|
319 | - { |
|
320 | - $ancestor = $_POST['ancestor']; |
|
321 | - $accountCreator->ancestor = $ancestor; |
|
322 | - } |
|
323 | - if(isset($_POST['color'])) |
|
324 | - { |
|
325 | - $color = $_POST['color']; |
|
326 | - switch ($color) { |
|
327 | - case '8ABDB0': |
|
328 | - $color = '8ABDB0'; |
|
329 | - break; |
|
330 | - case '9EC41C': |
|
331 | - $color = '9EC41C'; |
|
332 | - break; |
|
333 | - case '06A3CB': |
|
334 | - $color = '06A3CB'; |
|
335 | - break; |
|
336 | - case 'FFBA00': |
|
337 | - $color = 'FFBA00'; |
|
338 | - break; |
|
339 | - case 'DD5F5F': |
|
340 | - $color = 'DD5F5F'; |
|
341 | - break; |
|
342 | - case 'FF9908': |
|
343 | - $color = 'FF9908'; |
|
344 | - break; |
|
345 | - default: |
|
346 | - $color = '8ABDB0'; |
|
347 | - break; |
|
348 | - } |
|
349 | - $accountCreator->color = $color; |
|
350 | - } |
|
351 | - |
|
352 | - $accountCreatorLocation = new UpdateLocation(); |
|
353 | - $accountCreatorLocation->setLocation($location); |
|
354 | - $accountCreatorLocation->setAccessToken($this->accessToken); |
|
355 | - $data = $accountCreatorLocation->execute(); |
|
316 | + $accountCreator = new SendJodel(); |
|
317 | + |
|
318 | + if(isset($_POST['ancestor'])) |
|
319 | + { |
|
320 | + $ancestor = $_POST['ancestor']; |
|
321 | + $accountCreator->ancestor = $ancestor; |
|
322 | + } |
|
323 | + if(isset($_POST['color'])) |
|
324 | + { |
|
325 | + $color = $_POST['color']; |
|
326 | + switch ($color) { |
|
327 | + case '8ABDB0': |
|
328 | + $color = '8ABDB0'; |
|
329 | + break; |
|
330 | + case '9EC41C': |
|
331 | + $color = '9EC41C'; |
|
332 | + break; |
|
333 | + case '06A3CB': |
|
334 | + $color = '06A3CB'; |
|
335 | + break; |
|
336 | + case 'FFBA00': |
|
337 | + $color = 'FFBA00'; |
|
338 | + break; |
|
339 | + case 'DD5F5F': |
|
340 | + $color = 'DD5F5F'; |
|
341 | + break; |
|
342 | + case 'FF9908': |
|
343 | + $color = 'FF9908'; |
|
344 | + break; |
|
345 | + default: |
|
346 | + $color = '8ABDB0'; |
|
347 | + break; |
|
348 | + } |
|
349 | + $accountCreator->color = $color; |
|
350 | + } |
|
351 | + |
|
352 | + $accountCreatorLocation = new UpdateLocation(); |
|
353 | + $accountCreatorLocation->setLocation($location); |
|
354 | + $accountCreatorLocation->setAccessToken($this->accessToken); |
|
355 | + $data = $accountCreatorLocation->execute(); |
|
356 | 356 | |
357 | 357 | if($data != 'Success') |
358 | 358 | { |
359 | 359 | error_log('Could not set location befor Post: ' . print_r($data, true)); |
360 | 360 | } |
361 | 361 | |
362 | - $accountCreator->location = $this->location; |
|
362 | + $accountCreator->location = $this->location; |
|
363 | 363 | |
364 | - $image = ''; |
|
365 | - if(isset($_FILES['image']) && $_FILES['image']['size'] > 0) |
|
366 | - { |
|
367 | - $image = file_get_contents($_FILES['image']['tmp_name']); |
|
368 | - } |
|
364 | + $image = ''; |
|
365 | + if(isset($_FILES['image']) && $_FILES['image']['size'] > 0) |
|
366 | + { |
|
367 | + $image = file_get_contents($_FILES['image']['tmp_name']); |
|
368 | + } |
|
369 | 369 | |
370 | - $accountCreator->image = $image; |
|
370 | + $accountCreator->image = $image; |
|
371 | 371 | |
372 | - $accountCreator->setAccessToken($this->accessToken); |
|
373 | - $data = $accountCreator->execute(); |
|
372 | + $accountCreator->setAccessToken($this->accessToken); |
|
373 | + $data = $accountCreator->execute(); |
|
374 | 374 | |
375 | - if(isset($data['error']) && $data['error'] == 'length') |
|
376 | - { |
|
377 | - $errorMsg = 'Error: The input was to long'; |
|
378 | - return $errorMsg; |
|
379 | - } |
|
375 | + if(isset($data['error']) && $data['error'] == 'length') |
|
376 | + { |
|
377 | + $errorMsg = 'Error: The input was to long'; |
|
378 | + return $errorMsg; |
|
379 | + } |
|
380 | 380 | |
381 | - user_log('User posted: ' . print_r($data, true)); |
|
381 | + user_log('User posted: ' . print_r($data, true)); |
|
382 | 382 | |
383 | - if(isset($_POST['ancestor'])) |
|
384 | - { |
|
385 | - header('Location: ' . $view->toUrl()); |
|
386 | - exit; |
|
387 | - } |
|
388 | - else |
|
389 | - { |
|
390 | - header('Location: ' . $view->baseUrl); |
|
391 | - exit; |
|
392 | - } |
|
393 | - } |
|
383 | + if(isset($_POST['ancestor'])) |
|
384 | + { |
|
385 | + header('Location: ' . $view->toUrl()); |
|
386 | + exit; |
|
387 | + } |
|
388 | + else |
|
389 | + { |
|
390 | + header('Location: ' . $view->baseUrl); |
|
391 | + exit; |
|
392 | + } |
|
393 | + } |
|
394 | 394 | |
395 | - function isTokenFresh() |
|
396 | - { |
|
397 | - $db = new DatabaseConnect(); |
|
398 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
395 | + function isTokenFresh() |
|
396 | + { |
|
397 | + $db = new DatabaseConnect(); |
|
398 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
399 | 399 | |
400 | - if ($result->num_rows > 0) |
|
401 | - { |
|
402 | - // output data of each row |
|
403 | - while($row = $result->fetch_assoc()) |
|
404 | - { |
|
405 | - $expiration_date = $row["expiration_date"]; |
|
406 | - } |
|
407 | - } |
|
408 | - else |
|
409 | - { |
|
410 | - error_log('0 results'); |
|
411 | - } |
|
400 | + if ($result->num_rows > 0) |
|
401 | + { |
|
402 | + // output data of each row |
|
403 | + while($row = $result->fetch_assoc()) |
|
404 | + { |
|
405 | + $expiration_date = $row["expiration_date"]; |
|
406 | + } |
|
407 | + } |
|
408 | + else |
|
409 | + { |
|
410 | + error_log('0 results'); |
|
411 | + } |
|
412 | 412 | |
413 | - if($expiration_date <= time()) |
|
414 | - { |
|
415 | - return FALSE; |
|
416 | - } |
|
413 | + if($expiration_date <= time()) |
|
414 | + { |
|
415 | + return FALSE; |
|
416 | + } |
|
417 | 417 | |
418 | - return TRUE; |
|
419 | - } |
|
420 | - |
|
421 | - function refreshToken() |
|
422 | - { |
|
423 | - $accountCreator = new CreateUser(); |
|
424 | - $accountCreator->setAccessToken($this->accessToken); |
|
425 | - $accountCreator->setDeviceUid($this->deviceUid); |
|
426 | - $accountCreator->setLocation($this->location); |
|
427 | - $data = $accountCreator->execute(); |
|
428 | - |
|
429 | - $access_token = (string)$data[0]['access_token']; |
|
430 | - $expiration_date = $data[0]['expiration_date']; |
|
431 | - $device_uid = (string)$data[1]; |
|
418 | + return TRUE; |
|
419 | + } |
|
420 | + |
|
421 | + function refreshToken() |
|
422 | + { |
|
423 | + $accountCreator = new CreateUser(); |
|
424 | + $accountCreator->setAccessToken($this->accessToken); |
|
425 | + $accountCreator->setDeviceUid($this->deviceUid); |
|
426 | + $accountCreator->setLocation($this->location); |
|
427 | + $data = $accountCreator->execute(); |
|
428 | + |
|
429 | + $access_token = (string)$data[0]['access_token']; |
|
430 | + $expiration_date = $data[0]['expiration_date']; |
|
431 | + $device_uid = (string)$data[1]; |
|
432 | 432 | |
433 | - $db = new DatabaseConnect(); |
|
434 | - $result = $db->query("UPDATE accounts |
|
433 | + $db = new DatabaseConnect(); |
|
434 | + $result = $db->query("UPDATE accounts |
|
435 | 435 | SET access_token='" . $access_token . "', |
436 | 436 | expiration_date='" . $expiration_date . "' |
437 | 437 | WHERE device_uid='" . $device_uid . "'"); |
438 | 438 | |
439 | - if($result === false){ |
|
440 | - error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
|
441 | - } |
|
442 | - } |
|
439 | + if($result === false){ |
|
440 | + error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
|
441 | + } |
|
442 | + } |
|
443 | 443 | |
444 | 444 | |
445 | 445 | |
446 | - function getAccessToken() |
|
447 | - { |
|
448 | - $db = new DatabaseConnect(); |
|
449 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
446 | + function getAccessToken() |
|
447 | + { |
|
448 | + $db = new DatabaseConnect(); |
|
449 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
450 | 450 | |
451 | - $accessToken; |
|
451 | + $accessToken; |
|
452 | 452 | |
453 | - if ($result->num_rows > 0) |
|
454 | - { |
|
455 | - // output data of each row |
|
456 | - while($row = $result->fetch_assoc()) |
|
457 | - { |
|
458 | - $accessToken = $row['access_token']; |
|
459 | - } |
|
460 | - } |
|
461 | - else |
|
462 | - { |
|
463 | - error_log('Error: 0 results'); |
|
464 | - } |
|
453 | + if ($result->num_rows > 0) |
|
454 | + { |
|
455 | + // output data of each row |
|
456 | + while($row = $result->fetch_assoc()) |
|
457 | + { |
|
458 | + $accessToken = $row['access_token']; |
|
459 | + } |
|
460 | + } |
|
461 | + else |
|
462 | + { |
|
463 | + error_log('Error: 0 results'); |
|
464 | + } |
|
465 | 465 | |
466 | - return $accessToken; |
|
467 | - } |
|
466 | + return $accessToken; |
|
467 | + } |
|
468 | 468 | |
469 | 469 | |
470 | - function getKarma() |
|
471 | - { |
|
472 | - $accountCreator = new GetKarma(); |
|
473 | - $accountCreator->setAccessToken($this->accessToken); |
|
474 | - $data = $accountCreator->execute(); |
|
470 | + function getKarma() |
|
471 | + { |
|
472 | + $accountCreator = new GetKarma(); |
|
473 | + $accountCreator->setAccessToken($this->accessToken); |
|
474 | + $data = $accountCreator->execute(); |
|
475 | 475 | |
476 | - return $data['karma']; |
|
477 | - } |
|
476 | + return $data['karma']; |
|
477 | + } |
|
478 | 478 | |
479 | - function hasVoted($postId) |
|
480 | - { |
|
481 | - $db = new DatabaseConnect(); |
|
479 | + function hasVoted($postId) |
|
480 | + { |
|
481 | + $db = new DatabaseConnect(); |
|
482 | 482 | |
483 | - $postId = $db->real_escape_string($postId); |
|
483 | + $postId = $db->real_escape_string($postId); |
|
484 | 484 | |
485 | - $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
485 | + $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
486 | 486 | |
487 | - if($result === false) |
|
488 | - { |
|
489 | - $error = db_error(); |
|
490 | - echo $error; |
|
491 | - error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
492 | - } |
|
487 | + if($result === false) |
|
488 | + { |
|
489 | + $error = db_error(); |
|
490 | + echo $error; |
|
491 | + error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
492 | + } |
|
493 | 493 | |
494 | - if($result->num_rows == 0) |
|
495 | - { |
|
496 | - return FALSE; |
|
497 | - } |
|
498 | - else |
|
499 | - { |
|
500 | - return TRUE; |
|
501 | - } |
|
502 | - } |
|
494 | + if($result->num_rows == 0) |
|
495 | + { |
|
496 | + return FALSE; |
|
497 | + } |
|
498 | + else |
|
499 | + { |
|
500 | + return TRUE; |
|
501 | + } |
|
502 | + } |
|
503 | 503 | |
504 | - function addVoteWithPostIdAndType($postId, $voteType) |
|
505 | - { |
|
506 | - $db = new DatabaseConnect(); |
|
504 | + function addVoteWithPostIdAndType($postId, $voteType) |
|
505 | + { |
|
506 | + $db = new DatabaseConnect(); |
|
507 | 507 | |
508 | - $postId = $db->real_escape_string($postId); |
|
509 | - $voteType = $db->real_escape_string($voteType); |
|
508 | + $postId = $db->real_escape_string($postId); |
|
509 | + $voteType = $db->real_escape_string($voteType); |
|
510 | 510 | |
511 | - if($this->hasVoted($postId)) |
|
512 | - { |
|
513 | - return "Already voted"; |
|
514 | - } |
|
511 | + if($this->hasVoted($postId)) |
|
512 | + { |
|
513 | + return "Already voted"; |
|
514 | + } |
|
515 | 515 | |
516 | - $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
516 | + $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
517 | 517 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
518 | 518 | |
519 | - if($result === false){ |
|
520 | - $error = db_error(); |
|
521 | - echo $error; |
|
522 | - echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
523 | - } |
|
524 | - } |
|
525 | - |
|
526 | - function registerAccount($location) { |
|
527 | - $accountCreator = new CreateUser(); |
|
528 | - $accountCreator->setLocation($location); |
|
529 | - $data = $accountCreator->execute(); |
|
519 | + if($result === false){ |
|
520 | + $error = db_error(); |
|
521 | + echo $error; |
|
522 | + echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
523 | + } |
|
524 | + } |
|
525 | + |
|
526 | + function registerAccount($location) { |
|
527 | + $accountCreator = new CreateUser(); |
|
528 | + $accountCreator->setLocation($location); |
|
529 | + $data = $accountCreator->execute(); |
|
530 | 530 | |
531 | - $access_token = (string)$data[0]['access_token']; |
|
532 | - $refresh_token = (string)$data[0]['refresh_token']; |
|
533 | - $token_type = (string)$data[0]['token_type']; |
|
534 | - $expires_in = $data[0]['expires_in']; |
|
535 | - $expiration_date = $data[0]['expiration_date']; |
|
536 | - $distinct_id = (string)$data[0]['distinct_id']; |
|
537 | - $device_uid = (string)$data[1]; |
|
538 | - |
|
539 | - $name = $location->cityName; |
|
540 | - $lat = $location->lat; |
|
541 | - $lng = $location->lng; |
|
531 | + $access_token = (string)$data[0]['access_token']; |
|
532 | + $refresh_token = (string)$data[0]['refresh_token']; |
|
533 | + $token_type = (string)$data[0]['token_type']; |
|
534 | + $expires_in = $data[0]['expires_in']; |
|
535 | + $expiration_date = $data[0]['expiration_date']; |
|
536 | + $distinct_id = (string)$data[0]['distinct_id']; |
|
537 | + $device_uid = (string)$data[1]; |
|
538 | + |
|
539 | + $name = $location->cityName; |
|
540 | + $lat = $location->lat; |
|
541 | + $lng = $location->lng; |
|
542 | 542 | |
543 | - $db = new DatabaseConnect(); |
|
544 | - $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
543 | + $db = new DatabaseConnect(); |
|
544 | + $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
545 | 545 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
546 | 546 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
547 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
548 | - "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
549 | - |
|
550 | - $success = TRUE; |
|
551 | - if($result === false){ |
|
552 | - $error = $db->error(); |
|
553 | - echo $error; |
|
554 | - echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
555 | - $success = FALSE; |
|
556 | - } |
|
547 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
548 | + "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
549 | + |
|
550 | + $success = TRUE; |
|
551 | + if($result === false){ |
|
552 | + $error = $db->error(); |
|
553 | + echo $error; |
|
554 | + echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
555 | + $success = FALSE; |
|
556 | + } |
|
557 | 557 | |
558 | - return $device_uid; |
|
559 | - } |
|
558 | + return $device_uid; |
|
559 | + } |
|
560 | 560 | |
561 | - function createAccount() |
|
562 | - { |
|
563 | - $config = parse_ini_file('config/config.ini.php'); |
|
564 | - $location = new Location(); |
|
565 | - $location->setLat($config['default_lat']); |
|
566 | - $location->setLng($config['default_lng']); |
|
567 | - $location->setCityName($config['default_location']); |
|
561 | + function createAccount() |
|
562 | + { |
|
563 | + $config = parse_ini_file('config/config.ini.php'); |
|
564 | + $location = new Location(); |
|
565 | + $location->setLat($config['default_lat']); |
|
566 | + $location->setLng($config['default_lng']); |
|
567 | + $location->setCityName($config['default_location']); |
|
568 | 568 | |
569 | - $deviceUid = $this->registerAccount($location); |
|
569 | + $deviceUid = $this->registerAccount($location); |
|
570 | 570 | |
571 | - return $deviceUid; |
|
572 | - } |
|
571 | + return $deviceUid; |
|
572 | + } |
|
573 | 573 | } |
574 | 574 | \ No newline at end of file |
@@ -2,41 +2,41 @@ |
||
2 | 2 | |
3 | 3 | class GetChannel extends AbstractRequest |
4 | 4 | { |
5 | - /** |
|
6 | - * @var Location |
|
7 | - */ |
|
8 | - public $location; |
|
9 | - public $channel; |
|
10 | - public $hasPayload = FALSE; |
|
11 | - public $lastPostId = ''; |
|
12 | - public $view = 'combo'; |
|
5 | + /** |
|
6 | + * @var Location |
|
7 | + */ |
|
8 | + public $location; |
|
9 | + public $channel; |
|
10 | + public $hasPayload = FALSE; |
|
11 | + public $lastPostId = ''; |
|
12 | + public $view = 'combo'; |
|
13 | 13 | |
14 | - function getApiEndPoint() |
|
15 | - { |
|
16 | - if($this->lastPostId == '') |
|
17 | - { |
|
18 | - $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel; |
|
19 | - } |
|
20 | - else |
|
21 | - { |
|
22 | - if($this->view == 'combo') |
|
23 | - { |
|
24 | - $apiEndPoint = '/v3/posts/hashtag?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
25 | - } |
|
26 | - else |
|
27 | - { |
|
28 | - $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
29 | - } |
|
30 | - } |
|
31 | - return $apiEndPoint; |
|
32 | - } |
|
33 | - function getPayload() |
|
34 | - { |
|
35 | - return array( |
|
36 | - ); |
|
37 | - } |
|
38 | - function getMethod() |
|
39 | - { |
|
40 | - return 'GET'; |
|
41 | - } |
|
14 | + function getApiEndPoint() |
|
15 | + { |
|
16 | + if($this->lastPostId == '') |
|
17 | + { |
|
18 | + $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel; |
|
19 | + } |
|
20 | + else |
|
21 | + { |
|
22 | + if($this->view == 'combo') |
|
23 | + { |
|
24 | + $apiEndPoint = '/v3/posts/hashtag?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
25 | + } |
|
26 | + else |
|
27 | + { |
|
28 | + $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
29 | + } |
|
30 | + } |
|
31 | + return $apiEndPoint; |
|
32 | + } |
|
33 | + function getPayload() |
|
34 | + { |
|
35 | + return array( |
|
36 | + ); |
|
37 | + } |
|
38 | + function getMethod() |
|
39 | + { |
|
40 | + return 'GET'; |
|
41 | + } |
|
42 | 42 | } |
@@ -1,12 +1,24 @@ |
||
1 | 1 | <div id="sortJodelBy" class="row"> |
2 | 2 | <div class="col-3"> |
3 | - <a <?php if($view->view == 'combo')echo 'class="active"';?> href="<?php echo $view->changeView('combo')->back()->toUrl();?>"><i class="fa fa-clock-o fa-3x"></i></a> |
|
3 | + <a <?php if($view->view == 'combo') |
|
4 | +{ |
|
5 | + echo 'class="active"'; |
|
6 | +} |
|
7 | +?> href="<?php echo $view->changeView('combo')->back()->toUrl();?>"><i class="fa fa-clock-o fa-3x"></i></a> |
|
4 | 8 | </div> |
5 | 9 | <div class="col-3"> |
6 | - <a <?php if($view->view == 'discussed') echo 'class="active"';?> href="<?php echo $view->changeView('discussed')->back()->toUrl();?>"><i class="fa fa-commenting-o fa-3x"></i></a> |
|
10 | + <a <?php if($view->view == 'discussed') |
|
11 | +{ |
|
12 | + echo 'class="active"'; |
|
13 | +} |
|
14 | +?> href="<?php echo $view->changeView('discussed')->back()->toUrl();?>"><i class="fa fa-commenting-o fa-3x"></i></a> |
|
7 | 15 | </div> |
8 | 16 | <div class="col-3"> |
9 | - <a <?php if($view->view == 'popular') echo 'class="active"';?> href="<?php echo $view->changeView('popular')->back()->toUrl();?>"><i class="fa fa-angle-up fa-3x"></i></a> |
|
17 | + <a <?php if($view->view == 'popular') |
|
18 | +{ |
|
19 | + echo 'class="active"'; |
|
20 | +} |
|
21 | +?> href="<?php echo $view->changeView('popular')->back()->toUrl();?>"><i class="fa fa-angle-up fa-3x"></i></a> |
|
10 | 22 | </div> |
11 | 23 | <div class="col-3"> |
12 | 24 | <nav> |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <div id="sortJodelBy" class="row"> |
2 | 2 | <div class="col-3"> |
3 | - <a <?php if($view->view == 'combo')echo 'class="active"';?> href="<?php echo $view->changeView('combo')->back()->toUrl();?>"><i class="fa fa-clock-o fa-3x"></i></a> |
|
3 | + <a <?php if($view->view == 'combo')echo 'class="active"'; ?> href="<?php echo $view->changeView('combo')->back()->toUrl(); ?>"><i class="fa fa-clock-o fa-3x"></i></a> |
|
4 | 4 | </div> |
5 | 5 | <div class="col-3"> |
6 | - <a <?php if($view->view == 'discussed') echo 'class="active"';?> href="<?php echo $view->changeView('discussed')->back()->toUrl();?>"><i class="fa fa-commenting-o fa-3x"></i></a> |
|
6 | + <a <?php if($view->view == 'discussed') echo 'class="active"'; ?> href="<?php echo $view->changeView('discussed')->back()->toUrl(); ?>"><i class="fa fa-commenting-o fa-3x"></i></a> |
|
7 | 7 | </div> |
8 | 8 | <div class="col-3"> |
9 | - <a <?php if($view->view == 'popular') echo 'class="active"';?> href="<?php echo $view->changeView('popular')->back()->toUrl();?>"><i class="fa fa-angle-up fa-3x"></i></a> |
|
9 | + <a <?php if($view->view == 'popular') echo 'class="active"'; ?> href="<?php echo $view->changeView('popular')->back()->toUrl(); ?>"><i class="fa fa-angle-up fa-3x"></i></a> |
|
10 | 10 | </div> |
11 | 11 | <div class="col-3"> |
12 | 12 | <nav> |
13 | - <a href="<?php echo $baseUrl;?>about-us.php">about</a> |
|
13 | + <a href="<?php echo $baseUrl; ?>about-us.php">about</a> |
|
14 | 14 | </nav> |
15 | 15 | </div> |
16 | 16 | </div> |
@@ -74,7 +74,11 @@ |
||
74 | 74 | |
75 | 75 | <div id="location_mobile" class="hidden-sm-up"> |
76 | 76 | <form method="get"> |
77 | - <input type="text" id="city_mobile" name="search" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
77 | + <input type="text" id="city_mobile" name="search" placeholder="<?php if(isset($newPositionStatus)) |
|
78 | +{ |
|
79 | + echo $newPositionStatus; |
|
80 | +} |
|
81 | +?>" required> |
|
78 | 82 | |
79 | 83 | <input type="submit" id="submit_mobile" class="fa" value="" /> |
80 | 84 | </form> |
@@ -1,53 +1,53 @@ |
||
1 | 1 | <!DOCTYPE html> |
2 | 2 | <html lang="en"> |
3 | 3 | <head> |
4 | - <title><?php echo $title;?></title> |
|
4 | + <title><?php echo $title; ?></title> |
|
5 | 5 | |
6 | 6 | <meta charset="utf-8"> |
7 | 7 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
8 | 8 | <meta http-equiv="x-ua-compatible" content="ie=edge"> |
9 | 9 | |
10 | - <meta name="description" content="<?php echo $description;?>"> |
|
10 | + <meta name="description" content="<?php echo $description; ?>"> |
|
11 | 11 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app"> |
12 | 12 | |
13 | 13 | <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"> |
14 | 14 | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.1.1/ekko-lightbox.min.css" integrity="sha256-8aNQFtmxcOMVoOhLD4mrHqaKC2Ui++LmlQsoKTqxwIE=" crossorigin="anonymous" /> |
15 | - <link rel="stylesheet" href="<?php echo $baseUrl;?>css/font-awesome.min.css"> |
|
16 | - <link rel="stylesheet" href="<?php echo $baseUrl;?>style.css" type="text/css"> |
|
15 | + <link rel="stylesheet" href="<?php echo $baseUrl; ?>css/font-awesome.min.css"> |
|
16 | + <link rel="stylesheet" href="<?php echo $baseUrl; ?>style.css" type="text/css"> |
|
17 | 17 | |
18 | - <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
|
19 | - <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
|
20 | - <link rel="icon" type="image/gif" href="<?php echo $baseUrl;?>img/favicon/favicon.gif"> |
|
21 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon.png"> |
|
22 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon.png"> |
|
23 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
|
24 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
|
25 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
|
26 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
|
27 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
|
28 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
|
29 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
|
30 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
|
31 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
|
32 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
|
33 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-precomposed.png"> |
|
34 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-16x16.png" sizes="16x16"> |
|
35 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-32x32.png" sizes="32x32"> |
|
36 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-96x96.png" sizes="96x96"> |
|
37 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-160x160.png" sizes="160x160"> |
|
38 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-192x192.png" sizes="192x192"> |
|
39 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-196x196.png" sizes="196x196"> |
|
40 | - <meta name="msapplication-TileImage" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
|
18 | + <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl; ?>img/favicon/favicon.ico"> |
|
19 | + <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl; ?>img/favicon/favicon.ico"> |
|
20 | + <link rel="icon" type="image/gif" href="<?php echo $baseUrl; ?>img/favicon/favicon.gif"> |
|
21 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon.png"> |
|
22 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon.png"> |
|
23 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
|
24 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
|
25 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
|
26 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
|
27 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
|
28 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
|
29 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
|
30 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
|
31 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
|
32 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
|
33 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-precomposed.png"> |
|
34 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-16x16.png" sizes="16x16"> |
|
35 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-32x32.png" sizes="32x32"> |
|
36 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-96x96.png" sizes="96x96"> |
|
37 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-160x160.png" sizes="160x160"> |
|
38 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-192x192.png" sizes="192x192"> |
|
39 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-196x196.png" sizes="196x196"> |
|
40 | + <meta name="msapplication-TileImage" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-144x144.png"> |
|
41 | 41 | <meta name="msapplication-TileColor" content="#5682a3"> |
42 | 42 | <meta name="msapplication-navbutton-color" content="#5682a3"> |
43 | 43 | <meta name="application-name" content="JodelBlue"/> |
44 | 44 | <meta name="msapplication-tooltip" content="JodelBlue"/> |
45 | 45 | <meta name="apple-mobile-web-app-title" content="JodelBlue"/> |
46 | - <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-70x70.png"> |
|
47 | - <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
|
48 | - <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-150x150.png"> |
|
49 | - <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x150.png"> |
|
50 | - <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x310.png"> |
|
46 | + <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-70x70.png"> |
|
47 | + <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-144x144.png"> |
|
48 | + <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-150x150.png"> |
|
49 | + <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-310x150.png"> |
|
50 | + <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-310x310.png"> |
|
51 | 51 | </head> |
52 | 52 | |
53 | 53 | <body> |
@@ -47,6 +47,6 @@ |
||
47 | 47 | </content> |
48 | 48 | </article> |
49 | 49 | </div> |
50 | - <?php include 'templates/nav-bottom.php';?> |
|
50 | + <?php include 'templates/nav-bottom.php'; ?> |
|
51 | 51 | </div> |
52 | -<?php include 'templates/footer.php';?> |
|
53 | 52 | \ No newline at end of file |
53 | +<?php include 'templates/footer.php'; ?> |
|
54 | 54 | \ No newline at end of file |
@@ -129,7 +129,7 @@ |
||
129 | 129 | <?php |
130 | 130 | if(is_file(realpath(__DIR__ . '/..') . '/piwik-script.html')) |
131 | 131 | { |
132 | - include(realpath(__DIR__ . '/..') . '/piwik-script.html'); |
|
132 | + include(realpath(__DIR__ . '/..') . '/piwik-script.html'); |
|
133 | 133 | } |
134 | 134 | ?> |
135 | 135 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | crossorigin="anonymous"></script> |
6 | 6 | <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script> |
7 | 7 | <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script> |
8 | - <script src="<?php echo $baseUrl;?>js/jQueryEmoji.js"></script> |
|
8 | + <script src="<?php echo $baseUrl; ?>js/jQueryEmoji.js"></script> |
|
9 | 9 | <script src="https://cdnjs.cloudflare.com/ajax/libs/ekko-lightbox/5.1.1/ekko-lightbox.min.js" integrity="sha256-1odJPEl+KoMUaA1T7QNMGSSU/r5LCKCRC6SL8P0r2gY=" crossorigin="anonymous"></script> |
10 | 10 | |
11 | 11 | <script> |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | console.log(solution); |
38 | 38 | $.ajax({ |
39 | 39 | type: "POST", |
40 | - url: "<?php echo $baseUrl;?>vote-ajax.php?solution=" + solution + "&key="+key, |
|
40 | + url: "<?php echo $baseUrl; ?>vote-ajax.php?solution=" + solution + "&key="+key, |
|
41 | 41 | data: {"deviceUid" : deviceUid}, |
42 | 42 | success: function(result){ |
43 | 43 | var response = JSON.parse(result); |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | { |
62 | 62 | window.history.back(); |
63 | 63 | } |
64 | - <?php if(isset($includeEmojiAndAjax)){ ?> |
|
64 | + <?php if(isset($includeEmojiAndAjax)) { ?> |
|
65 | 65 | |
66 | 66 | function vote(postId, vote, obj) |
67 | 67 | { |
68 | 68 | $.ajax({ |
69 | - url: '<?php echo $baseUrl;?>vote-ajax.php?postId=' + postId + '&vote=' + vote, |
|
69 | + url: '<?php echo $baseUrl; ?>vote-ajax.php?postId=' + postId + '&vote=' + vote, |
|
70 | 70 | dataType: 'json', |
71 | 71 | async: true, |
72 | 72 | success: function(json) |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | { |
94 | 94 | <?php if(isset($errorMsg)) { ?> |
95 | 95 | //Error Msg |
96 | - if('<?php echo $errorMsg;?>' != '') |
|
96 | + if('<?php echo $errorMsg; ?>' != '') |
|
97 | 97 | { |
98 | - alert('<?php echo $errorMsg;?>'); |
|
98 | + alert('<?php echo $errorMsg; ?>'); |
|
99 | 99 | } |
100 | 100 | <?php } ?> |
101 | 101 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | function getMorePosts(lastPostId, view, hashtag, old_lastPostId) |
129 | 129 | { |
130 | 130 | $.ajax({ |
131 | - url: '<?php echo $baseUrl;?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURIComponent(hashtag), |
|
131 | + url: '<?php echo $baseUrl; ?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURIComponent(hashtag), |
|
132 | 132 | dataType: 'html', |
133 | 133 | async: false, |
134 | 134 | success: function(html) { |
@@ -61,7 +61,9 @@ discard block |
||
61 | 61 | { |
62 | 62 | window.history.back(); |
63 | 63 | } |
64 | - <?php if(isset($includeEmojiAndAjax)){ ?> |
|
64 | + <?php if(isset($includeEmojiAndAjax)) |
|
65 | +{ |
|
66 | +?> |
|
65 | 67 | |
66 | 68 | function vote(postId, vote, obj) |
67 | 69 | { |
@@ -91,7 +93,9 @@ discard block |
||
91 | 93 | |
92 | 94 | $(document).ready(function() |
93 | 95 | { |
94 | - <?php if(isset($errorMsg)) { ?> |
|
96 | + <?php if(isset($errorMsg)) |
|
97 | +{ |
|
98 | +?> |
|
95 | 99 | //Error Msg |
96 | 100 | if('<?php echo $errorMsg;?>' != '') |
97 | 101 | { |
@@ -155,7 +159,9 @@ discard block |
||
155 | 159 | return {"lastPostId":lastPostId, "old_lastPostId":old_lastPostId}; |
156 | 160 | } |
157 | 161 | |
158 | - <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?> |
|
162 | + <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) |
|
163 | +{ |
|
164 | +?> |
|
159 | 165 | |
160 | 166 | if(window.location.hash) |
161 | 167 | { |