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