Completed
Push — master ( 9d108c...649a59 )
by mains
43:34 queued 07:20
created

index.php (46 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
	setcookie("JodelId", "", time()-3600);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal JodelId 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...
15
16 View Code Duplication
	if(!isset($_COOKIE["JodelDeviceId"]))
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal JodelDeviceId 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...
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...
17
	{
18
		$deviceUid = createAccount();
19
		setcookie("JodelDeviceId", $deviceUid, time()+60*60*24*365*10);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal JodelDeviceId 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...
20
		
21
	}
22
	else
23
	{
24
		$deviceUid = $db->real_escape_string($_COOKIE["JodelDeviceId"]);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal JodelDeviceId 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...
25
	}
26
27
	$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...
28
	$newPositionStatus = $location->getCityName();
29
	$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...
30
	//Acc is fresh. token and location is set
31
32
	$accessToken_forId1 = isTokenFresh($location);
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 access_token='" . $accessToken . "'");
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 View Code Duplication
		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...
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...
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_forId1);
110
		$accountCreator->postId = $_GET['postID'];
111
		$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...
112
113
		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...
114
		die();
115
	}
116
	
117
	
118
	//SendJodel
119
	if(isset($_POST['message'])) {
120
		$accountCreator = new SendJodel();
121
122
		if(isset($_POST['ancestor']))
123
		{
124
			$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...
125
			$accountCreator->ancestor = $ancestor;
126
		}
127
		if(isset($_POST['color']))
128
		{
129
			$color = $_POST['color'];
130
			switch ($color) {
131
				case '8ABDB0':
132
					$color = '8ABDB0';
133
					break;
134
				case '9EC41C':
135
					$color = '9EC41C';
136
					break;
137
				case '06A3CB':
138
					$color = '06A3CB';
139
					break;
140
				case 'FFBA00':
141
					$color = 'FFBA00';
142
					break;
143
				case 'DD5F5F':
144
					$color = 'DD5F5F';
145
					break;
146
				case 'FF9908':
147
					$color = 'FF9908';
148
					break;
149
				
150
				default:
151
					$color = '8ABDB0';
152
					break;
153
			}
154
			$accountCreator->color = $color;
155
		}
156
		
157
		//$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...
158
159
		$accountCreatorLocation = new UpdateLocation();
160
		$accountCreatorLocation->setLocation($location);
161
		$accountCreatorLocation->setAccessToken($accessToken_forId1);
162
		$data = $accountCreatorLocation->execute();
163
		
164
		$accountCreator->location = $location;
165
		
166
		$accountCreator->setAccessToken($accessToken_forId1);
167
		$data = $accountCreator->execute();
168
169
		if(isset($_POST['ancestor']))
170
		{
171
			$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $_SERVER instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
172
			header('Location: ' . $actual_link . '#postId-' . htmlspecialchars($data['post_id']));
173
			exit;
174
		}
175
		else
176
		{
177
			header('Location: ./');
178
			exit;
179
		}
180
	}
181
?>
182
<!DOCTYPE html>
183
<html lang="en">
184
	<head>
185
		<title>JodelBlue WebClient</title>
186
		
187
		<meta charset="utf8">
188
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
189
		<meta http-equiv="x-ua-compatible" content="ie=edge">
190
		
191
		<meta name="description" content="JodelBlue is a WebClient 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 180 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...
192
		<meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client">
193
		
194
		<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...
195
		<link rel="stylesheet" href="css/font-awesome.min.css">
196
		<link rel="stylesheet" href="style.css" type="text/css">
197
		
198
		<link rel="shortcut icon" type="image/x-icon" href="./img/favicon/favicon.ico">
199
		<link rel="icon" type="image/x-icon" href="./img/favicon/favicon.ico">
200
		<link rel="icon" type="image/gif" href="./img/favicon/favicon.gif">
201
		<link rel="icon" type="image/png" href="./img/favicon/favicon.png">
