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 | // Функции модуля |
||
9 | //include __DIR__ . '/../class/utility.php'; |
||
10 | // Пагинатор |
||
11 | include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
12 | require_once __DIR__ . '/../include/common.php'; |
||
13 | |||
14 | // Admin Gui |
||
15 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||
16 | // Объявляем объекты |
||
0 ignored issues
–
show
|
|||
17 | //$instructionHandler = xoops_getModuleHandler('instruction', 'instruction'); |
||
18 | //$categoryHandler = xoops_getModuleHandler('category', 'instruction'); |
||
19 | //$pageHandler = xoops_getModuleHandler('page', 'instruction'); |
||
20 | |||
21 | $uid = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||
0 ignored issues
–
show
The class
XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
22 | $time = time(); |
||
23 | |||
24 | // ID инструкции |
||
25 | $instrid = Request::getInt('instrid', 0); |
||
26 | // ID страницы |
||
27 | $pageid = Request::getInt('pageid', 0); |
||
28 | // ID категории |
||
29 | $cid = Request::getInt('cid', 0); |
||
30 | // Вес |
||
31 | $weight = Request::getInt('weight', 0, 'POST'); |
||
32 | // |
||
33 | $pid = Request::getInt('pid', 0); |
||
34 | // |
||
35 | $start = Request::getInt('start', 0, 'GET'); |
||
36 | // |
||
37 | $limit = xoops_getModuleOption('perpageadmin', 'instruction'); |
||
38 | |||
39 | $op = Request::getString('op', Request::getString('op', 'main', 'GET'), 'POST'); |
||
40 | |||
41 | // Выбор |
||
42 | switch ($op) { |
||
43 | |||
44 | case 'main': |
||
45 | |||
46 | // Заголовок админки |
||
47 | xoops_cp_header(); |
||
48 | // Меню |
||
49 | $adminObject->displayNavigation(basename(__FILE__)); |
||
50 | $adminObject->addItemButton(_AM_INSTRUCTION_ADDINSTR, 'instr.php?op=editinstr', 'add'); |
||
51 | $adminObject->displayButton('left', ''); |
||
52 | |||
53 | // |
||
54 | $criteria = new \CriteriaCompo(); |
||
55 | |||
56 | // Если была передана категория |
||
57 | if ($cid) { |
||
58 | // Добавляем в выборку ID категории |
||
59 | $criteria->add(new \Criteria('cid', $cid, '=')); |
||
60 | // Получаем объект категории |
||
61 | $objInscat = $categoryHandler->get($cid); |
||
62 | // Если нет такой категории |
||
63 | if (!is_object($objInscat)) { |
||
64 | redirect_header('cat.php', 3, _AM_INSTRUCTION_ERR_CATNOTSELECT); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | // Число инструкций, удовлетворяющих данному условию |
||
69 | $numrows = $instructionHandler->getCount($criteria); |
||
70 | |||
71 | // Число выборки |
||
72 | $criteria->setLimit($limit); |
||
73 | // Начинасть с данного элемента |
||
74 | $criteria->setStart($start); |
||
75 | // Сортировать по |
||
76 | $criteria->setSort('instrid'); |
||
77 | // Порядок сортировки |
||
78 | $criteria->setOrder('DESC'); |
||
79 | // Находим все справки |
||
80 | $instr_arr = $instructionHandler->getall($criteria); |
||
81 | // Если записей больше чем $limit, то выводим пагинатор |
||
82 | View Code Duplication | if ($numrows > $limit) { |
|
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. ![]() |
|||
83 | $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'op=' . $op . '&cid=' . $cid); |
||
84 | $pagenav = $pagenav->renderNav(4); |
||
85 | } else { |
||
86 | $pagenav = ''; |
||
87 | } |
||
88 | // Выводим пагинатор в шаблон |
||
89 | $GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav); |
||
90 | |||
91 | // Если есть записи |
||
92 | if ($numrows > 0) { |
||
93 | $class = 'odd'; |
||
94 | foreach (array_keys($instr_arr) as $i) { |
||
95 | |||
96 | // |
||
97 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
98 | // ID |
||
99 | $insinstr_instrid = $instr_arr[$i]->getVar('instrid'); |
||
100 | // Название |
||
101 | $insinstr_title = $instr_arr[$i]->getVar('title'); |
||
102 | // Статус |
||
103 | $insinstr_status = $instr_arr[$i]->getVar('status'); |
||
104 | // Количество страниц |
||
105 | $insinstr_pages = $instr_arr[$i]->getVar('pages'); |
||
106 | // Категория |
||
107 | $insinstr_cat = $categoryHandler->get($instr_arr[$i]->getVar('cid')); |
||
108 | |||
109 | // Выводим в шаблон |
||
110 | $GLOBALS['xoopsTpl']->append('insListInstr', ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cat->getVar('cid'), 'class' => $class]); |
||
111 | } |
||
112 | |||
113 | // |
||
114 | $inshead = isset($objInscat) && is_object($objInscat) ? sprintf(_AM_INSTR_LISTINSTRINCAT, $objInscat->getVar('title')) : _AM_INSTR_LISTINSTRALL; |
||
115 | $GLOBALS['xoopsTpl']->assign('insHead', $inshead); |
||
116 | // Языковые константы |
||
117 | $GLOBALS['xoopsTpl']->assign('lang_title', _AM_INSTRUCTION_TITLE); |
||
118 | $GLOBALS['xoopsTpl']->assign('lang_cat', _AM_INSTRUCTION_CAT); |
||
119 | $GLOBALS['xoopsTpl']->assign('lang_pages', _AM_INSTRUCTION_PAGES); |
||
120 | $GLOBALS['xoopsTpl']->assign('lang_action', _AM_INSTRUCTION_ACTION); |
||
121 | $GLOBALS['xoopsTpl']->assign('lang_display', _AM_INSTRUCTION_DISPLAY); |
||
122 | $GLOBALS['xoopsTpl']->assign('lang_edit', _AM_INSTRUCTION_EDIT); |
||
123 | $GLOBALS['xoopsTpl']->assign('lang_del', _AM_INSTRUCTION_DEL); |
||
124 | $GLOBALS['xoopsTpl']->assign('lang_lock', _AM_INSTRUCTION_LOCK); |
||
125 | $GLOBALS['xoopsTpl']->assign('lang_unlock', _AM_INSTRUCTION_UNLOCK); |
||
126 | $GLOBALS['xoopsTpl']->assign('lang_addpage', _AM_INSTRUCTION_ADDPAGE); |
||
127 | $GLOBALS['xoopsTpl']->assign('lang_addinstr', _AM_INSTRUCTION_ADDINSTR); |
||
128 | } |
||
129 | |||
130 | // Выводим шаблон |
||
131 | $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_instr.tpl'); |
||
132 | |||
133 | // Текст внизу админки |
||
134 | include __DIR__ . '/admin_footer.php'; |
||
135 | |||
136 | break; |
||
137 | |||
138 | // Редактирование категории |
||
139 | case 'editinstr': |
||
140 | |||
141 | // Заголовок админки |
||
142 | xoops_cp_header(); |
||
143 | // Меню |
||
144 | $adminObject->displayNavigation(basename(__FILE__)); |
||
145 | |||
146 | // Если мы редактируем инструкцию |
||
147 | if ($instrid) { |
||
148 | $objInsinstr = $instructionHandler->get($instrid); |
||
149 | // Создание новой страницы |
||
150 | } else { |
||
151 | $objInsinstr = $instructionHandler->create(); |
||
152 | } |
||
153 | |||
154 | // Выводим шаблон |
||
155 | $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editinstr.tpl'); |
||
156 | $form = $objInsinstr->getForm('instr.php'); |
||
157 | // Форма |
||
158 | echo $form->render(); |
||
159 | |||
160 | // Текст внизу админки |
||
161 | include __DIR__ . '/admin_footer.php'; |
||
162 | |||
163 | break; |
||
164 | |||
165 | // Сохранение инструкций |
||
166 | case 'saveinstr': |
||
167 | |||
168 | // Проверка |
||
169 | 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. ![]() |
|||
170 | redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
171 | } |
||
172 | // Если мы редактируем |
||
173 | if ($instrid) { |
||
174 | $objInsinstr = $instructionHandler->get($instrid); |
||
175 | } else { |
||
176 | $objInsinstr = $instructionHandler->create(); |
||
177 | // Указываем дату создания |
||
178 | $objInsinstr->setVar('datecreated', $time); |
||
179 | // Указываем пользователя |
||
180 | $objInsinstr->setVar('uid', $uid); |
||
181 | } |
||
182 | |||
183 | $err = false; |
||
184 | $message_err = ''; |
||
185 | // |
||
186 | $instr_title = Request::getString('title', '', 'POST'); |
||
187 | $instr_description = Request::getText('description', '', 'POST'); |
||
188 | |||
189 | // Дата обновления |
||
190 | $objInsinstr->setVar('dateupdated', $time); |
||
191 | // |
||
192 | $objInsinstr->setVar('cid', $cid); |
||
193 | $objInsinstr->setVar('title', $instr_title); |
||
194 | $objInsinstr->setVar('status', Request::getInt('status', 0)); |
||
195 | $objInsinstr->setVar('description', $instr_description); |
||
196 | $objInsinstr->setVar('metakeywords', Request::getString('metakeywords', '')); |
||
197 | $objInsinstr->setVar('metadescription', Request::getString('metadescription', '')); |
||
198 | |||
199 | // Проверка категорий |
||
200 | if (!$cid) { |
||
201 | $err = true; |
||
202 | $message_err .= _AM_INSTRUCTION_ERR_CAT . '<br>'; |
||
203 | } |
||
204 | // Проверка названия |
||
205 | if (!$instr_title) { |
||
206 | $err = true; |
||
207 | $message_err .= _AM_INSTR_ERR_TITLE . '<br>'; |
||
208 | } |
||
209 | // Проверка основного текста |
||
210 | if (!$instr_description) { |
||
211 | $err = true; |
||
212 | $message_err .= _AM_INSTR_ERR_DESCRIPTION . '<br>'; |
||
213 | } |
||
214 | |||
215 | // Если были ошибки |
||
216 | if (true === $err) { |
||
217 | xoops_cp_header(); |
||
218 | // Меню страницы |
||
219 | $adminObject->displayNavigation(basename(__FILE__)); |
||
220 | |||
221 | $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>'; |
||
222 | // Выводим ошибки в шаблон |
||
223 | $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err); |
||
224 | // Если небыло ошибок |
||
225 | } else { |
||
226 | // Вставляем данные в БД |
||
227 | if ($instructionHandler->insert($objInsinstr)) { |
||
228 | // Получаем ID созданной записи |
||
229 | $instrid_new = $instrid ?: $objInsinstr->getNewInstertId(); |
||
230 | // Обновление даты в категории |
||
231 | $categoryHandler->updateDateupdated($cid, $time); |
||
232 | // Тэги |
||
233 | if (xoops_getModuleOption('usetag', 'instruction')) { |
||
234 | $tagHandler = xoops_getModuleHandler('tag', 'tag'); |
||
235 | $tagHandler->updateByItem(Request::getArray('tag', '', 'POST'), $instrid_new, $GLOBALS['xoopsModule']->getVar('dirname'), 0); |
||
236 | } |
||
237 | |||
238 | // Если мы редактируем |
||
239 | if ($instrid) { |
||
240 | redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRMODIFY); |
||
241 | } else { |
||
242 | redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRADDED); |
||
243 | } |
||
244 | } |
||
245 | xoops_cp_header(); |
||
246 | // Меню страницы |
||
247 | $adminObject->displayNavigation(basename(__FILE__)); |
||
248 | |||
249 | // Выводим ошибки в шаблон |
||
250 | $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInstructioncat->getHtmlErrors()); |
||
251 | } |
||
252 | // Выводим шаблон |
||
253 | $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_saveinstr.tpl'); |
||
254 | // Выводим форму |
||
255 | $form = $objInsinstr->getForm(); |
||
256 | // Форма |
||
257 | echo $form->render(); |
||
258 | // Текст внизу админки |
||
259 | include __DIR__ . '/admin_footer.php'; |
||
260 | |||
261 | break; |
||
262 | |||
263 | // Просмотр категории |
||
264 | case 'viewinstr': |
||
265 | |||
266 | // Подключаем трей |
||
267 | include_once XOOPS_ROOT_PATH . '/modules/instruction/class/Tree.php'; |
||
268 | |||
269 | // Заголовок админки |
||
270 | xoops_cp_header(); |
||
271 | // Меню |
||
272 | $adminObject->displayNavigation(basename(__FILE__)); |
||
273 | // Кнопки |
||
274 | $adminObject->addItemButton(_AM_INSTRUCTION_ADDPAGE, 'instr.php?op=editpage&instrid=' . $instrid, 'add'); |
||
275 | $adminObject->displayButton('left', ''); |
||
276 | |||
277 | // |
||
278 | $objInsinstr = $instructionHandler->get($instrid); |
||
279 | |||
280 | // Находим все страницы в данной инструкции |
||
281 | $criteria = new \CriteriaCompo(); |
||
282 | $criteria->add(new \Criteria('instrid', $instrid, '=')); |
||
283 | $criteria->setSort('weight'); |
||
284 | $criteria->setOrder('ASC'); |
||
285 | $ins_page = $pageHandler->getall($criteria); |
||
286 | // |
||
287 | unset($criteria); |
||
288 | |||
289 | // Инициализируем |
||
290 | $instree = new instruction\Tree($ins_page, 'pageid', 'pid'); |
||
291 | // Выводим список страниц в шаблон |
||
292 | $GLOBALS['xoopsTpl']->assign('insListPage', $instree->makePagesAdmin($objInsinstr, '--')); |
||
293 | |||
294 | // Выводим шаблон |
||
295 | $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_viewinstr.tpl'); |
||
296 | |||
297 | // Текст внизу админки |
||
298 | include __DIR__ . '/admin_footer.php'; |
||
299 | |||
300 | break; |
||
301 | |||
302 | // Удаление категории |
||
303 | case 'delinstr': |
||
304 | |||
305 | // Проверка на instrid |
||
306 | // ================== |
||
307 | // Объект инструкций |
||
308 | $objInsinstr = $instructionHandler->get($instrid); |
||
309 | |||
310 | // Нажали ли мы на кнопку OK |
||
311 | $ok = Request::getInt('ok', 0, 'POST'); |
||
312 | // |
||
313 | if ($ok) { |
||
314 | |||
315 | // Проверка |
||
316 | 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. ![]() |
|||
317 | redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
318 | } |
||
319 | // Находим все страницы, пренадлежащие этой инструкции |
||
320 | $criteria = new \CriteriaCompo(); |
||
321 | $criteria->add(new \Criteria('instrid', $instrid)); |
||
322 | $ins_page = $pageHandler->getall($criteria); |
||
323 | // |
||
324 | unset($criteria); |
||
325 | // Перебираем все страницы в данной инструкции |
||
326 | foreach (array_keys($ins_page) as $i) { |
||
327 | // Декримент комментов |
||
328 | // Делает дикримент одного коммента, а не всех в цикле... |
||
329 | // Удаляем комментарии |
||
330 | xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $ins_page[$i]->getVar('pageid')); |
||
331 | // Декримент страниц (Опционально) |
||
332 | // ============================== |
||
333 | |||
334 | // Удаляем страницу |
||
335 | // Сделать проверку на удалённость страницы |
||
336 | // ======================================== |
||
337 | $pageHandler->delete($ins_page[$i]); |
||
338 | } |
||
339 | // Пытаемся удалить инструкцию |
||
340 | if ($instructionHandler->delete($objInsinstr)) { |
||
341 | // Редирект |
||
342 | redirect_header('instr.php', 3, _AM_INSTRUCTION_INSTRDELETED); |
||
343 | } else { |
||
344 | // Редирект |
||
345 | redirect_header('instr.php', 3, _AM_INSTRUCTION_ERR_DELINSTR); |
||
346 | } |
||
347 | 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. ![]() |
|||
348 | xoops_cp_header(); |
||
349 | |||
350 | $adminObject->displayNavigation(basename(__FILE__)); |
||
351 | // Форма |
||
352 | xoops_confirm(['ok' => 1, 'instrid' => $instrid, 'op' => 'delinstr'], 'instr.php', sprintf(_AM_INSTRUCTION_FORMDELINSTR, $objInsinstr->getVar('title'))); |
||
353 | // Текст внизу админки |
||
354 | include __DIR__ . '/admin_footer.php'; |
||
355 | } |
||
356 | |||
357 | break; |
||
358 | |||
359 | // Добавление страницы |
||
360 | case 'editpage': |
||
361 | |||
362 | // Заголовок админки |
||
363 | xoops_cp_header(); |
||
364 | // Скрипты |
||
365 | $xoTheme->addScript(XOOPS_URL . '/modules/instruction/assets/js/admin.js'); |
||
366 | // Меню |
||
367 | $adminObject->displayNavigation(basename(__FILE__)); |
||
368 | |||
369 | // Если мы редактируем страницу |
||
370 | if ($pageid) { |
||
371 | // Получаем объект страницы |
||
372 | $objInspage = $pageHandler->get($pageid); |
||
373 | // ID инструкции |
||
374 | $instrid = $objInspage->getVar('instrid'); |
||
375 | // Создание новой страницы |
||
376 | } elseif ($instrid) { |
||
377 | // Создаём объект страницы |
||
378 | $objInspage = $pageHandler->create(); |
||
379 | // Устанавливаем родительскую страницу |
||
380 | $objInspage->setVar('pid', $pid); |
||
381 | } else { |
||
382 | redirect_header('instr.php', 3, _AM_INSTRUCTION_BADREQUEST); |
||
383 | } |
||
384 | // Форма |
||
385 | $form = $objInspage->getForm('instr.php', $instrid); |
||
386 | // Форма |
||
387 | echo $form->render(); |
||
388 | // Выводим шаблон |
||
389 | $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_editpage.tpl'); |
||
390 | |||
391 | // Текст внизу админки |
||
392 | include __DIR__ . '/admin_footer.php'; |
||
393 | |||
394 | break; |
||
395 | |||
396 | // Сохранение страницы |
||
397 | case 'savepage': |
||
398 | // Ошибки |
||
399 | $err = false; |
||
400 | $message_err = ''; |
||
401 | |||
402 | // Проверка сессии |
||
403 | 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. ![]() |
|||
404 | $err = true; |
||
405 | $err_txt = implode(', ', $GLOBALS['xoopsSecurity']->getErrors()); |
||
406 | $message_err .= $err_txt . '<br>'; |
||
407 | } |
||
408 | |||
409 | // Если мы редактируем |
||
410 | View Code Duplication | if ($pageid) { |
|
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. ![]() |
|||
411 | $objInspage = $pageHandler->get($pageid); |
||
412 | } elseif ($instrid) { |
||
413 | $objInspage = $pageHandler->create(); |
||
414 | // Если мы создаём страницу необходимо указать к какой инструкции |
||
415 | $objInspage->setVar('instrid', $instrid); |
||
416 | // Указываем дату создания |
||
417 | $objInspage->setVar('datecreated', $time); |
||
418 | // Указываем пользователя |
||
419 | $objInspage->setVar('uid', $uid); |
||
420 | } else { |
||
421 | redirect_header('instr.php', 3, _AM_INSTRUCTION_BADREQUEST); |
||
422 | } |
||
423 | |||
424 | // |
||
425 | $page_title = Request::getString('title', '', 'POST'); |
||
426 | $page_hometext = Request::getText('hometext', '', 'POST'); |
||
427 | |||
428 | // Родительская страница |
||
429 | $objInspage->setVar('pid', $pid); |
||
430 | // Дата обновления |
||
431 | $objInspage->setVar('dateupdated', $time); |
||
432 | // Название страницы |
||
433 | $objInspage->setVar('title', $page_title); |
||
434 | // Вес страницы |
||
435 | $objInspage->setVar('weight', $weight); |
||
436 | // Основной текст |
||
437 | $objInspage->setVar('hometext', $page_hometext); |
||
438 | // Сноска |
||
439 | $objInspage->setVar('footnote', Request::getString('footnote', '', 'POST')); |
||
440 | // Статус |
||
441 | $objInspage->setVar('status', Request::getInt('status', 0, 'POST')); |
||
442 | // Тип |
||
443 | $objInspage->setVar('type', Request::getInt('type', 0, 'POST')); |
||
444 | // Мета-теги описания |
||
445 | $objInspage->setVar('keywords', Request::getString('keywords', '', 'POST')); |
||
446 | // Мета-теги ключевых слов |
||
447 | $objInspage->setVar('description', Request::getText('description', '', 'POST')); |
||
448 | // |
||
449 | $dosmiley = (Request::getInt('dosmiley', 0, 'POST') > 0) ? 1 : 0; |
||
450 | $doxcode = (Request::getInt('doxcode', 0, 'POST') > 0) ? 1 : 0; |
||
451 | $dobr = (Request::getInt('dobr', 0, 'POST') > 0) ? 1 : 0; |
||
452 | $dohtml = (Request::getInt('dohtml', 0, 'POST') > 0) ? 1 : 0; |
||
453 | //$doimage = ( isset( $_POST['doimage'] ) && intval( $_POST['doimage'] ) > 0 ) ? 1 : 0; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
55% 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. ![]() |
|||
454 | $objInspage->setVar('dohtml', $dohtml); |
||
455 | $objInspage->setVar('dosmiley', $dosmiley); |
||
456 | $objInspage->setVar('doxcode', $doxcode); |
||
457 | //$objInspage->setVar( 'doimage', $doimage ); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% 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. ![]() |
|||
458 | $objInspage->setVar('dobr', $dobr); |
||
459 | |||
460 | // |
||
461 | View Code Duplication | if (!$pageid && !$instrid) { |
|
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. ![]() |
|||
462 | $err = true; |
||
463 | $message_err .= _AM_INSTRUCTION_ERR_INSTR . '<br>'; |
||
464 | } |
||
465 | // Проверка веса |
||
466 | if (0 == $weight) { |
||
467 | $err = true; |
||
468 | $message_err .= _AM_INSTRUCTION_ERR_WEIGHT . '<br>'; |
||
469 | } |
||
470 | // Проверка родительской страницы |
||
471 | View Code Duplication | if ($pageid && ($pageid == $pid)) { |
|
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. ![]() |
|||
472 | $err = true; |
||
473 | $message_err .= _AM_INSTRUCTION_ERR_PPAGE . '<br>'; |
||
474 | } |
||
475 | // Проверка названия |
||
476 | if (!$page_title) { |
||
477 | $err = true; |
||
478 | $message_err .= _AM_INSTR_ERR_TITLE . '<br>'; |
||
479 | } |
||
480 | // Проверка основного текста |
||
481 | if (!$page_hometext) { |
||
482 | $err = true; |
||
483 | $message_err .= _AM_INSTR_ERR_HOMETEXT . '<br>'; |
||
484 | } |
||
485 | |||
486 | // Если были ошибки |
||
487 | if (true === $err) { |
||
488 | xoops_cp_header(); |
||
489 | // Меню страницы |
||
490 | $adminObject->displayNavigation(basename(__FILE__)); |
||
491 | |||
492 | $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>'; |
||
493 | // Выводим ошибки в шаблон |
||
494 | $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err); |
||
495 | // Если небыло ошибок |
||
496 | } else { |
||
497 | // Вставляем данные в БД |
||
498 | if ($pageHandler->insert($objInspage)) { |
||
499 | // Ссылка для редиректа |
||
500 | $redirect_url = 'instr.php?op=viewinstr&instrid=' . $instrid . '#pageid_' . $pid; |
||
501 | // Получаем ID инструкции |
||
502 | $instrid = $objInspage->getInstrid(); |
||
503 | // Обновляем в инструкции число страниц и дату |
||
504 | $instructionHandler->updatePages($instrid); |
||
505 | // Если мы редактируем |
||
506 | if ($pageid) { |
||
507 | // Редирект |
||
508 | redirect_header($redirect_url, 3, _AM_INSTRUCTION_PAGEMODIFY); |
||
509 | // Если мы добавляем |
||
510 | } else { |
||
511 | // Инкримент комментов |
||
512 | $pageHandler->updateposts($uid, Request::getInt('status', 0, 'POST'), 'add'); |
||
513 | // Редирект |
||
514 | redirect_header($redirect_url, 3, _AM_INSTRUCTION_PAGEADDED); |
||
515 | } |
||
516 | } |
||
517 | xoops_cp_header(); |
||
518 | // Меню страницы |
||
519 | $adminObject->displayNavigation(basename(__FILE__)); |
||
520 | |||
521 | // Выводим ошибки в шаблон |
||
522 | $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors()); |
||
523 | } |
||
524 | // Скрипты |
||
525 | $xoTheme->addScript(XOOPS_URL . '/modules/instruction/assets/js/admin.js'); |
||
526 | // Выводим шаблон |
||
527 | $GLOBALS['xoopsTpl']->display('db:admin/instruction_admin_savepage.tpl'); |
||
528 | // Выводим форму |
||
529 | $form = $objInspage->getForm('instr.php', $instrid); |
||
530 | // Форма |
||
531 | echo $form->render(); |
||
532 | // Текст внизу админки |
||
533 | include __DIR__ . '/admin_footer.php'; |
||
534 | |||
535 | break; |
||
536 | |||
537 | // Удаление страницы |
||
538 | case 'delpage': |
||
539 | |||
540 | // Проверка на pageid |
||
541 | // ================== |
||
542 | |||
543 | $objInspage = $pageHandler->get($pageid); |
||
544 | // Нажали ли мы на кнопку OK |
||
545 | $ok = Request::getInt('ok', 0, 'POST'); |
||
546 | // Если мы нажали на кнопку |
||
547 | if ($ok) { |
||
548 | |||
549 | // Проверка |
||
550 | 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. ![]() |
|||
551 | redirect_header('instr.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
552 | } |
||
553 | // ID инструкции |
||
554 | $page_instrid = $objInspage->getVar('instrid'); |
||
555 | // Декримент комментов |
||
556 | $pageHandler->updateposts($objInspage->getVar('uid'), $objInspage->getVar('status'), 'delete'); |
||
557 | // Пытаемся удалить страницу |
||
558 | if ($pageHandler->delete($objInspage)) { |
||
559 | // Обновляем в инструкции число страниц и дату |
||
560 | $instructionHandler->updatePages($page_instrid); |
||
561 | // Удаляем комментарии |
||
562 | xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $pageid); |
||
563 | // |
||
564 | redirect_header('instr.php?op=viewinstr&instrid=' . $page_instrid, 3, _AM_INSTRUCTION_PAGEDELETED); |
||
565 | // Если не смогли удалить страницу |
||
566 | } else { |
||
567 | redirect_header('instr.php?op=viewinstr&instrid=' . $page_instrid, 3, _AM_INSTRUCTION_ERR_DELPAGE); |
||
568 | } |
||
569 | 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. ![]() |
|||
570 | |||
571 | // Заголовок админки |
||
572 | xoops_cp_header(); |
||
573 | // Меню |
||
574 | $adminObject->displayNavigation(basename(__FILE__)); |
||
575 | // Форма |
||
576 | xoops_confirm(['ok' => 1, 'pageid' => $pageid, 'op' => 'delpage'], 'instr.php', sprintf(_AM_INSTRUCTION_FORMDELPAGE, $objInspage->getVar('title'))); |
||
577 | // Текст внизу админки |
||
578 | include __DIR__ . '/admin_footer.php'; |
||
579 | } |
||
580 | |||
581 | break; |
||
582 | |||
583 | // Удаление страницы |
||
584 | case 'updpage': |
||
585 | |||
586 | // Принимаем данные |
||
587 | $pageids = Request::getArray('pageids', 0, 'POST'); |
||
588 | $weights = Request::getArray('weights', 0, 'POST'); |
||
589 | // Перебираем все значения |
||
590 | foreach ($pageids as $key => $pageid) { |
||
591 | |||
592 | // Объявляем объект |
||
593 | $objInspage = $pageHandler->get($pageid); |
||
594 | // Устанавливаем вес |
||
595 | $objInspage->setVar('weight', $weights[$key]); |
||
596 | // Вставляем данные в БД |
||
597 | $pageHandler->insert($objInspage); |
||
598 | // Удаляем объект |
||
599 | unset($objInspage); |
||
600 | } |
||
601 | // Редирект |
||
602 | redirect_header('instr.php?op=viewinstr&instrid=' . $instrid, 3, _AM_INSTRUCTION_PAGESUPDATE); |
||
603 | |||
604 | break; |
||
605 | |||
606 | } |
||
607 |
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.