Completed
Push — master ( a546a7...10dc14 )
by mains
02:38
created

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