Completed
Push — master ( ae0f54...3a96c8 )
by mains
02:54
created
php/jodel-web.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			}
108 108
 			else
109 109
 			{
110
-				error_log('User with JodelDeviceId:' . $deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
110
+				error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
111 111
 			}
112 112
 		}
113 113
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	if(isset($_POST['color']))
170 170
 	{
171 171
 		$color = $_POST['color'];
172
-		switch ($color) {
172
+		switch($color) {
173 173
 			case '8ABDB0':
174 174
 				$color = '8ABDB0';
175 175
 				break;
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 function isDeviceUidInDatabase($deviceUid)
222 222
 {
223 223
 	$db = new DatabaseConnect();  
224
-	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
224
+	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'");
225 225
 
226
-	if ($result->num_rows > 0)
226
+	if($result->num_rows > 0)
227 227
 	{
228 228
 		return TRUE;
229 229
 	}
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	
241 241
 	$access_token;
242 242
 
243
-	if ($result->num_rows > 0)
243
+	if($result->num_rows > 0)
244 244
 	{
245 245
 			// output data of each row
246 246
 			while($row = $result->fetch_assoc()) {
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
 	if($expiration_date <= time()) {
259 259
 		$accountCreator = new CreateUser();
260
-		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
260
+		$accountCreator->setAccessToken($access_token); //$accountData->getAccessToken());
261 261
 		$accountCreator->setDeviceUid($deviceUid);
262 262
 		$accountCreator->setLocation($location);
263 263
 		$data = $accountCreator->execute();
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 									expiration_date='" . $expiration_date . "'
273 273
 								WHERE device_uid='" . $device_uid . "'");
274 274
 
275
-		if($result === false){
275
+		if($result === false) {
276 276
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
277 277
 		}	
278 278
 	}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	$db = new DatabaseConnect();  
286 286
 	$result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'");
287 287
 	
288
-	if ($result->num_rows > 0)
288
+	if($result->num_rows > 0)
289 289
 	{
290 290
 			// output data of each row
291 291
 			while($row = $result->fetch_assoc()) {
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 	if($expiration_date <= time()) {
304 304
 		$accountCreator = new CreateUser();
305
-		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
305
+		$accountCreator->setAccessToken($access_token); //$accountData->getAccessToken());
306 306
 		$accountCreator->setDeviceUid($deviceUid);
307 307
 		$accountCreator->setLocation($location);
308 308
 		$data = $accountCreator->execute();
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 									expiration_date='" . $expiration_date . "'
318 318
 								WHERE device_uid='" . $device_uid . "'");
319 319
 
320
-		if($result === false){
320
+		if($result === false) {
321 321
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
322 322
 		}	
323 323
 	}
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
 	$access_token;
334 334
 
335
-	if ($result->num_rows > 0)
335
+	if($result->num_rows > 0)
336 336
 	{
337 337
 			// output data of each row
338 338
 			while($row = $result->fetch_assoc()) {
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 									expiration_date='" . $expiration_date . "'
365 365
 								WHERE device_uid='" . $device_uid . "'");
366 366
 
367
-		if($result === false){
367
+		if($result === false) {
368 368
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
369 369
 		}	
370 370
 	}
@@ -375,11 +375,11 @@  discard block
 block discarded – undo
375 375
 function getLocationByAccessToken($accessToken)
376 376
 {
377 377
 	$db = new DatabaseConnect();
378
-	$result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken  . "'");
378
+	$result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'");
379 379
 	
380 380
 	$location = new Location();
381 381
 	
382
-	if ($result->num_rows > 0)
382
+	if($result->num_rows > 0)
383 383
 	{
384 384
 		// output data of each row
385 385
 		while($row = $result->fetch_assoc())
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
 function getLocationByDeviceUid($deviceUid)
401 401
 {
402 402
 	$db = new DatabaseConnect();
403
-	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
403
+	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'");
404 404
 	
405 405
 	$location = new Location();
406 406
 	
407
-	if ($result->num_rows > 0)
407
+	if($result->num_rows > 0)
408 408
 	{
409 409
 		// output data of each row
410 410
 		while($row = $result->fetch_assoc())
@@ -425,11 +425,11 @@  discard block
 block discarded – undo
425 425
 function getDeviceUidByAccessToken($accesstoken)
426 426
 {
427 427
 	$db = new DatabaseConnect();
428
-	$result = $db->query("SELECT device_uid FROM accounts WHERE access_token='" . $accesstoken  . "'");
428
+	$result = $db->query("SELECT device_uid FROM accounts WHERE access_token='" . $accesstoken . "'");
429 429
 	
430 430
 	$deviceUid;
431 431
 	
432
-	if ($result->num_rows > 0)
432
+	if($result->num_rows > 0)
433 433
 	{
434 434
 		// output data of each row
435 435
 		while($row = $result->fetch_assoc())
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
 function getAccessTokenByDeviceUid($deviceUid)
449 449
 {
450 450
 	$db = new DatabaseConnect();
451
-	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
451
+	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'");
452 452
 	
453 453
 	$accessToken;
454 454
 	
455
-	if ($result->num_rows > 0)
455
+	if($result->num_rows > 0)
456 456
 	{
457 457
 		// output data of each row
458 458
 		while($row = $result->fetch_assoc())
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 	$result = $db->query("INSERT INTO votes (device_uid, postId, type)
521 521
 					VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')");
522 522
 	
523
-	if($result === false){
523
+	if($result === false) {
524 524
 			$error = db_error();
525 525
 			echo $error;
526 526
 			echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
@@ -548,11 +548,11 @@  discard block
 block discarded – undo
548 548
 	$result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
549 549
 					expires_in, expiration_date, distinct_id, device_uid, name, lat, lng)
550 550
 					VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type .
551
-					"','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
551
+					"','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id .
552 552
 					"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
553 553
 
554 554
 	$success = TRUE;
555
-	if($result === false){
555
+	if($result === false) {
556 556
 			$error = db_error();
557 557
 			echo $error;
558 558
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 {
599 599
 	preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
600 600
 
601
-    return (isset($matches[0])) ? true : false;
601
+    return (isset($matches[0]))?true : false;
602 602
 }
603 603
 
604 604
 function botDeviceUidIsSet($config)
@@ -667,25 +667,25 @@  discard block
 block discarded – undo
667 667
 	$timediff_inDays = (string)$timediff->format('%d');
668 668
 	$timediff_inMonth = (string)$timediff->format('%m');
669 669
 
670
-	if($timediff_inMonth!=0)
670
+	if($timediff_inMonth != 0)
671 671
 	{
672 672
 			$timediff = $timediff_inMonth . "m";
673 673
 	}
674 674
 	else
675 675
 	{
676
-		if($timediff_inDays!=0)
676
+		if($timediff_inDays != 0)
677 677
 		{
678 678
 			$timediff = $timediff_inDays . "d";
679 679
 		}
680 680
 		else
681 681
 		{
682
-			if($timediff_inHours!=0)
682
+			if($timediff_inHours != 0)
683 683
 			{
684 684
 				$timediff = $timediff_inHours . "h";
685 685
 			}
686 686
 			else
687 687
 			{
688
-				if($timediff_inMinutes!=0)
688
+				if($timediff_inMinutes != 0)
689 689
 				{
690 690
 					$timediff = $timediff_inMinutes . "m";
691 691
 				}
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 
700 700
 
701 701
 	?>
702
-	<article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color'];?>;">
702
+	<article id ="postId-<?php echo $post['post_id']; ?>" class="jodel" style="background-color: #<?php echo $post['color']; ?>;">
703 703
 		<content>
704 704
 			<?php 
705 705
 			if(isset($post['image_url']))
@@ -717,24 +717,24 @@  discard block
 block discarded – undo
717 717
 			<?php
718 718
 				if($isDetailedView)
719 719
 				{?>
720
-					<a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
720
+					<a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>" rel="nofollow">
721 721
 		  <?php }
722 722
 				else
723 723
 				{?>
724
-					<a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow">
724
+					<a href="index.php?vote=up&postID=<?php echo $post['post_id']; ?>" rel="nofollow">
725 725
 		  <?php } ?>
726 726
 						<i class="fa fa-angle-up fa-3x"></i>
727 727
 					</a>	
728 728
 						<br />
729
-					<?php echo $post["vote_count"];?><br />
729
+					<?php echo $post["vote_count"]; ?><br />
730 730
 			<?php
731 731
 				if($isDetailedView)
732 732
 				{?>
733
-					<a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
733
+					<a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>" rel="nofollow">
734 734
 		  <?php }
735 735
 				else
736 736
 				{?>
737
-					<a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow">
737
+					<a href="index.php?vote=down&postID=<?php echo $post['post_id']; ?>" rel="nofollow">
738 738
 		  <?php } ?>
739 739
 						<i class="fa fa-angle-down fa-3x"></i>
740 740
 					</a>
@@ -746,14 +746,14 @@  discard block
 block discarded – undo
746 746
 					<td class="time">
747 747
 						<span class="tip" data-tooltip="Time">
748 748
 							<i class="fa fa-clock-o"></i>
749
-							<?php echo $timediff;?>
750
-							<span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span>
749
+							<?php echo $timediff; ?>
750
+							<span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span>
751 751
 						</span> 
752 752
 					</td>
753 753
 					<td class="comments">
754 754
 						<?php if(!$isDetailedView) {?>
755 755
 						<span data-tooltip="Comments">
756
-							<a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
756
+							<a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $post["post_id"]; ?>">
757 757
 								<i class="fa fa-commenting-o"></i>
758 758
 								<?php if(array_key_exists("child_count", $post)) {
759 759
 											echo $post["child_count"];
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 									{
783 783
 							  			?>
784 784
 							  			<span data-tooltip="Author">
785
-											<i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> |
785
+											<i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> |
786 786
 										</span>
787 787
 										<?php
788 788
 									}
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 
793 793
 						<span class="tip" data-tooltip="Distance">
794 794
 							<i class="fa fa-map-marker"></i>
795
-							<?php echo $post['distance'];?> km
796
-							<span class="tiptext"><?php echo $post['location']['name'];?></span>
795
+							<?php echo $post['distance']; ?> km
796
+							<span class="tiptext"><?php echo $post['location']['name']; ?></span>
797 797
 						</span>
798 798
 					</td>
799 799
 				</tr>
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 		if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($_COOKIE['JodelDeviceId']))
37 37
 		{
38 38
 			$deviceUid = createAccount();
39
-			setcookie('JodelDeviceId', $deviceUid, time()+60*60*24*365*10);
40
-			error_log('Created account with JodelDeviceId:' . $deviceUid .  ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
39
+			setcookie('JodelDeviceId', $deviceUid, time() + 60 * 60 * 24 * 365 * 10);
40
+			error_log('Created account with JodelDeviceId:' . $deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
41 41
 			
42 42
 		}
43 43
 		else
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	//Set View
58 58
 	if(isset($_GET['view']))
59 59
 	{
60
-		switch ($_GET['view']) {
60
+		switch($_GET['view']) {
61 61
 			case 'comment':
62 62
 				$view = 'comment';
63 63
 				break;
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 	else
146 146
 	{
147 147
 		$version = 'v2';
148
-		if($view=='comment')
148
+		if($view == 'comment')
149 149
 		{
150 150
 			$url = "/v2/posts/location/discussed/";
151 151
 		}
152 152
 		else
153 153
 		{
154
-			if($view=='upVote')
154
+			if($view == 'upVote')
155 155
 			{
156 156
 				$url = "/v2/posts/location/popular/";
157 157
 			}
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
 <!DOCTYPE html>
178 178
 <html lang="en">
179 179
 	<head>
180
-		<title><?php echo getTitle($posts[0], $view, $isDetailedView);?></title>
180
+		<title><?php echo getTitle($posts[0], $view, $isDetailedView); ?></title>
181 181
 		
182 182
 		<meta charset="utf-8">
183 183
 		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
184 184
 		<meta http-equiv="x-ua-compatible" content="ie=edge">
185 185
 		
186
-		<meta name="description" content="<?php echo getMetaDescription($posts[0], $view, $isDetailedView);?>">
186
+		<meta name="description" content="<?php echo getMetaDescription($posts[0], $view, $isDetailedView); ?>">
187 187
 		<meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app">
188 188
 		
189 189
 		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
 					<content id="posts">
266 266
 						<?php
267
-							for($i = 0; $i<$loops; $i++)
267
+							for($i = 0; $i < $loops; $i++)
268 268
 							{
269 269
 								if(array_key_exists($i, $posts) && array_key_exists('post_id', $posts[$i]) && isset($posts[$i]['post_id']))
270 270
 								{
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
309 309
 								<h2>Comment on Jodel</h2>
310 310
 								<form method="POST">				
311
-										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
311
+										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" />
312 312
 										<textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> 
313 313
 									<br />
314 314
 									<input type="submit" value="SEND" /> 
@@ -345,13 +345,13 @@  discard block
 block discarded – undo
345 345
 				<div class="col-xs-12">
346 346
 					<div class="row">
347 347
 						<div class="col-xs-3">
348
-							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
348
+							<a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a>
349 349
 						</div>
350 350
 						<div class="col-xs-3">
351
-							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
351
+							<a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a>
352 352
 						</div>
353 353
 						<div class="col-xs-3">
354
-							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
354
+							<a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a>
355 355
 						</div>
356 356
 						<div class="col-xs-3">
357 357
 							<nav>
Please login to merge, or discard this patch.