This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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['postId']) && $_GET['vote']) |
||
6 | { |
||
7 | header('Content-Type: application/json'); |
||
8 | $voteResult = $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
||
9 | echo json_encode($voteResult); |
||
10 | die(); |
||
11 | } |
||
12 | |||
13 | View Code Duplication | if(isset($_GET['solution']) && isset($_POST['deviceUid'])) |
|
14 | { |
||
15 | $jodelAccount = new JodelAccount($_POST['deviceUid']); |
||
16 | $response = array("success" => $jodelAccount->verifyCaptcha()); |
||
17 | echo json_encode($response); |
||
18 | die(); |
||
19 | } |
||
20 | $userIsAdmin = isUserAdmin(); |
||
21 | if(!$userIsAdmin) |
||
22 | { |
||
23 | $userIsVoter = isUserVoter(); |
||
24 | } |
||
25 | else |
||
26 | { |
||
27 | $userIsVoter = false; |
||
28 | } |
||
29 | |||
30 | if(!$userIsVoter && !$userIsAdmin) |
||
31 | { |
||
32 | error_log($_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php'); |
||
33 | $response = array("message" => $_SERVER['REMOTE_ADDR'] . ' used a wrong password on vote-ajax.php',"success" => false); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
success 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. ![]() |
|||
34 | echo json_encode($response); |
||
35 | die(); |
||
36 | } |
||
37 | else |
||
38 | { |
||
39 | if($userIsVoter) |
||
40 | { |
||
41 | $result = $db->query("SELECT user_token, remaining_votes FROM users WHERE user_token = '" . $_COOKIE['JodelVoterPassword'] . "'"); |
||
42 | if($result->num_rows > 0) |
||
43 | { |
||
44 | $row = $result->fetch_assoc(); |
||
45 | $remaining_votes = $row['remaining_votes']; |
||
46 | } |
||
47 | if($remaining_votes <= 0) |
||
48 | { |
||
49 | $message = 'This voter account run out of votes. For more information please contact [email protected]'; |
||
50 | $success = false; |
||
51 | |||
52 | $response = array("success" => $success, "message" => $message); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
success 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. ![]() Coding Style
Comprehensibility
introduced
by
The string literal
message 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. ![]() |
|||
53 | echo json_encode($response); |
||
54 | die(); |
||
55 | } |
||
56 | } |
||
57 | |||
58 | |||
59 | $message = ""; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
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. ![]() |
|||
60 | $success = true; |
||
61 | $token = ""; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 3 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. ![]() Coding Style
Comprehensibility
introduced
by
The string literal
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. ![]() |
|||
62 | if(isset($_POST['vote']) && isset($_POST['postId'])) |
||
63 | { |
||
64 | $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. ![]() |
|||
65 | $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
|
|||
66 | |||
67 | if($result->num_rows > 0) |
||
68 | { |
||
69 | $row = $result->fetch_assoc(); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 9 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. ![]() |
|||
70 | $accessToken = $row['access_token']; |
||
71 | $deviceUid = $row['device_uid']; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 3 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. ![]() |
|||
72 | |||
73 | $jodelAccount = new JodelAccount($deviceUid); |
||
74 | |||
75 | if(!$jodelAccount->isAccountVerified()) |
||
76 | { |
||
77 | $message = "This account is not verified. Please verify this account first."; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
This account is not veri...ify this account first. 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. ![]() |
|||
78 | $captcha = $jodelAccount->getCaptcha(); |
||
79 | |||
80 | $_GET['key'] = $captcha["key"]; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 7 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. ![]() Coding Style
Comprehensibility
introduced
by
The string literal
key 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. ![]() |
|||
81 | $_GET['deviceUid'] = $deviceUid; |
||
82 | |||
83 | $success = false; |
||
84 | } |
||
85 | else |
||
86 | { |
||
87 | if($userIsVoter) |
||
88 | { |
||
89 | $remaining_votes = $remaining_votes - 1; |
||
90 | $result = $db->query("UPDATE users |
||
91 | SET remaining_votes='" . $remaining_votes . "' |
||
92 | WHERE user_token='" . $_COOKIE['JodelVoterPassword'] . "'"); |
||
93 | View Code Duplication | if($result === false) |
|
94 | { |
||
95 | error_log("Update remaining votes failed: (" . $db->errno . ") " . $db->error); |
||
96 | } |
||
97 | $db->close(); |
||
98 | } |
||
99 | $jodelAccount->votePostId($_POST['postId'], $_POST['vote']); |
||
100 | //Feedback |
||
101 | } |
||
102 | } |
||
103 | else |
||
104 | { |
||
105 | $message = 'There is no account available for this jodel. Please create at least one new account to vote this jodel.'; |
||
0 ignored issues
–
show
|
|||
106 | $success = false; |
||
107 | } |
||
108 | } |
||
109 | |||
110 | if(isset($captcha)) |
||
111 | { |
||
112 | $response = array("success" => $success, "message" => $message, "captcha" => $captcha, "deviceUid" => $deviceUid); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
success 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. ![]() Coding Style
Comprehensibility
introduced
by
The string literal
message 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. ![]() Coding Style
Comprehensibility
introduced
by
The string literal
captcha 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. ![]() |
|||
113 | } |
||
114 | else |
||
115 | { |
||
116 | $response = array("success" => $success, "message" => $message); |
||
117 | } |
||
118 | } |
||
119 | echo json_encode($response); |
||
120 | ?> |
||
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. ![]() |
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.
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.