Completed
Push — master ( dc3cec...6a6184 )
by mains
03:04
created

index.php (38 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('0.1');
7
	$location->setLng('0.1');
8
	$location->setCityName('Munich');
9
10
	isTokenFresh($location);
11
12
	$result = $db->query("SELECT * FROM accounts WHERE id='1'");
13
	
14
	$accessToken;
15
	$newPositionStatus;
16
	
17
	if ($result->num_rows > 0)
18
	{
19
		// output data of each row
20
		while($row = $result->fetch_assoc())
21
		{
22
			$accessToken = $row["access_token"];
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal access_token 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...
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...
23
			$newPositionStatus = $row['name'];
24
		}
25
	}
26
	else
27
	{
28
		echo "Error: 0 results";
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Error: 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...
29
	}
30
	
31
	
32
	//createAccount();
33
34
35
	//Set View
36 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...
37
	{
38
		switch ($_GET['view']) {
39
			case 'comment':
40
				$view = 'comment';
41
				break;
42
			
43
			case 'upVote':
44
				$view = 'upVote';
45
				break;
46
47
			default:
48
				$view = 'time';
49
				break;
50
		}
51
	}
52
	else
53
	{
54
		$view = 'time';
55
	}
56
	
57
	//Set Location
58
	if(isset($_GET['city'])) {
59
		$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...
60
		$result = Requests::post($url);
61
		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...
62
		{
63
			$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...
64
		}
65
		else
66
		{
67
			$name = json_decode($result->body, true)['results']['0']['address_components']['0']['long_name'];
68
			$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...
69
			$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...
70
71
			$location = new Location();
72
			$location->setLat($lat);
73
			$location->setLng($lng);
74
			$location->setCityName($name);
75
			$accountCreator = new UpdateLocation();
76
			$accountCreator->setLocation($location);
77
			$accountCreator->setAccessToken($accessToken);
78
			$data = $accountCreator->execute();
79
80
			//safe location to db
81
			if($data == "Success")
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Success 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...
82
			{
83
				$result = $db->query("UPDATE accounts 
84
						SET name='" . $name . "',
85
							lat='" . $lat . "',
86
							lng='" . $lng . "'
87
						WHERE id='1'");
88
89
				if($result === false)
90
				{
91
						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...
92
				}
93
				else
94
				{
95
					$newPositionStatus = $name;
96
				}
97
			}
98
		}
99
	}
100
	
101
	//Vote
102
	if(isset($_GET['vote']) && isset($_GET['postID'])) {
103
		if($_GET['vote'] == "up") {
0 ignored issues
show
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...
104
			$accountCreator = new Upvote();
105
		}
106
		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...
107
			$accountCreator = new Downvote();
108
		}
109
		$accountCreator->setAccessToken($accessToken);
110
		$data = $accountCreator->execute();
111
112
		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...
113
		die();
114
	}
115
	
116
	
117
	//SendJodel
118
	if(isset($_POST['message'])) {
119
		$accountCreator = new SendJodel();
120
121
		if(isset($_POST['ancestor']))
122
		{
123
			$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...
124
			$accountCreator->ancestor = $ancestor;
125
		}
126
		if(isset($_POST['color']))
127
		{
128
			$color = $_POST['color'];
129
			switch ($color) {
130
				case '8ABDB0':
131
					$color = '8ABDB0';
132
					break;
133
				case '9EC41C':
134
					$color = '9EC41C';
135
					break;
136
				case '06A3CB':
137
					$color = '06A3CB';
138
					break;
139
				case 'FFBA00':
140
					$color = 'FFBA00';
141
					break;
142
				case 'DD5F5F':
143
					$color = 'DD5F5F';
144
					break;
145
				case 'FF9908':
146
					$color = 'FF9908';
147
					break;
148
				
149
				default:
150
					$color = '8ABDB0';
151
					break;
152
			}
153
			$accountCreator->color = $color;
154
			echo "Setting color:" . $color;
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Setting color: 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...
155
		}
156
		
157
		$location = new Location();
158
		$location->setLat('0.1');
159
		$location->setLng('0.1');
160
		$location->setCityName('Munich');
161
		
162
		$accountCreator->location = $location;
163
		
164
		$accountCreator->setAccessToken($accessToken);
165
		$data = $accountCreator->execute();
166
	}
167
?>
168
<!DOCTYPE html>
169
<html lang="de">
170
	<head>
171
		<title>JodelBlue WebClient - </title>
172
		
173
		<meta charset="utf8" />
174
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
175
		<meta http-equiv="x-ua-compatible" content="ie=edge">
176
		
177
		<meta name="description" content=""/>
178
		<meta name="keywords" content=""/>
179
		
180
		<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...
181
		<link rel="stylesheet" href="css/font-awesome.min.css">
182
		<link rel="stylesheet" href="style.css" type="text/css">
183
		
184
		<link rel="shortcut icon" href="img/favicon/favicon.ico" type="image/x-icon">
185
		<link rel="icon" href="img/favicon/favicon.ico" type="image/x-icon">	
186
	</head>
187
	
188
	<body>
189
		<header>
190
			<nav class="navbar navbar-full navbar-dark navbar-fixed-top">
191
				<div class="container">					
192
						<?php
193
							if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
194
							{
195
								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...
196
								echo '<i class="fa fa-angle-left fa-3x"></i>';
197
								echo '</a>';
198
								echo '<h1>';
199
								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...
200
							}
201
							else
202
							{
203
								echo '<h1>';	
204
								echo '<a href="index.php" class="spinnable">';
205
							}
206
						?>
207
						JodelBlue <i class="fa fa-refresh fa-1x"></i></a>
208
					</h1>					
209
				</div>
210
			</nav>
211
		</header>
212
		
213
		<div class="mainContent container">		
214
			<div class="content row">
215
				<article class="topContent col-sm-8">
216
217
					<content id="posts">
218
						<?php
219
							$posts;
220
221
							//Get Post Details
222
							if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
223
							{
224
								$userHandleBuffer = [];
225
226
								$accountCreator = new GetPostDetails();
227
								$accountCreator->setAccessToken($accessToken);
228
								$data = $accountCreator->execute();
229
								
230
								$posts[0] = $data;
231
								if(isset($data['children'])) {
232
									foreach($data['children'] as $key => $child)
233
									{
234
										
235
										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...
236
										{
237
											$numberForUser = array_search($child['user_handle'], $userHandleBuffer);
238
											if($numberForUser === FALSE)
239
											{
240
												array_push($userHandleBuffer, $child['user_handle']);
241
												$data['children'][$key]['user_handle'] = count($userHandleBuffer);
242
											}
243
											else
244
											{
245
												$data['children'][$key]['user_handle'] = $numberForUser + 1;
246
											}
247
										}
248
249
										array_push($posts, $data['children'][$key]);
250
									}
251
									$loops = $data['child_count'] + 1;
252
								}
253
								else $loops = 1;
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...
254
								$isDetailedView = TRUE;
255
							}
256
							//Get Posts
257
							else
258
							{
259
								$version = 'v2';
260
								if($view=='comment')
261
								{
262
									$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...
263
								}
264
								else
265
								{
266
									if($view=='upVote')
267
									{
268
										$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...
269
									}
270
									else
271
									{
272
										$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...
273
										$version = 'v3';
274
									}
275
								}
276
277
								if($version == 'v3')
278
								{
279
									$posts = getPosts($lastPostId, $accessToken, $url, $version)['recent'];
280
								}
281
								else
282
								{
283
									$posts = getPosts($lastPostId, $accessToken, $url, $version)['posts'];
284
								}
285
								$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...
286
								$isDetailedView = FALSE;
287
							}
288
							
289
290 View Code Duplication
							for($i = 0; $i<$loops; $i++)
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...
291
							{
292
							
293
							if(isset($posts[$i]))
294
							{
295
								$lastPostId = $posts[$i]['post_id'];
296
297
								jodelToHtml($posts[$i], $view, $isDetailedView);
298
							}
299
						} ?>
300
301
					</content>
302
					
303
					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
304
						<p id="loading">
305
							Loading…
306
						</p>
307
					<?php } ?>
