Completed
Push — master ( 602f8a...43b654 )
by mains
02:59
created

index.php (41 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
error_reporting(-1);
3
include 'php/jodel-web.php';
4
5
	$location = new Location();
6
	$location->setLat('52.5134288');
7
	$location->setLng('13.2746394');
8
	$location->setCityName('Berlin');
9
10
	$accessToken;
11
	$accessToken_forId1;
12
	$deviceUid;
13
14
	//What is dude doing with my Server?
15
	if($_SERVER['REMOTE_ADDR'] == '94.231.103.52')
16
	{
17
		echo('You are flooting my Server! Pls enable Cookies in your script and contact me: [email protected]');
18
		die();
19
	}
20
21
22
	$config = parse_ini_file('config/config.ini.php');
23
24
	//Check if it's a Spider or Google Bot
25
	if(botDeviceUidIsSet($config) && isUserBot())
26
	{
27
		error_log('Spider or Bot checked in!');
28
		
29
		//Change this to a free device_uid listed in your DB
30
		$deviceUid = $config['botDeviceUid'];
31
		$config = NULL;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
32
	}
33
	else
34
	{
35
		$config = NULL;
36
		if(!isset($_COOKIE['JodelDeviceId']))
37
		{
38
			$deviceUid = createAccount();
39
			setcookie('JodelDeviceId', $deviceUid, time()+60*60*24*365*10);
40
			error_log('Created account with JodelDeviceId:' . $deviceUid .  ' for [' . $_SERVER ['HTTP_USER_AGENT'] . ']');
41
			
42
		}
43
		else
44
		{
45
			$deviceUid = $db->real_escape_string($_COOKIE['JodelDeviceId']);
46
		}
47
	}
48
49
	$location = getLocationByDeviceUid($deviceUid);
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
50
	$newPositionStatus = $location->getCityName();
51
	$accessToken = isTokenFreshByDeviceUid($location, $deviceUid);
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
52
	//Acc is fresh. token and location is set
53
54
	$accessToken_forId1 = isTokenFresh($location);
55
56
57
	//Set View
58 View Code Duplication
	if(isset($_GET['view']))
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
	{
60
		switch ($_GET['view']) {
61
			case 'comment':
62
				$view = 'comment';
63
				break;
64
			
65
			case 'upVote':
66
				$view = 'upVote';
67
				break;
68
69
			default:
70
				$view = 'time';
71
				break;
72
		}
73
	}
74
	else
75
	{
76
		$view = 'time';
77
	}
78
	
79
	//Set Location
80
	if(isset($_GET['city'])) {
81
		$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . htmlspecialchars($_GET['city']) . '&key=AIzaSyCwhnja-or07012HqrhPW7prHEDuSvFT4w';
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
This line exceeds maximum limit of 120 characters; contains 153 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
82
		$result = Requests::post($url);
83
		if(json_decode($result->body, true)['status'] == 'ZERO_RESULTS' || json_decode($result->body, true)['status'] == 'INVALID_REQUEST')
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
84
		{
85
			$newPositionStatus = "0 results";
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 0 results does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
86
		}
87
		else
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'];
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
91
			$lng = json_decode($result->body, true)['results']['0']['geometry']['location']['lng'];
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
92
93
			$location = new Location();
94
			$location->setLat($lat);
95
			$location->setLng($lng);
96
			$location->setCityName($name);
97
			$accountCreator = new UpdateLocation();
98
			$accountCreator->setLocation($location);
99
			$accountCreator->setAccessToken($accessToken);
100
			$data = $accountCreator->execute();
101
102
			//safe location to db
103
			if($data == 'Success')
104
			{
105
				$result = $db->query("UPDATE accounts 
106
						SET name='" . $name . "',
107
							lat='" . $lat . "',
108
							lng='" . $lng . "'
109
						WHERE access_token='" . $accessToken . "'");
110
111
				if($result === false)
112
				{
113
						echo "Updating location failed: (" . $db->errno . ") " . $db->error;
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Updating location failed: ( does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal ) does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
114
				}
115
				else
116
				{
117
					$newPositionStatus = $name;
118
					error_log('User with JodelDeviceId:' . $deviceUid .  ' [' . $_SERVER['REMOTE_ADDR'] . '][' . $_SERVER ['HTTP_USER_AGENT'] . '] changed to Location: ' . $name);
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 164 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
119
				}
120
			}
121
		}
122
	}
123
	
124
	//Vote
125
	if(isset($_GET['vote']) && isset($_GET['postID'])) {
126 View Code Duplication
		if($_GET['vote'] == "up") {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
Coding Style Comprehensibility introduced by
The string literal up does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
127
			$accountCreator = new Upvote();
128
		}
129
		else if($_GET['vote'] == "down") {
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal down does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
130
			$accountCreator = new Downvote();
131
		}
132
		$accountCreator->setAccessToken($accessToken_forId1);
133
		$accountCreator->postId = $_GET['postID'];
134
		$data = $accountCreator->execute();
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 19 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
135
136
		if(isset($_GET['getPostDetails']) && $_GET['getPostDetails'])
137
		{
138
			header('Location: index.php?getPostDetails=true&postID=' . htmlspecialchars($_GET['postID_parent']) . '#postId-' . htmlspecialchars($_GET['postID']));
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 153 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
139
		}
140
		else
141
		{
142
			header("Location: index.php#postId-" . htmlspecialchars($_GET['postID']));
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Location: index.php#postId- does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
143
		}	
144
		die();
145
	}
146
	
147
	
148
	//SendJodel
149
	if(isset($_POST['message']))
150
	{
151
		$accountCreator = new SendJodel();
152
153
		if(isset($_POST['ancestor']))
154
		{
155
			$ancestor = $_POST['ancestor'];
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 17 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
156
			$accountCreator->ancestor = $ancestor;
157
		}
158
		if(isset($_POST['color']))
159
		{
160
			$color = $_POST['color'];
161
			switch ($color) {
162
				case '8ABDB0':
163
					$color = '8ABDB0';
164
					break;
165
				case '9EC41C':
166
					$color = '9EC41C';
167
					break;
168
				case '06A3CB':
169
					$color = '06A3CB';
170
					break;
171
				case 'FFBA00':
172
					$color = 'FFBA00';
173
					break;
174
				case 'DD5F5F':
175
					$color = 'DD5F5F';
176
					break;
177
				case 'FF9908':
178
					$color = 'FF9908';
179
					break;
180
				
181
				default:
182
					$color = '8ABDB0';
183
					break;
184
			}
185
			$accountCreator->color = $color;
186
		}
187
		
188
		//$location = getLocationByAccessToken($accessToken);
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
189
190
		$accountCreatorLocation = new UpdateLocation();
191
		$accountCreatorLocation->setLocation($location);
192
		$accountCreatorLocation->setAccessToken($accessToken_forId1);
193
		$data = $accountCreatorLocation->execute();
194
		
195
		$accountCreator->location = $location;
196
		
197
		$accountCreator->setAccessToken($accessToken_forId1);
198
		$data = $accountCreator->execute();
199
200
		if(isset($_POST['ancestor']))
201
		{
202
			$actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
203
			header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id']));
204
			exit;
205
		}
206
		else
207
		{
208
			header('Location: ./');
209
			exit;
210
		}
211
	}
212
?>
213
<!DOCTYPE html>
214
<html lang="en">
215
	<head>
216
		<title>JodelBlue - Web-App and Browser-Client</title>
217
		
218
		<meta charset="utf-8">
219
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
220
		<meta http-equiv="x-ua-compatible" content="ie=edge">
221
		
222
		<meta name="description" content="JodelBlue is a Web-App and Browser-Client for the Jodel App. No registration required! Browse Jodels all over the world. Send your own Jodels or upvote others.">
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 197 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
223
		<meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client, web-app, browser, app">
224
		
225
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 218 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
226
		<link rel="stylesheet" href="css/font-awesome.min.css">
227
		<link rel="stylesheet" href="style.css" type="text/css">
228
		
229
		<link rel="shortcut icon" type="image/x-icon" href="./img/favicon/favicon.ico">
230
		<link rel="icon" type="image/x-icon" href="./img/favicon/favicon.ico">
231
		<link rel="icon" type="image/gif" href="./img/favicon/favicon.gif">
232
		<link rel="icon" type="image/png" href="./img/favicon/favicon.png">
233
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon.png">
234
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-57x57.png" sizes="57x57">
235
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-60x60.png" sizes="60x60">
236
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-72x72.png" sizes="72x72">
237
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-76x76.png" sizes="76x76">
238
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-114x114.png" sizes="114x114">
239
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-120x120.png" sizes="120x120">
240
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-128x128.png" sizes="128x128">
241
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-144x144.png" sizes="144x144">
242
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-152x152.png" sizes="152x152">
243
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-180x180.png" sizes="180x180">
244
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-precomposed.png">
245
		<link rel="icon" type="image/png" href="./img/favicon/favicon-16x16.png" sizes="16x16">
246
		<link rel="icon" type="image/png" href="./img/favicon/favicon-32x32.png" sizes="32x32">
247
		<link rel="icon" type="image/png" href="./img/favicon/favicon-96x96.png" sizes="96x96">
248
		<link rel="icon" type="image/png" href="./img/favicon/favicon-160x160.png" sizes="160x160">
249
		<link rel="icon" type="image/png" href="./img/favicon/favicon-192x192.png" sizes="192x192">
250
		<link rel="icon" type="image/png" href="./img/favicon/favicon-196x196.png" sizes="196x196">
251
		<meta name="msapplication-TileImage" content="./img/favicon/win8-tile-144x144.png"> 
252
		<meta name="msapplication-TileColor" content="#5682a3"> 
253
		<meta name="msapplication-navbutton-color" content="#5682a3"> 
254
		<meta name="application-name" content="JodelBlue"/> 
255
		<meta name="msapplication-tooltip" content="JodelBlue"/> 
256
		<meta name="apple-mobile-web-app-title" content="JodelBlue"/> 
257
		<meta name="msapplication-square70x70logo" content="./img/favicon/win8-tile-70x70.png"> 
258
		<meta name="msapplication-square144x144logo" content="./img/favicon/win8-tile-144x144.png"> 
259
		<meta name="msapplication-square150x150logo" content="./img/favicon/win8-tile-150x150.png"> 
260
		<meta name="msapplication-wide310x150logo" content="./img/favicon/win8-tile-310x150.png"> 
261
		<meta name="msapplication-square310x310logo" content="./img/favicon/win8-tile-310x310.png"> 
262
	</head>
263
	
264
	<body>
265
		<header>
266
			<nav class="navbar navbar-full navbar-dark navbar-fixed-top">
267
				<div class="container">					
268
						<?php
269
							if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
270
							{
271
								echo '<a id="comment-back" href="index.php?view=' . $view . '#postId-' . htmlspecialchars($_GET['postID']) . '">';
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
272
								echo '<i class="fa fa-angle-left fa-3x"></i>';
273
								echo '</a>';
274
								echo '<h1>';
275
								echo '<a href="index.php?getPostDetails=' . htmlspecialchars($_GET['getPostDetails']) . '&postID=' . htmlspecialchars($_GET['postID']) . '" class="spinnable">';
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 168 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
276
							}
277
							else
278
							{
279
								echo '<h1>';	
280
								echo '<a href="./" class="spinnable">';
281
							}
282
						?>
283
						JodelBlue <i class="fa fa-refresh fa-1x"></i></a>
284
					</h1>
285
286
					<div id="location_mobile" class="hidden-sm-up">
287
						<form method="get">
288
							<input type="text" id="city_mobile" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 142 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
289
290
							<input type="submit" id="submit_mobile" class="fa" value="&#xf0ac;" />
291
						</form>
292
					</div>
293
				</div>
294
			</nav>
295
		</header>
296
		
297
		<div class="mainContent container">		
298
			<div class="content row">
299
				<article class="topContent col-sm-8">
300
301
					<content id="posts">
302
						<?php
303
							$posts;
304
305
							//Get Post Details
306
							if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
307
							{
308
								$userHandleBuffer = [];
309
310
								$accountCreator = new GetPostDetails();
311
								$accountCreator->setAccessToken($accessToken);
312
								$data = $accountCreator->execute();
313
								
314
								$posts[0] = $data;
315
								if(array_key_exists('children', $data)) {
316
									foreach($data['children'] as $key => $child)
317
									{
318
										
319
										if(!$child["parent_creator"] == 1)
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal parent_creator does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
320
										{
321
											$numberForUser = array_search($child['user_handle'], $userHandleBuffer);
322
											if($numberForUser === FALSE)
323
											{
324
												array_push($userHandleBuffer, $child['user_handle']);
325
												$data['children'][$key]['user_handle'] = count($userHandleBuffer);
326
											}
327
											else
328
											{
329
												$data['children'][$key]['user_handle'] = $numberForUser + 1;
330
											}
331
										}
332
333
										array_push($posts, $data['children'][$key]);
334
									}
335
									$loops = $data['child_count'] + 1;
336
								}
337
								else
338
								{
339
									$loops = 1;
340
								}
341
								$isDetailedView = TRUE;
342
							}
343
							//Get Posts
344
							else
345
							{
346
								$version = 'v2';
347
								if($view=='comment')
348
								{
349
									$url = "/v2/posts/location/discussed/";
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal /v2/posts/location/discussed/ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
350
								}
351
								else
352
								{
353
									if($view=='upVote')
354
									{
355
										$url = "/v2/posts/location/popular/";
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal /v2/posts/location/popular/ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
356
									}
357
									else
358
									{
359
										$url = "/v3/posts/location/combo/";
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style Comprehensibility introduced by
The string literal /v3/posts/location/combo/ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
360
										$version = 'v3';
361
									}
362
								}
363
364
								if($version == 'v3')
365
								{
366
									$posts = getPosts($lastPostId, $accessToken, $url, $version)['recent'];
367
								}
368
								else
369
								{
370
									$posts = getPosts($lastPostId, $accessToken, $url, $version)['posts'];
371
								}
372
								$loops = 29;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
373
								$isDetailedView = FALSE;
374
							}
375
							
376
377
							for($i = 0; $i<$loops; $i++)
378
							{
379
								if(array_key_exists($i, $posts) && array_key_exists('post_id', $posts[$i]) && isset($posts[$i]['post_id']))
380
								{
381
									$lastPostId = $posts[$i]['post_id'];
382
383
									jodelToHtml($posts[$i], $view, $isDetailedView);
384
								}
385
							} ?>
386
387
					</content>
388
					
389
					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
390
						<p id="loading">
391
							Loading…
392
						</p>
393
					<?php } ?>
