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 | use CMSFactory\assetManager; |
||
4 | |||
5 | if (!defined('BASEPATH')) { |
||
6 | exit('No direct script access allowed'); |
||
7 | } |
||
8 | |||
9 | /** |
||
10 | * Image CMS |
||
11 | * |
||
12 | * Comments component |
||
13 | * @property Base $base |
||
14 | */ |
||
15 | class Comments extends MY_Controller |
||
16 | { |
||
17 | |||
18 | public $period = 5; // Post comment period in minutes. If user is unregistered, check will be made by ip address. 0 - To disable this method. |
||
19 | |||
20 | public $can_comment = 0; // Possible values: 0 - all, 1 - registered only. |
||
21 | |||
22 | public $max_comment_length = 500; // Max. comments text lenght. |
||
23 | |||
24 | public $use_captcha = FALSE; // Possible values TRUE/FALSE; |
||
25 | |||
26 | public $cache_ttl = 86400; |
||
27 | |||
28 | public $module = 'core'; |
||
29 | |||
30 | public $order_by = 'date.desc'; |
||
31 | |||
32 | public $comment_controller = 'comments/add'; |
||
33 | |||
34 | public $tpl_name = 'comments'; // Use comments.tpl |
||
35 | |||
36 | public $use_moderation = TRUE; |
||
37 | |||
38 | public $enable_comments = TRUE; |
||
39 | |||
40 | public function __construct() { |
||
41 | |||
42 | parent::__construct(); |
||
43 | $this->load->module('core'); |
||
44 | $this->load->language('comments'); |
||
45 | $this->load->helper('cookie'); |
||
46 | |||
47 | $obj = new MY_Lang(); |
||
48 | $obj->load('comments'); |
||
49 | } |
||
50 | |||
51 | public function show() { |
||
52 | |||
53 | $url = $this->uri->uri_string(); |
||
54 | $comments = $this->load->module('comments/commentsapi')->getComments($url); |
||
55 | if (($result = $this->session->flashdata('result'))) { |
||
56 | $comments = (array_merge($result, $comments)); |
||
57 | } |
||
58 | |||
59 | $locale = MY_Controller::getCurrentLocale() == MY_Controller::getDefaultLanguage()['identif'] ? '' : '/'. MY_Controller::getCurrentLocale(); |
||
60 | |||
61 | assetManager::create() |
||
62 | ->setData($comments) |
||
63 | ->setData(['locale' => $locale]) |
||
64 | ->render('comments', TRUE); |
||
65 | } |
||
66 | |||
67 | public function addPost() { |
||
68 | |||
69 | $result = $this->load->module('comments/commentsapi')->addPost(); |
||
70 | $result['parent_id'] = $this->input->post('comment_parent'); |
||
71 | if ('error' == $result['answer']) { |
||
72 | $result['old_text'] = $this->input->post('comment_text'); |
||
73 | $result['old_ratec'] = $this->input->post('ratec'); |
||
74 | $result['old_author'] = $this->input->post('comment_author'); |
||
75 | $result['old_email'] = $this->input->post('comment_email'); |
||
76 | } |
||
77 | $this->session->set_flashdata(['result' => $result]); |
||
78 | redirect($this->input->server('HTTP_REFERER')); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Default function to access module by URL |
||
83 | */ |
||
84 | public function index() { |
||
85 | |||
86 | return FALSE; |
||
87 | } |
||
88 | |||
89 | public static function adminAutoload() { |
||
90 | |||
91 | \CMSFactory\Events::create()->onShopProductDelete()->setListener( |
||
92 | function ($data){ |
||
93 | $models = $data['model']; |
||
94 | $ids = []; |
||
95 | foreach ($models as $model) { |
||
96 | $ids[] = $model->getId(); |
||
97 | } |
||
98 | CI::$APP->db->where('module', 'shop')->where_in('item_id', $ids)->delete('comments'); |
||
99 | } |
||
100 | ); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * |
||
105 | * @param array $data |
||
106 | * @return string |
||
107 | */ |
||
108 | public function _fetchComments($data) { |
||
109 | |||
110 | if ($this->enable_comments) { |
||
111 | $comments = assetManager::create() |
||
112 | ->setData($data) |
||
113 | ->registerStyle('comments', TRUE) |
||
114 | ->fetchTemplate($this->tpl_name); |
||
115 | } else { |
||
116 | $comments = ''; |
||
117 | } |
||
118 | return $comments; |
||
119 | } |
||
120 | |||
121 | public function commentsDeleteFromCategory($product) { |
||
122 | |||
123 | if (!$product) { |
||
124 | return; |
||
125 | } |
||
126 | |||
127 | $CI = &get_instance(); |
||
128 | |||
129 | $ids = []; |
||
130 | foreach ($product[ShopCategoryId] as $key => $p) { |
||
131 | $ids[$key] = $p; |
||
132 | } |
||
133 | |||
134 | $array = $CI->db |
||
135 | ->select('item_id') |
||
136 | ->join('shop_products', 'comments.item_id=shop_products.id') |
||
137 | ->where_in('shop_products.category_id', $ids) |
||
138 | ->where('module', 'shop') |
||
139 | ->group_by('item_id') |
||
140 | ->get('comments') |
||
141 | ->result_array(); |
||
142 | |||
143 | $ids = []; |
||
144 | foreach ($array as $key => $a) { |
||
145 | $ids[$key] = $a['item_id']; |
||
146 | } |
||
147 | |||
148 | $CI->db->where_in('item_id', $ids); |
||
149 | $CI->db->where('module', 'shop'); |
||
150 | $CI->db->delete('comments'); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * |
||
155 | * @param string $page_id |
||
156 | * @param string $module |
||
157 | * @return boolean |
||
158 | */ |
||
159 | public function _recount_comments($page_id, $module) { |
||
160 | |||
161 | if ($module != 'core') { |
||
162 | return FALSE; |
||
163 | } |
||
164 | |||
165 | $this->db->where('item_id', $page_id); |
||
166 | $this->db->where('status', 0); |
||
167 | $this->db->where('module', 'core'); |
||
168 | $this->db->from('comments'); |
||
169 | $total = $this->db->count_all_results(); |
||
170 | |||
171 | $this->db->limit(1); |
||
172 | $this->db->where('id', $page_id); |
||
173 | $this->db->update('content', ['comments_count' => $total]); |
||
174 | return TRUE; |
||
175 | } |
||
176 | |||
177 | public function commentsDeleteFromProduct($product) { |
||
178 | |||
179 | if (!$product) { |
||
180 | return; |
||
181 | } |
||
182 | |||
183 | $CI = &get_instance(); |
||
184 | |||
185 | $product = $product[model]; |
||
186 | $ids = []; |
||
187 | foreach ($product as $key => $p) { |
||
188 | $ids[$key] = $p->id; |
||
189 | } |
||
190 | |||
191 | $CI->db->join('shop_products', 'comments.item_id=shop_products.id'); |
||
192 | $CI->db->where_in('item_id', $ids); |
||
193 | $CI->db->where('module', 'shop'); |
||
194 | $CI->db->delete('comments'); |
||
195 | } |
||
196 | |||
197 | public function init($model) { |
||
198 | |||
199 | assetManager::create() |
||
200 | ->registerScript('comments', TRUE); |
||
201 | |||
202 | if ($model instanceof SProducts) { |
||
0 ignored issues
–
show
|
|||
203 | $productsCount = $this->load->module('comments/commentsapi')->getTotalCommentsForProducts($model->getId()); |
||
204 | } else { |
||
205 | $ids = []; |
||
206 | if ($this->core->core_data['module'] != 'shop') { |
||
207 | foreach ((array) $model as $key => $id) { |
||
208 | if (is_array($id)) { |
||
209 | $ids[$key] = $id[id]; |
||
210 | } else { |
||
211 | $ids[$key] = $id; |
||
212 | } |
||
213 | } |
||
214 | $productsCount = $this->load->module('comments/commentsapi')->getTotalCommentsForProducts($ids, 'core'); |
||
215 | } else { |
||
216 | foreach ($model as $id) { |
||
217 | $ids[] = $id->getId(); |
||
218 | } |
||
219 | $productsCount = $this->load->module('comments/commentsapi')->getTotalCommentsForProducts($ids); |
||
220 | } |
||
221 | } |
||
222 | return $productsCount; |
||
223 | } |
||
224 | |||
225 | public function _init_settings() { |
||
226 | |||
227 | $settings = $this->base->get_settings(); |
||
228 | |||
229 | ($hook = get_hook('comments_settigs_init')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_settigs_init' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
230 | if (is_array($settings)) { |
||
231 | foreach ($settings as $k => $v) { |
||
232 | $this->$k = $v; |
||
233 | } |
||
234 | } |
||
235 | |||
236 | $this->use_moderation = $this->dx_auth->is_admin() ? FALSE : $settings['use_moderation']; |
||
237 | $this->use_captcha = $this->dx_auth->is_admin() ? FALSE : $settings['use_captcha']; |
||
238 | } |
||
239 | |||
240 | /** |
||
241 | * Fetch comments and load template |
||
242 | */ |
||
243 | public function build_comments($item_id = 0) { |
||
244 | |||
245 | $this->load->model('base'); |
||
246 | $this->_init_settings(); |
||
247 | |||
248 | // if (($comments = $this->cache->fetch('comments_' . $item_id . $this->module, 'comments')) !== FALSE) { |
||
249 | // ($hook = get_hook('comments_fetch_cache_ok')) ? eval($hook) : NULL; |
||
250 | // // Comments fetched from cahce file |
||
251 | // } else { |
||
252 | $this->db->where('module', $this->module); |
||
253 | $comments = $this->base->get($item_id, 0, $this->module, $this->input->post('countcomment'), $this->order_by); |
||
254 | |||
255 | // Read comments template |
||
256 | // Set page id for comments form |
||
257 | View Code Duplication | if ($comments != FALSE) { |
|
258 | ($hook = get_hook('comments_store_cache')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_store_cache' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
259 | $this->cache->store('comments_' . $item_id . $this->module, $comments, $this->cache_ttl, 'comments'); |
||
260 | } |
||
261 | //} |
||
262 | |||
263 | View Code Duplication | if (is_array($comments)) { |
|
264 | $i = 0; |
||
265 | foreach ($comments as $comment) { |
||
266 | if ($comment['parent'] > 0) { |
||
267 | $comment_ch[] = $comment; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$comment_ch was never initialized. Although not strictly required by PHP, it is generally a good practice to add $comment_ch = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
268 | unset($comments[$i]); |
||
269 | } |
||
270 | $i++; |
||
271 | } |
||
272 | } |
||
273 | // $this->load->library('pagination'); |
||
274 | // |
||
275 | // $config['base_url'] = ''; |
||
276 | // $config['total_rows'] = '200'; |
||
277 | // $config['per_page'] = '20'; |
||
278 | // |
||
279 | // $this->pagination->initialize($config); |
||
280 | // |
||
281 | // echo $this->pagination->create_links(); |
||
282 | |||
283 | if ($comments != null) { |
||
284 | $comments_count = count($comments); |
||
0 ignored issues
–
show
$comments_count 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 ![]() |
|||
285 | } else { |
||
286 | $comments_count = 0; |
||
0 ignored issues
–
show
$comments_count 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 ![]() |
|||
287 | } |
||
288 | |||
289 | $data = [ |
||
290 | 'comments_arr' => $comments, |
||
291 | 'comment_ch' => $comment_ch, |
||
292 | 'comment_controller' => $this->comment_controller, |
||
293 | 'total_comments' => lang('Total comments: ', 'comments') . count($comments), |
||
294 | 'can_comment' => $this->can_comment, |
||
295 | 'use_captcha' => $this->use_captcha, |
||
296 | 'item_id' => $item_id, |
||
297 | ]; |
||
298 | |||
299 | View Code Duplication | if ($this->use_captcha == TRUE) { |
|
300 | $this->dx_auth->captcha(); |
||
301 | $data['cap_image'] = $this->dx_auth->get_captcha_image(); |
||
302 | } |
||
303 | |||
304 | ($hook = get_hook('comments_read_com_tpl')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_read_com_tpl' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
305 | |||
306 | $comments = $this->template->read($this->tpl_name, $data); |
||
307 | |||
308 | ($hook = get_hook('comments_assign_tpl_data')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_assign_tpl_data' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
309 | //$this->render('comments_list', array('comments'=>$comments)); |
||
310 | |||
311 | $this->template->add_array( |
||
312 | ['comments' => $comments] |
||
313 | ); |
||
314 | } |
||
315 | |||
316 | /** |
||
317 | * Add comment |
||
318 | * @deprecated ImageCMS 4.3 |
||
319 | */ |
||
320 | public function add() { |
||
321 | |||
322 | ($hook = get_hook('comments_on_add')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_on_add' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
323 | |||
324 | // Load comments model |
||
325 | $this->load->model('base'); |
||
326 | $this->_init_settings(); |
||
327 | |||
328 | // Check access only for registered users |
||
329 | if ($this->can_comment === 1 AND $this->dx_auth->is_logged_in() == FALSE) { |
||
330 | ($hook = get_hook('comments_login_for_comments')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_login_for_comments' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
331 | $this->core->error(lang('Only authorized users can leave comments.', 'comments') . '<a href="%s" class="loginAjax"> ' . lang('log in, please.', 'comments') . '</ a>'); |
||
332 | } |
||
333 | |||
334 | $item_id = $this->input->post('comment_item_id'); |
||
335 | |||
336 | // Check if page comments status. |
||
337 | if ($this->module == 'core') { |
||
338 | if ($this->base->get_item_comments_status($item_id) == FALSE) { |
||
339 | ($hook = get_hook('comments_page_comments_disabled')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_page_comments_disabled' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
340 | $this->core->error(lang('Commenting on recording is prohibited.', 'comments')); |
||
341 | } |
||
342 | } |
||
343 | |||
344 | $this->load->library('user_agent'); |
||
345 | $this->load->library('form_validation'); |
||
346 | // $this->form_validation->CI = & $this; |
||
347 | // Check post comment period. |
||
348 | if ($this->period > 0) { |
||
349 | if ($this->check_comment_period() == FALSE) { |
||
350 | ($hook = get_hook('comments_period_error')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_period_error' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
351 | $this->core->error(sprintf(lang('Allowed to comment once in %s minutes.', 'comments'), $this->period)); |
||
352 | } |
||
353 | } |
||
354 | |||
355 | // Validate email and nickname from unregistered users. |
||
356 | View Code Duplication | if ($this->dx_auth->is_logged_in() == FALSE) { |
|
357 | ($hook = get_hook('comments_set_val_rules')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_set_val_rules' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
358 | |||
359 | $this->form_validation->set_rules('comment_email', lang('Email', 'comments'), 'trim|required|xss_clean|valid_email'); |
||
360 | $this->form_validation->set_rules('comment_author', lang('Your name', 'comments'), 'trim|required|xss_clean|max_length[50]'); |
||
361 | $this->form_validation->set_rules('comment_site', lang('Site', 'comments'), 'trim|xss_clean|max_length[250]'); |
||
362 | } |
||
363 | |||
364 | // Check captcha code if captcha_check enabled and user in not admin. |
||
365 | if ($this->use_captcha == TRUE AND $this->dx_auth->is_admin() == FALSE) { |
||
366 | ($hook = get_hook('comments_set_captcha')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_set_captcha' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
367 | View Code Duplication | if ($this->dx_auth->use_recaptcha) { |
|
368 | $this->form_validation->set_rules('recaptcha_response_field', lang('Code protection'), 'trim|required|xss_clean|callback_captcha_check'); |
||
369 | } else { |
||
370 | $this->form_validation->set_rules('captcha', lang('Code protection'), 'trim|required|xss_clean|callback_captcha_check'); |
||
371 | } |
||
372 | } |
||
373 | |||
374 | $this->form_validation->set_rules('comment_text', lang('Comment', 'comments'), 'trim|required|xss_clean|max_length[' . $this->max_comment_length . ']'); |
||
375 | |||
376 | if ($this->form_validation->run($this) == FALSE) { |
||
377 | ($hook = get_hook('comments_validation_failed')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_validation_failed' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
378 | |||
379 | $this->template->assign('comment_errors', validation_errors()); |
||
380 | } else { |
||
381 | if ($this->dx_auth->is_logged_in() == FALSE) { |
||
382 | ($hook = get_hook('comments_author_not_logged')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_author_not_logged' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
383 | |||
384 | $comment_author = trim(htmlspecialchars($this->input->post('comment_author'))); |
||
385 | $comment_email = trim(htmlspecialchars($this->input->post('comment_email'))); |
||
386 | |||
387 | // Write on cookie nickname and email |
||
388 | $this->_write_cookie($comment_author, $comment_email, $this->input->post('comment_site')); |
||
389 | } else { |
||
390 | ($hook = get_hook('comments_author_logged')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_author_logged' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
391 | |||
392 | $user = $this->db->get_where('users', ['id' => $this->dx_auth->get_user_id()])->row_array(); |
||
393 | $comment_author = $user['username']; |
||
394 | $comment_email = $user['email']; |
||
395 | } |
||
396 | |||
397 | $comment_text = trim(htmlspecialchars($this->input->post('comment_text'))); |
||
398 | $comment_text = str_replace("\n", '<br/>', $comment_text); |
||
399 | $comment_text_plus = trim(htmlspecialchars($this->input->post('comment_text_plus'))); |
||
400 | $comment_text_plus = str_replace("\n", '<br/>', $comment_text_plus); |
||
401 | $comment_text_minus = trim(htmlspecialchars($this->input->post('comment_text_minus'))); |
||
402 | $comment_text_minus = str_replace("\n", '<br/>', $comment_text_minus); |
||
403 | $rate = $this->input->post('ratec'); |
||
404 | View Code Duplication | if ($this->input->post('ratec')) { |
|
405 | if (SProductsQuery::create()->setComment(__METHOD__)->findPk($item_id) !== null) { |
||
406 | $model = SProductsRatingQuery::create()->setComment(__METHOD__)->findPk($item_id); |
||
407 | if ($model === null) { |
||
408 | $model = new SProductsRating; |
||
409 | $model->setProductId($item_id); |
||
410 | } |
||
411 | $model->setVotes($model->getVotes() + 1); |
||
412 | $model->setRating($model->getRating() + $rate); |
||
413 | $model->save(); |
||
414 | } |
||
415 | } |
||
416 | $parent = $this->input->post('parent'); |
||
417 | |||
418 | if ($comment_text != '') { |
||
419 | $comment_data = [ |
||
420 | 'module' => $this->module, |
||
421 | 'user_id' => $this->dx_auth->get_user_id(), // 0 if unregistered |
||
422 | 'user_name' => htmlspecialchars($comment_author), |
||
423 | 'user_mail' => $comment_email, |
||
424 | 'user_site' => htmlspecialchars($this->input->post('comment_site')), |
||
425 | 'text' => $comment_text, |
||
426 | 'text_plus' => $comment_text_plus, |
||
427 | 'text_minus' => $comment_text_minus, |
||
428 | 'item_id' => $item_id, |
||
429 | 'status' => $this->_comment_status(), |
||
430 | 'agent' => $this->agent->agent_string(), |
||
431 | 'user_ip' => $this->input->ip_address(), |
||
432 | 'date' => time(), |
||
433 | 'rate' => $rate, |
||
434 | 'parent' => $parent, |
||
435 | ]; |
||
436 | |||
437 | ($hook = get_hook('comments_db_insert')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_db_insert' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
438 | |||
439 | $this->base->add($comment_data); |
||
440 | |||
441 | if ($comment_data['status'] == 0) { |
||
442 | ($hook = get_hook('comments_update_count')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_update_count' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
443 | |||
444 | $this->db->set('comments_count', 'comments_count + 1', FALSE); |
||
445 | $this->db->where('id', $comment_data['item_id']); |
||
446 | $this->db->update('content'); |
||
447 | } |
||
448 | |||
449 | // Drop cached comments |
||
450 | $this->cache->delete('comments_' . $item_id . $this->module, 'comments'); |
||
451 | |||
452 | ($hook = get_hook('comments_goes_redirect')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_goes_redirect' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
453 | // Redirect back to page |
||
454 | //redirect($this->input->post('redirect')); |
||
455 | if ($this->input->post('redirect')) { |
||
456 | redirect((substr($this->input->post('redirect'), 0, 1) == '/') ? $this->input->post('redirect') : '/' . $this->input->post('redirect'), 301); |
||
457 | } else { |
||
458 | redirect('/'); |
||
459 | } |
||
460 | } else { |
||
461 | ($hook = get_hook('comments_empty_text')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_empty_text' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
462 | $this->core->error(lang('Fill text in comment.', 'comments')); |
||
463 | } |
||
464 | } |
||
465 | } |
||
466 | |||
467 | /** |
||
468 | * Determinate comment status. |
||
469 | * |
||
470 | * Comment statuses |
||
471 | * 0 - Normal(approved) comment. |
||
472 | * 1 - Waiting for moderation(pending). |
||
473 | * 2 - Spam. |
||
474 | */ |
||
475 | public function _comment_status() { |
||
476 | |||
477 | ($hook = get_hook('comments_on_get_status')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_on_get_status' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
478 | |||
479 | $status = 0; |
||
480 | |||
481 | if ($this->dx_auth->is_admin() == TRUE) { |
||
482 | return 0; |
||
483 | } |
||
484 | |||
485 | if ($this->use_moderation == TRUE) { |
||
486 | $status = 1; |
||
487 | } elseif ($this->use_moderation == FALSE) { |
||
488 | $status = 0; |
||
489 | } |
||
490 | |||
491 | return $status; |
||
492 | } |
||
493 | |||
494 | /** |
||
495 | * Write in cookie author nickname and email |
||
496 | * |
||
497 | * @param string $name |
||
498 | * @param string $email |
||
499 | * @param string $site |
||
500 | * @return boolean |
||
501 | */ |
||
502 | public function _write_cookie($name, $email, $site) { |
||
503 | |||
504 | $this->load->helper('cookie'); |
||
505 | |||
506 | ($hook = get_hook('comments_write_cookie')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_write_cookie' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
507 | |||
508 | $cookie_name = [ |
||
509 | 'name' => 'comment_author', |
||
510 | 'value' => $name, |
||
511 | 'expire' => '30000000', |
||
512 | ]; |
||
513 | |||
514 | $cookie_email = [ |
||
515 | 'name' => 'comment_email', |
||
516 | 'value' => $email, |
||
517 | 'expire' => '30000000', |
||
518 | ]; |
||
519 | |||
520 | $cookie_site = [ |
||
521 | 'name' => 'comment_site', |
||
522 | 'value' => $site, |
||
523 | 'expire' => '30000000', |
||
524 | ]; |
||
525 | |||
526 | set_cookie($cookie_name); |
||
527 | set_cookie($cookie_email); |
||
528 | set_cookie($cookie_site); |
||
529 | |||
530 | return TRUE; |
||
531 | } |
||
532 | |||
533 | protected function check_comment_period() { |
||
534 | |||
535 | ($hook = get_hook('comments_on_check_period')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_on_check_period' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
536 | |||
537 | if ($this->dx_auth->is_admin() == TRUE) { |
||
538 | return TRUE; |
||
539 | } |
||
540 | |||
541 | $this->db->select('id, date'); |
||
542 | $this->db->order_by('date', 'desc'); |
||
543 | |||
544 | if ($this->dx_auth->is_logged_in() == TRUE) { |
||
545 | $this->db->where('user_id', $this->dx_auth->get_user_id()); |
||
546 | } else { |
||
547 | $this->db->where('user_ip', $this->input->ip_address()); |
||
548 | } |
||
549 | |||
550 | $query = $this->db->get('comments', 1); |
||
551 | |||
552 | if ($query->num_rows() == 1) { |
||
553 | $query = $query->row_array(); |
||
554 | |||
555 | $latest_comment = $query['date']; |
||
556 | $allow_time = $latest_comment + ($this->period * 60); |
||
557 | |||
558 | if ($allow_time > time()) { |
||
0 ignored issues
–
show
|
|||
559 | return FALSE; |
||
560 | } else { |
||
561 | return TRUE; |
||
562 | } |
||
563 | } else { |
||
564 | return TRUE; |
||
565 | } |
||
566 | } |
||
567 | |||
568 | public function captcha_check($code) { |
||
569 | |||
570 | ($hook = get_hook('comments_captcha_check')) ? eval($hook) : NULL; |
||
0 ignored issues
–
show
The call to
get_hook() has too many arguments starting with 'comments_captcha_check' .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
571 | |||
572 | if (!$this->dx_auth->captcha_check($code)) { |
||
0 ignored issues
–
show
|
|||
573 | return FALSE; |
||
574 | } else { |
||
575 | return TRUE; |
||
576 | } |
||
577 | } |
||
578 | |||
579 | public function get_comments_number($id) { |
||
580 | |||
581 | $this->where('item_id', $id); |
||
582 | $query = $this->db->get('comments')->result_array(); |
||
583 | return count($query); |
||
584 | } |
||
585 | |||
586 | View Code Duplication | public function setyes($id = false) { |
|
587 | |||
588 | $like = false; |
||
589 | $comid = $this->input->post('comid') ?: $id; |
||
590 | if ($this->session->userdata('commentl' . $comid) != 1) { |
||
591 | $like = $this->load->model('base')->setYes($comid); |
||
592 | $this->session->set_userdata('commentl' . $comid, 1); |
||
593 | } |
||
594 | if ($this->input->is_ajax_request()) { |
||
595 | return json_encode(['y_count' => $like]); |
||
596 | } else { |
||
597 | redirect($this->input->server('HTTP_REFERER')); |
||
598 | } |
||
599 | } |
||
600 | |||
601 | View Code Duplication | public function setno($id = false) { |
|
602 | |||
603 | $disslike = false; |
||
604 | $comid = $this->input->post('comid') ?: $id; |
||
605 | if ($this->session->userdata('commentl' . $comid) != 1) { |
||
606 | $disslike = $this->load->model('base')->setNo($comid); |
||
607 | $this->session->set_userdata('commentl' . $comid, 1); |
||
608 | } |
||
609 | if ($this->input->is_ajax_request()) { |
||
610 | return json_encode(['n_count' => $disslike]); |
||
611 | } else { |
||
612 | redirect($this->input->server('HTTP_REFERER')); |
||
613 | } |
||
614 | } |
||
615 | |||
616 | public function _install() { |
||
617 | |||
618 | if ($this->dx_auth->is_admin() == FALSE) { |
||
619 | exit; |
||
620 | } |
||
621 | |||
622 | $this->load->dbforge(); |
||
623 | |||
624 | $fields = [ |
||
625 | 'id' => [ |
||
626 | 'type' => 'INT', |
||
627 | 'constraint' => 11, |
||
628 | 'auto_increment' => TRUE, |
||
629 | ], |
||
630 | 'module' => [ |
||
631 | 'type' => 'varchar', |
||
632 | 'constraint' => 25, |
||
633 | ], |
||
634 | 'user_id' => [ |
||
635 | 'type' => 'INT', |
||
636 | 'constraint' => 11, |
||
637 | ], |
||
638 | 'user_name' => [ |
||
639 | 'type' => 'varchar', |
||
640 | 'constraint' => 50, |
||
641 | ], |
||
642 | 'user_mail' => [ |
||
643 | 'type' => 'varchar', |
||
644 | 'constraint' => 50, |
||
645 | ], |
||
646 | 'user_site' => [ |
||
647 | 'type' => 'varchar', |
||
648 | 'constraint' => 250, |
||
649 | ], |
||
650 | 'item_id' => [ |
||
651 | 'type' => 'bigint', |
||
652 | 'constraint' => 11, |
||
653 | ], |
||
654 | 'text' => [ |
||
655 | 'type' => 'varchar', |
||
656 | 'constraint' => 500, |
||
657 | ], |
||
658 | 'date' => [ |
||
659 | 'type' => 'int', |
||
660 | 'constraint' => 11, |
||
661 | ], |
||
662 | 'status' => [ |
||
663 | 'type' => 'smallint', |
||
664 | 'constraint' => 1, |
||
665 | ], |
||
666 | 'agent' => [ |
||
667 | 'type' => 'varchar', |
||
668 | 'constraint' => 250, |
||
669 | ], |
||
670 | 'user_ip' => [ |
||
671 | 'type' => 'varchar', |
||
672 | 'constraint' => 64, |
||
673 | ], |
||
674 | 'rate' => [ |
||
675 | 'type' => 'int', |
||
676 | 'constraint' => 11, |
||
677 | ], |
||
678 | 'text_plus' => [ |
||
679 | 'type' => 'varchar', |
||
680 | 'constraint' => 500, |
||
681 | ], |
||
682 | 'text_minus' => [ |
||
683 | 'type' => 'varchar', |
||
684 | 'constraint' => 500, |
||
685 | ], |
||
686 | 'like' => [ |
||
687 | 'type' => 'int', |
||
688 | 'constraint' => 11, |
||
689 | 'default' => 0, |
||
690 | ], |
||
691 | 'disslike' => [ |
||
692 | 'type' => 'int', |
||
693 | 'constraint' => 11, |
||
694 | 'default' => 0, |
||
695 | ], |
||
696 | 'parent' => [ |
||
697 | 'type' => 'int', |
||
698 | 'constraint' => 11, |
||
699 | ], |
||
700 | ]; |
||
701 | $this->dbforge->add_key('id', TRUE); |
||
702 | $this->dbforge->add_field($fields); |
||
703 | $this->dbforge->create_table('comments', TRUE); |
||
704 | |||
705 | // Enable module autoload |
||
706 | $this->db->where('name', 'comments'); |
||
707 | $this->db->update('components', ['autoload' => '1']); |
||
708 | } |
||
709 | |||
710 | public function _deinstall() { |
||
711 | |||
712 | $this->load->dbforge(); |
||
713 | ($this->dx_auth->is_admin()) OR exit; |
||
714 | $this->dbforge->drop_table('comments'); |
||
715 | } |
||
716 | |||
717 | public function getWaitingForMaderationCount() { |
||
718 | |||
719 | $count = $this->db->where('status', 1)->count_all_results('comments'); |
||
720 | return $count; |
||
721 | } |
||
722 | |||
723 | } |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.