308
				</article>
309
			
310
				<aside class="topSidebar col-sm-4 sidebar-outer">
311
					<div class="fixed">
312
						<article>
313
							<div>
314
								<h2>Position</h2>
315
								<form method="get">
316
									<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...
317
318
									<input type="submit" value="Set Location" /> 
319
								</form>
320
							</div>
321
						</article>
322
323
						<article>
324
							<div>
325
								<h2>Karma</h2>
326
								<?php echo getKarma($accessToken); ?>
327
							</div>
328
						</article>
329
330
						<article>
331
							<div>
332
								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
333
								<h2>Comment on Jodel</h2>
334
								<form method="POST">				
335
										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
336
										<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...
337
									<br />
338
									<input type="submit" value="SEND" /> 
339
								</form>
340
									<?php } else { ?>
341
								<h2>New Jodel</h2>
342
								<form method="POST">
343
									<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...
344
									<br />
345
									<select id="postColorPicker" name="color">
346
										<option value="06A3CB">Blue</option>
347
										<option value="8ABDB0">Teal</option>
348
										<option value="9EC41C">Green</option>
349
										<option value="FFBA00">Yellow</option>
350
										<option value="DD5F5F">Red</option>
351
										<option value="FF9908">Orange</option>
352
									</select> 
353
									<br />
354
									<input type="submit" value="SEND" /> 
355
								</form>
356
								<?php } ?>
