Completed
Push — master ( 9ca507...f40742 )
by mains
03:55
created
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.
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')
@@ -172,7 +174,8 @@  discard block
 block discarded – undo
172 174
 		if(isset($_POST['color']))
173 175
 		{
174 176
 			$color = $_POST['color'];
175
-			switch ($color) {
177
+			switch ($color)
178
+			{
176 179
 				case '8ABDB0':
177 180
 					$color = '8ABDB0';
178 181
 					break;
@@ -235,7 +238,8 @@  discard block
 block discarded – undo
235 238
 		$data = $accountCreator->execute();
236 239
 		
237 240
 		$posts[0] = $data;
238
-		if(array_key_exists('children', $data)) {
241
+		if(array_key_exists('children', $data))
242
+		{
239 243
 			foreach($data['children'] as $key => $child)
240 244
 			{
241 245
 				
@@ -371,7 +375,11 @@  discard block
 block discarded – undo
371 375
 
372 376
 					<div id="location_mobile" class="hidden-sm-up">
373 377
 						<form method="get">
374
-							<input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
378
+							<input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus))
379
+{
380
+	echo $newPositionStatus;
381
+}
382
+?>" required>
375 383
 
376 384
 							<input type="submit" id="submit_mobile" class="fa" value="&#xf0ac;" />
377 385
 						</form>
@@ -398,7 +406,9 @@  discard block
 block discarded – undo
398 406
 
399 407
 					</content>
400 408
 					
401
-					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
409
+					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
410
+{
411
+?>
402 412
 						<p id="loading">
403 413
 							Loading…
404 414
 						</p>
@@ -411,7 +421,11 @@  discard block
 block discarded – undo
411 421
 							<div>
412 422
 								<h2>Position</h2>
413 423
 								<form method="get">
414
-									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
424
+									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus))
425
+{
426
+	echo $newPositionStatus;
427
+}
428
+?>" required>
415 429
 
416 430
 									<input type="submit" value="Set Location" /> 
417 431
 								</form>
@@ -427,7 +441,9 @@  discard block
 block discarded – undo
427 441
 
428 442
 						<article>
429 443
 							<div>
430
-								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
444
+								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
445
+{
446
+?>
431 447
 								<h2>Comment on Jodel</h2>
432 448
 								<form method="POST">				
433 449
 										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
@@ -435,7 +451,10 @@  discard block
 block discarded – undo
435 451
 									<br />
436 452
 									<input type="submit" value="SEND" /> 
437 453
 								</form>
438
-									<?php } else { ?>
454
+									<?php }
455
+else
456
+{
457
+?>
439 458
 								<h2>New Jodel</h2>
440 459
 								<form method="POST">
441 460
 									<textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> 
@@ -467,13 +486,25 @@  discard block
 block discarded – undo
467 486
 				<div class="col-xs-12">
468 487
 					<div class="row">
469 488
 						<div class="col-xs-3">
470
-							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
489
+							<a href="index.php" <?php if($view=='time')
490
+{
491
+	echo 'class="active"';
492
+}
493
+?>><i class="fa fa-clock-o fa-3x"></i></a>
471 494
 						</div>
472 495
 						<div class="col-xs-3">
473
-							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
496
+							<a href="index.php?view=comment" <?php if($view=='comment')
497
+{
498
+	echo 'class="active"';
499
+}
500
+?>><i class="fa fa-commenting-o fa-3x"></i></a>
474 501
 						</div>
475 502
 						<div class="col-xs-3">
476
-							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
503
+							<a href="index.php?view=upVote" <?php if($view=='upVote')
504
+{
505
+	echo 'class="active"';
506
+}
507
+?>><i class="fa fa-angle-up fa-3x"></i></a>
477 508
 						</div>
478 509
 						<div class="col-xs-3">
479 510
 							<nav>
@@ -516,7 +547,9 @@  discard block
 block discarded – undo
516 547
 				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
517 548
 				}
518 549
 
519
-				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
550
+				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
551
+{
552
+?>
520 553
 
521 554
 				
522 555
 
Please login to merge, or discard this patch.
php/jodel-web.php 1 patch
Braces   +48 added lines, -24 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);
@@ -452,7 +464,8 @@  discard block
 block discarded – undo
452 464
 }
453 465
 
454 466
 function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE)
455
-{	//ToDO
467
+{
468
+//ToDO
456 469
 	//Replace # with link
457 470
 	//preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
458 471
 
@@ -528,7 +541,8 @@  discard block
 block discarded – undo
528 541
 
529 542
 				echo '<img src="' . $post["image_url"] . '" alt="' . htmlspecialchars(preg_replace($regexEmoticons, '', $clean_text)) . '">';
530 543
 			}
531
-			else {
544
+			else
545
+			{
532 546
 				echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post["message"])));
533 547
 			}
534 548
 			?>
@@ -536,11 +550,13 @@  discard block
 block discarded – undo
536 550
 		<aside>
537 551
 			<?php
538 552
 				if($isDetailedView)
539
-				{?>
553
+				{
554
+?>
540 555
 					<a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
541 556
 		  <?php }
542
-				else
543
-				{?>
557
+else
558
+				{
559
+?>
544 560
 					<a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow">
545 561
 		  <?php } ?>
546 562
 						<i class="fa fa-angle-up fa-3x"></i>
@@ -549,11 +565,13 @@  discard block
 block discarded – undo
549 565
 					<?php echo $post["vote_count"];?><br />
550 566
 			<?php
551 567
 				if($isDetailedView)
552
-				{?>
568
+				{
569
+?>
553 570
 					<a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
554 571
 		  <?php }
555
-				else
556
-				{?>
572
+else
573
+				{
574
+?>
557 575
 					<a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow">
558 576
 		  <?php } ?>
559 577
 						<i class="fa fa-angle-down fa-3x"></i>
@@ -571,13 +589,19 @@  discard block
 block discarded – undo
571 589
 						</span> 
572 590
 					</td>
573 591
 					<td class="comments">
574
-						<?php if(!$isDetailedView) {?>
592
+						<?php if(!$isDetailedView)
593
+{
594
+?>
575 595
 						<span data-tooltip="Comments">
576 596
 							<a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
577 597
 								<i class="fa fa-commenting-o"></i>
578
-								<?php if(array_key_exists("child_count", $post)) {
598
+								<?php if(array_key_exists("child_count", $post))
599
+{
579 600
 											echo $post["child_count"];
580
-										} else echo "0";
601
+										}
602
+										else {
603
+											echo "0";
604
+										}
581 605
 								?>
582 606
 								</a>
583 607
 						</span>
Please login to merge, or discard this patch.