Completed
Push — master ( 6fce2f...9d108c )
by mains
16:33
created

admin.php (12 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
11
12
if(isset($_POST['createAccount']) && $_POST['createAccount'])
13
{
14
	createAccount();
15
}
16
17
18
//Vote
19
if(isset($_POST['vote']) && isset($_POST['postId']) && isset($_POST['quantity']))
20
{
21
	$i = 0;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 6 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...
22
	$result = $db->query("SELECT access_token FROM accounts");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal SELECT access_token FROM accounts 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...
23
24
	if($result->num_rows > 0)
25
	{
26
		// output data of each row
27
		while(($row = $result->fetch_assoc()) && $i < $_POST['quantity'])
28
		{
29
			$accessToken = $row['access_token'];
30
			
31
			$location = getLocationByAccessToken($accessToken);
32
33
			$accessToken = isTokenFreshByAccessToken($location, $accessToken);
34
35
36 View Code Duplication
			if($_POST['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...
37
				$accountCreator = new Upvote();
38
			}
39
			else if($_POST['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...
40
				$accountCreator = new Downvote();
41
			}
42
43
			$accountCreator->setAccessToken($accessToken);
44
			$accountCreator->postId = $_POST['postId'];
45
			$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...
46
			if(array_key_exists('post', $data))
47
			{
48
				$i++;
49
			}
50
		}
51
	}
52
	else
53
	{
54
		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...
55
	}
56
}
57
58
59
?>
60
<!DOCTYPE html>
61
<html lang="en">
62
	<head>
63
		<title>Backend - JodelBlue WebClient</title>
64
		
65
		<meta charset="utf8">
66
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
67
		<meta http-equiv="x-ua-compatible" content="ie=edge">
68
		
69
		<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...
70
		<meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client">
71
		
72
		<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...
73
		<link rel="stylesheet" href="css/font-awesome.min.css">
74
		<link rel="stylesheet" href="style.css" type="text/css">
75
		
76
		<link rel="shortcut icon" type="image/x-icon" href="./img/favicon/favicon.ico">
77
		<link rel="icon" type="image/x-icon" href="./img/favicon/favicon.ico">
78
		<link rel="icon" type="image/gif" href="./img/favicon/favicon.gif">
79
		<link rel="icon" type="image/png" href="./img/favicon/favicon.png">
80
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon.png">
81
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-57x57.png" sizes="57x57">
82
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-60x60.png" sizes="60x60">
83
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-72x72.png" sizes="72x72">
84
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-76x76.png" sizes="76x76">
85
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-114x114.png" sizes="114x114">
86
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-120x120.png" sizes="120x120">
87
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-128x128.png" sizes="128x128">
88
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-144x144.png" sizes="144x144">
89
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-152x152.png" sizes="152x152">
90
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-180x180.png" sizes="180x180">
91
		<link rel="apple-touch-icon" href="./img/favicon/apple-touch-icon-precomposed.png">
92
		<link rel="icon" type="image/png" href="./img/favicon/favicon-16x16.png" sizes="16x16">
93
		<link rel="icon" type="image/png" href="./img/favicon/favicon-32x32.png" sizes="32x32">
94
		<link rel="icon" type="image/png" href="./img/favicon/favicon-96x96.png" sizes="96x96">
95
		<link rel="icon" type="image/png" href="./img/favicon/favicon-160x160.png" sizes="160x160">
96
		<link rel="icon" type="image/png" href="./img/favicon/favicon-192x192.png" sizes="192x192">
97
		<link rel="icon" type="image/png" href="./img/favicon/favicon-196x196.png" sizes="196x196">
98
		<meta name="msapplication-TileImage" content="./img/favicon/win8-tile-144x144.png"> 
99
		<meta name="msapplication-TileColor" content="#5682a3"> 
100
		<meta name="msapplication-navbutton-color" content="#5682a3"> 
101
		<meta name="application-name" content="JodelBlue"/> 
102
		<meta name="msapplication-tooltip" content="JodelBlue"/> 
103
		<meta name="apple-mobile-web-app-title" content="JodelBlue"/> 
104
		<meta name="msapplication-square70x70logo" content="./img/favicon/win8-tile-70x70.png"> 
105
		<meta name="msapplication-square144x144logo" content="./img/favicon/win8-tile-144x144.png"> 
106
		<meta name="msapplication-square150x150logo" content="./img/favicon/win8-tile-150x150.png"> 
107
		<meta name="msapplication-wide310x150logo" content="./img/favicon/win8-tile-310x150.png"> 
108
		<meta name="msapplication-square310x310logo" content="./img/favicon/win8-tile-310x310.png"> 
109
	</head>
110
	
111
	<body>
112
		<header>
113
			<nav class="navbar navbar-full navbar-dark navbar-fixed-top">
114
				<div class="container">					
115
						<h1>
116
						<a href="./" class="spinnable">
117
						
118
						JodelBlue <i class="fa fa-refresh fa-1x"></i></a>
119
					</h1>					
120
				</div>
121
			</nav>
122
		</header>
123
		
124
		<div class="mainContent container">		
125
			<div class="content row">
126
				<article class="topContent col-sm-8">
127
128
					<content id="posts">
129
						<form method="post">
130
							<button type="submit" name="createAccount" value="TRUE">Create new Account</button>
131
						</form>
132
133
						<form method="post">
134
							quantity<input type="number" name="quantity">
135
							postId<input type="text" name="postId">
136
							<button type="submit" name="vote" value="up">Upvote</button>
137
							<button type="submit" name="vote" value="down">Downvote</button>
138
						</form>
139
					</content>
140
				</article>
141
			
142
				<aside class="topSidebar col-sm-4 sidebar-outer">
143
					<div class="fixed">
144
						<article>
145
							
146
						</article>
147
					</div>
148
				</aside>
149
			</div>
150
			<div id="sortJodelBy" class="row">
151
				<div class="col-sm-12">
152
					<div class="row">
153
						
154
					</div>
155
				</div>	
156
			</div>
157
		</div>
158
		
159
		
160
		<!-- jQuery, Tether, Bootstrap JS and own-->
161
		<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...
162
    	<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...
163
    	<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...
164
    	<script src="js/jQueryEmoji.js"></script>
165
166
		<script>
167
			//BackButton
168
			function goBack()
169
			{
170
				window.history.back();
171
			}
172
173
			$(document).ready(function()
174
			{
175
176
177
				//Transform UTF-8 Emoji to img
178
				$('.jodel > content').Emoji();
179
180
				$('a').on('click', function(){
181
				    $('a').removeClass('selected');
182
				    $(this).addClass('selected');
183
				});
184
185
				function scrollToAnchor(aid){
186
				    var aTag = $("article[id='"+ aid +"']");
187
				    $('html,body').animate({scrollTop: aTag.offset().top-90},'slow');
188
				}
189
			});	
190
191
		</script>
192
	</body>
193
</html>