Issues (1020)

Security Analysis    no vulnerabilities found

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

models/MaintenanceChallenge.php (29 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
class MaintenanceChallenge extends CModel
3
{
4
    private $_finishable = [];
5
6
    public function attributeNames() {
7
        return [];
8
    }
9
10
    public function fetchFinishable() {
11
        $res = Yii::app()->db->createCommand()
12
            ->select('*')
13
            ->from('command_stack')
14
            ->where('process_time <= NOW()')
15
            ->queryAll();
16
        foreach ($res as $d) {
17
            $d['params'] = CJSON::decode($d['params']);
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 17 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...
18
            $this->_finishable[$d['id']] = $d;
19
        }
20
    }
21
22
    public function process() {
23
        if (!count($this->_finishable)) return false;
24
25
        foreach ($this->_finishable as $cmd) {
26
            $command = $cmd['command'];
27
            if (method_exists('MaintenanceChallenge', $command)) {
28
                $this->$command($cmd['params']);
29
                $this->deleteCommand($cmd['id']);
30
            }
31
        }
32
    }
33
34
    private function endChallenge($params) {
35
        $id = (int)$params['id'];
36
37
38
        $ch = Yii::app()->db->createCommand()
39
            ->select('*')
40
            ->from('challenge')
41
            ->where('id=:id', [':id'=>$id])
42
            ->queryRow();
43
44
        if ($ch['winner']) return false;
45
46
        if ($ch['point_caller'] <> $ch['point_opponent']) {
47
            //not equal points
48
            $winnerTag = $ch['point_caller'] < $ch['point_opponent'] ? 'opponent' : 'caller'; //caller only lose, if she has less points, that opponent.
49
        } else {
50
            //equal points
51
            $winnerTag = $ch['cnt_won_caller'] < $ch['cnt_won_opponent'] ? 'opponent' : 'caller'; //caller only lose, if she has less won games, that opponent.
52
        }
53
54
        $looserTag = $winnerTag == 'caller' ? 'opponent' : 'caller';
55
56
        $forum = new Forum;
57
58
        //without games
59
        if (!$ch['cnt_won_caller'] and !$ch['cnt_won_opponent']) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as and instead of && is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
60
            //close unplayed challenge, no winners
61
            $msg = "{$ch['name_caller']} - {$ch['name_opponent']}: ez a verseny párbajok nélkül ért véget, így jutalmat sem kaptok.";
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.

Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $ch instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
62
            $forum->id = $ch['caller'];
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Forum.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
63
            $forum->save($msg, true);
64
            $forum->id = $ch['opponent'];
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Forum.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
65
            $forum->save($msg, true);
66
67
            //update the winner-state
68
            Yii::app()->db->createCommand()
69
                ->update('challenge', ['winner'=>3], 'id=:id', [':id'=>$id]);
70
            return false;
71
        }
72
73
        $forum->id = $ch[$winnerTag];
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Forum.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
74
75
        $club = new Club;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 5 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...
76
        $club->id = $ch[$winnerTag]; //winner club
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Club.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
77
        $club->fetch();
78
        $club->fetchMembers();
79
80
81
        $winnerMsg = "Gratulálok! :) Győztetek a következő versenyben: <b> {$ch['name_caller']} - {$ch['name_opponent']}</b>. ";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $ch instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
82
        $looserMsg = "Sajnos elbuktátok a következő versenyt: <b> {$ch['name_caller']} - {$ch['name_opponent']}</b>. ";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $ch instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
83
84
        //distribute the loot
85
        $members = [$club->owner=>$club->ownerName];
0 ignored issues
show
The property owner cannot be accessed from this context as it is declared private in class Club.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
The property ownerName cannot be accessed from this context as it is declared private in class Club.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
86
        foreach ($club->members as $member) {
0 ignored issues
show
The property members cannot be accessed from this context as it is declared private in class Club.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
87
            $members[$member['uid']] = $member['user'];
88
        }
89
        $cntMembers = count($members);
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 4 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...
90
        $loot = (int)$ch['loot_'.$winnerTag];
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 10 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...
91
        $lootPerMember = floor($loot / $cntMembers);
92
93
        $forum->id = $ch[$winnerTag];
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Forum.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
94
        if ($lootPerMember > 0) {
95
            $winnerMsg .= "Minden tag <b> {$lootPerMember}$</b>-t kap a zsákmányból. Név szerint: ";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $lootPerMember instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
96
97
            $contest = new Contest;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 5 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...
98
            $listPlayers = [];
99
            $p = new Player;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 11 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...
100
            foreach ($members as $uid => $member) {
101
                $p->setAllAttributes($uid);
102
                $incr = ['dollar'=>$lootPerMember];
103
                $p->updateAttributes($incr, []);
104
                $contest->addPoints($p->uid, Contest::ACT_DUEL, 0, 0, $incr['dollar']);
0 ignored issues
show
The property uid cannot be accessed from this context as it is declared private in class Player.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
105
106
                $listPlayers[] = $p->user;
0 ignored issues
show
The property user cannot be accessed from this context as it is declared private in class Player.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
107
            }
108
            $winnerMsg .= join(', ', $listPlayers) . '. ';
109
        } else {
110
            $winnerMsg .= "Sajnos a zsákmány ({$loot}$) túl alacsony ahhoz, hogy osztozzatok rajta. ";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $loot instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
111
        }
112
        $lootLosers = (int)$ch['loot_'.$looserTag];
113
        $looserMsg .= "Mivel nem nyertetek, a zsákmány ({$lootLosers}$) a horgásszövetség tulajdonába kerül. Köszönik szépen!";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $lootLosers instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
114
115
        //refresh the toplist
116
        $winnerPoints = (int)$ch['point_'.$winnerTag];
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 21 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...
117
        if (!$winnerPoints) $winnerPoints = 1; //when result is 0:0
118
119
        Yii::app()->redis->getClient()->zIncrBy('board_c:'.date('Ym'), $winnerPoints, $ch[$winnerTag]);
120
121
        $winnerMsg .= "A klub <b> {$winnerPoints} pontot </b> erősödött a ranglistán.";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $winnerPoints instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
122
123
        //report
124
        $forum->id = $ch[$winnerTag];
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Forum.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
125
        $forum->save($winnerMsg, true);
126
        $forum->id = $ch[$looserTag];
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Forum.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
127
        $forum->save($looserMsg, true);
128
129
        //refresh the winner state of the challenge
130
        $winner = $winnerTag=='caller' ? 1 : 2;
131
        Yii::app()->db->createCommand()
132
            ->update('challenge', ['winner'=>$winner], 'id=:id', [':id'=>$id]);
133
134
        return true;
135
    }
136
137
    private function deleteCommand($id) {
138
        Yii::app()->db->createCommand()
139
            ->delete('command_stack', 'id=:id', [':id'=>(int)$id]);
140
    }
141
}
0 ignored issues
show
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
142