These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | error_reporting(-1); |
||
3 | include 'php/jodel-web.php'; |
||
4 | |||
5 | $config = parse_ini_file('config/config.ini.php'); |
||
6 | |||
7 | $location = new Location(); |
||
8 | $location->setLat($config['default_lat']); |
||
9 | $location->setLng($config['default_lng']); |
||
10 | $location->setCityName($config['default_location']); |
||
11 | |||
12 | $accessToken; |
||
13 | $accessToken_forId1; |
||
14 | $deviceUid; |
||
15 | $isSpider = FALSE; |
||
16 | |||
17 | //What is dude doing with my Server? |
||
18 | if($_SERVER['REMOTE_ADDR'] == '94.231.103.52') |
||
19 | { |
||
20 | echo('You are flooting my Server! Pls enable Cookies in your script and contact me: [email protected]'); |
||
21 | die(); |
||
22 | } |
||
23 | |||
24 | //Check if it's a Spider or Google Bot |
||
25 | if(botDeviceUidIsSet($config) && isUserBot()) |
||
26 | { |
||
27 | $isSpider = TRUE; |
||
28 | error_log('Spider or Bot checked in!'); |
||
29 | |||
30 | $deviceUid = $config['botDeviceUid']; |
||
31 | $config = NULL; |
||
32 | } |
||
33 | else |
||
34 | { |
||
35 | $config = NULL; |
||
36 | if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId'])) |
||
37 | { |
||
38 | $deviceUid = createAccount(); |
||
39 | setcookie('JodelDeviceId', $deviceUid, time()+60*60*24*365*10); |
||
40 | error_log('Created account with JodelDeviceId:' . $deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
||
41 | |||
42 | } |
||
43 | else |
||
44 | { |
||
45 | $deviceUid = $_COOKIE['JodelDeviceId']; |
||
46 | } |
||
47 | } |
||
48 | |||
49 | $location = getLocationByDeviceUid($deviceUid); |
||
50 | $newPositionStatus = $location->getCityName(); |
||
51 | $accessToken = isTokenFreshByDeviceUid($location, $deviceUid); |
||
52 | //Acc is fresh. token and location is set |
||
53 | |||
54 | $accessToken_forId1 = isTokenFresh($location); |
||
55 | $deviceUid_forId1 = getDeviceUidByAccessToken($accessToken_forId1); |
||
56 | |||
57 | //Set View |
||
58 | View Code Duplication | if(isset($_GET['view'])) |
|
0 ignored issues
–
show
|
|||
59 | { |
||
60 | switch ($_GET['view']) { |
||
61 | case 'comment': |
||
62 | $view = 'comment'; |
||
63 | break; |
||
64 | |||
65 | case 'upVote': |
||
66 | $view = 'upVote'; |
||
67 | break; |
||
68 | |||
69 | default: |
||
70 | $view = 'time'; |
||
71 | break; |
||
72 | } |
||
73 | } |
||
74 | else |
||
75 | { |
||
76 | $view = 'time'; |
||
77 | } |
||
78 | |||
79 | //Verify Account |
||
80 | if(isset($_GET['solution']) && isset($_GET['key'])) |
||
81 | { |
||
82 | verifyCaptcha($accessToken_forId1); |
||
83 | } |
||
84 | |||
85 | //Set Location |
||
86 | if(isset($_GET['city'])) |
||
87 | { |
||
88 | $newPositionStatus = setLocation($accessToken, $deviceUid); |
||
89 | } |
||
90 | |||
91 | //Vote |
||
92 | if(isset($_GET['vote']) && isset($_GET['postID'])) |
||
93 | { |
||
94 | votePostId($deviceUid_forId1, $accessToken_forId1); |
||
95 | } |
||
96 | |||
97 | //SendJodel |
||
98 | if(isset($_POST['message'])) |
||
99 | { |
||
100 | sendJodel($location, $accessToken_forId1); |
||
101 | } |
||
102 | |||
103 | |||
104 | $posts; |
||
105 | |||
106 | //Get Post Details |
||
107 | if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
||
108 | { |
||
109 | $userHandleBuffer = []; |
||
110 | |||
111 | $accountCreator = new GetPostDetails(); |
||
112 | $accountCreator->setAccessToken($accessToken); |
||
113 | $data = $accountCreator->execute(); |
||
114 | |||
115 | $posts[0] = $data; |
||
116 | if(array_key_exists('children', $data)) { |
||
117 | foreach($data['children'] as $key => $child) |
||
118 | { |
||
119 | |||
120 | if(!$child["parent_creator"] == 1) |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
parent_creator does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
121 | { |
||
122 | $numberForUser = array_search($child['user_handle'], $userHandleBuffer); |
||
123 | if($numberForUser === FALSE) |
||
124 | { |
||
125 | array_push($userHandleBuffer, $child['user_handle']); |
||
126 | $data['children'][$key]['user_handle'] = count($userHandleBuffer); |
||
127 | } |
||
128 | else |
||
129 | { |
||
130 | $data['children'][$key]['user_handle'] = $numberForUser + 1; |
||
131 | } |
||
132 | } |
||
133 | |||
134 | array_push($posts, $data['children'][$key]); |
||
135 | } |
||
136 | $loops = $data['child_count'] + 1; |
||
137 | } |
||
138 | else |
||
139 | { |
||
140 | $loops = 1; |
||
141 | } |
||
142 | $isDetailedView = TRUE; |
||
143 | } |
||
144 | //Get Posts |
||
145 | else |
||
146 | { |
||
147 | $version = 'v2'; |
||
148 | if($view=='comment') |
||
149 | { |
||
150 | $url = "/v2/posts/location/discussed/"; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
/v2/posts/location/discussed/ does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
151 | } |
||
152 | else |
||
153 | { |
||
154 | if($view=='upVote') |
||
155 | { |
||
156 | $url = "/v2/posts/location/popular/"; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
/v2/posts/location/popular/ does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
157 | } |
||
158 | else |
||
159 | { |
||
160 | $url = "/v3/posts/location/combo/"; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() Coding Style
Comprehensibility
introduced
by
The string literal
/v3/posts/location/combo/ does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
161 | $version = 'v3'; |
||
162 | } |
||
163 | } |
||
164 | |||
165 | if($version == 'v3') |
||
166 | { |
||
167 | $posts = getPosts($lastPostId, $accessToken, $url, $version)['recent']; |
||
168 | } |
||
169 | else |
||
170 | { |
||
171 | $posts = getPosts($lastPostId, $accessToken, $url, $version)['posts']; |
||
172 | } |
||
173 | $loops = 29; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
174 | $isDetailedView = FALSE; |
||
175 | } |
||
176 | ?> |
||
177 | <!DOCTYPE html> |
||
178 | <html lang="en"> |
||
179 | <head> |
||
180 | <title><?php echo getTitle($posts[0], $view, $isDetailedView);?></title> |
||
181 | |||
182 | <meta charset="utf-8"> |
||
183 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
||
184 | <meta http-equiv="x-ua-compatible" content="ie=edge"> |
||
185 | |||
186 | <meta name="description" content="<?php echo getMetaDescription($posts[0], $view, $isDetailedView);?>"> |
||
187 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app"> |
||
188 | |||
189 | <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"> |
||
190 | <link rel="stylesheet" href="css/font-awesome.min.css"> |
||
191 | <link rel="stylesheet" href="style.css" type="text/css"> |
||
192 | |||
193 | <link rel="shortcut icon" type="image/x-icon" href="./img/favicon/favicon.ico"> |
||
194 | <link rel="icon" type="image/x-icon" href="./img/favicon/favicon.ico"> |
||
195 | <link rel="icon" type="image/gif" href="./img/favicon/favicon.gif"> |
||
196 | <link rel="icon" type="image/png" href="./img/favicon/favicon.png"> |
||
197 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon.png"> |
||
198 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
||
199 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
||
200 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
||
201 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
||
202 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
||
203 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
||
204 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
||
205 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
||
206 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
||
207 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
||
208 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-precomposed.png"> |
||
209 | <link rel="icon" type="image/png" href="./img/favicon/favicon-16x16.png" sizes="16x16"> |
||
210 | <link rel="icon" type="image/png" href="./img/favicon/favicon-32x32.png" sizes="32x32"> |
||
211 | <link rel="icon" type="image/png" href="./img/favicon/favicon-96x96.png" sizes="96x96"> |
||
212 | <link rel="icon" type="image/png" href="./img/favicon/favicon-160x160.png" sizes="160x160"> |
||
213 | <link rel="icon" type="image/png" href="./img/favicon/favicon-192x192.png" sizes="192x192"> |
||
214 | <link rel="icon" type="image/png" href="./img/favicon/favicon-196x196.png" sizes="196x196"> |
||
215 | <meta name="msapplication-TileImage" content="./img/favicon/win8-tile-144x144.png"> |
||
216 | <meta name="msapplication-TileColor" content="#5682a3"> |
||
217 | <meta name="msapplication-navbutton-color" content="#5682a3"> |
||
218 | <meta name="application-name" content="JodelBlue"/> |
||
219 | <meta name="msapplication-tooltip" content="JodelBlue"/> |
||
220 | <meta name="apple-mobile-web-app-title" content="JodelBlue"/> |
||
221 | <meta name="msapplication-square70x70logo" content="./img/favicon/win8-tile-70x70.png"> |
||
222 | <meta name="msapplication-square144x144logo" content="./img/favicon/win8-tile-144x144.png"> |
||
223 | <meta name="msapplication-square150x150logo" content="./img/favicon/win8-tile-150x150.png"> |
||
224 | <meta name="msapplication-wide310x150logo" content="./img/favicon/win8-tile-310x150.png"> |
||
225 | <meta name="msapplication-square310x310logo" content="./img/favicon/win8-tile-310x310.png"> |
||
226 | </head> |
||
227 | |||
228 | <body> |
||
229 | <header> |
||
230 | <nav class="navbar navbar-full navbar-dark navbar-fixed-top"> |
||
231 | <div class="container"> |
||
232 | <?php |
||
233 | if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
||
234 | { |
||
235 | echo '<a id="comment-back" href="index.php?view=' . $view . '#postId-' . htmlspecialchars($_GET['postID']) . '">'; |
||
236 | echo '<i class="fa fa-angle-left fa-3x"></i>'; |
||
237 | echo '</a>'; |
||
238 | echo '<h1>'; |
||
239 | echo '<a href="index.php?getPostDetails=' . htmlspecialchars($_GET['getPostDetails']) . '&postID=' . htmlspecialchars($_GET['postID']) . '" class="spinnable">'; |
||
240 | } |
||
241 | else |
||
242 | { |
||
243 | echo '<h1>'; |
||
244 | echo '<a href="./" class="spinnable">'; |
||
245 | } |
||
246 | ?> |
||
247 | JodelBlue <i class="fa fa-refresh fa-1x"></i></a> |
||
248 | </h1> |
||
249 | |||
250 | <div id="location_mobile" class="hidden-sm-up"> |
||
251 | <form method="get"> |
||
252 | <input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
||
253 | |||
254 | <input type="submit" id="submit_mobile" class="fa" value="" /> |
||
255 | </form> |
||
256 | </div> |
||
257 | </div> |
||
258 | </nav> |
||
259 | </header> |
||
260 | |||
261 | <div class="mainContent container"> |
||
262 | <div class="content row"> |
||
263 | <article class="topContent col-sm-8"> |
||
264 | |||
265 | <content id="posts"> |
||
266 | <?php |
||
267 | for($i = 0; $i<$loops; $i++) |
||
268 | { |
||
269 | if(array_key_exists($i, $posts) && array_key_exists('post_id', $posts[$i]) && isset($posts[$i]['post_id'])) |
||
270 | { |
||
271 | $lastPostId = $posts[$i]['post_id']; |
||
272 | |||
273 | jodelToHtml($posts[$i], $view, $isDetailedView); |
||
274 | } |
||
275 | } ?> |
||
276 | |||
277 | </content> |
||
278 | |||
279 | <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
||
280 | <p id="loading"> |
||
281 | Loading… |
||
282 | </p> |
||
283 | <?php } ?> |
||
284 | </article> |
||
285 | |||
286 | <aside class="topSidebar col-sm-4 sidebar-outer"> |
||
287 | <div class="fixed"> |
||
288 | <article> |
||
289 | <div> |
||
290 | <h2>Position</h2> |
||
291 | <form method="get"> |
||
292 | <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
||
293 | |||
294 | <input type="submit" value="Set Location" /> |
||
295 | </form> |
||
296 | </div> |
||
297 | </article> |
||
298 | |||
299 | <article> |
||
300 | <div> |
||
301 | <h2>Karma</h2> |
||
302 | <?php echo getKarma($accessToken_forId1); ?> |
||
303 | </div> |
||
304 | </article> |
||
305 | |||
306 | <article> |
||
307 | <div> |
||
308 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
||
309 | <h2>Comment on Jodel</h2> |
||
310 | <form method="POST"> |
||
311 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
||
312 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
||
313 | <br /> |
||
314 | <input type="submit" value="SEND" /> |
||
315 | </form> |
||
316 | <?php } else { ?> |
||
317 | <h2>New Jodel</h2> |
||
318 | <form method="POST"> |
||
319 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
||
320 | <br /> |
||
321 | <select id="postColorPicker" name="color"> |
||
322 | <option value="06A3CB">Blue</option> |
||
323 | <option value="8ABDB0">Teal</option> |
||
324 | <option value="9EC41C">Green</option> |
||
325 | <option value="FFBA00">Yellow</option> |
||
326 | <option value="DD5F5F">Red</option> |
||
327 | <option value="FF9908">Orange</option> |
||
328 | </select> |
||
329 | <br /> |
||
330 | <input type="submit" value="SEND" /> |
||
331 | </form> |
||
332 | <?php } ?> |
||
333 | </div> |
||
334 | </article> |
||
335 | |||
336 | <article> |
||
337 | <div> |
||
338 | <h2>Login</h2> |
||
339 | </div> |
||
340 | </article> |
||
341 | </div> |
||
342 | </aside> |
||
343 | </div> |
||
344 | <div id="sortJodelBy" class="row"> |
||
345 | <div class="col-xs-12"> |
||
346 | <div class="row"> |
||
347 | <div class="col-xs-3"> |
||
348 | <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
||
349 | </div> |
||
350 | <div class="col-xs-3"> |
||
351 | <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
||
352 | </div> |
||
353 | <div class="col-xs-3"> |
||
354 | <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
||
355 | </div> |
||
356 | <div class="col-xs-3"> |
||
357 | <nav> |
||
358 | <a href="./about-us.html">about us</a> |
||
359 | </nav> |
||
360 | </div> |
||
361 | </div> |
||
362 | </div> |
||
363 | </div> |
||
364 | </div> |
||
365 | |||
366 | |||
367 | <!-- jQuery, Tether, Bootstrap JS and own--> |
||
368 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script> |
||
369 | <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script> |
||
370 | <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script> |
||
371 | <script src="js/jQueryEmoji.js"></script> |
||
372 | |||
373 | <script> |
||
374 | //BackButton |
||
375 | function goBack() |
||
376 | { |
||
377 | window.history.back(); |
||
378 | } |
||
379 | |||
380 | $(document).ready(function() |
||
381 | { |
||
382 | //Transform UTF-8 Emoji to img |
||
383 | $('.jodel > content').Emoji(); |
||
384 | |||
385 | $('a').on('click', function(){ |
||
386 | $('a').removeClass('selected'); |
||
387 | $(this).addClass('selected'); |
||
388 | }); |
||
389 | |||
390 | function scrollToAnchor(aid){ |
||
391 | var aTag = $("article[id='"+ aid +"']"); |
||
392 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
||
393 | } |
||
394 | |||
395 | <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
||
396 | |||
397 | |||
398 | |||
399 | |||
400 | |||
401 | var win = $(window); |
||
402 | var lastPostId = "<?php echo $lastPostId; ?>"; |
||
403 | var view = "<?php echo $view; ?>" |
||
404 | var old_lastPostId = ""; |
||
405 | var morePostsAvailable = true; |
||
406 | |||
407 | if(window.location.hash) |
||
408 | { |
||
409 | var hash = window.location.hash.slice(1); |
||
410 | |||
411 | if(!$("article[id='"+ hash +"']").length) |
||
412 | { |
||
413 | for (var i = 5; i >= 0; i--) |
||
414 | { |
||
415 | if(!$("article[id='"+ hash +"']").length) |
||
416 | { |
||
417 | $.ajax({ |
||
418 | url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view, |
||
419 | dataType: 'html', |
||
420 | async: false, |
||
421 | success: function(html) { |
||
422 | var div = document.createElement('div'); |
||
423 | div.innerHTML = html; |
||
424 | var elements = div.childNodes; |
||
425 | old_lastPostId = lastPostId; |
||
426 | lastPostId = elements[3].textContent; |
||
427 | lastPostId = lastPostId.replace(/\s+/g, ''); |
||
428 | //alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId); |
||
429 | if(lastPostId == old_lastPostId) { |
||
430 | |||
431 | //morePostsAvailable = false; |
||
432 | } |
||
433 | else { |
||
434 | //alert(elements[3].textContent); |
||
435 | $('#posts').append(elements[1].innerHTML); |
||
436 | $('#posts').hide().show(0); |
||
437 | } |
||
438 | $('#loading').hide(); |
||
439 | } |
||
440 | }); |
||
441 | |||
442 | $('.jodel > content').Emoji(); |
||
443 | } |
||
444 | |||
445 | } |
||
446 | scrollToAnchor(hash); |
||
447 | |||
448 | } |
||
449 | } |
||
450 | |||
451 | // Each time the user scrolls |
||
452 | win.scroll(function() { |
||
453 | |||
454 | |||
455 | // End of the document reached? |
||
456 | if ($(window).scrollTop() + $(window).height() > $(document).height() - 100 && morePostsAvailable) |
||
457 | { |
||
458 | $('#loading').show(); |
||
459 | |||
460 | $.ajax({ |
||
461 | url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view, |
||
462 | dataType: 'html', |
||
463 | async: false, |
||
464 | success: function(html) { |
||
465 | var div = document.createElement('div'); |
||
466 | div.innerHTML = html; |
||
467 | var elements = div.childNodes; |
||
468 | old_lastPostId = lastPostId; |
||
469 | lastPostId = elements[3].textContent; |
||
470 | lastPostId = lastPostId.replace(/\s+/g, ''); |
||
471 | //alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId); |
||
472 | if(lastPostId == old_lastPostId) |
||
473 | { |
||
474 | |||
475 | //morePostsAvailable = false; |
||
476 | } |
||
477 | else |
||
478 | { |
||
479 | //alert(elements[3].textContent); |
||
480 | $('#posts').append(elements[1].innerHTML); |
||
481 | } |
||
482 | $('#loading').hide(); |
||
483 | } |
||
484 | }); |
||
485 | |||
486 | $('.jodel > content').Emoji(); |
||
487 | } |
||
488 | }); |
||
489 | <?php } ?> |
||
490 | }); |
||
491 | |||
492 | </script> |
||
493 | |||
494 | <?php |
||
495 | if(is_file('./piwik-script.html')) |
||
496 | { |
||
497 | require_once('./piwik-script.html'); |
||
498 | } |
||
499 | ?> |
||
500 | |||
501 | </body> |
||
502 | </html> |
||
503 | |||
0 ignored issues
–
show
|
|||
504 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.