@@ -6,8 +6,8 @@ |
||
6 | 6 | { |
7 | 7 | error_log('test'); |
8 | 8 | header('Content-Type: application/json'); |
9 | - echo json_encode($jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote'])); |
|
10 | - die(); |
|
9 | + echo json_encode($jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote'])); |
|
10 | + die(); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | if((!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) && !isUserAdmin()) |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | crossorigin="anonymous"></script> |
6 | 6 | <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script> |
7 | 7 | <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script> |
8 | - <script src="<?php echo $baseUrl;?>js/jQueryEmoji.js"></script> |
|
8 | + <script src="<?php echo $baseUrl; ?>js/jQueryEmoji.js"></script> |
|
9 | 9 | |
10 | 10 | <script> |
11 | 11 | //BackButton |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | { |
14 | 14 | window.history.back(); |
15 | 15 | } |
16 | - <?php if(isset($includeEmojiAndAjax)){ ?> |
|
16 | + <?php if(isset($includeEmojiAndAjax)) { ?> |
|
17 | 17 | |
18 | 18 | function vote(postId, vote, obj) |
19 | 19 | { |
20 | 20 | $.ajax({ |
21 | - url: '<?php echo $baseUrl;?>vote-ajax.php?postId=' + postId + '&vote=' + vote, |
|
21 | + url: '<?php echo $baseUrl; ?>vote-ajax.php?postId=' + postId + '&vote=' + vote, |
|
22 | 22 | dataType: 'json', |
23 | 23 | async: true, |
24 | 24 | success: function(json) |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | function getMorePosts(lastPostId, view, hashtag, old_lastPostId) |
73 | 73 | { |
74 | 74 | $.ajax({ |
75 | - url: '<?php echo $baseUrl;?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURIComponent(hashtag), |
|
75 | + url: '<?php echo $baseUrl; ?>get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view + '&hashtag=' + encodeURIComponent(hashtag), |
|
76 | 76 | dataType: 'html', |
77 | 77 | async: false, |
78 | 78 | success: function(html) { |
@@ -13,7 +13,9 @@ discard block |
||
13 | 13 | { |
14 | 14 | window.history.back(); |
15 | 15 | } |
16 | - <?php if(isset($includeEmojiAndAjax)){ ?> |
|
16 | + <?php if(isset($includeEmojiAndAjax)) |
|
17 | +{ |
|
18 | +?> |
|
17 | 19 | |
18 | 20 | function vote(postId, vote, obj) |
19 | 21 | { |
@@ -99,7 +101,9 @@ discard block |
||
99 | 101 | return {"lastPostId":lastPostId, "old_lastPostId":old_lastPostId}; |
100 | 102 | } |
101 | 103 | |
102 | - <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?> |
|
104 | + <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) |
|
105 | +{ |
|
106 | +?> |
|
103 | 107 | |
104 | 108 | if(window.location.hash) |
105 | 109 | { |
@@ -48,27 +48,27 @@ discard block |
||
48 | 48 | |
49 | 49 | function user_log($msg) |
50 | 50 | { |
51 | - $log = $msg . PHP_EOL; |
|
52 | - file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
51 | + $log = $msg . PHP_EOL; |
|
52 | + file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | function isUserBot() |
56 | 56 | { |
57 | - preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
57 | + preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
58 | 58 | |
59 | - return (isset($matches[0])) ? true : false; |
|
59 | + return (isset($matches[0])) ? true : false; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | function configPropertyExists($config, $property) |
63 | 63 | { |
64 | - if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
65 | - { |
|
66 | - return FALSE; |
|
67 | - } |
|
68 | - else |
|
69 | - { |
|
70 | - return TRUE; |
|
71 | - } |
|
64 | + if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
65 | + { |
|
66 | + return FALSE; |
|
67 | + } |
|
68 | + else |
|
69 | + { |
|
70 | + return TRUE; |
|
71 | + } |
|
72 | 72 | } |
73 | 73 | function isUserAdmin() { |
74 | 74 | global $config; |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | |
85 | 85 | function isDeviceUidInDatabase($deviceUid) |
86 | 86 | { |
87 | - $db = new DatabaseConnect(); |
|
88 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
89 | - |
|
90 | - if ($result->num_rows > 0) |
|
91 | - { |
|
92 | - return TRUE; |
|
93 | - } |
|
94 | - else |
|
95 | - { |
|
96 | - return FALSE; |
|
97 | - } |
|
87 | + $db = new DatabaseConnect(); |
|
88 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
89 | + |
|
90 | + if ($result->num_rows > 0) |
|
91 | + { |
|
92 | + return TRUE; |
|
93 | + } |
|
94 | + else |
|
95 | + { |
|
96 | + return FALSE; |
|
97 | + } |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | //Check if it's a Spider or Google Bot |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | if(configPropertyExists($config, 'karmaDeviceUid')) |
124 | - { |
|
125 | - $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
126 | - } |
|
127 | - else |
|
128 | - { |
|
129 | - error_log("No Karma deviceUid set in config file"); |
|
124 | + { |
|
125 | + $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
126 | + } |
|
127 | + else |
|
128 | + { |
|
129 | + error_log("No Karma deviceUid set in config file"); |
|
130 | 130 | $jodelAccountForKarma = new JodelAccount($deviceUid); |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | 133 | /* |
134 | 134 | * Cunstruct View |
@@ -70,7 +70,8 @@ discard block |
||
70 | 70 | return TRUE; |
71 | 71 | } |
72 | 72 | } |
73 | -function isUserAdmin() { |
|
73 | +function isUserAdmin() |
|
74 | +{ |
|
74 | 75 | global $config; |
75 | 76 | if (isset($_COOKIE['JodelAdminPassword']) && configPropertyExists($config, 'pw') && $config['pw'] == $_COOKIE['JodelAdminPassword']) |
76 | 77 | { |
@@ -121,7 +122,7 @@ discard block |
||
121 | 122 | } |
122 | 123 | |
123 | 124 | if(configPropertyExists($config, 'karmaDeviceUid')) |
124 | - { |
|
125 | + { |
|
125 | 126 | $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
126 | 127 | } |
127 | 128 | else |
@@ -194,7 +195,8 @@ discard block |
||
194 | 195 | |
195 | 196 | if(isset($_GET['view'])) |
196 | 197 | { |
197 | - switch ($_GET['view']) { |
|
198 | + switch ($_GET['view']) |
|
199 | + { |
|
198 | 200 | case 'discussed': |
199 | 201 | $view = 'discussed'; |
200 | 202 | break; |
@@ -2,98 +2,98 @@ discard block |
||
2 | 2 | |
3 | 3 | class View |
4 | 4 | { |
5 | - public $country; |
|
6 | - public $city; |
|
7 | - public $hashtag; |
|
5 | + public $country; |
|
6 | + public $city; |
|
7 | + public $hashtag; |
|
8 | 8 | public $view; |
9 | - public $postId; |
|
10 | - public $isDetailedView; |
|
11 | - public $baseUrl; |
|
9 | + public $postId; |
|
10 | + public $isDetailedView; |
|
11 | + public $baseUrl; |
|
12 | 12 | |
13 | 13 | public $lastPostId = ''; |
14 | 14 | |
15 | - function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '') |
|
16 | - { |
|
17 | - $this->baseUrl = $baseUrl; |
|
18 | - $this->country = $country; |
|
19 | - $this->city = $city; |
|
20 | - $this->hashtag = urldecode($hashtag); |
|
21 | - $this->view = $view; |
|
22 | - $this->postId = $postId; |
|
15 | + function __construct($baseUrl, $country, $city, $hashtag = '%23all', $view = 'time', $postId = '') |
|
16 | + { |
|
17 | + $this->baseUrl = $baseUrl; |
|
18 | + $this->country = $country; |
|
19 | + $this->city = $city; |
|
20 | + $this->hashtag = urldecode($hashtag); |
|
21 | + $this->view = $view; |
|
22 | + $this->postId = $postId; |
|
23 | 23 | |
24 | - if($postId == '') |
|
25 | - { |
|
26 | - $this->isDetailedView = FALSE; |
|
27 | - } |
|
28 | - else |
|
29 | - { |
|
30 | - $this->isDetailedView = TRUE; |
|
31 | - } |
|
32 | - } |
|
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); |
|
37 | + { //ToDO |
|
38 | + //Replace # with link |
|
39 | + //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
|
40 | 40 | |
41 | - //Time to time difference |
|
42 | - $now = new DateTime(); |
|
43 | - $d = new DateTime($post['created_at']); |
|
44 | - $timediff = $now->diff($d); |
|
41 | + //Time to time difference |
|
42 | + $now = new DateTime(); |
|
43 | + $d = new DateTime($post['created_at']); |
|
44 | + $timediff = $now->diff($d); |
|
45 | 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'); |
|
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 | 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 | - } |
|
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 | 81 | |
82 | 82 | |
83 | - ?> |
|
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'; |
|
87 | + if(isset($post['image_url'])) |
|
88 | + { |
|
89 | + $regexRest = '/[^\w$ .!?-]+/u'; |
|
90 | 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 | - ?> |
|
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 | <button onclick="vote('<?php echo $post['post_id'];?>', 'up', this)"> |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
123 | 123 | <i class="fa fa-commenting-o"></i> |
124 | 124 | <?php if(array_key_exists("child_count", $post)) |
125 | - { |
|
126 | - echo $post["child_count"]; |
|
127 | - } else echo "0"; |
|
128 | - ?> |
|
125 | + { |
|
126 | + echo $post["child_count"]; |
|
127 | + } else echo "0"; |
|
128 | + ?> |
|
129 | 129 | </a> |
130 | 130 | </span> |
131 | 131 | |
@@ -145,30 +145,30 @@ discard block |
||
145 | 145 | ?> |
146 | 146 | <span class="distance"> |
147 | 147 | <?php |
148 | - if($this->isDetailedView) |
|
149 | - { |
|
150 | - if(isset($post['user_handle']) && $post['user_handle'] == 'OJ') |
|
151 | - { |
|
152 | - ?> |
|
148 | + if($this->isDetailedView) |
|
149 | + { |
|
150 | + if(isset($post['user_handle']) && $post['user_handle'] == 'OJ') |
|
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)) |
|
162 | - { |
|
163 | - ?> |
|
157 | + } |
|
158 | + else |
|
159 | + { |
|
160 | + //Is not parent Jodel in detailed View |
|
161 | + if(!array_key_exists('child_count', $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 | /** |
@@ -218,135 +218,135 @@ discard block |
||
218 | 218 | return $description; |
219 | 219 | } |
220 | 220 | |
221 | - function toUrl() |
|
222 | - { |
|
223 | - $url = $this->baseUrl . 'index.php?country=DE' . |
|
224 | - '&city=' . urlencode($this->city) . |
|
225 | - '&hashtag=' . urlencode($this->hashtag) . |
|
226 | - '&view=' . $this->view; |
|
227 | - if($this->postId != '') |
|
228 | - { |
|
229 | - $url .= '&postId=' . $this->postId . |
|
230 | - '&getPostDetails=TRUE'; |
|
231 | - } |
|
221 | + function toUrl() |
|
222 | + { |
|
223 | + $url = $this->baseUrl . 'index.php?country=DE' . |
|
224 | + '&city=' . urlencode($this->city) . |
|
225 | + '&hashtag=' . urlencode($this->hashtag) . |
|
226 | + '&view=' . $this->view; |
|
227 | + if($this->postId != '') |
|
228 | + { |
|
229 | + $url .= '&postId=' . $this->postId . |
|
230 | + '&getPostDetails=TRUE'; |
|
231 | + } |
|
232 | 232 | |
233 | - return $url; |
|
234 | - } |
|
233 | + return $url; |
|
234 | + } |
|
235 | 235 | |
236 | - function changePostId($postId) |
|
237 | - { |
|
238 | - $tempView = clone $this; |
|
239 | - $tempView->postId = $postId; |
|
240 | - $tempView->isDetailedView = TRUE; |
|
241 | - return $tempView; |
|
242 | - } |
|
236 | + function changePostId($postId) |
|
237 | + { |
|
238 | + $tempView = clone $this; |
|
239 | + $tempView->postId = $postId; |
|
240 | + $tempView->isDetailedView = TRUE; |
|
241 | + return $tempView; |
|
242 | + } |
|
243 | 243 | |
244 | - function back() |
|
245 | - { |
|
246 | - $tempView = clone $this; |
|
247 | - $tempView->postId = ''; |
|
248 | - return $tempView; |
|
249 | - } |
|
244 | + function back() |
|
245 | + { |
|
246 | + $tempView = clone $this; |
|
247 | + $tempView->postId = ''; |
|
248 | + return $tempView; |
|
249 | + } |
|
250 | 250 | |
251 | - function changeView($view) |
|
252 | - { |
|
253 | - $tempView = clone $this; |
|
254 | - $tempView->view = $view; |
|
255 | - return $tempView; |
|
256 | - } |
|
251 | + function changeView($view) |
|
252 | + { |
|
253 | + $tempView = clone $this; |
|
254 | + $tempView->view = $view; |
|
255 | + return $tempView; |
|
256 | + } |
|
257 | 257 | |
258 | 258 | function getPosts($jodelAccount) |
259 | 259 | { |
260 | - if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
261 | - { |
|
262 | - $accountCreator = new GetChannel(); |
|
263 | - $accountCreator->view = $this->view; |
|
264 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
265 | - $accountCreator->channel = $this->hashtag; |
|
266 | - $accountCreator->lastPostId = $this->lastPostId; |
|
267 | - $data = $accountCreator->execute(); |
|
268 | - } |
|
269 | - else |
|
270 | - { |
|
271 | - if($this->lastPostId == '' && $this->view == 'combo') |
|
272 | - { |
|
273 | - $url = "/v3/posts/location/combo"; |
|
274 | - } |
|
275 | - else |
|
276 | - { |
|
277 | - if($this->view == 'discussed') |
|
278 | - { |
|
279 | - $url = "/v2/posts/location/discussed/"; |
|
280 | - } |
|
281 | - else |
|
282 | - { |
|
283 | - if($this->view == 'popular') |
|
284 | - { |
|
285 | - $url = "/v2/posts/location/popular/"; |
|
286 | - } |
|
287 | - else |
|
288 | - { |
|
289 | - $url = "/v2/posts/location/"; |
|
290 | - } |
|
291 | - } |
|
292 | - } |
|
260 | + if($this->hashtag != '#all' && $this->hashtag != '' && $this->hashtag != NULL) |
|
261 | + { |
|
262 | + $accountCreator = new GetChannel(); |
|
263 | + $accountCreator->view = $this->view; |
|
264 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
265 | + $accountCreator->channel = $this->hashtag; |
|
266 | + $accountCreator->lastPostId = $this->lastPostId; |
|
267 | + $data = $accountCreator->execute(); |
|
268 | + } |
|
269 | + else |
|
270 | + { |
|
271 | + if($this->lastPostId == '' && $this->view == 'combo') |
|
272 | + { |
|
273 | + $url = "/v3/posts/location/combo"; |
|
274 | + } |
|
275 | + else |
|
276 | + { |
|
277 | + if($this->view == 'discussed') |
|
278 | + { |
|
279 | + $url = "/v2/posts/location/discussed/"; |
|
280 | + } |
|
281 | + else |
|
282 | + { |
|
283 | + if($this->view == 'popular') |
|
284 | + { |
|
285 | + $url = "/v2/posts/location/popular/"; |
|
286 | + } |
|
287 | + else |
|
288 | + { |
|
289 | + $url = "/v2/posts/location/"; |
|
290 | + } |
|
291 | + } |
|
292 | + } |
|
293 | 293 | |
294 | - $accountCreator = new GetPosts(); |
|
295 | - $accountCreator->setLastPostId($this->lastPostId); |
|
296 | - $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
297 | - $accountCreator->setUrl($url); |
|
298 | - $accountCreator->version = 'v3'; |
|
294 | + $accountCreator = new GetPosts(); |
|
295 | + $accountCreator->setLastPostId($this->lastPostId); |
|
296 | + $accountCreator->setAccessToken($jodelAccount->accessToken); |
|
297 | + $accountCreator->setUrl($url); |
|
298 | + $accountCreator->version = 'v3'; |
|
299 | 299 | |
300 | - $config = parse_ini_file('config/config.ini.php'); |
|
301 | - $location = new Location(); |
|
302 | - $location->setLat($config['default_lat']); |
|
303 | - $location->setLng($config['default_lng']); |
|
304 | - $location->setCityName($config['default_location']); |
|
305 | - $accountCreator->location = $location; |
|
306 | - $data = $accountCreator->execute(); |
|
307 | - } |
|
308 | - if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
|
309 | - { |
|
310 | - return $data['recent']; |
|
311 | - } |
|
312 | - else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
313 | - { |
|
314 | - return $data['posts']; |
|
315 | - } |
|
316 | - else |
|
317 | - { |
|
318 | - error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true)); |
|
319 | - //error_log(print_r($data, true)); |
|
300 | + $config = parse_ini_file('config/config.ini.php'); |
|
301 | + $location = new Location(); |
|
302 | + $location->setLat($config['default_lat']); |
|
303 | + $location->setLng($config['default_lng']); |
|
304 | + $location->setCityName($config['default_location']); |
|
305 | + $accountCreator->location = $location; |
|
306 | + $data = $accountCreator->execute(); |
|
307 | + } |
|
308 | + if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
|
309 | + { |
|
310 | + return $data['recent']; |
|
311 | + } |
|
312 | + else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
313 | + { |
|
314 | + return $data['posts']; |
|
315 | + } |
|
316 | + else |
|
317 | + { |
|
318 | + error_log('Could not find Posts in: ' . $this->city . ' Error: ' . print_r($data, true)); |
|
319 | + //error_log(print_r($data, true)); |
|
320 | 320 | |
321 | - $notFound[0] = array( |
|
322 | - "post_id" => "0", |
|
323 | - "discovered_by" => 0, |
|
324 | - "message" => "No more Posts found", |
|
325 | - "created_at" => "2017-02-11T16:44:50.385Z", |
|
326 | - "updated_at" => "2017-02-11T16:44:50.385Z", |
|
327 | - "pin_count" => 0, |
|
328 | - "color" => "5682a3", |
|
329 | - "got_thanks" => FALSE, |
|
330 | - "post_own" => "friend", |
|
331 | - "discovered" => 0, |
|
332 | - "distance" => 9, |
|
333 | - "vote_count" => 0, |
|
334 | - "location" => |
|
335 | - array("name" => "Berlin", |
|
336 | - "loc_coordinates" => |
|
337 | - array( |
|
338 | - "lat" => 0, |
|
339 | - "lng" => 0 |
|
340 | - ), |
|
341 | - "loc_accuracy" => 0, |
|
342 | - "country" => "", |
|
343 | - "city" => "", |
|
344 | - ), |
|
345 | - "tags" => |
|
346 | - array(), |
|
347 | - "user_handle" => "0" |
|
348 | - ); |
|
349 | - return $notFound; |
|
350 | - } |
|
321 | + $notFound[0] = array( |
|
322 | + "post_id" => "0", |
|
323 | + "discovered_by" => 0, |
|
324 | + "message" => "No more Posts found", |
|
325 | + "created_at" => "2017-02-11T16:44:50.385Z", |
|
326 | + "updated_at" => "2017-02-11T16:44:50.385Z", |
|
327 | + "pin_count" => 0, |
|
328 | + "color" => "5682a3", |
|
329 | + "got_thanks" => FALSE, |
|
330 | + "post_own" => "friend", |
|
331 | + "discovered" => 0, |
|
332 | + "distance" => 9, |
|
333 | + "vote_count" => 0, |
|
334 | + "location" => |
|
335 | + array("name" => "Berlin", |
|
336 | + "loc_coordinates" => |
|
337 | + array( |
|
338 | + "lat" => 0, |
|
339 | + "lng" => 0 |
|
340 | + ), |
|
341 | + "loc_accuracy" => 0, |
|
342 | + "country" => "", |
|
343 | + "city" => "", |
|
344 | + ), |
|
345 | + "tags" => |
|
346 | + array(), |
|
347 | + "user_handle" => "0" |
|
348 | + ); |
|
349 | + return $notFound; |
|
350 | + } |
|
351 | 351 | } |
352 | 352 | } |
@@ -49,25 +49,25 @@ discard block |
||
49 | 49 | $timediff_inDays = (string)$timediff->format('%d'); |
50 | 50 | $timediff_inMonth = (string)$timediff->format('%m'); |
51 | 51 | |
52 | - if($timediff_inMonth!=0) |
|
52 | + if($timediff_inMonth != 0) |
|
53 | 53 | { |
54 | 54 | $timediff = $timediff_inMonth . "m"; |
55 | 55 | } |
56 | 56 | else |
57 | 57 | { |
58 | - if($timediff_inDays!=0) |
|
58 | + if($timediff_inDays != 0) |
|
59 | 59 | { |
60 | 60 | $timediff = $timediff_inDays . "d"; |
61 | 61 | } |
62 | 62 | else |
63 | 63 | { |
64 | - if($timediff_inHours!=0) |
|
64 | + if($timediff_inHours != 0) |
|
65 | 65 | { |
66 | 66 | $timediff = $timediff_inHours . "h"; |
67 | 67 | } |
68 | 68 | else |
69 | 69 | { |
70 | - if($timediff_inMinutes!=0) |
|
70 | + if($timediff_inMinutes != 0) |
|
71 | 71 | { |
72 | 72 | $timediff = $timediff_inMinutes . "m"; |
73 | 73 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | ?> |
84 | - <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;"> |
|
84 | + <article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color']; ?>;"> |
|
85 | 85 | <content> |
86 | 86 | <?php |
87 | 87 | if(isset($post['image_url'])) |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | ?> |
97 | 97 | </content> |
98 | 98 | <aside> |
99 | - <button onclick="vote('<?php echo $post['post_id'];?>', 'up', this)"> |
|
99 | + <button onclick="vote('<?php echo $post['post_id']; ?>', 'up', this)"> |
|
100 | 100 | <i class="fa fa-angle-up fa-3x"></i> |
101 | 101 | </button> |
102 | - <br><span><?php echo $post["vote_count"];?></span><br> |
|
102 | + <br><span><?php echo $post["vote_count"]; ?></span><br> |
|
103 | 103 | |
104 | - <button onclick="vote('<?php echo $post['post_id'];?>', 'down', this)"> |
|
104 | + <button onclick="vote('<?php echo $post['post_id']; ?>', 'down', this)"> |
|
105 | 105 | <i class="fa fa-angle-down fa-3x"></i> |
106 | 106 | </button> |
107 | 107 | </aside> |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | <span class="time"> |
113 | 113 | <span class="tip" data-tooltip="Time"> |
114 | 114 | <i class="fa fa-clock-o"></i> |
115 | - <?php echo $timediff;?> |
|
116 | - <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
|
115 | + <?php echo $timediff; ?> |
|
116 | + <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span> |
|
117 | 117 | </span> |
118 | 118 | </span> |
119 | 119 | <?php if(!$this->isDetailedView) {?> |
120 | 120 | <span class="comments"> |
121 | 121 | <span data-tooltip="Comments"> |
122 | - <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
|
122 | + <a href="<?php echo $this->changePostId($post['post_id'])->toUrl(); ?>"> |
|
123 | 123 | <i class="fa fa-commenting-o"></i> |
124 | 124 | <?php if(array_key_exists("child_count", $post)) |
125 | 125 | { |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | </span> |
133 | 133 | <?php |
134 | 134 | } |
135 | - if (isUserAdmin()) |
|
135 | + if(isUserAdmin()) |
|
136 | 136 | { |
137 | 137 | ?> |
138 | 138 | <span class="voting"> |
@@ -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 | </span> |
179 | 179 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | if($post != '' && array_key_exists('message', $post) && $post['message'] != '' && $this->isDetailedView) |
214 | 214 | { |
215 | - $description = 'On JodelBlue in ' . htmlspecialchars($this->city) . ' with ' . htmlspecialchars($post['vote_count']) . ' Upvotes: ' . substr(htmlspecialchars($post['message']), 0, 130); |
|
215 | + $description = 'On JodelBlue in ' . htmlspecialchars($this->city) . ' with ' . htmlspecialchars($post['vote_count']) . ' Upvotes: ' . substr(htmlspecialchars($post['message']), 0, 130); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | return $description; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | { |
310 | 310 | return $data['recent']; |
311 | 311 | } |
312 | - else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
|
312 | + else if(array_key_exists('posts', $data) && array_key_exists(0, $data['posts'])) |
|
313 | 313 | { |
314 | 314 | return $data['posts']; |
315 | 315 | } |
@@ -34,7 +34,8 @@ discard block |
||
34 | 34 | * Compute HTML Code |
35 | 35 | */ |
36 | 36 | function jodelToHtml($post) |
37 | - { //ToDO |
|
37 | + { |
|
38 | +//ToDO |
|
38 | 39 | //Replace # with link |
39 | 40 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
40 | 41 | |
@@ -90,7 +91,8 @@ discard block |
||
90 | 91 | |
91 | 92 | echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
92 | 93 | } |
93 | - else { |
|
94 | + else |
|
95 | + { |
|
94 | 96 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
95 | 97 | } |
96 | 98 | ?> |
@@ -116,15 +118,20 @@ discard block |
||
116 | 118 | <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
117 | 119 | </span> |
118 | 120 | </span> |
119 | - <?php if(!$this->isDetailedView) {?> |
|
121 | + <?php if(!$this->isDetailedView) |
|
122 | +{ |
|
123 | +?> |
|
120 | 124 | <span class="comments"> |
121 | 125 | <span data-tooltip="Comments"> |
122 | 126 | <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
123 | 127 | <i class="fa fa-commenting-o"></i> |
124 | 128 | <?php if(array_key_exists("child_count", $post)) |
125 | - { |
|
129 | +{ |
|
126 | 130 | echo $post["child_count"]; |
127 | - } else echo "0"; |
|
131 | + } |
|
132 | + else { |
|
133 | + echo "0"; |
|
134 | + } |
|
128 | 135 | ?> |
129 | 136 | </a> |
130 | 137 | </span> |
@@ -306,7 +313,7 @@ discard block |
||
306 | 313 | $data = $accountCreator->execute(); |
307 | 314 | } |
308 | 315 | if(array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
309 | - { |
|
316 | + { |
|
310 | 317 | return $data['recent']; |
311 | 318 | } |
312 | 319 | else if(array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |