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 BasketController extends FController |
||
10 | { |
||
11 | private $renderPanel = false; |
||
12 | |||
13 | public function filter() |
||
14 | { |
||
15 | return array('ajaxOnly + ajax, fastOrder, favoriteToBasket, repeatOrder'); |
||
16 | } |
||
17 | |||
18 | public function actionAjax() |
||
19 | { |
||
20 | $this->processBasketAction(); |
||
21 | $this->renderAjax(); |
||
22 | } |
||
23 | |||
24 | public function actionFastOrder() |
||
25 | { |
||
26 | $form = $this->fastOrderForm; |
||
27 | $form->ajaxValidation(); |
||
28 | |||
29 | $fastOrderBasket = new FBasket('fastOrderBasket', array(), false); |
||
30 | $fastOrderBasket->add(Yii::app()->request->getPost($this->basket->keyCollection)); |
||
31 | $form->model->setFastOrderBasket($fastOrderBasket); |
||
32 | |||
33 | if( !$fastOrderBasket->isEmpty() && $form->save() ) |
||
34 | { |
||
35 | Yii::app()->notification->send('FastOrderBackend', array('model' => $form->model), null, 'backend'); |
||
36 | Yii::app()->notification->send('FastOrder', array('model' => $form->model), $form->model->email); |
||
37 | |||
38 | echo CJSON::encode(array( |
||
39 | 'status' => 'ok', |
||
40 | 'hideElements' => array($form->id), |
||
41 | 'showElements' => array($this->basket->fastOrderFormSuccessId) |
||
42 | )); |
||
43 | Yii::app()->end(); |
||
0 ignored issues
–
show
|
|||
44 | } |
||
45 | } |
||
46 | |||
47 | public function actionRepeatOrder() |
||
48 | { |
||
49 | $data = Yii::app()->request->getPost($this->basket->keyCollection); |
||
50 | $orderId = Arr::get($data, 'order-id'); |
||
51 | |||
52 | try |
||
53 | { |
||
54 | /** |
||
55 | * @var OrderHistory $order |
||
56 | */ |
||
57 | if( $order = OrderHistory::model()->findByPk($orderId) ) |
||
58 | { |
||
59 | foreach($order->products as $orderProduct) |
||
60 | { |
||
61 | $data = array( |
||
62 | 'type' => 'product', |
||
63 | 'id' => $orderProduct->history->product_id, |
||
64 | 'amount' => $orderProduct->count, |
||
65 | 'items' => array() |
||
66 | ); |
||
67 | |||
68 | if( $options = $orderProduct->getItems('ProductOption') ) |
||
69 | { |
||
70 | foreach($options as $option) |
||
71 | { |
||
72 | $data['items']['options'][] = array('id' => $option->pk, 'type' => $option->type); |
||
73 | } |
||
74 | } |
||
75 | |||
76 | if( $ingredients = $orderProduct->getItems('ProductIngredientAssignment') ) |
||
77 | { |
||
78 | foreach($ingredients as $ingredient) |
||
79 | { |
||
80 | $data['items']['ingredients'][] = array( |
||
81 | 'id' => $ingredient->pk, |
||
82 | 'type' => $ingredient->type, |
||
83 | 'amount' => $ingredient->amount |
||
84 | ); |
||
85 | } |
||
86 | } |
||
87 | $this->basket->add($data); |
||
88 | } |
||
89 | |||
90 | $this->renderAjax(); |
||
91 | } |
||
92 | } |
||
93 | catch(CHttpException $e) |
||
0 ignored issues
–
show
The class
CHttpException does not exist. Did you forget a USE statement, or did you not list all dependencies?
Scrutinizer analyzes your It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis. ![]() |
|||
94 | { |
||
95 | $e->handled = true; |
||
96 | throw new CHttpException(500, 'Ошибка. Невозможно выполнить повтрный заказ'); |
||
97 | } |
||
98 | } |
||
99 | |||
100 | protected function processBasketAction() |
||
101 | { |
||
102 | $request = Yii::app()->request; |
||
103 | $data = $request->getPost($this->basket->keyCollection); |
||
104 | $action = $request->getPost('action'); |
||
105 | |||
106 | if( $data && $action ) |
||
107 | { |
||
108 | switch($action) |
||
109 | { |
||
110 | 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. ![]() |
|||
111 | $index = Arr::get($data, 'index'); |
||
112 | |||
113 | if( is_null($index) ) |
||
114 | $index = $this->basket->getIndex($data); |
||
115 | |||
116 | if( is_null($index) || !$this->basket->exists($index) ) |
||
117 | throw new CHttpException(500, 'Данный продукт уже удален. Обновите страницу.'); |
||
118 | |||
119 | $this->basket->remove($index); |
||
120 | break; |
||
121 | |||
122 | case 'changeAmount': |
||
123 | if( !$this->basket->exists($data['index']) ) |
||
124 | throw new CHttpException(500, 'Продукт не найден. Обновите страницу.'); |
||
125 | $amount = intval($data['amount']); |
||
126 | $this->basket->changeAmount($data['index'], $amount > 0 ? $amount : 1); |
||
127 | break; |
||
128 | |||
129 | case 'changeItems': |
||
130 | if( !$this->basket->exists($data['index']) ) |
||
131 | throw new CHttpException(500, 'Продукт не найден. Обновите страницу.'); |
||
132 | |||
133 | $items = Arr::get($this->basket[$data['index']]->getCollectionElement()->toArray(), 'items', array()); |
||
0 ignored issues
–
show
$items is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
134 | $items = $data; |
||
135 | $this->basket->changeItems($data['index'], $items); |
||
136 | break; |
||
137 | |||
138 | case 'add': |
||
139 | $this->basket->add($data); |
||
140 | break; |
||
141 | } |
||
142 | } |
||
143 | } |
||
144 | |||
145 | protected function renderAjax() |
||
146 | { |
||
147 | $this->renderPartial('/_basket_header'); |
||
148 | $this->renderPanel(); |
||
149 | } |
||
150 | |||
151 | private function renderPanel() |
||
152 | { |
||
153 | if( $this->renderPanel ) |
||
154 | $this->renderPartial('/panel/panel'); |
||
155 | } |
||
156 | } |
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: