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 Xmf\Request; |
||
4 | use Xoopsmodules\instruction; |
||
5 | |||
6 | // |
||
7 | include __DIR__ . '/admin_header.php'; |
||
8 | // Функции модуля |
||
0 ignored issues
–
show
|
|||
9 | //include __DIR__ . '/../class/utility.php'; |
||
10 | //include __DIR__ . '/../include/common.php'; |
||
11 | |||
12 | // Admin Gui |
||
13 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||
14 | |||
15 | // Объявляем объекты |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
47% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
16 | //$categoryHandler = xoops_getModuleHandler('category', 'instruction'); |
||
17 | //$instructionHandler = xoops_getModuleHandler('instruction', 'instruction'); |
||
18 | |||
19 | $time = time(); |
||
20 | |||
21 | // ID категории |
||
22 | $cid = Request::getInt('cid', 0); |
||
23 | // ID родителя |
||
24 | $pid = Request::getInt('pid', 0); |
||
25 | // Вес |
||
26 | $weight = Request::getInt('weight', 0); |
||
27 | // Опция |
||
28 | $op = Request::getString('op', 'main'); |
||
29 | // Выбор |
||
30 | switch ($op) { |
||
31 | |||
32 | case 'main': |
||
33 | |||
34 | // Подключаем трей |
||
35 | |||
36 | // include_once __DIR__ . '/../class/Tree.php'; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
45% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
37 | //include_once $GLOBALS['xoops']->path('modules/instruction/class/Tree.php'); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
84% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
38 | |||
39 | // Заголовок админки |
||
40 | xoops_cp_header(); |
||
41 | // Навигация |
||
42 | $adminObject->displayNavigation(basename(__FILE__)); |
||
43 | |||
44 | // Находим ID-категории => Число страниц |
||
45 | $cidinstrids = []; |
||
46 | $sql = "SELECT `cid`, COUNT( `instrid` ) FROM {$instructionHandler->table} GROUP BY `cid`"; |
||
47 | $result = $GLOBALS['xoopsDB']->query($sql); |
||
48 | while (list($cid, $count) = $GLOBALS['xoopsDB']->fetchRow($result)) { |
||
49 | // Заполняем массив |
||
50 | $cidinstrids[$cid] = $count; |
||
51 | } |
||
52 | |||
53 | // Выбираем категории из БД |
||
54 | $criteria = new \CriteriaCompo(); |
||
55 | $criteria->setSort('weight ASC, title'); |
||
56 | $criteria->setOrder('ASC'); |
||
57 | $ins_cat = $categoryHandler->getall($criteria); |
||
58 | unset($criteria); |
||
59 | |||
60 | // Инициализируем |
||
61 | $cattree = new instruction\Tree($ins_cat, 'cid', 'pid'); |
||
62 | // Выводим списко категорий в шаблон |
||
63 | $GLOBALS['xoopsTpl']->assign('insListCat', $cattree->makeCatsAdmin('--', $cidinstrids)); |
||
64 | |||
65 | // Создание новой категории |
||
66 | $objInstructioncat = $categoryHandler->create(); |
||
67 | $form = $objInstructioncat->getForm('cat.php'); |
||
68 | // Форма |
||
69 | $GLOBALS['xoopsTpl']->assign('insFormCat', $form->render()); |
||
70 | // Выводим шаблон |
||
71 | $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_cat.tpl'); |
||
72 | |||
73 | // Текст внизу админки |
||
74 | include __DIR__ . '/admin_footer.php'; |
||
75 | |||
76 | break; |
||
77 | |||
78 | // Редактирование категории |
||
79 | case 'editcat': |
||
80 | |||
81 | // Заголовок админки |
||
82 | xoops_cp_header(); |
||
83 | // Навигация |
||
84 | $adminObject->displayNavigation(basename(__FILE__)); |
||
85 | |||
86 | $objInstructioncat = $categoryHandler->get($cid); |
||
87 | $form = $objInstructioncat->getForm('cat.php'); |
||
88 | // Форма |
||
89 | //$GLOBALS['xoopsTpl']->assign( 'insFormCat', $form->render() ); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
74% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
90 | echo $form->render(); |
||
91 | // Выводим шаблон |
||
92 | $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editcat.tpl'); |
||
93 | |||
94 | // Текст внизу админки |
||
95 | include __DIR__ . '/admin_footer.php'; |
||
96 | |||
97 | break; |
||
98 | |||
99 | // Сохранение категорий |
||
100 | case 'savecat': |
||
101 | |||
102 | // Проверка |
||
103 | View Code Duplication | if (!$GLOBALS['xoopsSecurity']->check()) { |
|
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. ![]() |
|||
104 | redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
105 | } |
||
106 | // Если мы редактируем |
||
107 | if ($cid) { |
||
108 | $objInstructioncat = $categoryHandler->get($cid); |
||
109 | } else { |
||
110 | $objInstructioncat = $categoryHandler->create(); |
||
111 | // Указываем дату создания |
||
112 | $objInstructioncat->setVar('datecreated', $time); |
||
113 | } |
||
114 | |||
115 | $err = false; |
||
116 | $message_err = ''; |
||
117 | |||
118 | // Дата обновления |
||
119 | $objInstructioncat->setVar('dateupdated', $time); |
||
120 | $objInstructioncat->setVar('pid', $pid); |
||
121 | $objInstructioncat->setVar('title', Request::getString('title', '', 'POST')); |
||
122 | $objInstructioncat->setVar('description', Request::getString('description', '', 'POST')); |
||
123 | $objInstructioncat->setVar('weight', $weight); |
||
124 | $objInstructioncat->setVar('metakeywords', Request::getString('metakeywords', '', 'POST')); |
||
125 | $objInstructioncat->setVar('metadescription', Request::getString('metadescription', '', 'POST')); |
||
126 | |||
127 | // Проверка веса |
||
128 | if (0 == $weight) { |
||
129 | $err = true; |
||
130 | $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>'; |
||
131 | } |
||
132 | // Проверка категорий |
||
133 | if ($cid && ($cid == $pid)) { |
||
134 | $err = true; |
||
135 | $message_err .= _AM_INSTRUCTION_ERR_PCAT . '<br>'; |
||
136 | } |
||
137 | // Если были ошибки |
||
138 | if (true === $err) { |
||
139 | xoops_cp_header(); |
||
140 | // Навигация |
||
141 | $adminObject->displayNavigation(basename(__FILE__)); |
||
142 | |||
143 | $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>'; |
||
144 | // Выводим ошибки в шаблон |
||
145 | $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err); |
||
146 | // Если небыло ошибок |
||
147 | } else { |
||
148 | // Вставляем данные в БД |
||
149 | if ($categoryHandler->insert($objInstructioncat)) { |
||
150 | |||
151 | // ID категории. Если редактируем - то не изменяется. Если создаём новую - то получаем ID созданной записи. |
||
152 | $new_cid = $cid ?: $objInstructioncat->getNewInstertId(); |
||
153 | |||
154 | // =============== |
||
155 | // ==== Права ==== |
||
156 | // =============== |
||
157 | |||
158 | $gpermHandler = xoops_getHandler('groupperm'); |
||
159 | |||
160 | // Если мы редактируем категорию, то старые права нужно удалить |
||
161 | if ($cid) { |
||
162 | // Права на просмотр |
||
163 | $criteria = new\ CriteriaCompo(); |
||
164 | $criteria->add(new \Criteria('gperm_itemid', $new_cid, '=')); |
||
165 | $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
||
166 | $criteria->add(new \Criteria('gperm_name', 'instruction_view', '=')); |
||
167 | $gpermHandler->deleteAll($criteria); |
||
168 | // Права на добавление |
||
169 | $criteria = new \CriteriaCompo(); |
||
170 | $criteria->add(new \Criteria('gperm_itemid', $new_cid, '=')); |
||
171 | $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
||
172 | $criteria->add(new \Criteria('gperm_name', 'instruction_submit', '=')); |
||
173 | $gpermHandler->deleteAll($criteria); |
||
174 | // Права на редактирование |
||
175 | $criteria = new \CriteriaCompo(); |
||
176 | $criteria->add(new \Criteria('gperm_itemid', $new_cid, '=')); |
||
177 | $criteria->add(new \Criteria('gperm_modid', $GLOBALS['xoopsModule']->getVar('mid'), '=')); |
||
178 | $criteria->add(new \Criteria('gperm_name', 'instruction_edit', '=')); |
||
179 | $gpermHandler->deleteAll($criteria); |
||
180 | } |
||
181 | |||
182 | // Добавляем права |
||
183 | // Права на просмотр |
||
184 | View Code Duplication | if (Request::hasVar('groups_instr_view', 'POST')) { |
|
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. ![]() |
|||
185 | foreach (Request::getArray('groups_instr_view', '', 'POST') as $onegroup_id) { |
||
186 | $gpermHandler->addRight('instruction_view', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
||
187 | } |
||
188 | } |
||
189 | // Права на добавление |
||
190 | View Code Duplication | if (Request::hasVar('groups_instr_submit', 'POST')) { |
|
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. ![]() |
|||
191 | foreach (Request::getArray('groups_instr_submit', '', 'POST') as $onegroup_id) { |
||
192 | $gpermHandler->addRight('instruction_submit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
||
193 | } |
||
194 | } |
||
195 | // Права на редактирование |
||
196 | View Code Duplication | if (Request::hasVar('groups_instr_edit', 'POST')) { |
|
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. ![]() |
|||
197 | foreach (Request::getArray('groups_instr_edit', '', 'POST') as $onegroup_id) { |
||
198 | $gpermHandler->addRight('instruction_edit', $new_cid, $onegroup_id, $GLOBALS['xoopsModule']->getVar('mid')); |
||
199 | } |
||
200 | } |
||
201 | |||
202 | // |
||
203 | redirect_header('cat.php', 3, _AM_INSTRUCTION_NEWCATADDED); |
||
204 | } |
||
205 | xoops_cp_header(); |
||
206 | // Навигация |
||
207 | $adminObject->displayNavigation(basename(__FILE__)); |
||
208 | // Выводим ошибки в шаблон |
||
209 | $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors()); |
||
210 | } |
||
211 | // Выводим шаблон |
||
212 | $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savecat.tpl'); |
||
213 | // Выводим форму |
||
214 | $form = $objInstructioncat->getForm(); |
||
215 | // Форма |
||
216 | echo $form->render(); |
||
217 | // Текст внизу админки |
||
218 | include __DIR__ . '/admin_footer.php'; |
||
219 | |||
220 | break; |
||
221 | |||
222 | // Удаление категории |
||
223 | case 'delcat': |
||
224 | |||
225 | // Находим число инструкций в данной категории |
||
226 | // Критерий выборки |
||
227 | $criteria = new \CriteriaCompo(); |
||
228 | // Все инструкции в данной категории |
||
229 | $criteria->add(new \Criteria('cid', $cid, '=')); |
||
230 | $numrows = $instructionHandler->getCount($criteria); |
||
231 | // |
||
232 | unset($criteria); |
||
233 | // Если есть хоть одна инструкция |
||
234 | if ($numrows) { |
||
235 | redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTEMPTY); |
||
236 | } |
||
237 | |||
238 | $objInscat = $categoryHandler->get($cid); |
||
239 | // Если нет такой категории |
||
240 | if (!is_object($objInscat)) { |
||
241 | redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT); |
||
242 | } |
||
243 | |||
244 | // Нельзя удалять пока есть доченрии категории |
||
245 | // Подключаем трей |
||
246 | include_once $GLOBALS['xoops']->path('class/tree.php'); |
||
247 | $inscat_arr = $categoryHandler->getall(); |
||
248 | $mytree = new \XoopsObjectTree($inscat_arr, 'cid', 'pid'); |
||
249 | $ins_childcat = $mytree->getAllChild($cid); |
||
250 | // Если есть дочернии категории |
||
251 | if (count($ins_childcat)) { |
||
252 | redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATCHILDREN); |
||
253 | } |
||
254 | |||
255 | // Нажали ли мы на кнопку OK |
||
256 | $ok = Request::getInt('ok', 0, 'POST'); |
||
257 | // Если мы нажали на кнопку |
||
258 | if ($ok) { |
||
259 | |||
260 | // Проверка |
||
261 | View Code Duplication | if (!$GLOBALS['xoopsSecurity']->check()) { |
|
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. ![]() |
|||
262 | redirect_header('cat.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
263 | } |
||
264 | // Пытаемся удалить категорию |
||
265 | if ($categoryHandler->delete($objInscat)) { |
||
266 | |||
267 | // Удалить права доступа к категории |
||
268 | // ================================= |
||
269 | |||
270 | // Редирект |
||
271 | redirect_header('cat.php', 3, _AM_INSTRUCTION_CATDELETED); |
||
272 | // Если не смогли удалить категорию |
||
273 | } else { |
||
274 | // Редирект |
||
275 | redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_DELCAT); |
||
276 | } |
||
277 | View Code Duplication | } else { |
|
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. ![]() |
|||
278 | |||
279 | // Заголовок админки |
||
280 | xoops_cp_header(); |
||
281 | // Навигация |
||
282 | $adminObject->displayNavigation(basename(__FILE__)); |
||
283 | |||
284 | xoops_confirm(['ok' => 1, 'cid' => $cid, 'op' => 'delcat'], 'cat.php', sprintf(_AM_INSTRUCTION_FORMDELCAT, $objInscat->getVar('title'))); |
||
285 | |||
286 | // Текст внизу админки |
||
287 | include __DIR__ . '/admin_footer.php'; |
||
288 | } |
||
289 | |||
290 | break; |
||
291 | |||
292 | } |
||
293 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.