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/Leaderboard.php (16 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 integer $uid
4
 * @property integer $inClub
5
 * @property array $items
6
 * @property string $boardType
7
 * @property string $range
8
 * @property string $title
9
 * @property string $playerRankDescription
10
 * @property string $clubRankDescription
11
 */
12
class Leaderboard extends CModel
13
{
14
    const BOARD_RANGE = 5;
15
    const TYPE_PLAYER = 'board_p';
16
    const TYPE_CLUB = 'board_c';
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...
17
18
    const RANGE_ACTUAL = 'actual';
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...
19
    const RANGE_PREVIOUS = 'prev';
20
    const RANGE_LAST_SIX = 'last';
21
22
    private $uid;
23
    private $inClub;
24
    private $items = [];
25
    private $key = '';
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...
26
    private $boardType;
27
    private $range;
28
29
    public function attributeNames()
30
    {
31
        return [];
32
    }
33
34
    public function getUid()
35
    {
36
        return $this->uid;
37
    }
38
39
    public function getInClub()
40
    {
41
        return $this->inClub;
42
    }
43
44
    public function getItems()
45
    {
46
        return $this->items;
47
    }
48
49
    public function getBoardType()
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...
50
    {
51
        return $this->boardType;
52
    }
53
54
    public function getRange()
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...
55
    {
56
        return $this->range;
57
    }
58
59
    public function getTitle()
60
    {
61
        $titles = [
62
            self::TYPE_PLAYER => [
63
            self::RANGE_ACTUAL => 'Aktuális hónap legjobb játékosai',
64
            self::RANGE_PREVIOUS => 'Előző hónap legjobb játékosai',
65
            self::RANGE_LAST_SIX => 'Utolsó 6 hónap legjobb játékosai',
66
            ],
67
            self::TYPE_CLUB => [
68
            self::RANGE_ACTUAL => 'Aktuális hónap legjobb klubjai',
69
            self::RANGE_PREVIOUS => 'Előző hónap legjobb klubjai',
70
            self::RANGE_LAST_SIX => 'Utolsó 6 hónap legjobb klubjai',
71
            ]
72
            ];
73
        return $titles[$this->boardType][$this->range];
74
    }
75
76 View Code Duplication
    public function getPlayerRankDescription()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
77
    {
78
        $redis = Yii::app()->redis->getClient();
79
80
        $total = $redis->zCard($this->key);
81
        $rank  = $redis->zRevRank($this->key, $this->uid) + 1;
82
83
        if ($rank == 1) {
84
            return 'Te vagy a király!';
85
        } else {
86
            $percent = round((1 - ($rank / $total)) * 100, 1);
87
            if (!$percent) {
88
                return 'Több párbajgyőzelemre van szükséged.';
89
            }
90
91
            return 'Jobb vagy, mint a játékosok ' . $percent . '%-a!';
92
        }
93
    }
94
95 View Code Duplication
    public function getClubRankDescription()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
96
    {
97
        $redis = Yii::app()->redis->getClient();
98
99
        $total = $redis->zCard($this->key);
100
        $rank  = $redis->zRevRank($this->key, $this->inClub) + 1;
101
102
        if ($rank == 1) {
103
            return 'A te klubod a király!';
104
        } else {
105
            $percent = round((1 - ($rank / $total)) * 100, 1);
106
            if (!$percent) {
107
                return 'Több versenygyőzelemre van szükségetek.';
108
            }
109
110
            return 'Jobb a klubod, mint a többi klub ' . $percent . '%-a!';
111
        }
112
    }
113
114
    public function setBoardType ($type)
115
    {
116
        $this->boardType = $type;
117
    }
118
119
    public function setRange ($range)
120
    {
121
        $d = new DateTime();
122
123
        //create key from date/intersect
124
        switch ($range) {
125
            case self::RANGE_LAST_SIX:
126
                $this->key = $this->boardType . ':6month';
127
                //create intersect
128
129
                $history = [];
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...
130
                $history[] = $this->boardType . ':' . $d->format('Ym');
131
132
                for ($i=0; $i<6; $i++) {
133
                    $d->modify('first day of previous month');
134
                    $history[] = $this->boardType . ':' . $d->format('Ym');
135
                }
136
137
                $redis = Yii::app()->redis->getClient();
138
                $redis->zUnionStore($this->key, $history);
139
140
                break;
141 View Code Duplication
            case self::RANGE_PREVIOUS:
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
142
                $d->modify('first day of previous month');
143
                $this->key = $this->boardType . ':' . $d->format('Ym');
144
                break;
145 View Code Duplication
            default:
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
146
                $range = self::RANGE_ACTUAL;
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...
147
                $this->key = $this->boardType . ':' . $d->format('Ym');
148
        }
149
        $this->range = $range;
150
    }
151
152
    public function setUid($uid)
153
    {
154
        $this->uid = (int)$uid;
155
    }
156
157
    public function setInClub($id)
158
    {
159
        $this->inClub = (int)$id;
160
    }
161
162
    public function fetchList()
163
    {
164
        if ($this->boardType == self::TYPE_PLAYER) {
165
            $class = 'Player';
166
        } else {
167
            $class = 'Club';
168
        }
169
170
        $redis = Yii::app()->redis->getClient();
171
172
        $myRank = $redis->zRevRank($this->key, $this->inClub);
173
174
        $range = self::BOARD_RANGE;
175
        $min = $myRank - $range > 0 ? $myRank - $range : 0;
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...
176
        $max = $myRank + $range + ($range-$myRank+$min);
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...
177
178
        $item = new $class;
179
        $i = $min+1;
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...
180 View Code Duplication
        foreach ($redis->zRevRange($this->key, $min, $max, true) as $id => $score) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
181
            $item->subjectId = $id;
182
183
            $this->items[$i] = [
184
                'id'=>$id,
185
                'name'=>$item->getSubjectName(),
186
                'score'=>$score,
187
                ];
188
            $i++;
189
        }
190
    }
191
192
    public function getRankDescription()
193
    {
194
        if ($this->boardType == self::TYPE_CLUB) {
195
            $ret = $this->getClubRankDescription();
196
        } else {
197
            $ret = $this->getPlayerRankDescription();
198
        }
199
        return $ret;
200
    }
201
}
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...
202