heal25 /
ced
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 | * @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
|
|||
| 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
|
|||
| 204 |
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
@returnannotation as described here.