These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | include 'php/jodel-web.php'; |
||
4 | |||
5 | if((!isset($_GET['pw']) || $config['pw'] != $_GET['pw']) && !isUserAdmin()) |
||
6 | { |
||
7 | error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on admin.php'); |
||
8 | die(); |
||
9 | } |
||
10 | else if (isset($_GET['pw'])) |
||
11 | { |
||
12 | setcookie('JodelAdminPassword', $_GET['pw'], time()+60*60*24*365*10); |
||
13 | error_log('admin password saved for [' . $_SERVER ['HTTP_USER_AGENT'] . ']'); |
||
14 | } |
||
15 | |||
16 | |||
17 | |||
18 | if(isset($_POST['createAccount']) && $_POST['createAccount']) |
||
19 | { |
||
20 | $newJodelAccount = new JodelAccount(); |
||
21 | } |
||
22 | |||
23 | |||
24 | //Vote |
||
25 | if(isset($_POST['vote']) && isset($_POST['postId']) && isset($_POST['quantity'])) |
||
26 | { |
||
27 | $i = 0; |
||
0 ignored issues
–
show
|
|||
28 | $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
|
|||
29 | |||
30 | if($result->num_rows > 0) |
||
31 | { |
||
32 | // output data of each row |
||
33 | while(($row = $result->fetch_assoc()) && $i < $_POST['quantity']) |
||
34 | { |
||
35 | $jodelAccount = new JodelAccount($row['device_uid']); |
||
36 | |||
37 | if($jodelAccount->votePostId($_POST['postId'], $_POST['vote'])) |
||
38 | { |
||
39 | $i++; |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 | else |
||
44 | { |
||
45 | 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 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 ( 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: 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. ![]() |
|||
46 | } |
||
47 | } |
||
48 | |||
49 | |||
50 | ?> |
||
51 | <!DOCTYPE html> |
||
52 | <html lang="en"> |
||
53 | <head> |
||
54 | <title>Backend - JodelBlue WebClient</title> |
||
55 | |||
56 | <meta charset="utf8"> |
||
57 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
||
58 | <meta http-equiv="x-ua-compatible" content="ie=edge"> |
||
59 | |||
60 | <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
|
|||
61 | <meta name="keywords" content="jodelblue, jodel, blue, webclient, web, client"> |
||
62 | |||
63 | <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
|
|||
64 | <link rel="stylesheet" href="<?php echo $baseUrl;?>css/font-awesome.min.css"> |
||
65 | <link rel="stylesheet" href="<?php echo $baseUrl;?>style.css" type="text/css"> |
||
66 | |||
67 | <link rel="shortcut icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
||
68 | <link rel="icon" type="image/x-icon" href="<?php echo $baseUrl;?>img/favicon/favicon.ico"> |
||
69 | <link rel="icon" type="image/gif" href="<?php echo $baseUrl;?>img/favicon/favicon.gif"> |
||
70 | <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon.png"> |
||
71 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon.png"> |
||
72 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-57x57.png" sizes="57x57"> |
||
73 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-60x60.png" sizes="60x60"> |
||
74 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-72x72.png" sizes="72x72"> |
||
75 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-76x76.png" sizes="76x76"> |
||
76 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-114x114.png" sizes="114x114"> |
||
77 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-120x120.png" sizes="120x120"> |
||
78 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-128x128.png" sizes="128x128"> |
||
79 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-144x144.png" sizes="144x144"> |
||
80 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-152x152.png" sizes="152x152"> |
||
81 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-180x180.png" sizes="180x180"> |
||
82 | <link rel="apple-touch-icon" href="<?php echo $baseUrl;?>img/favicon/apple-touch-icon-precomposed.png"> |
||
83 | <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-16x16.png" sizes="16x16"> |
||
84 | <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-32x32.png" sizes="32x32"> |
||
85 | <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-96x96.png" sizes="96x96"> |
||
86 | <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-160x160.png" sizes="160x160"> |
||
87 | <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-192x192.png" sizes="192x192"> |
||
88 | <link rel="icon" type="image/png" href="<?php echo $baseUrl;?>img/favicon/favicon-196x196.png" sizes="196x196"> |
||
89 | <meta name="msapplication-TileImage" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
||
90 | <meta name="msapplication-TileColor" content="#5682a3"> |
||
91 | <meta name="msapplication-navbutton-color" content="#5682a3"> |
||
92 | <meta name="application-name" content="JodelBlue"/> |
||
93 | <meta name="msapplication-tooltip" content="JodelBlue"/> |
||
94 | <meta name="apple-mobile-web-app-title" content="JodelBlue"/> |
||
95 | <meta name="msapplication-square70x70logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-70x70.png"> |
||
96 | <meta name="msapplication-square144x144logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-144x144.png"> |
||
97 | <meta name="msapplication-square150x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-150x150.png"> |
||
98 | <meta name="msapplication-wide310x150logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x150.png"> |
||
99 | <meta name="msapplication-square310x310logo" content="<?php echo $baseUrl;?>img/favicon/win8-tile-310x310.png"> |
||
100 | </head> |
||
101 | |||
102 | <body> |
||
103 | <header> |
||
104 | <nav class="navbar navbar-full navbar-dark navbar-fixed-top"> |
||
105 | <div class="container"> |
||
106 | <h1> |
||
107 | <a href="./" class="spinnable"> |
||
108 | |||
109 | JodelBlue <i class="fa fa-refresh fa-1x"></i></a> |
||
110 | </h1> |
||
111 | </div> |
||
112 | </nav> |
||
113 | </header> |
||
114 | |||
115 | <div class="mainContent container"> |
||
116 | <div class="content row"> |
||
117 | <article class="topContent col-sm-8"> |
||
118 | |||
119 | <content id="posts" class="adminpanel"> |
||
120 | <h2>account management</h2> |
||
121 | <form method="post"> |
||
122 | <div> |
||
123 | <?php |
||
124 | $result = $db->query("SELECT COUNT(*) FROM accounts"); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
SELECT COUNT(*) 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 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 ( 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: 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. ![]() |
|||
125 | echo $result->fetch_row()[0]; |
||
126 | ?> |
||
127 | accounts in the database</div> |
||
128 | <button type="submit" name="createAccount" value="TRUE">Create new Account</button> |
||
129 | </form> |
||
130 | <hr> |
||
131 | <h2>voting</h2> |
||
132 | <form method="POST"> |
||
133 | <input placeholder="quantity" type="number" name="quantity"><br> |
||
134 | <input placeholder="postId" type="text" name="postId"><br> |
||
135 | <button type="submit" name="vote" value="up" class="half">Upvote</button> |
||
136 | <button type="submit" name="vote" value="down" class="half">Downvote</button> |
||
137 | </form> |
||
138 | <hr> |
||
139 | <h2>delayed voting</h2> |
||
140 | <input placeholder="quantity" id="quantityDelay" type="number" name="quantity"><br> |
||
141 | <input placeholder="min interval" id="minDelay" value="<?php echo $config["minInterval"]?>" type="text" name="min"><br> |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
minInterval 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 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 ( 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: 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. ![]() |
|||
142 | <input placeholder="max interval" id="maxDelay" value="<?php echo $config["maxInterval"]?>" type="text" name="max"><br> |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
maxInterval 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 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 ( 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: 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. ![]() |
|||
143 | <input placeholder="postId" id="postIdDelay" value="<?php echo $_GET["postId"]?>" type="text" name="postId"><br> |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
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 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 ( 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: 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. ![]() |
|||
144 | <button name="vote" value="up" class="half" onClick="vote('up');">Upvote</button> |
||
145 | <button name="vote" value="down" class="half" onClick="vote('down');">Downvote</button><br> |
||
146 | <progress id="progressDelay" value="0" max="100"></progress> |
||
147 | <div id="ResponseMessage"></div> |
||
148 | <div id="ResponseCaptcha"></div> |
||
149 | |||
150 | </content> |
||
151 | </article> |
||
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
|
|||
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
|
|||
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
|
|||
160 | |||
161 | <script> |
||
162 | //delayed voting |
||
163 | var rekData; |
||
164 | function vote(type) |
||
165 | { |
||
166 | var id = $("#postIdDelay").val(); |
||
167 | var quantity = parseInt($("#quantityDelay").val()); |
||
168 | var minTime = parseFloat($("#minDelay").val()); |
||
169 | var maxTime = parseFloat($("#maxDelay").val()); |
||
170 | var data = {"vote": type, |
||
171 | "id":id, |
||
172 | "i": 1, |
||
173 | "quantity":quantity, |
||
174 | "minTime":minTime, |
||
175 | "maxTime":maxTime}; |
||
176 | |||
177 | $("#progressDelay").attr("max", quantity); |
||
178 | $("#progressDelay").val(0); |
||
179 | if (minTime > maxTime) |
||
180 | { |
||
181 | $("#ResponseMessage").html("min interval is greater than max interval"); |
||
182 | |||
183 | } |
||
184 | else if (id == "") |
||
185 | { |
||
186 | $("#ResponseMessage").html("please enter a postId"); |
||
187 | } |
||
188 | else if (isNaN(quantity)) |
||
189 | { |
||
190 | $("#ResponseMessage").html("please enter a valid quantity of votes"); |
||
191 | } |
||
192 | else |
||
193 | { |
||
194 | voteRek(data); |
||
195 | } |
||
196 | } |
||
197 | |||
198 | function voteRek(data) |
||
199 | { |
||
200 | $.ajax({ |
||
201 | type: "POST", |
||
202 | url: "<?php echo $baseUrl;?>vote-ajax.php?pw=<?php echo $_GET["pw"]?>", |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
pw 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 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 ( 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: 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. ![]() |
|||
203 | data: {"vote" : data["vote"], |
||
204 | "postId" : data["id"]}, |
||
205 | success: function(result){ |
||
206 | $("#progressDelay").val(data["i"]); |
||
207 | var response; |
||
208 | try |
||
209 | { |
||
210 | response = JSON.parse(result); |
||
211 | } catch (e) { |
||
212 | //voteRek(data); |
||
213 | } |
||
214 | if (response["success"] != true) |
||
215 | { |
||
216 | $("#ResponseMessage").html(response["message"]); |
||
217 | if (response["captcha"] != null) { |
||
218 | rekData = data; |
||
219 | $("#ResponseCaptcha").append( "<div id='captchaWrapper_" + data["i"] + "'><img src='" + response["captcha"]["image_url"] + "' style='width:100%'><div class='captchaWrapper'><input id='box_0' type='checkbox'><input id='box_1' type='checkbox'><input id='box_2' type='checkbox'><input id='box_3' type='checkbox'><input id='box_4' type='checkbox'><input id='box_5' type='checkbox'><input id='box_6' type='checkbox'><input id='box_7' type='checkbox'><input id='box_8' type='checkbox'></div><button onClick=\"verifyAccount(" + data["i"] + ", '" + response["captcha"]["key"] + "' , '" + response["deviceUid"] + "');\">Verify</button></div>"); |
||
0 ignored issues
–
show
|
|||
220 | //verifyAccount(data["i"], response["captcha"]["key"], response["deviceUid"]); |
||
221 | } |
||
222 | } |
||
223 | else if (data["i"] < data["quantity"]) |
||
224 | { |
||
225 | $("#ResponseMessage").html(data["i"] + " of " + data["quantity"]); |
||
226 | data["i"] += 1; |
||
227 | setTimeout(function(){voteRek(data)}, getRandomFloat(data["minTime"],data["maxTime"])*1000); |
||
228 | } else { |
||
229 | $("#ResponseMessage").html(data["quantity"] + " votes completed"); |
||
230 | } |
||
231 | } |
||
232 | }); |
||
233 | } |
||
234 | |||
235 | function verifyAccount(id, key, deviceUid) |
||
236 | { |
||
237 | var solution = ""; |
||
238 | for (i=0; i<9; i++) { |
||
239 | var box = $("#box_"+i); |
||
240 | if (box.is(':checked') == true) |
||
241 | { |
||
242 | if (solution != "") |
||
243 | { |
||
244 | solution += "-" + i; |
||
245 | } |
||
246 | else |
||
247 | { |
||
248 | solution = i; |
||
249 | } |
||
250 | |||
251 | } |
||
252 | } |
||
253 | console.log(solution); |
||
254 | $.ajax({ |
||
255 | type: "POST", |
||
256 | url: "<?php echo $baseUrl;?>vote-ajax.php?pw=<?php echo $_GET["pw"]?>&solution=" + solution + "&key="+key, |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
pw 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 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 ( 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: 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. ![]() |
|||
257 | data: {"deviceUid" : deviceUid}, |
||
258 | success: function(result){ |
||
259 | var response = JSON.parse(result); |
||
260 | console.log("Verification = "+response["success"]) |
||
261 | $("#captchaWrapper_"+id).remove(); |
||
262 | voteRek(rekData); |
||
263 | } |
||
264 | }); |
||
265 | } |
||
266 | |||
267 | function getRandomFloat(min, max) |
||
268 | { |
||
269 | return Math.floor(Math.random() * (max - min)) + min; |
||
270 | } |
||
271 | |||
272 | </script> |
||
273 | </body> |
||
274 | </html> |
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
will produce issues in the first and second line, while this second example
will produce no issues.