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 | require_once __DIR__ . '/header.php'; |
||
7 | |||
8 | // Объявляем объекты |
||
0 ignored issues
–
show
|
|||
9 | //$instructionHandler = xoops_getModuleHandler('instruction', 'instruction'); |
||
10 | //$categoryHandler = xoops_getModuleHandler( 'category', 'instruction' ); |
||
11 | //$pageHandler = xoops_getModuleHandler('page', 'instruction'); |
||
12 | |||
13 | // |
||
14 | $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. ![]() |
|||
15 | $time = time(); |
||
16 | |||
17 | // ID инструкции |
||
18 | $instrid = Request::getInt('instrid', Request::getInt('instrid', 0, 'GET'), 'POST'); |
||
19 | |||
20 | // ID страницы |
||
21 | $pageid = Request::getInt('pageid', Request::getInt('pageid', 0, 'GET'), 'POST'); |
||
22 | // ID категории |
||
23 | $cid = Request::getInt('cid', 0, 'POST'); |
||
24 | // Вес |
||
25 | $weight = Request::getInt('weight', 0, 'POST'); |
||
26 | // |
||
27 | $pid = Request::getInt('pid', 0, 'POST'); |
||
28 | |||
29 | // Права на добавление |
||
30 | $cat_submit = Xoopsmodules\instruction\Utility::getItemIds($moduleDirName . '_submit'); |
||
31 | // Права на редактирование |
||
32 | $cat_edit = Xoopsmodules\instruction\Utility::getItemIds($moduleDirName . '_edit'); |
||
33 | |||
34 | $op = Request::getString('op', Request::getString('op', '', 'GET'), 'POST'); |
||
35 | |||
36 | switch ($op) { |
||
37 | |||
38 | case 'editpage': |
||
39 | |||
40 | // Задание тайтла |
||
41 | $xoopsOption['xoops_pagetitle'] = ''; |
||
42 | // Шаблон |
||
43 | $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_editpage.tpl'; |
||
44 | // Заголовок |
||
45 | include_once $GLOBALS['xoops']->path('header.php'); |
||
46 | |||
47 | // Если мы редактируем страницу |
||
48 | if ($pageid) { |
||
49 | // Получаем объект страницы |
||
50 | $objInspage = $pageHandler->get($pageid); |
||
51 | // ID инструкции |
||
52 | $instrid = $objInspage->getVar('instrid'); |
||
53 | // Объект инструкции |
||
54 | $objInsinstr = $instructionHandler->get($instrid); |
||
55 | // Можно ли редактировать инструкцию в данной категории |
||
56 | if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) { |
||
57 | redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE); |
||
58 | } |
||
59 | // Создание новой страницы |
||
60 | } elseif ($instrid) { |
||
61 | |||
62 | // Если нельзя добавлять не в одну категорию |
||
63 | //if( ! count( $cat_submit ) ) redirect_header( 'index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMIT_PAGE ); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
52% 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. ![]() |
|||
64 | // Создаём объект страницы |
||
65 | $objInspage = $pageHandler->create(); |
||
66 | // Объект инструкции |
||
67 | $objInsinstr = $instructionHandler->get($instrid); |
||
68 | // Можно ли добавлять инструкции в данной категории |
||
69 | if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) { |
||
70 | redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE); |
||
71 | } |
||
72 | } else { |
||
73 | redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST); |
||
74 | } |
||
75 | |||
76 | // Информация об инструкции |
||
77 | |||
78 | // Массив данных об инструкции |
||
79 | $instrs = []; |
||
80 | // ID инструкции |
||
81 | $instrs['instrid'] = $objInsinstr->getVar('instrid'); |
||
82 | // Название страницы |
||
83 | $instrs['title'] = $objInsinstr->getVar('title'); |
||
84 | // Описание |
||
85 | $instrs['description'] = $objInsinstr->getVar('description'); |
||
86 | |||
87 | // Выводим в шаблон |
||
88 | $GLOBALS['xoopsTpl']->assign('insInstr', $instrs); |
||
89 | |||
90 | // |
||
91 | |||
92 | $form = $objInspage->getForm('submit.php', $instrid); |
||
93 | // Форма |
||
94 | $GLOBALS['xoopsTpl']->assign('insFormPage', $form->render()); |
||
95 | |||
96 | // Подвал |
||
97 | include_once $GLOBALS['xoops']->path('footer.php'); |
||
98 | |||
99 | break; |
||
100 | // Сохранение страницы |
||
101 | case 'savepage': |
||
102 | |||
103 | // Проверка |
||
104 | 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. ![]() |
|||
105 | redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
106 | } |
||
107 | |||
108 | $err = false; |
||
109 | $message_err = ''; |
||
110 | |||
111 | // Если мы редактируем |
||
112 | if ($pageid) { |
||
113 | $objInspage = $pageHandler->get($pageid); |
||
114 | // Объект инструкции |
||
115 | $objInsinstr = $instructionHandler->get($objInspage->getVar('instrid')); |
||
116 | // Можно ли редактировать инструкцию в данной категории |
||
117 | if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) { |
||
118 | redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE); |
||
119 | } |
||
120 | } elseif ($instrid) { |
||
121 | $objInspage = $pageHandler->create(); |
||
122 | // Объект инструкции |
||
123 | $objInsinstr = $instructionHandler->get($instrid); |
||
124 | // Можно ли добавлять инструкции в данной категории |
||
125 | if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) { |
||
126 | redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE); |
||
127 | } |
||
128 | |||
129 | // Если мы создаём страницу необходимо указать к какой инструкции |
||
130 | $objInspage->setVar('instrid', $instrid); |
||
131 | // Указываем дату создания |
||
132 | $objInspage->setVar('datecreated', $time); |
||
133 | // Указываем пользователя |
||
134 | $objInspage->setVar('uid', $uid); |
||
135 | } else { |
||
136 | redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST); |
||
137 | } |
||
138 | |||
139 | // Родительская страница |
||
140 | $objInspage->setVar('pid', $pid); |
||
141 | // Дата обновления |
||
142 | $objInspage->setVar('dateupdated', $time); |
||
143 | // |
||
144 | $objInspage->setVar('title', Request::getString('title', '', 'POST')); |
||
145 | $objInspage->setVar('weight', $weight); |
||
146 | $objInspage->setVar('hometext', Request::getText('hometext', '', 'POST')); |
||
147 | // Сноска |
||
148 | $objInspage->setVar('footnote', Request::getText('footnote', '', 'POST')); |
||
149 | $objInspage->setVar('status', Request::getInt('status', 0, 'POST')); |
||
150 | $objInspage->setVar('keywords', Request::getString('keywords', '', 'POST')); |
||
151 | $objInspage->setVar('description', Request::getText('description', '', 'POST')); |
||
152 | |||
153 | // Проверка категорий |
||
154 | if (!$pageid && !$instrid) { |
||
155 | $err = true; |
||
156 | $message_err .= _MD_INSTRUCTION_ERR_INSTR . '<br>'; |
||
157 | } |
||
158 | // Проверка веса |
||
159 | if (0 == $weight) { |
||
160 | $err = true; |
||
161 | $message_err .= _MD_INSTRUCTION_ERR_WEIGHT . '<br>'; |
||
162 | } |
||
163 | // Проверка родительской страницы |
||
164 | if ($pageid && ($pageid == $pid)) { |
||
165 | $err = true; |
||
166 | $message_err .= _MD_INSTRUCTION_ERR_PPAGE . '<br>'; |
||
167 | } |
||
168 | // Если были ошибки |
||
169 | if (true === $err) { |
||
170 | // Задание тайтла |
||
171 | $xoopsOption['xoops_pagetitle'] = ''; |
||
172 | // Шаблон |
||
173 | $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl'; |
||
174 | // Заголовок |
||
175 | include_once $GLOBALS['xoops']->path('header.php'); |
||
176 | // Сообщение об ошибке |
||
177 | $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>'; |
||
178 | // Выводим ошибки в шаблон |
||
179 | $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err); |
||
180 | // Если небыло ошибок |
||
181 | } else { |
||
182 | // Вставляем данные в БД |
||
183 | if ($pageHandler->insert($objInspage)) { |
||
184 | // Если мы редактируем |
||
185 | if ($pageid) { |
||
186 | // Обновление даты |
||
187 | $sql = sprintf('UPDATE %s SET `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid); |
||
188 | $GLOBALS['xoopsDB']->query($sql); |
||
189 | // Запись в лог |
||
190 | xoops_loadLanguage('main', 'userslog'); |
||
191 | //userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_MODIFY_PAGE ); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
54% 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. ![]() |
|||
192 | // |
||
193 | redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEMODIFY); |
||
194 | // Если мы добавляем |
||
195 | } else { |
||
196 | // Инкримент комментов |
||
197 | $pageHandler->updateposts($uid, Request::getInt('status', 0, 'POST'), 'add'); |
||
198 | // Инкремент страниц и обновление даты |
||
199 | $sql = sprintf('UPDATE %s SET `pages` = `pages` + 1, `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid); |
||
200 | $GLOBALS['xoopsDB']->query($sql); |
||
201 | // Запись в лог |
||
202 | xoops_loadLanguage('main', 'userslog'); |
||
203 | //userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_SUBMIT_PAGE ); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
54% 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. ![]() |
|||
204 | // |
||
205 | redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEADDED); |
||
206 | } |
||
207 | } |
||
208 | |||
209 | // Задание тайтла |
||
210 | $xoopsOption['xoops_pagetitle'] = ''; |
||
211 | // Шаблон |
||
212 | $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl'; |
||
213 | // Заголовок |
||
214 | include_once $GLOBALS['xoops']->path('header.php'); |
||
215 | |||
216 | // Выводим ошибки в шаблон |
||
217 | $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors()); |
||
218 | } |
||
219 | // Получаем форму |
||
220 | $form = $objInspage->getForm('submit.php', $instrid); |
||
221 | |||
222 | // Форма |
||
223 | $GLOBALS['xoopsTpl']->assign('insFormPage', $form->render()); |
||
224 | |||
225 | // Подвал |
||
226 | include_once $GLOBALS['xoops']->path('footer.php'); |
||
227 | |||
228 | break; |
||
229 | } |
||
230 |
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.