394
				</article>
395
			
396
				<aside class="topSidebar col-sm-4 sidebar-outer">
397
					<div class="fixed">
398
						<article>
399
							<div>
400
								<h2>Position</h2>
401
								<form method="get">
402
									<input type="text" id="city" name="city" placeholder="<?php if(isset($newPositionStatus)) echo $newPositionStatus; ?>" required>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 137 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
403
404
									<input type="submit" value="Set Location" /> 
405
								</form>
406
							</div>
407
						</article>
408
409
						<article>
410
							<div>
411
								<h2>Karma</h2>
412
								<?php echo getKarma($accessToken_forId1); ?>
413
							</div>
414
						</article>
415
416
						<article>
417
							<div>
418
								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
419
								<h2>Comment on Jodel</h2>
420
								<form method="POST">				
421
										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
422
										<textarea id="message" name="message" placeholder="Send a comment on a Jodel to all students within 10km" required></textarea> 
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 137 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
423
									<br />
424
									<input type="submit" value="SEND" /> 
425
								</form>
426
									<?php } else { ?>
427
								<h2>New Jodel</h2>
428
								<form method="POST">
429
									<textarea id="message" name="message" placeholder="Send a Jodel to all students within 10km" required></textarea> 
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 123 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
430
									<br />
431
									<select id="postColorPicker" name="color">
432
										<option value="06A3CB">Blue</option>
433
										<option value="8ABDB0">Teal</option>
434
										<option value="9EC41C">Green</option>
435
										<option value="FFBA00">Yellow</option>
436
										<option value="DD5F5F">Red</option>
437
										<option value="FF9908">Orange</option>
438
									</select> 
439
									<br />
440
									<input type="submit" value="SEND" /> 
441
								</form>
442
								<?php } ?>
