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