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/DuelList.php (21 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
/**
3
 * @property array $opponents
4
 * @property CPagination $pagination
5
 * @property integer $count
6
 * @property string $clubName
7
 * @property integer $page
8
 */
9
class DuelList extends CModel
10
{
11
    private $opponents = [];
12
    private $pagination;
13
    private $count;
14
    private $page = 0;
15
16
    public function attributeNames()
17
    {
18
        return [];
19
    }
20
21
    public function getOpponents()
22
    {
23
        return $this->opponents;
24
    }
25
26
    public function getPagination()
27
    {
28
        return $this->pagination;
29
    }
30
31
    public function getCount()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
32
    {
33
        return $this->count;
34
    }
35
36
    /**
37
     * @param Club $club
38
     */
39
    public function getClubName($club, $id)
40
    {
41
        if ($id) {
42
            $club->id = $id;
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...
43
            $club->fetchName();
44
            return '<span> | ' .  $club->name . '</span>';
0 ignored issues
show
The property name 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...
45
        }
46
        return '';
47
    }
48
49
    public function setPage($page)
50
    {
51
        $this->page = $page;
52
    }
53
54
    public function fetchOpponents()
55
    {
56
        $player = Yii::app()->player->model;
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.

Loading history...
57
        $limit = Yii::app()->params['listPerPage'];
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...
58
        $minLevel = $player->level - Yii::app()->params['duelWeakerOpponentLevelDiff'];
59
        if ($minLevel < Yii::app()->params['duelLevelRequirement']) {
60
            $minLevel = Yii::app()->params['duelLevelRequirement'];
61
        }
62
63
        $this->count = Yii::app()->db->createCommand()
64
            ->select('COUNT(*) AS count')
65
            ->from('main')
66
            ->where('uid <> :uid AND level >= :minLevel', [':uid'=>$player->uid, ':minLevel'=>$minLevel])
67
            ->queryScalar();
68
69
        $res = Yii::app()->db->createCommand()
70
            ->select('uid, user, level, energy_max, energy, dollar, in_club')
71
            ->from('main')
72
            ->where('uid <> :uid AND level >= :minLevel', [':uid'=>$player->uid, ':minLevel'=>$minLevel])
73
            ->order('level ASC')
74
            ->limit($limit, ($this->page * $limit) - $limit) // the trick is here!
75
            ->queryAll();
76
77
        $this->pagination = new CPagination($this->count);
78
        $this->pagination->setPageSize(Yii::app()->params['listPerPage']);
79
80
        $club = new Club();
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.

Loading history...
81
        $duelShiel = new DuelShield();
82
83
        foreach ($res as $item) {
84
            $duelShiel->uid = $item['uid'];
0 ignored issues
show
The property uid cannot be accessed from this context as it is declared private in class DuelShield.

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...
85
            if ($duelShiel->lifeTime > 0) {
86
                $item['energy'] = 0;
87
            }
88
89
            $item['disabled'] = 0;
90
            if ($item['energy'] <= $item['energy_max'] / 10) {
91
                $item['disabled'] = 1; //low energy
92
            }
93
            $item['prize'] = round($item['dollar'] / 10);
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...
94
            $item['clubName'] = $this->getClubName($club, $item['in_club']);
95
96
            $this->opponents[$item['uid']] = $item;
97
        }
98
    }
99
100
    public function fetchCommonRivals()
101
    {
102
        $player = Yii::app()->player->model;
103
        $limit = Yii::app()->params['listPerPage'];
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 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...
104
105
        $res = Yii::app()->db->createCommand()
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...
106
            ->select('uid, COUNT(*) AS cnt')
107
            ->from('duel_player')
108
            ->where('uid <> :uid AND duel_id IN (SELECT duel_id FROM duel_player WHERE uid=:uid)', [':uid'=>$player->uid])
109
            ->group('uid')
110
            ->order('cnt DESC')
111
            ->limit($limit)
112
            ->queryAll();
113
        $club = new Club();
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.

Loading history...
114
        $duelShiel = new DuelShield();
115
116
        foreach ($res as $item) {
117
            $p = Yii::app()->db->createCommand()
118
                ->select('user, energy, energy_max, dollar, level, in_club')
119
                ->from('main')
120
                ->where('uid=:uid', [':uid'=>(int)$item['uid']])
121
                ->queryRow();
122
            if (!is_array($p)) {
123
                continue;
124
            }
125
126
            foreach ($p as $k => $v) {
127
                $item[$k] = $v;
128
            }
129
130
            $duelShiel->uid = $item['uid'];
0 ignored issues
show
The property uid cannot be accessed from this context as it is declared private in class DuelShield.

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...
131
            if ($duelShiel->lifeTime > 0) {
132
                $item['energy'] = 0;
133
            }
134
135
            $item['disabled'] = 0;
136
            if ($item['energy'] <= $item['energy_max'] / 10) {
137
                $item['disabled'] = 1; //low energy
138
            }
139
140
            if ($player->level - $item['level'] > Yii::app()->params['duelWeakerOpponentLevelDiff']) {
141
                $item['disabled'] = 2; //too weak
142
            }
143
144
            $item['prize'] = round($item['dollar'] / 10);
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...
145
            $item['clubName'] = $this->getClubName($club, $item['in_club']);
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 14 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...
146
            $this->opponents[$item['uid']] = $item;
147
        }
148
    }
149
150
    public function fetchLastRivals()
151
    {
152
        $player = Yii::app()->player->model;
153
        $limit = Yii::app()->params['listPerPage'];
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 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...
154
155
        $res = Yii::app()->db->createCommand()
156
            ->select('id, caller, created')
157
            ->from('duel')
158
            ->where('opponent=:uid', [':uid'=>$player->uid])
159
            ->order('id DESC')
160
            ->limit($limit)
161
            ->queryAll();
162
163
        $club = new Club();
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.

Loading history...
164
        $duelShiel = new DuelShield();
165
        $cache = [];
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...
166
        foreach ($res as $item) {
167
            $item['uid'] = $item['caller'];
168
169
            if (!isset($cache[$item['uid']])) {
170
                $p = Yii::app()->db->createCommand()
171
                    ->select('user, energy, energy_max, dollar, level, in_club')
172
                    ->from('main')
173
                    ->where('uid=:uid', [':uid'=>(int)$item['uid']])
174
                    ->queryRow();
175
                if (!is_array($p)) {
176
                    continue;
177
                }
178
179
                $cache[$item['uid']] = $p;
180
            } else {
181
                $p = $cache[$item['uid']];
182
            }
183
184
            foreach ($p as $k => $v) {
185
                $item[$k] = $v;
186
            }
187
188
            $duelShiel->uid = $item['uid'];
0 ignored issues
show
The property uid cannot be accessed from this context as it is declared private in class DuelShield.

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...
189
            if ($duelShiel->lifeTime > 0) {
190
                $item['energy'] = 0;
191
            }
192
193
            $item['disabled'] = 0;
194
            if ($item['energy'] <= $item['energy_max'] / 10) {
195
                $item['disabled'] = 1; //low energy
196
            }
197
198
            $item['prize'] = round($item['dollar'] / 10);
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...
199
            $item['clubName'] = $this->getClubName($club, $item['in_club']);
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 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...
200
            $this->opponents[] = $item;
201
        }
202
    }
203
}
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...
204