443
							</div>
444
						</article>
445
							
446
						<article>
447
							<div>
448
								<h2>Login</h2>
449
							</div>
450
						</article>
451
					</div>
452
				</aside>
453
			</div>
454
			<div id="sortJodelBy" class="row">
455
				<div class="col-xs-12">
456
					<div class="row">
457
						<div class="col-xs-3">
458
							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
459
						</div>
460
						<div class="col-xs-3">
461
							<a href="index.php?view=comment" <?php if($view=='comment') echo 'class="active"';?>><i class="fa fa-commenting-o fa-3x"></i></a>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 136 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
462
						</div>
463
						<div class="col-xs-3">
464
							<a href="index.php?view=upVote" <?php if($view=='upVote') echo 'class="active"';?>><i class="fa fa-angle-up fa-3x"></i></a>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 130 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
465
						</div>
466
						<div class="col-xs-3">
467
							<nav>
468
								<a href="./about-us.html">about us</a>
469
							</nav>
470
						</div>
471
					</div>
472
				</div>	
473
			</div>
474
		</div>
475
		
476
		
477
		<!-- jQuery, Tether, Bootstrap JS and own-->
478
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7" crossorigin="anonymous"></script>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 198 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
479
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 205 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
480
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/js/bootstrap.min.js" integrity="sha384-BLiI7JTZm+JWlgKa0M0kGRpJbF2J8q+qreVrKBC47e3K6BW78kGLrCkeRX6I9RoK" crossorigin="anonymous"></script>
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 212 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
481
    	<script src="js/jQueryEmoji.js"></script>