202
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon.png">
203
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-57x57.png" sizes="57x57">
204
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-60x60.png" sizes="60x60">
205
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-72x72.png" sizes="72x72">
206
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-76x76.png" sizes="76x76">
207
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-114x114.png" sizes="114x114">
208
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-120x120.png" sizes="120x120">
209
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-128x128.png" sizes="128x128">
210
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-144x144.png" sizes="144x144">
211
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-152x152.png" sizes="152x152">
212
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-180x180.png" sizes="180x180">
213
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-precomposed.png">
214
		<link rel="icon" type="image/png" href="./img/favicon/favicon-16x16.png" sizes="16x16">
215
		<link rel="icon" type="image/png" href="./img/favicon/favicon-32x32.png" sizes="32x32">
216
		<link rel="icon" type="image/png" href="./img/favicon/favicon-96x96.png" sizes="96x96">
217
		<link rel="icon" type="image/png" href="./img/favicon/favicon-160x160.png" sizes="160x160">
218
		<link rel="icon" type="image/png" href="./img/favicon/favicon-192x192.png" sizes="192x192">
219
		<link rel="icon" type="image/png" href="./img/favicon/favicon-196x196.png" sizes="196x196">
220
		<meta name="msapplication-TileImage" content="./img/favicon/win8-tile-144x144.png"> 
221
		<meta name="msapplication-TileColor" content="#5682a3"> 
222
		<meta name="msapplication-navbutton-color" content="#5682a3"> 
223
		<meta name="application-name" content="JodelBlue"/> 
224
		<meta name="msapplication-tooltip" content="JodelBlue"/> 
225
		<meta name="apple-mobile-web-app-title" content="JodelBlue"/> 
226
		<meta name="msapplication-square70x70logo" content="./img/favicon/win8-tile-70x70.png"> 
227
		<meta name="msapplication-square144x144logo" content="./img/favicon/win8-tile-144x144.png"> 
228
		<meta name="msapplication-square150x150logo" content="./img/favicon/win8-tile-150x150.png"> 
229
		<meta name="msapplication-wide310x150logo" content="./img/favicon/win8-tile-310x150.png"> 
230
		<meta name="msapplication-square310x310logo" content="./img/favicon/win8-tile-310x310.png"> 
231
	</head>
232
	
233
	<body>
234
		<header>
235
			<nav class="navbar navbar-full navbar-dark navbar-fixed-top">
236
				<div class="container">					
237
						<?php
238
							if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
239
							{
240
								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...
241
								echo '<i class="fa fa-angle-left fa-3x"></i>';
242
								echo '</a>';
243
								echo '<h1>';
244
								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...
245
							}
246
							else
247
							{
248
								echo '<h1>';	
249
								echo '<a href="./" class="spinnable">';
250
							}
251
						?>
252
						JodelBlue <i class="fa fa-refresh fa-1x"></i></a>
253
					</h1>					
254
				</div>
255
			</nav>
256
		</header>
257
		
258
		<div class="mainContent container">		
259
			<div class="content row">
260
				<article class="topContent col-sm-8">
261
262
					<content id="posts">
263
						<?php
264
							$posts;
265
266
							//Get Post Details
267
							if(isset($_GET['postID']) && isset($_GET['getPostDetails']))
268
							{
269
								$userHandleBuffer = [];
270
271
								$accountCreator = new GetPostDetails();
272
								$accountCreator->setAccessToken($accessToken);
273
								$data = $accountCreator->execute();
274
								
275
								$posts[0] = $data;
276
								if(array_key_exists('children', $data)) {
277
									foreach($data['children'] as $key => $child)
278
									{
279
										
280
										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...
281
										{
282
											$numberForUser = array_search($child['user_handle'], $userHandleBuffer);
283
											if($numberForUser === FALSE)
284
											{
285
												array_push($userHandleBuffer, $child['user_handle']);
286
												$data['children'][$key]['user_handle'] = count($userHandleBuffer);
287
											}
288
											else
289
											{
290
												$data['children'][$key]['user_handle'] = $numberForUser + 1;
291
											}
292
										}
293
294
										array_push($posts, $data['children'][$key]);
295
									}
296
									$loops = $data['child_count'] + 1;
297
								}
298
								else
299
								{
300
									$loops = 1;
301
								}
302
								$isDetailedView = TRUE;
303
							}
