@@ -2,41 +2,41 @@ |
||
| 2 | 2 | |
| 3 | 3 | class GetChannel extends AbstractRequest |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * @var Location |
|
| 7 | - */ |
|
| 8 | - public $location; |
|
| 9 | - public $channel; |
|
| 10 | - public $hasPayload = FALSE; |
|
| 11 | - public $lastPostId = ''; |
|
| 12 | - public $view = 'combo'; |
|
| 5 | + /** |
|
| 6 | + * @var Location |
|
| 7 | + */ |
|
| 8 | + public $location; |
|
| 9 | + public $channel; |
|
| 10 | + public $hasPayload = FALSE; |
|
| 11 | + public $lastPostId = ''; |
|
| 12 | + public $view = 'combo'; |
|
| 13 | 13 | |
| 14 | - function getApiEndPoint() |
|
| 15 | - { |
|
| 16 | - if($this->lastPostId == '') |
|
| 17 | - { |
|
| 18 | - $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel; |
|
| 19 | - } |
|
| 20 | - else |
|
| 21 | - { |
|
| 22 | - if($this->view == 'combo') |
|
| 23 | - { |
|
| 24 | - $apiEndPoint = '/v3/posts/hashtag?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
| 25 | - } |
|
| 26 | - else |
|
| 27 | - { |
|
| 28 | - $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
| 29 | - } |
|
| 30 | - } |
|
| 31 | - return $apiEndPoint; |
|
| 32 | - } |
|
| 33 | - function getPayload() |
|
| 34 | - { |
|
| 35 | - return array( |
|
| 36 | - ); |
|
| 37 | - } |
|
| 38 | - function getMethod() |
|
| 39 | - { |
|
| 40 | - return 'GET'; |
|
| 41 | - } |
|
| 14 | + function getApiEndPoint() |
|
| 15 | + { |
|
| 16 | + if($this->lastPostId == '') |
|
| 17 | + { |
|
| 18 | + $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel; |
|
| 19 | + } |
|
| 20 | + else |
|
| 21 | + { |
|
| 22 | + if($this->view == 'combo') |
|
| 23 | + { |
|
| 24 | + $apiEndPoint = '/v3/posts/hashtag?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
| 25 | + } |
|
| 26 | + else |
|
| 27 | + { |
|
| 28 | + $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | + return $apiEndPoint; |
|
| 32 | + } |
|
| 33 | + function getPayload() |
|
| 34 | + { |
|
| 35 | + return array( |
|
| 36 | + ); |
|
| 37 | + } |
|
| 38 | + function getMethod() |
|
| 39 | + { |
|
| 40 | + return 'GET'; |
|
| 41 | + } |
|
| 42 | 42 | } |
@@ -2,105 +2,105 @@ 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; |
|
| 9 | + public $postId; |
|
| 10 | + public $isDetailedView; |
|
| 11 | 11 | |
| 12 | 12 | public $lastPostId = ''; |
| 13 | 13 | |
| 14 | - function __construct($country, $city, $hashtag = '#all', $view = 'time', $postId = '') |
|
| 15 | - { |
|
| 16 | - $this->country = $country; |
|
| 17 | - $this->city = $city; |
|
| 18 | - $this->hashtag = $hashtag; |
|
| 19 | - $this->view = $view; |
|
| 20 | - $this->postId = $postId; |
|
| 14 | + function __construct($country, $city, $hashtag = '#all', $view = 'time', $postId = '') |
|
| 15 | + { |
|
| 16 | + $this->country = $country; |
|
| 17 | + $this->city = $city; |
|
| 18 | + $this->hashtag = $hashtag; |
|
| 19 | + $this->view = $view; |
|
| 20 | + $this->postId = $postId; |
|
| 21 | 21 | |
| 22 | - if($postId == '') |
|
| 23 | - { |
|
| 24 | - $this->isDetailedView = FALSE; |
|
| 25 | - } |
|
| 26 | - else |
|
| 27 | - { |
|
| 28 | - $this->isDetailedView = TRUE; |
|
| 29 | - } |
|
| 30 | - } |
|
| 22 | + if($postId == '') |
|
| 23 | + { |
|
| 24 | + $this->isDetailedView = FALSE; |
|
| 25 | + } |
|
| 26 | + else |
|
| 27 | + { |
|
| 28 | + $this->isDetailedView = TRUE; |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | 31 | /** |
| 32 | 32 | * Compute HTML Code |
| 33 | 33 | */ |
| 34 | 34 | function jodelToHtml($post) |
| 35 | - { //ToDO |
|
| 36 | - //Replace # with link |
|
| 37 | - //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
| 35 | + { //ToDO |
|
| 36 | + //Replace # with link |
|
| 37 | + //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
| 38 | 38 | |
| 39 | - //Time to time difference |
|
| 40 | - $now = new DateTime(); |
|
| 41 | - $d = new DateTime($post['created_at']); |
|
| 42 | - $timediff = $now->diff($d); |
|
| 39 | + //Time to time difference |
|
| 40 | + $now = new DateTime(); |
|
| 41 | + $d = new DateTime($post['created_at']); |
|
| 42 | + $timediff = $now->diff($d); |
|
| 43 | 43 | |
| 44 | - $timediff_inSeconds = (string)$timediff->format('%s'); |
|
| 45 | - $timediff_inMinutes = (string)$timediff->format('%i'); |
|
| 46 | - $timediff_inHours = (string)$timediff->format('%h'); |
|
| 47 | - $timediff_inDays = (string)$timediff->format('%d'); |
|
| 48 | - $timediff_inMonth = (string)$timediff->format('%m'); |
|
| 44 | + $timediff_inSeconds = (string)$timediff->format('%s'); |
|
| 45 | + $timediff_inMinutes = (string)$timediff->format('%i'); |
|
| 46 | + $timediff_inHours = (string)$timediff->format('%h'); |
|
| 47 | + $timediff_inDays = (string)$timediff->format('%d'); |
|
| 48 | + $timediff_inMonth = (string)$timediff->format('%m'); |
|
| 49 | 49 | |
| 50 | - if($timediff_inMonth!=0) |
|
| 51 | - { |
|
| 52 | - $timediff = $timediff_inMonth . "m"; |
|
| 53 | - } |
|
| 54 | - else |
|
| 55 | - { |
|
| 56 | - if($timediff_inDays!=0) |
|
| 57 | - { |
|
| 58 | - $timediff = $timediff_inDays . "d"; |
|
| 59 | - } |
|
| 60 | - else |
|
| 61 | - { |
|
| 62 | - if($timediff_inHours!=0) |
|
| 63 | - { |
|
| 64 | - $timediff = $timediff_inHours . "h"; |
|
| 65 | - } |
|
| 66 | - else |
|
| 67 | - { |
|
| 68 | - if($timediff_inMinutes!=0) |
|
| 69 | - { |
|
| 70 | - $timediff = $timediff_inMinutes . "m"; |
|
| 71 | - } |
|
| 72 | - else |
|
| 73 | - { |
|
| 74 | - $timediff = $timediff_inSeconds . "s"; |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 50 | + if($timediff_inMonth!=0) |
|
| 51 | + { |
|
| 52 | + $timediff = $timediff_inMonth . "m"; |
|
| 53 | + } |
|
| 54 | + else |
|
| 55 | + { |
|
| 56 | + if($timediff_inDays!=0) |
|
| 57 | + { |
|
| 58 | + $timediff = $timediff_inDays . "d"; |
|
| 59 | + } |
|
| 60 | + else |
|
| 61 | + { |
|
| 62 | + if($timediff_inHours!=0) |
|
| 63 | + { |
|
| 64 | + $timediff = $timediff_inHours . "h"; |
|
| 65 | + } |
|
| 66 | + else |
|
| 67 | + { |
|
| 68 | + if($timediff_inMinutes!=0) |
|
| 69 | + { |
|
| 70 | + $timediff = $timediff_inMinutes . "m"; |
|
| 71 | + } |
|
| 72 | + else |
|
| 73 | + { |
|
| 74 | + $timediff = $timediff_inSeconds . "s"; |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | - ?> |
|
| 81 | + ?> |
|
| 82 | 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 | - if(isset($post['image_url'])) |
|
| 86 | - { |
|
| 87 | - $regexRest = '/[^\w$ .!?-]+/u'; |
|
| 85 | + if(isset($post['image_url'])) |
|
| 86 | + { |
|
| 87 | + $regexRest = '/[^\w$ .!?-]+/u'; |
|
| 88 | 88 | |
| 89 | - echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
|
| 90 | - } |
|
| 91 | - else { |
|
| 92 | - echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
|
| 93 | - } |
|
| 94 | - ?> |
|
| 89 | + echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
|
| 90 | + } |
|
| 91 | + else { |
|
| 92 | + echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
|
| 93 | + } |
|
| 94 | + ?> |
|
| 95 | 95 | </content> |
| 96 | 96 | <aside> |
| 97 | 97 | <?php |
| 98 | - if($this->isDetailedView) |
|
| 99 | - {?> |
|
| 98 | + if($this->isDetailedView) |
|
| 99 | + {?> |
|
| 100 | 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 | - else |
|
| 103 | - {?> |
|
| 102 | + else |
|
| 103 | + {?> |
|
| 104 | 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> |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | <br /> |
| 109 | 109 | <?php echo $post["vote_count"];?><br /> |
| 110 | 110 | <?php |
| 111 | - if($this->isDetailedView) |
|
| 112 | - {?> |
|
| 111 | + if($this->isDetailedView) |
|
| 112 | + {?> |
|
| 113 | 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 | - else |
|
| 116 | - {?> |
|
| 115 | + else |
|
| 116 | + {?> |
|
| 117 | 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> |
@@ -136,39 +136,39 @@ discard block |
||
| 136 | 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 | - echo $post["child_count"]; |
|
| 140 | - } else echo "0"; |
|
| 141 | - ?> |
|
| 139 | + echo $post["child_count"]; |
|
| 140 | + } else echo "0"; |
|
| 141 | + ?> |
|
| 142 | 142 | </a> |
| 143 | 143 | </span> |
| 144 | 144 | <?php } ?> |
| 145 | 145 | </td> |
| 146 | 146 | <td class="distance"> |
| 147 | 147 | <?php |
| 148 | - if($this->isDetailedView) |
|
| 149 | - { |
|
| 150 | - if(isset($post["parent_creator"]) && $post["parent_creator"] == 1) |
|
| 151 | - { |
|
| 152 | - ?> |
|
| 148 | + if($this->isDetailedView) |
|
| 149 | + { |
|
| 150 | + if(isset($post["parent_creator"]) && $post["parent_creator"] == 1) |
|
| 151 | + { |
|
| 152 | + ?> |
|
| 153 | 153 | <span data-tooltip="Author"> |
| 154 | 154 | <i class="fa fa-user-o"></i> OJ | |
| 155 | 155 | </span> |
| 156 | 156 | <?php |
| 157 | - } |
|
| 158 | - else |
|
| 159 | - { |
|
| 160 | - //Is not parent Jodel in detailed View |
|
| 161 | - if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post)) |
|
| 162 | - { |
|
| 163 | - ?> |
|
| 157 | + } |
|
| 158 | + else |
|
| 159 | + { |
|
| 160 | + //Is not parent Jodel in detailed View |
|
| 161 | + if(!array_key_exists('child_count', $post) && array_key_exists('parent_creator', $post)) |
|
| 162 | + { |
|
| 163 | + ?> |
|
| 164 | 164 | <span data-tooltip="Author"> |
| 165 | 165 | <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
| 166 | 166 | </span> |
| 167 | 167 | <?php |
| 168 | - } |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - ?> |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + ?> |
|
| 172 | 172 | |
| 173 | 173 | <span class="tip" data-tooltip="Distance"> |
| 174 | 174 | <i class="fa fa-map-marker"></i> |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | </footer> |
| 182 | 182 | </article> |
| 183 | 183 | <?php |
| 184 | - } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -254,96 +254,96 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | function getPosts($jodelAccount) |
| 256 | 256 | { |
| 257 | - if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
| 258 | - { |
|
| 259 | - $accountCreator = new GetChannel(); |
|
| 260 | - $accountCreator->view = $this->view; |
|
| 261 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 262 | - $accountCreator->channel = $this->hashtag; |
|
| 263 | - $accountCreator->lastPostId = $this->lastPostId; |
|
| 264 | - $data = $accountCreator->execute(); |
|
| 265 | - } |
|
| 266 | - else |
|
| 267 | - { |
|
| 268 | - if($this->lastPostId == '' && $this->view == 'combo') |
|
| 269 | - { |
|
| 270 | - $url = "/v3/posts/location/combo"; |
|
| 271 | - } |
|
| 272 | - else |
|
| 273 | - { |
|
| 274 | - if($this->view == 'discussed') |
|
| 275 | - { |
|
| 276 | - $url = "/v2/posts/location/discussed/"; |
|
| 277 | - } |
|
| 278 | - else |
|
| 279 | - { |
|
| 280 | - if($this->view == 'popular') |
|
| 281 | - { |
|
| 282 | - $url = "/v2/posts/location/popular/"; |
|
| 283 | - } |
|
| 284 | - else |
|
| 285 | - { |
|
| 286 | - $url = "/v2/posts/location/"; |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - } |
|
| 257 | + if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
| 258 | + { |
|
| 259 | + $accountCreator = new GetChannel(); |
|
| 260 | + $accountCreator->view = $this->view; |
|
| 261 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 262 | + $accountCreator->channel = $this->hashtag; |
|
| 263 | + $accountCreator->lastPostId = $this->lastPostId; |
|
| 264 | + $data = $accountCreator->execute(); |
|
| 265 | + } |
|
| 266 | + else |
|
| 267 | + { |
|
| 268 | + if($this->lastPostId == '' && $this->view == 'combo') |
|
| 269 | + { |
|
| 270 | + $url = "/v3/posts/location/combo"; |
|
| 271 | + } |
|
| 272 | + else |
|
| 273 | + { |
|
| 274 | + if($this->view == 'discussed') |
|
| 275 | + { |
|
| 276 | + $url = "/v2/posts/location/discussed/"; |
|
| 277 | + } |
|
| 278 | + else |
|
| 279 | + { |
|
| 280 | + if($this->view == 'popular') |
|
| 281 | + { |
|
| 282 | + $url = "/v2/posts/location/popular/"; |
|
| 283 | + } |
|
| 284 | + else |
|
| 285 | + { |
|
| 286 | + $url = "/v2/posts/location/"; |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | - $accountCreator = new GetPosts(); |
|
| 292 | - $accountCreator->setLastPostId($this->lastPostId); |
|
| 293 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 294 | - $accountCreator->setUrl($url); |
|
| 295 | - $accountCreator->version = 'v3'; |
|
| 291 | + $accountCreator = new GetPosts(); |
|
| 292 | + $accountCreator->setLastPostId($this->lastPostId); |
|
| 293 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
| 294 | + $accountCreator->setUrl($url); |
|
| 295 | + $accountCreator->version = 'v3'; |
|
| 296 | 296 | |
| 297 | - $config = parse_ini_file('config/config.ini.php'); |
|
| 298 | - $location = new Location(); |
|
| 299 | - $location->setLat($config['default_lat']); |
|
| 300 | - $location->setLng($config['default_lng']); |
|
| 301 | - $location->setCityName($config['default_location']); |
|
| 302 | - $accountCreator->location = $location; |
|
| 303 | - $data = $accountCreator->execute(); |
|
| 304 | - } |
|
| 305 | - if(array_key_exists('recent', $data)) |
|
| 306 | - { |
|
| 307 | - return $data['recent']; |
|
| 308 | - } |
|
| 309 | - else if(array_key_exists('posts', $data)) |
|
| 310 | - { |
|
| 311 | - return $data['posts']; |
|
| 312 | - } |
|
| 313 | - else |
|
| 314 | - { |
|
| 315 | - error_log('Fehler View getPosts '); |
|
| 316 | - error_log(print_r($data, true)); |
|
| 297 | + $config = parse_ini_file('config/config.ini.php'); |
|
| 298 | + $location = new Location(); |
|
| 299 | + $location->setLat($config['default_lat']); |
|
| 300 | + $location->setLng($config['default_lng']); |
|
| 301 | + $location->setCityName($config['default_location']); |
|
| 302 | + $accountCreator->location = $location; |
|
| 303 | + $data = $accountCreator->execute(); |
|
| 304 | + } |
|
| 305 | + if(array_key_exists('recent', $data)) |
|
| 306 | + { |
|
| 307 | + return $data['recent']; |
|
| 308 | + } |
|
| 309 | + else if(array_key_exists('posts', $data)) |
|
| 310 | + { |
|
| 311 | + return $data['posts']; |
|
| 312 | + } |
|
| 313 | + else |
|
| 314 | + { |
|
| 315 | + error_log('Fehler View getPosts '); |
|
| 316 | + error_log(print_r($data, true)); |
|
| 317 | 317 | |
| 318 | - $notFound[0] = array( |
|
| 319 | - "post_id" => "0", |
|
| 320 | - "discovered_by" => 0, |
|
| 321 | - "message" => "Not found", |
|
| 322 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
| 323 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
| 324 | - "pin_count" => 0, |
|
| 325 | - "color" => "FFBA00", |
|
| 326 | - "got_thanks" => FALSE, |
|
| 327 | - "post_own" => "friend", |
|
| 328 | - "discovered" => 0, |
|
| 329 | - "distance" => 9, |
|
| 330 | - "vote_count" => 0, |
|
| 331 | - "location" => |
|
| 332 | - array("name" => "Berlin", |
|
| 333 | - "loc_coordinates" => |
|
| 334 | - array( |
|
| 335 | - "lat" => 0, |
|
| 336 | - "lng" => 0 |
|
| 337 | - ), |
|
| 338 | - "loc_accuracy" => 0, |
|
| 339 | - "country" => "", |
|
| 340 | - "city" => "", |
|
| 341 | - ), |
|
| 342 | - "tags" => |
|
| 343 | - array(), |
|
| 344 | - "user_handle" => "0" |
|
| 345 | - ); |
|
| 346 | - return $notFound; |
|
| 347 | - } |
|
| 318 | + $notFound[0] = array( |
|
| 319 | + "post_id" => "0", |
|
| 320 | + "discovered_by" => 0, |
|
| 321 | + "message" => "Not found", |
|
| 322 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
| 323 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
| 324 | + "pin_count" => 0, |
|
| 325 | + "color" => "FFBA00", |
|
| 326 | + "got_thanks" => FALSE, |
|
| 327 | + "post_own" => "friend", |
|
| 328 | + "discovered" => 0, |
|
| 329 | + "distance" => 9, |
|
| 330 | + "vote_count" => 0, |
|
| 331 | + "location" => |
|
| 332 | + array("name" => "Berlin", |
|
| 333 | + "loc_coordinates" => |
|
| 334 | + array( |
|
| 335 | + "lat" => 0, |
|
| 336 | + "lng" => 0 |
|
| 337 | + ), |
|
| 338 | + "loc_accuracy" => 0, |
|
| 339 | + "country" => "", |
|
| 340 | + "city" => "", |
|
| 341 | + ), |
|
| 342 | + "tags" => |
|
| 343 | + array(), |
|
| 344 | + "user_handle" => "0" |
|
| 345 | + ); |
|
| 346 | + return $notFound; |
|
| 347 | + } |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | \ No newline at end of file |
@@ -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 |