@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $expiration_date; |
27 | 27 | $deviceUid; |
28 | 28 | |
29 | - if ($result->num_rows > 0) |
|
29 | + if($result->num_rows > 0) |
|
30 | 30 | { |
31 | 31 | // output data of each row |
32 | 32 | while($row = $result->fetch_assoc()) { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | if($expiration_date <= time()) { |
45 | 45 | $accountCreator = new CreateUser(); |
46 | - $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
|
46 | + $accountCreator->setAccessToken($access_token); //$accountData->getAccessToken()); |
|
47 | 47 | $accountCreator->setDeviceUid($deviceUid); |
48 | 48 | $accountCreator->setLocation($location); |
49 | 49 | $data = $accountCreator->execute(); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | WHERE device_uid='" . $device_uid . "'"); |
64 | 64 | |
65 | 65 | $success = TRUE; |
66 | - if($result === false){ |
|
66 | + if($result === false) { |
|
67 | 67 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
68 | 68 | $success = FALSE; |
69 | 69 | } |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | $result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type, |
103 | 103 | expires_in, expiration_date, distinct_id, device_uid) |
104 | 104 | VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type . |
105 | - "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
105 | + "','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id . |
|
106 | 106 | "','" . $device_uid . "') "); |
107 | 107 | |
108 | 108 | $success = TRUE; |
109 | - if($result === false){ |
|
109 | + if($result === false) { |
|
110 | 110 | $error = db_error(); |
111 | 111 | echo $error; |
112 | 112 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -18,7 +18,8 @@ discard block |
||
18 | 18 | |
19 | 19 | $lastPostId = ""; |
20 | 20 | |
21 | -function isTokenFresh(Location $location) { |
|
21 | +function isTokenFresh(Location $location) |
|
22 | +{ |
|
22 | 23 | $db = new DatabaseConnect(); |
23 | 24 | $result = $db->query("SELECT * FROM accounts WHERE id='1'"); |
24 | 25 | |
@@ -29,7 +30,8 @@ discard block |
||
29 | 30 | if ($result->num_rows > 0) |
30 | 31 | { |
31 | 32 | // output data of each row |
32 | - while($row = $result->fetch_assoc()) { |
|
33 | + while($row = $result->fetch_assoc()) |
|
34 | + { |
|
33 | 35 | //$access_token = $row["access_token"]; |
34 | 36 | $expiration_date = $row["expiration_date"]; |
35 | 37 | $deviceUid = $row["device_uid"]; |
@@ -41,7 +43,8 @@ discard block |
||
41 | 43 | echo "0 results"; |
42 | 44 | } |
43 | 45 | |
44 | - if($expiration_date <= time()) { |
|
46 | + if($expiration_date <= time()) |
|
47 | + { |
|
45 | 48 | $accountCreator = new CreateUser(); |
46 | 49 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
47 | 50 | $accountCreator->setDeviceUid($deviceUid); |
@@ -63,7 +66,8 @@ discard block |
||
63 | 66 | WHERE device_uid='" . $device_uid . "'"); |
64 | 67 | |
65 | 68 | $success = TRUE; |
66 | - if($result === false){ |
|
69 | + if($result === false) |
|
70 | + { |
|
67 | 71 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
68 | 72 | $success = FALSE; |
69 | 73 | } |
@@ -85,7 +89,8 @@ discard block |
||
85 | 89 | return $data["karma"]; |
86 | 90 | } |
87 | 91 | |
88 | -function registerAccount(Location $location) { |
|
92 | +function registerAccount(Location $location) |
|
93 | +{ |
|
89 | 94 | $accountCreator = new CreateUser(); |
90 | 95 | $accountCreator->setLocation($location); |
91 | 96 | $data = $accountCreator->execute(); |
@@ -106,7 +111,8 @@ discard block |
||
106 | 111 | "','" . $device_uid . "') "); |
107 | 112 | |
108 | 113 | $success = TRUE; |
109 | - if($result === false){ |
|
114 | + if($result === false) |
|
115 | + { |
|
110 | 116 | $error = db_error(); |
111 | 117 | echo $error; |
112 | 118 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -117,7 +123,7 @@ discard block |
||
117 | 123 | } |
118 | 124 | |
119 | 125 | function getPosts($lastPostId, $accessToken, $url) |
120 | -{ |
|
126 | +{ |
|
121 | 127 | $accountCreator = new GetPosts(); |
122 | 128 | $accountCreator->setLastPostId($lastPostId); |
123 | 129 | $accountCreator->setAccessToken($accessToken); |
@@ -127,7 +133,8 @@ discard block |
||
127 | 133 | return $data; |
128 | 134 | } |
129 | 135 | |
130 | -function createAccount() { |
|
136 | +function createAccount() |
|
137 | +{ |
|
131 | 138 | $location = new Location(); |
132 | 139 | $location->setLat(50.690399); |
133 | 140 | $location->setLng(10.918175); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | WHERE device_uid='" . $device_uid . "'"); |
64 | 64 | |
65 | 65 | $success = TRUE; |
66 | - if($result === false){ |
|
66 | + if($result === FALSE){ |
|
67 | 67 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
68 | 68 | $success = FALSE; |
69 | 69 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | "','" . $device_uid . "') "); |
107 | 107 | |
108 | 108 | $success = TRUE; |
109 | - if($result === false){ |
|
109 | + if($result === FALSE){ |
|
110 | 110 | $error = db_error(); |
111 | 111 | echo $error; |
112 | 112 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -2,94 +2,94 @@ |
||
2 | 2 | |
3 | 3 | class AccountData |
4 | 4 | { |
5 | - /** |
|
6 | - * @var string |
|
7 | - */ |
|
8 | - public $accessToken; |
|
9 | - /** |
|
10 | - * @var string |
|
11 | - */ |
|
12 | - public $expirationDate; |
|
13 | - /** |
|
14 | - * @var string |
|
15 | - */ |
|
16 | - public $refreshToken; |
|
17 | - /** |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - public $distinctId; |
|
21 | - /** |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - public $deviceUid; |
|
25 | - /** |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function getAccessToken() |
|
29 | - { |
|
30 | - return $this->accessToken; |
|
31 | - } |
|
32 | - /** |
|
33 | - * @param string $accessToken |
|
34 | - */ |
|
35 | - public function setAccessToken(string $accessToken) |
|
36 | - { |
|
37 | - $this->accessToken = $accessToken; |
|
38 | - } |
|
39 | - /** |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function getExpirationDate() |
|
43 | - { |
|
44 | - return $this->expirationDate; |
|
45 | - } |
|
46 | - /** |
|
47 | - * @param string $expirationDate |
|
48 | - */ |
|
49 | - public function setExpirationDate(string $expirationDate) |
|
50 | - { |
|
51 | - $this->expirationDate = $expirationDate; |
|
52 | - } |
|
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function getRefreshToken() |
|
57 | - { |
|
58 | - return $this->refreshToken; |
|
59 | - } |
|
60 | - /** |
|
61 | - * @param string $refreshToken |
|
62 | - */ |
|
63 | - public function setRefreshToken(string $refreshToken) |
|
64 | - { |
|
65 | - $this->refreshToken = $refreshToken; |
|
66 | - } |
|
67 | - /** |
|
68 | - * @return string |
|
69 | - */ |
|
70 | - public function getDistinctId() |
|
71 | - { |
|
72 | - return $this->distinctId; |
|
73 | - } |
|
74 | - /** |
|
75 | - * @param string $distinctId |
|
76 | - */ |
|
77 | - public function setDistinctId(string $distinctId) |
|
78 | - { |
|
79 | - $this->distinctId = $distinctId; |
|
80 | - } |
|
81 | - /** |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function getDeviceUid() |
|
85 | - { |
|
86 | - return $this->deviceUid; |
|
87 | - } |
|
88 | - /** |
|
89 | - * @param string $deviceUid |
|
90 | - */ |
|
91 | - public function setDeviceUid(string $deviceUid) |
|
92 | - { |
|
93 | - $this->deviceUid = $deviceUid; |
|
94 | - } |
|
5 | + /** |
|
6 | + * @var string |
|
7 | + */ |
|
8 | + public $accessToken; |
|
9 | + /** |
|
10 | + * @var string |
|
11 | + */ |
|
12 | + public $expirationDate; |
|
13 | + /** |
|
14 | + * @var string |
|
15 | + */ |
|
16 | + public $refreshToken; |
|
17 | + /** |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + public $distinctId; |
|
21 | + /** |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + public $deviceUid; |
|
25 | + /** |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function getAccessToken() |
|
29 | + { |
|
30 | + return $this->accessToken; |
|
31 | + } |
|
32 | + /** |
|
33 | + * @param string $accessToken |
|
34 | + */ |
|
35 | + public function setAccessToken(string $accessToken) |
|
36 | + { |
|
37 | + $this->accessToken = $accessToken; |
|
38 | + } |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function getExpirationDate() |
|
43 | + { |
|
44 | + return $this->expirationDate; |
|
45 | + } |
|
46 | + /** |
|
47 | + * @param string $expirationDate |
|
48 | + */ |
|
49 | + public function setExpirationDate(string $expirationDate) |
|
50 | + { |
|
51 | + $this->expirationDate = $expirationDate; |
|
52 | + } |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function getRefreshToken() |
|
57 | + { |
|
58 | + return $this->refreshToken; |
|
59 | + } |
|
60 | + /** |
|
61 | + * @param string $refreshToken |
|
62 | + */ |
|
63 | + public function setRefreshToken(string $refreshToken) |
|
64 | + { |
|
65 | + $this->refreshToken = $refreshToken; |
|
66 | + } |
|
67 | + /** |
|
68 | + * @return string |
|
69 | + */ |
|
70 | + public function getDistinctId() |
|
71 | + { |
|
72 | + return $this->distinctId; |
|
73 | + } |
|
74 | + /** |
|
75 | + * @param string $distinctId |
|
76 | + */ |
|
77 | + public function setDistinctId(string $distinctId) |
|
78 | + { |
|
79 | + $this->distinctId = $distinctId; |
|
80 | + } |
|
81 | + /** |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function getDeviceUid() |
|
85 | + { |
|
86 | + return $this->deviceUid; |
|
87 | + } |
|
88 | + /** |
|
89 | + * @param string $deviceUid |
|
90 | + */ |
|
91 | + public function setDeviceUid(string $deviceUid) |
|
92 | + { |
|
93 | + $this->deviceUid = $deviceUid; |
|
94 | + } |
|
95 | 95 | } |
@@ -34,15 +34,15 @@ |
||
34 | 34 | if(isset($_GET['city'])) { |
35 | 35 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w'; |
36 | 36 | $result = Requests::post($url); |
37 | - if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST') |
|
37 | + if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST') |
|
38 | 38 | { |
39 | 39 | $newPositionStatus = "0 results"; |
40 | 40 | } |
41 | 41 | else |
42 | 42 | { |
43 | 43 | $location = new Location(); |
44 | - $location->setLat(json_decode($result->body, true)['results']['0']['geometry']['location']['lat']); |
|
45 | - $location->setLng(json_decode($result->body, true)['results']['0']['geometry']['location']['lng']); |
|
44 | + $location->setLat(json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat']); |
|
45 | + $location->setLng(json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng']); |
|
46 | 46 | $location->setCityName(htmlspecialchars($_GET['city'])); |
47 | 47 | $accountCreator = new UpdateLocation(); |
48 | 48 | $accountCreator->setLocation($location); |
@@ -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()) |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | <a href="index.php"> |
114 | 114 | <h1> |
115 | 115 | JodelBlue |
116 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) echo '<i class="fa fa-refresh fa-1x"></i>';?> |
|
116 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) echo '<i class="fa fa-refresh fa-1x"></i>'; ?> |
|
117 | 117 | </h1> |
118 | 118 | </a> |
119 | 119 | </div> |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | //Set View |
132 | 132 | if(isset($_GET['view'])) |
133 | 133 | { |
134 | - switch ($_GET['view']) { |
|
134 | + switch($_GET['view']) { |
|
135 | 135 | case 'comment': |
136 | 136 | $view = 'comment'; |
137 | 137 | break; |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { |
155 | 155 | //Header Nav in Comment View |
156 | 156 | ?> |
157 | - <a id="comment-back" href="index.php?view=<?php echo $view;?>#postId-<?php echo htmlspecialchars($_GET['postID']);?>"> |
|
157 | + <a id="comment-back" href="index.php?view=<?php echo $view; ?>#postId-<?php echo htmlspecialchars($_GET['postID']); ?>"> |
|
158 | 158 | <i class="fa fa-angle-left fa-3x"></i> |
159 | 159 | </a> |
160 | 160 | |
161 | - <a id="comment-refresh" href="index.php?getPostDetails=<?php echo htmlspecialchars($_GET['getPostDetails']);?>&postID=<?php echo htmlspecialchars($_GET['postID']);?>"> |
|
161 | + <a id="comment-refresh" href="index.php?getPostDetails=<?php echo htmlspecialchars($_GET['getPostDetails']); ?>&postID=<?php echo htmlspecialchars($_GET['postID']); ?>"> |
|
162 | 162 | <i class="fa fa-refresh fa-2x"></i> |
163 | 163 | </a> |
164 | 164 | <?php |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | //Get Posts |
182 | 182 | else |
183 | 183 | { |
184 | - if($view=='comment') |
|
184 | + if($view == 'comment') |
|
185 | 185 | { |
186 | 186 | $url = "/v2/posts/location/discussed/"; |
187 | 187 | } |
188 | 188 | else |
189 | 189 | { |
190 | - if($view=='upVote') |
|
190 | + if($view == 'upVote') |
|
191 | 191 | { |
192 | 192 | $url = "/v2/posts/location/popular/"; |
193 | 193 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | |
206 | - for($i = 0; $i<$loops; $i++) { |
|
206 | + for($i = 0; $i < $loops; $i++) { |
|
207 | 207 | |
208 | 208 | if(isset($posts[$i])) { |
209 | 209 | $lastPostId = $posts[$i]['post_id']; |
@@ -221,24 +221,24 @@ discard block |
||
221 | 221 | $timediff_inHours = (string)$timediff->format('%h'); |
222 | 222 | $timediff_inDays = (string)$timediff->format('%d'); |
223 | 223 | $timediff_inMonth = (string)$timediff->format('%m'); |
224 | - if($timediff_inMonth!=0) { |
|
224 | + if($timediff_inMonth != 0) { |
|
225 | 225 | $timediff = $timediff_inMonth . "m"; |
226 | 226 | } |
227 | 227 | else |
228 | 228 | { |
229 | - if($timediff_inDays!=0) |
|
229 | + if($timediff_inDays != 0) |
|
230 | 230 | { |
231 | 231 | $timediff = $timediff_inDays . "d"; |
232 | 232 | } |
233 | 233 | else |
234 | 234 | { |
235 | - if($timediff_inHours!=0) |
|
235 | + if($timediff_inHours != 0) |
|
236 | 236 | { |
237 | 237 | $timediff = $timediff_inHours . "h"; |
238 | 238 | } |
239 | 239 | else |
240 | 240 | { |
241 | - if($timediff_inMinutes!=0) |
|
241 | + if($timediff_inMinutes != 0) |
|
242 | 242 | { |
243 | 243 | $timediff = $timediff_inMinutes . "m"; |
244 | 244 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | } |
252 | 252 | ?> |
253 | 253 | |
254 | - <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
|
254 | + <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"]; ?>;"> |
|
255 | 255 | <content> |
256 | 256 | <?php |
257 | 257 | if(isset($posts[$i]["image_url"])) { |
@@ -263,12 +263,12 @@ discard block |
||
263 | 263 | ?> |
264 | 264 | </content> |
265 | 265 | <aside> |
266 | - <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
266 | + <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
267 | 267 | <i class="fa fa-angle-up fa-3x"></i> |
268 | 268 | </a> |
269 | 269 | <br /> |
270 | - <?php echo $posts[$i]["vote_count"];?><br /> |
|
271 | - <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
270 | + <?php echo $posts[$i]["vote_count"]; ?><br /> |
|
271 | + <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
272 | 272 | <i class="fa fa-angle-down fa-3x"></i> |
273 | 273 | </a> |
274 | 274 | </aside> |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | <td class="time"> |
280 | 280 | <span data-tooltip="Time"> |
281 | 281 | <i class="fa fa-clock-o"></i> |
282 | - <?php echo $timediff;?> |
|
282 | + <?php echo $timediff; ?> |
|
283 | 283 | </span> |
284 | 284 | </td> |
285 | 285 | <td class="comments"> |
286 | 286 | <?php if($showCommentIcon) {?> |
287 | 287 | <span data-tooltip="Comments"> |
288 | - <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
288 | + <a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
289 | 289 | <i class="fa fa-commenting-o"></i> |
290 | 290 | <?php if(array_key_exists("child_count", $posts[$i])) { |
291 | 291 | echo $posts[$i]["child_count"]; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | <td class="distance"> |
299 | 299 | <span data-tooltip="Distance"> |
300 | 300 | <i class="fa fa-map-marker"></i> |
301 | - <?php echo $posts[$i]["distance"];?> km |
|
301 | + <?php echo $posts[$i]["distance"]; ?> km |
|
302 | 302 | </span> |
303 | 303 | </td> |
304 | 304 | </tr> |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
346 | 346 | <h2>Comment on Jodel</h2> |
347 | 347 | <form method="POST"> |
348 | - <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
|
348 | + <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" /> |
|
349 | 349 | <textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> |
350 | 350 | <br /> |
351 | 351 | <input type="submit" value="SEND" /> |
@@ -373,13 +373,13 @@ discard block |
||
373 | 373 | <div class="col-sm-12"> |
374 | 374 | <div class="row"> |
375 | 375 | <div class="col-sm-3"> |
376 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
376 | + <a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
377 | 377 | </div> |
378 | 378 | <div class="col-sm-3"> |
379 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
379 | + <a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
380 | 380 | </div> |
381 | 381 | <div class="col-sm-3"> |
382 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
382 | + <a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
383 | 383 | </div> |
384 | 384 | <div class="col-sm-3"> |
385 | 385 | <nav> |
@@ -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 | { |
@@ -113,7 +118,11 @@ discard block |
||
113 | 118 | <a href="index.php"> |
114 | 119 | <h1> |
115 | 120 | JodelBlue |
116 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) echo '<i class="fa fa-refresh fa-1x"></i>';?> |
|
121 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
122 | +{ |
|
123 | + echo '<i class="fa fa-refresh fa-1x"></i>'; |
|
124 | +} |
|
125 | +?> |
|
117 | 126 | </h1> |
118 | 127 | </a> |
119 | 128 | </div> |
@@ -131,7 +140,8 @@ discard block |
||
131 | 140 | //Set View |
132 | 141 | if(isset($_GET['view'])) |
133 | 142 | { |
134 | - switch ($_GET['view']) { |
|
143 | + switch ($_GET['view']) |
|
144 | + { |
|
135 | 145 | case 'comment': |
136 | 146 | $view = 'comment'; |
137 | 147 | break; |
@@ -151,7 +161,8 @@ discard block |
||
151 | 161 | } |
152 | 162 | |
153 | 163 | //Get Post Details |
154 | - if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { |
|
164 | + if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
165 | + { |
|
155 | 166 | //Header Nav in Comment View |
156 | 167 | ?> |
157 | 168 | <a id="comment-back" href="index.php?view=<?php echo $view;?>#postId-<?php echo htmlspecialchars($_GET['postID']);?>"> |
@@ -169,13 +180,17 @@ discard block |
||
169 | 180 | $data = $accountCreator->execute(); |
170 | 181 | |
171 | 182 | $posts[0] = $data; |
172 | - if(isset($data['children'])) { |
|
173 | - foreach($data['children'] as $child) { |
|
183 | + if(isset($data['children'])) |
|
184 | + { |
|
185 | + foreach($data['children'] as $child) |
|
186 | + { |
|
174 | 187 | array_push($posts, $child); |
175 | 188 | } |
176 | 189 | $loops = $data['child_count'] + 1; |
177 | 190 | } |
178 | - else $loops = 1; |
|
191 | + else { |
|
192 | + $loops = 1; |
|
193 | + } |
|
179 | 194 | $showCommentIcon = FALSE; |
180 | 195 | } |
181 | 196 | //Get Posts |
@@ -203,9 +218,11 @@ discard block |
||
203 | 218 | } |
204 | 219 | |
205 | 220 | |
206 | - for($i = 0; $i<$loops; $i++) { |
|
221 | + for($i = 0; $i<$loops; $i++) |
|
222 | + { |
|
207 | 223 | |
208 | - if(isset($posts[$i])) { |
|
224 | + if(isset($posts[$i])) |
|
225 | + { |
|
209 | 226 | $lastPostId = $posts[$i]['post_id']; |
210 | 227 | |
211 | 228 | |
@@ -221,7 +238,8 @@ discard block |
||
221 | 238 | $timediff_inHours = (string)$timediff->format('%h'); |
222 | 239 | $timediff_inDays = (string)$timediff->format('%d'); |
223 | 240 | $timediff_inMonth = (string)$timediff->format('%m'); |
224 | - if($timediff_inMonth!=0) { |
|
241 | + if($timediff_inMonth!=0) |
|
242 | + { |
|
225 | 243 | $timediff = $timediff_inMonth . "m"; |
226 | 244 | } |
227 | 245 | else |
@@ -254,10 +272,12 @@ discard block |
||
254 | 272 | <article id ="postId-<?php echo $posts[$i]["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
255 | 273 | <content> |
256 | 274 | <?php |
257 | - if(isset($posts[$i]["image_url"])) { |
|
275 | + if(isset($posts[$i]["image_url"])) |
|
276 | + { |
|
258 | 277 | echo '<img src="' . $posts[$i]["image_url"] . '">'; |
259 | 278 | } |
260 | - else { |
|
279 | + else |
|
280 | + { |
|
261 | 281 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($posts[$i]["message"]))); |
262 | 282 | } |
263 | 283 | ?> |
@@ -283,13 +303,19 @@ discard block |
||
283 | 303 | </span> |
284 | 304 | </td> |
285 | 305 | <td class="comments"> |
286 | - <?php if($showCommentIcon) {?> |
|
306 | + <?php if($showCommentIcon) |
|
307 | +{ |
|
308 | +?> |
|
287 | 309 | <span data-tooltip="Comments"> |
288 | 310 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $posts[$i]["post_id"];?>"> |
289 | 311 | <i class="fa fa-commenting-o"></i> |
290 | - <?php if(array_key_exists("child_count", $posts[$i])) { |
|
312 | + <?php if(array_key_exists("child_count", $posts[$i])) |
|
313 | +{ |
|
291 | 314 | echo $posts[$i]["child_count"]; |
292 | - } else echo "0"; |
|
315 | + } |
|
316 | + else { |
|
317 | + echo "0"; |
|
318 | + } |
|
293 | 319 | ?> |
294 | 320 | </a> |
295 | 321 | </span> |
@@ -313,7 +339,9 @@ discard block |
||
313 | 339 | |
314 | 340 | </content> |
315 | 341 | |
316 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
342 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
343 | +{ |
|
344 | +?> |
|
317 | 345 | <p id="loading"> |
318 | 346 | Loading… |
319 | 347 | </p> |
@@ -326,7 +354,14 @@ discard block |
||
326 | 354 | <div> |
327 | 355 | <h2>Position</h2> |
328 | 356 | <form method="get"> |
329 | - <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; else echo htmlspecialchars($posts[0]["location"]["name"]); ?>" required> |
|
357 | + <input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) |
|
358 | +{ |
|
359 | + echo $newPositionStatus; |
|
360 | +} |
|
361 | +else { |
|
362 | + echo htmlspecialchars($posts[0]["location"]["name"]); |
|
363 | +} |
|
364 | +?>" required> |
|
330 | 365 | |
331 | 366 | <input type="submit" value="Set Location" /> |
332 | 367 | </form> |
@@ -342,7 +377,9 @@ discard block |
||
342 | 377 | |
343 | 378 | <article> |
344 | 379 | <div> |
345 | - <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?> |
|
380 | + <?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) |
|
381 | +{ |
|
382 | +?> |
|
346 | 383 | <h2>Comment on Jodel</h2> |
347 | 384 | <form method="POST"> |
348 | 385 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" /> |
@@ -350,7 +387,10 @@ discard block |
||
350 | 387 | <br /> |
351 | 388 | <input type="submit" value="SEND" /> |
352 | 389 | </form> |
353 | - <?php } else { ?> |
|
390 | + <?php } |
|
391 | +else |
|
392 | +{ |
|
393 | +?> |
|
354 | 394 | <h2>New Jodel</h2> |
355 | 395 | <form method="POST"> |
356 | 396 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |
@@ -373,13 +413,25 @@ discard block |
||
373 | 413 | <div class="col-sm-12"> |
374 | 414 | <div class="row"> |
375 | 415 | <div class="col-sm-3"> |
376 | - <a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
416 | + <a href="index.php" <?php if($view=='time') |
|
417 | +{ |
|
418 | + echo 'class="active"'; |
|
419 | +} |
|
420 | +?>><i class="fa fa-clock-o fa-3x"></i></a> |
|
377 | 421 | </div> |
378 | 422 | <div class="col-sm-3"> |
379 | - <a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
423 | + <a href="index.php?view=comment" <?php if($view=='comment') |
|
424 | +{ |
|
425 | + echo 'class="active"'; |
|
426 | +} |
|
427 | +?>><i class="fa fa-commenting-o fa-3x"></i></a> |
|
380 | 428 | </div> |
381 | 429 | <div class="col-sm-3"> |
382 | - <a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
430 | + <a href="index.php?view=upVote" <?php if($view=='upVote') |
|
431 | +{ |
|
432 | + echo 'class="active"'; |
|
433 | +} |
|
434 | +?>><i class="fa fa-angle-up fa-3x"></i></a> |
|
383 | 435 | </div> |
384 | 436 | <div class="col-sm-3"> |
385 | 437 | <nav> |
@@ -403,7 +455,9 @@ discard block |
||
403 | 455 | $(this).addClass('selected'); |
404 | 456 | }); |
405 | 457 | |
406 | - <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?> |
|
458 | + <?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) |
|
459 | +{ |
|
460 | +?> |
|
407 | 461 | $(document).ready(function() { |
408 | 462 | var win = $(window); |
409 | 463 | var lastPostId = "<?php echo $lastPostId; ?>"; |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | |
20 | 20 | function getPosts($lastPostId, $url) { |
21 | 21 | $db = new DatabaseConnect(); |
22 | - if ($db->connect_errno) { |
|
22 | + if($db->connect_errno) { |
|
23 | 23 | echo 'Sorry, die Verbindung zu unserem superfetten endgeilen |
24 | 24 | Server ist hops gegangen. Wegen '. $db -> connect_error; |
25 | 25 | } |
26 | 26 | |
27 | 27 | $result = $db->query("SELECT * FROM accounts WHERE id='1'"); |
28 | 28 | |
29 | - if ($result->num_rows > 0) { |
|
29 | + if($result->num_rows > 0) { |
|
30 | 30 | // output data of each row |
31 | 31 | while($row = $result->fetch_assoc()) { |
32 | 32 | $access_token = $row["access_token"]; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | if(isset($_GET['view'])) |
51 | 51 | { |
52 | - switch ($_GET['view']) { |
|
52 | + switch($_GET['view']) { |
|
53 | 53 | case 'comment': |
54 | 54 | $view = 'comment'; |
55 | 55 | break; |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | $view = 'time'; |
69 | 69 | } |
70 | 70 | |
71 | - if($view=='comment') |
|
71 | + if($view == 'comment') |
|
72 | 72 | { |
73 | 73 | $url = "/v2/posts/location/discussed/"; |
74 | 74 | } |
75 | 75 | else |
76 | 76 | { |
77 | - if($view=='upVote') |
|
77 | + if($view == 'upVote') |
|
78 | 78 | { |
79 | 79 | $url = "/v2/posts/location/popular/"; |
80 | 80 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | ?> |
95 | 95 | <div class="nextPosts"> |
96 | 96 | <?php |
97 | - for($i = 0; $i<$loops; $i++) { |
|
97 | + for($i = 0; $i < $loops; $i++) { |
|
98 | 98 | |
99 | 99 | if(isset($posts[$i])) { |
100 | 100 | $lastPostId = $posts[$i]['post_id']; |
@@ -112,24 +112,24 @@ discard block |
||
112 | 112 | $timediff_inHours = (string)$timediff->format('%h'); |
113 | 113 | $timediff_inDays = (string)$timediff->format('%d'); |
114 | 114 | $timediff_inMonth = (string)$timediff->format('%m'); |
115 | - if($timediff_inMonth!=0) { |
|
115 | + if($timediff_inMonth != 0) { |
|
116 | 116 | $timediff = $timediff_inMonth . "m"; |
117 | 117 | } |
118 | 118 | else |
119 | 119 | { |
120 | - if($timediff_inDays!=0) |
|
120 | + if($timediff_inDays != 0) |
|
121 | 121 | { |
122 | 122 | $timediff = $timediff_inDays . "d"; |
123 | 123 | } |
124 | 124 | else |
125 | 125 | { |
126 | - if($timediff_inHours!=0) |
|
126 | + if($timediff_inHours != 0) |
|
127 | 127 | { |
128 | 128 | $timediff = $timediff_inHours . "h"; |
129 | 129 | } |
130 | 130 | else |
131 | 131 | { |
132 | - if($timediff_inMinutes!=0) |
|
132 | + if($timediff_inMinutes != 0) |
|
133 | 133 | { |
134 | 134 | $timediff = $timediff_inMinutes . "m"; |
135 | 135 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | ?> |
144 | 144 | |
145 | - <article class="jodel" style="background-color: #<?php echo $posts[$i]["color"];?>;"> |
|
145 | + <article class="jodel" style="background-color: #<?php echo $posts[$i]["color"]; ?>;"> |
|
146 | 146 | <content> |
147 | 147 | <?php |
148 | 148 | if(isset($posts[$i]["image_url"])) { |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | ?> |
155 | 155 | </content> |
156 | 156 | <aside> |
157 | - <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
157 | + <a href="index.php?vote=up&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
158 | 158 | <i class="fa fa-angle-up fa-3x"></i> |
159 | 159 | </a> |
160 | 160 | <br /> |
161 | - <?php echo $posts[$i]["vote_count"];?><br /> |
|
162 | - <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
161 | + <?php echo $posts[$i]["vote_count"]; ?><br /> |
|
162 | + <a href="index.php?vote=down&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
163 | 163 | <i class="fa fa-angle-down fa-3x"></i> |
164 | 164 | </a> |
165 | 165 | </aside> |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | <td class="time"> |
171 | 171 | <span data-tooltip="Time"> |
172 | 172 | <i class="fa fa-clock-o"></i> |
173 | - <?php echo $timediff;?> |
|
173 | + <?php echo $timediff; ?> |
|
174 | 174 | </span> |
175 | 175 | </td> |
176 | 176 | <td class="comments"> |
177 | 177 | <?php if($showCommentIcon) {?> |
178 | 178 | <span data-tooltip="Comments"> |
179 | - <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $posts[$i]["post_id"];?>"> |
|
179 | + <a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $posts[$i]["post_id"]; ?>"> |
|
180 | 180 | <i class="fa fa-commenting-o"></i> |
181 | 181 | <?php if(array_key_exists("child_count", $posts[$i])) { |
182 | 182 | echo $posts[$i]["child_count"]; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | <td class="distance"> |
190 | 190 | <span data-tooltip="Distance"> |
191 | 191 | <i class="fa fa-map-marker"></i> |
192 | - <?php echo $posts[$i]["distance"];?> km |
|
192 | + <?php echo $posts[$i]["distance"]; ?> km |
|
193 | 193 | </span> |
194 | 194 | </td> |
195 | 195 | </tr> |
@@ -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> |