304
							//Get Posts
305
							else
306
							{
307
								$version = 'v2';
308
								if($view=='comment')
309
								{
310
									$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...
311
								}
312
								else
313
								{
314
									if($view=='upVote')
315
									{
316
										$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...
317
									}
318
									else
319
									{
320
										$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...
321
										$version = 'v3';
322
									}
323
								}
324
325
								if($version == 'v3')
326
								{
327
									$posts = getPosts($lastPostId, $accessToken, $url, $version)['recent'];
328
								}
329
								else
330
								{
331
									$posts = getPosts($lastPostId, $accessToken, $url, $version)['posts'];
332
								}
333
								$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...
334
								$isDetailedView = FALSE;
335
							}
336
							
337
338 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...
339
							{
340
							
341
							if(isset($posts[$i]))
342
							{
343
								$lastPostId = $posts[$i]['post_id'];
344
345
								jodelToHtml($posts[$i], $view, $isDetailedView);
346
							}
347
						} ?>
348
349
					</content>
350
					
351
					<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
352
						<p id="loading">
353
							Loading…
354
						</p>
355
					<?php } ?>
356
				</article>
357
			
358
				<aside class="topSidebar col-sm-4 sidebar-outer">
359
					<div class="fixed">
360
						<article>
361
							<div>
362
								<h2>Position</h2>
363
								<form method="get">
364
									<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...
365
366
									<input type="submit" value="Set Location" /> 
367
								</form>
368
							</div>
369
						</article>
370
371
						<article>
372
							<div>
373
								<h2>Karma</h2>
374
								<?php echo getKarma($accessToken_forId1); ?>
375
							</div>
376
						</article>
377
378
						<article>
379
							<div>
380
								<?php if(isset($_GET['postID']) && isset($_GET['getPostDetails'])) { ?>
381
								<h2>Comment on Jodel</h2>
382
								<form method="POST">				
383
										<input type="hidden" name="ancestor" value="<?php echo htmlspecialchars($_GET['postID']);?>" />
384
										<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...
385
									<br />
386
									<input type="submit" value="SEND" /> 
387
								</form>
388
									<?php } else { ?>
389
								<h2>New Jodel</h2>
390
								<form method="POST">
391
									<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...
392
									<br />
393
									<select id="postColorPicker" name="color">
394
										<option value="06A3CB">Blue</option>
395
										<option value="8ABDB0">Teal</option>
396
										<option value="9EC41C">Green</option>
397
										<option value="FFBA00">Yellow</option>
398
										<option value="DD5F5F">Red</option>
399
										<option value="FF9908">Orange</option>
400
									</select> 
401
									<br />
402
									<input type="submit" value="SEND" /> 
403
								</form>
404
								<?php } ?>
405
							</div>
406
						</article>
407
							
408
						<article>
409
							<div>
410
								<h2>Login</h2>
411
							</div>
412
						</article>
413
					</div>
414
				</aside>
415
			</div>
416
			<div id="sortJodelBy" class="row">
417
				<div class="col-sm-12">
418
					<div class="row">
419
						<div class="col-sm-3">
420
							<a href="index.php" <?php if($view=='time') echo 'class="active"';?>><i class="fa fa-clock-o fa-3x"></i></a>
421
						</div>
422
						<div class="col-sm-3">
423
							<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...
424
						</div>
425
						<div class="col-sm-3">
426
							<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...
427
						</div>
428
						<div class="col-sm-3">
