Completed
Pull Request — master (#10)
by
unknown
02:49
created
index.php 1 patch
Braces   +46 added lines, -13 removed lines patch added patch discarded remove patch
@@ -61,7 +61,8 @@  discard block
 block discarded – undo
61 61
 	//Set View
62 62
 	if(isset($_GET['view']))
63 63
 	{
64
-		switch ($_GET['view']) {
64
+		switch ($_GET['view'])
65
+		{
65 66
 			case 'comment':
66 67
 				$view = 'comment';
67 68
 				break;
@@ -81,7 +82,8 @@  discard block
 block discarded – undo
81 82
 	}
82 83
 	
83 84
 	//Set Location
84
-	if(isset($_GET['city'])) {
85
+	if(isset($_GET['city']))
86
+	{
85 87
 		$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
86 88
 		$result = Requests::post($url);
87 89
 		if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
@@ -165,7 +167,8 @@  discard block
 block discarded – undo
165 167
 		if(isset($_POST['color']))
166 168
 		{
167 169
 			$color = $_POST['color'];
168
-			switch ($color) {
170
+			switch ($color)
171
+			{
169 172
 				case '8ABDB0':
170 173
 					$color = '8ABDB0';
171 174
 					break;
@@ -292,7 +295,11 @@  discard block
 block discarded – undo
292 295
 
293 296
 					<div id="location_mobile" class="hidden-sm-up">
294 297
 						<form method="get">
295
-							<input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
298
+							<input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus))
299
+{
300
+	echo $newPositionStatus;
301
+}
302
+?>" required>
296 303
 
297 304
 							<input type="submit" id="submit_mobile" class="fa" value="&#xf0ac;" />
298 305
 						</form>
@@ -319,7 +326,8 @@  discard block
 block discarded – undo
319 326
 								$data = $accountCreator->execute();
320 327
 								
321 328
 								$posts[0] = $data;
322
-								if(array_key_exists('children', $data)) {
329
+								if(array_key_exists('children', $data))
330
+								{
323 331
 									foreach($data['children'] as $key => $child)
324 332
 									{
325 333
 										
@@ -393,7 +401,9 @@  discard block
 block discarded – undo
393 401
 
394 402
 					</content>
395 403
 					
396
-					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
404
+					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
405
+{
406
+?>
397 407
 						<p id="loading">
398 408
 							Loading…
399 409
 						</p>
@@ -406,7 +416,11 @@  discard block
 block discarded – undo
406 416
 							<div>
407 417
 								<h2>Position</h2>
408 418
 								<form method="get">
409
-									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
419
+									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus))
420
+{
421
+	echo $newPositionStatus;
422
+}
423
+?>" required>
410 424
 
411 425
 									<input type="submit" value="Set Location" /> 
412 426
 								</form>
@@ -422,7 +436,9 @@  discard block
 block discarded – undo
422 436
 
423 437
 						<article>
424 438
 							<div>
425
-								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
439
+								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
440
+{
441
+?>
426 442
 								<h2>Comment on Jodel</h2>
427 443
 								<form method="POST">				
428 444
 										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
@@ -430,7 +446,10 @@  discard block
 block discarded – undo
430 446
 									<br />
431 447
 									<input type="submit" value="SEND" /> 
432 448
 								</form>
433
-									<?php } else { ?>
449
+									<?php }
450
+else
451
+{
452
+?>
434 453
 								<h2>New Jodel</h2>
435 454
 								<form method="POST">
436 455
 									<textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> 
@@ -462,13 +481,25 @@  discard block
 block discarded – undo
462 481
 				<div class="col-xs-12">
463 482
 					<div class="row">
464 483
 						<div class="col-xs-3">
465
-							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
484
+							<a href="index.php" <?php if($view=='time')
485
+{
486
+	echo 'class="active"';
487
+}
488
+?>><i class="fa fa-clock-o fa-3x"></i></a>
466 489
 						</div>
467 490
 						<div class="col-xs-3">
468
-							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
491
+							<a href="index.php?view=comment" <?php if($view=='comment')
492
+{
493
+	echo 'class="active"';
494
+}
495
+?>><i class="fa fa-commenting-o fa-3x"></i></a>
469 496
 						</div>
470 497
 						<div class="col-xs-3">
471
-							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
498
+							<a href="index.php?view=upVote" <?php if($view=='upVote')
499
+{
500
+	echo 'class="active"';
501
+}
502
+?>><i class="fa fa-angle-up fa-3x"></i></a>
472 503
 						</div>
473 504
 						<div class="col-xs-3">
474 505
 							<nav>
@@ -511,7 +542,9 @@  discard block
 block discarded – undo
511 542
 				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
512 543
 				}
513 544
 
514
-				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
545
+				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
546
+{
547
+?>
515 548
 
516 549
 				
517 550
 
Please login to merge, or discard this patch.
php/Requests/AbstractRequest.php 1 patch
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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 = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG';
@@ -19,7 +19,8 @@  discard block
 block discarded – undo
19 19
 		        
20 20
 		$this->payLoad = $this->getPayload();
21 21
 		$device_uid = '';
22
-		if(isset($this->payLoad['device_uid'])) {
22
+		if(isset($this->payLoad['device_uid']))
23
+		{
23 24
 			$device_uid = $this->payLoad['device_uid'];
24 25
 		}
25 26
 				
@@ -28,7 +29,8 @@  discard block
 block discarded – undo
28 29
         $header = $this->getSignHeaders();
29 30
         $url = $this->getFullUrl();
30 31
 
31
-        if ($this->getAccessToken()) {
32
+        if ($this->getAccessToken())
33
+        {
32 34
             $header['Authorization'] = "Bearer " . $this->getAccessToken();
33 35
         }
34 36
         //Comment out to debug the Request:
@@ -45,7 +47,8 @@  discard block
 block discarded – undo
45 47
             'proxy' => '186.103.169.165:8080',
46 48
         );*/
47 49
 
48
-        switch ($this->getMethod()) {
50
+        switch ($this->getMethod())
51
+        {
49 52
             case 'POST':
50 53
                 $result = Requests::post($url, $header, $this->payLoad);
51 54
                 break;
@@ -63,7 +66,8 @@  discard block
 block discarded – undo
63 66
                 $result = Requests::put($url, $header, $this->payLoad);
64 67
                 break;
65 68
         }
66
-        switch ($result->status_code) {
69
+        switch ($result->status_code)
70
+        {
67 71
             case 200:
68 72
                 $result = json_decode($result->body, true);
69 73
                 break;
@@ -114,10 +118,12 @@  discard block
 block discarded – undo
114 118
      */
115 119
     private function getSignHeaders()
116 120
     {
117
-			if($this->getAccessToken() == null) {
121
+			if($this->getAccessToken() == null)
122
+			{
118 123
 				$payload_accessToken = "";
119 124
 			}
120
-			else {
125
+			else
126
+			{
121 127
 				$payload_accessToken = $this->getAccessToken();
122 128
 			}
123 129
 			
Please login to merge, or discard this patch.
php/jodel-web.php 1 patch
Braces   +50 added lines, -25 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@  discard block
 block discarded – undo
43 43
 	if ($result->num_rows > 0)
44 44
 	{
45 45
 			// output data of each row
46
-			while($row = $result->fetch_assoc()) {
46
+			while($row = $result->fetch_assoc())
47
+			{
47 48
 					//$access_token = $row["access_token"];
48 49
 					$expiration_date = $row["expiration_date"];
49 50
 					$deviceUid = $row["device_uid"];
@@ -55,7 +56,8 @@  discard block
 block discarded – undo
55 56
 			echo '0 results';
56 57
 	}
57 58
 
58
-	if($expiration_date <= time()) {
59
+	if($expiration_date <= time())
60
+	{
59 61
 		$accountCreator = new CreateUser();
60 62
 		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
61 63
 		$accountCreator->setDeviceUid($deviceUid);
@@ -72,7 +74,8 @@  discard block
 block discarded – undo
72 74
 									expiration_date='" . $expiration_date . "'
73 75
 								WHERE device_uid='" . $device_uid . "'");
74 76
 
75
-		if($result === false){
77
+		if($result === false)
78
+		{
76 79
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
77 80
 		}	
78 81
 	}
@@ -88,7 +91,8 @@  discard block
 block discarded – undo
88 91
 	if ($result->num_rows > 0)
89 92
 	{
90 93
 			// output data of each row
91
-			while($row = $result->fetch_assoc()) {
94
+			while($row = $result->fetch_assoc())
95
+			{
92 96
 					//$access_token = $row["access_token"];
93 97
 					$expiration_date = $row["expiration_date"];
94 98
 					$deviceUid = $row["device_uid"];
@@ -100,7 +104,8 @@  discard block
 block discarded – undo
100 104
 			echo '0 results';
101 105
 	}
102 106
 
103
-	if($expiration_date <= time()) {
107
+	if($expiration_date <= time())
108
+	{
104 109
 		$accountCreator = new CreateUser();
105 110
 		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
106 111
 		$accountCreator->setDeviceUid($deviceUid);
@@ -117,7 +122,8 @@  discard block
 block discarded – undo
117 122
 									expiration_date='" . $expiration_date . "'
118 123
 								WHERE device_uid='" . $device_uid . "'");
119 124
 
120
-		if($result === false){
125
+		if($result === false)
126
+		{
121 127
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
122 128
 		}	
123 129
 	}
@@ -135,7 +141,8 @@  discard block
 block discarded – undo
135 141
 	if ($result->num_rows > 0)
136 142
 	{
137 143
 			// output data of each row
138
-			while($row = $result->fetch_assoc()) {
144
+			while($row = $result->fetch_assoc())
145
+			{
139 146
 					//$access_token = $row["access_token"];
140 147
 					$expiration_date = $row["expiration_date"];
141 148
 					$deviceUid = $row["device_uid"];
@@ -147,7 +154,8 @@  discard block
 block discarded – undo
147 154
 			echo '0 results';
148 155
 	}
149 156
 
150
-	if($expiration_date <= time()) {
157
+	if($expiration_date <= time())
158
+	{
151 159
 		$accountCreator = new CreateUser();
152 160
 		$accountCreator->setAccessToken($access_token);
153 161
 		$accountCreator->setDeviceUid($deviceUid);
@@ -164,7 +172,8 @@  discard block
 block discarded – undo
164 172
 									expiration_date='" . $expiration_date . "'
165 173
 								WHERE device_uid='" . $device_uid . "'");
166 174
 
167
-		if($result === false){
175
+		if($result === false)
176
+		{
168 177
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
169 178
 		}	
170 179
 	}
@@ -320,14 +329,16 @@  discard block
 block discarded – undo
320 329
 	$result = $db->query("INSERT INTO votes (device_uid, postId, type)
321 330
 					VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')");
322 331
 	
323
-	if($result === false){
332
+	if($result === false)
333
+	{
324 334
 			$error = db_error();
325 335
 			echo $error;
326 336
 			echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
327 337
 	}		
328 338
 }
329 339
 
330
-function registerAccount(Location $location) {
340
+function registerAccount(Location $location)
341
+{
331 342
 	$accountCreator = new CreateUser();
332 343
 	$accountCreator->setLocation($location);
333 344
 	$data = $accountCreator->execute();
@@ -352,7 +363,8 @@  discard block
 block discarded – undo
352 363
 					"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
353 364
 
354 365
 	$success = TRUE;
355
-	if($result === false){
366
+	if($result === false)
367
+	{
356 368
 			$error = db_error();
357 369
 			echo $error;
358 370
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
@@ -363,7 +375,7 @@  discard block
 block discarded – undo
363 375
 }
364 376
 
365 377
 function getPosts($lastPostId, $accessToken, $url, $version = 'v2')
366
-{	
378
+{
367 379
 	$accountCreator = new GetPosts();
368 380
 	$accountCreator->setLastPostId($lastPostId);
369 381
 	$accountCreator->setAccessToken($accessToken);
@@ -414,7 +426,8 @@  discard block
 block discarded – undo
414 426
 }
415 427
 
416 428
 function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE)
417
-{	//ToDO
429
+{
430
+//ToDO
418 431
 	//Replace # with link
419 432
 	//preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
420 433
 
@@ -464,10 +477,12 @@  discard block
 block discarded – undo
464 477
 	<article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;">
465 478
 		<content>
466 479
 			<?php 
467
-			if(isset($post["image_url"])) {
480
+			if(isset($post["image_url"]))
481
+			{
468 482
 				echo '<img src="' . $post["image_url"] . '">';
469 483
 			}
470
-			else {
484
+			else
485
+			{
471 486
 				echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post["message"])));
472 487
 			}
473 488
 			?>
@@ -475,11 +490,13 @@  discard block
 block discarded – undo
475 490
 		<aside>
476 491
 			<?php
477 492
 				if($isDetailedView)
478
-				{?>
493
+				{
494
+?>
479 495
 					<a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>">
480 496
 		  <?php }
481
-				else
482
-				{?>
497
+else
498
+				{
499
+?>
483 500
 					<a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>">
484 501
 		  <?php } ?>
485 502
 						<i class="fa fa-angle-up fa-3x"></i>
@@ -488,11 +505,13 @@  discard block
 block discarded – undo
488 505
 					<?php echo $post["vote_count"];?><br />
489 506
 			<?php
490 507
 				if($isDetailedView)
491
-				{?>
508
+				{
509
+?>
492 510
 					<a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>">
493 511
 		  <?php }
494
-				else
495
-				{?>
512
+else
513
+				{
514
+?>
496 515
 					<a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>">
497 516
 		  <?php } ?>
498 517
 						<i class="fa fa-angle-down fa-3x"></i>
@@ -510,13 +529,19 @@  discard block
 block discarded – undo
510 529
 						</span> 
511 530
 					</td>
512 531
 					<td class="comments">
513
-						<?php if(!$isDetailedView) {?>
532
+						<?php if(!$isDetailedView)
533
+{
534
+?>
514 535
 						<span data-tooltip="Comments">
515 536
 							<a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
516 537
 								<i class="fa fa-commenting-o"></i>
517
-								<?php if(array_key_exists("child_count", $post)) {
538
+								<?php if(array_key_exists("child_count", $post))
539
+{
518 540
 											echo $post["child_count"];
519
-										} else echo "0";
541
+										}
542
+										else {
543
+											echo "0";
544
+										}
520 545
 								?>
521 546
 								</a>
522 547
 						</span>
Please login to merge, or discard this patch.