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