357
							</div>
358
						</article>
359
							
360
						<article>
361
							<div>
362
								<h2>Login</h2>
363
							</div>
364
						</article>
365
					</div>
366
				</aside>
367
			</div>
368
			<div id="sortJodelBy" class="row">
369
				<div class="col-sm-12">
370
					<div class="row">
371
						<div class="col-sm-3">
372
							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
373
						</div>
374
						<div class="col-sm-3">
375
							<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...
376
						</div>
377
						<div class="col-sm-3">
378
							<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...
379
						</div>
380
						<div class="col-sm-3">
381
							<nav>
382
								<a href="./impressum.html">Impressum</a> | <a href="./datenschutz.html">Datenschutz</a>
383
							</nav>
384
						</div>
385
					</div>
386
				</div>	
387
			</div>
388
		</div>
389
		
390
		
391
		<!-- jQuery, Tether, Bootstrap JS and own-->
392
		<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...
393
    	<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...
394
    	<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...
395
    	<script src="js/jQueryEmoji.js"></script>
396
397
		<script>
398
399
			$(document).ready(function() {
400
				//Transform UTF-8 Emoji to img
401
				$('.jodel > content').Emoji();
402
403
				$('a').on('click', function(){
404
				    $('a').removeClass('selected');
405
				    $(this).addClass('selected');
406
				});
407
408
				function scrollToAnchor(aid){
409
				    var aTag = $("article[id='"+ aid +"']");
410
				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
411
				}
412
413
				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
414
415
				
416
417
418
419
				var win = $(window);
420
				var lastPostId = "<?php echo $lastPostId; ?>";
421
				var view = "<?php echo $view; ?>"
422
				var old_lastPostId = "";
423
				var morePostsAvailable = true;
424
425
				if(window.location.hash)
426
				{
427
					var hash = window.location.hash.slice(1);
428
429
					if(!$("article[id='"+ hash +"']").length)
430
					{
431
						for (var i = 5; i >= 0; i--)
432
						{
433
							if(!$("article[id='"+ hash +"']").length)
434
							{
435
								$.ajax({
436
									url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
437
									dataType: 'html',
438
									async: false,
439
									success: function(html) {
440
										var div = document.createElement('div');
441
										div.innerHTML = html;
442
										var elements = div.childNodes;
443
										old_lastPostId = lastPostId;
444
										lastPostId = elements[3].textContent;
445
										lastPostId = lastPostId.replace(/\s+/g, '');
446
										//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
447
										if(lastPostId == old_lastPostId) {
448
											
449
											//morePostsAvailable = false;
450
										}
451
										else {
452
											//alert(elements[3].textContent);
453
											$('#posts').append(elements[1].innerHTML);
454
											$('#posts').hide().show(0);
455
										}
456
										$('#loading').hide();
457
									}
458
								});
459
460
								$('.jodel > content').Emoji();
461
							}
462
							
463
						}
464
						scrollToAnchor(hash);
465
466
					}						
467
				}
468
469
				// Each time the user scrolls
470
				win.scroll(function() {
471
472
473
					// End of the document reached?
474
					if (($(document).height() - win.height() == win.scrollTop()) && morePostsAvailable) {
475
						$('#loading').show();
476
477
						
478
						
479
						$.ajax({
480
							url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
481
							dataType: 'html',
482
							async: false,
483
							success: function(html) {
484
								var div = document.createElement('div');
485
								div.innerHTML = html;
486
								var elements = div.childNodes;
487
								old_lastPostId = lastPostId;
488
								lastPostId = elements[3].textContent;
489
								lastPostId = lastPostId.replace(/\s+/g, '');
490
								//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
491
								if(lastPostId == old_lastPostId)
492
								{
493
									
494
									//morePostsAvailable = false;
495
								}
496
								else
497
								{
498
									//alert(elements[3].textContent);
499
									$('#posts').append(elements[1].innerHTML);
500
								}
501
								$('#loading').hide();
502
							}
503
						});
504
505
						$('.jodel > content').Emoji();
506
					}
507
				});
508
			<?php } ?>
509
			});	
510
511
		</script>
512
513
	</body>
514
</html>
515
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...
516