@@ -13,7 +13,7 @@ |
||
13 | 13 | public $varsToDump; |
14 | 14 | |
15 | 15 | function __construct($msg = 'not Set', $varsToDump = 'not Set', $view = 'not Set', $actions = 'not Set', $accountId = 'not Set', $isVerified = 'not Set', $isTokenFresh = 'not Set', $page = 'not Set', $referrer = 'not Set') |
16 | - { |
|
16 | + { |
|
17 | 17 | $this->view = $view; |
18 | 18 | $this->actions = $actions; |
19 | 19 | $this->accountId = $accountId; |
@@ -61,7 +61,9 @@ discard block |
||
61 | 61 | { |
62 | 62 | window.history.back(); |
63 | 63 | } |
64 | - <?php if(isset($includeEmojiAndAjax)){ ?> |
|
64 | + <?php if(isset($includeEmojiAndAjax)) |
|
65 | +{ |
|
66 | +?> |
|
65 | 67 | |
66 | 68 | function vote(postId, vote, obj) |
67 | 69 | { |
@@ -91,7 +93,9 @@ discard block |
||
91 | 93 | |
92 | 94 | $(document).ready(function() |
93 | 95 | { |
94 | - <?php if(isset($errorMsg)) { ?> |
|
96 | + <?php if(isset($errorMsg)) |
|
97 | +{ |
|
98 | +?> |
|
95 | 99 | //Error Msg |
96 | 100 | if('<?php echo $errorMsg;?>' != '') |
97 | 101 | { |
@@ -155,7 +159,9 @@ discard block |
||
155 | 159 | return {"lastPostId":lastPostId, "old_lastPostId":old_lastPostId}; |
156 | 160 | } |
157 | 161 | |
158 | - <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?> |
|
162 | + <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) |
|
163 | +{ |
|
164 | +?> |
|
159 | 165 | |
160 | 166 | if(window.location.hash) |
161 | 167 | { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | function isUserVoter() |
76 | 76 | { |
77 | 77 | if(isset($_COOKIE['JodelVoterPassword'])) |
78 | - { |
|
78 | + { |
|
79 | 79 | $db = new DatabaseConnect(); |
80 | 80 | $result = $db->query("SELECT id FROM users WHERE user_token = '" . $_COOKIE['JodelVoterPassword'] . "'"); |
81 | 81 | if($result->num_rows == 0) |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | if(configPropertyExists($config, 'karmaDeviceUid')) |
150 | - { |
|
150 | + { |
|
151 | 151 | $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
152 | 152 | } |
153 | 153 | else |
@@ -220,7 +220,8 @@ discard block |
||
220 | 220 | |
221 | 221 | if(isset($_GET['view'])) |
222 | 222 | { |
223 | - switch ($_GET['view']) { |
|
223 | + switch ($_GET['view']) |
|
224 | + { |
|
224 | 225 | case 'discussed': |
225 | 226 | $view = 'discussed'; |
226 | 227 | break; |
@@ -13,9 +13,12 @@ |
||
13 | 13 | } |
14 | 14 | $db = new DatabaseConnect(); |
15 | 15 | |
16 | -if($db->connect_errno == 1203) // 1203 == ER_TOO_MANY_USER_CONNECTIONS (mysqld_error.h) |
|
16 | +if($db->connect_errno == 1203) |
|
17 | +{ |
|
18 | + // 1203 == ER_TOO_MANY_USER_CONNECTIONS (mysqld_error.h) |
|
17 | 19 | { |
18 | 20 | error_log('ER_TOO_MANY_USER_CONNECTIONS'); |
21 | +} |
|
19 | 22 | sleep(1); |
20 | 23 | header('location: '.$_SERVER['PHP_SELF']); |
21 | 24 | } |
@@ -62,7 +62,8 @@ discard block |
||
62 | 62 | . "','" . $db->escape_string($_POST['device_uid']) |
63 | 63 | . "','" . $db->escape_string($_POST['rights']) . "')"); |
64 | 64 | |
65 | - if($result === false){ |
|
65 | + if($result === false) |
|
66 | + { |
|
66 | 67 | $error = db_error(); |
67 | 68 | error_log($error); |
68 | 69 | error_log("Adding Voter failed: (" . $result->errno . ") " . $result->error); |
@@ -165,7 +166,9 @@ discard block |
||
165 | 166 | <div class="row"> |
166 | 167 | <article class="topContent col-12 col-sm-12"> |
167 | 168 | <content id="posts" class="adminpanel"> |
168 | - <?php if($userIsAdmin) { ?> |
|
169 | + <?php if($userIsAdmin) |
|
170 | +{ |
|
171 | +?> |
|
169 | 172 | <div class="row"> |
170 | 173 | <div class="col-md-12"> |
171 | 174 | <h2>Account management</h2> |
@@ -213,7 +216,8 @@ discard block |
||
213 | 216 | <?php |
214 | 217 | } |
215 | 218 | |
216 | - if($userIsVoter) { |
|
219 | + if($userIsVoter) |
|
220 | + { |
|
217 | 221 | ?> |
218 | 222 | <div class="row"> |
219 | 223 | <div class="col-12 col-sm-12"> |
@@ -239,7 +243,11 @@ discard block |
||
239 | 243 | </div> |
240 | 244 | <div class="form-group"> |
241 | 245 | <label for="postIdDelay">Post Id</label> |
242 | - <input placeholder="postId" class="form-control" id="postIdDelay" value="<?php if(isset($_GET['postId'])) echo $_GET['postId'];?>" type="text" name="postId"> |
|
246 | + <input placeholder="postId" class="form-control" id="postIdDelay" value="<?php if(isset($_GET['postId'])) |
|
247 | +{ |
|
248 | + echo $_GET['postId']; |
|
249 | +} |
|
250 | +?>" type="text" name="postId"> |
|
243 | 251 | </div> |
244 | 252 | <div class="row"> |
245 | 253 | <div class="col-6 col-xs-6"><button type="button" name="vote" value="up" class="half" onclick="voteWithAjax('up');">Upvote</button></div> |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | if($location->getCityName() == $city) |
133 | 133 | { |
134 | 134 | return TRUE; |
135 | - } |
|
135 | + } |
|
136 | 136 | else |
137 | 137 | { |
138 | 138 | return FALSE; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | if(substr($_GET['city'], 0, 1) === '#') |
146 | 146 | { |
147 | 147 | return htmlspecialchars($_GET['city']) . " " . $this->location->cityName; |
148 | - } |
|
148 | + } |
|
149 | 149 | else |
150 | 150 | { |
151 | 151 | $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=' . $this->getGeocodingToken(); |
@@ -333,7 +333,8 @@ discard block |
||
333 | 333 | if(isset($_POST['color'])) |
334 | 334 | { |
335 | 335 | $color = $_POST['color']; |
336 | - switch ($color) { |
|
336 | + switch ($color) |
|
337 | + { |
|
337 | 338 | case '8ABDB0': |
338 | 339 | $color = '8ABDB0'; |
339 | 340 | break; |
@@ -446,7 +447,8 @@ discard block |
||
446 | 447 | expiration_date='" . $expiration_date . "' |
447 | 448 | WHERE device_uid='" . $device_uid . "'"); |
448 | 449 | |
449 | - if($result === false){ |
|
450 | + if($result === false) |
|
451 | + { |
|
450 | 452 | error_log("Adding account failed: (" . $db->errno . ") " . $db->error); |
451 | 453 | } |
452 | 454 | } |
@@ -526,14 +528,16 @@ discard block |
||
526 | 528 | $result = $db->query("INSERT INTO votes (device_uid, postId, type) |
527 | 529 | VALUES ('" . $this->deviceUid . "','" . $postId . "','" . $voteType . "')"); |
528 | 530 | |
529 | - if($result === false){ |
|
531 | + if($result === false) |
|
532 | + { |
|
530 | 533 | $error = db_error(); |
531 | 534 | echo $error; |
532 | 535 | echo "Adding Vote failed: (" . $result->errno . ") " . $result->error; |
533 | 536 | } |
534 | 537 | } |
535 | 538 | |
536 | - function registerAccount($location) { |
|
539 | + function registerAccount($location) |
|
540 | + { |
|
537 | 541 | $accountCreator = new CreateUser(); |
538 | 542 | $accountCreator->setLocation($location); |
539 | 543 | $data = $accountCreator->execute(); |
@@ -558,7 +562,8 @@ discard block |
||
558 | 562 | "','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') "); |
559 | 563 | |
560 | 564 | $success = TRUE; |
561 | - if($result === false){ |
|
565 | + if($result === false) |
|
566 | + { |
|
562 | 567 | $error = $db->error(); |
563 | 568 | echo $error; |
564 | 569 | echo "Adding account failed: (" . $result->errno . ") " . $result->error; |
@@ -48,7 +48,8 @@ discard block |
||
48 | 48 | * Compute HTML Code |
49 | 49 | */ |
50 | 50 | function jodelToHtml($post) |
51 | - { //ToDO |
|
51 | + { |
|
52 | +//ToDO |
|
52 | 53 | //Replace # with link |
53 | 54 | //preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text); |
54 | 55 | |
@@ -104,7 +105,8 @@ discard block |
||
104 | 105 | |
105 | 106 | echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">'; |
106 | 107 | } |
107 | - else { |
|
108 | + else |
|
109 | + { |
|
108 | 110 | echo str_replace(' ', ' ', nl2br(htmlspecialchars($post['message']))); |
109 | 111 | } |
110 | 112 | ?> |
@@ -130,15 +132,20 @@ discard block |
||
130 | 132 | <span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span> |
131 | 133 | </span> |
132 | 134 | </span> |
133 | - <?php if(!$this->isDetailedView) {?> |
|
135 | + <?php if(!$this->isDetailedView) |
|
136 | +{ |
|
137 | +?> |
|
134 | 138 | <span class="comments"> |
135 | 139 | <span data-tooltip="Comments"> |
136 | 140 | <a href="<?php echo $this->changePostId($post['post_id'])->toUrl();?>"> |
137 | 141 | <i class="fa fa-commenting-o"></i> |
138 | 142 | <?php if(array_key_exists("child_count", $post)) |
139 | - { |
|
143 | +{ |
|
140 | 144 | echo $post["child_count"]; |
141 | - } else echo "0"; |
|
145 | + } |
|
146 | + else { |
|
147 | + echo "0"; |
|
148 | + } |
|
142 | 149 | ?> |
143 | 150 | </a> |
144 | 151 | </span> |
@@ -313,7 +320,7 @@ discard block |
||
313 | 320 | $data = $accountCreator->execute(); |
314 | 321 | } |
315 | 322 | if(is_array($data) && array_key_exists('recent', $data) && array_key_exists(0, $data['recent'])) |
316 | - { |
|
323 | + { |
|
317 | 324 | return $data['recent']; |
318 | 325 | } |
319 | 326 | else if(is_array($data) && array_key_exists('posts', $data)&& array_key_exists(0, $data['posts'])) |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | abstract class AbstractRequest |
4 | -{ |
|
4 | +{ |
|
5 | 5 | const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
6 | 6 | const APIURL = 'https://api.go-tellm.com/api'; |
7 | 7 | const SECRET = 'bJYlFZkrnLpLMVisrbstPDNsaYHPbzcKRSpqtjtt'; |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | |
21 | 21 | $this->payLoad = $this->getPayload(); |
22 | 22 | $device_uid = ''; |
23 | - if(isset($this->payLoad['device_uid'])) { |
|
23 | + if(isset($this->payLoad['device_uid'])) |
|
24 | + { |
|
24 | 25 | $device_uid = $this->payLoad['device_uid']; |
25 | 26 | } |
26 | 27 | |
@@ -29,7 +30,8 @@ discard block |
||
29 | 30 | $header = $this->getSignHeaders(); |
30 | 31 | $url = $this->getFullUrl(); |
31 | 32 | |
32 | - if ($this->getAccessToken()) { |
|
33 | + if ($this->getAccessToken()) |
|
34 | + { |
|
33 | 35 | $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
34 | 36 | } |
35 | 37 | //Comment out to debug the Request: |
@@ -52,7 +54,8 @@ discard block |
||
52 | 54 | 'proxy' => '186.103.169.165:8080', |
53 | 55 | );*/ |
54 | 56 | |
55 | - switch ($this->getMethod()) { |
|
57 | + switch ($this->getMethod()) |
|
58 | + { |
|
56 | 59 | case 'POST': |
57 | 60 | $result = Requests::post($url, $header, $this->payLoad); |
58 | 61 | break; |
@@ -73,7 +76,8 @@ discard block |
||
73 | 76 | |
74 | 77 | http_response_code($result->status_code); |
75 | 78 | |
76 | - switch ($result->status_code) { |
|
79 | + switch ($result->status_code) |
|
80 | + { |
|
77 | 81 | case 200: |
78 | 82 | $result = json_decode($result->body, true); |
79 | 83 | break; |
@@ -163,10 +167,12 @@ discard block |
||
163 | 167 | */ |
164 | 168 | private function getSignHeaders() |
165 | 169 | { |
166 | - if($this->getAccessToken() == null) { |
|
170 | + if($this->getAccessToken() == null) |
|
171 | + { |
|
167 | 172 | $payload_accessToken = ""; |
168 | 173 | } |
169 | - else { |
|
174 | + else |
|
175 | + { |
|
170 | 176 | $payload_accessToken = $this->getAccessToken(); |
171 | 177 | } |
172 | 178 |
@@ -97,7 +97,9 @@ discard block |
||
97 | 97 | } ?> |
98 | 98 | </content> |
99 | 99 | |
100 | - <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) { ?> |
|
100 | + <?php if(!isset($_GET['postId']) && !isset($_GET['getPostDetails'])) |
|
101 | +{ |
|
102 | +?> |
|
101 | 103 | <p id="loading"> |
102 | 104 | Loading… |
103 | 105 | </p> |
@@ -105,12 +107,20 @@ discard block |
||
105 | 107 | </article> |
106 | 108 | |
107 | 109 | <aside class="topSidebar col-sm-4 sidebar-outer"> |
108 | - <div class="fixed<?php if(!$view->isDetailedView) echo(' hide-mobile');?>"> |
|
110 | + <div class="fixed<?php if(!$view->isDetailedView) |
|
111 | +{ |
|
112 | + echo(' hide-mobile'); |
|
113 | +} |
|
114 | +?>"> |
|
109 | 115 | <article> |
110 | 116 | <div> |
111 | 117 | <h2>Position / Hashtag</h2> |
112 | 118 | <form action="index.php" method="get"> |
113 | - <input type="text" id="city" name="search" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required> |
|
119 | + <input type="text" id="city" name="search" placeholder="<?php if(isset($newPositionStatus)) |
|
120 | +{ |
|
121 | + echo $newPositionStatus; |
|
122 | +} |
|
123 | +?>" required> |
|
114 | 124 | <label>try: #jhj</label><br> |
115 | 125 | <input type="submit" value="Set Location" /> |
116 | 126 | </form> |
@@ -127,7 +137,7 @@ discard block |
||
127 | 137 | <article> |
128 | 138 | <div> |
129 | 139 | <?php if(!$jodelAccountForView->isAccountVerified()) |
130 | - { |
|
140 | +{ |
|
131 | 141 | ?> |
132 | 142 | <h2>New Jodel</h2> |
133 | 143 | |
@@ -137,7 +147,9 @@ discard block |
||
137 | 147 | } |
138 | 148 | else |
139 | 149 | { |
140 | - if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) { ?> |
|
150 | + if(isset($_GET['postId']) && isset($_GET['getPostDetails'])) |
|
151 | + { |
|
152 | +?> |
|
141 | 153 | <h2>Comment on Jodel</h2> |
142 | 154 | <form enctype="multipart/form-data" method="POST"> |
143 | 155 | <input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postId']);?>" /> |
@@ -146,7 +158,10 @@ discard block |
||
146 | 158 | <input name="image" type="file" /> |
147 | 159 | <input type="submit" value="SEND" /> |
148 | 160 | </form> |
149 | - <?php } else { ?> |
|
161 | + <?php } |
|
162 | +else |
|
163 | +{ |
|
164 | +?> |
|
150 | 165 | <h2>New Jodel</h2> |
151 | 166 | <form enctype="multipart/form-data" method="POST"> |
152 | 167 | <textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> |