@@ -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> |
@@ -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_forId1); |
@@ -116,7 +121,8 @@ discard block |
||
116 | 121 | |
117 | 122 | |
118 | 123 | //SendJodel |
119 | - if(isset($_POST['message'])) { |
|
124 | + if(isset($_POST['message'])) |
|
125 | + { |
|
120 | 126 | $accountCreator = new SendJodel(); |
121 | 127 | |
122 | 128 | if(isset($_POST['ancestor'])) |
@@ -127,7 +133,8 @@ discard block |
||
127 | 133 | if(isset($_POST['color'])) |
128 | 134 | { |
129 | 135 | $color = $_POST['color']; |
130 | - switch ($color) { |
|
136 | + switch ($color) |
|
137 | + { |
|
131 | 138 | case '8ABDB0': |
132 | 139 | $color = '8ABDB0'; |
133 | 140 | break; |
@@ -273,7 +280,8 @@ discard block |
||
273 | 280 | $data = $accountCreator->execute(); |
274 | 281 | |
275 | 282 | $posts[0] = $data; |
276 | - if(array_key_exists('children', $data)) { |
|
283 | + if(array_key_exists('children', $data)) |
|
284 | + { |
|
277 | 285 | foreach($data['children'] as $key => $child) |
278 | 286 | { |
279 | 287 | |
@@ -348,7 +356,9 @@ discard block |
||
348 | 356 | |
349 | 357 | </content> |
350 | 358 | |
351 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
359 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
360 | +{ |
|
361 | +?> |
|
352 | 362 | <p id="loading"> |
353 | 363 | Loading… |
354 | 364 | </p> |
@@ -361,7 +371,11 @@ discard block |
||
361 | 371 | <div> |
362 | 372 | <h2>Position</h2> |
363 | 373 | <form method="get"> |
364 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
374 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
375 | +{ |
|
376 | + echo $newPositionStatus; |
|
377 | +} |
|
378 | +?>" required> |
|
365 | 379 | |
366 | 380 | <input type="submit" value="Set Location" /> |
367 | 381 | </form> |
@@ -377,7 +391,9 @@ discard block |
||
377 | 391 | |
378 | 392 | <article> |
379 | 393 | <div> |
380 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
394 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
395 | +{ |
|
396 | +?> |
|
381 | 397 | <h2>Comment on Jodel</h2> |
382 | 398 | <form method="POST"> |
383 | 399 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
@@ -385,7 +401,10 @@ discard block |
||
385 | 401 | <br /> |
386 | 402 | <input type="submit" value="SEND" /> |
387 | 403 | </form> |
388 | - <?php } else { ?> |
|
404 | + <?php } |
|
405 | +else |
|
406 | +{ |
|
407 | +?> |
|
389 | 408 | <h2>New Jodel</h2> |
390 | 409 | <form method="POST"> |
391 | 410 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -417,13 +436,25 @@ discard block |
||
417 | 436 | <div class="col-sm-12"> |
418 | 437 | <div class="row"> |
419 | 438 | <div class="col-sm-3"> |
420 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
439 | + <a href="index.php" <?php if($view=='time') |
|
440 | +{ |
|
441 | + echo 'class="active"'; |
|
442 | +} |
|
443 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
421 | 444 | </div> |
422 | 445 | <div class="col-sm-3"> |
423 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
446 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
447 | +{ |
|
448 | + echo 'class="active"'; |
|
449 | +} |
|
450 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
424 | 451 | </div> |
425 | 452 | <div class="col-sm-3"> |
426 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
453 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
454 | +{ |
|
455 | + echo 'class="active"'; |
|
456 | +} |
|
457 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
427 | 458 | </div> |
428 | 459 | <div class="col-sm-3"> |
429 | 460 | <nav> |
@@ -466,7 +497,9 @@ discard block |
||
466 | 497 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
467 | 498 | } |
468 | 499 | |
469 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
500 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
501 | +{ |
|
502 | +?> |
|
470 | 503 | |
471 | 504 | |
472 | 505 |