482
483
		<script>
484
			//BackButton
485
			function goBack()
486
			{
487
				window.history.back();
488
			}
489
490
			$(document).ready(function()
491
			{
492
493
494
				//Transform UTF-8 Emoji to img
495
				$('.jodel > content').Emoji();
496
497
				$('a').on('click', function(){
498
				    $('a').removeClass('selected');
499
				    $(this).addClass('selected');
500
				});
501
502
				function scrollToAnchor(aid){
503
				    var aTag = $("article[id='"+ aid +"']");
504
				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
505
				}
506
507
				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
508
509
				
510
511
512
513
				var win = $(window);
514
				var lastPostId = "<?php echo $lastPostId; ?>";
515
				var view = "<?php echo $view; ?>"
516
				var old_lastPostId = "";
517
				var morePostsAvailable = true;
518
519
				if(window.location.hash)
520
				{
521
					var hash = window.location.hash.slice(1);
522
523
					if(!$("article[id='"+ hash +"']").length)
524
					{
525
						for (var i = 5; i >= 0; i--)
526
						{
527
							if(!$("article[id='"+ hash +"']").length)
528
							{
529
								$.ajax({
530
									url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
531
									dataType: 'html',
532
									async: false,
533
									success: function(html) {
534
										var div = document.createElement('div');
535
										div.innerHTML = html;
536
										var elements = div.childNodes;
537
										old_lastPostId = lastPostId;
538
										lastPostId = elements[3].textContent;
539
										lastPostId = lastPostId.replace(/\s+/g, '');
540
										//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
541
										if(lastPostId == old_lastPostId) {
542
											
543
											//morePostsAvailable = false;
544
										}
545
										else {
546
											//alert(elements[3].textContent);
547
											$('#posts').append(elements[1].innerHTML);
548
											$('#posts').hide().show(0);
549
										}
550
										$('#loading').hide();
551
									}
552
								});
553
554
								$('.jodel > content').Emoji();
555
							}
556
							
557
						}
558
						scrollToAnchor(hash);
559
560
					}						
561
				}
562
563
				// Each time the user scrolls
564
				win.scroll(function() {
565
566
567
					// End of the document reached?
568
					if (($(document).height() - win.height() == win.scrollTop()) && morePostsAvailable) {
569
						$('#loading').show();
570
571
						$.ajax({
572
							url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
573
							dataType: 'html',
574
							async: false,
575
							success: function(html) {
576
								var div = document.createElement('div');
577
								div.innerHTML = html;
578
								var elements = div.childNodes;
579
								old_lastPostId = lastPostId;
580
								lastPostId = elements[3].textContent;
581
								lastPostId = lastPostId.replace(/\s+/g, '');
582
								//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
583
								if(lastPostId == old_lastPostId)
584
								{
585
									
586
									//morePostsAvailable = false;
587
								}
588
								else
589
								{
590
									//alert(elements[3].textContent);
591
									$('#posts').append(elements[1].innerHTML);
592
								}
593
								$('#loading').hide();
594
							}
595
						});
596
597
						$('.jodel > content').Emoji();
598
					}
599
				});
600
			<?php } ?>
601
			});	
602
603
		</script>
604
	</body>
605
</html>
606
0 ignored issues
show
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
607