Completed
Push — master ( 6fce2f...9d108c )
by mains
16:33
created
index.php 1 patch
Braces   +52 added lines, -17 removed lines patch added patch discarded remove patch
@@ -35,7 +35,8 @@  discard block
 block discarded – undo
35 35
 	//Set View
36 36
 	if(isset($_GET['view']))
37 37
 	{
38
-		switch ($_GET['view']) {
38
+		switch ($_GET['view'])
39
+		{
39 40
 			case 'comment':
40 41
 				$view = 'comment';
41 42
 				break;
@@ -55,7 +56,8 @@  discard block
 block discarded – undo
55 56
 	}
56 57
 	
57 58
 	//Set Location
58
-	if(isset($_GET['city'])) {
59
+	if(isset($_GET['city']))
60
+	{
59 61
 		$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
60 62
 		$result = Requests::post($url);
61 63
 		if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
@@ -99,11 +101,14 @@  discard block
 block discarded – undo
99 101
 	}
100 102
 	
101 103
 	//Vote
102
-	if(isset($_GET['vote']) && isset($_GET['postID'])) {
103
-		if($_GET['vote'] == "up") {
104
+	if(isset($_GET['vote']) && isset($_GET['postID']))
105
+	{
106
+		if($_GET['vote'] == "up")
107
+		{
104 108
 			$accountCreator = new Upvote();
105 109
 		}
106
-		else if($_GET['vote'] == "down") {
110
+		else if($_GET['vote'] == "down")
111
+		{
107 112
 			$accountCreator = new Downvote();
108 113
 		}
109 114
 		$accountCreator->setAccessToken($accessToken_forId1);
@@ -116,7 +121,8 @@  discard block
 block discarded – undo
116 121
 	
117 122
 	
118 123
 	//SendJodel
119
-	if(isset($_POST['message'])) {
124
+	if(isset($_POST['message']))
125
+	{
120 126
 		$accountCreator = new SendJodel();
121 127
 
122 128
 		if(isset($_POST['ancestor']))
@@ -127,7 +133,8 @@  discard block
 block discarded – undo
127 133
 		if(isset($_POST['color']))
128 134
 		{
129 135
 			$color = $_POST['color'];
130
-			switch ($color) {
136
+			switch ($color)
137
+			{
131 138
 				case '8ABDB0':
132 139
 					$color = '8ABDB0';
133 140
 					break;
@@ -273,7 +280,8 @@  discard block
 block discarded – undo
273 280
 								$data = $accountCreator->execute();
274 281
 								
275 282
 								$posts[0] = $data;
276
-								if(property_exists($data, 'children')) {
283
+								if(property_exists($data, 'children'))
284
+								{
277 285
 									foreach($data['children'] as $key => $child)
278 286
 									{
279 287
 										
@@ -295,7 +303,9 @@  discard block
 block discarded – undo
295 303
 									}
296 304
 									$loops = $data['child_count'] + 1;
297 305
 								}
298
-								else $loops = 1;
306
+								else {
307
+									$loops = 1;
308
+								}
299 309
 								$isDetailedView = TRUE;
300 310
 							}
301 311
 							//Get Posts
@@ -345,7 +355,9 @@  discard block
 block discarded – undo
345 355
 
346 356
 					</content>
347 357
 					
348
-					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
358
+					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
359
+{
360
+?>
349 361
 						<p id="loading">
350 362
 							Loading…
351 363
 						</p>
@@ -358,7 +370,11 @@  discard block
 block discarded – undo
358 370
 							<div>
359 371
 								<h2>Position</h2>
360 372
 								<form method="get">
361
-									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
373
+									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus))
374
+{
375
+	echo $newPositionStatus;
376
+}
377
+?>" required>
362 378
 
363 379
 									<input type="submit" value="Set Location" /> 
364 380
 								</form>
@@ -374,7 +390,9 @@  discard block
 block discarded – undo
374 390
 
375 391
 						<article>
376 392
 							<div>
377
-								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
393
+								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
394
+{
395
+?>
378 396
 								<h2>Comment on Jodel</h2>
379 397
 								<form method="POST">				
380 398
 										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
@@ -382,7 +400,10 @@  discard block
 block discarded – undo
382 400
 									<br />
383 401
 									<input type="submit" value="SEND" /> 
384 402
 								</form>
385
-									<?php } else { ?>
403
+									<?php }
404
+else
405
+{
406
+?>
386 407
 								<h2>New Jodel</h2>
387 408
 								<form method="POST">
388 409
 									<textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> 
@@ -414,13 +435,25 @@  discard block
 block discarded – undo
414 435
 				<div class="col-sm-12">
415 436
 					<div class="row">
416 437
 						<div class="col-sm-3">
417
-							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
438
+							<a href="index.php" <?php if($view=='time')
439
+{
440
+	echo 'class="active"';
441
+}
442
+?>><i class="fa fa-clock-o fa-3x"></i></a>
418 443
 						</div>
419 444
 						<div class="col-sm-3">
420
-							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
445
+							<a href="index.php?view=comment" <?php if($view=='comment')
446
+{
447
+	echo 'class="active"';
448
+}
449
+?>><i class="fa fa-commenting-o fa-3x"></i></a>
421 450
 						</div>
422 451
 						<div class="col-sm-3">
423
-							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
452
+							<a href="index.php?view=upVote" <?php if($view=='upVote')
453
+{
454
+	echo 'class="active"';
455
+}
456
+?>><i class="fa fa-angle-up fa-3x"></i></a>
424 457
 						</div>
425 458
 						<div class="col-sm-3">
426 459
 							<nav>
@@ -463,7 +496,9 @@  discard block
 block discarded – undo
463 496
 				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
464 497
 				}
465 498
 
466
-				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
499
+				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails']))
500
+{
501
+?>
467 502
 
468 503
 				
469 504
 
Please login to merge, or discard this patch.
php/Requests/AbstractRequest.php 1 patch
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -2,19 +2,19 @@  discard block
 block discarded – undo
2 2
 
3 3
 abstract class AbstractRequest
4 4
 {	
5
-    const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26';
6
-    const APIURL = 'https://api.go-tellm.com/api';
7
-    const SECRET = 'plerFToqEdWlzShdZlTywaCHRuzlKIMsNmOJVDGE';
8
-    const USERAGENT = 'Jodel/4.31.1 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
-    const CLIENT_TYPE = 'android_4.31.1';
5
+	const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26';
6
+	const APIURL = 'https://api.go-tellm.com/api';
7
+	const SECRET = 'plerFToqEdWlzShdZlTywaCHRuzlKIMsNmOJVDGE';
8
+	const USERAGENT = 'Jodel/4.31.1 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
+	const CLIENT_TYPE = 'android_4.31.1';
10 10
     
11
-    private $accessToken = null;
12
-    private $payLoad;
13
-    public $expects = "";
14
-    public $version = 'v2';
11
+	private $accessToken = null;
12
+	private $payLoad;
13
+	public $expects = "";
14
+	public $version = 'v2';
15 15
 
16
-    public function execute()
17
-    {
16
+	public function execute()
17
+	{
18 18
 		$result = new \stdClass();
19 19
 		        
20 20
 		$this->payLoad = $this->getPayload();
@@ -24,82 +24,82 @@  discard block
 block discarded – undo
24 24
 		}
25 25
 				
26 26
 				
27
-        $this->payLoad = json_encode($this->payLoad);
28
-        $header = $this->getSignHeaders();
29
-        $url = $this->getFullUrl();
27
+		$this->payLoad = json_encode($this->payLoad);
28
+		$header = $this->getSignHeaders();
29
+		$url = $this->getFullUrl();
30 30
 
31
-        if ($this->getAccessToken()) {
32
-            $header['Authorization'] = "Bearer " . $this->getAccessToken();
33
-        }
34
-        //Comment out to debug the Request:
31
+		if ($this->getAccessToken()) {
32
+			$header['Authorization'] = "Bearer " . $this->getAccessToken();
33
+		}
34
+		//Comment out to debug the Request:
35 35
         
36
-        /*
36
+		/*
37 37
         var_dump($url);
38 38
         var_dump($header);
39 39
         var_dump($this->payLoad);
40 40
         */
41 41
         
42 42
 
43
-        switch ($this->getMethod()) {
44
-            case 'POST':
45
-                $result = Requests::post($url, $header, $this->payLoad);
46
-                break;
47
-            case 'GET':
48
-                if($this->version == 'v3')
49
-                {
50
-                    $result = Requests::get($url, $header);
51
-                }
52
-                else
53
-                {
54
-                    $result = Requests::get($url, $header);
55
-                }
56
-                break;
57
-            case 'PUT':
58
-                $result = Requests::put($url, $header, $this->payLoad);
59
-                break;
60
-        }
61
-        switch ($result->status_code) {
62
-            case 200:
63
-                $result = json_decode($result->body, true);
64
-                break;
65
-            case 204:
66
-                $result = "Success";
67
-                break;
68
-            case 401:
43
+		switch ($this->getMethod()) {
44
+			case 'POST':
45
+				$result = Requests::post($url, $header, $this->payLoad);
46
+				break;
47
+			case 'GET':
48
+				if($this->version == 'v3')
49
+				{
50
+					$result = Requests::get($url, $header);
51
+				}
52
+				else
53
+				{
54
+					$result = Requests::get($url, $header);
55
+				}
56
+				break;
57
+			case 'PUT':
58
+				$result = Requests::put($url, $header, $this->payLoad);
59
+				break;
60
+		}
61
+		switch ($result->status_code) {
62
+			case 200:
63
+				$result = json_decode($result->body, true);
64
+				break;
65
+			case 204:
66
+				$result = "Success";
67
+				break;
68
+			case 401:
69 69
 				//throw new \Exception('Unauthorized');
70
-                break;
71
-            case 404:
72
-                //echo "Es wurde bereits gevoted";
70
+				break;
71
+			case 404:
72
+				//echo "Es wurde bereits gevoted";
73 73
 			case 477:
74
-                //echo "Es wurde bereits gevoted";
75
-                //throw  new \Exception('Signing failed!');
76
-                break;
77
-            case 429:
78
-            	exit("Error 429: Too Many Requests");
79
-            	break;
80
-            default:
81
-                throw  new \Exception('Unknown Error: '.$result->status_code);
82
-        }
74
+				//echo "Es wurde bereits gevoted";
75
+				//throw  new \Exception('Signing failed!');
76
+				break;
77
+			case 429:
78
+				exit("Error 429: Too Many Requests");
79
+				break;
80
+			default:
81
+				throw  new \Exception('Unknown Error: '.$result->status_code);
82
+		}
83 83
 
84
-        if($device_uid != "")
85
-        {
84
+		if($device_uid != "")
85
+		{
86 86
 			$result[0] = $result;
87 87
 			$result[1] = $device_uid;
88 88
 		}
89 89
 
90 90
         
91
-        /*var_dump($result);*/
91
+		/*var_dump($result);*/
92 92
         
93 93
 
94
-        return $result;
95
-    }
96
-    abstract function getPayload();
97
-    /**
98
-     * Gets Sign headers
99
-     * @return array headers
100
-     */
101
-    private function getSignHeaders()
102
-    {
94
+		return $result;
95
+	}
96
+	abstract function getPayload();
97
+	/**
98
+	 * Gets Sign headers
99
+	 * @return array headers
100
+	 */
101
+	private function getSignHeaders()
102
+	{
103 103
 			if($this->getAccessToken() == null) {
104 104
 				$payload_accessToken = "";
105 105
 			}
@@ -108,54 +108,54 @@  discard block
 block discarded – undo
108 108
 			}
109 109
 			
110 110
 			
111
-        $headers = array(
112
-            "Connection" => "keep-alive",
113
-            "Accept-Encoding" => "gzip",
114
-            "Content-Type" => "application/json; charset=UTF-8",
115
-            "User-Agent" => self::USERAGENT
116
-        );
117
-        $timestamp = new DateTime();
118
-        $timestamp = $timestamp->format(DateTime::ATOM);
119
-        $timestamp = substr($timestamp, 0, -6);
120
-        $timestamp .= "Z";
121
-        $urlParts = parse_url($this->getFullUrl());
122
-        $url2 = "";
123
-        $req = [$this->getMethod(),
124
-            $urlParts['host'],
125
-            "443",
126
-            $urlParts['path'],
127
-            $payload_accessToken,
128
-            $timestamp,
129
-            $url2,
130
-            $this->payLoad];
131
-        $reqString = implode("%", $req);
132
-        $secret = self::SECRET;
133
-        $signature = hash_hmac('sha1', $reqString, $secret);
134
-        $signature = strtoupper($signature);
135
-        $headers['X-Authorization'] = 'HMAC ' . $signature;
136
-        $headers['X-Client-Type'] = self::CLIENT_TYPE;
137
-        $headers['X-Timestamp'] = $timestamp;
138
-        $headers['X-Api-Version'] = '0.2';
139
-        return $headers;
140
-    }
141
-    private function getFullUrl()
142
-    {
143
-        return self::APIURL . $this->getApiEndPoint();
144
-    }
145
-    abstract function getApiEndPoint();
146
-    abstract function getMethod();
147
-    /**
148
-     * @return string
149
-     */
150
-    private function getAccessToken()
151
-    {
152
-        return $this->accessToken;
153
-    }
154
-    /**
155
-     * @param string $accessToken
156
-     */
157
-    public function setAccessToken($accessToken)
158
-    {
159
-        $this->accessToken = $accessToken;
160
-    }
111
+		$headers = array(
112
+			"Connection" => "keep-alive",
113
+			"Accept-Encoding" => "gzip",
114
+			"Content-Type" => "application/json; charset=UTF-8",
115
+			"User-Agent" => self::USERAGENT
116
+		);
117
+		$timestamp = new DateTime();
118
+		$timestamp = $timestamp->format(DateTime::ATOM);
119
+		$timestamp = substr($timestamp, 0, -6);
120
+		$timestamp .= "Z";
121
+		$urlParts = parse_url($this->getFullUrl());
122
+		$url2 = "";
123
+		$req = [$this->getMethod(),
124
+			$urlParts['host'],
125
+			"443",
126
+			$urlParts['path'],
127
+			$payload_accessToken,
128
+			$timestamp,
129
+			$url2,
130
+			$this->payLoad];
131
+		$reqString = implode("%", $req);
132
+		$secret = self::SECRET;
133
+		$signature = hash_hmac('sha1', $reqString, $secret);
134
+		$signature = strtoupper($signature);
135
+		$headers['X-Authorization'] = 'HMAC ' . $signature;
136
+		$headers['X-Client-Type'] = self::CLIENT_TYPE;
137
+		$headers['X-Timestamp'] = $timestamp;
138
+		$headers['X-Api-Version'] = '0.2';
139
+		return $headers;
140
+	}
141
+	private function getFullUrl()
142
+	{
143
+		return self::APIURL . $this->getApiEndPoint();
144
+	}
145
+	abstract function getApiEndPoint();
146
+	abstract function getMethod();
147
+	/**
148
+	 * @return string
149
+	 */
150
+	private function getAccessToken()
151
+	{
152
+		return $this->accessToken;
153
+	}
154
+	/**
155
+	 * @param string $accessToken
156
+	 */
157
+	public function setAccessToken($accessToken)
158
+	{
159
+		$this->accessToken = $accessToken;
160
+	}
161 161
 }
Please login to merge, or discard this patch.