Completed
Push — master ( a872d3...fc7130 )
by mains
02:41
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.
php/Requests/GetCaptcha.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 class GetCaptcha extends AbstractRequest
3
-{		
3
+{
4 4
     function getApiEndPoint()
5 5
     {
6 6
         return '/v3/user/verification/imageCaptcha/';
Please login to merge, or discard this patch.
vote-ajax.php 1 patch
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,17 +40,20 @@  discard block
 block discarded – undo
40 40
 				$token = $accessToken;
41 41
 				$success = false;
42 42
 			}
43
-			else {
43
+			else
44
+			{
44 45
 				
45 46
 				$location = getLocationByAccessToken($accessToken);
46 47
 
47 48
 				$accessToken = isTokenFreshByAccessToken($location, $accessToken);
48 49
 
49 50
 
50
-				if($_POST['vote'] == "up") {
51
+				if($_POST['vote'] == "up")
52
+				{
51 53
 					$accountCreator = new Upvote();
52 54
 				}
53
-				else if($_POST['vote'] == "down") {
55
+				else if($_POST['vote'] == "down")
56
+				{
54 57
 					$accountCreator = new Downvote();
55 58
 				}
56 59
 
@@ -74,7 +77,7 @@  discard block
 block discarded – undo
74 77
 {
75 78
 	$response = array("success" => $success, "message" => $message, "captcha" => $captcha, "accessToken" => $token);
76 79
 }
77
-else 
80
+else
78 81
 {
79 82
 	$response = array("success" => $success, "message" => $message);
80 83
 }
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +42 added lines, -11 removed lines patch added patch discarded remove patch
@@ -57,7 +57,8 @@  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 62
 			case 'comment':
62 63
 				$view = 'comment';
63 64
 				break;
@@ -219,7 +220,8 @@  discard block
 block discarded – undo
219 220
 
220 221
 			$posts[0] = $data;
221 222
 
222
-			if(array_key_exists('children', $data)) {
223
+			if(array_key_exists('children', $data))
224
+			{
223 225
 				foreach($data['children'] as $key => $child)
224 226
 				{
225 227
 					
@@ -357,7 +359,11 @@  discard block
 block discarded – undo
357 359
 
358 360
 					<div id="location_mobile" class="hidden-sm-up">
359 361
 						<form method="get">
360
-							<input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
362
+							<input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus))
363
+{
364
+	echo $newPositionStatus;
365
+}
366
+?>" required>
361 367
 
362 368
 							<input type="submit" id="submit_mobile" class="fa" value="&#xf0ac;" />
363 369
 						</form>
@@ -384,7 +390,9 @@  discard block
 block discarded – undo
384 390
 
385 391
 					</content>
386 392
 					
387
-					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
393
+					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
394
+{
395
+?>
388 396
 						<p id="loading">
389 397
 							Loading…
390 398
 						</p>
@@ -397,7 +405,11 @@  discard block
 block discarded – undo
397 405
 							<div>
398 406
 								<h2>Position / Hashtag</h2>
399 407
 								<form method="get">
400
-									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
408
+									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus))
409
+{
410
+	echo $newPositionStatus;
411
+}
412
+?>" required>
401 413
 									<label>try: #jhj</label><br>
402 414
 									<input type="submit" value="Set Location" /> 
403 415
 								</form>
@@ -413,7 +425,9 @@  discard block
 block discarded – undo
413 425
 
414 426
 						<article>
415 427
 							<div>
416
-								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
428
+								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
429
+{
430
+?>
417 431
 								<h2>Comment on Jodel</h2>
418 432
 								<form method="POST">				
419 433
 										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
@@ -421,7 +435,10 @@  discard block
 block discarded – undo
421 435
 									<br />
422 436
 									<input type="submit" value="SEND" /> 
423 437
 								</form>
424
-									<?php } else { ?>
438
+									<?php }
439
+else
440
+{
441
+?>
425 442
 								<h2>New Jodel</h2>
426 443
 								<form method="POST">
427 444
 									<textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> 
@@ -453,13 +470,25 @@  discard block
 block discarded – undo
453 470
 				<div class="col-xs-12">
454 471
 					<div class="row">
455 472
 						<div class="col-xs-3">
456
-							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
473
+							<a href="index.php" <?php if($view=='time')
474
+{
475
+	echo 'class="active"';
476
+}
477
+?>><i class="fa fa-clock-o fa-3x"></i></a>
457 478
 						</div>
458 479
 						<div class="col-xs-3">
459
-							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
480
+							<a href="index.php?view=comment" <?php if($view=='comment')
481
+{
482
+	echo 'class="active"';
483
+}
484
+?>><i class="fa fa-commenting-o fa-3x"></i></a>
460 485
 						</div>
461 486
 						<div class="col-xs-3">
462
-							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
487
+							<a href="index.php?view=upVote" <?php if($view=='upVote')
488
+{
489
+	echo 'class="active"';
490
+}
491
+?>><i class="fa fa-angle-up fa-3x"></i></a>
463 492
 						</div>
464 493
 						<div class="col-xs-3">
465 494
 							<nav>
@@ -500,7 +529,9 @@  discard block
 block discarded – undo
500 529
 				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
501 530
 				}
502 531
 
503
-				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
532
+				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
533
+{
534
+?>
504 535
 
505 536
 				
506 537
 
Please login to merge, or discard this patch.
php/jodel-web.php 1 patch
Braces   +51 added lines, -26 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	if(substr($_GET['city'], 0, 1) === '#')
84 84
 	{
85 85
 		return htmlspecialchars($_GET['city']) . " " . $cityName;
86
-	}                
86
+	}
87 87
 	else
88 88
 	{
89 89
 		$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
@@ -187,7 +187,8 @@  discard block
 block discarded – undo
187 187
 	if(isset($_POST['color']))
188 188
 	{
189 189
 		$color = $_POST['color'];
190
-		switch ($color) {
190
+		switch ($color)
191
+		{
191 192
 			case '8ABDB0':
192 193
 				$color = '8ABDB0';
193 194
 				break;
@@ -261,7 +262,8 @@  discard block
 block discarded – undo
261 262
 	if ($result->num_rows > 0)
262 263
 	{
263 264
 			// output data of each row
264
-			while($row = $result->fetch_assoc()) {
265
+			while($row = $result->fetch_assoc())
266
+			{
265 267
 					//$access_token = $row["access_token"];
266 268
 					$expiration_date = $row["expiration_date"];
267 269
 					$deviceUid = $row["device_uid"];
@@ -273,7 +275,8 @@  discard block
 block discarded – undo
273 275
 			echo '0 results';
274 276
 	}
275 277
 
276
-	if($expiration_date <= time()) {
278
+	if($expiration_date <= time())
279
+	{
277 280
 		$accountCreator = new CreateUser();
278 281
 		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
279 282
 		$accountCreator->setDeviceUid($deviceUid);
@@ -290,7 +293,8 @@  discard block
 block discarded – undo
290 293
 									expiration_date='" . $expiration_date . "'
291 294
 								WHERE device_uid='" . $device_uid . "'");
292 295
 
293
-		if($result === false){
296
+		if($result === false)
297
+		{
294 298
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
295 299
 		}	
296 300
 	}
@@ -306,7 +310,8 @@  discard block
 block discarded – undo
306 310
 	if ($result->num_rows > 0)
307 311
 	{
308 312
 			// output data of each row
309
-			while($row = $result->fetch_assoc()) {
313
+			while($row = $result->fetch_assoc())
314
+			{
310 315
 					//$access_token = $row["access_token"];
311 316
 					$expiration_date = $row["expiration_date"];
312 317
 					$deviceUid = $row["device_uid"];
@@ -318,7 +323,8 @@  discard block
 block discarded – undo
318 323
 			echo '0 results';
319 324
 	}
320 325
 
321
-	if($expiration_date <= time()) {
326
+	if($expiration_date <= time())
327
+	{
322 328
 		$accountCreator = new CreateUser();
323 329
 		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
324 330
 		$accountCreator->setDeviceUid($deviceUid);
@@ -335,7 +341,8 @@  discard block
 block discarded – undo
335 341
 									expiration_date='" . $expiration_date . "'
336 342
 								WHERE device_uid='" . $device_uid . "'");
337 343
 
338
-		if($result === false){
344
+		if($result === false)
345
+		{
339 346
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
340 347
 		}	
341 348
 	}
@@ -353,7 +360,8 @@  discard block
 block discarded – undo
353 360
 	if ($result->num_rows > 0)
354 361
 	{
355 362
 			// output data of each row
356
-			while($row = $result->fetch_assoc()) {
363
+			while($row = $result->fetch_assoc())
364
+			{
357 365
 					//$access_token = $row["access_token"];
358 366
 					$expiration_date = $row["expiration_date"];
359 367
 					$deviceUid = $row["device_uid"];
@@ -365,7 +373,8 @@  discard block
 block discarded – undo
365 373
 			echo '0 results';
366 374
 	}
367 375
 
368
-	if($expiration_date <= time()) {
376
+	if($expiration_date <= time())
377
+	{
369 378
 		$accountCreator = new CreateUser();
370 379
 		$accountCreator->setAccessToken($access_token);
371 380
 		$accountCreator->setDeviceUid($deviceUid);
@@ -382,7 +391,8 @@  discard block
 block discarded – undo
382 391
 									expiration_date='" . $expiration_date . "'
383 392
 								WHERE device_uid='" . $device_uid . "'");
384 393
 
385
-		if($result === false){
394
+		if($result === false)
395
+		{
386 396
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
387 397
 		}	
388 398
 	}
@@ -538,14 +548,16 @@  discard block
 block discarded – undo
538 548
 	$result = $db->query("INSERT INTO votes (device_uid, postId, type)
539 549
 					VALUES ('" . $device_uid . "','" . $postId . "','" . $voteType . "')");
540 550
 	
541
-	if($result === false){
551
+	if($result === false)
552
+	{
542 553
 			$error = db_error();
543 554
 			echo $error;
544 555
 			echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
545 556
 	}		
546 557
 }
547 558
 
548
-function registerAccount(Location $location) {
559
+function registerAccount(Location $location)
560
+{
549 561
 	$accountCreator = new CreateUser();
550 562
 	$accountCreator->setLocation($location);
551 563
 	$data = $accountCreator->execute();
@@ -570,7 +582,8 @@  discard block
 block discarded – undo
570 582
 					"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
571 583
 
572 584
 	$success = TRUE;
573
-	if($result === false){
585
+	if($result === false)
586
+	{
574 587
 			$error = db_error();
575 588
 			echo $error;
576 589
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
@@ -581,7 +594,7 @@  discard block
 block discarded – undo
581 594
 }
582 595
 
583 596
 function getPosts($lastPostId, $accessToken, $url, $version = 'v2')
584
-{	
597
+{
585 598
 	$accountCreator = new GetPosts();
586 599
 	$accountCreator->setLastPostId($lastPostId);
587 600
 	$accountCreator->setAccessToken($accessToken);
@@ -670,7 +683,8 @@  discard block
 block discarded – undo
670 683
 }
671 684
 
672 685
 function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE)
673
-{	//ToDO
686
+{
687
+//ToDO
674 688
 	//Replace # with link
675 689
 	//preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
676 690
 
@@ -726,7 +740,8 @@  discard block
 block discarded – undo
726 740
 
727 741
 				echo '<img src="' . $post['image_url'] . '" alt="' . htmlspecialchars(preg_replace($regexRest, '', $post['message'])) . '">';
728 742
 			}
729
-			else {
743
+			else
744
+			{
730 745
 				echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post['message'])));
731 746
 			}
732 747
 			?>
@@ -734,11 +749,13 @@  discard block
 block discarded – undo
734 749
 		<aside>
735 750
 			<?php
736 751
 				if($isDetailedView)
737
-				{?>
752
+				{
753
+?>
738 754
 					<a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
739 755
 		  <?php }
740
-				else
741
-				{?>
756
+else
757
+				{
758
+?>
742 759
 					<a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>" rel="nofollow">
743 760
 		  <?php } ?>
744 761
 						<i class="fa fa-angle-up fa-3x"></i>
@@ -747,11 +764,13 @@  discard block
 block discarded – undo
747 764
 					<?php echo $post["vote_count"];?><br />
748 765
 			<?php
749 766
 				if($isDetailedView)
750
-				{?>
767
+				{
768
+?>
751 769
 					<a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>" rel="nofollow">
752 770
 		  <?php }
753
-				else
754
-				{?>
771
+else
772
+				{
773
+?>
755 774
 					<a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>" rel="nofollow">
756 775
 		  <?php } ?>
757 776
 						<i class="fa fa-angle-down fa-3x"></i>
@@ -769,13 +788,19 @@  discard block
 block discarded – undo
769 788
 						</span> 
770 789
 					</td>
771 790
 					<td class="comments">
772
-						<?php if(!$isDetailedView) {?>
791
+						<?php if(!$isDetailedView)
792
+{
793
+?>
773 794
 						<span data-tooltip="Comments">
774 795
 							<a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
775 796
 								<i class="fa fa-commenting-o"></i>
776
-								<?php if(array_key_exists("child_count", $post)) {
797
+								<?php if(array_key_exists("child_count", $post))
798
+{
777 799
 											echo $post["child_count"];
778
-										} else echo "0";
800
+										}
801
+										else {
802
+											echo "0";
803
+										}
779 804
 								?>
780 805
 								</a>
781 806
 						</span>
Please login to merge, or discard this patch.