@@ -2,18 +2,18 @@ |
||
2 | 2 | class GetUserConfig extends AbstractRequest |
3 | 3 | { |
4 | 4 | |
5 | - function getApiEndPoint() |
|
6 | - { |
|
7 | - return '/v3/user/config/'; |
|
8 | - } |
|
9 | - function getPayload() |
|
10 | - { |
|
11 | - return array( |
|
12 | - ); |
|
13 | - } |
|
14 | - function getMethod() |
|
15 | - { |
|
16 | - return 'GET'; |
|
17 | - } |
|
5 | + function getApiEndPoint() |
|
6 | + { |
|
7 | + return '/v3/user/config/'; |
|
8 | + } |
|
9 | + function getPayload() |
|
10 | + { |
|
11 | + return array( |
|
12 | + ); |
|
13 | + } |
|
14 | + function getMethod() |
|
15 | + { |
|
16 | + return 'GET'; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 |
@@ -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) |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | return TRUE; |
56 | 56 | } |
57 | 57 | } |
58 | -function isUserAdmin() { |
|
58 | +function isUserAdmin() |
|
59 | +{ |
|
59 | 60 | global $config; |
60 | 61 | if (isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
61 | 62 | { |
@@ -106,7 +107,7 @@ discard block |
||
106 | 107 | } |
107 | 108 | |
108 | 109 | if(configPropertyExists($config, 'karmaDeviceUid')) |
109 | - { |
|
110 | + { |
|
110 | 111 | $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
111 | 112 | } |
112 | 113 | else |
@@ -176,7 +177,8 @@ discard block |
||
176 | 177 | |
177 | 178 | if(isset($_GET['view'])) |
178 | 179 | { |
179 | - switch ($_GET['view']) { |
|
180 | + switch ($_GET['view']) |
|
181 | + { |
|
180 | 182 | case 'discussed': |
181 | 183 | $view = 'discussed'; |
182 | 184 | break; |
@@ -223,7 +225,7 @@ discard block |
||
223 | 225 | { |
224 | 226 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
225 | 227 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
226 | - { |
|
228 | + { |
|
227 | 229 | header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
228 | 230 | } |
229 | 231 | else |
@@ -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') |
@@ -39,27 +39,27 @@ discard block |
||
39 | 39 | |
40 | 40 | function user_log($msg) |
41 | 41 | { |
42 | - $log = $msg . PHP_EOL; |
|
43 | - file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
42 | + $log = $msg . PHP_EOL; |
|
43 | + file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | function isUserBot() |
47 | 47 | { |
48 | - preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
48 | + preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
49 | 49 | |
50 | - return (isset($matches[0])) ? true : false; |
|
50 | + return (isset($matches[0])) ? true : false; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function configPropertyExists($config, $property) |
54 | 54 | { |
55 | - if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
56 | - { |
|
57 | - return FALSE; |
|
58 | - } |
|
59 | - else |
|
60 | - { |
|
61 | - return TRUE; |
|
62 | - } |
|
55 | + if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
56 | + { |
|
57 | + return FALSE; |
|
58 | + } |
|
59 | + else |
|
60 | + { |
|
61 | + return TRUE; |
|
62 | + } |
|
63 | 63 | } |
64 | 64 | function isUserAdmin() { |
65 | 65 | global $config; |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | |
76 | 76 | function isDeviceUidInDatabase($deviceUid) |
77 | 77 | { |
78 | - $db = new DatabaseConnect(); |
|
79 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
80 | - |
|
81 | - if ($result->num_rows > 0) |
|
82 | - { |
|
83 | - return TRUE; |
|
84 | - } |
|
85 | - else |
|
86 | - { |
|
87 | - return FALSE; |
|
88 | - } |
|
78 | + $db = new DatabaseConnect(); |
|
79 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
80 | + |
|
81 | + if ($result->num_rows > 0) |
|
82 | + { |
|
83 | + return TRUE; |
|
84 | + } |
|
85 | + else |
|
86 | + { |
|
87 | + return FALSE; |
|
88 | + } |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | //Check if it's a Spider or Google Bot |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | if(configPropertyExists($config, 'karmaDeviceUid')) |
115 | - { |
|
116 | - $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
117 | - } |
|
118 | - else |
|
119 | - { |
|
120 | - error_log("No Karma deviceUid set in config file"); |
|
115 | + { |
|
116 | + $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
117 | + } |
|
118 | + else |
|
119 | + { |
|
120 | + error_log("No Karma deviceUid set in config file"); |
|
121 | 121 | $jodelAccountForKarma = new JodelAccount($deviceUid); |
122 | - } |
|
122 | + } |
|
123 | 123 | |
124 | 124 | /* |
125 | 125 | * Cunstruct View |
@@ -229,14 +229,14 @@ discard block |
||
229 | 229 | { |
230 | 230 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
231 | 231 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
232 | - { |
|
233 | - header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
234 | - } |
|
235 | - else |
|
236 | - { |
|
237 | - header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
238 | - } |
|
239 | - die(); |
|
232 | + { |
|
233 | + header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
234 | + } |
|
235 | + else |
|
236 | + { |
|
237 | + header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
238 | + } |
|
239 | + die(); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | //SendJodel |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | function user_log($msg) |
41 | 41 | { |
42 | - $log = $msg . PHP_EOL; |
|
42 | + $log = $msg . PHP_EOL; |
|
43 | 43 | file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
44 | 44 | } |
45 | 45 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
49 | 49 | |
50 | - return (isset($matches[0])) ? true : false; |
|
50 | + return (isset($matches[0]))?true : false; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function configPropertyExists($config, $property) |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | } |
64 | 64 | function isUserAdmin() { |
65 | 65 | global $config; |
66 | - if (isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
|
66 | + if(isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
|
67 | 67 | { |
68 | 68 | return TRUE; |
69 | 69 | } |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | function isDeviceUidInDatabase($deviceUid) |
77 | 77 | { |
78 | 78 | $db = new DatabaseConnect(); |
79 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
79 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
80 | 80 | |
81 | - if ($result->num_rows > 0) |
|
81 | + if($result->num_rows > 0) |
|
82 | 82 | { |
83 | 83 | return TRUE; |
84 | 84 | } |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId'])) |
101 | 101 | { |
102 | 102 | $jodelAccountForView = new JodelAccount(); |
103 | - setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time()+60*60*24*365*10); |
|
104 | - user_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
103 | + setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time() + 60 * 60 * 24 * 365 * 10); |
|
104 | + user_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
105 | 105 | |
106 | 106 | } |
107 | 107 | else |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | if(isset($_GET['search'])) |
131 | 131 | { |
132 | 132 | |
133 | - user_log('User with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] searched for ' . $_GET['search']); |
|
133 | + user_log('User with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] searched for ' . $_GET['search']); |
|
134 | 134 | |
135 | 135 | if(substr($_GET['search'], 0, 1) === "#") |
136 | 136 | { |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | if(isset($_GET['view'])) |
187 | 187 | { |
188 | - switch ($_GET['view']) { |
|
188 | + switch($_GET['view']) { |
|
189 | 189 | case 'discussed': |
190 | 190 | $view = 'discussed'; |
191 | 191 | 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); |
@@ -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 | |
41 | 41 | function isAccountVerified() |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | $db = new DatabaseConnect(); |
67 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
67 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
68 | 68 | |
69 | 69 | $location = new Location(); |
70 | 70 | |
71 | - if ($result->num_rows > 0) |
|
71 | + if($result->num_rows > 0) |
|
72 | 72 | { |
73 | 73 | // output data of each row |
74 | 74 | while($row = $result->fetch_assoc()) |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | } |
141 | 141 | else |
142 | 142 | { |
143 | - user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
143 | + user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | function getLocation() |
153 | 153 | { |
154 | 154 | $db = new DatabaseConnect(); |
155 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
155 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
156 | 156 | |
157 | 157 | $location = new Location(); |
158 | 158 | |
159 | - if ($result->num_rows > 0) |
|
159 | + if($result->num_rows > 0) |
|
160 | 160 | { |
161 | 161 | // output data of each row |
162 | 162 | while($row = $result->fetch_assoc()) |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | if(isset($_POST['color'])) |
273 | 273 | { |
274 | 274 | $color = $_POST['color']; |
275 | - switch ($color) { |
|
275 | + switch($color) { |
|
276 | 276 | case '8ABDB0': |
277 | 277 | $color = '8ABDB0'; |
278 | 278 | break; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $db = new DatabaseConnect(); |
331 | 331 | $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
332 | 332 | |
333 | - if ($result->num_rows > 0) |
|
333 | + if($result->num_rows > 0) |
|
334 | 334 | { |
335 | 335 | // output data of each row |
336 | 336 | while($row = $result->fetch_assoc()) |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | expiration_date='" . $expiration_date . "' |
370 | 370 | WHERE device_uid='" . $device_uid . "'"); |
371 | 371 | |
372 | - if($result === false){ |
|
372 | + if($result === false) { |
|
373 | 373 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
374 | 374 | } |
375 | 375 | } |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | function getAccessToken() |
380 | 380 | { |
381 | 381 | $db = new DatabaseConnect(); |
382 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
382 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
383 | 383 | |
384 | 384 | $accessToken; |
385 | 385 | |
386 | - if ($result->num_rows > 0) |
|
386 | + if($result->num_rows > 0) |
|
387 | 387 | { |
388 | 388 | // output data of each row |
389 | 389 | while($row = $result->fetch_assoc()) |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
450 | 450 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
451 | 451 | |
452 | - if($result === false){ |
|
452 | + if($result === false) { |
|
453 | 453 | $error = db_error(); |
454 | 454 | echo $error; |
455 | 455 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -477,11 +477,11 @@ discard block |
||
477 | 477 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
478 | 478 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
479 | 479 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
480 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
480 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
481 | 481 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
482 | 482 | |
483 | 483 | $success = TRUE; |
484 | - if($result === false){ |
|
484 | + if($result === false) { |
|
485 | 485 | $error = $db->error(); |
486 | 486 | echo $error; |
487 | 487 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -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; |
@@ -2,508 +2,508 @@ |
||
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; |
|
16 | - |
|
17 | - //Location of the Account |
|
18 | - public $location; |
|
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 | - } |
|
30 | - |
|
31 | - $this->isBot = $isBot; |
|
32 | - $this->location = $this->getLocation(); |
|
33 | - |
|
34 | - if(!$this->isTokenFresh()) |
|
35 | - { |
|
36 | - $this->refreshToken(); |
|
37 | - } |
|
38 | - $this->accessToken = $this->getAccessToken(); |
|
39 | - } |
|
40 | - |
|
41 | - function isAccountVerified() |
|
42 | - { |
|
43 | - $accountCreator = new GetUserConfig(); |
|
44 | - $accountCreator->setAccessToken($this->accessToken); |
|
45 | - $data = $accountCreator->execute(); |
|
46 | - |
|
47 | - return $data['verified']; |
|
48 | - } |
|
49 | - |
|
50 | - function locationEquals($city) |
|
51 | - { |
|
52 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
53 | - $result = Requests::post($url); |
|
54 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
55 | - { |
|
56 | - error_log('Error locationEquals'); |
|
57 | - return FALSE; |
|
58 | - } |
|
59 | - else |
|
60 | - { |
|
61 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
62 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
63 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
64 | - } |
|
65 | - |
|
66 | - $db = new DatabaseConnect(); |
|
67 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
14 | + // array of voted Jodels |
|
15 | + public $votes; |
|
16 | + |
|
17 | + //Location of the Account |
|
18 | + public $location; |
|
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 | + } |
|
30 | + |
|
31 | + $this->isBot = $isBot; |
|
32 | + $this->location = $this->getLocation(); |
|
33 | + |
|
34 | + if(!$this->isTokenFresh()) |
|
35 | + { |
|
36 | + $this->refreshToken(); |
|
37 | + } |
|
38 | + $this->accessToken = $this->getAccessToken(); |
|
39 | + } |
|
40 | + |
|
41 | + function isAccountVerified() |
|
42 | + { |
|
43 | + $accountCreator = new GetUserConfig(); |
|
44 | + $accountCreator->setAccessToken($this->accessToken); |
|
45 | + $data = $accountCreator->execute(); |
|
46 | + |
|
47 | + return $data['verified']; |
|
48 | + } |
|
49 | + |
|
50 | + function locationEquals($city) |
|
51 | + { |
|
52 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
53 | + $result = Requests::post($url); |
|
54 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
55 | + { |
|
56 | + error_log('Error locationEquals'); |
|
57 | + return FALSE; |
|
58 | + } |
|
59 | + else |
|
60 | + { |
|
61 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
62 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
63 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
64 | + } |
|
65 | + |
|
66 | + $db = new DatabaseConnect(); |
|
67 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
68 | 68 | |
69 | - $location = new Location(); |
|
69 | + $location = new Location(); |
|
70 | 70 | |
71 | - if ($result->num_rows > 0) |
|
72 | - { |
|
73 | - // output data of each row |
|
74 | - while($row = $result->fetch_assoc()) |
|
75 | - { |
|
76 | - $location->setLat($row['lat']); |
|
77 | - $location->setLng($row['lng']); |
|
78 | - $location->setCityName($row['name']); |
|
79 | - } |
|
80 | - } |
|
81 | - else |
|
82 | - { |
|
83 | - error_log("Error no Location found - getLocation"); |
|
84 | - } |
|
85 | - |
|
86 | - if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
|
87 | - { |
|
88 | - return TRUE; |
|
89 | - } |
|
90 | - else |
|
91 | - { |
|
92 | - return FALSE; |
|
93 | - } |
|
94 | - } |
|
95 | - |
|
96 | - function setLocation() |
|
97 | - { |
|
98 | - //Is Channel or City |
|
99 | - if(substr($_GET['city'], 0, 1) === '#') |
|
100 | - { |
|
101 | - return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
102 | - } |
|
103 | - else |
|
104 | - { |
|
105 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
106 | - $result = Requests::post($url); |
|
107 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
108 | - { |
|
109 | - return "0 results"; |
|
110 | - } |
|
111 | - else |
|
112 | - { |
|
113 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
114 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
115 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
116 | - |
|
117 | - $location = new Location(); |
|
118 | - $location->setLat($lat); |
|
119 | - $location->setLng($lng); |
|
120 | - $location->setCityName($name); |
|
121 | - $accountCreator = new UpdateLocation(); |
|
122 | - $accountCreator->setLocation($location); |
|
123 | - $accountCreator->setAccessToken($this->accessToken); |
|
124 | - $data = $accountCreator->execute(); |
|
125 | - |
|
126 | - //safe location to db |
|
127 | - $db = new DatabaseConnect(); |
|
128 | - |
|
129 | - if($data == 'Success') |
|
130 | - { |
|
131 | - $result = $db->query("UPDATE accounts |
|
71 | + if ($result->num_rows > 0) |
|
72 | + { |
|
73 | + // output data of each row |
|
74 | + while($row = $result->fetch_assoc()) |
|
75 | + { |
|
76 | + $location->setLat($row['lat']); |
|
77 | + $location->setLng($row['lng']); |
|
78 | + $location->setCityName($row['name']); |
|
79 | + } |
|
80 | + } |
|
81 | + else |
|
82 | + { |
|
83 | + error_log("Error no Location found - getLocation"); |
|
84 | + } |
|
85 | + |
|
86 | + if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
|
87 | + { |
|
88 | + return TRUE; |
|
89 | + } |
|
90 | + else |
|
91 | + { |
|
92 | + return FALSE; |
|
93 | + } |
|
94 | + } |
|
95 | + |
|
96 | + function setLocation() |
|
97 | + { |
|
98 | + //Is Channel or City |
|
99 | + if(substr($_GET['city'], 0, 1) === '#') |
|
100 | + { |
|
101 | + return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
102 | + } |
|
103 | + else |
|
104 | + { |
|
105 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
106 | + $result = Requests::post($url); |
|
107 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
108 | + { |
|
109 | + return "0 results"; |
|
110 | + } |
|
111 | + else |
|
112 | + { |
|
113 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
114 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
115 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
116 | + |
|
117 | + $location = new Location(); |
|
118 | + $location->setLat($lat); |
|
119 | + $location->setLng($lng); |
|
120 | + $location->setCityName($name); |
|
121 | + $accountCreator = new UpdateLocation(); |
|
122 | + $accountCreator->setLocation($location); |
|
123 | + $accountCreator->setAccessToken($this->accessToken); |
|
124 | + $data = $accountCreator->execute(); |
|
125 | + |
|
126 | + //safe location to db |
|
127 | + $db = new DatabaseConnect(); |
|
128 | + |
|
129 | + if($data == 'Success') |
|
130 | + { |
|
131 | + $result = $db->query("UPDATE accounts |
|
132 | 132 | SET name='" . $name . "', |
133 | 133 | lat='" . $lat . "', |
134 | 134 | lng='" . $lng . "' |
135 | 135 | WHERE access_token='" . $this->accessToken . "'"); |
136 | 136 | |
137 | - if($result === false) |
|
138 | - { |
|
139 | - echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
140 | - } |
|
141 | - else |
|
142 | - { |
|
143 | - user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
144 | - } |
|
145 | - } |
|
146 | - |
|
147 | - return $name; |
|
148 | - } |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - function getLocation() |
|
153 | - { |
|
154 | - $db = new DatabaseConnect(); |
|
155 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
137 | + if($result === false) |
|
138 | + { |
|
139 | + echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
140 | + } |
|
141 | + else |
|
142 | + { |
|
143 | + user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
144 | + } |
|
145 | + } |
|
146 | + |
|
147 | + return $name; |
|
148 | + } |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + function getLocation() |
|
153 | + { |
|
154 | + $db = new DatabaseConnect(); |
|
155 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
156 | 156 | |
157 | - $location = new Location(); |
|
157 | + $location = new Location(); |
|
158 | 158 | |
159 | - if ($result->num_rows > 0) |
|
160 | - { |
|
161 | - // output data of each row |
|
162 | - while($row = $result->fetch_assoc()) |
|
163 | - { |
|
164 | - $location->setLat($row['lat']); |
|
165 | - $location->setLng($row['lng']); |
|
166 | - $location->setCityName($row['name']); |
|
167 | - } |
|
168 | - } |
|
169 | - else |
|
170 | - { |
|
171 | - echo "Error: 0 results"; |
|
172 | - error_log("Error no Location found - getLocation"); |
|
173 | - } |
|
174 | - |
|
175 | - return $location; |
|
176 | - } |
|
177 | - |
|
178 | - function verifyCaptcha() |
|
179 | - { |
|
180 | - if(isset($_GET['deviceUid'])) |
|
181 | - { |
|
182 | - $deviceUid = $_GET['deviceUid']; |
|
183 | - } |
|
184 | - if(isset($_POST['deviceUid'])) |
|
185 | - { |
|
186 | - $deviceUid = $_POST['deviceUid']; |
|
187 | - } |
|
188 | - $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
189 | - |
|
190 | - $solution = $_GET['solution']; |
|
191 | - $solution = array_map('intval', explode('-', $solution)); |
|
192 | - |
|
193 | - $accountCreator = new PostCaptcha(); |
|
194 | - $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
195 | - $accountCreator->captchaKey = $_GET['key']; |
|
196 | - $accountCreator->captchaSolution = $solution; |
|
197 | - $verified = $accountCreator->execute(); |
|
198 | - |
|
199 | - if(isset($verified->status_code)) |
|
200 | - { |
|
201 | - return $verified->status_code; |
|
202 | - } |
|
203 | - return $verified['verified']; |
|
204 | - } |
|
205 | - |
|
206 | - //ToDo Spider Check |
|
207 | - function votePostId($postId, $vote) |
|
208 | - { |
|
209 | - if(!$this->isBot) |
|
210 | - { |
|
211 | - if(!$this->isAccountVerified()) |
|
212 | - { |
|
213 | - $view = new View(); |
|
214 | - $view->showCaptcha($this->accessToken, $this->deviceUid); |
|
215 | - } |
|
216 | - |
|
217 | - if(!$this->hasVoted($postId)) |
|
218 | - { |
|
219 | - if($vote == "up") |
|
220 | - { |
|
221 | - $accountCreator = new Upvote(); |
|
222 | - } |
|
223 | - else if($vote == "down") |
|
224 | - { |
|
225 | - $accountCreator = new Downvote(); |
|
226 | - } |
|
227 | - |
|
228 | - $accountCreator->setAccessToken($this->accessToken); |
|
229 | - $accountCreator->postId = htmlspecialchars($postId); |
|
230 | - $data = $accountCreator->execute(); |
|
231 | - |
|
232 | - error_log('Could not vote: ' . print_r($data, true)); |
|
233 | - |
|
234 | - if(array_key_exists('post', $data)) |
|
235 | - { |
|
236 | - $this->addVoteWithPostIdAndType($postId, $vote); |
|
237 | - return TRUE; |
|
238 | - } |
|
239 | - else if(array_key_exists('error', $data)) |
|
240 | - { |
|
241 | - error_log('Could not vote - Error: ' . $data['error']); |
|
242 | - } |
|
243 | - else |
|
244 | - { |
|
245 | - error_log('Could not vote: ' . print_r($data, true)); |
|
246 | - return FALSE; |
|
247 | - } |
|
248 | - } |
|
249 | - else |
|
250 | - { |
|
251 | - return FALSE; |
|
252 | - } |
|
253 | - } |
|
254 | - |
|
255 | - return FALSE; |
|
256 | - } |
|
257 | - |
|
258 | - //ToDo Spider Check |
|
259 | - function sendJodel($location, $view) |
|
260 | - { |
|
261 | - if(!$this->isAccountVerified()) |
|
262 | - { |
|
263 | - showCaptcha($this->accessToken); |
|
264 | - } |
|
265 | - |
|
266 | - $accountCreator = new SendJodel(); |
|
267 | - |
|
268 | - if(isset($_POST['ancestor'])) |
|
269 | - { |
|
270 | - $ancestor = $_POST['ancestor']; |
|
271 | - $accountCreator->ancestor = $ancestor; |
|
272 | - } |
|
273 | - if(isset($_POST['color'])) |
|
274 | - { |
|
275 | - $color = $_POST['color']; |
|
276 | - switch ($color) { |
|
277 | - case '8ABDB0': |
|
278 | - $color = '8ABDB0'; |
|
279 | - break; |
|
280 | - case '9EC41C': |
|
281 | - $color = '9EC41C'; |
|
282 | - break; |
|
283 | - case '06A3CB': |
|
284 | - $color = '06A3CB'; |
|
285 | - break; |
|
286 | - case 'FFBA00': |
|
287 | - $color = 'FFBA00'; |
|
288 | - break; |
|
289 | - case 'DD5F5F': |
|
290 | - $color = 'DD5F5F'; |
|
291 | - break; |
|
292 | - case 'FF9908': |
|
293 | - $color = 'FF9908'; |
|
294 | - break; |
|
295 | - default: |
|
296 | - $color = '8ABDB0'; |
|
297 | - break; |
|
298 | - } |
|
299 | - $accountCreator->color = $color; |
|
300 | - } |
|
301 | - |
|
302 | - $accountCreatorLocation = new UpdateLocation(); |
|
303 | - $accountCreatorLocation->setLocation($location); |
|
304 | - $accountCreatorLocation->setAccessToken($this->accessToken); |
|
305 | - $data = $accountCreatorLocation->execute(); |
|
159 | + if ($result->num_rows > 0) |
|
160 | + { |
|
161 | + // output data of each row |
|
162 | + while($row = $result->fetch_assoc()) |
|
163 | + { |
|
164 | + $location->setLat($row['lat']); |
|
165 | + $location->setLng($row['lng']); |
|
166 | + $location->setCityName($row['name']); |
|
167 | + } |
|
168 | + } |
|
169 | + else |
|
170 | + { |
|
171 | + echo "Error: 0 results"; |
|
172 | + error_log("Error no Location found - getLocation"); |
|
173 | + } |
|
174 | + |
|
175 | + return $location; |
|
176 | + } |
|
177 | + |
|
178 | + function verifyCaptcha() |
|
179 | + { |
|
180 | + if(isset($_GET['deviceUid'])) |
|
181 | + { |
|
182 | + $deviceUid = $_GET['deviceUid']; |
|
183 | + } |
|
184 | + if(isset($_POST['deviceUid'])) |
|
185 | + { |
|
186 | + $deviceUid = $_POST['deviceUid']; |
|
187 | + } |
|
188 | + $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
189 | + |
|
190 | + $solution = $_GET['solution']; |
|
191 | + $solution = array_map('intval', explode('-', $solution)); |
|
192 | + |
|
193 | + $accountCreator = new PostCaptcha(); |
|
194 | + $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
195 | + $accountCreator->captchaKey = $_GET['key']; |
|
196 | + $accountCreator->captchaSolution = $solution; |
|
197 | + $verified = $accountCreator->execute(); |
|
198 | + |
|
199 | + if(isset($verified->status_code)) |
|
200 | + { |
|
201 | + return $verified->status_code; |
|
202 | + } |
|
203 | + return $verified['verified']; |
|
204 | + } |
|
205 | + |
|
206 | + //ToDo Spider Check |
|
207 | + function votePostId($postId, $vote) |
|
208 | + { |
|
209 | + if(!$this->isBot) |
|
210 | + { |
|
211 | + if(!$this->isAccountVerified()) |
|
212 | + { |
|
213 | + $view = new View(); |
|
214 | + $view->showCaptcha($this->accessToken, $this->deviceUid); |
|
215 | + } |
|
216 | + |
|
217 | + if(!$this->hasVoted($postId)) |
|
218 | + { |
|
219 | + if($vote == "up") |
|
220 | + { |
|
221 | + $accountCreator = new Upvote(); |
|
222 | + } |
|
223 | + else if($vote == "down") |
|
224 | + { |
|
225 | + $accountCreator = new Downvote(); |
|
226 | + } |
|
227 | + |
|
228 | + $accountCreator->setAccessToken($this->accessToken); |
|
229 | + $accountCreator->postId = htmlspecialchars($postId); |
|
230 | + $data = $accountCreator->execute(); |
|
231 | + |
|
232 | + error_log('Could not vote: ' . print_r($data, true)); |
|
233 | + |
|
234 | + if(array_key_exists('post', $data)) |
|
235 | + { |
|
236 | + $this->addVoteWithPostIdAndType($postId, $vote); |
|
237 | + return TRUE; |
|
238 | + } |
|
239 | + else if(array_key_exists('error', $data)) |
|
240 | + { |
|
241 | + error_log('Could not vote - Error: ' . $data['error']); |
|
242 | + } |
|
243 | + else |
|
244 | + { |
|
245 | + error_log('Could not vote: ' . print_r($data, true)); |
|
246 | + return FALSE; |
|
247 | + } |
|
248 | + } |
|
249 | + else |
|
250 | + { |
|
251 | + return FALSE; |
|
252 | + } |
|
253 | + } |
|
254 | + |
|
255 | + return FALSE; |
|
256 | + } |
|
257 | + |
|
258 | + //ToDo Spider Check |
|
259 | + function sendJodel($location, $view) |
|
260 | + { |
|
261 | + if(!$this->isAccountVerified()) |
|
262 | + { |
|
263 | + showCaptcha($this->accessToken); |
|
264 | + } |
|
265 | + |
|
266 | + $accountCreator = new SendJodel(); |
|
267 | + |
|
268 | + if(isset($_POST['ancestor'])) |
|
269 | + { |
|
270 | + $ancestor = $_POST['ancestor']; |
|
271 | + $accountCreator->ancestor = $ancestor; |
|
272 | + } |
|
273 | + if(isset($_POST['color'])) |
|
274 | + { |
|
275 | + $color = $_POST['color']; |
|
276 | + switch ($color) { |
|
277 | + case '8ABDB0': |
|
278 | + $color = '8ABDB0'; |
|
279 | + break; |
|
280 | + case '9EC41C': |
|
281 | + $color = '9EC41C'; |
|
282 | + break; |
|
283 | + case '06A3CB': |
|
284 | + $color = '06A3CB'; |
|
285 | + break; |
|
286 | + case 'FFBA00': |
|
287 | + $color = 'FFBA00'; |
|
288 | + break; |
|
289 | + case 'DD5F5F': |
|
290 | + $color = 'DD5F5F'; |
|
291 | + break; |
|
292 | + case 'FF9908': |
|
293 | + $color = 'FF9908'; |
|
294 | + break; |
|
295 | + default: |
|
296 | + $color = '8ABDB0'; |
|
297 | + break; |
|
298 | + } |
|
299 | + $accountCreator->color = $color; |
|
300 | + } |
|
301 | + |
|
302 | + $accountCreatorLocation = new UpdateLocation(); |
|
303 | + $accountCreatorLocation->setLocation($location); |
|
304 | + $accountCreatorLocation->setAccessToken($this->accessToken); |
|
305 | + $data = $accountCreatorLocation->execute(); |
|
306 | 306 | |
307 | 307 | if($data != 'Success') |
308 | 308 | { |
309 | 309 | error_log('Could not set location befor Post: ' . print_r($data, true)); |
310 | 310 | } |
311 | 311 | |
312 | - $accountCreator->location = $this->location; |
|
312 | + $accountCreator->location = $this->location; |
|
313 | 313 | |
314 | - $accountCreator->setAccessToken($this->accessToken); |
|
315 | - $data = $accountCreator->execute(); |
|
316 | - |
|
317 | - error_log(print_r($data, true)); |
|
318 | - |
|
319 | - if(isset($_POST['ancestor'])) |
|
320 | - { |
|
321 | - header('Location: ' . $view->toUrl()); |
|
322 | - exit; |
|
323 | - } |
|
324 | - else |
|
325 | - { |
|
326 | - header('Location: ' . $view->baseUrl); |
|
327 | - exit; |
|
328 | - } |
|
329 | - } |
|
330 | - |
|
331 | - function isTokenFresh() |
|
332 | - { |
|
333 | - $db = new DatabaseConnect(); |
|
334 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
335 | - |
|
336 | - if ($result->num_rows > 0) |
|
337 | - { |
|
338 | - // output data of each row |
|
339 | - while($row = $result->fetch_assoc()) |
|
340 | - { |
|
341 | - $expiration_date = $row["expiration_date"]; |
|
342 | - } |
|
343 | - } |
|
344 | - else |
|
345 | - { |
|
346 | - error_log('0 results'); |
|
347 | - } |
|
348 | - |
|
349 | - if($expiration_date <= time()) |
|
350 | - { |
|
351 | - return FALSE; |
|
352 | - } |
|
314 | + $accountCreator->setAccessToken($this->accessToken); |
|
315 | + $data = $accountCreator->execute(); |
|
316 | + |
|
317 | + error_log(print_r($data, true)); |
|
318 | + |
|
319 | + if(isset($_POST['ancestor'])) |
|
320 | + { |
|
321 | + header('Location: ' . $view->toUrl()); |
|
322 | + exit; |
|
323 | + } |
|
324 | + else |
|
325 | + { |
|
326 | + header('Location: ' . $view->baseUrl); |
|
327 | + exit; |
|
328 | + } |
|
329 | + } |
|
330 | + |
|
331 | + function isTokenFresh() |
|
332 | + { |
|
333 | + $db = new DatabaseConnect(); |
|
334 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
335 | + |
|
336 | + if ($result->num_rows > 0) |
|
337 | + { |
|
338 | + // output data of each row |
|
339 | + while($row = $result->fetch_assoc()) |
|
340 | + { |
|
341 | + $expiration_date = $row["expiration_date"]; |
|
342 | + } |
|
343 | + } |
|
344 | + else |
|
345 | + { |
|
346 | + error_log('0 results'); |
|
347 | + } |
|
348 | + |
|
349 | + if($expiration_date <= time()) |
|
350 | + { |
|
351 | + return FALSE; |
|
352 | + } |
|
353 | 353 | |
354 | - return TRUE; |
|
355 | - } |
|
356 | - |
|
357 | - function refreshToken() |
|
358 | - { |
|
359 | - $accountCreator = new CreateUser(); |
|
360 | - $accountCreator->setAccessToken($this->accessToken); |
|
361 | - $accountCreator->setDeviceUid($this->deviceUid); |
|
362 | - $accountCreator->setLocation($this->location); |
|
363 | - $data = $accountCreator->execute(); |
|
364 | - |
|
365 | - $access_token = (string)$data[0]['access_token']; |
|
366 | - $expiration_date = $data[0]['expiration_date']; |
|
367 | - $device_uid = (string)$data[1]; |
|
354 | + return TRUE; |
|
355 | + } |
|
356 | + |
|
357 | + function refreshToken() |
|
358 | + { |
|
359 | + $accountCreator = new CreateUser(); |
|
360 | + $accountCreator->setAccessToken($this->accessToken); |
|
361 | + $accountCreator->setDeviceUid($this->deviceUid); |
|
362 | + $accountCreator->setLocation($this->location); |
|
363 | + $data = $accountCreator->execute(); |
|
364 | + |
|
365 | + $access_token = (string)$data[0]['access_token']; |
|
366 | + $expiration_date = $data[0]['expiration_date']; |
|
367 | + $device_uid = (string)$data[1]; |
|
368 | 368 | |
369 | - $db = new DatabaseConnect(); |
|
370 | - $result = $db->query("UPDATE accounts |
|
369 | + $db = new DatabaseConnect(); |
|
370 | + $result = $db->query("UPDATE accounts |
|
371 | 371 | SET access_token='" . $access_token . "', |
372 | 372 | expiration_date='" . $expiration_date . "' |
373 | 373 | WHERE device_uid='" . $device_uid . "'"); |
374 | 374 | |
375 | - if($result === false){ |
|
376 | - error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
|
377 | - } |
|
378 | - } |
|
375 | + if($result === false){ |
|
376 | + error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
|
377 | + } |
|
378 | + } |
|
379 | 379 | |
380 | 380 | |
381 | 381 | |
382 | - function getAccessToken() |
|
383 | - { |
|
384 | - $db = new DatabaseConnect(); |
|
385 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
382 | + function getAccessToken() |
|
383 | + { |
|
384 | + $db = new DatabaseConnect(); |
|
385 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
386 | 386 | |
387 | - $accessToken; |
|
387 | + $accessToken; |
|
388 | 388 | |
389 | - if ($result->num_rows > 0) |
|
390 | - { |
|
391 | - // output data of each row |
|
392 | - while($row = $result->fetch_assoc()) |
|
393 | - { |
|
394 | - $accessToken = $row['access_token']; |
|
395 | - } |
|
396 | - } |
|
397 | - else |
|
398 | - { |
|
399 | - error_log('Error: 0 results'); |
|
400 | - } |
|
401 | - |
|
402 | - return $accessToken; |
|
403 | - } |
|
404 | - |
|
405 | - |
|
406 | - function getKarma() |
|
407 | - { |
|
408 | - $accountCreator = new GetKarma(); |
|
409 | - $accountCreator->setAccessToken($this->accessToken); |
|
410 | - $data = $accountCreator->execute(); |
|
389 | + if ($result->num_rows > 0) |
|
390 | + { |
|
391 | + // output data of each row |
|
392 | + while($row = $result->fetch_assoc()) |
|
393 | + { |
|
394 | + $accessToken = $row['access_token']; |
|
395 | + } |
|
396 | + } |
|
397 | + else |
|
398 | + { |
|
399 | + error_log('Error: 0 results'); |
|
400 | + } |
|
401 | + |
|
402 | + return $accessToken; |
|
403 | + } |
|
404 | + |
|
405 | + |
|
406 | + function getKarma() |
|
407 | + { |
|
408 | + $accountCreator = new GetKarma(); |
|
409 | + $accountCreator->setAccessToken($this->accessToken); |
|
410 | + $data = $accountCreator->execute(); |
|
411 | 411 | |
412 | - return $data['karma']; |
|
413 | - } |
|
412 | + return $data['karma']; |
|
413 | + } |
|
414 | 414 | |
415 | - function hasVoted($postId) |
|
416 | - { |
|
417 | - $db = new DatabaseConnect(); |
|
415 | + function hasVoted($postId) |
|
416 | + { |
|
417 | + $db = new DatabaseConnect(); |
|
418 | 418 | |
419 | - $postId = $db->real_escape_string($postId); |
|
419 | + $postId = $db->real_escape_string($postId); |
|
420 | 420 | |
421 | - $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
421 | + $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
422 | 422 | |
423 | - if($result === false) |
|
424 | - { |
|
425 | - $error = db_error(); |
|
426 | - echo $error; |
|
427 | - error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
428 | - } |
|
429 | - |
|
430 | - if($result->num_rows == 0) |
|
431 | - { |
|
432 | - return FALSE; |
|
433 | - } |
|
434 | - else |
|
435 | - { |
|
436 | - return TRUE; |
|
437 | - } |
|
438 | - } |
|
439 | - |
|
440 | - function addVoteWithPostIdAndType($postId, $voteType) |
|
441 | - { |
|
442 | - $db = new DatabaseConnect(); |
|
443 | - |
|
444 | - $postId = $db->real_escape_string($postId); |
|
445 | - $voteType = $db->real_escape_string($voteType); |
|
423 | + if($result === false) |
|
424 | + { |
|
425 | + $error = db_error(); |
|
426 | + echo $error; |
|
427 | + error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
428 | + } |
|
429 | + |
|
430 | + if($result->num_rows == 0) |
|
431 | + { |
|
432 | + return FALSE; |
|
433 | + } |
|
434 | + else |
|
435 | + { |
|
436 | + return TRUE; |
|
437 | + } |
|
438 | + } |
|
439 | + |
|
440 | + function addVoteWithPostIdAndType($postId, $voteType) |
|
441 | + { |
|
442 | + $db = new DatabaseConnect(); |
|
443 | + |
|
444 | + $postId = $db->real_escape_string($postId); |
|
445 | + $voteType = $db->real_escape_string($voteType); |
|
446 | 446 | |
447 | - if($this->hasVoted($postId)) |
|
448 | - { |
|
449 | - return "Already voted"; |
|
450 | - } |
|
447 | + if($this->hasVoted($postId)) |
|
448 | + { |
|
449 | + return "Already voted"; |
|
450 | + } |
|
451 | 451 | |
452 | - $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
452 | + $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
453 | 453 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
454 | 454 | |
455 | - if($result === false){ |
|
456 | - $error = db_error(); |
|
457 | - echo $error; |
|
458 | - echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
459 | - } |
|
460 | - } |
|
461 | - |
|
462 | - function registerAccount($location) { |
|
463 | - $accountCreator = new CreateUser(); |
|
464 | - $accountCreator->setLocation($location); |
|
465 | - $data = $accountCreator->execute(); |
|
455 | + if($result === false){ |
|
456 | + $error = db_error(); |
|
457 | + echo $error; |
|
458 | + echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
459 | + } |
|
460 | + } |
|
461 | + |
|
462 | + function registerAccount($location) { |
|
463 | + $accountCreator = new CreateUser(); |
|
464 | + $accountCreator->setLocation($location); |
|
465 | + $data = $accountCreator->execute(); |
|
466 | 466 | |
467 | - $access_token = (string)$data[0]['access_token']; |
|
468 | - $refresh_token = (string)$data[0]['refresh_token']; |
|
469 | - $token_type = (string)$data[0]['token_type']; |
|
470 | - $expires_in = $data[0]['expires_in']; |
|
471 | - $expiration_date = $data[0]['expiration_date']; |
|
472 | - $distinct_id = (string)$data[0]['distinct_id']; |
|
473 | - $device_uid = (string)$data[1]; |
|
474 | - |
|
475 | - $name = $location->cityName; |
|
476 | - $lat = $location->lat; |
|
477 | - $lng = $location->lng; |
|
467 | + $access_token = (string)$data[0]['access_token']; |
|
468 | + $refresh_token = (string)$data[0]['refresh_token']; |
|
469 | + $token_type = (string)$data[0]['token_type']; |
|
470 | + $expires_in = $data[0]['expires_in']; |
|
471 | + $expiration_date = $data[0]['expiration_date']; |
|
472 | + $distinct_id = (string)$data[0]['distinct_id']; |
|
473 | + $device_uid = (string)$data[1]; |
|
474 | + |
|
475 | + $name = $location->cityName; |
|
476 | + $lat = $location->lat; |
|
477 | + $lng = $location->lng; |
|
478 | 478 | |
479 | - $db = new DatabaseConnect(); |
|
480 | - $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
479 | + $db = new DatabaseConnect(); |
|
480 | + $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
481 | 481 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
482 | 482 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
483 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
484 | - "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
485 | - |
|
486 | - $success = TRUE; |
|
487 | - if($result === false){ |
|
488 | - $error = $db->error(); |
|
489 | - echo $error; |
|
490 | - echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
491 | - $success = FALSE; |
|
492 | - } |
|
483 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
484 | + "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
485 | + |
|
486 | + $success = TRUE; |
|
487 | + if($result === false){ |
|
488 | + $error = $db->error(); |
|
489 | + echo $error; |
|
490 | + echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
491 | + $success = FALSE; |
|
492 | + } |
|
493 | 493 | |
494 | - return $device_uid; |
|
495 | - } |
|
494 | + return $device_uid; |
|
495 | + } |
|
496 | 496 | |
497 | - function createAccount() |
|
498 | - { |
|
499 | - $config = parse_ini_file('config/config.ini.php'); |
|
500 | - $location = new Location(); |
|
501 | - $location->setLat($config['default_lat']); |
|
502 | - $location->setLng($config['default_lng']); |
|
503 | - $location->setCityName($config['default_location']); |
|
497 | + function createAccount() |
|
498 | + { |
|
499 | + $config = parse_ini_file('config/config.ini.php'); |
|
500 | + $location = new Location(); |
|
501 | + $location->setLat($config['default_lat']); |
|
502 | + $location->setLng($config['default_lng']); |
|
503 | + $location->setCityName($config['default_location']); |
|
504 | 504 | |
505 | - $deviceUid = $this->registerAccount($location); |
|
505 | + $deviceUid = $this->registerAccount($location); |
|
506 | 506 | |
507 | - return $deviceUid; |
|
508 | - } |
|
507 | + return $deviceUid; |
|
508 | + } |
|
509 | 509 | } |
510 | 510 | \ No newline at end of file |
@@ -51,16 +51,16 @@ discard block |
||
51 | 51 | { |
52 | 52 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($city) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
53 | 53 | $result = Requests::post($url); |
54 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
54 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
55 | 55 | { |
56 | 56 | error_log('Error locationEquals'); |
57 | 57 | return FALSE; |
58 | 58 | } |
59 | 59 | else |
60 | 60 | { |
61 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
62 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
63 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
61 | + $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name']; |
|
62 | + $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']; |
|
63 | + $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $db = new DatabaseConnect(); |
@@ -104,15 +104,15 @@ discard block |
||
104 | 104 | { |
105 | 105 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
106 | 106 | $result = Requests::post($url); |
107 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
107 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
108 | 108 | { |
109 | 109 | return "0 results"; |
110 | 110 | } |
111 | 111 | else |
112 | 112 | { |
113 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
114 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
115 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
113 | + $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name']; |
|
114 | + $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']; |
|
115 | + $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']; |
|
116 | 116 | |
117 | 117 | $location = new Location(); |
118 | 118 | $location->setLat($lat); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | lng='" . $lng . "' |
135 | 135 | WHERE access_token='" . $this->accessToken . "'"); |
136 | 136 | |
137 | - if($result === false) |
|
137 | + if($result === FALSE) |
|
138 | 138 | { |
139 | 139 | echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
140 | 140 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $accountCreator->postId = htmlspecialchars($postId); |
230 | 230 | $data = $accountCreator->execute(); |
231 | 231 | |
232 | - error_log('Could not vote: ' . print_r($data, true)); |
|
232 | + error_log('Could not vote: ' . print_r($data, TRUE)); |
|
233 | 233 | |
234 | 234 | if(array_key_exists('post', $data)) |
235 | 235 | { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | else |
244 | 244 | { |
245 | - error_log('Could not vote: ' . print_r($data, true)); |
|
245 | + error_log('Could not vote: ' . print_r($data, TRUE)); |
|
246 | 246 | return FALSE; |
247 | 247 | } |
248 | 248 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | |
307 | 307 | if($data != 'Success') |
308 | 308 | { |
309 | - error_log('Could not set location befor Post: ' . print_r($data, true)); |
|
309 | + error_log('Could not set location befor Post: ' . print_r($data, TRUE)); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | $accountCreator->location = $this->location; |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $accountCreator->setAccessToken($this->accessToken); |
315 | 315 | $data = $accountCreator->execute(); |
316 | 316 | |
317 | - error_log(print_r($data, true)); |
|
317 | + error_log(print_r($data, TRUE)); |
|
318 | 318 | |
319 | 319 | if(isset($_POST['ancestor'])) |
320 | 320 | { |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | expiration_date='" . $expiration_date . "' |
373 | 373 | WHERE device_uid='" . $device_uid . "'"); |
374 | 374 | |
375 | - if($result === false){ |
|
375 | + if($result === FALSE){ |
|
376 | 376 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
377 | 377 | } |
378 | 378 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
422 | 422 | |
423 | - if($result === false) |
|
423 | + if($result === FALSE) |
|
424 | 424 | { |
425 | 425 | $error = db_error(); |
426 | 426 | echo $error; |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
453 | 453 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
454 | 454 | |
455 | - if($result === false){ |
|
455 | + if($result === FALSE){ |
|
456 | 456 | $error = db_error(); |
457 | 457 | echo $error; |
458 | 458 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
485 | 485 | |
486 | 486 | $success = TRUE; |
487 | - if($result === false){ |
|
487 | + if($result === FALSE){ |
|
488 | 488 | $error = $db->error(); |
489 | 489 | echo $error; |
490 | 490 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -204,6 +204,9 @@ |
||
204 | 204 | return array("image_url" => $captcha['image_url'], "key" => $captcha['key']); |
205 | 205 | } |
206 | 206 | |
207 | + /** |
|
208 | + * @param string $deviceUid |
|
209 | + */ |
|
207 | 210 | function showCaptcha($accessToken, $deviceUid) |
208 | 211 | { |
209 | 212 | $accountCreator = new GetCaptcha(); |
@@ -49,25 +49,25 @@ discard block |
||
49 | 49 | $timediff_inDays = (string)$timediff->format('%d'); |
50 | 50 | $timediff_inMonth = (string)$timediff->format('%m'); |
51 | 51 | |
52 | - if($timediff_inMonth!=0) |
|
52 | + if($timediff_inMonth != 0) |
|
53 | 53 | { |
54 | 54 | $timediff = $timediff_inMonth . "m"; |
55 | 55 | } |
56 | 56 | else |
57 | 57 | { |
58 | - if($timediff_inDays!=0) |
|
58 | + if($timediff_inDays != 0) |
|
59 | 59 | { |
60 | 60 | $timediff = $timediff_inDays . "d"; |
61 | 61 | } |
62 | 62 | else |
63 | 63 | { |
64 | - if($timediff_inHours!=0) |
|
64 | + if($timediff_inHours != 0) |
|
65 | 65 | { |
66 | 66 | $timediff = $timediff_inHours . "h"; |
67 | 67 | } |
68 | 68 | else |
69 | 69 | { |
70 | - if($timediff_inMinutes!=0) |
|
70 | + if($timediff_inMinutes != 0) |
|
71 | 71 | { |
72 | 72 | $timediff = $timediff_inMinutes . "m"; |
73 | 73 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | ?> |
84 | - <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
|
84 | + <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color']; ?>;"> |
|
85 | 85 | <content> |
86 | 86 | <?php |
87 | 87 | if(isset($post['image_url'])) |
@@ -99,24 +99,24 @@ discard block |
||
99 | 99 | <?php |
100 | 100 | if($this->isDetailedView) |
101 | 101 | {?> |
102 | - <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
|
102 | + <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id']; ?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']); ?>" rel="nofollow"> |
|
103 | 103 | <?php } |
104 | 104 | else |
105 | 105 | {?> |
106 | - <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
106 | + <a href="index.php?vote=up&postId=<?php echo $post['post_id']; ?>" rel="nofollow"> |
|
107 | 107 | <?php } ?> |
108 | 108 | <i class="fa fa-angle-up fa-3x"></i> |
109 | 109 | </a> |
110 | 110 | <br /> |
111 | - <?php echo $post["vote_count"];?><br /> |
|
111 | + <?php echo $post["vote_count"]; ?><br /> |
|
112 | 112 | <?php |
113 | 113 | if($this->isDetailedView) |
114 | 114 | {?> |
115 | - <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
|
115 | + <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id']; ?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']); ?>" rel="nofollow"> |
|
116 | 116 | <?php } |
117 | 117 | else |
118 | 118 | {?> |
119 | - <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
119 | + <a href="index.php?vote=down&postId=<?php echo $post['post_id']; ?>" rel="nofollow"> |
|
120 | 120 | <?php } ?> |
121 | 121 | <i class="fa fa-angle-down fa-3x"></i> |
122 | 122 | </a> |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | <span class="time"> |
129 | 129 | <span class="tip" data-tooltip="Time"> |
130 | 130 | <i class="fa fa-clock-o"></i> |
131 | - <?php echo $timediff;?> |
|
132 | - <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
|
131 | + <?php echo $timediff; ?> |
|
132 | + <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span> |
|
133 | 133 | </span> |
134 | 134 | </span> |
135 | 135 | <?php if(!$this->isDetailedView) {?> |
136 | 136 | <span class="comments"> |
137 | 137 | <span data-tooltip="Comments"> |
138 | - <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
|
138 | + <a href="<?php echo $this->changePostId($post['post_id'])->toUrl(); ?>"> |
|
139 | 139 | <i class="fa fa-commenting-o"></i> |
140 | 140 | <?php if(array_key_exists("child_count", $post)) { |
141 | 141 | echo $post["child_count"]; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | </span> |
148 | 148 | <?php |
149 | 149 | } |
150 | - if (isUserAdmin()) |
|
150 | + if(isUserAdmin()) |
|
151 | 151 | { |
152 | 152 | ?> |
153 | 153 | <span class="voting"> |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | { |
178 | 178 | ?> |
179 | 179 | <span data-tooltip="Author"> |
180 | - <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
|
180 | + <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> | |
|
181 | 181 | </span> |
182 | 182 | <?php |
183 | 183 | } |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | |
188 | 188 | <span class="tip" data-tooltip="Distance"> |
189 | 189 | <i class="fa fa-map-marker"></i> |
190 | - <?php echo $post['distance'];?> km |
|
191 | - <span class="tiptext"><?php echo $post['location']['name'];?></span> |
|
190 | + <?php echo $post['distance']; ?> km |
|
191 | + <span class="tiptext"><?php echo $post['location']['name']; ?></span> |
|
192 | 192 | </span> |
193 | 193 | </span> |
194 | 194 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | if($post != '' && array_key_exists('message', $post) && $post['message'] != '' && $this->isDetailedView) |
229 | 229 | { |
230 | - $description = 'On JodelBlue in ' . htmlspecialchars($this->city) . ' with ' . htmlspecialchars($post['vote_count']) . ' Upvotes: ' . substr(htmlspecialchars($post['message']), 0, 130); |
|
230 | + $description = 'On JodelBlue in ' . htmlspecialchars($this->city) . ' with ' . htmlspecialchars($post['vote_count']) . ' Upvotes: ' . substr(htmlspecialchars($post['message']), 0, 130); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | return $description; |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | { |
359 | 359 | return $data['recent']; |
360 | 360 | } |
361 | - else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
361 | + else if(array_key_exists('posts', $data) && array_key_exists(0, $data['posts'])) |
|
362 | 362 | { |
363 | 363 | return $data['posts']; |
364 | 364 | } |
@@ -34,7 +34,8 @@ discard block |
||
34 | 34 | * Compute HTML Code |
35 | 35 | */ |
36 | 36 | function jodelToHtml($post) |
37 | - { //ToDO |
|
37 | + { |
|
38 | +//ToDO |
|
38 | 39 | //Replace # with link |
39 | 40 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
40 | 41 | |
@@ -90,7 +91,8 @@ discard block |
||
90 | 91 | |
91 | 92 | echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
92 | 93 | } |
93 | - else { |
|
94 | + else |
|
95 | + { |
|
94 | 96 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
95 | 97 | } |
96 | 98 | ?> |
@@ -98,11 +100,13 @@ discard block |
||
98 | 100 | <aside> |
99 | 101 | <?php |
100 | 102 | if($this->isDetailedView) |
101 | - {?> |
|
103 | + { |
|
104 | +?> |
|
102 | 105 | <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
103 | 106 | <?php } |
104 | - else |
|
105 | - {?> |
|
107 | +else |
|
108 | + { |
|
109 | +?> |
|
106 | 110 | <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
107 | 111 | <?php } ?> |
108 | 112 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -111,11 +115,13 @@ discard block |
||
111 | 115 | <?php echo $post["vote_count"];?><br /> |
112 | 116 | <?php |
113 | 117 | if($this->isDetailedView) |
114 | - {?> |
|
118 | + { |
|
119 | +?> |
|
115 | 120 | <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
116 | 121 | <?php } |
117 | - else |
|
118 | - {?> |
|
122 | +else |
|
123 | + { |
|
124 | +?> |
|
119 | 125 | <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
120 | 126 | <?php } ?> |
121 | 127 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -132,14 +138,20 @@ discard block |
||
132 | 138 | <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
133 | 139 | </span> |
134 | 140 | </span> |
135 | - <?php if(!$this->isDetailedView) {?> |
|
141 | + <?php if(!$this->isDetailedView) |
|
142 | +{ |
|
143 | +?> |
|
136 | 144 | <span class="comments"> |
137 | 145 | <span data-tooltip="Comments"> |
138 | 146 | <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
139 | 147 | <i class="fa fa-commenting-o"></i> |
140 | - <?php if(array_key_exists("child_count", $post)) { |
|
148 | + <?php if(array_key_exists("child_count", $post)) |
|
149 | +{ |
|
141 | 150 | echo $post["child_count"]; |
142 | - } else echo "0"; |
|
151 | + } |
|
152 | + else { |
|
153 | + echo "0"; |
|
154 | + } |
|
143 | 155 | ?> |
144 | 156 | </a> |
145 | 157 | </span> |
@@ -355,7 +367,7 @@ discard block |
||
355 | 367 | $data = $accountCreator->execute(); |
356 | 368 | } |
357 | 369 | if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
358 | - { |
|
370 | + { |
|
359 | 371 | return $data['recent']; |
360 | 372 | } |
361 | 373 | else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
@@ -2,107 +2,107 @@ discard block |
||
2 | 2 | |
3 | 3 | class View |
4 | 4 | { |
5 | - public $country; |
|
6 | - public $city; |
|
7 | - public $hashtag; |
|
5 | + public $country; |
|
6 | + public $city; |
|
7 | + public $hashtag; |
|
8 | 8 | public $view; |
9 | - public $postId; |
|
10 | - public $isDetailedView; |
|
11 | - public $baseUrl; |
|
9 | + public $postId; |
|
10 | + public $isDetailedView; |
|
11 | + public $baseUrl; |
|
12 | 12 | |
13 | 13 | public $lastPostId = ''; |
14 | 14 | |
15 | - function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '') |
|
16 | - { |
|
17 | - $this->baseUrl = $baseUrl; |
|
18 | - $this->country = $country; |
|
19 | - $this->city = $city; |
|
20 | - $this->hashtag = urldecode($hashtag); |
|
21 | - $this->view = $view; |
|
22 | - $this->postId = $postId; |
|
23 | - |
|
24 | - if($postId == '') |
|
25 | - { |
|
26 | - $this->isDetailedView = FALSE; |
|
27 | - } |
|
28 | - else |
|
29 | - { |
|
30 | - $this->isDetailedView = TRUE; |
|
31 | - } |
|
32 | - } |
|
15 | + function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '') |
|
16 | + { |
|
17 | + $this->baseUrl = $baseUrl; |
|
18 | + $this->country = $country; |
|
19 | + $this->city = $city; |
|
20 | + $this->hashtag = urldecode($hashtag); |
|
21 | + $this->view = $view; |
|
22 | + $this->postId = $postId; |
|
23 | + |
|
24 | + if($postId == '') |
|
25 | + { |
|
26 | + $this->isDetailedView = FALSE; |
|
27 | + } |
|
28 | + else |
|
29 | + { |
|
30 | + $this->isDetailedView = TRUE; |
|
31 | + } |
|
32 | + } |
|
33 | 33 | /** |
34 | 34 | * Compute HTML Code |
35 | 35 | */ |
36 | 36 | function jodelToHtml($post) |
37 | - { //ToDO |
|
38 | - //Replace # with link |
|
39 | - //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
40 | - |
|
41 | - //Time to time difference |
|
42 | - $now = new DateTime(); |
|
43 | - $d = new DateTime($post['created_at']); |
|
44 | - $timediff = $now->diff($d); |
|
45 | - |
|
46 | - $timediff_inSeconds = (string)$timediff->format('%s'); |
|
47 | - $timediff_inMinutes = (string)$timediff->format('%i'); |
|
48 | - $timediff_inHours = (string)$timediff->format('%h'); |
|
49 | - $timediff_inDays = (string)$timediff->format('%d'); |
|
50 | - $timediff_inMonth = (string)$timediff->format('%m'); |
|
51 | - |
|
52 | - if($timediff_inMonth!=0) |
|
53 | - { |
|
54 | - $timediff = $timediff_inMonth . "m"; |
|
55 | - } |
|
56 | - else |
|
57 | - { |
|
58 | - if($timediff_inDays!=0) |
|
59 | - { |
|
60 | - $timediff = $timediff_inDays . "d"; |
|
61 | - } |
|
62 | - else |
|
63 | - { |
|
64 | - if($timediff_inHours!=0) |
|
65 | - { |
|
66 | - $timediff = $timediff_inHours . "h"; |
|
67 | - } |
|
68 | - else |
|
69 | - { |
|
70 | - if($timediff_inMinutes!=0) |
|
71 | - { |
|
72 | - $timediff = $timediff_inMinutes . "m"; |
|
73 | - } |
|
74 | - else |
|
75 | - { |
|
76 | - $timediff = $timediff_inSeconds . "s"; |
|
77 | - } |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - ?> |
|
37 | + { //ToDO |
|
38 | + //Replace # with link |
|
39 | + //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
40 | + |
|
41 | + //Time to time difference |
|
42 | + $now = new DateTime(); |
|
43 | + $d = new DateTime($post['created_at']); |
|
44 | + $timediff = $now->diff($d); |
|
45 | + |
|
46 | + $timediff_inSeconds = (string)$timediff->format('%s'); |
|
47 | + $timediff_inMinutes = (string)$timediff->format('%i'); |
|
48 | + $timediff_inHours = (string)$timediff->format('%h'); |
|
49 | + $timediff_inDays = (string)$timediff->format('%d'); |
|
50 | + $timediff_inMonth = (string)$timediff->format('%m'); |
|
51 | + |
|
52 | + if($timediff_inMonth!=0) |
|
53 | + { |
|
54 | + $timediff = $timediff_inMonth . "m"; |
|
55 | + } |
|
56 | + else |
|
57 | + { |
|
58 | + if($timediff_inDays!=0) |
|
59 | + { |
|
60 | + $timediff = $timediff_inDays . "d"; |
|
61 | + } |
|
62 | + else |
|
63 | + { |
|
64 | + if($timediff_inHours!=0) |
|
65 | + { |
|
66 | + $timediff = $timediff_inHours . "h"; |
|
67 | + } |
|
68 | + else |
|
69 | + { |
|
70 | + if($timediff_inMinutes!=0) |
|
71 | + { |
|
72 | + $timediff = $timediff_inMinutes . "m"; |
|
73 | + } |
|
74 | + else |
|
75 | + { |
|
76 | + $timediff = $timediff_inSeconds . "s"; |
|
77 | + } |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + ?> |
|
84 | 84 | <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
85 | 85 | <content> |
86 | 86 | <?php |
87 | - if(isset($post['image_url'])) |
|
88 | - { |
|
89 | - $regexRest = '/[^\w$ .!?-]+/u'; |
|
90 | - |
|
91 | - echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
|
92 | - } |
|
93 | - else { |
|
94 | - echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
|
95 | - } |
|
96 | - ?> |
|
87 | + if(isset($post['image_url'])) |
|
88 | + { |
|
89 | + $regexRest = '/[^\w$ .!?-]+/u'; |
|
90 | + |
|
91 | + echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
|
92 | + } |
|
93 | + else { |
|
94 | + echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
|
95 | + } |
|
96 | + ?> |
|
97 | 97 | </content> |
98 | 98 | <aside> |
99 | 99 | <?php |
100 | - if($this->isDetailedView) |
|
101 | - {?> |
|
100 | + if($this->isDetailedView) |
|
101 | + {?> |
|
102 | 102 | <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
103 | 103 | <?php } |
104 | - else |
|
105 | - {?> |
|
104 | + else |
|
105 | + {?> |
|
106 | 106 | <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
107 | 107 | <?php } ?> |
108 | 108 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | <br /> |
111 | 111 | <?php echo $post["vote_count"];?><br /> |
112 | 112 | <?php |
113 | - if($this->isDetailedView) |
|
114 | - {?> |
|
113 | + if($this->isDetailedView) |
|
114 | + {?> |
|
115 | 115 | <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
116 | 116 | <?php } |
117 | - else |
|
118 | - {?> |
|
117 | + else |
|
118 | + {?> |
|
119 | 119 | <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
120 | 120 | <?php } ?> |
121 | 121 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
139 | 139 | <i class="fa fa-commenting-o"></i> |
140 | 140 | <?php if(array_key_exists("child_count", $post)) { |
141 | - echo $post["child_count"]; |
|
142 | - } else echo "0"; |
|
143 | - ?> |
|
141 | + echo $post["child_count"]; |
|
142 | + } else echo "0"; |
|
143 | + ?> |
|
144 | 144 | </a> |
145 | 145 | </span> |
146 | 146 | |
@@ -160,30 +160,30 @@ discard block |
||
160 | 160 | ?> |
161 | 161 | <span class="distance"> |
162 | 162 | <?php |
163 | - if($this->isDetailedView) |
|
164 | - { |
|
165 | - if(isset($post["parent_creator"]) && $post["parent_creator"] == 1) |
|
166 | - { |
|
167 | - ?> |
|
163 | + if($this->isDetailedView) |
|
164 | + { |
|
165 | + if(isset($post["parent_creator"]) && $post["parent_creator"] == 1) |
|
166 | + { |
|
167 | + ?> |
|
168 | 168 | <span data-tooltip="Author"> |
169 | 169 | <i class="fa fa-user-o"></i> OJ | |
170 | 170 | </span> |
171 | 171 | <?php |
172 | - } |
|
173 | - else |
|
174 | - { |
|
175 | - //Is not parent Jodel in detailed View |
|
176 | - if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post)) |
|
177 | - { |
|
178 | - ?> |
|
172 | + } |
|
173 | + else |
|
174 | + { |
|
175 | + //Is not parent Jodel in detailed View |
|
176 | + if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post)) |
|
177 | + { |
|
178 | + ?> |
|
179 | 179 | <span data-tooltip="Author"> |
180 | 180 | <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
181 | 181 | </span> |
182 | 182 | <?php |
183 | - } |
|
184 | - } |
|
185 | - } |
|
186 | - ?> |
|
183 | + } |
|
184 | + } |
|
185 | + } |
|
186 | + ?> |
|
187 | 187 | |
188 | 188 | <span class="tip" data-tooltip="Distance"> |
189 | 189 | <i class="fa fa-map-marker"></i> |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | </footer> |
197 | 197 | </article> |
198 | 198 | <?php |
199 | - } |
|
199 | + } |
|
200 | 200 | |
201 | 201 | |
202 | 202 | /** |
@@ -267,135 +267,135 @@ discard block |
||
267 | 267 | |
268 | 268 | } |
269 | 269 | |
270 | - function toUrl() |
|
271 | - { |
|
272 | - $url = $this->baseUrl . 'index.php?country=DE' . |
|
273 | - '&city=' . urlencode($this->city) . |
|
274 | - '&hashtag=' . urlencode($this->hashtag) . |
|
275 | - '&view=' . $this->view; |
|
276 | - if($this->postId != '') |
|
277 | - { |
|
278 | - $url .= '&postId=' . $this->postId . |
|
279 | - '&getPostDetails=TRUE'; |
|
280 | - } |
|
281 | - |
|
282 | - return $url; |
|
283 | - } |
|
284 | - |
|
285 | - function changePostId($postId) |
|
286 | - { |
|
287 | - $tempView = clone $this; |
|
288 | - $tempView->postId = $postId; |
|
289 | - $tempView->isDetailedView = TRUE; |
|
290 | - return $tempView; |
|
291 | - } |
|
292 | - |
|
293 | - function back() |
|
294 | - { |
|
295 | - $tempView = clone $this; |
|
296 | - $tempView->postId = ''; |
|
297 | - return $tempView; |
|
298 | - } |
|
299 | - |
|
300 | - function changeView($view) |
|
301 | - { |
|
302 | - $tempView = clone $this; |
|
303 | - $tempView->view = $view; |
|
304 | - return $tempView; |
|
305 | - } |
|
270 | + function toUrl() |
|
271 | + { |
|
272 | + $url = $this->baseUrl . 'index.php?country=DE' . |
|
273 | + '&city=' . urlencode($this->city) . |
|
274 | + '&hashtag=' . urlencode($this->hashtag) . |
|
275 | + '&view=' . $this->view; |
|
276 | + if($this->postId != '') |
|
277 | + { |
|
278 | + $url .= '&postId=' . $this->postId . |
|
279 | + '&getPostDetails=TRUE'; |
|
280 | + } |
|
281 | + |
|
282 | + return $url; |
|
283 | + } |
|
284 | + |
|
285 | + function changePostId($postId) |
|
286 | + { |
|
287 | + $tempView = clone $this; |
|
288 | + $tempView->postId = $postId; |
|
289 | + $tempView->isDetailedView = TRUE; |
|
290 | + return $tempView; |
|
291 | + } |
|
292 | + |
|
293 | + function back() |
|
294 | + { |
|
295 | + $tempView = clone $this; |
|
296 | + $tempView->postId = ''; |
|
297 | + return $tempView; |
|
298 | + } |
|
299 | + |
|
300 | + function changeView($view) |
|
301 | + { |
|
302 | + $tempView = clone $this; |
|
303 | + $tempView->view = $view; |
|
304 | + return $tempView; |
|
305 | + } |
|
306 | 306 | |
307 | 307 | function getPosts($jodelAccount) |
308 | 308 | { |
309 | - if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
310 | - { |
|
311 | - $accountCreator = new GetChannel(); |
|
312 | - $accountCreator->view = $this->view; |
|
313 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
314 | - $accountCreator->channel = $this->hashtag; |
|
315 | - $accountCreator->lastPostId = $this->lastPostId; |
|
316 | - $data = $accountCreator->execute(); |
|
317 | - } |
|
318 | - else |
|
319 | - { |
|
320 | - if($this->lastPostId == '' && $this->view == 'combo') |
|
321 | - { |
|
322 | - $url = "/v3/posts/location/combo"; |
|
323 | - } |
|
324 | - else |
|
325 | - { |
|
326 | - if($this->view == 'discussed') |
|
327 | - { |
|
328 | - $url = "/v2/posts/location/discussed/"; |
|
329 | - } |
|
330 | - else |
|
331 | - { |
|
332 | - if($this->view == 'popular') |
|
333 | - { |
|
334 | - $url = "/v2/posts/location/popular/"; |
|
335 | - } |
|
336 | - else |
|
337 | - { |
|
338 | - $url = "/v2/posts/location/"; |
|
339 | - } |
|
340 | - } |
|
341 | - } |
|
342 | - |
|
343 | - $accountCreator = new GetPosts(); |
|
344 | - $accountCreator->setLastPostId($this->lastPostId); |
|
345 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
346 | - $accountCreator->setUrl($url); |
|
347 | - $accountCreator->version = 'v3'; |
|
348 | - |
|
349 | - $config = parse_ini_file('config/config.ini.php'); |
|
350 | - $location = new Location(); |
|
351 | - $location->setLat($config['default_lat']); |
|
352 | - $location->setLng($config['default_lng']); |
|
353 | - $location->setCityName($config['default_location']); |
|
354 | - $accountCreator->location = $location; |
|
355 | - $data = $accountCreator->execute(); |
|
356 | - } |
|
357 | - if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
|
358 | - { |
|
359 | - return $data['recent']; |
|
360 | - } |
|
361 | - else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
362 | - { |
|
363 | - return $data['posts']; |
|
364 | - } |
|
365 | - else |
|
366 | - { |
|
367 | - error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true)); |
|
368 | - //error_log(print_r($data, true)); |
|
369 | - |
|
370 | - $notFound[0] = array( |
|
371 | - "post_id" => "0", |
|
372 | - "discovered_by" => 0, |
|
373 | - "message" => "Not found", |
|
374 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
375 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
376 | - "pin_count" => 0, |
|
377 | - "color" => "FFBA00", |
|
378 | - "got_thanks" => FALSE, |
|
379 | - "post_own" => "friend", |
|
380 | - "discovered" => 0, |
|
381 | - "distance" => 9, |
|
382 | - "vote_count" => 0, |
|
383 | - "location" => |
|
384 | - array("name" => "Berlin", |
|
385 | - "loc_coordinates" => |
|
386 | - array( |
|
387 | - "lat" => 0, |
|
388 | - "lng" => 0 |
|
389 | - ), |
|
390 | - "loc_accuracy" => 0, |
|
391 | - "country" => "", |
|
392 | - "city" => "", |
|
393 | - ), |
|
394 | - "tags" => |
|
395 | - array(), |
|
396 | - "user_handle" => "0" |
|
397 | - ); |
|
398 | - return $notFound; |
|
399 | - } |
|
309 | + if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
310 | + { |
|
311 | + $accountCreator = new GetChannel(); |
|
312 | + $accountCreator->view = $this->view; |
|
313 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
314 | + $accountCreator->channel = $this->hashtag; |
|
315 | + $accountCreator->lastPostId = $this->lastPostId; |
|
316 | + $data = $accountCreator->execute(); |
|
317 | + } |
|
318 | + else |
|
319 | + { |
|
320 | + if($this->lastPostId == '' && $this->view == 'combo') |
|
321 | + { |
|
322 | + $url = "/v3/posts/location/combo"; |
|
323 | + } |
|
324 | + else |
|
325 | + { |
|
326 | + if($this->view == 'discussed') |
|
327 | + { |
|
328 | + $url = "/v2/posts/location/discussed/"; |
|
329 | + } |
|
330 | + else |
|
331 | + { |
|
332 | + if($this->view == 'popular') |
|
333 | + { |
|
334 | + $url = "/v2/posts/location/popular/"; |
|
335 | + } |
|
336 | + else |
|
337 | + { |
|
338 | + $url = "/v2/posts/location/"; |
|
339 | + } |
|
340 | + } |
|
341 | + } |
|
342 | + |
|
343 | + $accountCreator = new GetPosts(); |
|
344 | + $accountCreator->setLastPostId($this->lastPostId); |
|
345 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
346 | + $accountCreator->setUrl($url); |
|
347 | + $accountCreator->version = 'v3'; |
|
348 | + |
|
349 | + $config = parse_ini_file('config/config.ini.php'); |
|
350 | + $location = new Location(); |
|
351 | + $location->setLat($config['default_lat']); |
|
352 | + $location->setLng($config['default_lng']); |
|
353 | + $location->setCityName($config['default_location']); |
|
354 | + $accountCreator->location = $location; |
|
355 | + $data = $accountCreator->execute(); |
|
356 | + } |
|
357 | + if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
|
358 | + { |
|
359 | + return $data['recent']; |
|
360 | + } |
|
361 | + else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
362 | + { |
|
363 | + return $data['posts']; |
|
364 | + } |
|
365 | + else |
|
366 | + { |
|
367 | + error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true)); |
|
368 | + //error_log(print_r($data, true)); |
|
369 | + |
|
370 | + $notFound[0] = array( |
|
371 | + "post_id" => "0", |
|
372 | + "discovered_by" => 0, |
|
373 | + "message" => "Not found", |
|
374 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
375 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
376 | + "pin_count" => 0, |
|
377 | + "color" => "FFBA00", |
|
378 | + "got_thanks" => FALSE, |
|
379 | + "post_own" => "friend", |
|
380 | + "discovered" => 0, |
|
381 | + "distance" => 9, |
|
382 | + "vote_count" => 0, |
|
383 | + "location" => |
|
384 | + array("name" => "Berlin", |
|
385 | + "loc_coordinates" => |
|
386 | + array( |
|
387 | + "lat" => 0, |
|
388 | + "lng" => 0 |
|
389 | + ), |
|
390 | + "loc_accuracy" => 0, |
|
391 | + "country" => "", |
|
392 | + "city" => "", |
|
393 | + ), |
|
394 | + "tags" => |
|
395 | + array(), |
|
396 | + "user_handle" => "0" |
|
397 | + ); |
|
398 | + return $notFound; |
|
399 | + } |
|
400 | 400 | } |
401 | 401 | } |
@@ -364,7 +364,7 @@ |
||
364 | 364 | } |
365 | 365 | else |
366 | 366 | { |
367 | - error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true)); |
|
367 | + error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, TRUE)); |
|
368 | 368 | //error_log(print_r($data, true)); |
369 | 369 | |
370 | 370 | $notFound[0] = array( |
@@ -59,7 +59,7 @@ |
||
59 | 59 | { |
60 | 60 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid); |
61 | 61 | } |
62 | -else |
|
62 | +else |
|
63 | 63 | { |
64 | 64 | $response = array("success" => $success, "message" => $message); |
65 | 65 | } |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | if((!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) && !isUserAdmin()) |
5 | 5 | { |
6 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
7 | - $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
6 | + error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
|
7 | + $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php', "success" => false); |
|
8 | 8 | echo json_encode($response); |
9 | 9 | die(); |
10 | 10 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -if (isset($captcha)) |
|
57 | +if(isset($captcha)) |
|
58 | 58 | { |
59 | 59 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid); |
60 | 60 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | if((!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) && !isUserAdmin()) |
6 | 6 | { |
7 | 7 | error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
8 | - $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
|
8 | + $respone = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => FALSE); |
|
9 | 9 | echo json_encode($response); |
10 | 10 | die(); |
11 | 11 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | } |
22 | 22 | |
23 | 23 | $message = ""; |
24 | -$success = true; |
|
24 | +$success = TRUE; |
|
25 | 25 | $token = ""; |
26 | 26 | if(isset($_POST['vote']) && isset($_POST['postId'])) |
27 | 27 | { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $response = array("success" => $jodelAccount->verifyCaptcha()); |
90 | 90 | echo json_encode($response); |
91 | 91 | die(); |
92 | - $success = false; |
|
92 | + $success = FALSE; |
|
93 | 93 | } |
94 | 94 | else |
95 | 95 | { |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | else |
100 | 100 | { |
101 | 101 | $message = 'There is no account available for this jodel. Please create at least one new account to vote this jodel.'; |
102 | - $success = false; |
|
102 | + $success = FALSE; |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 |
@@ -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> |