429
							<nav>
430
								<a href="./about-us.html">about us</a>
431
							</nav>
432
						</div>
433
					</div>
434
				</div>	
435
			</div>
436
		</div>
437
		
438
		
439
		<!-- jQuery, Tether, Bootstrap JS and own-->
440
		<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...
441
    	<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...
442
    	<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...
443
    	<script src="js/jQueryEmoji.js"></script>
444
445
		<script>
446
			//BackButton
447
			function goBack()
448
			{
449
				window.history.back();
450
			}
451
452
			$(document).ready(function()
453
			{
454
455
456
				//Transform UTF-8 Emoji to img
457
				$('.jodel > content').Emoji();
458
459
				$('a').on('click', function(){
460
				    $('a').removeClass('selected');
461
				    $(this).addClass('selected');
462
				});
463
464
				function scrollToAnchor(aid){
465
				    var aTag = $("article[id='"+ aid +"']");
466
				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
467
				}
468
469
				<?php if(!isset($_GET['postID']) && !isset($_GET['getPostDetails'])) { ?>
470
471
				
472
473
474
475
				var win = $(window);
476
				var lastPostId = "<?php echo $lastPostId; ?>";
477
				var view = "<?php echo $view; ?>"
478
				var old_lastPostId = "";
479
				var morePostsAvailable = true;
480
481
				if(window.location.hash)
482
				{
483
					var hash = window.location.hash.slice(1);
484
485
					if(!$("article[id='"+ hash +"']").length)
486
					{
487
						for (var i = 5; i >= 0; i--)
488
						{
489
							if(!$("article[id='"+ hash +"']").length)
490
							{
491
								$.ajax({
492
									url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
493
									dataType: 'html',
494
									async: false,
495
									success: function(html) {
496
										var div = document.createElement('div');
497
										div.innerHTML = html;
498
										var elements = div.childNodes;
499
										old_lastPostId = lastPostId;
500
										lastPostId = elements[3].textContent;
501
										lastPostId = lastPostId.replace(/\s+/g, '');
502
										//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
503
										if(lastPostId == old_lastPostId) {
504
											
505
											//morePostsAvailable = false;
506
										}
507
										else {
508
											//alert(elements[3].textContent);
509
											$('#posts').append(elements[1].innerHTML);
510
											$('#posts').hide().show(0);
511
										}
512
										$('#loading').hide();
513
									}
514
								});
515
516
								$('.jodel > content').Emoji();
517
							}
518
							
519
						}
520
						scrollToAnchor(hash);
521
522
					}						
523
				}
524
525
				// Each time the user scrolls
526
				win.scroll(function() {
527
528
529
					// End of the document reached?
530
					if (($(document).height() - win.height() == win.scrollTop()) && morePostsAvailable) {
531
						$('#loading').show();
532
533
						
534
						
535
						$.ajax({
536
							url: 'get-posts-ajax.php?lastPostId=' + lastPostId + '&view=' + view,
537
							dataType: 'html',
538
							async: false,
539
							success: function(html) {
540
								var div = document.createElement('div');
541
								div.innerHTML = html;
542
								var elements = div.childNodes;
543
								old_lastPostId = lastPostId;
544
								lastPostId = elements[3].textContent;
545
								lastPostId = lastPostId.replace(/\s+/g, '');
546
								//alert('Neu: ' + lastPostId + " Alt: " + old_lastPostId);
547
								if(lastPostId == old_lastPostId)
548
								{
549
									
550
									//morePostsAvailable = false;
551
								}
552
								else
553
								{
554
									//alert(elements[3].textContent);
555
									$('#posts').append(elements[1].innerHTML);
556
								}
557
								$('#loading').hide();
558
							}
559
						});
560
561
						$('.jodel > content').Emoji();
562
					}
563
				});
564
			<?php } ?>
565
			});	
566
567
		</script>
568
	</body>
569
</html>
570
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...
571