@@ -616,7 +616,7 @@ |
||
| 616 | 616 | <?php |
| 617 | 617 | if(is_file('./piwik-script.html')) |
| 618 | 618 | { |
| 619 | - require_once('./piwik-script.html'); |
|
| 619 | + require_once('./piwik-script.html'); |
|
| 620 | 620 | } |
| 621 | 621 | ?> |
| 622 | 622 | |
@@ -51,52 +51,52 @@ discard block |
||
| 51 | 51 | <!DOCTYPE html> |
| 52 | 52 | <html lang="en"> |
| 53 | 53 | <head> |
| 54 | - <title><?php echo $view->getTitle($posts[0]);?></title> |
|
| 54 | + <title><?php echo $view->getTitle($posts[0]); ?></title> |
|
| 55 | 55 | |
| 56 | 56 | <meta charset="utf-8"> |
| 57 | 57 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 58 | 58 | <meta http-equiv="x-ua-compatible" content="ie=edge"> |
| 59 | 59 | |
| 60 | - <meta name="description" content="<?php echo $view->getMetaDescription($posts[0]);?>"> |
|
| 60 | + <meta name="description" content="<?php echo $view->getMetaDescription($posts[0]); ?>"> |
|
| 61 | 61 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app"> |
| 62 | 62 | |
| 63 | 63 | <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous"> |
| 64 | - <link rel="stylesheet" href="<?php echo $baseUrl;?>css/font-awesome.min.css"> |
|
| 65 | - <link rel="stylesheet" href="<?php echo $baseUrl;?>style.css" type="text/css"> |
|
| 64 | + <link rel="stylesheet" href="<?php echo $baseUrl; ?>css/font-awesome.min.css"> |
|
| 65 | + <link rel="stylesheet" href="<?php echo $baseUrl; ?>style.css" type="text/css"> |
|
| 66 | 66 | |
| 67 | - <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
|
| 68 | - <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
|
| 69 | - <link rel="icon" type="image/gif" href="<?php echo $baseUrl;?>img/favicon/favicon.gif"> |
|
| 70 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon.png"> |
|
| 71 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon.png"> |
|
| 72 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
|
| 73 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
|
| 74 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
|
| 75 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
|
| 76 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
|
| 77 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
|
| 78 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
|
| 79 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
|
| 80 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
|
| 81 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
|
| 82 | - <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-precomposed.png"> |
|
| 83 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-16x16.png" sizes="16x16"> |
|
| 84 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-32x32.png" sizes="32x32"> |
|
| 85 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-96x96.png" sizes="96x96"> |
|
| 86 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-160x160.png" sizes="160x160"> |
|
| 87 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-192x192.png" sizes="192x192"> |
|
| 88 | - <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-196x196.png" sizes="196x196"> |
|
| 89 | - <meta name="msapplication-TileImage" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
|
| 67 | + <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl; ?>img/favicon/favicon.ico"> |
|
| 68 | + <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl; ?>img/favicon/favicon.ico"> |
|
| 69 | + <link rel="icon" type="image/gif" href="<?php echo $baseUrl; ?>img/favicon/favicon.gif"> |
|
| 70 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon.png"> |
|
| 71 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon.png"> |
|
| 72 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
|
| 73 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
|
| 74 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
|
| 75 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
|
| 76 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
|
| 77 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
|
| 78 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
|
| 79 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
|
| 80 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
|
| 81 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
|
| 82 | + <link rel="apple-touch-icon" href="<?php echo $baseUrl; ?>img/favicon/apple-touch-icon-precomposed.png"> |
|
| 83 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-16x16.png" sizes="16x16"> |
|
| 84 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-32x32.png" sizes="32x32"> |
|
| 85 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-96x96.png" sizes="96x96"> |
|
| 86 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-160x160.png" sizes="160x160"> |
|
| 87 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-192x192.png" sizes="192x192"> |
|
| 88 | + <link rel="icon" type="image/png" href="<?php echo $baseUrl; ?>img/favicon/favicon-196x196.png" sizes="196x196"> |
|
| 89 | + <meta name="msapplication-TileImage" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-144x144.png"> |
|
| 90 | 90 | <meta name="msapplication-TileColor" content="#5682a3"> |
| 91 | 91 | <meta name="msapplication-navbutton-color" content="#5682a3"> |
| 92 | 92 | <meta name="application-name" content="JodelBlue"/> |
| 93 | 93 | <meta name="msapplication-tooltip" content="JodelBlue"/> |
| 94 | 94 | <meta name="apple-mobile-web-app-title" content="JodelBlue"/> |
| 95 | - <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-70x70.png"> |
|
| 96 | - <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
|
| 97 | - <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-150x150.png"> |
|
| 98 | - <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x150.png"> |
|
| 99 | - <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x310.png"> |
|
| 95 | + <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-70x70.png"> |
|
| 96 | + <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-144x144.png"> |
|
| 97 | + <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-150x150.png"> |
|
| 98 | + <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-310x150.png"> |
|
| 99 | + <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl; ?>img/favicon/win8-tile-310x310.png"> |
|
| 100 | 100 | </head> |
| 101 | 101 | |
| 102 | 102 | <body> |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | <?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?> |
| 179 | 179 | <h2>Comment on Jodel</h2> |
| 180 | 180 | <form method="POST"> |
| 181 | - <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" /> |
|
| 181 | + <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']); ?>" /> |
|
| 182 | 182 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
| 183 | 183 | <br /> |
| 184 | 184 | <input type="submit" value="SEND" /> |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | </div> |
| 212 | 212 | </aside> |
| 213 | 213 | </div> |
| 214 | - <?php include './template/nav-bottom.php';?> |
|
| 214 | + <?php include './template/nav-bottom.php'; ?> |
|
| 215 | 215 | |
| 216 | 216 | |
| 217 | 217 | <!-- jQuery, Tether, Bootstrap JS and own--> |
| 218 | 218 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script> |
| 219 | 219 | <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script> |
| 220 | 220 | <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script> |
| 221 | - <script src="<?php echo $baseUrl;?>js/jQueryEmoji.js"></script> |
|
| 221 | + <script src="<?php echo $baseUrl; ?>js/jQueryEmoji.js"></script> |
|
| 222 | 222 | |
| 223 | 223 | <script> |
| 224 | 224 | //BackButton |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | if(!$("article[id='"+ hash +"']").length) |
| 267 | 267 | { |
| 268 | 268 | $.ajax({ |
| 269 | - url: '<?php echo $baseUrl;?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURI(hashtag), |
|
| 269 | + url: '<?php echo $baseUrl; ?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURI(hashtag), |
|
| 270 | 270 | dataType: 'html', |
| 271 | 271 | async: false, |
| 272 | 272 | success: function(html) { |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | $('#loading').show(); |
| 310 | 310 | |
| 311 | 311 | $.ajax({ |
| 312 | - url: '<?php echo $baseUrl;?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURI(hashtag), |
|
| 312 | + url: '<?php echo $baseUrl; ?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURI(hashtag), |
|
| 313 | 313 | dataType: 'html', |
| 314 | 314 | async: false, |
| 315 | 315 | success: function(html) { |
@@ -20,7 +20,8 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $posts[0] = $data; |
| 22 | 22 | |
| 23 | - if(array_key_exists('children', $data)) { |
|
| 23 | + if(array_key_exists('children', $data)) |
|
| 24 | + { |
|
| 24 | 25 | foreach($data['children'] as $key => $child) |
| 25 | 26 | { |
| 26 | 27 | |
@@ -124,7 +125,11 @@ discard block |
||
| 124 | 125 | |
| 125 | 126 | <div id="location_mobile" class="hidden-sm-up"> |
| 126 | 127 | <form method="get"> |
| 127 | - <input type="text" id="city_mobile" name="search" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
| 128 | + <input type="text" id="city_mobile" name="search" placeholder="<?php if(isset($newPositionStatus)) |
|
| 129 | +{ |
|
| 130 | + echo $newPositionStatus; |
|
| 131 | +} |
|
| 132 | +?>" required> |
|
| 128 | 133 | |
| 129 | 134 | <input type="submit" id="submit_mobile" class="fa" value="" /> |
| 130 | 135 | </form> |
@@ -146,7 +151,9 @@ discard block |
||
| 146 | 151 | } ?> |
| 147 | 152 | </content> |
| 148 | 153 | |
| 149 | - <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 154 | + <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) |
|
| 155 | +{ |
|
| 156 | +?> |
|
| 150 | 157 | <p id="loading"> |
| 151 | 158 | Loading… |
| 152 | 159 | </p> |
@@ -159,7 +166,11 @@ discard block |
||
| 159 | 166 | <div> |
| 160 | 167 | <h2>Position / Hashtag</h2> |
| 161 | 168 | <form method="get"> |
| 162 | - <input type="text" id="city" name="search" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
| 169 | + <input type="text" id="city" name="search" placeholder="<?php if(isset($newPositionStatus)) |
|
| 170 | +{ |
|
| 171 | + echo $newPositionStatus; |
|
| 172 | +} |
|
| 173 | +?>" required> |
|
| 163 | 174 | <label>try: #jhj</label><br> |
| 164 | 175 | <input type="submit" value="Set Location" /> |
| 165 | 176 | </form> |
@@ -175,7 +186,9 @@ discard block |
||
| 175 | 186 | |
| 176 | 187 | <article> |
| 177 | 188 | <div> |
| 178 | - <?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?> |
|
| 189 | + <?php if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) |
|
| 190 | +{ |
|
| 191 | +?> |
|
| 179 | 192 | <h2>Comment on Jodel</h2> |
| 180 | 193 | <form method="POST"> |
| 181 | 194 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" /> |
@@ -183,7 +196,10 @@ discard block |
||
| 183 | 196 | <br /> |
| 184 | 197 | <input type="submit" value="SEND" /> |
| 185 | 198 | </form> |
| 186 | - <?php } else { ?> |
|
| 199 | + <?php } |
|
| 200 | +else |
|
| 201 | +{ |
|
| 202 | +?> |
|
| 187 | 203 | <h2>New Jodel</h2> |
| 188 | 204 | <form method="POST"> |
| 189 | 205 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -242,7 +258,9 @@ discard block |
||
| 242 | 258 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
| 243 | 259 | } |
| 244 | 260 | |
| 245 | - <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?> |
|
| 261 | + <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) |
|
| 262 | +{ |
|
| 263 | +?> |
|
| 246 | 264 | |
| 247 | 265 | |
| 248 | 266 | |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | } |
| 50 | 50 | if(!isset($posts[0])) |
| 51 | 51 | { |
| 52 | - error_log('Fehler: ' . print_r($posts, true) . print_r($posts['recent'], true) . print_r($posts['posts'], true)); |
|
| 52 | + error_log('Fehler: ' . print_r($posts, TRUE) . print_r($posts['recent'], TRUE) . print_r($posts['posts'], TRUE)); |
|
| 53 | 53 | } |
| 54 | 54 | ?> |
| 55 | 55 | <!DOCTYPE html> |
@@ -2,22 +2,22 @@ |
||
| 2 | 2 | class PostCaptcha extends AbstractRequest |
| 3 | 3 | { |
| 4 | 4 | public $captchaKey; |
| 5 | - public $captchaSolution; |
|
| 5 | + public $captchaSolution; |
|
| 6 | 6 | |
| 7 | - function getApiEndPoint() |
|
| 8 | - { |
|
| 9 | - return '/v3/user/verification/imageCaptcha/'; |
|
| 10 | - } |
|
| 11 | - function getPayload() |
|
| 12 | - { |
|
| 13 | - return array( |
|
| 14 | - 'key' => $this->captchaKey, |
|
| 15 | - 'answer' => $this->captchaSolution, |
|
| 16 | - ); |
|
| 17 | - } |
|
| 18 | - function getMethod() |
|
| 19 | - { |
|
| 20 | - return 'POST'; |
|
| 21 | - } |
|
| 7 | + function getApiEndPoint() |
|
| 8 | + { |
|
| 9 | + return '/v3/user/verification/imageCaptcha/'; |
|
| 10 | + } |
|
| 11 | + function getPayload() |
|
| 12 | + { |
|
| 13 | + return array( |
|
| 14 | + 'key' => $this->captchaKey, |
|
| 15 | + 'answer' => $this->captchaSolution, |
|
| 16 | + ); |
|
| 17 | + } |
|
| 18 | + function getMethod() |
|
| 19 | + { |
|
| 20 | + return 'POST'; |
|
| 21 | + } |
|
| 22 | 22 | } |
| 23 | 23 | |
@@ -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) |
@@ -41,36 +41,36 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | function isUserBot() |
| 43 | 43 | { |
| 44 | - preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
| 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) |
| 50 | 50 | { |
| 51 | - if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
| 52 | - { |
|
| 53 | - return FALSE; |
|
| 54 | - } |
|
| 55 | - else |
|
| 56 | - { |
|
| 57 | - return TRUE; |
|
| 58 | - } |
|
| 51 | + if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
| 52 | + { |
|
| 53 | + return FALSE; |
|
| 54 | + } |
|
| 55 | + else |
|
| 56 | + { |
|
| 57 | + return TRUE; |
|
| 58 | + } |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | function isDeviceUidInDatabase($deviceUid) |
| 62 | 62 | { |
| 63 | - $db = new DatabaseConnect(); |
|
| 64 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 65 | - |
|
| 66 | - if ($result->num_rows > 0) |
|
| 67 | - { |
|
| 68 | - return TRUE; |
|
| 69 | - } |
|
| 70 | - else |
|
| 71 | - { |
|
| 72 | - return FALSE; |
|
| 73 | - } |
|
| 63 | + $db = new DatabaseConnect(); |
|
| 64 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 65 | + |
|
| 66 | + if ($result->num_rows > 0) |
|
| 67 | + { |
|
| 68 | + return TRUE; |
|
| 69 | + } |
|
| 70 | + else |
|
| 71 | + { |
|
| 72 | + return FALSE; |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | //Check if it's a Spider or Google Bot |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | if(configPropertyExists($config, 'karmaDeviceUid')) |
| 100 | - { |
|
| 101 | - $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
| 102 | - } |
|
| 103 | - else |
|
| 104 | - { |
|
| 105 | - error_log("No Karma deviceUid set in config file"); |
|
| 100 | + { |
|
| 101 | + $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
| 102 | + } |
|
| 103 | + else |
|
| 104 | + { |
|
| 105 | + error_log("No Karma deviceUid set in config file"); |
|
| 106 | 106 | $jodelAccountForKarma = new JodelAccount($deviceUid); |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | /* |
| 110 | 110 | * Cunstruct View |
@@ -212,14 +212,14 @@ discard block |
||
| 212 | 212 | { |
| 213 | 213 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
| 214 | 214 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
| 215 | - { |
|
| 216 | - header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
| 217 | - } |
|
| 218 | - else |
|
| 219 | - { |
|
| 220 | - header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
| 221 | - } |
|
| 222 | - die(); |
|
| 215 | + { |
|
| 216 | + header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
| 217 | + } |
|
| 218 | + else |
|
| 219 | + { |
|
| 220 | + header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
| 221 | + } |
|
| 222 | + die(); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | //SendJodel |
@@ -43,7 +43,7 @@ discard block |
||
| 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) |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | function isDeviceUidInDatabase($deviceUid) |
| 62 | 62 | { |
| 63 | 63 | $db = new DatabaseConnect(); |
| 64 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 64 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
| 65 | 65 | |
| 66 | - if ($result->num_rows > 0) |
|
| 66 | + if($result->num_rows > 0) |
|
| 67 | 67 | { |
| 68 | 68 | return TRUE; |
| 69 | 69 | } |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId'])) |
| 86 | 86 | { |
| 87 | 87 | $jodelAccountForView = new JodelAccount(); |
| 88 | - setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time()+60*60*24*365*10); |
|
| 89 | - error_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 88 | + setcookie('JodelDeviceId', $jodelAccountForView->deviceUid, time() + 60 * 60 * 24 * 365 * 10); |
|
| 89 | + error_log('Created account with JodelDeviceId:' . $jodelAccountForView->deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
|
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | else |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | if(isset($_GET['view'])) |
| 167 | 167 | { |
| 168 | - switch ($_GET['view']) { |
|
| 168 | + switch($_GET['view']) { |
|
| 169 | 169 | case 'discussed': |
| 170 | 170 | $view = 'discussed'; |
| 171 | 171 | break; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | if(configPropertyExists($config, 'karmaDeviceUid')) |
| 100 | - { |
|
| 100 | + { |
|
| 101 | 101 | $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
| 102 | 102 | } |
| 103 | 103 | else |
@@ -165,7 +165,8 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | if(isset($_GET['view'])) |
| 167 | 167 | { |
| 168 | - switch ($_GET['view']) { |
|
| 168 | + switch ($_GET['view']) |
|
| 169 | + { |
|
| 169 | 170 | case 'discussed': |
| 170 | 171 | $view = 'discussed'; |
| 171 | 172 | break; |
@@ -212,7 +213,7 @@ discard block |
||
| 212 | 213 | { |
| 213 | 214 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
| 214 | 215 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
| 215 | - { |
|
| 216 | + { |
|
| 216 | 217 | header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
| 217 | 218 | } |
| 218 | 219 | else |
@@ -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()) |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } |
| 142 | 142 | else |
| 143 | 143 | { |
| 144 | - error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 144 | + error_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; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $db = new DatabaseConnect(); |
| 317 | 317 | $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
| 318 | 318 | |
| 319 | - if ($result->num_rows > 0) |
|
| 319 | + if($result->num_rows > 0) |
|
| 320 | 320 | { |
| 321 | 321 | // output data of each row |
| 322 | 322 | while($row = $result->fetch_assoc()) |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | expiration_date='" . $expiration_date . "' |
| 356 | 356 | WHERE device_uid='" . $device_uid . "'"); |
| 357 | 357 | |
| 358 | - if($result === false){ |
|
| 358 | + if($result === false) { |
|
| 359 | 359 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
| 360 | 360 | } |
| 361 | 361 | } |
@@ -365,11 +365,11 @@ discard block |
||
| 365 | 365 | function getAccessToken() |
| 366 | 366 | { |
| 367 | 367 | $db = new DatabaseConnect(); |
| 368 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 368 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 369 | 369 | |
| 370 | 370 | $accessToken; |
| 371 | 371 | |
| 372 | - if ($result->num_rows > 0) |
|
| 372 | + if($result->num_rows > 0) |
|
| 373 | 373 | { |
| 374 | 374 | // output data of each row |
| 375 | 375 | while($row = $result->fetch_assoc()) |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 436 | 436 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
| 437 | 437 | |
| 438 | - if($result === false){ |
|
| 438 | + if($result === false) { |
|
| 439 | 439 | $error = db_error(); |
| 440 | 440 | echo $error; |
| 441 | 441 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -463,11 +463,11 @@ discard block |
||
| 463 | 463 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
| 464 | 464 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
| 465 | 465 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
| 466 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 466 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 467 | 467 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 468 | 468 | |
| 469 | 469 | $success = TRUE; |
| 470 | - if($result === false){ |
|
| 470 | + if($result === false) { |
|
| 471 | 471 | $error = db_error(); |
| 472 | 472 | echo $error; |
| 473 | 473 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
| 88 | 88 | { |
| 89 | 89 | return TRUE; |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | else |
| 92 | 92 | { |
| 93 | 93 | return FALSE; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | if(substr($_GET['city'], 0, 1) === '#') |
| 101 | 101 | { |
| 102 | 102 | return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
| 103 | - } |
|
| 103 | + } |
|
| 104 | 104 | else |
| 105 | 105 | { |
| 106 | 106 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
@@ -262,7 +262,8 @@ discard block |
||
| 262 | 262 | if(isset($_POST['color'])) |
| 263 | 263 | { |
| 264 | 264 | $color = $_POST['color']; |
| 265 | - switch ($color) { |
|
| 265 | + switch ($color) |
|
| 266 | + { |
|
| 266 | 267 | case '8ABDB0': |
| 267 | 268 | $color = '8ABDB0'; |
| 268 | 269 | break; |
@@ -355,7 +356,8 @@ discard block |
||
| 355 | 356 | expiration_date='" . $expiration_date . "' |
| 356 | 357 | WHERE device_uid='" . $device_uid . "'"); |
| 357 | 358 | |
| 358 | - if($result === false){ |
|
| 359 | + if($result === false) |
|
| 360 | + { |
|
| 359 | 361 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
| 360 | 362 | } |
| 361 | 363 | } |
@@ -435,14 +437,16 @@ discard block |
||
| 435 | 437 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 436 | 438 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
| 437 | 439 | |
| 438 | - if($result === false){ |
|
| 440 | + if($result === false) |
|
| 441 | + { |
|
| 439 | 442 | $error = db_error(); |
| 440 | 443 | echo $error; |
| 441 | 444 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
| 442 | 445 | } |
| 443 | 446 | } |
| 444 | 447 | |
| 445 | - function registerAccount($location) { |
|
| 448 | + function registerAccount($location) |
|
| 449 | + { |
|
| 446 | 450 | $accountCreator = new CreateUser(); |
| 447 | 451 | $accountCreator->setLocation($location); |
| 448 | 452 | $data = $accountCreator->execute(); |
@@ -467,7 +471,8 @@ discard block |
||
| 467 | 471 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 468 | 472 | |
| 469 | 473 | $success = TRUE; |
| 470 | - if($result === false){ |
|
| 474 | + if($result === false) |
|
| 475 | + { |
|
| 471 | 476 | $error = db_error(); |
| 472 | 477 | echo $error; |
| 473 | 478 | 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(); |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
| 107 | 107 | $result = Requests::post($url); |
| 108 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
| 108 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
| 109 | 109 | { |
| 110 | 110 | return "0 results"; |
| 111 | 111 | } |
| 112 | 112 | else |
| 113 | 113 | { |
| 114 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
| 115 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
| 116 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
| 114 | + $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name']; |
|
| 115 | + $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']; |
|
| 116 | + $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']; |
|
| 117 | 117 | |
| 118 | 118 | $location = new Location(); |
| 119 | 119 | $location->setLat($lat); |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | lng='" . $lng . "' |
| 136 | 136 | WHERE access_token='" . $this->accessToken . "'"); |
| 137 | 137 | |
| 138 | - if($result === false) |
|
| 138 | + if($result === FALSE) |
|
| 139 | 139 | { |
| 140 | 140 | echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
| 141 | 141 | } |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | expiration_date='" . $expiration_date . "' |
| 356 | 356 | WHERE device_uid='" . $device_uid . "'"); |
| 357 | 357 | |
| 358 | - if($result === false){ |
|
| 358 | + if($result === FALSE){ |
|
| 359 | 359 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
| 360 | 360 | } |
| 361 | 361 | } |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
| 405 | 405 | |
| 406 | - if($result === false) |
|
| 406 | + if($result === FALSE) |
|
| 407 | 407 | { |
| 408 | 408 | $error = db_error(); |
| 409 | 409 | echo $error; |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
| 436 | 436 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
| 437 | 437 | |
| 438 | - if($result === false){ |
|
| 438 | + if($result === FALSE){ |
|
| 439 | 439 | $error = db_error(); |
| 440 | 440 | echo $error; |
| 441 | 441 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
| 468 | 468 | |
| 469 | 469 | $success = TRUE; |
| 470 | - if($result === false){ |
|
| 470 | + if($result === FALSE){ |
|
| 471 | 471 | $error = db_error(); |
| 472 | 472 | echo $error; |
| 473 | 473 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -2,491 +2,491 @@ |
||
| 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 | - echo "Error: 0 results"; |
|
| 84 | - error_log("Error no Location found - getLocation"); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
|
| 88 | - { |
|
| 89 | - return TRUE; |
|
| 90 | - } |
|
| 91 | - else |
|
| 92 | - { |
|
| 93 | - return FALSE; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - function setLocation() |
|
| 98 | - { |
|
| 99 | - //Is Channel or City |
|
| 100 | - if(substr($_GET['city'], 0, 1) === '#') |
|
| 101 | - { |
|
| 102 | - return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
| 103 | - } |
|
| 104 | - else |
|
| 105 | - { |
|
| 106 | - $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
| 107 | - $result = Requests::post($url); |
|
| 108 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
| 109 | - { |
|
| 110 | - return "0 results"; |
|
| 111 | - } |
|
| 112 | - else |
|
| 113 | - { |
|
| 114 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
| 115 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
| 116 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
| 117 | - |
|
| 118 | - $location = new Location(); |
|
| 119 | - $location->setLat($lat); |
|
| 120 | - $location->setLng($lng); |
|
| 121 | - $location->setCityName($name); |
|
| 122 | - $accountCreator = new UpdateLocation(); |
|
| 123 | - $accountCreator->setLocation($location); |
|
| 124 | - $accountCreator->setAccessToken($this->accessToken); |
|
| 125 | - $data = $accountCreator->execute(); |
|
| 126 | - |
|
| 127 | - //safe location to db |
|
| 128 | - $db = new DatabaseConnect(); |
|
| 129 | - |
|
| 130 | - if($data == 'Success') |
|
| 131 | - { |
|
| 132 | - $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 | + echo "Error: 0 results"; |
|
| 84 | + error_log("Error no Location found - getLocation"); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + if($location->getLat() == $lat && $location->getLng() == $lng && $location->getCityName() == $name) |
|
| 88 | + { |
|
| 89 | + return TRUE; |
|
| 90 | + } |
|
| 91 | + else |
|
| 92 | + { |
|
| 93 | + return FALSE; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + function setLocation() |
|
| 98 | + { |
|
| 99 | + //Is Channel or City |
|
| 100 | + if(substr($_GET['city'], 0, 1) === '#') |
|
| 101 | + { |
|
| 102 | + return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
|
| 103 | + } |
|
| 104 | + else |
|
| 105 | + { |
|
| 106 | + $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
|
| 107 | + $result = Requests::post($url); |
|
| 108 | + if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
| 109 | + { |
|
| 110 | + return "0 results"; |
|
| 111 | + } |
|
| 112 | + else |
|
| 113 | + { |
|
| 114 | + $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
| 115 | + $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
| 116 | + $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
| 117 | + |
|
| 118 | + $location = new Location(); |
|
| 119 | + $location->setLat($lat); |
|
| 120 | + $location->setLng($lng); |
|
| 121 | + $location->setCityName($name); |
|
| 122 | + $accountCreator = new UpdateLocation(); |
|
| 123 | + $accountCreator->setLocation($location); |
|
| 124 | + $accountCreator->setAccessToken($this->accessToken); |
|
| 125 | + $data = $accountCreator->execute(); |
|
| 126 | + |
|
| 127 | + //safe location to db |
|
| 128 | + $db = new DatabaseConnect(); |
|
| 129 | + |
|
| 130 | + if($data == 'Success') |
|
| 131 | + { |
|
| 132 | + $result = $db->query("UPDATE accounts |
|
| 133 | 133 | SET name='" . $name . "', |
| 134 | 134 | lat='" . $lat . "', |
| 135 | 135 | lng='" . $lng . "' |
| 136 | 136 | WHERE access_token='" . $this->accessToken . "'"); |
| 137 | 137 | |
| 138 | - if($result === false) |
|
| 139 | - { |
|
| 140 | - echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
| 141 | - } |
|
| 142 | - else |
|
| 143 | - { |
|
| 144 | - error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return $name; |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - function getLocation() |
|
| 154 | - { |
|
| 155 | - $db = new DatabaseConnect(); |
|
| 156 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 138 | + if($result === false) |
|
| 139 | + { |
|
| 140 | + echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
|
| 141 | + } |
|
| 142 | + else |
|
| 143 | + { |
|
| 144 | + error_log('User with JodelDeviceId:' . $this->deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return $name; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + function getLocation() |
|
| 154 | + { |
|
| 155 | + $db = new DatabaseConnect(); |
|
| 156 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 157 | 157 | |
| 158 | - $location = new Location(); |
|
| 158 | + $location = new Location(); |
|
| 159 | 159 | |
| 160 | - if ($result->num_rows > 0) |
|
| 161 | - { |
|
| 162 | - // output data of each row |
|
| 163 | - while($row = $result->fetch_assoc()) |
|
| 164 | - { |
|
| 165 | - $location->setLat($row['lat']); |
|
| 166 | - $location->setLng($row['lng']); |
|
| 167 | - $location->setCityName($row['name']); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - else |
|
| 171 | - { |
|
| 172 | - echo "Error: 0 results"; |
|
| 173 | - error_log("Error no Location found - getLocation"); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - return $location; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - function verifyCaptcha() |
|
| 180 | - { |
|
| 181 | - if(isset($_GET['deviceUid'])) |
|
| 182 | - { |
|
| 183 | - $deviceUid = $_GET['deviceUid']; |
|
| 184 | - } |
|
| 185 | - if(isset($_POST['deviceUid'])) |
|
| 186 | - { |
|
| 187 | - $deviceUid = $_POST['deviceUid']; |
|
| 188 | - } |
|
| 189 | - $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
| 190 | - |
|
| 191 | - $solution = $_GET['solution']; |
|
| 192 | - $solution = array_map('intval', explode('-', $solution)); |
|
| 193 | - |
|
| 194 | - $accountCreator = new PostCaptcha(); |
|
| 195 | - $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
| 196 | - $accountCreator->captchaKey = $_GET['key']; |
|
| 197 | - $accountCreator->captchaSolution = $solution; |
|
| 198 | - $verified = $accountCreator->execute(); |
|
| 199 | - |
|
| 200 | - if(isset($verified->status_code)) |
|
| 201 | - { |
|
| 202 | - return $verified->status_code; |
|
| 203 | - } |
|
| 204 | - return $verified['verified']; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - //ToDo Spider Check |
|
| 208 | - function votePostId($postId, $vote) |
|
| 209 | - { |
|
| 210 | - if(!$this->isAccountVerified()) |
|
| 211 | - { |
|
| 212 | - $view = new View(); |
|
| 213 | - $view->showCaptcha($this->accessToken, $this->deviceUid); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - if(!$this->hasVoted($postId)) |
|
| 217 | - { |
|
| 218 | - if($vote == "up") |
|
| 219 | - { |
|
| 220 | - $accountCreator = new Upvote(); |
|
| 221 | - } |
|
| 222 | - else if($vote == "down") |
|
| 223 | - { |
|
| 224 | - $accountCreator = new Downvote(); |
|
| 225 | - } |
|
| 226 | - $accountCreator->setAccessToken($this->accessToken); |
|
| 227 | - $accountCreator->postId = htmlspecialchars($postId); |
|
| 228 | - $data = $accountCreator->execute(); |
|
| 229 | - |
|
| 230 | - if(array_key_exists('post', $data)) |
|
| 231 | - { |
|
| 232 | - $this->addVoteWithPostIdAndType($postId, $vote); |
|
| 233 | - return TRUE; |
|
| 234 | - } |
|
| 235 | - else |
|
| 236 | - { |
|
| 237 | - error_log("Could not vote: " . var_dump($data)); |
|
| 238 | - return FALSE; |
|
| 239 | - } |
|
| 240 | - } |
|
| 241 | - else |
|
| 242 | - { |
|
| 243 | - return FALSE; |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - //ToDo Spider Check |
|
| 248 | - function sendJodel($location) |
|
| 249 | - { |
|
| 250 | - if(!$this->isAccountVerified()) |
|
| 251 | - { |
|
| 252 | - showCaptcha($this->accessToken); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - $accountCreator = new SendJodel(); |
|
| 256 | - |
|
| 257 | - if(isset($_POST['ancestor'])) |
|
| 258 | - { |
|
| 259 | - $ancestor = $_POST['ancestor']; |
|
| 260 | - $accountCreator->ancestor = $ancestor; |
|
| 261 | - } |
|
| 262 | - if(isset($_POST['color'])) |
|
| 263 | - { |
|
| 264 | - $color = $_POST['color']; |
|
| 265 | - switch ($color) { |
|
| 266 | - case '8ABDB0': |
|
| 267 | - $color = '8ABDB0'; |
|
| 268 | - break; |
|
| 269 | - case '9EC41C': |
|
| 270 | - $color = '9EC41C'; |
|
| 271 | - break; |
|
| 272 | - case '06A3CB': |
|
| 273 | - $color = '06A3CB'; |
|
| 274 | - break; |
|
| 275 | - case 'FFBA00': |
|
| 276 | - $color = 'FFBA00'; |
|
| 277 | - break; |
|
| 278 | - case 'DD5F5F': |
|
| 279 | - $color = 'DD5F5F'; |
|
| 280 | - break; |
|
| 281 | - case 'FF9908': |
|
| 282 | - $color = 'FF9908'; |
|
| 283 | - break; |
|
| 284 | - default: |
|
| 285 | - $color = '8ABDB0'; |
|
| 286 | - break; |
|
| 287 | - } |
|
| 288 | - $accountCreator->color = $color; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - $accountCreatorLocation = new UpdateLocation(); |
|
| 292 | - $accountCreatorLocation->setLocation($location); |
|
| 293 | - $accountCreatorLocation->setAccessToken($this->accessToken); |
|
| 294 | - $data = $accountCreatorLocation->execute(); |
|
| 160 | + if ($result->num_rows > 0) |
|
| 161 | + { |
|
| 162 | + // output data of each row |
|
| 163 | + while($row = $result->fetch_assoc()) |
|
| 164 | + { |
|
| 165 | + $location->setLat($row['lat']); |
|
| 166 | + $location->setLng($row['lng']); |
|
| 167 | + $location->setCityName($row['name']); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + else |
|
| 171 | + { |
|
| 172 | + echo "Error: 0 results"; |
|
| 173 | + error_log("Error no Location found - getLocation"); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + return $location; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + function verifyCaptcha() |
|
| 180 | + { |
|
| 181 | + if(isset($_GET['deviceUid'])) |
|
| 182 | + { |
|
| 183 | + $deviceUid = $_GET['deviceUid']; |
|
| 184 | + } |
|
| 185 | + if(isset($_POST['deviceUid'])) |
|
| 186 | + { |
|
| 187 | + $deviceUid = $_POST['deviceUid']; |
|
| 188 | + } |
|
| 189 | + $jodelAccountForVerify = new JodelAccount($deviceUid); |
|
| 190 | + |
|
| 191 | + $solution = $_GET['solution']; |
|
| 192 | + $solution = array_map('intval', explode('-', $solution)); |
|
| 193 | + |
|
| 194 | + $accountCreator = new PostCaptcha(); |
|
| 195 | + $accountCreator->setAccessToken($jodelAccountForVerify->accessToken); |
|
| 196 | + $accountCreator->captchaKey = $_GET['key']; |
|
| 197 | + $accountCreator->captchaSolution = $solution; |
|
| 198 | + $verified = $accountCreator->execute(); |
|
| 199 | + |
|
| 200 | + if(isset($verified->status_code)) |
|
| 201 | + { |
|
| 202 | + return $verified->status_code; |
|
| 203 | + } |
|
| 204 | + return $verified['verified']; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + //ToDo Spider Check |
|
| 208 | + function votePostId($postId, $vote) |
|
| 209 | + { |
|
| 210 | + if(!$this->isAccountVerified()) |
|
| 211 | + { |
|
| 212 | + $view = new View(); |
|
| 213 | + $view->showCaptcha($this->accessToken, $this->deviceUid); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + if(!$this->hasVoted($postId)) |
|
| 217 | + { |
|
| 218 | + if($vote == "up") |
|
| 219 | + { |
|
| 220 | + $accountCreator = new Upvote(); |
|
| 221 | + } |
|
| 222 | + else if($vote == "down") |
|
| 223 | + { |
|
| 224 | + $accountCreator = new Downvote(); |
|
| 225 | + } |
|
| 226 | + $accountCreator->setAccessToken($this->accessToken); |
|
| 227 | + $accountCreator->postId = htmlspecialchars($postId); |
|
| 228 | + $data = $accountCreator->execute(); |
|
| 229 | + |
|
| 230 | + if(array_key_exists('post', $data)) |
|
| 231 | + { |
|
| 232 | + $this->addVoteWithPostIdAndType($postId, $vote); |
|
| 233 | + return TRUE; |
|
| 234 | + } |
|
| 235 | + else |
|
| 236 | + { |
|
| 237 | + error_log("Could not vote: " . var_dump($data)); |
|
| 238 | + return FALSE; |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | + else |
|
| 242 | + { |
|
| 243 | + return FALSE; |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + //ToDo Spider Check |
|
| 248 | + function sendJodel($location) |
|
| 249 | + { |
|
| 250 | + if(!$this->isAccountVerified()) |
|
| 251 | + { |
|
| 252 | + showCaptcha($this->accessToken); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + $accountCreator = new SendJodel(); |
|
| 256 | + |
|
| 257 | + if(isset($_POST['ancestor'])) |
|
| 258 | + { |
|
| 259 | + $ancestor = $_POST['ancestor']; |
|
| 260 | + $accountCreator->ancestor = $ancestor; |
|
| 261 | + } |
|
| 262 | + if(isset($_POST['color'])) |
|
| 263 | + { |
|
| 264 | + $color = $_POST['color']; |
|
| 265 | + switch ($color) { |
|
| 266 | + case '8ABDB0': |
|
| 267 | + $color = '8ABDB0'; |
|
| 268 | + break; |
|
| 269 | + case '9EC41C': |
|
| 270 | + $color = '9EC41C'; |
|
| 271 | + break; |
|
| 272 | + case '06A3CB': |
|
| 273 | + $color = '06A3CB'; |
|
| 274 | + break; |
|
| 275 | + case 'FFBA00': |
|
| 276 | + $color = 'FFBA00'; |
|
| 277 | + break; |
|
| 278 | + case 'DD5F5F': |
|
| 279 | + $color = 'DD5F5F'; |
|
| 280 | + break; |
|
| 281 | + case 'FF9908': |
|
| 282 | + $color = 'FF9908'; |
|
| 283 | + break; |
|
| 284 | + default: |
|
| 285 | + $color = '8ABDB0'; |
|
| 286 | + break; |
|
| 287 | + } |
|
| 288 | + $accountCreator->color = $color; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + $accountCreatorLocation = new UpdateLocation(); |
|
| 292 | + $accountCreatorLocation->setLocation($location); |
|
| 293 | + $accountCreatorLocation->setAccessToken($this->accessToken); |
|
| 294 | + $data = $accountCreatorLocation->execute(); |
|
| 295 | 295 | |
| 296 | - $accountCreator->location = $this->location; |
|
| 296 | + $accountCreator->location = $this->location; |
|
| 297 | 297 | |
| 298 | - $accountCreator->setAccessToken($this->accessToken); |
|
| 299 | - $data = $accountCreator->execute(); |
|
| 300 | - |
|
| 301 | - if(isset($_POST['ancestor'])) |
|
| 302 | - { |
|
| 303 | - $actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 304 | - header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id'])); |
|
| 305 | - exit; |
|
| 306 | - } |
|
| 307 | - else |
|
| 308 | - { |
|
| 309 | - header('Location: ./#'); |
|
| 310 | - exit; |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - function isTokenFresh() |
|
| 315 | - { |
|
| 316 | - $db = new DatabaseConnect(); |
|
| 317 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 318 | - |
|
| 319 | - if ($result->num_rows > 0) |
|
| 320 | - { |
|
| 321 | - // output data of each row |
|
| 322 | - while($row = $result->fetch_assoc()) |
|
| 323 | - { |
|
| 324 | - $expiration_date = $row["expiration_date"]; |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - else |
|
| 328 | - { |
|
| 329 | - error_log('0 results'); |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - if($expiration_date <= time()) |
|
| 333 | - { |
|
| 334 | - return FALSE; |
|
| 335 | - } |
|
| 298 | + $accountCreator->setAccessToken($this->accessToken); |
|
| 299 | + $data = $accountCreator->execute(); |
|
| 300 | + |
|
| 301 | + if(isset($_POST['ancestor'])) |
|
| 302 | + { |
|
| 303 | + $actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 304 | + header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id'])); |
|
| 305 | + exit; |
|
| 306 | + } |
|
| 307 | + else |
|
| 308 | + { |
|
| 309 | + header('Location: ./#'); |
|
| 310 | + exit; |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + function isTokenFresh() |
|
| 315 | + { |
|
| 316 | + $db = new DatabaseConnect(); |
|
| 317 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 318 | + |
|
| 319 | + if ($result->num_rows > 0) |
|
| 320 | + { |
|
| 321 | + // output data of each row |
|
| 322 | + while($row = $result->fetch_assoc()) |
|
| 323 | + { |
|
| 324 | + $expiration_date = $row["expiration_date"]; |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + else |
|
| 328 | + { |
|
| 329 | + error_log('0 results'); |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + if($expiration_date <= time()) |
|
| 333 | + { |
|
| 334 | + return FALSE; |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - return TRUE; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - function refreshToken() |
|
| 341 | - { |
|
| 342 | - $accountCreator = new CreateUser(); |
|
| 343 | - $accountCreator->setAccessToken($this->accessToken); |
|
| 344 | - $accountCreator->setDeviceUid($this->deviceUid); |
|
| 345 | - $accountCreator->setLocation($this->location); |
|
| 346 | - $data = $accountCreator->execute(); |
|
| 347 | - |
|
| 348 | - $access_token = (string)$data[0]['access_token']; |
|
| 349 | - $expiration_date = $data[0]['expiration_date']; |
|
| 350 | - $device_uid = (string)$data[1]; |
|
| 337 | + return TRUE; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + function refreshToken() |
|
| 341 | + { |
|
| 342 | + $accountCreator = new CreateUser(); |
|
| 343 | + $accountCreator->setAccessToken($this->accessToken); |
|
| 344 | + $accountCreator->setDeviceUid($this->deviceUid); |
|
| 345 | + $accountCreator->setLocation($this->location); |
|
| 346 | + $data = $accountCreator->execute(); |
|
| 347 | + |
|
| 348 | + $access_token = (string)$data[0]['access_token']; |
|
| 349 | + $expiration_date = $data[0]['expiration_date']; |
|
| 350 | + $device_uid = (string)$data[1]; |
|
| 351 | 351 | |
| 352 | - $db = new DatabaseConnect(); |
|
| 353 | - $result = $db->query("UPDATE accounts |
|
| 352 | + $db = new DatabaseConnect(); |
|
| 353 | + $result = $db->query("UPDATE accounts |
|
| 354 | 354 | SET access_token='" . $access_token . "', |
| 355 | 355 | expiration_date='" . $expiration_date . "' |
| 356 | 356 | WHERE device_uid='" . $device_uid . "'"); |
| 357 | 357 | |
| 358 | - if($result === false){ |
|
| 359 | - error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
|
| 360 | - } |
|
| 361 | - } |
|
| 358 | + if($result === false){ |
|
| 359 | + error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | 363 | |
| 364 | 364 | |
| 365 | - function getAccessToken() |
|
| 366 | - { |
|
| 367 | - $db = new DatabaseConnect(); |
|
| 368 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 365 | + function getAccessToken() |
|
| 366 | + { |
|
| 367 | + $db = new DatabaseConnect(); |
|
| 368 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $this->deviceUid . "'"); |
|
| 369 | 369 | |
| 370 | - $accessToken; |
|
| 370 | + $accessToken; |
|
| 371 | 371 | |
| 372 | - if ($result->num_rows > 0) |
|
| 373 | - { |
|
| 374 | - // output data of each row |
|
| 375 | - while($row = $result->fetch_assoc()) |
|
| 376 | - { |
|
| 377 | - $accessToken = $row['access_token']; |
|
| 378 | - } |
|
| 379 | - } |
|
| 380 | - else |
|
| 381 | - { |
|
| 382 | - error_log('Error: 0 results'); |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - return $accessToken; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - |
|
| 389 | - function getKarma() |
|
| 390 | - { |
|
| 391 | - $accountCreator = new GetKarma(); |
|
| 392 | - $accountCreator->setAccessToken($this->accessToken); |
|
| 393 | - $data = $accountCreator->execute(); |
|
| 372 | + if ($result->num_rows > 0) |
|
| 373 | + { |
|
| 374 | + // output data of each row |
|
| 375 | + while($row = $result->fetch_assoc()) |
|
| 376 | + { |
|
| 377 | + $accessToken = $row['access_token']; |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | + else |
|
| 381 | + { |
|
| 382 | + error_log('Error: 0 results'); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + return $accessToken; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + |
|
| 389 | + function getKarma() |
|
| 390 | + { |
|
| 391 | + $accountCreator = new GetKarma(); |
|
| 392 | + $accountCreator->setAccessToken($this->accessToken); |
|
| 393 | + $data = $accountCreator->execute(); |
|
| 394 | 394 | |
| 395 | - return $data["karma"]; |
|
| 396 | - } |
|
| 395 | + return $data["karma"]; |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | - function hasVoted($postId) |
|
| 399 | - { |
|
| 400 | - $db = new DatabaseConnect(); |
|
| 398 | + function hasVoted($postId) |
|
| 399 | + { |
|
| 400 | + $db = new DatabaseConnect(); |
|
| 401 | 401 | |
| 402 | - $postId = $db->real_escape_string($postId); |
|
| 402 | + $postId = $db->real_escape_string($postId); |
|
| 403 | 403 | |
| 404 | - $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
| 404 | + $result = $db->query("SELECT id FROM votes WHERE (postId = '" . $postId . "' AND device_uid = '" . $this->deviceUid . "')"); |
|
| 405 | 405 | |
| 406 | - if($result === false) |
|
| 407 | - { |
|
| 408 | - $error = db_error(); |
|
| 409 | - echo $error; |
|
| 410 | - error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - if($result->num_rows == 0) |
|
| 414 | - { |
|
| 415 | - return FALSE; |
|
| 416 | - } |
|
| 417 | - else |
|
| 418 | - { |
|
| 419 | - return TRUE; |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - function addVoteWithPostIdAndType($postId, $voteType) |
|
| 424 | - { |
|
| 425 | - $db = new DatabaseConnect(); |
|
| 426 | - |
|
| 427 | - $postId = $db->real_escape_string($postId); |
|
| 428 | - $voteType = $db->real_escape_string($voteType); |
|
| 406 | + if($result === false) |
|
| 407 | + { |
|
| 408 | + $error = db_error(); |
|
| 409 | + echo $error; |
|
| 410 | + error_log("Adding Vote failed: (" . $result->errno . ") " . $result->error); |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + if($result->num_rows == 0) |
|
| 414 | + { |
|
| 415 | + return FALSE; |
|
| 416 | + } |
|
| 417 | + else |
|
| 418 | + { |
|
| 419 | + return TRUE; |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + function addVoteWithPostIdAndType($postId, $voteType) |
|
| 424 | + { |
|
| 425 | + $db = new DatabaseConnect(); |
|
| 426 | + |
|
| 427 | + $postId = $db->real_escape_string($postId); |
|
| 428 | + $voteType = $db->real_escape_string($voteType); |
|
| 429 | 429 | |
| 430 | - if($this->hasVoted($postId)) |
|
| 431 | - { |
|
| 432 | - return "Already voted"; |
|
| 433 | - } |
|
| 430 | + if($this->hasVoted($postId)) |
|
| 431 | + { |
|
| 432 | + return "Already voted"; |
|
| 433 | + } |
|
| 434 | 434 | |
| 435 | - $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
| 435 | + $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
|
| 436 | 436 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
| 437 | 437 | |
| 438 | - if($result === false){ |
|
| 439 | - $error = db_error(); |
|
| 440 | - echo $error; |
|
| 441 | - echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
| 442 | - } |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - function registerAccount($location) { |
|
| 446 | - $accountCreator = new CreateUser(); |
|
| 447 | - $accountCreator->setLocation($location); |
|
| 448 | - $data = $accountCreator->execute(); |
|
| 438 | + if($result === false){ |
|
| 439 | + $error = db_error(); |
|
| 440 | + echo $error; |
|
| 441 | + echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
|
| 442 | + } |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + function registerAccount($location) { |
|
| 446 | + $accountCreator = new CreateUser(); |
|
| 447 | + $accountCreator->setLocation($location); |
|
| 448 | + $data = $accountCreator->execute(); |
|
| 449 | 449 | |
| 450 | - $access_token = (string)$data[0]['access_token']; |
|
| 451 | - $refresh_token = (string)$data[0]['refresh_token']; |
|
| 452 | - $token_type = (string)$data[0]['token_type']; |
|
| 453 | - $expires_in = $data[0]['expires_in']; |
|
| 454 | - $expiration_date = $data[0]['expiration_date']; |
|
| 455 | - $distinct_id = (string)$data[0]['distinct_id']; |
|
| 456 | - $device_uid = (string)$data[1]; |
|
| 457 | - |
|
| 458 | - $name = $location->cityName; |
|
| 459 | - $lat = $location->lat; |
|
| 460 | - $lng = $location->lng; |
|
| 450 | + $access_token = (string)$data[0]['access_token']; |
|
| 451 | + $refresh_token = (string)$data[0]['refresh_token']; |
|
| 452 | + $token_type = (string)$data[0]['token_type']; |
|
| 453 | + $expires_in = $data[0]['expires_in']; |
|
| 454 | + $expiration_date = $data[0]['expiration_date']; |
|
| 455 | + $distinct_id = (string)$data[0]['distinct_id']; |
|
| 456 | + $device_uid = (string)$data[1]; |
|
| 457 | + |
|
| 458 | + $name = $location->cityName; |
|
| 459 | + $lat = $location->lat; |
|
| 460 | + $lng = $location->lng; |
|
| 461 | 461 | |
| 462 | - $db = new DatabaseConnect(); |
|
| 463 | - $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
| 462 | + $db = new DatabaseConnect(); |
|
| 463 | + $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
|
| 464 | 464 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
| 465 | 465 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
| 466 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 467 | - "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
| 468 | - |
|
| 469 | - $success = TRUE; |
|
| 470 | - if($result === false){ |
|
| 471 | - $error = db_error(); |
|
| 472 | - echo $error; |
|
| 473 | - echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
| 474 | - $success = FALSE; |
|
| 475 | - } |
|
| 466 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
| 467 | + "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
|
| 468 | + |
|
| 469 | + $success = TRUE; |
|
| 470 | + if($result === false){ |
|
| 471 | + $error = db_error(); |
|
| 472 | + echo $error; |
|
| 473 | + echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
|
| 474 | + $success = FALSE; |
|
| 475 | + } |
|
| 476 | 476 | |
| 477 | - return $device_uid; |
|
| 478 | - } |
|
| 477 | + return $device_uid; |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | - function createAccount() |
|
| 481 | - { |
|
| 482 | - $config = parse_ini_file('config/config.ini.php'); |
|
| 483 | - $location = new Location(); |
|
| 484 | - $location->setLat($config['default_lat']); |
|
| 485 | - $location->setLng($config['default_lng']); |
|
| 486 | - $location->setCityName($config['default_location']); |
|
| 480 | + function createAccount() |
|
| 481 | + { |
|
| 482 | + $config = parse_ini_file('config/config.ini.php'); |
|
| 483 | + $location = new Location(); |
|
| 484 | + $location->setLat($config['default_lat']); |
|
| 485 | + $location->setLng($config['default_lng']); |
|
| 486 | + $location->setCityName($config['default_location']); |
|
| 487 | 487 | |
| 488 | - $deviceUid = $this->registerAccount($location); |
|
| 488 | + $deviceUid = $this->registerAccount($location); |
|
| 489 | 489 | |
| 490 | - return $deviceUid; |
|
| 491 | - } |
|
| 490 | + return $deviceUid; |
|
| 491 | + } |
|
| 492 | 492 | } |
| 493 | 493 | \ No newline at end of file |
@@ -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(); |
@@ -47,25 +47,25 @@ discard block |
||
| 47 | 47 | $timediff_inDays = (string)$timediff->format('%d'); |
| 48 | 48 | $timediff_inMonth = (string)$timediff->format('%m'); |
| 49 | 49 | |
| 50 | - if($timediff_inMonth!=0) |
|
| 50 | + if($timediff_inMonth != 0) |
|
| 51 | 51 | { |
| 52 | 52 | $timediff = $timediff_inMonth . "m"; |
| 53 | 53 | } |
| 54 | 54 | else |
| 55 | 55 | { |
| 56 | - if($timediff_inDays!=0) |
|
| 56 | + if($timediff_inDays != 0) |
|
| 57 | 57 | { |
| 58 | 58 | $timediff = $timediff_inDays . "d"; |
| 59 | 59 | } |
| 60 | 60 | else |
| 61 | 61 | { |
| 62 | - if($timediff_inHours!=0) |
|
| 62 | + if($timediff_inHours != 0) |
|
| 63 | 63 | { |
| 64 | 64 | $timediff = $timediff_inHours . "h"; |
| 65 | 65 | } |
| 66 | 66 | else |
| 67 | 67 | { |
| 68 | - if($timediff_inMinutes!=0) |
|
| 68 | + if($timediff_inMinutes != 0) |
|
| 69 | 69 | { |
| 70 | 70 | $timediff = $timediff_inMinutes . "m"; |
| 71 | 71 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | ?> |
| 82 | - <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
|
| 82 | + <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color']; ?>;"> |
|
| 83 | 83 | <content> |
| 84 | 84 | <?php |
| 85 | 85 | if(isset($post['image_url'])) |
@@ -97,24 +97,24 @@ discard block |
||
| 97 | 97 | <?php |
| 98 | 98 | if($this->isDetailedView) |
| 99 | 99 | {?> |
| 100 | - <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
|
| 100 | + <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id']; ?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']); ?>" rel="nofollow"> |
|
| 101 | 101 | <?php } |
| 102 | 102 | else |
| 103 | 103 | {?> |
| 104 | - <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
| 104 | + <a href="index.php?vote=up&postId=<?php echo $post['post_id']; ?>" rel="nofollow"> |
|
| 105 | 105 | <?php } ?> |
| 106 | 106 | <i class="fa fa-angle-up fa-3x"></i> |
| 107 | 107 | </a> |
| 108 | 108 | <br /> |
| 109 | - <?php echo $post["vote_count"];?><br /> |
|
| 109 | + <?php echo $post["vote_count"]; ?><br /> |
|
| 110 | 110 | <?php |
| 111 | 111 | if($this->isDetailedView) |
| 112 | 112 | {?> |
| 113 | - <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
|
| 113 | + <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id']; ?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']); ?>" rel="nofollow"> |
|
| 114 | 114 | <?php } |
| 115 | 115 | else |
| 116 | 116 | {?> |
| 117 | - <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
|
| 117 | + <a href="index.php?vote=down&postId=<?php echo $post['post_id']; ?>" rel="nofollow"> |
|
| 118 | 118 | <?php } ?> |
| 119 | 119 | <i class="fa fa-angle-down fa-3x"></i> |
| 120 | 120 | </a> |
@@ -126,14 +126,14 @@ discard block |
||
| 126 | 126 | <td class="time"> |
| 127 | 127 | <span class="tip" data-tooltip="Time"> |
| 128 | 128 | <i class="fa fa-clock-o"></i> |
| 129 | - <?php echo $timediff;?> |
|
| 130 | - <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
|
| 129 | + <?php echo $timediff; ?> |
|
| 130 | + <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span> |
|
| 131 | 131 | </span> |
| 132 | 132 | </td> |
| 133 | 133 | <td class="comments"> |
| 134 | 134 | <?php if(!$this->isDetailedView) {?> |
| 135 | 135 | <span data-tooltip="Comments"> |
| 136 | - <a href="index.php?getPostDetails=true&view=<?php echo $this->view;?>&postId=<?php echo $post["post_id"];?>"> |
|
| 136 | + <a href="index.php?getPostDetails=true&view=<?php echo $this->view; ?>&postId=<?php echo $post["post_id"]; ?>"> |
|
| 137 | 137 | <i class="fa fa-commenting-o"></i> |
| 138 | 138 | <?php if(array_key_exists("child_count", $post)) { |
| 139 | 139 | echo $post["child_count"]; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | ?> |
| 164 | 164 | <span data-tooltip="Author"> |
| 165 | - <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
|
| 165 | + <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> | |
|
| 166 | 166 | </span> |
| 167 | 167 | <?php |
| 168 | 168 | } |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | <span class="tip" data-tooltip="Distance"> |
| 174 | 174 | <i class="fa fa-map-marker"></i> |
| 175 | - <?php echo $post['distance'];?> km |
|
| 176 | - <span class="tiptext"><?php echo $post['location']['name'];?></span> |
|
| 175 | + <?php echo $post['distance']; ?> km |
|
| 176 | + <span class="tiptext"><?php echo $post['location']['name']; ?></span> |
|
| 177 | 177 | </span> |
| 178 | 178 | </td> |
| 179 | 179 | </tr> |
@@ -32,7 +32,8 @@ discard block |
||
| 32 | 32 | * Compute HTML Code |
| 33 | 33 | */ |
| 34 | 34 | function jodelToHtml($post) |
| 35 | - { //ToDO |
|
| 35 | + { |
|
| 36 | +//ToDO |
|
| 36 | 37 | //Replace # with link |
| 37 | 38 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
| 38 | 39 | |
@@ -88,7 +89,8 @@ discard block |
||
| 88 | 89 | |
| 89 | 90 | echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
| 90 | 91 | } |
| 91 | - else { |
|
| 92 | + else |
|
| 93 | + { |
|
| 92 | 94 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
| 93 | 95 | } |
| 94 | 96 | ?> |
@@ -96,11 +98,13 @@ discard block |
||
| 96 | 98 | <aside> |
| 97 | 99 | <?php |
| 98 | 100 | if($this->isDetailedView) |
| 99 | - {?> |
|
| 101 | + { |
|
| 102 | +?> |
|
| 100 | 103 | <a href="index.php?vote=up&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
| 101 | 104 | <?php } |
| 102 | - else |
|
| 103 | - {?> |
|
| 105 | +else |
|
| 106 | + { |
|
| 107 | +?> |
|
| 104 | 108 | <a href="index.php?vote=up&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
| 105 | 109 | <?php } ?> |
| 106 | 110 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -109,11 +113,13 @@ discard block |
||
| 109 | 113 | <?php echo $post["vote_count"];?><br /> |
| 110 | 114 | <?php |
| 111 | 115 | if($this->isDetailedView) |
| 112 | - {?> |
|
| 116 | + { |
|
| 117 | +?> |
|
| 113 | 118 | <a href="index.php?vote=down&getPostDetails=true&postId=<?php echo $post['post_id'];?>&postId_parent=<?php echo htmlspecialchars($_GET['postId']);?>" rel="nofollow"> |
| 114 | 119 | <?php } |
| 115 | - else |
|
| 116 | - {?> |
|
| 120 | +else |
|
| 121 | + { |
|
| 122 | +?> |
|
| 117 | 123 | <a href="index.php?vote=down&postId=<?php echo $post['post_id'];?>" rel="nofollow"> |
| 118 | 124 | <?php } ?> |
| 119 | 125 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -131,13 +137,19 @@ discard block |
||
| 131 | 137 | </span> |
| 132 | 138 | </td> |
| 133 | 139 | <td class="comments"> |
| 134 | - <?php if(!$this->isDetailedView) {?> |
|
| 140 | + <?php if(!$this->isDetailedView) |
|
| 141 | +{ |
|
| 142 | +?> |
|
| 135 | 143 | <span data-tooltip="Comments"> |
| 136 | 144 | <a href="index.php?getPostDetails=true&view=<?php echo $this->view;?>&postId=<?php echo $post["post_id"];?>"> |
| 137 | 145 | <i class="fa fa-commenting-o"></i> |
| 138 | - <?php if(array_key_exists("child_count", $post)) { |
|
| 146 | + <?php if(array_key_exists("child_count", $post)) |
|
| 147 | +{ |
|
| 139 | 148 | echo $post["child_count"]; |
| 140 | - } else echo "0"; |
|
| 149 | + } |
|
| 150 | + else { |
|
| 151 | + echo "0"; |
|
| 152 | + } |
|
| 141 | 153 | ?> |
| 142 | 154 | </a> |
| 143 | 155 | </span> |
@@ -303,7 +315,7 @@ discard block |
||
| 303 | 315 | $data = $accountCreator->execute(); |
| 304 | 316 | } |
| 305 | 317 | if(array_key_exists('recent', $data)) |
| 306 | - { |
|
| 318 | + { |
|
| 307 | 319 | return $data['recent']; |
| 308 | 320 | } |
| 309 | 321 | else if(array_key_exists('posts', $data)) |
@@ -313,7 +313,7 @@ |
||
| 313 | 313 | else |
| 314 | 314 | { |
| 315 | 315 | error_log('Fehler View getPosts '); |
| 316 | - error_log(print_r($data, true)); |
|
| 316 | + error_log(print_r($data, TRUE)); |
|
| 317 | 317 | |
| 318 | 318 | $notFound[0] = array( |
| 319 | 319 | "post_id" => "0", |
@@ -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 = '#all', $view = 'time', $postId = '') |
|
| 16 | - { |
|
| 17 | - $this->baseUrl = $baseUrl; |
|
| 18 | - $this->country = $country; |
|
| 19 | - $this->city = $city; |
|
| 20 | - $this->hashtag = $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 = '#all', $view = 'time', $postId = '') |
|
| 16 | + { |
|
| 17 | + $this->baseUrl = $baseUrl; |
|
| 18 | + $this->country = $country; |
|
| 19 | + $this->city = $city; |
|
| 20 | + $this->hashtag = $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,39 +138,39 @@ discard block |
||
| 138 | 138 | <a href="index.php?getPostDetails=true&view=<?php echo $this->view;?>&postId=<?php echo $post["post_id"];?>"> |
| 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 | <?php } ?> |
| 147 | 147 | </td> |
| 148 | 148 | <td class="distance"> |
| 149 | 149 | <?php |
| 150 | - if($this->isDetailedView) |
|
| 151 | - { |
|
| 152 | - if(isset($post["parent_creator"]) && $post["parent_creator"] == 1) |
|
| 153 | - { |
|
| 154 | - ?> |
|
| 150 | + if($this->isDetailedView) |
|
| 151 | + { |
|
| 152 | + if(isset($post["parent_creator"]) && $post["parent_creator"] == 1) |
|
| 153 | + { |
|
| 154 | + ?> |
|
| 155 | 155 | <span data-tooltip="Author"> |
| 156 | 156 | <i class="fa fa-user-o"></i> OJ | |
| 157 | 157 | </span> |
| 158 | 158 | <?php |
| 159 | - } |
|
| 160 | - else |
|
| 161 | - { |
|
| 162 | - //Is not parent Jodel in detailed View |
|
| 163 | - if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post)) |
|
| 164 | - { |
|
| 165 | - ?> |
|
| 159 | + } |
|
| 160 | + else |
|
| 161 | + { |
|
| 162 | + //Is not parent Jodel in detailed View |
|
| 163 | + if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post)) |
|
| 164 | + { |
|
| 165 | + ?> |
|
| 166 | 166 | <span data-tooltip="Author"> |
| 167 | 167 | <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
| 168 | 168 | </span> |
| 169 | 169 | <?php |
| 170 | - } |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - ?> |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + ?> |
|
| 174 | 174 | |
| 175 | 175 | <span class="tip" data-tooltip="Distance"> |
| 176 | 176 | <i class="fa fa-map-marker"></i> |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | </footer> |
| 184 | 184 | </article> |
| 185 | 185 | <?php |
| 186 | - } |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -254,120 +254,120 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - function toUrl() |
|
| 258 | - { |
|
| 259 | - $url = $this->baseUrl . 'index.php?country=DE' . |
|
| 260 | - '&city=' . $this->city . |
|
| 261 | - '&hashtag=' . urlencode($this->hashtag) . |
|
| 262 | - '&view=' . $this->view; |
|
| 263 | - if($this->postId != '') |
|
| 264 | - { |
|
| 265 | - $url .= '&postId=' . $this->postId . |
|
| 266 | - '&getPostDetails=TRUE'; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - return $url; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - function changeView($view) |
|
| 273 | - { |
|
| 274 | - $tempView = clone $this; |
|
| 275 | - $tempView->view = $view; |
|
| 276 | - return $tempView; |
|
| 277 | - } |
|
| 257 | + function toUrl() |
|
| 258 | + { |
|
| 259 | + $url = $this->baseUrl . 'index.php?country=DE' . |
|
| 260 | + '&city=' . $this->city . |
|
| 261 | + '&hashtag=' . urlencode($this->hashtag) . |
|
| 262 | + '&view=' . $this->view; |
|
| 263 | + if($this->postId != '') |
|
| 264 | + { |
|
| 265 | + $url .= '&postId=' . $this->postId . |
|
| 266 | + '&getPostDetails=TRUE'; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + return $url; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + function changeView($view) |
|
| 273 | + { |
|
| 274 | + $tempView = clone $this; |
|
| 275 | + $tempView->view = $view; |
|
| 276 | + return $tempView; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | 279 | function getPosts($jodelAccount) |
| 280 | 280 | { |
| 281 | - if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
| 282 | - { |
|
| 283 | - $accountCreator = new GetChannel(); |
|
| 284 | - $accountCreator->view = $this->view; |
|
| 285 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 286 | - $accountCreator->channel = $this->hashtag; |
|
| 287 | - $accountCreator->lastPostId = $this->lastPostId; |
|
| 288 | - $data = $accountCreator->execute(); |
|
| 289 | - } |
|
| 290 | - else |
|
| 291 | - { |
|
| 292 | - if($this->lastPostId == '' && $this->view == 'combo') |
|
| 293 | - { |
|
| 294 | - $url = "/v3/posts/location/combo"; |
|
| 295 | - } |
|
| 296 | - else |
|
| 297 | - { |
|
| 298 | - if($this->view == 'discussed') |
|
| 299 | - { |
|
| 300 | - $url = "/v2/posts/location/discussed/"; |
|
| 301 | - } |
|
| 302 | - else |
|
| 303 | - { |
|
| 304 | - if($this->view == 'popular') |
|
| 305 | - { |
|
| 306 | - $url = "/v2/posts/location/popular/"; |
|
| 307 | - } |
|
| 308 | - else |
|
| 309 | - { |
|
| 310 | - $url = "/v2/posts/location/"; |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - $accountCreator = new GetPosts(); |
|
| 316 | - $accountCreator->setLastPostId($this->lastPostId); |
|
| 317 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 318 | - $accountCreator->setUrl($url); |
|
| 319 | - $accountCreator->version = 'v3'; |
|
| 320 | - |
|
| 321 | - $config = parse_ini_file('config/config.ini.php'); |
|
| 322 | - $location = new Location(); |
|
| 323 | - $location->setLat($config['default_lat']); |
|
| 324 | - $location->setLng($config['default_lng']); |
|
| 325 | - $location->setCityName($config['default_location']); |
|
| 326 | - $accountCreator->location = $location; |
|
| 327 | - $data = $accountCreator->execute(); |
|
| 328 | - } |
|
| 329 | - if(array_key_exists('recent', $data)) |
|
| 330 | - { |
|
| 331 | - return $data['recent']; |
|
| 332 | - } |
|
| 333 | - else if(array_key_exists('posts', $data)) |
|
| 334 | - { |
|
| 335 | - return $data['posts']; |
|
| 336 | - } |
|
| 337 | - else |
|
| 338 | - { |
|
| 339 | - error_log('Fehler View getPosts '); |
|
| 340 | - error_log(print_r($data, true)); |
|
| 341 | - |
|
| 342 | - $notFound[0] = array( |
|
| 343 | - "post_id" => "0", |
|
| 344 | - "discovered_by" => 0, |
|
| 345 | - "message" => "Not found", |
|
| 346 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
| 347 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
| 348 | - "pin_count" => 0, |
|
| 349 | - "color" => "FFBA00", |
|
| 350 | - "got_thanks" => FALSE, |
|
| 351 | - "post_own" => "friend", |
|
| 352 | - "discovered" => 0, |
|
| 353 | - "distance" => 9, |
|
| 354 | - "vote_count" => 0, |
|
| 355 | - "location" => |
|
| 356 | - array("name" => "Berlin", |
|
| 357 | - "loc_coordinates" => |
|
| 358 | - array( |
|
| 359 | - "lat" => 0, |
|
| 360 | - "lng" => 0 |
|
| 361 | - ), |
|
| 362 | - "loc_accuracy" => 0, |
|
| 363 | - "country" => "", |
|
| 364 | - "city" => "", |
|
| 365 | - ), |
|
| 366 | - "tags" => |
|
| 367 | - array(), |
|
| 368 | - "user_handle" => "0" |
|
| 369 | - ); |
|
| 370 | - return $notFound; |
|
| 371 | - } |
|
| 281 | + if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
| 282 | + { |
|
| 283 | + $accountCreator = new GetChannel(); |
|
| 284 | + $accountCreator->view = $this->view; |
|
| 285 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 286 | + $accountCreator->channel = $this->hashtag; |
|
| 287 | + $accountCreator->lastPostId = $this->lastPostId; |
|
| 288 | + $data = $accountCreator->execute(); |
|
| 289 | + } |
|
| 290 | + else |
|
| 291 | + { |
|
| 292 | + if($this->lastPostId == '' && $this->view == 'combo') |
|
| 293 | + { |
|
| 294 | + $url = "/v3/posts/location/combo"; |
|
| 295 | + } |
|
| 296 | + else |
|
| 297 | + { |
|
| 298 | + if($this->view == 'discussed') |
|
| 299 | + { |
|
| 300 | + $url = "/v2/posts/location/discussed/"; |
|
| 301 | + } |
|
| 302 | + else |
|
| 303 | + { |
|
| 304 | + if($this->view == 'popular') |
|
| 305 | + { |
|
| 306 | + $url = "/v2/posts/location/popular/"; |
|
| 307 | + } |
|
| 308 | + else |
|
| 309 | + { |
|
| 310 | + $url = "/v2/posts/location/"; |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + $accountCreator = new GetPosts(); |
|
| 316 | + $accountCreator->setLastPostId($this->lastPostId); |
|
| 317 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 318 | + $accountCreator->setUrl($url); |
|
| 319 | + $accountCreator->version = 'v3'; |
|
| 320 | + |
|
| 321 | + $config = parse_ini_file('config/config.ini.php'); |
|
| 322 | + $location = new Location(); |
|
| 323 | + $location->setLat($config['default_lat']); |
|
| 324 | + $location->setLng($config['default_lng']); |
|
| 325 | + $location->setCityName($config['default_location']); |
|
| 326 | + $accountCreator->location = $location; |
|
| 327 | + $data = $accountCreator->execute(); |
|
| 328 | + } |
|
| 329 | + if(array_key_exists('recent', $data)) |
|
| 330 | + { |
|
| 331 | + return $data['recent']; |
|
| 332 | + } |
|
| 333 | + else if(array_key_exists('posts', $data)) |
|
| 334 | + { |
|
| 335 | + return $data['posts']; |
|
| 336 | + } |
|
| 337 | + else |
|
| 338 | + { |
|
| 339 | + error_log('Fehler View getPosts '); |
|
| 340 | + error_log(print_r($data, true)); |
|
| 341 | + |
|
| 342 | + $notFound[0] = array( |
|
| 343 | + "post_id" => "0", |
|
| 344 | + "discovered_by" => 0, |
|
| 345 | + "message" => "Not found", |
|
| 346 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
| 347 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
| 348 | + "pin_count" => 0, |
|
| 349 | + "color" => "FFBA00", |
|
| 350 | + "got_thanks" => FALSE, |
|
| 351 | + "post_own" => "friend", |
|
| 352 | + "discovered" => 0, |
|
| 353 | + "distance" => 9, |
|
| 354 | + "vote_count" => 0, |
|
| 355 | + "location" => |
|
| 356 | + array("name" => "Berlin", |
|
| 357 | + "loc_coordinates" => |
|
| 358 | + array( |
|
| 359 | + "lat" => 0, |
|
| 360 | + "lng" => 0 |
|
| 361 | + ), |
|
| 362 | + "loc_accuracy" => 0, |
|
| 363 | + "country" => "", |
|
| 364 | + "city" => "", |
|
| 365 | + ), |
|
| 366 | + "tags" => |
|
| 367 | + array(), |
|
| 368 | + "user_handle" => "0" |
|
| 369 | + ); |
|
| 370 | + return $notFound; |
|
| 371 | + } |
|
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | \ No newline at end of file |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | $config = parse_ini_file('config/config.ini.php'); |
| 4 | 4 | if(!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) |
| 5 | 5 | { |
| 6 | - error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on 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 | |
| 10 | 10 | die(); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | -if (isset($captcha)) |
|
| 58 | +if(isset($captcha)) |
|
| 59 | 59 | { |
| 60 | 60 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid); |
| 61 | 61 | } |
@@ -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 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | if(!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) |
| 5 | 5 | { |
| 6 | 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); |
|
| 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 | |
| 10 | 10 | die(); |
@@ -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 | { |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | $view = new View(); |
| 42 | 42 | $message = "This account is not verified. Please verify this account first."; |
| 43 | 43 | $captcha = $view->getCaptcha($accessToken); |
| 44 | - $success = false; |
|
| 44 | + $success = FALSE; |
|
| 45 | 45 | } |
| 46 | 46 | else |
| 47 | 47 | { |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | else |
| 52 | 52 | { |
| 53 | 53 | $message = 'There is no account available for this jodel. Please create at least one new account to vote this jodel.'; |
| 54 | - $success = false; |
|
| 54 | + $success = FALSE; |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |