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 | * @author Alexey Tatarinov <[email protected]> |
||
4 | * @link https://github.com/shogodev/argilla/ |
||
5 | * @copyright Copyright © 2003-2014 Shogo |
||
6 | * @license http://argilla.ru/LICENSE |
||
7 | * @package frontend.controllers |
||
8 | */ |
||
9 | class CompareController extends FController |
||
10 | { |
||
11 | public function init() |
||
12 | { |
||
13 | parent::init(); |
||
14 | |||
15 | $this->processCompareAction(); |
||
16 | } |
||
17 | |||
18 | public function actionIndex() |
||
19 | { |
||
20 | $this->breadcrumbs = array('Сравнение'); |
||
21 | |||
22 | $data = array(); |
||
23 | |||
24 | if( $selectedSection = $this->getSelectedSection() ) |
||
25 | { |
||
26 | $productList = $this->compare->getProductListByGroup($selectedSection->id); |
||
27 | $parametersCompare = $this->getParametersCompare($productList); |
||
28 | |||
29 | $data = array( |
||
30 | 'selectedSection' => $selectedSection, |
||
31 | 'parametersCompare' => $parametersCompare, |
||
32 | 'productsDataProvider' => $productList->getDataProvider(), |
||
33 | ); |
||
34 | } |
||
35 | |||
36 | if( Yii::app()->request->isAjaxRequest ) |
||
37 | { |
||
38 | $this->renderPartial('_compare_header'); |
||
39 | $this->renderPartial('compare', $data); |
||
40 | } |
||
41 | else |
||
42 | $this->render('compare', $data); |
||
43 | } |
||
44 | |||
45 | public function actionAdd() |
||
46 | { |
||
47 | $request = Yii::app()->request; |
||
48 | $data = $request->getPost($this->compare->keyCollection); |
||
49 | |||
50 | if( !$request->isAjaxRequest && $request->getPost('action') != 'add' ) |
||
51 | return; |
||
52 | |||
53 | /** |
||
54 | * @var Product $product |
||
55 | */ |
||
56 | $product = Product::model()->findByPk(Arr::get($data, 'id')); |
||
57 | |||
58 | if( !$product ) |
||
59 | throw new CHttpException(500, 'Ошибка продукт не найден.'); |
||
60 | |||
61 | if( !$this->compare->isInCollection($product) ) |
||
62 | $this->compare->add($data); |
||
63 | |||
64 | $this->renderPartial('_compare_header'); |
||
65 | |||
66 | Yii::app()->end(); |
||
0 ignored issues
–
show
|
|||
67 | } |
||
68 | |||
69 | protected function processCompareAction() |
||
70 | { |
||
71 | $request = Yii::app()->request; |
||
72 | |||
73 | if( !$request->isAjaxRequest ) |
||
74 | return; |
||
75 | |||
76 | $data = $request->getPost($this->compare->keyCollection); |
||
77 | $action = $request->getPost('action'); |
||
78 | |||
79 | if( $data && $action ) |
||
80 | { |
||
81 | switch($action) |
||
82 | { |
||
83 | View Code Duplication | case 'remove': |
|
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. ![]() |
|||
84 | $index = Arr::get($data, 'index'); |
||
85 | |||
86 | if( is_null($index) ) |
||
87 | $index = $this->compare->getIndex($data); |
||
88 | |||
89 | if( is_null($index) || !$this->compare->exists($index) ) |
||
90 | throw new CHttpException(500, 'Данный продукт уже удален. Обновите страницу.'); |
||
91 | |||
92 | $this->compare->remove($index); |
||
93 | break; |
||
94 | } |
||
95 | } |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Возвращает не пустые параметры сравнения |
||
100 | * @param ProductList $productList |
||
101 | * |
||
102 | * @return array; |
||
0 ignored issues
–
show
The doc-type
array; could not be parsed: Expected "|" or "end of type", but got ";" at position 5. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
103 | */ |
||
104 | protected function getParametersCompare($productList) |
||
105 | { |
||
106 | $notEmptyParametersCompare = array(); |
||
107 | |||
108 | foreach($productList->getDataProvider()->getData() as $product) |
||
109 | { |
||
110 | foreach($product->getParameters() as $parameter) |
||
111 | { |
||
112 | if( !empty($parameter->value) ) |
||
113 | $notEmptyParametersCompare[$parameter->id] = $parameter; |
||
114 | } |
||
115 | } |
||
116 | |||
117 | return $notEmptyParametersCompare; |
||
118 | } |
||
119 | |||
120 | protected function getProductsForChange($sectionId) |
||
121 | { |
||
122 | $criteria = new CDbCriteria(); |
||
123 | $criteria->compare('a.section_id', $sectionId); |
||
124 | $criteria->order = 't.name'; |
||
125 | |||
126 | return new ProductList($criteria, null, false); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @return FCollectionElement|ProductSection |
||
131 | */ |
||
132 | protected function getSelectedSection() |
||
133 | { |
||
134 | $data = Yii::app()->request->getParam($this->compare->keyCollection, array()); |
||
135 | |||
136 | $sectionId = Arr::get($data, 'groupId'); |
||
137 | if( !$sectionId ) |
||
138 | $sectionId = Arr::get($data, 'id'); |
||
139 | |||
140 | $selectedSection = null; |
||
141 | |||
142 | /** |
||
143 | * @var FCollectionElement|ProductSection $section |
||
144 | */ |
||
145 | foreach($this->compare->getGroups() as $section) |
||
146 | { |
||
147 | if( $section->id == $sectionId ) |
||
148 | { |
||
149 | $selectedSection = $section; |
||
150 | break; |
||
151 | } |
||
152 | else if( empty($selectedSection) ) |
||
153 | $selectedSection = $section; |
||
154 | } |
||
155 | |||
156 | return $selectedSection; |
||
157 | } |
||
158 | } |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: