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 integer $id |
||
| 4 | * @property CPagination $pagination |
||
| 5 | * @property integer $count |
||
| 6 | * @property array $items |
||
| 7 | * @property integer $page |
||
| 8 | * @property boolean $private |
||
| 9 | */ |
||
| 10 | class Forum extends CModel |
||
| 11 | { |
||
| 12 | private $id; |
||
| 13 | private $items = []; |
||
| 14 | private $page = 0; |
||
|
0 ignored issues
–
show
|
|||
| 15 | private $pagination; |
||
| 16 | private $count; |
||
| 17 | private $private = false; |
||
| 18 | |||
| 19 | public function attributeNames() |
||
| 20 | { |
||
| 21 | return []; |
||
| 22 | } |
||
| 23 | |||
| 24 | public function getId() |
||
| 25 | { |
||
| 26 | return (int)$this->id; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function getPagination() |
||
| 30 | { |
||
| 31 | return $this->pagination; |
||
| 32 | } |
||
| 33 | |||
| 34 | 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 Loading history...
|
|||
| 35 | { |
||
| 36 | return $this->count; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function getItems() |
||
| 40 | { |
||
| 41 | return $this->items; |
||
| 42 | } |
||
| 43 | |||
| 44 | public function setId($id) |
||
| 45 | { |
||
| 46 | $this->id = (int)$id; |
||
| 47 | } |
||
| 48 | |||
| 49 | public function setPage($page) |
||
| 50 | { |
||
| 51 | $this->page = $page; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function setPrivate($private) |
||
| 55 | { |
||
| 56 | $this->private = (bool)$private; |
||
| 57 | } |
||
| 58 | |||
| 59 | public function fetchItems() |
||
| 60 | { |
||
| 61 | $player = Yii::app()->player->model; |
||
| 62 | $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...
|
|||
| 63 | |||
| 64 | $fetchPrivates = $this->id !== $player->in_club ? ' AND private=0' : ''; |
||
| 65 | |||
| 66 | $this->count = Yii::app()->db->createCommand() |
||
| 67 | ->select('COUNT(*) AS count') |
||
| 68 | ->from('forum') |
||
| 69 | ->where('club_id = :id'.$fetchPrivates, [':id'=>$this->id]) |
||
| 70 | ->queryScalar(); |
||
| 71 | |||
| 72 | $res = Yii::app()->db->createCommand() |
||
| 73 | ->select('*') |
||
| 74 | ->from('forum') |
||
| 75 | ->where('club_id = :id'.$fetchPrivates, [':id'=>$this->id]) |
||
| 76 | ->order('id DESC') |
||
| 77 | ->limit($limit, ($this->page * $limit) - $limit) // the trick is here! |
||
| 78 | ->queryAll(); |
||
| 79 | |||
| 80 | $this->pagination = new CPagination($this->count); |
||
| 81 | $this->pagination->setPageSize(Yii::app()->params['listPerPage']); |
||
| 82 | |||
| 83 | $this->items = $res; |
||
| 84 | } |
||
| 85 | |||
| 86 | public function save($post, $isMentor = false) |
||
| 87 | { |
||
| 88 | if (!$isMentor) { |
||
| 89 | $post = trim($post); |
||
| 90 | $post = strip_tags($post); |
||
| 91 | $post = htmlspecialchars($post); |
||
| 92 | $post = substr($post, 0, 800); |
||
| 93 | } |
||
| 94 | |||
| 95 | if (!$post) { |
||
| 96 | return false; |
||
| 97 | } |
||
| 98 | |||
| 99 | $player = Yii::app()->player->model; |
||
| 100 | $uid = $isMentor ? 1 : $player->uid; |
||
|
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...
|
|||
| 101 | $user = $isMentor ? 'Áron bá' : $player->user; |
||
|
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...
|
|||
| 102 | if ($uid > 1 && $player->in_club != $this->id) { |
||
| 103 | return false; //nem klubtag, nem mentor |
||
| 104 | } |
||
| 105 | |||
| 106 | $parameters = [ |
||
| 107 | 'club_id'=>$this->id, |
||
| 108 | 'uid'=>$uid, |
||
| 109 | 'user'=>$user, |
||
| 110 | 'body'=>$post, |
||
| 111 | 'private'=>$this->private |
||
| 112 | ]; |
||
| 113 | |||
| 114 | Yii::app()->db->createCommand() |
||
| 115 | ->insert('forum', $parameters); |
||
| 116 | |||
| 117 | $parameters['created'] = 'most'; |
||
| 118 | array_unshift($this->items, $parameters); |
||
| 119 | return true; |
||
| 120 | } |
||
| 121 | |||
| 122 | public function delete($id) |
||
| 123 | { |
||
| 124 | if (!$id) { |
||
| 125 | return false; |
||
| 126 | } |
||
| 127 | |||
| 128 | $player = Yii::app()->player->model; |
||
| 129 | if ($player->in_club != $this->id) { |
||
| 130 | return false; //nem klubtag, nem mentor |
||
| 131 | } |
||
| 132 | |||
| 133 | Yii::app()->db->createCommand()->delete( |
||
| 134 | 'forum', |
||
| 135 | 'id=:id AND uid=:uid', |
||
| 136 | [':id'=>(int)$id, ':uid'=>Yii::app()->player->model->uid] |
||
| 137 | ); |
||
| 138 | |||
| 139 | return true; |
||
| 140 | } |
||
| 141 | } |
||
|
0 ignored issues
–
show
|
|||
| 142 |
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
will produce issues in the first and second line, while this second example
will produce no issues.