Completed
Pull Request — master (#7)
by
unknown
03:20
created
php/Requests/Upvote.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
 class Upvote extends AbstractRequest {
3 3
 		
4
-    public $postId;
4
+	public $postId;
5 5
 
6
-    function getApiEndPoint()
7
-    {
8
-        return '/v2/posts/' . $this->postId . '/upvote';
9
-    }
10
-    function getPayload()
11
-    {
12
-        return array(
6
+	function getApiEndPoint()
7
+	{
8
+		return '/v2/posts/' . $this->postId . '/upvote';
9
+	}
10
+	function getPayload()
11
+	{
12
+		return array(
13 13
 					"reason_code" => -1,
14
-        );
15
-    }
16
-    function getMethod()
17
-    {
18
-        return 'PUT';
19
-    }
14
+		);
15
+	}
16
+	function getMethod()
17
+	{
18
+		return 'PUT';
19
+	}
20 20
 }
21 21
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,6 @@
 block discarded – undo
1 1
 <?php
2
-class Upvote extends AbstractRequest {
2
+class Upvote extends AbstractRequest
3
+{
3 4
 		
4 5
     public $postId;
5 6
 
Please login to merge, or discard this patch.
admin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 $config = parse_ini_file('config/config.ini.php');
4 4
 if(!isset($_GET['pw']) || $config['pw'] != $_GET['pw'])
5 5
 {
6
-	error_log($_SERVER['REMOTE_ADDR']  . ' used a wrong password on admin.php');
6
+	error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on admin.php');
7 7
 	die();
8 8
 }
9 9
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,10 +40,12 @@
 block discarded – undo
40 40
 			$accessToken = isTokenFreshByAccessToken($location, $accessToken);
41 41
 
42 42
 
43
-			if($_POST['vote'] == "up") {
43
+			if($_POST['vote'] == "up")
44
+			{
44 45
 				$accountCreator = new Upvote();
45 46
 			}
46
-			else if($_POST['vote'] == "down") {
47
+			else if($_POST['vote'] == "down")
48
+			{
47 49
 				$accountCreator = new Downvote();
48 50
 			}
49 51
 
Please login to merge, or discard this patch.
php/jodel-web.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -309,7 +309,7 @@
 block discarded – undo
309 309
 {
310 310
 	preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches);
311 311
 
312
-    return (isset($matches[0])) ? true : false;
312
+	return (isset($matches[0])) ? true : false;
313 313
 }
314 314
 
315 315
 function botDeviceUidIsSet($config)
Please login to merge, or discard this 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.
Braces   +52 added lines, -26 removed lines patch added patch discarded remove patch
@@ -45,7 +45,8 @@  discard block
 block discarded – undo
45 45
 	if ($result->num_rows > 0)
46 46
 	{
47 47
 			// output data of each row
48
-			while($row = $result->fetch_assoc()) {
48
+			while($row = $result->fetch_assoc())
49
+			{
49 50
 					//$access_token = $row["access_token"];
50 51
 					$expiration_date = $row["expiration_date"];
51 52
 					$deviceUid = $row["device_uid"];
@@ -57,7 +58,8 @@  discard block
 block discarded – undo
57 58
 			echo '0 results';
58 59
 	}
59 60
 
60
-	if($expiration_date <= time()) {
61
+	if($expiration_date <= time())
62
+	{
61 63
 		$accountCreator = new CreateUser();
62 64
 		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
63 65
 		$accountCreator->setDeviceUid($deviceUid);
@@ -74,7 +76,8 @@  discard block
 block discarded – undo
74 76
 									expiration_date='" . $expiration_date . "'
75 77
 								WHERE device_uid='" . $device_uid . "'");
76 78
 
77
-		if($result === false){
79
+		if($result === false)
80
+		{
78 81
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
79 82
 		}	
80 83
 	}
@@ -90,7 +93,8 @@  discard block
 block discarded – undo
90 93
 	if ($result->num_rows > 0)
91 94
 	{
92 95
 			// output data of each row
93
-			while($row = $result->fetch_assoc()) {
96
+			while($row = $result->fetch_assoc())
97
+			{
94 98
 					//$access_token = $row["access_token"];
95 99
 					$expiration_date = $row["expiration_date"];
96 100
 					$deviceUid = $row["device_uid"];
@@ -102,7 +106,8 @@  discard block
 block discarded – undo
102 106
 			echo '0 results';
103 107
 	}
104 108
 
105
-	if($expiration_date <= time()) {
109
+	if($expiration_date <= time())
110
+	{
106 111
 		$accountCreator = new CreateUser();
107 112
 		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
108 113
 		$accountCreator->setDeviceUid($deviceUid);
@@ -119,7 +124,8 @@  discard block
 block discarded – undo
119 124
 									expiration_date='" . $expiration_date . "'
120 125
 								WHERE device_uid='" . $device_uid . "'");
121 126
 
122
-		if($result === false){
127
+		if($result === false)
128
+		{
123 129
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
124 130
 		}	
125 131
 	}
@@ -137,7 +143,8 @@  discard block
 block discarded – undo
137 143
 	if ($result->num_rows > 0)
138 144
 	{
139 145
 			// output data of each row
140
-			while($row = $result->fetch_assoc()) {
146
+			while($row = $result->fetch_assoc())
147
+			{
141 148
 					//$access_token = $row["access_token"];
142 149
 					$expiration_date = $row["expiration_date"];
143 150
 					$deviceUid = $row["device_uid"];
@@ -149,7 +156,8 @@  discard block
 block discarded – undo
149 156
 			echo '0 results';
150 157
 	}
151 158
 
152
-	if($expiration_date <= time()) {
159
+	if($expiration_date <= time())
160
+	{
153 161
 		$accountCreator = new CreateUser();
154 162
 		$accountCreator->setAccessToken($access_token);
155 163
 		$accountCreator->setDeviceUid($deviceUid);
@@ -166,7 +174,8 @@  discard block
 block discarded – undo
166 174
 									expiration_date='" . $expiration_date . "'
167 175
 								WHERE device_uid='" . $device_uid . "'");
168 176
 
169
-		if($result === false){
177
+		if($result === false)
178
+		{
170 179
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
171 180
 		}	
172 181
 	}
@@ -280,13 +289,15 @@  discard block
 block discarded – undo
280 289
 	return $data["karma"];
281 290
 }
282 291
 
283
-function addVoteWithPostIdToDeviceUid($postId, $device_uid) {
292
+function addVoteWithPostIdToDeviceUid($postId, $device_uid)
293
+{
284 294
 	
285 295
 	$db = new DatabaseConnect();  
286 296
 	$result = $db->query("INSERT INTO votes (device_uid, postId)
287 297
 					VALUES ('" . $device_uid . "','" . $postId . "') ");
288 298
 	
289
-	if($result === false){
299
+	if($result === false)
300
+	{
290 301
 			$error = db_error();
291 302
 			echo $error;
292 303
 			echo "Adding Vote failed: (" . $result->errno . ") " . $result->error;
@@ -294,7 +305,8 @@  discard block
 block discarded – undo
294 305
 	
295 306
 }
296 307
 
297
-function registerAccount(Location $location) {
308
+function registerAccount(Location $location)
309
+{
298 310
 	$accountCreator = new CreateUser();
299 311
 	$accountCreator->setLocation($location);
300 312
 	$data = $accountCreator->execute();
@@ -319,7 +331,8 @@  discard block
 block discarded – undo
319 331
 					"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
320 332
 
321 333
 	$success = TRUE;
322
-	if($result === false){
334
+	if($result === false)
335
+	{
323 336
 			$error = db_error();
324 337
 			echo $error;
325 338
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
@@ -330,7 +343,7 @@  discard block
 block discarded – undo
330 343
 }
331 344
 
332 345
 function getPosts($lastPostId, $accessToken, $url, $version = 'v2')
333
-{	
346
+{
334 347
 	$accountCreator = new GetPosts();
335 348
 	$accountCreator->setLastPostId($lastPostId);
336 349
 	$accountCreator->setAccessToken($accessToken);
@@ -381,7 +394,8 @@  discard block
 block discarded – undo
381 394
 }
382 395
 
383 396
 function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE)
384
-{	//ToDO
397
+{
398
+//ToDO
385 399
 	//Replace # with link
386 400
 	//preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
387 401
 
@@ -431,10 +445,12 @@  discard block
 block discarded – undo
431 445
 	<article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;">
432 446
 		<content>
433 447
 			<?php 
434
-			if(isset($post["image_url"])) {
448
+			if(isset($post["image_url"]))
449
+			{
435 450
 				echo '<img src="' . $post["image_url"] . '">';
436 451
 			}
437
-			else {
452
+			else
453
+			{
438 454
 				echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post["message"])));
439 455
 			}
440 456
 			?>
@@ -442,11 +458,13 @@  discard block
 block discarded – undo
442 458
 		<aside>
443 459
 			<?php
444 460
 				if($isDetailedView)
445
-				{?>
461
+				{
462
+?>
446 463
 					<a href="index.php?vote=up&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>">
447 464
 		  <?php }
448
-				else
449
-				{?>
465
+else
466
+				{
467
+?>
450 468
 					<a href="index.php?vote=up&postID=<?php echo $post['post_id'];?>">
451 469
 		  <?php } ?>
452 470
 						<i class="fa fa-angle-up fa-3x"></i>
@@ -455,11 +473,13 @@  discard block
 block discarded – undo
455 473
 					<?php echo $post["vote_count"];?><br />
456 474
 			<?php
457 475
 				if($isDetailedView)
458
-				{?>
476
+				{
477
+?>
459 478
 					<a href="index.php?vote=down&getPostDetails=true&postID=<?php echo $post['post_id'];?>&postID_parent=<?php echo htmlspecialchars($_GET['postID']);?>">
460 479
 		  <?php }
461
-				else
462
-				{?>
480
+else
481
+				{
482
+?>
463 483
 					<a href="index.php?vote=down&postID=<?php echo $post['post_id'];?>">
464 484
 		  <?php } ?>
465 485
 						<i class="fa fa-angle-down fa-3x"></i>
@@ -477,13 +497,19 @@  discard block
 block discarded – undo
477 497
 						</span> 
478 498
 					</td>
479 499
 					<td class="comments">
480
-						<?php if(!$isDetailedView) {?>
500
+						<?php if(!$isDetailedView)
501
+{
502
+?>
481 503
 						<span data-tooltip="Comments">
482 504
 							<a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
483 505
 								<i class="fa fa-commenting-o"></i>
484
-								<?php if(array_key_exists("child_count", $post)) {
506
+								<?php if(array_key_exists("child_count", $post))
507
+{
485 508
 											echo $post["child_count"];
486
-										} else echo "0";
509
+										}
510
+										else {
511
+											echo "0";
512
+										}
487 513
 								?>
488 514
 								</a>
489 515
 						</span>
Please login to merge, or discard this patch.
Upper-Lower-Casing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -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
 	}
@@ -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
 	}
@@ -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
 	}
@@ -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;
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
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)
Please login to merge, or discard this patch.
index.php 3 patches
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 	if(isset($_GET['city'])) {
81 81
 		$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
82 82
 		$result = Requests::post($url);
83
-		if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
83
+		if(json_decode($result->body, TRUE)['status'] == 'ZERO_RESULTS' || json_decode($result->body, TRUE)['status'] == 'INVALID_REQUEST')
84 84
 		{
85 85
 			$newPositionStatus = "0 results";
86 86
 		}
87 87
 		else
88 88
 		{
89
-			$name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
90
-			$lat = json_decode($result->body, true)['results']['0']['geometry']['location']['lat'];
91
-			$lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
89
+			$name = json_decode($result->body, TRUE)['results']['0']['address_components']['0']['long_name'];
90
+			$lat = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lat'];
91
+			$lng = json_decode($result->body, TRUE)['results']['0']['geometry']['location']['lng'];
92 92
 
93 93
 			$location = new Location();
94 94
 			$location->setLat($lat);
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 							lng='" . $lng . "'
109 109
 						WHERE access_token='" . $accessToken . "'");
110 110
 
111
-				if($result === false)
111
+				if($result === FALSE)
112 112
 				{
113 113
 						echo "Updating location failed: (" . $db->errno . ") " . $db->error;
114 114
 				}
Please login to merge, or discard this 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.
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.
php/Requests/AbstractRequest.php 4 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $header = $this->getSignHeaders();
29 29
         $url = $this->getFullUrl();
30 30
 
31
-        if ($this->getAccessToken()) {
31
+        if($this->getAccessToken()) {
32 32
             $header['Authorization'] = "Bearer " . $this->getAccessToken();
33 33
         }
34 34
         //Comment out to debug the Request:
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
             'proxy' => '186.103.169.165:8080',
46 46
         );*/
47 47
 
48
-        switch ($this->getMethod()) {
48
+        switch($this->getMethod()) {
49 49
             case 'POST':
50 50
                 $result = Requests::post($url, $header, $this->payLoad);
51 51
                 break;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                 $result = Requests::put($url, $header, $this->payLoad);
64 64
                 break;
65 65
         }
66
-        switch ($result->status_code) {
66
+        switch($result->status_code) {
67 67
             case 200:
68 68
                 $result = json_decode($result->body, true);
69 69
                 break;
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
                 exit("Error 403: Access denied");
92 92
                 break;
93 93
             default:
94
-                error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
95
-                throw  new \Exception('Unknown Error: '.$result->status_code);
94
+                error_log('Error ' . $result->status_code . ' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
95
+                throw  new \Exception('Unknown Error: ' . $result->status_code);
96 96
         }
97 97
 
98 98
         if($device_uid != '')
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 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 = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG';
8
-    const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
-    const CLIENT_TYPE = 'android_4.32.2';
5
+	const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26';
6
+	const APIURL = 'https://api.go-tellm.com/api';
7
+	const SECRET = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG';
8
+	const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
+	const CLIENT_TYPE = 'android_4.32.2';
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,96 +24,96 @@  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
         $options = array(
43 43
             'timeout' => 100,
44 44
             'connect_timeout' => 100,
45 45
             'proxy' => '186.103.169.165:8080',
46 46
         );*/
47 47
 
48
-        switch ($this->getMethod()) {
49
-            case 'POST':
50
-                $result = Requests::post($url, $header, $this->payLoad);
51
-                break;
52
-            case 'GET':
53
-                if($this->version == 'v3')
54
-                {
55
-                    $result = Requests::get($url, $header);
56
-                }
57
-                else
58
-                {
59
-                    $result = Requests::get($url, $header);
60
-                }
61
-                break;
62
-            case 'PUT':
63
-                $result = Requests::put($url, $header, $this->payLoad);
64
-                break;
65
-        }
66
-        switch ($result->status_code) {
67
-            case 200:
68
-                $result = json_decode($result->body, true);
69
-                break;
70
-            case 204:
71
-                $result = "Success";
72
-                break;
73
-            case 401:
48
+		switch ($this->getMethod()) {
49
+			case 'POST':
50
+				$result = Requests::post($url, $header, $this->payLoad);
51
+				break;
52
+			case 'GET':
53
+				if($this->version == 'v3')
54
+				{
55
+					$result = Requests::get($url, $header);
56
+				}
57
+				else
58
+				{
59
+					$result = Requests::get($url, $header);
60
+				}
61
+				break;
62
+			case 'PUT':
63
+				$result = Requests::put($url, $header, $this->payLoad);
64
+				break;
65
+		}
66
+		switch ($result->status_code) {
67
+			case 200:
68
+				$result = json_decode($result->body, true);
69
+				break;
70
+			case 204:
71
+				$result = "Success";
72
+				break;
73
+			case 401:
74 74
 				//throw new \Exception('Unauthorized');
75
-                error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
76
-                break;
77
-            case 404:
78
-                //echo "Es wurde bereits gevoted";
79
-                error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid);
75
+				error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
76
+				break;
77
+			case 404:
78
+				//echo "Es wurde bereits gevoted";
79
+				error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid);
80 80
 			case 477:
81
-                //echo "Es wurde bereits gevoted";
82
-                //throw  new \Exception('Signing failed!');
83
-                error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid);
84
-                break;
85
-            case 429:
86
-                error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid);
87
-            	exit("Error 429: Too Many Requests");
88
-            	break;
89
-            case 403:
90
-                error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid);
91
-                exit("Error 403: Access denied");
92
-                break;
93
-            default:
94
-                error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
95
-                throw  new \Exception('Unknown Error: '.$result->status_code);
96
-        }
81
+				//echo "Es wurde bereits gevoted";
82
+				//throw  new \Exception('Signing failed!');
83
+				error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid);
84
+				break;
85
+			case 429:
86
+				error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid);
87
+				exit("Error 429: Too Many Requests");
88
+				break;
89
+			case 403:
90
+				error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid);
91
+				exit("Error 403: Access denied");
92
+				break;
93
+			default:
94
+				error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
95
+				throw  new \Exception('Unknown Error: '.$result->status_code);
96
+		}
97 97
 
98
-        if($device_uid != '')
99
-        {
98
+		if($device_uid != '')
99
+		{
100 100
 			$result[0] = $result;
101 101
 			$result[1] = $device_uid;
102 102
 	}
103 103
 
104 104
         
105
-        /*var_dump($result);*/
105
+		/*var_dump($result);*/
106 106
         
107 107
 
108
-        return $result;
109
-    }
110
-    abstract function getPayload();
111
-    /**
112
-     * Gets Sign headers
113
-     * @return array headers
114
-     */
115
-    private function getSignHeaders()
116
-    {
108
+		return $result;
109
+	}
110
+	abstract function getPayload();
111
+	/**
112
+	 * Gets Sign headers
113
+	 * @return array headers
114
+	 */
115
+	private function getSignHeaders()
116
+	{
117 117
 			if($this->getAccessToken() == null) {
118 118
 				$payload_accessToken = "";
119 119
 			}
@@ -122,54 +122,54 @@  discard block
 block discarded – undo
122 122
 			}
123 123
 			
124 124
 			
125
-        $headers = array(
126
-            "Connection" => "keep-alive",
127
-            "Accept-Encoding" => "gzip",
128
-            "Content-Type" => "application/json; charset=UTF-8",
129
-            "User-Agent" => self::USERAGENT
130
-        );
131
-        $timestamp = new DateTime();
132
-        $timestamp = $timestamp->format(DateTime::ATOM);
133
-        $timestamp = substr($timestamp, 0, -6);
134
-        $timestamp .= "Z";
135
-        $urlParts = parse_url($this->getFullUrl());
136
-        $url2 = "";
137
-        $req = [$this->getMethod(),
138
-            $urlParts['host'],
139
-            "443",
140
-            $urlParts['path'],
141
-            $payload_accessToken,
142
-            $timestamp,
143
-            $url2,
144
-            $this->payLoad];
145
-        $reqString = implode("%", $req);
146
-        $secret = self::SECRET;
147
-        $signature = hash_hmac('sha1', $reqString, $secret);
148
-        $signature = strtoupper($signature);
149
-        $headers['X-Authorization'] = 'HMAC ' . $signature;
150
-        $headers['X-Client-Type'] = self::CLIENT_TYPE;
151
-        $headers['X-Timestamp'] = $timestamp;
152
-        $headers['X-Api-Version'] = '0.2';
153
-        return $headers;
154
-    }
155
-    private function getFullUrl()
156
-    {
157
-        return self::APIURL . $this->getApiEndPoint();
158
-    }
159
-    abstract function getApiEndPoint();
160
-    abstract function getMethod();
161
-    /**
162
-     * @return string
163
-     */
164
-    private function getAccessToken()
165
-    {
166
-        return $this->accessToken;
167
-    }
168
-    /**
169
-     * @param string $accessToken
170
-     */
171
-    public function setAccessToken($accessToken)
172
-    {
173
-        $this->accessToken = $accessToken;
174
-    }
125
+		$headers = array(
126
+			"Connection" => "keep-alive",
127
+			"Accept-Encoding" => "gzip",
128
+			"Content-Type" => "application/json; charset=UTF-8",
129
+			"User-Agent" => self::USERAGENT
130
+		);
131
+		$timestamp = new DateTime();
132
+		$timestamp = $timestamp->format(DateTime::ATOM);
133
+		$timestamp = substr($timestamp, 0, -6);
134
+		$timestamp .= "Z";
135
+		$urlParts = parse_url($this->getFullUrl());
136
+		$url2 = "";
137
+		$req = [$this->getMethod(),
138
+			$urlParts['host'],
139
+			"443",
140
+			$urlParts['path'],
141
+			$payload_accessToken,
142
+			$timestamp,
143
+			$url2,
144
+			$this->payLoad];
145
+		$reqString = implode("%", $req);
146
+		$secret = self::SECRET;
147
+		$signature = hash_hmac('sha1', $reqString, $secret);
148
+		$signature = strtoupper($signature);
149
+		$headers['X-Authorization'] = 'HMAC ' . $signature;
150
+		$headers['X-Client-Type'] = self::CLIENT_TYPE;
151
+		$headers['X-Timestamp'] = $timestamp;
152
+		$headers['X-Api-Version'] = '0.2';
153
+		return $headers;
154
+	}
155
+	private function getFullUrl()
156
+	{
157
+		return self::APIURL . $this->getApiEndPoint();
158
+	}
159
+	abstract function getApiEndPoint();
160
+	abstract function getMethod();
161
+	/**
162
+	 * @return string
163
+	 */
164
+	private function getAccessToken()
165
+	{
166
+		return $this->accessToken;
167
+	}
168
+	/**
169
+	 * @param string $accessToken
170
+	 */
171
+	public function setAccessToken($accessToken)
172
+	{
173
+		$this->accessToken = $accessToken;
174
+	}
175 175
 }
Please login to merge, or discard this 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.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9 9
     const CLIENT_TYPE = 'android_4.32.2';
10 10
     
11
-    private $accessToken = null;
11
+    private $accessToken = NULL;
12 12
     private $payLoad;
13 13
     public $expects = '';
14 14
     public $version = 'v2';
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         }
66 66
         switch ($result->status_code) {
67 67
             case 200:
68
-                $result = json_decode($result->body, true);
68
+                $result = json_decode($result->body, TRUE);
69 69
                 break;
70 70
             case 204:
71 71
                 $result = "Success";
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     private function getSignHeaders()
116 116
     {
117
-			if($this->getAccessToken() == null) {
117
+			if($this->getAccessToken() == NULL) {
118 118
 				$payload_accessToken = "";
119 119
 			}
120 120
 			else {
Please login to merge, or discard this patch.