@@ -45,7 +45,8 @@ discard block |
||
45 | 45 | if ($result->num_rows > 0) |
46 | 46 | { |
47 | 47 | // output data of each row |
48 | - while($row = $result->fetch_assoc()) { |
|
48 | + while($row = $result->fetch_assoc()) |
|
49 | + { |
|
49 | 50 | //$access_token = $row["access_token"]; |
50 | 51 | $expiration_date = $row["expiration_date"]; |
51 | 52 | $deviceUid = $row["device_uid"]; |
@@ -57,7 +58,8 @@ discard block |
||
57 | 58 | echo '0 results'; |
58 | 59 | } |
59 | 60 | |
60 | - if($expiration_date <= time()) { |
|
61 | + if($expiration_date <= time()) |
|
62 | + { |
|
61 | 63 | $accountCreator = new CreateUser(); |
62 | 64 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
63 | 65 | $accountCreator->setDeviceUid($deviceUid); |
@@ -74,7 +76,8 @@ discard block |
||
74 | 76 | expiration_date='" . $expiration_date . "' |
75 | 77 | WHERE device_uid='" . $device_uid . "'"); |
76 | 78 | |
77 | - if($result === false){ |
|
79 | + if($result === false) |
|
80 | + { |
|
78 | 81 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
79 | 82 | } |
80 | 83 | } |
@@ -90,7 +93,8 @@ discard block |
||
90 | 93 | if ($result->num_rows > 0) |
91 | 94 | { |
92 | 95 | // output data of each row |
93 | - while($row = $result->fetch_assoc()) { |
|
96 | + while($row = $result->fetch_assoc()) |
|
97 | + { |
|
94 | 98 | //$access_token = $row["access_token"]; |
95 | 99 | $expiration_date = $row["expiration_date"]; |
96 | 100 | $deviceUid = $row["device_uid"]; |
@@ -102,7 +106,8 @@ discard block |
||
102 | 106 | echo '0 results'; |
103 | 107 | } |
104 | 108 | |
105 | - if($expiration_date <= time()) { |
|
109 | + if($expiration_date <= time()) |
|
110 | + { |
|
106 | 111 | $accountCreator = new CreateUser(); |
107 | 112 | $accountCreator->setAccessToken($access_token);//$accountData->getAccessToken()); |
108 | 113 | $accountCreator->setDeviceUid($deviceUid); |
@@ -119,7 +124,8 @@ discard block |
||
119 | 124 | expiration_date='" . $expiration_date . "' |
120 | 125 | WHERE device_uid='" . $device_uid . "'"); |
121 | 126 | |
122 | - if($result === false){ |
|
127 | + if($result === false) |
|
128 | + { |
|
123 | 129 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
124 | 130 | } |
125 | 131 | } |
@@ -137,7 +143,8 @@ discard block |
||
137 | 143 | if ($result->num_rows > 0) |
138 | 144 | { |
139 | 145 | // output data of each row |
140 | - while($row = $result->fetch_assoc()) { |
|
146 | + while($row = $result->fetch_assoc()) |
|
147 | + { |
|
141 | 148 | //$access_token = $row["access_token"]; |
142 | 149 | $expiration_date = $row["expiration_date"]; |
143 | 150 | $deviceUid = $row["device_uid"]; |
@@ -149,7 +156,8 @@ discard block |
||
149 | 156 | echo '0 results'; |
150 | 157 | } |
151 | 158 | |
152 | - if($expiration_date <= time()) { |
|
159 | + if($expiration_date <= time()) |
|
160 | + { |
|
153 | 161 | $accountCreator = new CreateUser(); |
154 | 162 | $accountCreator->setAccessToken($access_token); |
155 | 163 | $accountCreator->setDeviceUid($deviceUid); |
@@ -166,7 +174,8 @@ discard block |
||
166 | 174 | expiration_date='" . $expiration_date . "' |
167 | 175 | WHERE device_uid='" . $device_uid . "'"); |
168 | 176 | |
169 | - if($result === false){ |
|
177 | + if($result === false) |
|
178 | + { |
|
170 | 179 | echo "Adding account failed: (" . $db->errno . ") " . $db->error; |
171 | 180 | } |
172 | 181 | } |
@@ -280,13 +289,15 @@ discard block |
||
280 | 289 | return $data["karma"]; |
281 | 290 | } |
282 | 291 | |
283 | -function addVoteWithPostIdToDeviceUid($postId, $device_uid) { |
|
292 | +function addVoteWithPostIdToDeviceUid($postId, $device_uid) |
|
293 | +{ |
|
284 | 294 | |
285 | 295 | $db = new DatabaseConnect(); |
286 | 296 | $result = $db->query("INSERT INTO votes (device_uid, postId) |
287 | 297 | VALUES ('" . $device_uid . "','" . $postId . "') "); |
288 | 298 | |
289 | - if($result === false){ |
|
299 | + if($result === false) |
|
300 | + { |
|
290 | 301 | $error = db_error(); |
291 | 302 | echo $error; |
292 | 303 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
@@ -294,7 +305,8 @@ discard block |
||
294 | 305 | |
295 | 306 | } |
296 | 307 | |
297 | -function registerAccount(Location $location) { |
|
308 | +function registerAccount(Location $location) |
|
309 | +{ |
|
298 | 310 | $accountCreator = new CreateUser(); |
299 | 311 | $accountCreator->setLocation($location); |
300 | 312 | $data = $accountCreator->execute(); |
@@ -319,7 +331,8 @@ discard block |
||
319 | 331 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
320 | 332 | |
321 | 333 | $success = TRUE; |
322 | - if($result === false){ |
|
334 | + if($result === false) |
|
335 | + { |
|
323 | 336 | $error = db_error(); |
324 | 337 | echo $error; |
325 | 338 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -330,7 +343,7 @@ discard block |
||
330 | 343 | } |
331 | 344 | |
332 | 345 | function getPosts($lastPostId, $accessToken, $url, $version = 'v2') |
333 | -{ |
|
346 | +{ |
|
334 | 347 | $accountCreator = new GetPosts(); |
335 | 348 | $accountCreator->setLastPostId($lastPostId); |
336 | 349 | $accountCreator->setAccessToken($accessToken); |
@@ -381,7 +394,8 @@ discard block |
||
381 | 394 | } |
382 | 395 | |
383 | 396 | function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE) |
384 | -{ //ToDO |
|
397 | +{ |
|
398 | +//ToDO |
|
385 | 399 | //Replace # with link |
386 | 400 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
387 | 401 | |
@@ -431,10 +445,12 @@ discard block |
||
431 | 445 | <article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;"> |
432 | 446 | <content> |
433 | 447 | <?php |
434 | - if(isset($post["image_url"])) { |
|
448 | + if(isset($post["image_url"])) |
|
449 | + { |
|
435 | 450 | echo '<img src="' . $post["image_url"] . '">'; |
436 | 451 | } |
437 | - else { |
|
452 | + else |
|
453 | + { |
|
438 | 454 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post["message"]))); |
439 | 455 | } |
440 | 456 | ?> |
@@ -442,11 +458,13 @@ discard block |
||
442 | 458 | <aside> |
443 | 459 | <?php |
444 | 460 | if($isDetailedView) |
445 | - {?> |
|
461 | + { |
|
462 | +?> |
|
446 | 463 | <a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>"> |
447 | 464 | <?php } |
448 | - else |
|
449 | - {?> |
|
465 | +else |
|
466 | + { |
|
467 | +?> |
|
450 | 468 | <a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>"> |
451 | 469 | <?php } ?> |
452 | 470 | <i class="fa fa-angle-up fa-3x"></i> |
@@ -455,11 +473,13 @@ discard block |
||
455 | 473 | <?php echo $post["vote_count"];?><br /> |
456 | 474 | <?php |
457 | 475 | if($isDetailedView) |
458 | - {?> |
|
476 | + { |
|
477 | +?> |
|
459 | 478 | <a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>"> |
460 | 479 | <?php } |
461 | - else |
|
462 | - {?> |
|
480 | +else |
|
481 | + { |
|
482 | +?> |
|
463 | 483 | <a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>"> |
464 | 484 | <?php } ?> |
465 | 485 | <i class="fa fa-angle-down fa-3x"></i> |
@@ -477,13 +497,19 @@ discard block |
||
477 | 497 | </span> |
478 | 498 | </td> |
479 | 499 | <td class="comments"> |
480 | - <?php if(!$isDetailedView) {?> |
|
500 | + <?php if(!$isDetailedView) |
|
501 | +{ |
|
502 | +?> |
|
481 | 503 | <span data-tooltip="Comments"> |
482 | 504 | <a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>"> |
483 | 505 | <i class="fa fa-commenting-o"></i> |
484 | - <?php if(array_key_exists("child_count", $post)) { |
|
506 | + <?php if(array_key_exists("child_count", $post)) |
|
507 | +{ |
|
485 | 508 | echo $post["child_count"]; |
486 | - } else echo "0"; |
|
509 | + } |
|
510 | + else { |
|
511 | + echo "0"; |
|
512 | + } |
|
487 | 513 | ?> |
488 | 514 | </a> |
489 | 515 | </span> |