Completed
Push — master ( 45769d...0479fb )
by mains
02:43
created
get-posts-ajax.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,8 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +52 added lines, -17 removed lines patch added patch discarded remove patch
@@ -35,7 +35,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>
@@ -398,7 +431,9 @@  discard block
 block discarded – undo
398 431
 			}
399 432
 
400 433
 
401
-			<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
434
+			<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
435
+{
436
+?>
402 437
 			$(document).ready(function() {
403 438
 				var win = $(window);
404 439
 				var lastPostId = "<?php echo $lastPostId; ?>";
Please login to merge, or discard this patch.
php/jodel-web.php 1 patch
Braces   +28 added lines, -13 removed lines patch added patch discarded remove patch
@@ -18,14 +18,16 @@  discard block
 block discarded – undo
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
 	
25 26
 	if ($result->num_rows > 0)
26 27
 	{
27 28
 			// output data of each row
28
-			while($row = $result->fetch_assoc()) {
29
+			while($row = $result->fetch_assoc())
30
+			{
29 31
 					//$access_token = $row["access_token"];
30 32
 					$expiration_date = $row["expiration_date"];
31 33
 					$deviceUid = $row["device_uid"];
@@ -37,7 +39,8 @@  discard block
 block discarded – undo
37 39
 			echo '0 results';
38 40
 	}
39 41
 
40
-	if($expiration_date <= time()) {
42
+	if($expiration_date <= time())
43
+	{
41 44
 		$accountCreator = new CreateUser();
42 45
 		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
43 46
 		$accountCreator->setDeviceUid($deviceUid);
@@ -54,7 +57,8 @@  discard block
 block discarded – undo
54 57
 									expiration_date='" . $expiration_date . "'
55 58
 								WHERE device_uid='" . $device_uid . "'");
56 59
 
57
-		if($result === false){
60
+		if($result === false)
61
+		{
58 62
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
59 63
 		}	
60 64
 	}
@@ -71,7 +75,8 @@  discard block
 block discarded – undo
71 75
 	return $data["karma"];
72 76
 }
73 77
 
74
-function registerAccount(Location $location) {
78
+function registerAccount(Location $location)
79
+{
75 80
 	$accountCreator = new CreateUser();
76 81
 	$accountCreator->setLocation($location);
77 82
 	$data = $accountCreator->execute();
@@ -96,7 +101,8 @@  discard block
 block discarded – undo
96 101
 					"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
97 102
 
98 103
 	$success = TRUE;
99
-	if($result === false){
104
+	if($result === false)
105
+	{
100 106
 			$error = db_error();
101 107
 			echo $error;
102 108
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
@@ -107,7 +113,7 @@  discard block
 block discarded – undo
107 113
 }
108 114
 
109 115
 function getPosts($lastPostId, $accessToken, $url)
110
-{	
116
+{
111 117
 	$accountCreator = new GetPosts();
112 118
 	$accountCreator->setLastPostId($lastPostId);
113 119
 	$accountCreator->setAccessToken($accessToken);
@@ -128,7 +134,8 @@  discard block
 block discarded – undo
128 134
 }
129 135
 
130 136
 function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE)
131
-{	//ToDO
137
+{
138
+//ToDO
132 139
 	//Replace # with link
133 140
 	//preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
134 141
 
@@ -179,10 +186,12 @@  discard block
 block discarded – undo
179 186
 	<article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;">
180 187
 		<content>
181 188
 			<?php 
182
-			if(isset($post["image_url"])) {
189
+			if(isset($post["image_url"]))
190
+			{
183 191
 				echo '<img src="' . $post["image_url"] . '">';
184 192
 			}
185
-			else {
193
+			else
194
+			{
186 195
 				echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post["message"])));
187 196
 			}
188 197
 			?>
@@ -208,13 +217,19 @@  discard block
 block discarded – undo
208 217
 						</span> 
209 218
 					</td>
210 219
 					<td class="comments">
211
-						<?php if(!$isDetailedView) {?>
220
+						<?php if(!$isDetailedView)
221
+{
222
+?>
212 223
 						<span data-tooltip="Comments">
213 224
 							<a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
214 225
 								<i class="fa fa-commenting-o"></i>
215
-								<?php if(array_key_exists("child_count", $post)) {
226
+								<?php if(array_key_exists("child_count", $post))
227
+{
216 228
 											echo $post["child_count"];
217
-										} else echo "0";
229
+										}
230
+										else {
231
+											echo "0";
232
+										}
218 233
 								?>
219 234
 								</a>
220 235
 						</span>
Please login to merge, or discard this patch.