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 | $location = new Location(); |
||
6 | $location->setLat('52.5134288'); |
||
7 | $location->setLng('13.2746394'); |
||
8 | $location->setCityName('Berlin'); |
||
9 | |||
10 | $accessToken; |
||
11 | $accessToken_forId1; |
||
12 | $deviceUid; |
||
13 | |||
14 | //What is dude doing with my Server? |
||
15 | if($_SERVER['REMOTE_ADDR'] == '94.231.103.52') |
||
16 | { |
||
17 | echo('You are flooting my Server! Pls enable Cookies in your script and contact me: [email protected]'); |
||
18 | die(); |
||
19 | } |
||
20 | |||
21 | |||
22 | $config = parse_ini_file('config/config.ini.php'); |
||
23 | |||
24 | //Ceck if it's a Spider or Google Bot |
||
25 | if(botDeviceUidIsSet($config) && isUserBot()) |
||
26 | { |
||
27 | error_log('Spider or Bot checked in!'); |
||
28 | |||
29 | //Change this to a free device_uid listed in your DB |
||
30 | $deviceUid = $config['botDeviceUid']; |
||
31 | $config = NULL; |
||
32 | } |
||
33 | else |
||
34 | { |
||
35 | $config = NULL; |
||
36 | if(!isset($_COOKIE["JodelDeviceId"])) |
||
0 ignored issues
–
show
|
|||
37 | { |
||
38 | $deviceUid = createAccount(); |
||
39 | setcookie('JodelDeviceId', $deviceUid, time()+60*60*24*365*10); |
||
40 | error_log('Created account with JodelDeviceId:' . $deviceUid . ' for [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | } |
||
43 | else |
||
44 | { |
||
45 | $deviceUid = $db->real_escape_string($_COOKIE["JodelDeviceId"]); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
JodelDeviceId 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. ![]() |
|||
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 | |||
56 | |||
57 | //Set View |
||
58 | View Code Duplication | if(isset($_GET['view'])) |
|
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 | //Set Location |
||
80 | if(isset($_GET['city'])) { |
||
81 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
||
82 | $result = Requests::post($url); |
||
83 | if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
||
84 | { |
||
85 | $newPositionStatus = "0 results"; |
||
86 | } |
||
87 | else |
||
88 | { |
||
89 | $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
||
90 | $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
||
91 | $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
||
92 | |||
93 | $location = new Location(); |
||
94 | $location->setLat($lat); |
||
95 | $location->setLng($lng); |
||
96 | $location->setCityName($name); |
||
97 | $accountCreator = new UpdateLocation(); |
||
98 | $accountCreator->setLocation($location); |
||
99 | $accountCreator->setAccessToken($accessToken); |
||
100 | $data = $accountCreator->execute(); |
||
101 | |||
102 | //safe location to db |
||
103 | if($data == "Success") |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
Success 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. ![]() |
|||
104 | { |
||
105 | $result = $db->query("UPDATE accounts |
||
106 | SET name='" . $name . "', |
||
107 | lat='" . $lat . "', |
||
108 | lng='" . $lng . "' |
||
109 | WHERE access_token='" . $accessToken . "'"); |
||
110 | |||
111 | if($result === false) |
||
112 | { |
||
113 | echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
||
114 | } |
||
115 | else |
||
116 | { |
||
117 | $newPositionStatus = $name; |
||
118 | error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name); |
||
119 | } |
||
120 | } |
||
121 | } |
||
122 | } |
||
123 | |||
124 | //Vote |
||
125 | if(isset($_GET['vote']) && isset($_GET['postID'])) { |
||
126 | View Code Duplication | if($_GET['vote'] == "up") { |
|
127 | $accountCreator = new Upvote(); |
||
128 | } |
||
129 | else if($_GET['vote'] == "down") { |
||
130 | $accountCreator = new Downvote(); |
||
131 | } |
||
132 | $accountCreator->setAccessToken($accessToken_forId1); |
||
133 | $accountCreator->postId = $_GET['postID']; |
||
134 | $data = $accountCreator->execute(); |
||
135 | |||
136 | header("Location: index.php#postId-" . htmlspecialchars($_GET['postID'])); |
||
137 | die(); |
||
138 | } |
||
139 | |||
140 | |||
141 | //SendJodel |
||
142 | if(isset($_POST['message'])) { |
||
143 | $accountCreator = new SendJodel(); |
||
144 | |||
145 | if(isset($_POST['ancestor'])) |
||
146 | { |
||
147 | $ancestor = $_POST['ancestor']; |
||
148 | $accountCreator->ancestor = $ancestor; |
||
149 | } |
||
150 | if(isset($_POST['color'])) |
||
151 | { |
||
152 | $color = $_POST['color']; |
||
153 | switch ($color) { |
||
154 | case '8ABDB0': |
||
155 | $color = '8ABDB0'; |
||
156 | break; |
||
157 | case '9EC41C': |
||
158 | $color = '9EC41C'; |
||
159 | break; |
||
160 | case '06A3CB': |
||
161 | $color = '06A3CB'; |
||
162 | break; |
||
163 | case 'FFBA00': |
||
164 | $color = 'FFBA00'; |
||
165 | break; |
||
166 | case 'DD5F5F': |
||
167 | $color = 'DD5F5F'; |
||
168 | break; |
||
169 | case 'FF9908': |
||
170 | $color = 'FF9908'; |
||
171 | break; |
||
172 | |||
173 | default: |
||
174 | $color = '8ABDB0'; |
||
175 | break; |
||
176 | } |
||
177 | $accountCreator->color = $color; |
||
178 | } |
||
179 | |||
180 | //$location = getLocationByAccessToken($accessToken); |
||
181 | |||
182 | $accountCreatorLocation = new UpdateLocation(); |
||
183 | $accountCreatorLocation->setLocation($location); |
||
184 | $accountCreatorLocation->setAccessToken($accessToken_forId1); |
||
185 | $data = $accountCreatorLocation->execute(); |
||
186 | |||
187 | $accountCreator->location = $location; |
||
188 | |||
189 | $accountCreator->setAccessToken($accessToken_forId1); |
||
190 | $data = $accountCreator->execute(); |
||
191 | |||
192 | if(isset($_POST['ancestor'])) |
||
193 | { |
||
194 | $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; |
||
0 ignored issues
–
show
As per coding-style, please use concatenation or
sprintf for the variable $_SERVER instead of interpolation.
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings. // Instead of
$x = "foo $bar $baz";
// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
![]() |
|||
195 | header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id'])); |
||
196 | exit; |
||
197 | } |
||
198 | else |
||
199 | { |
||
200 | header('Location: ./'); |
||
201 | exit; |
||
202 | } |
||
203 | } |
||
204 | ?> |
||
205 | <!DOCTYPE html> |
||
206 | <html lang="en"> |
||
207 | <head> |
||
208 | <title>JodelBlue - Web-App and Browser-Client</title> |
||
209 | |||
210 | <meta charset="utf-8"> |
||
211 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
||
212 | <meta http-equiv="x-ua-compatible" content="ie=edge"> |
||
213 | |||
214 | <meta name="description" content="JodelBlue is a Web-App and Browser-Client for the Jodel App. No registration required! Browse Jodels all over the world. Send your own Jodels or upvote others."> |
||
215 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app"> |
||
216 | |||
217 | <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"> |
||
218 | <link rel="stylesheet" href="css/font-awesome.min.css"> |
||
219 | <link rel="stylesheet" href="style.css" type="text/css"> |
||
220 | |||
221 | <link rel="shortcut icon" type="image/x-icon" href="./img/favicon/favicon.ico"> |
||
222 | <link rel="icon" type="image/x-icon" href="./img/favicon/favicon.ico"> |
||
223 | <link rel="icon" type="image/gif" href="./img/favicon/favicon.gif"> |
||
224 | <link rel="icon" type="image/png" href="./img/favicon/favicon.png"> |
||
225 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon.png"> |
||
226 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
||
227 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
||
228 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
||
229 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
||
230 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
||
231 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
||
232 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
||
233 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
||
234 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
||
235 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
||
236 | <link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-precomposed.png"> |
||
237 | <link rel="icon" type="image/png" href="./img/favicon/favicon-16x16.png" sizes="16x16"> |
||
238 | <link rel="icon" type="image/png" href="./img/favicon/favicon-32x32.png" sizes="32x32"> |
||
239 | <link rel="icon" type="image/png" href="./img/favicon/favicon-96x96.png" sizes="96x96"> |
||
240 | <link rel="icon" type="image/png" href="./img/favicon/favicon-160x160.png" sizes="160x160"> |
||
241 | <link rel="icon" type="image/png" href="./img/favicon/favicon-192x192.png" sizes="192x192"> |
||
242 | <link rel="icon" type="image/png" href="./img/favicon/favicon-196x196.png" sizes="196x196"> |
||
243 | <meta name="msapplication-TileImage" content="./img/favicon/win8-tile-144x144.png"> |
||
244 | <meta name="msapplication-TileColor" content="#5682a3"> |
||
245 | <meta name="msapplication-navbutton-color" content="#5682a3"> |
||
246 | <meta name="application-name" content="JodelBlue"/> |
||
247 | <meta name="msapplication-tooltip" content="JodelBlue"/> |
||
248 | <meta name="apple-mobile-web-app-title" content="JodelBlue"/> |
||
249 | <meta name="msapplication-square70x70logo" content="./img/favicon/win8-tile-70x70.png"> |
||
250 | <meta name="msapplication-square144x144logo" content="./img/favicon/win8-tile-144x144.png"> |
||
251 | <meta name="msapplication-square150x150logo" content="./img/favicon/win8-tile-150x150.png"> |
||
252 | <meta name="msapplication-wide310x150logo" content="./img/favicon/win8-tile-310x150.png"> |
||
253 | <meta name="msapplication-square310x310logo" content="./img/favicon/win8-tile-310x310.png"> |
||
254 | </head> |
||
255 | |||
256 | <body> |
||
257 | <header> |
||
258 | <nav class="navbar navbar-full navbar-dark navbar-fixed-top"> |
||
259 | <div class="container"> |
||
260 | <?php |
||
261 | if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
||
262 | { |
||
263 | echo '<a id="comment-back" href="index.php?view=' . $view . '#postId-' . htmlspecialchars($_GET['postID']) . '">'; |
||
264 | echo '<i class="fa fa-angle-left fa-3x"></i>'; |
||
265 | echo '</a>'; |
||
266 | echo '<h1>'; |
||
267 | echo '<a href="index.php?getPostDetails=' . htmlspecialchars($_GET['getPostDetails']) . '&postID=' . htmlspecialchars($_GET['postID']) . '" class="spinnable">'; |
||
268 | } |
||
269 | else |
||
270 | { |
||
271 | echo '<h1>'; |
||
272 | echo '<a href="./" class="spinnable">'; |
||
273 | } |
||
274 | ?> |
||
275 | JodelBlue <i class="fa fa-refresh fa-1x"></i></a> |
||
276 | </h1> |
||
277 | </div> |
||
278 | </nav> |
||
279 | </header> |
||
280 | |||
281 | <div class="mainContent container"> |
||
282 | <div class="content row"> |
||
283 | <article class="topContent col-sm-8"> |
||
284 | |||
285 | <content id="posts"> |
||
286 | <?php |
||
287 | $posts; |
||
288 | |||
289 | //Get Post Details |
||
290 | if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
||
291 | { |
||
292 | $userHandleBuffer = []; |
||
293 | |||
294 | $accountCreator = new GetPostDetails(); |
||
295 | $accountCreator->setAccessToken($accessToken); |
||
296 | $data = $accountCreator->execute(); |
||
297 | |||
298 | $posts[0] = $data; |
||
299 | if(array_key_exists('children', $data)) { |
||
300 | foreach($data['children'] as $key => $child) |
||
301 | { |
||
302 | |||
303 | if(!$child["parent_creator"] == 1) |
||
304 | { |
||
305 | $numberForUser = array_search($child['user_handle'], $userHandleBuffer); |
||
306 | if($numberForUser === FALSE) |
||
307 | { |
||
308 | array_push($userHandleBuffer, $child['user_handle']); |
||
309 | $data['children'][$key]['user_handle'] = count($userHandleBuffer); |
||
310 | } |
||
311 | else |
||
312 | { |
||
313 | $data['children'][$key]['user_handle'] = $numberForUser + 1; |
||
314 | } |
||
315 | } |
||
316 | |||
317 | array_push($posts, $data['children'][$key]); |
||
318 | } |
||
319 | $loops = $data['child_count'] + 1; |
||
320 | } |
||
321 | else |
||
322 | { |
||
323 | $loops = 1; |
||
324 | } |
||
325 | $isDetailedView = TRUE; |
||
326 | } |
||
327 | //Get Posts |
||
328 | else |
||
329 | { |
||
330 | $version = 'v2'; |
||
331 | if($view=='comment') |
||
332 | { |
||
333 | $url = "/v2/posts/location/discussed/"; |
||
334 | } |
||
335 | else |
||
336 | { |
||
337 | if($view=='upVote') |
||
338 | { |
||
339 | $url = "/v2/posts/location/popular/"; |
||
340 | } |
||
341 | else |
||
342 | { |
||
343 | $url = "/v3/posts/location/combo/"; |
||
344 | $version = 'v3'; |
||
345 | } |
||
346 | } |
||
347 | |||
348 | if($version == 'v3') |
||
349 | { |
||
350 | $posts = getPosts($lastPostId, $accessToken, $url, $version)['recent']; |
||
351 | } |
||
352 | else |
||
353 | { |
||
354 | $posts = getPosts($lastPostId, $accessToken, $url, $version)['posts']; |
||
355 | } |
||
356 | $loops = 29; |
||
357 | $isDetailedView = FALSE; |
||
358 | } |
||
359 | |||
360 | |||
361 | View Code Duplication | for($i = 0; $i<$loops; $i++) |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. ![]() |
|||
362 | { |
||
363 | if(array_key_exists($i, $posts)) |
||
364 | { |
||
365 | $lastPostId = $posts[$i]['post_id']; |
||
366 | |||
367 | jodelToHtml($posts[$i], $view, $isDetailedView); |
||
368 | } |
||
369 | } ?> |
||
370 | |||
371 | </content> |
||
372 | |||
373 | <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
||
374 | <p id="loading"> |
||
375 | Loading… |
||
376 | </p> |
||
377 | <?php } ?> |
||
378 | </article> |
||
379 | |||
380 | <aside class="topSidebar col-sm-4 sidebar-outer"> |
||
381 | <div class="fixed"> |
||
382 | <article> |
||
383 | <div> |
||
384 | <h2>Position</h2> |
||
385 | <form method="get"> |
||
386 | <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
||
387 | |||
388 | <input type="submit" value="Set Location" /> |
||
389 | </form> |
||
390 | </div> |
||
391 | </article> |
||
392 | |||
393 | <article> |
||
394 | <div> |
||
395 | <h2>Karma</h2> |
||
396 | <?php echo getKarma($accessToken_forId1); ?> |
||
397 | </div> |
||
398 | </article> |
||
399 | |||
400 | <article> |
||
401 | <div> |
||
402 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
||
403 | <h2>Comment on Jodel</h2> |
||
404 | <form method="POST"> |
||
405 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
||
406 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
||
407 | <br /> |
||
408 | <input type="submit" value="SEND" /> |
||
409 | </form> |
||
410 | <?php } else { ?> |
||
411 | <h2>New Jodel</h2> |
||
412 | <form method="POST"> |
||
413 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
||
414 | <br /> |
||
415 | <select id="postColorPicker" name="color"> |
||
416 | <option value="06A3CB">Blue</option> |
||
417 | <option value="8ABDB0">Teal</option> |
||
418 | <option value="9EC41C">Green</option> |
||
419 | <option value="FFBA00">Yellow</option> |
||
420 | <option value="DD5F5F">Red</option> |
||
421 | <option value="FF9908">Orange</option> |
||
422 | </select> |
||
423 | <br /> |
||
424 | <input type="submit" value="SEND" /> |
||
425 | </form> |
||
426 | <?php } ?> |
||
427 | </div> |
||
428 | </article> |
||
429 | |||
430 | <article> |
||
431 | <div> |
||
432 | <h2>Login</h2> |
||
433 | </div> |
||
434 | </article> |
||
435 | </div> |
||
436 | </aside> |
||
437 | </div> |
||
438 | <div id="sortJodelBy" class="row"> |
||
439 | <div class="col-sm-12"> |
||
440 | <div class="row"> |
||
441 | <div class="col-sm-3"> |
||
442 | <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
||
443 | </div> |
||
444 | <div class="col-sm-3"> |
||
445 | <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
||
446 | </div> |
||
447 | <div class="col-sm-3"> |
||
448 | <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
||
449 | </div> |
||
450 | <div class="col-sm-3"> |
||
451 | <nav> |
||
452 | <a href="./about-us.html">about us</a> |
||
453 | </nav> |
||
454 | </div> |
||
455 | </div> |
||
456 | </div> |
||
457 | </div> |
||
458 | </div> |
||
459 | |||
460 | |||
461 | <!-- jQuery, Tether, Bootstrap JS and own--> |
||
462 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script> |
||
463 | <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script> |
||
464 | <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script> |
||
465 | <script src="js/jQueryEmoji.js"></script> |
||
466 | |||
467 | <script> |
||
468 | //BackButton |
||
469 | function goBack() |
||
470 | { |
||
471 | window.history.back(); |
||
472 | } |
||
473 | |||
474 | $(document).ready(function() |
||
475 | { |
||
476 | |||
477 | |||
478 | //Transform UTF-8 Emoji to img |
||
479 | $('.jodel > content').Emoji(); |
||
480 | |||
481 | $('a').on('click', function(){ |
||
482 | $('a').removeClass('selected'); |
||
483 | $(this).addClass('selected'); |
||
484 | }); |
||
485 | |||
486 | function scrollToAnchor(aid){ |
||
487 | var aTag = $("article[id='"+ aid +"']"); |
||
488 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
||
489 | } |
||
490 | |||
491 | <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
||
492 | |||
493 | |||
494 | |||
495 | |||
496 | |||
497 | var win = $(window); |
||
498 | var lastPostId = "<?php echo $lastPostId; ?>"; |
||
499 | var view = "<?php echo $view; ?>" |
||
500 | var old_lastPostId = ""; |
||
501 | var morePostsAvailable = true; |
||
502 | |||
503 | if(window.location.hash) |
||
504 | { |
||
505 | var hash = window.location.hash.slice(1); |
||
506 | |||
507 | if(!$("article[id='"+ hash +"']").length) |
||
508 | { |
||
509 | for (var i = 5; i >= 0; i--) |
||
510 | { |
||
511 | if(!$("article[id='"+ hash +"']").length) |
||
512 | { |
||
513 | $.ajax({ |
||
514 | url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view, |
||
515 | dataType: 'html', |
||
516 | async: false, |
||
517 | success: function(html) { |
||
518 | var div = document.createElement('div'); |
||
519 | div.innerHTML = html; |
||
520 | var elements = div.childNodes; |
||
521 | old_lastPostId = lastPostId; |
||
522 | lastPostId = elements[3].textContent; |
||
523 | lastPostId = lastPostId.replace(/\s+/g, ''); |
||
524 | //alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId); |
||
525 | if(lastPostId == old_lastPostId) { |
||
526 | |||
527 | //morePostsAvailable = false; |
||
528 | } |
||
529 | else { |
||
530 | //alert(elements[3].textContent); |
||
531 | $('#posts').append(elements[1].innerHTML); |
||
532 | $('#posts').hide().show(0); |
||
533 | } |
||
534 | $('#loading').hide(); |
||
535 | } |
||
536 | }); |
||
537 | |||
538 | $('.jodel > content').Emoji(); |
||
539 | } |
||
540 | |||
541 | } |
||
542 | scrollToAnchor(hash); |
||
543 | |||
544 | } |
||
545 | } |
||
546 | |||
547 | // Each time the user scrolls |
||
548 | win.scroll(function() { |
||
549 | |||
550 | |||
551 | // End of the document reached? |
||
552 | if (($(document).height() - win.height() == win.scrollTop()) && morePostsAvailable) { |
||
553 | $('#loading').show(); |
||
554 | |||
555 | |||
556 | |||
557 | $.ajax({ |
||
558 | url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view, |
||
559 | dataType: 'html', |
||
560 | async: false, |
||
561 | success: function(html) { |
||
562 | var div = document.createElement('div'); |
||
563 | div.innerHTML = html; |
||
564 | var elements = div.childNodes; |
||
565 | old_lastPostId = lastPostId; |
||
566 | lastPostId = elements[3].textContent; |
||
567 | lastPostId = lastPostId.replace(/\s+/g, ''); |
||
568 | //alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId); |
||
569 | if(lastPostId == old_lastPostId) |
||
570 | { |
||
571 | |||
572 | //morePostsAvailable = false; |
||
573 | } |
||
574 | else |
||
575 | { |
||
576 | //alert(elements[3].textContent); |
||
577 | $('#posts').append(elements[1].innerHTML); |
||
578 | } |
||
579 | $('#loading').hide(); |
||
580 | } |
||
581 | }); |
||
582 | |||
583 | $('.jodel > content').Emoji(); |
||
584 | } |
||
585 | }); |
||
586 | <?php } ?> |
||
587 | }); |
||
588 | |||
589 | </script> |
||
590 | </body> |
||
591 | </html> |
||
592 | |||
593 |
PHP provides two ways to mark string literals. Either with single quotes
'literal'
or with double quotes"literal"
. The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.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 (
\'
) and the backslash (\\
). Every other character is displayed as is.Double quoted string literals may contain other variables or more complex escape sequences.
will print an indented:
Single is Value
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.