@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | //createAccount(); |
32 | 32 | |
33 | 33 | //Set Location |
34 | - if(isset($_GET['city'])) { |
|
34 | + if(isset($_GET['city'])) |
|
35 | + { |
|
35 | 36 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
36 | 37 | $result = Requests::post($url); |
37 | 38 | if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
@@ -52,11 +53,14 @@ discard block |
||
52 | 53 | } |
53 | 54 | |
54 | 55 | //Vote |
55 | - if(isset($_GET['vote']) && isset($_GET['postID'])) { |
|
56 | - if($_GET['vote'] == "up") { |
|
56 | + if(isset($_GET['vote']) && isset($_GET['postID'])) |
|
57 | + { |
|
58 | + if($_GET['vote'] == "up") |
|
59 | + { |
|
57 | 60 | $accountCreator = new Upvote(); |
58 | 61 | } |
59 | - else if($_GET['vote'] == "down") { |
|
62 | + else if($_GET['vote'] == "down") |
|
63 | + { |
|
60 | 64 | $accountCreator = new Downvote(); |
61 | 65 | } |
62 | 66 | $accountCreator->setAccessToken($accessToken); |
@@ -68,7 +72,8 @@ discard block |
||
68 | 72 | |
69 | 73 | |
70 | 74 | //SendJodel |
71 | - if(isset($_POST['message'])) { |
|
75 | + if(isset($_POST['message'])) |
|
76 | + { |
|
72 | 77 | $ancestor; |
73 | 78 | if(isset($_POST['ancestor'])) |
74 | 79 | { |
@@ -114,7 +119,11 @@ discard block |
||
114 | 119 | <a href="index.php"> |
115 | 120 | <h1> |
116 | 121 | JodelBlue |
117 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) echo '<i class="fa fa-refresh fa-1x"></i>';?> |
|
122 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
123 | +{ |
|
124 | + echo '<i class="fa fa-refresh fa-1x"></i>'; |
|
125 | +} |
|
126 | +?> |
|
118 | 127 | </h1> |
119 | 128 | </a> |
120 | 129 | <div class="clear"></div> |
@@ -130,7 +139,8 @@ discard block |
||
130 | 139 | //Set View |
131 | 140 | if(isset($_GET['view'])) |
132 | 141 | { |
133 | - switch ($_GET['view']) { |
|
142 | + switch ($_GET['view']) |
|
143 | + { |
|
134 | 144 | case 'comment': |
135 | 145 | $view = 'comment'; |
136 | 146 | break; |
@@ -150,7 +160,8 @@ discard block |
||
150 | 160 | } |
151 | 161 | |
152 | 162 | //Get Post Details |
153 | - if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { |
|
163 | + if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
164 | + { |
|
154 | 165 | //Header Nav in Comment View |
155 | 166 | ?> |
156 | 167 | <a id="comment-back" href="index.php?view=<?php echo $view;?>#postId-<?php echo htmlspecialchars($_GET['postID']);?>"> |
@@ -168,13 +179,17 @@ discard block |
||
168 | 179 | $data = $accountCreator->execute(); |
169 | 180 | |
170 | 181 | $posts[0] = $data; |
171 | - if(isset($data['children'])) { |
|
172 | - foreach($data['children'] as $child) { |
|
182 | + if(isset($data['children'])) |
|
183 | + { |
|
184 | + foreach($data['children'] as $child) |
|
185 | + { |
|
173 | 186 | array_push($posts, $child); |
174 | 187 | } |
175 | 188 | $loops = $data['child_count'] + 1; |
176 | 189 | } |
177 | - else $loops = 1; |
|
190 | + else { |
|
191 | + $loops = 1; |
|
192 | + } |
|
178 | 193 | $showCommentIcon = FALSE; |
179 | 194 | } |
180 | 195 | //Get Posts |
@@ -202,9 +217,11 @@ discard block |
||
202 | 217 | } |
203 | 218 | |
204 | 219 | |
205 | - for($i = 0; $i<$loops; $i++) { |
|
220 | + for($i = 0; $i<$loops; $i++) |
|
221 | + { |
|
206 | 222 | |
207 | - if(isset($posts[$i])) { |
|
223 | + if(isset($posts[$i])) |
|
224 | + { |
|
208 | 225 | $lastPostId = $posts[$i]['post_id']; |
209 | 226 | |
210 | 227 | |
@@ -220,7 +237,8 @@ discard block |
||
220 | 237 | $timediff_inHours = (string)$timediff->format('%h'); |
221 | 238 | $timediff_inDays = (string)$timediff->format('%d'); |
222 | 239 | $timediff_inMonth = (string)$timediff->format('%m'); |
223 | - if($timediff_inMonth!=0) { |
|
240 | + if($timediff_inMonth!=0) |
|
241 | + { |
|
224 | 242 | $timediff = $timediff_inMonth . "m"; |
225 | 243 | } |
226 | 244 | else |
@@ -253,10 +271,12 @@ discard block |
||
253 | 271 | <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
254 | 272 | <content> |
255 | 273 | <?php |
256 | - if(isset($posts[$i]["image_url"])) { |
|
274 | + if(isset($posts[$i]["image_url"])) |
|
275 | + { |
|
257 | 276 | echo '<img src="' . $posts[$i]["image_url"] . '">'; |
258 | 277 | } |
259 | - else { |
|
278 | + else |
|
279 | + { |
|
260 | 280 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($posts[$i]["message"]))); |
261 | 281 | } |
262 | 282 | ?> |
@@ -282,13 +302,19 @@ discard block |
||
282 | 302 | </span> |
283 | 303 | </td> |
284 | 304 | <td class="comments"> |
285 | - <?php if($showCommentIcon) {?> |
|
305 | + <?php if($showCommentIcon) |
|
306 | +{ |
|
307 | +?> |
|
286 | 308 | <span data-tooltip="Comments"> |
287 | 309 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $posts[$i]["post_id"];?>"> |
288 | 310 | <i class="fa fa-commenting-o"></i> |
289 | - <?php if(array_key_exists("child_count", $posts[$i])) { |
|
311 | + <?php if(array_key_exists("child_count", $posts[$i])) |
|
312 | +{ |
|
290 | 313 | echo $posts[$i]["child_count"]; |
291 | - } else echo "0"; |
|
314 | + } |
|
315 | + else { |
|
316 | + echo "0"; |
|
317 | + } |
|
292 | 318 | ?> |
293 | 319 | </a> |
294 | 320 | </span> |
@@ -312,7 +338,9 @@ discard block |
||
312 | 338 | |
313 | 339 | </content> |
314 | 340 | |
315 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
341 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
342 | +{ |
|
343 | +?> |
|
316 | 344 | <p id="loading"> |
317 | 345 | Loading… |
318 | 346 | </p> |
@@ -323,7 +351,14 @@ discard block |
||
323 | 351 | <article> |
324 | 352 | <h2>Position</h2> |
325 | 353 | <form method="get"> |
326 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; else echo htmlspecialchars($posts[0]["location"]["name"]); ?>" required> |
|
354 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
355 | +{ |
|
356 | + echo $newPositionStatus; |
|
357 | +} |
|
358 | +else { |
|
359 | + echo htmlspecialchars($posts[0]["location"]["name"]); |
|
360 | +} |
|
361 | +?>" required> |
|
327 | 362 | |
328 | 363 | <input type="submit" value="Set Location" /> |
329 | 364 | </form> |
@@ -336,7 +371,9 @@ discard block |
||
336 | 371 | </article> |
337 | 372 | |
338 | 373 | <article> |
339 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
374 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
375 | +{ |
|
376 | +?> |
|
340 | 377 | <h2>Comment on Jodel</h2> |
341 | 378 | <form method="POST"> |
342 | 379 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
@@ -344,7 +381,10 @@ discard block |
||
344 | 381 | <br /> |
345 | 382 | <input type="submit" value="SEND" /> |
346 | 383 | </form> |
347 | - <?php } else { ?> |
|
384 | + <?php } |
|
385 | +else |
|
386 | +{ |
|
387 | +?> |
|
348 | 388 | <h2>New Jodel</h2> |
349 | 389 | <form method="POST"> |
350 | 390 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -364,13 +404,25 @@ discard block |
||
364 | 404 | <div class="col-sm-12"> |
365 | 405 | <div class="row"> |
366 | 406 | <div class="col-sm-3"> |
367 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
407 | + <a href="index.php" <?php if($view=='time') |
|
408 | +{ |
|
409 | + echo 'class="active"'; |
|
410 | +} |
|
411 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
368 | 412 | </div> |
369 | 413 | <div class="col-sm-3"> |
370 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
414 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
415 | +{ |
|
416 | + echo 'class="active"'; |
|
417 | +} |
|
418 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
371 | 419 | </div> |
372 | 420 | <div class="col-sm-3"> |
373 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
421 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
422 | +{ |
|
423 | + echo 'class="active"'; |
|
424 | +} |
|
425 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
374 | 426 | </div> |
375 | 427 | <div class="col-sm-3"> |
376 | 428 | <nav> |
@@ -394,7 +446,9 @@ discard block |
||
394 | 446 | $(this).addClass('selected'); |
395 | 447 | }); |
396 | 448 | |
397 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
449 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
450 | +{ |
|
451 | +?> |
|
398 | 452 | $(document).ready(function() { |
399 | 453 | var win = $(window); |
400 | 454 | var lastPostId = "<?php echo $lastPostId; ?>"; |
@@ -17,18 +17,22 @@ discard block |
||
17 | 17 | require_once 'php/Requests/libary/Requests.php'; |
18 | 18 | Requests::register_autoloader(); |
19 | 19 | |
20 | -function getPosts($lastPostId, $url) { |
|
20 | +function getPosts($lastPostId, $url) |
|
21 | +{ |
|
21 | 22 | $db = new DatabaseConnect(); |
22 | - if ($db->connect_errno) { |
|
23 | + if ($db->connect_errno) |
|
24 | + { |
|
23 | 25 | echo 'Sorry, die Verbindung zu unserem superfetten endgeilen |
24 | 26 | Server ist hops gegangen. Wegen '. $db -> connect_error; |
25 | 27 | } |
26 | 28 | |
27 | 29 | $result = $db->query("SELECT * FROM accounts WHERE id='1'"); |
28 | 30 | |
29 | - if ($result->num_rows > 0) { |
|
31 | + if ($result->num_rows > 0) |
|
32 | + { |
|
30 | 33 | // output data of each row |
31 | - while($row = $result->fetch_assoc()) { |
|
34 | + while($row = $result->fetch_assoc()) |
|
35 | + { |
|
32 | 36 | $access_token = $row["access_token"]; |
33 | 37 | } |
34 | 38 | } |
@@ -49,7 +53,8 @@ discard block |
||
49 | 53 | |
50 | 54 | if(isset($_GET['view'])) |
51 | 55 | { |
52 | - switch ($_GET['view']) { |
|
56 | + switch ($_GET['view']) |
|
57 | + { |
|
53 | 58 | case 'comment': |
54 | 59 | $view = 'comment'; |
55 | 60 | break; |
@@ -84,7 +89,8 @@ discard block |
||
84 | 89 | } |
85 | 90 | } |
86 | 91 | |
87 | - if(isset($_GET['lastPostId'])) { |
|
92 | + if(isset($_GET['lastPostId'])) |
|
93 | + { |
|
88 | 94 | |
89 | 95 | $lastPostId = htmlspecialchars($_GET['lastPostId']); |
90 | 96 | |
@@ -94,9 +100,11 @@ discard block |
||
94 | 100 | ?> |
95 | 101 | <div class="nextPosts"> |
96 | 102 | <?php |
97 | - for($i = 0; $i<$loops; $i++) { |
|
103 | + for($i = 0; $i<$loops; $i++) |
|
104 | + { |
|
98 | 105 | |
99 | - if(isset($posts[$i])) { |
|
106 | + if(isset($posts[$i])) |
|
107 | + { |
|
100 | 108 | $lastPostId = $posts[$i]['post_id']; |
101 | 109 | |
102 | 110 | |
@@ -112,7 +120,8 @@ discard block |
||
112 | 120 | $timediff_inHours = (string)$timediff->format('%h'); |
113 | 121 | $timediff_inDays = (string)$timediff->format('%d'); |
114 | 122 | $timediff_inMonth = (string)$timediff->format('%m'); |
115 | - if($timediff_inMonth!=0) { |
|
123 | + if($timediff_inMonth!=0) |
|
124 | + { |
|
116 | 125 | $timediff = $timediff_inMonth . "m"; |
117 | 126 | } |
118 | 127 | else |
@@ -145,10 +154,12 @@ discard block |
||
145 | 154 | <article class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
146 | 155 | <content> |
147 | 156 | <?php |
148 | - if(isset($posts[$i]["image_url"])) { |
|
157 | + if(isset($posts[$i]["image_url"])) |
|
158 | + { |
|
149 | 159 | echo '<img src="' . $posts[$i]["image_url"] . '">'; |
150 | 160 | } |
151 | - else { |
|
161 | + else |
|
162 | + { |
|
152 | 163 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($posts[$i]["message"]))); |
153 | 164 | } |
154 | 165 | ?> |
@@ -174,13 +185,19 @@ discard block |
||
174 | 185 | </span> |
175 | 186 | </td> |
176 | 187 | <td class="comments"> |
177 | - <?php if($showCommentIcon) {?> |
|
188 | + <?php if($showCommentIcon) |
|
189 | +{ |
|
190 | +?> |
|
178 | 191 | <span data-tooltip="Comments"> |
179 | 192 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $posts[$i]["post_id"];?>"> |
180 | 193 | <i class="fa fa-commenting-o"></i> |
181 | - <?php if(array_key_exists("child_count", $posts[$i])) { |
|
194 | + <?php if(array_key_exists("child_count", $posts[$i])) |
|
195 | +{ |
|
182 | 196 | echo $posts[$i]["child_count"]; |
183 | - } else echo "0"; |
|
197 | + } |
|
198 | + else { |
|
199 | + echo "0"; |
|
200 | + } |
|
184 | 201 | ?> |
185 | 202 | </a> |
186 | 203 | </span> |