@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | if(isset($_GET['city'])) { |
36 | 36 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
37 | 37 | $result = Requests::post($url); |
38 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
38 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
39 | 39 | { |
40 | 40 | $newPositionStatus = "0 results"; |
41 | 41 | } |
42 | 42 | else |
43 | 43 | { |
44 | - $name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name']; |
|
45 | - $lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat']; |
|
46 | - $lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng']; |
|
44 | + $name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name']; |
|
45 | + $lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']; |
|
46 | + $lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']; |
|
47 | 47 | |
48 | 48 | $location = new Location(); |
49 | 49 | $location->setLat($lat); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | lng='" . $lng . "' |
64 | 64 | WHERE id='1'"); |
65 | 65 | |
66 | - if($result === false) |
|
66 | + if($result === FALSE) |
|
67 | 67 | { |
68 | 68 | echo "Updating location failed: (" . $db->errno . ") " . $db->error; |
69 | 69 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $accessToken; |
15 | 15 | $newPositionStatus; |
16 | 16 | |
17 | - if ($result->num_rows > 0) |
|
17 | + if($result->num_rows > 0) |
|
18 | 18 | { |
19 | 19 | // output data of each row |
20 | 20 | while($row = $result->fetch_assoc()) |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | //Set View |
36 | 36 | if(isset($_GET['view'])) |
37 | 37 | { |
38 | - switch ($_GET['view']) { |
|
38 | + switch($_GET['view']) { |
|
39 | 39 | case 'comment': |
40 | 40 | $view = 'comment'; |
41 | 41 | break; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | if(isset($_POST['color'])) |
127 | 127 | { |
128 | 128 | $color = $_POST['color']; |
129 | - switch ($color) { |
|
129 | + switch($color) { |
|
130 | 130 | case '8ABDB0': |
131 | 131 | $color = '8ABDB0'; |
132 | 132 | break; |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | //Get Posts |
257 | 257 | else |
258 | 258 | { |
259 | - if($view=='comment') |
|
259 | + if($view == 'comment') |
|
260 | 260 | { |
261 | 261 | $url = "/v2/posts/location/discussed/"; |
262 | 262 | } |
263 | 263 | else |
264 | 264 | { |
265 | - if($view=='upVote') |
|
265 | + if($view == 'upVote') |
|
266 | 266 | { |
267 | 267 | $url = "/v2/posts/location/popular/"; |
268 | 268 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | |
281 | - for($i = 0; $i<$loops; $i++) |
|
281 | + for($i = 0; $i < $loops; $i++) |
|
282 | 282 | { |
283 | 283 | |
284 | 284 | if(isset($posts[$i])) |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
324 | 324 | <h2>Comment on Jodel</h2> |
325 | 325 | <form method="POST"> |
326 | - <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
|
326 | + <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" /> |
|
327 | 327 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
328 | 328 | <br /> |
329 | 329 | <input type="submit" value="SEND" /> |
@@ -360,13 +360,13 @@ discard block |
||
360 | 360 | <div class="col-sm-12"> |
361 | 361 | <div class="row"> |
362 | 362 | <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> |
|
363 | + <a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
364 | 364 | </div> |
365 | 365 | <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> |
|
366 | + <a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
367 | 367 | </div> |
368 | 368 | <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> |
|
369 | + <a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
370 | 370 | </div> |
371 | 371 | <div class="col-sm-3"> |
372 | 372 | <nav> |
@@ -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 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | error_reporting(-1); |
3 | 3 | |
4 | -include 'php/jodel-web.php';/* |
|
4 | +include 'php/jodel-web.php'; /* |
|
5 | 5 | include 'php/DatabaseConnect.php'; |
6 | 6 | include 'php/Requests/AbstractRequest.php'; |
7 | 7 | include 'php/Requests/CreateUser.php'; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $accessToken; |
30 | 30 | $newPositionStatus; |
31 | 31 | |
32 | -if ($result->num_rows > 0) |
|
32 | +if($result->num_rows > 0) |
|
33 | 33 | { |
34 | 34 | // output data of each row |
35 | 35 | while($row = $result->fetch_assoc()) |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | if(isset($_GET['view'])) |
47 | 47 | { |
48 | - switch ($_GET['view']) { |
|
48 | + switch($_GET['view']) { |
|
49 | 49 | case 'comment': |
50 | 50 | $view = 'comment'; |
51 | 51 | break; |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | $view = 'time'; |
65 | 65 | } |
66 | 66 | |
67 | - if($view=='comment') |
|
67 | + if($view == 'comment') |
|
68 | 68 | { |
69 | 69 | $url = "/v2/posts/location/discussed/"; |
70 | 70 | } |
71 | 71 | else |
72 | 72 | { |
73 | - if($view=='upVote') |
|
73 | + if($view == 'upVote') |
|
74 | 74 | { |
75 | 75 | $url = "/v2/posts/location/popular/"; |
76 | 76 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ?> |
91 | 91 | <div class="nextPosts"> |
92 | 92 | <?php |
93 | - for($i = 0; $i<$loops; $i++) |
|
93 | + for($i = 0; $i < $loops; $i++) |
|
94 | 94 | { |
95 | 95 | if(isset($posts[$i])) |
96 | 96 | { |
@@ -45,7 +45,8 @@ |
||
45 | 45 | |
46 | 46 | if(isset($_GET['view'])) |
47 | 47 | { |
48 | - switch ($_GET['view']) { |
|
48 | + switch ($_GET['view']) |
|
49 | + { |
|
49 | 50 | case 'comment': |
50 | 51 | $view = 'comment'; |
51 | 52 | break; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $i = 0; |
22 | 22 | $result = $db->query("SELECT access_token FROM accounts"); |
23 | 23 | |
24 | - if ($result->num_rows > 0) |
|
24 | + if($result->num_rows > 0) |
|
25 | 25 | { |
26 | 26 | // output data of each row |
27 | 27 | while(($row = $result->fetch_assoc()) && $i < $_POST['quantity']) |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
171 | 171 | <h2>Comment on Jodel</h2> |
172 | 172 | <form method="POST"> |
173 | - <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
|
173 | + <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" /> |
|
174 | 174 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
175 | 175 | <br /> |
176 | 176 | <input type="submit" value="SEND" /> |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | <div class="col-sm-12"> |
208 | 208 | <div class="row"> |
209 | 209 | <div class="col-sm-3"> |
210 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
210 | + <a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
211 | 211 | </div> |
212 | 212 | <div class="col-sm-3"> |
213 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
213 | + <a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
214 | 214 | </div> |
215 | 215 | <div class="col-sm-3"> |
216 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
216 | + <a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
217 | 217 | </div> |
218 | 218 | <div class="col-sm-3"> |
219 | 219 | <nav> |
@@ -30,10 +30,12 @@ discard block |
||
30 | 30 | var_dump($accessToken); |
31 | 31 | isTokenFreshByAccessToken($location, $accessToken); |
32 | 32 | |
33 | - if($_POST['vote'] == "up") { |
|
33 | + if($_POST['vote'] == "up") |
|
34 | + { |
|
34 | 35 | $accountCreator = new Upvote(); |
35 | 36 | } |
36 | - else if($_POST['vote'] == "down") { |
|
37 | + else if($_POST['vote'] == "down") |
|
38 | + { |
|
37 | 39 | $accountCreator = new Downvote(); |
38 | 40 | } |
39 | 41 | |
@@ -151,7 +153,11 @@ discard block |
||
151 | 153 | <div> |
152 | 154 | <h2>Position</h2> |
153 | 155 | <form method="get"> |
154 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
156 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
157 | +{ |
|
158 | + echo $newPositionStatus; |
|
159 | +} |
|
160 | +?>" required> |
|
155 | 161 | |
156 | 162 | <input type="submit" value="Set Location" /> |
157 | 163 | </form> |
@@ -167,7 +173,9 @@ discard block |
||
167 | 173 | |
168 | 174 | <article> |
169 | 175 | <div> |
170 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
176 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
177 | +{ |
|
178 | +?> |
|
171 | 179 | <h2>Comment on Jodel</h2> |
172 | 180 | <form method="POST"> |
173 | 181 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
@@ -175,7 +183,10 @@ discard block |
||
175 | 183 | <br /> |
176 | 184 | <input type="submit" value="SEND" /> |
177 | 185 | </form> |
178 | - <?php } else { ?> |
|
186 | + <?php } |
|
187 | +else |
|
188 | +{ |
|
189 | +?> |
|
179 | 190 | <h2>New Jodel</h2> |
180 | 191 | <form method="POST"> |
181 | 192 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -207,13 +218,25 @@ discard block |
||
207 | 218 | <div class="col-sm-12"> |
208 | 219 | <div class="row"> |
209 | 220 | <div class="col-sm-3"> |
210 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
221 | + <a href="index.php" <?php if($view=='time') |
|
222 | +{ |
|
223 | + echo 'class="active"'; |
|
224 | +} |
|
225 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
211 | 226 | </div> |
212 | 227 | <div class="col-sm-3"> |
213 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
228 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
229 | +{ |
|
230 | + echo 'class="active"'; |
|
231 | +} |
|
232 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
214 | 233 | </div> |
215 | 234 | <div class="col-sm-3"> |
216 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
235 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
236 | +{ |
|
237 | + echo 'class="active"'; |
|
238 | +} |
|
239 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
217 | 240 | </div> |
218 | 241 | <div class="col-sm-3"> |
219 | 242 | <nav> |
@@ -256,7 +279,9 @@ discard block |
||
256 | 279 | $('html,body').animate({scrollTop: aTag.offset().top-90},'slow'); |
257 | 280 | } |
258 | 281 | |
259 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
282 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
283 | +{ |
|
284 | +?> |
|
260 | 285 | |
261 | 286 | |
262 | 287 |
@@ -1,20 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | class Downvote extends AbstractRequest |
3 | 3 | { |
4 | - public $postId; |
|
4 | + public $postId; |
|
5 | 5 | |
6 | - function getApiEndPoint() |
|
7 | - { |
|
8 | - return '/v2/posts/' . $this->postId . '/downvote'; |
|
9 | - } |
|
10 | - function getPayload() |
|
11 | - { |
|
12 | - return array( |
|
13 | - ); |
|
14 | - } |
|
15 | - function getMethod() |
|
16 | - { |
|
17 | - return 'PUT'; |
|
18 | - } |
|
6 | + function getApiEndPoint() |
|
7 | + { |
|
8 | + return '/v2/posts/' . $this->postId . '/downvote'; |
|
9 | + } |
|
10 | + function getPayload() |
|
11 | + { |
|
12 | + return array( |
|
13 | + ); |
|
14 | + } |
|
15 | + function getMethod() |
|
16 | + { |
|
17 | + return 'PUT'; |
|
18 | + } |
|
19 | 19 | } |
20 | 20 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $db = new DatabaseConnect(); |
24 | 24 | $result = $db->query("SELECT * FROM accounts WHERE id='1'"); |
25 | 25 | |
26 | - if ($result->num_rows > 0) |
|
26 | + if($result->num_rows > 0) |
|
27 | 27 | { |
28 | 28 | // output data of each row |
29 | 29 | while($row = $result->fetch_assoc()) { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | if($expiration_date <= time()) { |
42 | 42 | $accountCreator = new CreateUser(); |
43 | - $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
|
43 | + $accountCreator->setAccessToken($access_token); //$accountData->getAccessToken()); |
|
44 | 44 | $accountCreator->setDeviceUid($deviceUid); |
45 | 45 | $accountCreator->setLocation($location); |
46 | 46 | $data = $accountCreator->execute(); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | expiration_date='" . $expiration_date . "' |
56 | 56 | WHERE device_uid='" . $device_uid . "'"); |
57 | 57 | |
58 | - if($result === false){ |
|
58 | + if($result === false) { |
|
59 | 59 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
60 | 60 | } |
61 | 61 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $db = new DatabaseConnect(); |
69 | 69 | $result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'"); |
70 | 70 | |
71 | - if ($result->num_rows > 0) |
|
71 | + if($result->num_rows > 0) |
|
72 | 72 | { |
73 | 73 | // output data of each row |
74 | 74 | while($row = $result->fetch_assoc()) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | if($expiration_date <= time()) { |
87 | 87 | $accountCreator = new CreateUser(); |
88 | - $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
|
88 | + $accountCreator->setAccessToken($access_token); //$accountData->getAccessToken()); |
|
89 | 89 | $accountCreator->setDeviceUid($deviceUid); |
90 | 90 | $accountCreator->setLocation($location); |
91 | 91 | $data = $accountCreator->execute(); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | expiration_date='" . $expiration_date . "' |
101 | 101 | WHERE device_uid='" . $device_uid . "'"); |
102 | 102 | |
103 | - if($result === false){ |
|
103 | + if($result === false) { |
|
104 | 104 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
105 | 105 | } |
106 | 106 | } |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
139 | 139 | expires_in, expiration_date, distinct_id, device_uid, name, lat, lng) |
140 | 140 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
141 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
141 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
142 | 142 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
143 | 143 | |
144 | 144 | $success = TRUE; |
145 | - if($result === false){ |
|
145 | + if($result === false) { |
|
146 | 146 | $error = db_error(); |
147 | 147 | echo $error; |
148 | 148 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -197,25 +197,25 @@ discard block |
||
197 | 197 | $timediff_inDays = (string)$timediff->format('%d'); |
198 | 198 | $timediff_inMonth = (string)$timediff->format('%m'); |
199 | 199 | |
200 | - if($timediff_inMonth!=0) |
|
200 | + if($timediff_inMonth != 0) |
|
201 | 201 | { |
202 | 202 | $timediff = $timediff_inMonth . "m"; |
203 | 203 | } |
204 | 204 | else |
205 | 205 | { |
206 | - if($timediff_inDays!=0) |
|
206 | + if($timediff_inDays != 0) |
|
207 | 207 | { |
208 | 208 | $timediff = $timediff_inDays . "d"; |
209 | 209 | } |
210 | 210 | else |
211 | 211 | { |
212 | - if($timediff_inHours!=0) |
|
212 | + if($timediff_inHours != 0) |
|
213 | 213 | { |
214 | 214 | $timediff = $timediff_inHours . "h"; |
215 | 215 | } |
216 | 216 | else |
217 | 217 | { |
218 | - if($timediff_inMinutes!=0) |
|
218 | + if($timediff_inMinutes != 0) |
|
219 | 219 | { |
220 | 220 | $timediff = $timediff_inMinutes . "m"; |
221 | 221 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | |
231 | 231 | ?> |
232 | - <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;"> |
|
232 | + <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"]; ?>;"> |
|
233 | 233 | <content> |
234 | 234 | <?php |
235 | 235 | if(isset($post["image_url"])) { |
@@ -241,12 +241,12 @@ discard block |
||
241 | 241 | ?> |
242 | 242 | </content> |
243 | 243 | <aside> |
244 | - <a href="index.php?vote=up&postID=<?php echo $post["post_id"];?>"> |
|
244 | + <a href="index.php?vote=up&postID=<?php echo $post["post_id"]; ?>"> |
|
245 | 245 | <i class="fa fa-angle-up fa-3x"></i> |
246 | 246 | </a> |
247 | 247 | <br /> |
248 | - <?php echo $post["vote_count"];?><br /> |
|
249 | - <a href="index.php?vote=down&postID=<?php echo $post["post_id"];?>"> |
|
248 | + <?php echo $post["vote_count"]; ?><br /> |
|
249 | + <a href="index.php?vote=down&postID=<?php echo $post["post_id"]; ?>"> |
|
250 | 250 | <i class="fa fa-angle-down fa-3x"></i> |
251 | 251 | </a> |
252 | 252 | </aside> |
@@ -257,13 +257,13 @@ discard block |
||
257 | 257 | <td class="time"> |
258 | 258 | <span data-tooltip="Time"> |
259 | 259 | <i class="fa fa-clock-o"></i> |
260 | - <?php echo $timediff;?> |
|
260 | + <?php echo $timediff; ?> |
|
261 | 261 | </span> |
262 | 262 | </td> |
263 | 263 | <td class="comments"> |
264 | 264 | <?php if(!$isDetailedView) {?> |
265 | 265 | <span data-tooltip="Comments"> |
266 | - <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
|
266 | + <a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $post["post_id"]; ?>"> |
|
267 | 267 | <i class="fa fa-commenting-o"></i> |
268 | 268 | <?php if(array_key_exists("child_count", $post)) { |
269 | 269 | echo $post["child_count"]; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | { |
293 | 293 | ?> |
294 | 294 | <span data-tooltip="Author"> |
295 | - <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> | |
|
295 | + <i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> | |
|
296 | 296 | </span> |
297 | 297 | <?php |
298 | 298 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | <span data-tooltip="Distance"> |
304 | 304 | <i class="fa fa-map-marker"></i> |
305 | - <?php echo $post["distance"];?> km |
|
305 | + <?php echo $post["distance"]; ?> km |
|
306 | 306 | </span> |
307 | 307 | </td> |
308 | 308 | </tr> |
@@ -26,7 +26,8 @@ discard block |
||
26 | 26 | if ($result->num_rows > 0) |
27 | 27 | { |
28 | 28 | // output data of each row |
29 | - while($row = $result->fetch_assoc()) { |
|
29 | + while($row = $result->fetch_assoc()) |
|
30 | + { |
|
30 | 31 | //$access_token = $row["access_token"]; |
31 | 32 | $expiration_date = $row["expiration_date"]; |
32 | 33 | $deviceUid = $row["device_uid"]; |
@@ -38,7 +39,8 @@ discard block |
||
38 | 39 | echo '0 results'; |
39 | 40 | } |
40 | 41 | |
41 | - if($expiration_date <= time()) { |
|
42 | + if($expiration_date <= time()) |
|
43 | + { |
|
42 | 44 | $accountCreator = new CreateUser(); |
43 | 45 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
44 | 46 | $accountCreator->setDeviceUid($deviceUid); |
@@ -55,7 +57,8 @@ discard block |
||
55 | 57 | expiration_date='" . $expiration_date . "' |
56 | 58 | WHERE device_uid='" . $device_uid . "'"); |
57 | 59 | |
58 | - if($result === false){ |
|
60 | + if($result === false) |
|
61 | + { |
|
59 | 62 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
60 | 63 | } |
61 | 64 | } |
@@ -71,7 +74,8 @@ discard block |
||
71 | 74 | if ($result->num_rows > 0) |
72 | 75 | { |
73 | 76 | // output data of each row |
74 | - while($row = $result->fetch_assoc()) { |
|
77 | + while($row = $result->fetch_assoc()) |
|
78 | + { |
|
75 | 79 | //$access_token = $row["access_token"]; |
76 | 80 | $expiration_date = $row["expiration_date"]; |
77 | 81 | $deviceUid = $row["device_uid"]; |
@@ -83,7 +87,8 @@ discard block |
||
83 | 87 | echo '0 results'; |
84 | 88 | } |
85 | 89 | |
86 | - if($expiration_date <= time()) { |
|
90 | + if($expiration_date <= time()) |
|
91 | + { |
|
87 | 92 | $accountCreator = new CreateUser(); |
88 | 93 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
89 | 94 | $accountCreator->setDeviceUid($deviceUid); |
@@ -100,7 +105,8 @@ discard block |
||
100 | 105 | expiration_date='" . $expiration_date . "' |
101 | 106 | WHERE device_uid='" . $device_uid . "'"); |
102 | 107 | |
103 | - if($result === false){ |
|
108 | + if($result === false) |
|
109 | + { |
|
104 | 110 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
105 | 111 | } |
106 | 112 | } |
@@ -117,7 +123,8 @@ discard block |
||
117 | 123 | return $data["karma"]; |
118 | 124 | } |
119 | 125 | |
120 | -function registerAccount(Location $location) { |
|
126 | +function registerAccount(Location $location) |
|
127 | +{ |
|
121 | 128 | $accountCreator = new CreateUser(); |
122 | 129 | $accountCreator->setLocation($location); |
123 | 130 | $data = $accountCreator->execute(); |
@@ -142,7 +149,8 @@ discard block |
||
142 | 149 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
143 | 150 | |
144 | 151 | $success = TRUE; |
145 | - if($result === false){ |
|
152 | + if($result === false) |
|
153 | + { |
|
146 | 154 | $error = db_error(); |
147 | 155 | echo $error; |
148 | 156 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -153,7 +161,7 @@ discard block |
||
153 | 161 | } |
154 | 162 | |
155 | 163 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
156 | -{ |
|
164 | +{ |
|
157 | 165 | $accountCreator = new GetPosts(); |
158 | 166 | $accountCreator->setLastPostId($lastPostId); |
159 | 167 | $accountCreator->setAccessToken($accessToken); |
@@ -181,7 +189,8 @@ discard block |
||
181 | 189 | } |
182 | 190 | |
183 | 191 | function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE) |
184 | -{ //ToDO |
|
192 | +{ |
|
193 | +//ToDO |
|
185 | 194 | //Replace # with link |
186 | 195 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
187 | 196 | |
@@ -232,10 +241,12 @@ discard block |
||
232 | 241 | <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;"> |
233 | 242 | <content> |
234 | 243 | <?php |
235 | - if(isset($post["image_url"])) { |
|
244 | + if(isset($post["image_url"])) |
|
245 | + { |
|
236 | 246 | echo '<img src="' . $post["image_url"] . '">'; |
237 | 247 | } |
238 | - else { |
|
248 | + else |
|
249 | + { |
|
239 | 250 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post["message"]))); |
240 | 251 | } |
241 | 252 | ?> |
@@ -261,13 +272,19 @@ discard block |
||
261 | 272 | </span> |
262 | 273 | </td> |
263 | 274 | <td class="comments"> |
264 | - <?php if(!$isDetailedView) {?> |
|
275 | + <?php if(!$isDetailedView) |
|
276 | +{ |
|
277 | +?> |
|
265 | 278 | <span data-tooltip="Comments"> |
266 | 279 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
267 | 280 | <i class="fa fa-commenting-o"></i> |
268 | - <?php if(array_key_exists("child_count", $post)) { |
|
281 | + <?php if(array_key_exists("child_count", $post)) |
|
282 | +{ |
|
269 | 283 | echo $post["child_count"]; |
270 | - } else echo "0"; |
|
284 | + } |
|
285 | + else { |
|
286 | + echo "0"; |
|
287 | + } |
|
271 | 288 | ?> |
272 | 289 | </a> |
273 | 290 | </span> |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | expiration_date='" . $expiration_date . "' |
56 | 56 | WHERE device_uid='" . $device_uid . "'"); |
57 | 57 | |
58 | - if($result === false){ |
|
58 | + if($result === FALSE){ |
|
59 | 59 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
60 | 60 | } |
61 | 61 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | expiration_date='" . $expiration_date . "' |
101 | 101 | WHERE device_uid='" . $device_uid . "'"); |
102 | 102 | |
103 | - if($result === false){ |
|
103 | + if($result === FALSE){ |
|
104 | 104 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
105 | 105 | } |
106 | 106 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
143 | 143 | |
144 | 144 | $success = TRUE; |
145 | - if($result === false){ |
|
145 | + if($result === FALSE){ |
|
146 | 146 | $error = db_error(); |
147 | 147 | echo $error; |
148 | 148 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |