Completed
Push — master ( 906cba...a2b8a4 )
by mains
03:35
created
index.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 	$accessToken_forId1;
12 12
 	$deviceUid;
13 13
 
14
-	setcookie("JodelId", "", time()-3600);
14
+	setcookie("JodelId", "", time() - 3600);
15 15
 
16 16
 	if(!isset($_COOKIE["JodelDeviceId"]))
17 17
 	{
18 18
 		$deviceUid = createAccount();
19
-		setcookie("JodelDeviceId", $deviceUid, time()+60*60*24*365*10);
19
+		setcookie("JodelDeviceId", $deviceUid, time() + 60 * 60 * 24 * 365 * 10);
20 20
 		
21 21
 	}
22 22
 	else
@@ -35,7 +35,7 @@  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
 			case 'comment':
40 40
 				$view = 'comment';
41 41
 				break;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		if(isset($_POST['color']))
128 128
 		{
129 129
 			$color = $_POST['color'];
130
-			switch ($color) {
130
+			switch($color) {
131 131
 				case '8ABDB0':
132 132
 					$color = '8ABDB0';
133 133
 					break;
@@ -297,13 +297,13 @@  discard block
 block discarded – undo
297 297
 							else
298 298
 							{
299 299
 								$version = 'v2';
300
-								if($view=='comment')
300
+								if($view == 'comment')
301 301
 								{
302 302
 									$url = "/v2/posts/location/discussed/";
303 303
 								}
304 304
 								else
305 305
 								{
306
-									if($view=='upVote')
306
+									if($view == 'upVote')
307 307
 									{
308 308
 										$url = "/v2/posts/location/popular/";
309 309
 									}
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 							}
328 328
 							
329 329
 
330
-							for($i = 0; $i<$loops; $i++)
330
+							for($i = 0; $i < $loops; $i++)
331 331
 							{
332 332
 							
333 333
 							if(isset($posts[$i]))
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
373 373
 								<h2>Comment on Jodel</h2>
374 374
 								<form method="POST">				
375
-										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
375
+										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']); ?>" />
376 376
 										<textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> 
377 377
 									<br />
378 378
 									<input type="submit" value="SEND" /> 
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 				<div class="col-sm-12">
410 410
 					<div class="row">
411 411
 						<div class="col-sm-3">
412
-							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
412
+							<a href="index.php" <?php if($view == 'time') echo 'class="active"'; ?>><i class="fa fa-clock-o fa-3x"></i></a>
413 413
 						</div>
414 414
 						<div class="col-sm-3">
415
-							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
415
+							<a href="index.php?view=comment" <?php if($view == 'comment') echo 'class="active"'; ?>><i class="fa fa-commenting-o fa-3x"></i></a>
416 416
 						</div>
417 417
 						<div class="col-sm-3">
418
-							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
418
+							<a href="index.php?view=upVote" <?php if($view == 'upVote') echo 'class="active"'; ?>><i class="fa fa-angle-up fa-3x"></i></a>
419 419
 						</div>
420 420
 						<div class="col-sm-3">
421 421
 							<nav>
Please login to merge, or discard this patch.
php/jodel-web.php 3 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	
26 26
 	$access_token;
27 27
 
28
-	if ($result->num_rows > 0)
28
+	if($result->num_rows > 0)
29 29
 	{
30 30
 			// output data of each row
31 31
 			while($row = $result->fetch_assoc()) {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 	if($expiration_date <= time()) {
44 44
 		$accountCreator = new CreateUser();
45
-		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
45
+		$accountCreator->setAccessToken($access_token); //$accountData->getAccessToken());
46 46
 		$accountCreator->setDeviceUid($deviceUid);
47 47
 		$accountCreator->setLocation($location);
48 48
 		$data = $accountCreator->execute();
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 									expiration_date='" . $expiration_date . "'
58 58
 								WHERE device_uid='" . $device_uid . "'");
59 59
 
60
-		if($result === false){
60
+		if($result === false) {
61 61
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
62 62
 		}	
63 63
 	}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	$db = new DatabaseConnect();  
71 71
 	$result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'");
72 72
 	
73
-	if ($result->num_rows > 0)
73
+	if($result->num_rows > 0)
74 74
 	{
75 75
 			// output data of each row
76 76
 			while($row = $result->fetch_assoc()) {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
 	if($expiration_date <= time()) {
89 89
 		$accountCreator = new CreateUser();
90
-		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
90
+		$accountCreator->setAccessToken($access_token); //$accountData->getAccessToken());
91 91
 		$accountCreator->setDeviceUid($deviceUid);
92 92
 		$accountCreator->setLocation($location);
93 93
 		$data = $accountCreator->execute();
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 									expiration_date='" . $expiration_date . "'
103 103
 								WHERE device_uid='" . $device_uid . "'");
104 104
 
105
-		if($result === false){
105
+		if($result === false) {
106 106
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
107 107
 		}	
108 108
 	}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 	$access_token;
119 119
 
120
-	if ($result->num_rows > 0)
120
+	if($result->num_rows > 0)
121 121
 	{
122 122
 			// output data of each row
123 123
 			while($row = $result->fetch_assoc()) {
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 									expiration_date='" . $expiration_date . "'
150 150
 								WHERE device_uid='" . $device_uid . "'");
151 151
 
152
-		if($result === false){
152
+		if($result === false) {
153 153
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
154 154
 		}	
155 155
 	}
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 function getLocationByAccessToken($accessToken)
161 161
 {
162 162
 	$db = new DatabaseConnect();
163
-	$result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken  . "'");
163
+	$result = $db->query("SELECT * FROM accounts WHERE access_token='" . $accessToken . "'");
164 164
 	
165 165
 	$location = new Location();
166 166
 	
167
-	if ($result->num_rows > 0)
167
+	if($result->num_rows > 0)
168 168
 	{
169 169
 		// output data of each row
170 170
 		while($row = $result->fetch_assoc())
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 function getLocationByDeviceUid($deviceUid)
186 186
 {
187 187
 	$db = new DatabaseConnect();
188
-	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
188
+	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'");
189 189
 	
190 190
 	$location = new Location();
191 191
 	
192
-	if ($result->num_rows > 0)
192
+	if($result->num_rows > 0)
193 193
 	{
194 194
 		// output data of each row
195 195
 		while($row = $result->fetch_assoc())
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 function getAccessTokenByDeviceUid($deviceUid)
211 211
 {
212 212
 	$db = new DatabaseConnect();
213
-	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid  . "'");
213
+	$result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'");
214 214
 	
215 215
 	$accessToken;
216 216
 	
217
-	if ($result->num_rows > 0)
217
+	if($result->num_rows > 0)
218 218
 	{
219 219
 		// output data of each row
220 220
 		while($row = $result->fetch_assoc())
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
 	$result = $db->query("INSERT INTO accounts (access_token, refresh_token, token_type,
262 262
 					expires_in, expiration_date, distinct_id, device_uid, name, lat, lng)
263 263
 					VALUES ('" . $access_token . "','" . $refresh_token . "','" . $token_type .
264
-					"','" .  $expires_in . "','" . $expiration_date . "','" . $distinct_id .
264
+					"','" . $expires_in . "','" . $expiration_date . "','" . $distinct_id .
265 265
 					"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
266 266
 
267 267
 	$success = TRUE;
268
-	if($result === false){
268
+	if($result === false) {
269 269
 			$error = db_error();
270 270
 			echo $error;
271 271
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
@@ -321,25 +321,25 @@  discard block
 block discarded – undo
321 321
 	$timediff_inDays = (string)$timediff->format('%d');
322 322
 	$timediff_inMonth = (string)$timediff->format('%m');
323 323
 
324
-	if($timediff_inMonth!=0)
324
+	if($timediff_inMonth != 0)
325 325
 	{
326 326
 			$timediff = $timediff_inMonth . "m";
327 327
 	}
328 328
 	else
329 329
 	{
330
-		if($timediff_inDays!=0)
330
+		if($timediff_inDays != 0)
331 331
 		{
332 332
 			$timediff = $timediff_inDays . "d";
333 333
 		}
334 334
 		else
335 335
 		{
336
-			if($timediff_inHours!=0)
336
+			if($timediff_inHours != 0)
337 337
 			{
338 338
 				$timediff = $timediff_inHours . "h";
339 339
 			}
340 340
 			else
341 341
 			{
342
-				if($timediff_inMinutes!=0)
342
+				if($timediff_inMinutes != 0)
343 343
 				{
344 344
 					$timediff = $timediff_inMinutes . "m";
345 345
 				}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 
354 354
 
355 355
 	?>
356
-	<article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;">
356
+	<article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"]; ?>;">
357 357
 		<content>
358 358
 			<?php 
359 359
 			if(isset($post["image_url"])) {
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
 			?>
366 366
 		</content>
367 367
 		<aside>
368
-			<a href="index.php?vote=up&postID=<?php echo $post["post_id"];?>">
368
+			<a href="index.php?vote=up&postID=<?php echo $post["post_id"]; ?>">
369 369
 				<i class="fa fa-angle-up fa-3x"></i>
370 370
 			</a>	
371 371
 				<br />
372
-			<?php echo $post["vote_count"];?><br />
373
-			<a href="index.php?vote=down&postID=<?php echo $post["post_id"];?>">
372
+			<?php echo $post["vote_count"]; ?><br />
373
+			<a href="index.php?vote=down&postID=<?php echo $post["post_id"]; ?>">
374 374
 				<i class="fa fa-angle-down fa-3x"></i>
375 375
 			</a>
376 376
 		</aside>
@@ -381,14 +381,14 @@  discard block
 block discarded – undo
381 381
 					<td class="time">
382 382
 						<span class="tip" data-tooltip="Time">
383 383
 							<i class="fa fa-clock-o"></i>
384
-							<?php echo $timediff;?>
385
-							<span class="tiptext"><?php echo $d->format('Y-m-d H:i:s');?></span>
384
+							<?php echo $timediff; ?>
385
+							<span class="tiptext"><?php echo $d->format('Y-m-d H:i:s'); ?></span>
386 386
 						</span> 
387 387
 					</td>
388 388
 					<td class="comments">
389 389
 						<?php if(!$isDetailedView) {?>
390 390
 						<span data-tooltip="Comments">
391
-							<a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
391
+							<a href="index.php?getPostDetails=true&view=<?php echo $view; ?>&postID=<?php echo $post["post_id"]; ?>">
392 392
 								<i class="fa fa-commenting-o"></i>
393 393
 								<?php if(array_key_exists("child_count", $post)) {
394 394
 											echo $post["child_count"];
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 									{
418 418
 							  			?>
419 419
 							  			<span data-tooltip="Author">
420
-											<i class="fa fa-user-o"></i> #<?php echo $post["user_handle"];?> |
420
+											<i class="fa fa-user-o"></i> #<?php echo $post["user_handle"]; ?> |
421 421
 										</span>
422 422
 										<?php
423 423
 									}
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 
428 428
 						<span class="tip" data-tooltip="Distance">
429 429
 							<i class="fa fa-map-marker"></i>
430
-							<?php echo $post['distance'];?> km
431
-							<span class="tiptext"><?php echo $post['location']['name'];?></span>
430
+							<?php echo $post['distance']; ?> km
431
+							<span class="tiptext"><?php echo $post['location']['name']; ?></span>
432 432
 						</span>
433 433
 					</td>
434 434
 				</tr>
Please login to merge, or discard this patch.
Braces   +38 added lines, -18 removed lines patch added patch discarded remove patch
@@ -28,7 +28,8 @@  discard block
 block discarded – undo
28 28
 	if ($result->num_rows > 0)
29 29
 	{
30 30
 			// output data of each row
31
-			while($row = $result->fetch_assoc()) {
31
+			while($row = $result->fetch_assoc())
32
+			{
32 33
 					//$access_token = $row["access_token"];
33 34
 					$expiration_date = $row["expiration_date"];
34 35
 					$deviceUid = $row["device_uid"];
@@ -40,7 +41,8 @@  discard block
 block discarded – undo
40 41
 			echo '0 results';
41 42
 	}
42 43
 
43
-	if($expiration_date <= time()) {
44
+	if($expiration_date <= time())
45
+	{
44 46
 		$accountCreator = new CreateUser();
45 47
 		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
46 48
 		$accountCreator->setDeviceUid($deviceUid);
@@ -57,7 +59,8 @@  discard block
 block discarded – undo
57 59
 									expiration_date='" . $expiration_date . "'
58 60
 								WHERE device_uid='" . $device_uid . "'");
59 61
 
60
-		if($result === false){
62
+		if($result === false)
63
+		{
61 64
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
62 65
 		}	
63 66
 	}
@@ -73,7 +76,8 @@  discard block
 block discarded – undo
73 76
 	if ($result->num_rows > 0)
74 77
 	{
75 78
 			// output data of each row
76
-			while($row = $result->fetch_assoc()) {
79
+			while($row = $result->fetch_assoc())
80
+			{
77 81
 					//$access_token = $row["access_token"];
78 82
 					$expiration_date = $row["expiration_date"];
79 83
 					$deviceUid = $row["device_uid"];
@@ -85,7 +89,8 @@  discard block
 block discarded – undo
85 89
 			echo '0 results';
86 90
 	}
87 91
 
88
-	if($expiration_date <= time()) {
92
+	if($expiration_date <= time())
93
+	{
89 94
 		$accountCreator = new CreateUser();
90 95
 		$accountCreator->setAccessToken($access_token);//$accountData->getAccessToken());
91 96
 		$accountCreator->setDeviceUid($deviceUid);
@@ -102,7 +107,8 @@  discard block
 block discarded – undo
102 107
 									expiration_date='" . $expiration_date . "'
103 108
 								WHERE device_uid='" . $device_uid . "'");
104 109
 
105
-		if($result === false){
110
+		if($result === false)
111
+		{
106 112
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
107 113
 		}	
108 114
 	}
@@ -120,7 +126,8 @@  discard block
 block discarded – undo
120 126
 	if ($result->num_rows > 0)
121 127
 	{
122 128
 			// output data of each row
123
-			while($row = $result->fetch_assoc()) {
129
+			while($row = $result->fetch_assoc())
130
+			{
124 131
 					//$access_token = $row["access_token"];
125 132
 					$expiration_date = $row["expiration_date"];
126 133
 					$deviceUid = $row["device_uid"];
@@ -132,7 +139,8 @@  discard block
 block discarded – undo
132 139
 			echo '0 results';
133 140
 	}
134 141
 
135
-	if($expiration_date <= time()) {
142
+	if($expiration_date <= time())
143
+	{
136 144
 		$accountCreator = new CreateUser();
137 145
 		$accountCreator->setAccessToken($access_token);
138 146
 		$accountCreator->setDeviceUid($deviceUid);
@@ -149,7 +157,8 @@  discard block
 block discarded – undo
149 157
 									expiration_date='" . $expiration_date . "'
150 158
 								WHERE device_uid='" . $device_uid . "'");
151 159
 
152
-		if($result === false){
160
+		if($result === false)
161
+		{
153 162
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
154 163
 		}	
155 164
 	}
@@ -240,7 +249,8 @@  discard block
 block discarded – undo
240 249
 	return $data["karma"];
241 250
 }
242 251
 
243
-function registerAccount(Location $location) {
252
+function registerAccount(Location $location)
253
+{
244 254
 	$accountCreator = new CreateUser();
245 255
 	$accountCreator->setLocation($location);
246 256
 	$data = $accountCreator->execute();
@@ -265,7 +275,8 @@  discard block
 block discarded – undo
265 275
 					"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
266 276
 
267 277
 	$success = TRUE;
268
-	if($result === false){
278
+	if($result === false)
279
+	{
269 280
 			$error = db_error();
270 281
 			echo $error;
271 282
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
@@ -276,7 +287,7 @@  discard block
 block discarded – undo
276 287
 }
277 288
 
278 289
 function getPosts($lastPostId, $accessToken, $url, $version = 'v2')
279
-{	
290
+{
280 291
 	$accountCreator = new GetPosts();
281 292
 	$accountCreator->setLastPostId($lastPostId);
282 293
 	$accountCreator->setAccessToken($accessToken);
@@ -306,7 +317,8 @@  discard block
 block discarded – undo
306 317
 }
307 318
 
308 319
 function jodelToHtml($post, $view = 'time', $isDetailedView = FALSE)
309
-{	//ToDO
320
+{
321
+//ToDO
310 322
 	//Replace # with link
311 323
 	//preg_replace('~(\#)([^\s!,. /()"\'?]+)~', '<a href="tag/$2">#$2</a>', $text);
312 324
 
@@ -356,10 +368,12 @@  discard block
 block discarded – undo
356 368
 	<article id ="postId-<?php echo $post["post_id"]; ?>" class="jodel" style="background-color: #<?php echo $post["color"];?>;">
357 369
 		<content>
358 370
 			<?php 
359
-			if(isset($post["image_url"])) {
371
+			if(isset($post["image_url"]))
372
+			{
360 373
 				echo '<img src="' . $post["image_url"] . '">';
361 374
 			}
362
-			else {
375
+			else
376
+			{
363 377
 				echo str_replace('  ', ' &nbsp;', nl2br(htmlspecialchars($post["message"])));
364 378
 			}
365 379
 			?>
@@ -386,13 +400,19 @@  discard block
 block discarded – undo
386 400
 						</span> 
387 401
 					</td>
388 402
 					<td class="comments">
389
-						<?php if(!$isDetailedView) {?>
403
+						<?php if(!$isDetailedView)
404
+{
405
+?>
390 406
 						<span data-tooltip="Comments">
391 407
 							<a href="index.php?getPostDetails=true&view=<?php echo $view;?>&postID=<?php echo $post["post_id"];?>">
392 408
 								<i class="fa fa-commenting-o"></i>
393
-								<?php if(array_key_exists("child_count", $post)) {
409
+								<?php if(array_key_exists("child_count", $post))
410
+{
394 411
 											echo $post["child_count"];
395
-										} else echo "0";
412
+										}
413
+										else {
414
+											echo "0";
415
+										}
396 416
 								?>
397 417
 								</a>
398 418
 						</span>
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 									expiration_date='" . $expiration_date . "'
58 58
 								WHERE device_uid='" . $device_uid . "'");
59 59
 
60
-		if($result === false){
60
+		if($result === FALSE){
61 61
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
62 62
 		}	
63 63
 	}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 									expiration_date='" . $expiration_date . "'
103 103
 								WHERE device_uid='" . $device_uid . "'");
104 104
 
105
-		if($result === false){
105
+		if($result === FALSE){
106 106
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
107 107
 		}	
108 108
 	}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 									expiration_date='" . $expiration_date . "'
150 150
 								WHERE device_uid='" . $device_uid . "'");
151 151
 
152
-		if($result === false){
152
+		if($result === FALSE){
153 153
 				echo "Adding account failed: (" . $db->errno . ") " . $db->error;
154 154
 		}	
155 155
 	}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 					"','" . $device_uid . "','" . $name . "','" . $lat . "','" . $lng . "') ");
266 266
 
267 267
 	$success = TRUE;
268
-	if($result === false){
268
+	if($result === FALSE){
269 269
 			$error = db_error();
270 270
 			echo $error;
271 271
 			echo "Adding account failed: (" . $result->errno . ") " . $result->error;
Please login to merge, or discard this patch.