@@ -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 | error_log(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt'); |
| 44 | 44 | file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
| 45 | 45 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 50 | 50 | |
| 51 | - return (isset($matches[0])) ? true : false; |
|
| 51 | + return (isset($matches[0]))?true : false; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | function configPropertyExists($config, $property) |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | function isUserAdmin() { |
| 66 | 66 | global $config; |
| 67 | - if (isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
|
| 67 | + if(isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
|
| 68 | 68 | { |
| 69 | 69 | return TRUE; |
| 70 | 70 | } |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | function isDeviceUidInDatabase($deviceUid) |
| 78 | 78 | { |
| 79 | 79 | $db = new DatabaseConnect(); |
| 80 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 80 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 81 | 81 | |
| 82 | - if ($result->num_rows > 0) |
|
| 82 | + if($result->num_rows > 0) |
|
| 83 | 83 | { |
| 84 | 84 | return TRUE; |
| 85 | 85 | } |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId'])) |
| 102 | 102 | { |
| 103 | 103 | $jodelAccountForView = new JodelAccount(); |
| 104 | - setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time()+60*60*24*365*10); |
|
| 105 | - user_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 104 | + setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time() + 60 * 60 * 24 * 365 * 10); |
|
| 105 | + user_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | else |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | if(isset($_GET['view'])) |
| 185 | 185 | { |
| 186 | - switch ($_GET['view']) { |
|
| 186 | + switch($_GET['view']) { |
|
| 187 | 187 | case 'discussed': |
| 188 | 188 | $view = 'discussed'; |
| 189 | 189 | break; |
@@ -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()) |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | else |
| 143 | 143 | { |
| 144 | - user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 144 | + user_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | function getLocation() |
| 154 | 154 | { |
| 155 | 155 | $db = new DatabaseConnect(); |
| 156 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 156 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 157 | 157 | |
| 158 | 158 | $location = new Location(); |
| 159 | 159 | |
| 160 | - if ($result->num_rows > 0) |
|
| 160 | + if($result->num_rows > 0) |
|
| 161 | 161 | { |
| 162 | 162 | // output data of each row |
| 163 | 163 | while($row = $result->fetch_assoc()) |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | if(isset($_POST['color'])) |
| 263 | 263 | { |
| 264 | 264 | $color = $_POST['color']; |
| 265 | - switch ($color) { |
|
| 265 | + switch($color) { |
|
| 266 | 266 | case '8ABDB0': |
| 267 | 267 | $color = '8ABDB0'; |
| 268 | 268 | break; |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $db = new DatabaseConnect(); |
| 316 | 316 | $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
| 317 | 317 | |
| 318 | - if ($result->num_rows > 0) |
|
| 318 | + if($result->num_rows > 0) |
|
| 319 | 319 | { |
| 320 | 320 | // output data of each row |
| 321 | 321 | while($row = $result->fetch_assoc()) |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | expiration_date='" . $expiration_date . "' |
| 355 | 355 | WHERE device_uid='" . $device_uid . "'"); |
| 356 | 356 | |
| 357 | - if($result === false){ |
|
| 357 | + if($result === false) { |
|
| 358 | 358 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
| 359 | 359 | } |
| 360 | 360 | } |
@@ -364,11 +364,11 @@ discard block |
||
| 364 | 364 | function getAccessToken() |
| 365 | 365 | { |
| 366 | 366 | $db = new DatabaseConnect(); |
| 367 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 367 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 368 | 368 | |
| 369 | 369 | $accessToken; |
| 370 | 370 | |
| 371 | - if ($result->num_rows > 0) |
|
| 371 | + if($result->num_rows > 0) |
|
| 372 | 372 | { |
| 373 | 373 | // output data of each row |
| 374 | 374 | while($row = $result->fetch_assoc()) |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 435 | 435 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
| 436 | 436 | |
| 437 | - if($result === false){ |
|
| 437 | + if($result === false) { |
|
| 438 | 438 | $error = db_error(); |
| 439 | 439 | echo $error; |
| 440 | 440 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -462,11 +462,11 @@ discard block |
||
| 462 | 462 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
| 463 | 463 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
| 464 | 464 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
| 465 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 465 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 466 | 466 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 467 | 467 | |
| 468 | 468 | $success = TRUE; |
| 469 | - if($result === false){ |
|
| 469 | + if($result === false) { |
|
| 470 | 470 | $error = db_error(); |
| 471 | 471 | echo $error; |
| 472 | 472 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |