Completed
Push — master ( 277882...5162b8 )
by mains
10s
created
php/jodel-web.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 function isDeviceUidInDatabase($deviceUid)
22 22
 {
23 23
 	$db = new DatabaseConnect();  
24
-	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
24
+	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'");
25 25
 	
26 26
 	$access_token;
27 27
 
28
-	if ($result->num_rows > 0)
28
+	if($result->num_rows > 0)
29 29
 	{
30 30
 		return TRUE;
31 31
 	}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	
43 43
 	$access_token;
44 44
 
45
-	if ($result->num_rows > 0)
45
+	if($result->num_rows > 0)
46 46
 	{
47 47
 			// output data of each row
48 48
 			while($row = $result->fetch_assoc()) {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
 	if($expiration_date <= time()) {
61 61
 		$accountCreator = new CreateUser();
62
-		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
62
+		$accountCreator->setAccessToken($access_token); //$accountData->getAccessToken());
63 63
 		$accountCreator->setDeviceUid($deviceUid);
64 64
 		$accountCreator->setLocation($location);
65 65
 		$data = $accountCreator->execute();
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 									expiration_date='" . $expiration_date . "'
75 75
 								WHERE device_uid='" . $device_uid . "'");
76 76
 
77
-		if($result === false){
77
+		if($result === false) {
78 78
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
79 79
 		}	
80 80
 	}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	$db = new DatabaseConnect();  
88 88
 	$result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'");
89 89
 	
90
-	if ($result->num_rows > 0)
90
+	if($result->num_rows > 0)
91 91
 	{
92 92
 			// output data of each row
93 93
 			while($row = $result->fetch_assoc()) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
 	if($expiration_date <= time()) {
106 106
 		$accountCreator = new CreateUser();
107
-		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
107
+		$accountCreator->setAccessToken($access_token); //$accountData->getAccessToken());
108 108
 		$accountCreator->setDeviceUid($deviceUid);
109 109
 		$accountCreator->setLocation($location);
110 110
 		$data = $accountCreator->execute();
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 									expiration_date='" . $expiration_date . "'
120 120
 								WHERE device_uid='" . $device_uid . "'");
121 121
 
122
-		if($result === false){
122
+		if($result === false) {
123 123
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
124 124
 		}	
125 125
 	}
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 	$access_token;
136 136
 
137
-	if ($result->num_rows > 0)
137
+	if($result->num_rows > 0)
138 138
 	{
139 139
 			// output data of each row
140 140
 			while($row = $result->fetch_assoc()) {
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 									expiration_date='" . $expiration_date . "'
167 167
 								WHERE device_uid='" . $device_uid . "'");
168 168
 
169
-		if($result === false){
169
+		if($result === false) {
170 170
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
171 171
 		}	
172 172
 	}
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 function getLocationByAccessToken($accessToken)
178 178
 {
179 179
 	$db = new DatabaseConnect();
180
-	$result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken  . "'");
180
+	$result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'");
181 181
 	
182 182
 	$location = new Location();
183 183
 	
184
-	if ($result->num_rows > 0)
184
+	if($result->num_rows > 0)
185 185
 	{
186 186
 		// output data of each row
187 187
 		while($row = $result->fetch_assoc())
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 function getLocationByDeviceUid($deviceUid)
203 203
 {
204 204
 	$db = new DatabaseConnect();
205
-	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
205
+	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'");
206 206
 	
207 207
 	$location = new Location();
208 208
 	
209
-	if ($result->num_rows > 0)
209
+	if($result->num_rows > 0)
210 210
 	{
211 211
 		// output data of each row
212 212
 		while($row = $result->fetch_assoc())
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 function getDeviceUidByAccessToken($accesstoken)
228 228
 {
229 229
 	$db = new DatabaseConnect();
230
-	$result = $db->query("SELECT device_uid FROM accounts WHERE access_token='" . $accesstoken  . "'");
230
+	$result = $db->query("SELECT device_uid FROM accounts WHERE access_token='" . $accesstoken . "'");
231 231
 	
232 232
 	$deviceUid;
233 233
 	
234
-	if ($result->num_rows > 0)
234
+	if($result->num_rows > 0)
235 235
 	{
236 236
 		// output data of each row
237 237
 		while($row = $result->fetch_assoc())
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 function getAccessTokenByDeviceUid($deviceUid)
251 251
 {
252 252
 	$db = new DatabaseConnect();
253
-	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
253
+	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'");
254 254
 	
255 255
 	$accessToken;
256 256
 	
257
-	if ($result->num_rows > 0)
257
+	if($result->num_rows > 0)
258 258
 	{
259 259
 		// output data of each row
260 260
 		while($row = $result->fetch_assoc())
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	$result = $db->query("INSERT INTO votes (device_uid, postId)
287 287
 					VALUES ('" . $device_uid . "','" . $postId . "') ");
288 288
 	
289
-	if($result === false){
289
+	if($result === false) {
290 290
 			$error = db_error();
291 291
 			echo $error;
292 292
 			echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 	$result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
316 316
 					expires_in, expiration_date, distinct_id, device_uid, name, lat, lng)
317 317
 					VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type .
318
-					"','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
318
+					"','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id .
319 319
 					"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
320 320
 
321 321
 	$success = TRUE;
322
-	if($result === false){
322
+	if($result === false) {
323 323
 			$error = db_error();
324 324
 			echo $error;
325 325
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 {
366 366
 	preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
367 367
 
368
-    return (isset($matches[0])) ? true : false;
368
+    return (isset($matches[0]))?true : false;
369 369
 }
370 370
 
371 371
 function botDeviceUidIsSet($config)
@@ -396,25 +396,25 @@  discard block
 block discarded – undo
396 396
 	$timediff_inDays = (string)$timediff->format('%d');
397 397
 	$timediff_inMonth = (string)$timediff->format('%m');
398 398
 
399
-	if($timediff_inMonth!=0)
399
+	if($timediff_inMonth != 0)
400 400
 	{
401 401
 			$timediff = $timediff_inMonth . "m";
402 402
 	}
403 403
 	else
404 404
 	{
405
-		if($timediff_inDays!=0)
405
+		if($timediff_inDays != 0)
406 406
 		{
407 407
 			$timediff = $timediff_inDays . "d";
408 408
 		}
409 409
 		else
410 410
 		{
411
-			if($timediff_inHours!=0)
411
+			if($timediff_inHours != 0)
412 412
 			{
413 413
 				$timediff = $timediff_inHours . "h";
414 414
 			}
415 415
 			else
416 416
 			{
417
-				if($timediff_inMinutes!=0)
417
+				if($timediff_inMinutes != 0)
418 418
 				{
419 419
 					$timediff = $timediff_inMinutes . "m";
420 420
 				}
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 
429 429
 
430 430
 	?>
431
-	<article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;">
431
+	<article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"]; ?>;">
432 432
 		<content>
433 433
 			<?php 
434 434
 			if(isset($post["image_url"])) {
@@ -443,24 +443,24 @@  discard block
 block discarded – undo
443 443
 			<?php
444 444
 				if($isDetailedView)
445 445
 				{?>
446
-					<a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>">
446
+					<a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>">
447 447
 		  <?php }
448 448
 				else
449 449
 				{?>
450
-					<a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>">
450
+					<a href="index.php?vote=up&postID=<?php echo $post['post_id']; ?>">
451 451
 		  <?php } ?>
452 452
 						<i class="fa fa-angle-up fa-3x"></i>
453 453
 					</a>	
454 454
 						<br />
455
-					<?php echo $post["vote_count"];?><br />
455
+					<?php echo $post["vote_count"]; ?><br />
456 456
 			<?php
457 457
 				if($isDetailedView)
458 458
 				{?>
459
-					<a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>">
459
+					<a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id']; ?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']); ?>">
460 460
 		  <?php }
461 461
 				else
462 462
 				{?>
463
-					<a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>">
463
+					<a href="index.php?vote=down&postID=<?php echo $post['post_id']; ?>">
464 464
 		  <?php } ?>
465 465
 						<i class="fa fa-angle-down fa-3x"></i>
466 466
 					</a>
@@ -472,14 +472,14 @@  discard block
 block discarded – undo
472 472
 					<td class="time">
473 473
 						<span class="tip" data-tooltip="Time">
474 474
 							<i class="fa fa-clock-o"></i>
475
-							<?php echo $timediff;?>
476
-							<span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span>
475
+							<?php echo $timediff; ?>
476
+							<span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span>
477 477
 						</span> 
478 478
 					</td>
479 479
 					<td class="comments">
480 480
 						<?php if(!$isDetailedView) {?>
481 481
 						<span data-tooltip="Comments">
482
-							<a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
482
+							<a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $post["post_id"]; ?>">
483 483
 								<i class="fa fa-commenting-o"></i>
484 484
 								<?php if(array_key_exists("child_count", $post)) {
485 485
 											echo $post["child_count"];
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 									{
509 509
 							  			?>
510 510
 							  			<span data-tooltip="Author">
511
-											<i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> |
511
+											<i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> |
512 512
 										</span>
513 513
 										<?php
514 514
 									}
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
 
519 519
 						<span class="tip" data-tooltip="Distance">
520 520
 							<i class="fa fa-map-marker"></i>
521
-							<?php echo $post['distance'];?> km
522
-							<span class="tiptext"><?php echo $post['location']['name'];?></span>
521
+							<?php echo $post['distance']; ?> km
522
+							<span class="tiptext"><?php echo $post['location']['name']; ?></span>
523 523
 						</span>
524 524
 					</td>
525 525
 				</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
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 		if(!isset($_COOKIE['JodelDeviceId']) || !isDeviceUidInDatabase($db->real_escape_string($_COOKIE['JodelDeviceId'])))
41 41
 		{
42 42
 			$deviceUid = createAccount();
43
-			setcookie('JodelDeviceId', $deviceUid, time()+60*60*24*365*10);
44
-			error_log('Created account with JodelDeviceId:' . $deviceUid .  ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
43
+			setcookie('JodelDeviceId', $deviceUid, time() + 60 * 60 * 24 * 365 * 10);
44
+			error_log('Created account with JodelDeviceId:' . $deviceUid . ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
45 45
 			
46 46
 		}
47 47
 		else
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	//Set View
63 63
 	if(isset($_GET['view']))
64 64
 	{
65
-		switch ($_GET['view']) {
65
+		switch($_GET['view']) {
66 66
 			case 'comment':
67 67
 				$view = 'comment';
68 68
 				break;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 				else
121 121
 				{
122 122
 					$newPositionStatus = $name;
123
-					error_log('User with JodelDeviceId:' . $deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
123
+					error_log('User with JodelDeviceId:' . $deviceUid . ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
124 124
 				}
125 125
 			}
126 126
 		}
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		if(isset($_POST['color']))
168 168
 		{
169 169
 			$color = $_POST['color'];
170
-			switch ($color) {
170
+			switch($color) {
171 171
 				case '8ABDB0':
172 172
 					$color = '8ABDB0';
173 173
 					break;
@@ -353,13 +353,13 @@  discard block
 block discarded – undo
353 353
 							else
354 354
 							{
355 355
 								$version = 'v2';
356
-								if($view=='comment')
356
+								if($view == 'comment')
357 357
 								{
358 358
 									$url = "/v2/posts/location/discussed/";
359 359
 								}
360 360
 								else
361 361
 								{
362
-									if($view=='upVote')
362
+									if($view == 'upVote')
363 363
 									{
364 364
 										$url = "/v2/posts/location/popular/";
365 365
 									}
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 							}
384 384
 							
385 385
 
386
-							for($i = 0; $i<$loops; $i++)
386
+							for($i = 0; $i < $loops; $i++)
387 387
 							{
388 388
 								if(array_key_exists($i, $posts) && array_key_exists('post_id', $posts[$i]) && isset($posts[$i]['post_id']))
389 389
 								{
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
428 428
 								<h2>Comment on Jodel</h2>
429 429
 								<form method="POST">				
430
-										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
430
+										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" />
431 431
 										<textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> 
432 432
 									<br />
433 433
 									<input type="submit" value="SEND" /> 
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
 				<div class="col-xs-12">
465 465
 					<div class="row">
466 466
 						<div class="col-xs-3">
467
-							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
467
+							<a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a>
468 468
 						</div>
469 469
 						<div class="col-xs-3">
470
-							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
470
+							<a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a>
471 471
 						</div>
472 472
 						<div class="col-xs-3">
473
-							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
473
+							<a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a>
474 474
 						</div>
475 475
 						<div class="col-xs-3">
476 476
 							<nav>
Please login to merge, or discard this patch.