Completed
Push — master ( 277882...5162b8 )
by mains
10s
created

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