@@ -35,7 +35,8 @@ discard block |
||
35 | 35 | //Set View |
36 | 36 | if(isset($_GET['view'])) |
37 | 37 | { |
38 | - switch ($_GET['view']) { |
|
38 | + switch ($_GET['view']) |
|
39 | + { |
|
39 | 40 | case 'comment': |
40 | 41 | $view = 'comment'; |
41 | 42 | break; |
@@ -55,7 +56,8 @@ discard block |
||
55 | 56 | } |
56 | 57 | |
57 | 58 | //Set Location |
58 | - if(isset($_GET['city'])) { |
|
59 | + if(isset($_GET['city'])) |
|
60 | + { |
|
59 | 61 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
60 | 62 | $result = Requests::post($url); |
61 | 63 | if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
@@ -99,11 +101,14 @@ discard block |
||
99 | 101 | } |
100 | 102 | |
101 | 103 | //Vote |
102 | - if(isset($_GET['vote']) && isset($_GET['postID'])) { |
|
103 | - if($_GET['vote'] == "up") { |
|
104 | + if(isset($_GET['vote']) && isset($_GET['postID'])) |
|
105 | + { |
|
106 | + if($_GET['vote'] == "up") |
|
107 | + { |
|
104 | 108 | $accountCreator = new Upvote(); |
105 | 109 | } |
106 | - else if($_GET['vote'] == "down") { |
|
110 | + else if($_GET['vote'] == "down") |
|
111 | + { |
|
107 | 112 | $accountCreator = new Downvote(); |
108 | 113 | } |
109 | 114 | $accountCreator->setAccessToken($accessToken); |
@@ -115,7 +120,8 @@ discard block |
||
115 | 120 | |
116 | 121 | |
117 | 122 | //SendJodel |
118 | - if(isset($_POST['message'])) { |
|
123 | + if(isset($_POST['message'])) |
|
124 | + { |
|
119 | 125 | $accountCreator = new SendJodel(); |
120 | 126 | |
121 | 127 | if(isset($_POST['ancestor'])) |
@@ -126,7 +132,8 @@ discard block |
||
126 | 132 | if(isset($_POST['color'])) |
127 | 133 | { |
128 | 134 | $color = $_POST['color']; |
129 | - switch ($color) { |
|
135 | + switch ($color) |
|
136 | + { |
|
130 | 137 | case '8ABDB0': |
131 | 138 | $color = '8ABDB0'; |
132 | 139 | break; |
@@ -228,7 +235,8 @@ discard block |
||
228 | 235 | $data = $accountCreator->execute(); |
229 | 236 | |
230 | 237 | $posts[0] = $data; |
231 | - if(isset($data['children'])) { |
|
238 | + if(isset($data['children'])) |
|
239 | + { |
|
232 | 240 | foreach($data['children'] as $key => $child) |
233 | 241 | { |
234 | 242 | |
@@ -250,7 +258,9 @@ discard block |
||
250 | 258 | } |
251 | 259 | $loops = $data['child_count'] + 1; |
252 | 260 | } |
253 | - else $loops = 1; |
|
261 | + else { |
|
262 | + $loops = 1; |
|
263 | + } |
|
254 | 264 | $isDetailedView = TRUE; |
255 | 265 | } |
256 | 266 | //Get Posts |
@@ -291,7 +301,9 @@ discard block |
||
291 | 301 | |
292 | 302 | </content> |
293 | 303 | |
294 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
304 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
305 | +{ |
|
306 | +?> |
|
295 | 307 | <p id="loading"> |
296 | 308 | Loading… |
297 | 309 | </p> |
@@ -304,7 +316,11 @@ discard block |
||
304 | 316 | <div> |
305 | 317 | <h2>Position</h2> |
306 | 318 | <form method="get"> |
307 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
319 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
320 | +{ |
|
321 | + echo $newPositionStatus; |
|
322 | +} |
|
323 | +?>" required> |
|
308 | 324 | |
309 | 325 | <input type="submit" value="Set Location" /> |
310 | 326 | </form> |
@@ -320,7 +336,9 @@ discard block |
||
320 | 336 | |
321 | 337 | <article> |
322 | 338 | <div> |
323 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
339 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
340 | +{ |
|
341 | +?> |
|
324 | 342 | <h2>Comment on Jodel</h2> |
325 | 343 | <form method="POST"> |
326 | 344 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
@@ -328,7 +346,10 @@ discard block |
||
328 | 346 | <br /> |
329 | 347 | <input type="submit" value="SEND" /> |
330 | 348 | </form> |
331 | - <?php } else { ?> |
|
349 | + <?php } |
|
350 | +else |
|
351 | +{ |
|
352 | +?> |
|
332 | 353 | <h2>New Jodel</h2> |
333 | 354 | <form method="POST"> |
334 | 355 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -360,13 +381,25 @@ discard block |
||
360 | 381 | <div class="col-sm-12"> |
361 | 382 | <div class="row"> |
362 | 383 | <div class="col-sm-3"> |
363 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
384 | + <a href="index.php" <?php if($view=='time') |
|
385 | +{ |
|
386 | + echo 'class="active"'; |
|
387 | +} |
|
388 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
364 | 389 | </div> |
365 | 390 | <div class="col-sm-3"> |
366 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
391 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
392 | +{ |
|
393 | + echo 'class="active"'; |
|
394 | +} |
|
395 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
367 | 396 | </div> |
368 | 397 | <div class="col-sm-3"> |
369 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
398 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
399 | +{ |
|
400 | + echo 'class="active"'; |
|
401 | +} |
|
402 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
370 | 403 | </div> |
371 | 404 | <div class="col-sm-3"> |
372 | 405 | <nav> |
@@ -401,7 +434,9 @@ discard block |
||
401 | 434 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
402 | 435 | } |
403 | 436 | |
404 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
437 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
438 | +{ |
|
439 | +?> |
|
405 | 440 | |
406 | 441 | |
407 | 442 |
@@ -32,10 +32,12 @@ |
||
32 | 32 | |
33 | 33 | isTokenFreshByAccessToken($location, $accessToken); |
34 | 34 | |
35 | - if($_POST['vote'] == "up") { |
|
35 | + if($_POST['vote'] == "up") |
|
36 | + { |
|
36 | 37 | $accountCreator = new Upvote(); |
37 | 38 | } |
38 | - else if($_POST['vote'] == "down") { |
|
39 | + else if($_POST['vote'] == "down") |
|
40 | + { |
|
39 | 41 | $accountCreator = new Downvote(); |
40 | 42 | } |
41 | 43 |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | if ($result->num_rows > 0) |
29 | 29 | { |
30 | 30 | // output data of each row |
31 | - while($row = $result->fetch_assoc()) { |
|
31 | + while($row = $result->fetch_assoc()) |
|
32 | + { |
|
32 | 33 | //$access_token = $row["access_token"]; |
33 | 34 | $expiration_date = $row["expiration_date"]; |
34 | 35 | $deviceUid = $row["device_uid"]; |
@@ -40,7 +41,8 @@ discard block |
||
40 | 41 | echo '0 results'; |
41 | 42 | } |
42 | 43 | |
43 | - if($expiration_date <= time()) { |
|
44 | + if($expiration_date <= time()) |
|
45 | + { |
|
44 | 46 | $accountCreator = new CreateUser(); |
45 | 47 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
46 | 48 | $accountCreator->setDeviceUid($deviceUid); |
@@ -57,7 +59,8 @@ discard block |
||
57 | 59 | expiration_date='" . $expiration_date . "' |
58 | 60 | WHERE device_uid='" . $device_uid . "'"); |
59 | 61 | |
60 | - if($result === false){ |
|
62 | + if($result === false) |
|
63 | + { |
|
61 | 64 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
62 | 65 | } |
63 | 66 | } |
@@ -73,7 +76,8 @@ discard block |
||
73 | 76 | if ($result->num_rows > 0) |
74 | 77 | { |
75 | 78 | // output data of each row |
76 | - while($row = $result->fetch_assoc()) { |
|
79 | + while($row = $result->fetch_assoc()) |
|
80 | + { |
|
77 | 81 | //$access_token = $row["access_token"]; |
78 | 82 | $expiration_date = $row["expiration_date"]; |
79 | 83 | $deviceUid = $row["device_uid"]; |
@@ -85,7 +89,8 @@ discard block |
||
85 | 89 | echo '0 results'; |
86 | 90 | } |
87 | 91 | |
88 | - if($expiration_date <= time()) { |
|
92 | + if($expiration_date <= time()) |
|
93 | + { |
|
89 | 94 | $accountCreator = new CreateUser(); |
90 | 95 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
91 | 96 | $accountCreator->setDeviceUid($deviceUid); |
@@ -102,7 +107,8 @@ discard block |
||
102 | 107 | expiration_date='" . $expiration_date . "' |
103 | 108 | WHERE device_uid='" . $device_uid . "'"); |
104 | 109 | |
105 | - if($result === false){ |
|
110 | + if($result === false) |
|
111 | + { |
|
106 | 112 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
107 | 113 | } |
108 | 114 | } |
@@ -120,7 +126,8 @@ discard block |
||
120 | 126 | if ($result->num_rows > 0) |
121 | 127 | { |
122 | 128 | // output data of each row |
123 | - while($row = $result->fetch_assoc()) { |
|
129 | + while($row = $result->fetch_assoc()) |
|
130 | + { |
|
124 | 131 | //$access_token = $row["access_token"]; |
125 | 132 | $expiration_date = $row["expiration_date"]; |
126 | 133 | $deviceUid = $row["device_uid"]; |
@@ -132,7 +139,8 @@ discard block |
||
132 | 139 | echo '0 results'; |
133 | 140 | } |
134 | 141 | |
135 | - if($expiration_date <= time()) { |
|
142 | + if($expiration_date <= time()) |
|
143 | + { |
|
136 | 144 | $accountCreator = new CreateUser(); |
137 | 145 | $accountCreator->setAccessToken($access_token); |
138 | 146 | $accountCreator->setDeviceUid($deviceUid); |
@@ -149,7 +157,8 @@ discard block |
||
149 | 157 | expiration_date='" . $expiration_date . "' |
150 | 158 | WHERE device_uid='" . $device_uid . "'"); |
151 | 159 | |
152 | - if($result === false){ |
|
160 | + if($result === false) |
|
161 | + { |
|
153 | 162 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
154 | 163 | } |
155 | 164 | } |
@@ -240,7 +249,8 @@ discard block |
||
240 | 249 | return $data["karma"]; |
241 | 250 | } |
242 | 251 | |
243 | -function registerAccount(Location $location) { |
|
252 | +function registerAccount(Location $location) |
|
253 | +{ |
|
244 | 254 | $accountCreator = new CreateUser(); |
245 | 255 | $accountCreator->setLocation($location); |
246 | 256 | $data = $accountCreator->execute(); |
@@ -265,7 +275,8 @@ discard block |
||
265 | 275 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
266 | 276 | |
267 | 277 | $success = TRUE; |
268 | - if($result === false){ |
|
278 | + if($result === false) |
|
279 | + { |
|
269 | 280 | $error = db_error(); |
270 | 281 | echo $error; |
271 | 282 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -276,7 +287,7 @@ discard block |
||
276 | 287 | } |
277 | 288 | |
278 | 289 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
279 | -{ |
|
290 | +{ |
|
280 | 291 | $accountCreator = new GetPosts(); |
281 | 292 | $accountCreator->setLastPostId($lastPostId); |
282 | 293 | $accountCreator->setAccessToken($accessToken); |
@@ -306,7 +317,8 @@ discard block |
||
306 | 317 | } |
307 | 318 | |
308 | 319 | function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE) |
309 | -{ //ToDO |
|
320 | +{ |
|
321 | +//ToDO |
|
310 | 322 | //Replace # with link |
311 | 323 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
312 | 324 | |
@@ -356,10 +368,12 @@ discard block |
||
356 | 368 | <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;"> |
357 | 369 | <content> |
358 | 370 | <?php |
359 | - if(isset($post["image_url"])) { |
|
371 | + if(isset($post["image_url"])) |
|
372 | + { |
|
360 | 373 | echo '<img src="' . $post["image_url"] . '">'; |
361 | 374 | } |
362 | - else { |
|
375 | + else |
|
376 | + { |
|
363 | 377 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post["message"]))); |
364 | 378 | } |
365 | 379 | ?> |
@@ -386,13 +400,19 @@ discard block |
||
386 | 400 | </span> |
387 | 401 | </td> |
388 | 402 | <td class="comments"> |
389 | - <?php if(!$isDetailedView) {?> |
|
403 | + <?php if(!$isDetailedView) |
|
404 | +{ |
|
405 | +?> |
|
390 | 406 | <span data-tooltip="Comments"> |
391 | 407 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
392 | 408 | <i class="fa fa-commenting-o"></i> |
393 | - <?php if(array_key_exists("child_count", $post)) { |
|
409 | + <?php if(array_key_exists("child_count", $post)) |
|
410 | +{ |
|
394 | 411 | echo $post["child_count"]; |
395 | - } else echo "0"; |
|
412 | + } |
|
413 | + else { |
|
414 | + echo "0"; |
|
415 | + } |
|
396 | 416 | ?> |
397 | 417 | </a> |
398 | 418 | </span> |