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.
1 | <?php |
||||
2 | // |
||||
3 | // ------------------------------------------------------------------------ // |
||||
4 | // XOOPS - PHP Content Management System // |
||||
5 | // Copyright (c) 2000-2020 XOOPS.org // |
||||
6 | // <https://xoops.org> // |
||||
7 | // ------------------------------------------------------------------------ // |
||||
8 | // This program is free software; you can redistribute it and/or modify // |
||||
9 | // it under the terms of the GNU General Public License as published by // |
||||
10 | // the Free Software Foundation; either version 2 of the License, or // |
||||
11 | // (at your option) any later version. // |
||||
12 | // // |
||||
13 | // You may not change or alter any portion of this comment or credits // |
||||
14 | // of supporting developers from this source code or any supporting // |
||||
15 | // source code which is considered copyrighted (c) material of the // |
||||
16 | // original comment or credit authors. // |
||||
17 | // // |
||||
18 | // This program is distributed in the hope that it will be useful, // |
||||
19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||||
20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||||
21 | // GNU General Public License for more details. // |
||||
22 | // // |
||||
23 | // You should have received a copy of the GNU General Public License // |
||||
24 | // along with this program; if not, write to the Free Software // |
||||
25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||||
26 | // ------------------------------------------------------------------------ // |
||||
27 | // Author: XOOPS Foundation // |
||||
28 | // URL: https://xoops.org/ // |
||||
29 | // Project: XOOPS Project // |
||||
30 | // ------------------------------------------------------------------------- // |
||||
31 | |||||
32 | use Xmf\Request; |
||||
33 | use XoopsModules\Newbb; |
||||
34 | |||||
35 | require_once __DIR__ . '/admin_header.php'; |
||||
36 | require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
||||
37 | if (!class_exists('XoopsGroupPermForm')) { |
||||
38 | require_once $GLOBALS['xoops']->path('class/xoopsform/grouppermform.php'); |
||||
39 | } |
||||
40 | |||||
41 | /** |
||||
42 | * TODO: synchronize cascade permissions for multi-level |
||||
43 | */ |
||||
44 | |||||
45 | /** |
||||
46 | * Add category navigation to forum casscade structure |
||||
47 | * <ol>Special points: |
||||
48 | * <li> Use negative values for category IDs to avoid conflict between category and forum |
||||
49 | * <li> Disabled checkbox for categories to avoid unnecessary permission items for categories in forum permission table |
||||
50 | * </ol> |
||||
51 | * |
||||
52 | * Note: this is a __patchy__ solution. We should have a more extensible and flexible group permission management: not only for data architecture but also for management interface |
||||
53 | */ |
||||
54 | |||||
55 | //$action = isset($_REQUEST['action']) ? strtolower($_REQUEST['action']) : ""; |
||||
56 | $action = mb_strtolower(Request::getCmd('action', '')); |
||||
57 | $module_id = $xoopsModule->getVar('mid'); |
||||
58 | /** var \XoopsModules\Newbb\PermissionHandler $newbbpermHandler */ |
||||
59 | $newbbpermHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); |
||||
60 | $perms = $newbbpermHandler->getValidForumPerms(); |
||||
61 | |||||
62 | switch ($action) { |
||||
63 | case 'template': |
||||
64 | xoops_cp_header(); |
||||
65 | $adminObject->displayNavigation(basename(__FILE__)); |
||||
66 | echo "<legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_PERM_ACTION . '</legend>'; |
||||
67 | $opform = new \XoopsSimpleForm(_AM_NEWBB_PERM_ACTION_HELP_TEMPLAT, 'actionform', 'admin_permissions.php', 'get'); |
||||
68 | $op_select = new \XoopsFormSelect('', 'action'); |
||||
69 | $op_select->setExtra('onchange="document.forms.actionform.submit()"'); |
||||
70 | $op_select->addOptionArray( |
||||
71 | [ |
||||
72 | 'no' => _SELECT, |
||||
73 | 'template' => _AM_NEWBB_PERM_TEMPLATE, |
||||
74 | 'apply' => _AM_NEWBB_PERM_TEMPLATEAPP, |
||||
75 | 'default' => _AM_NEWBB_PERM_SETBYGROUP, |
||||
76 | ] |
||||
77 | ); |
||||
78 | $opform->addElement($op_select); |
||||
79 | $opform->display(); |
||||
80 | /** @var \XoopsMemberHandler $memberHandler */ |
||||
81 | $memberHandler = xoops_getHandler('member'); |
||||
82 | $glist = $memberHandler->getGroupList(); |
||||
83 | $elements = []; |
||||
84 | $perm_template = $newbbpermHandler->getTemplate(); |
||||
85 | foreach (array_keys($glist) as $i) { |
||||
86 | $selected = !empty($perm_template[$i]) ? array_keys($perm_template[$i]) : []; |
||||
87 | $ret_ele = '<tr align="left" valign="top"><td class="head">' . $glist[$i] . '</td>'; |
||||
88 | $ret_ele .= '<td class="even">'; |
||||
89 | $ret_ele .= '<table class="outer"><tr><td class="odd"><table><tr>'; |
||||
90 | $ii = 0; |
||||
91 | $option_ids = []; |
||||
92 | foreach ($perms as $perm) { |
||||
93 | ++$ii; |
||||
94 | if (0 == $ii % 5) { |
||||
95 | $ret_ele .= '</tr><tr>'; |
||||
96 | } |
||||
97 | $checked = in_array('forum_' . $perm, $selected) ? ' checked' : ''; |
||||
98 | $option_id = $perm . '_' . $i; |
||||
99 | $option_ids[] = $option_id; |
||||
100 | $ret_ele .= '<td><input name="perms[' . $i . '][' . 'forum_' . $perm . ']" id="' . $option_id . '" onclick="" value="1" type="checkbox"' . $checked . '>' . constant('_AM_NEWBB_CAN_' . mb_strtoupper($perm)) . '<br></td>'; |
||||
101 | } |
||||
102 | $ret_ele .= '</tr></table></td><td class="even">'; |
||||
103 | $ret_ele .= _ALL . ' <input id="checkall[' . $i . ']" type="checkbox" value="" onclick="var optionids = new Array(' . implode(', ', $option_ids) . '); xoopsCheckAllElements(optionids, \'checkall[' . $i . ']\')" >'; |
||||
104 | $ret_ele .= '</td></tr></table>'; |
||||
105 | $ret_ele .= '</td></tr>'; |
||||
106 | $elements[] = $ret_ele; |
||||
107 | } |
||||
108 | $tray = new \XoopsFormElementTray(''); |
||||
109 | $tray->addElement(new \XoopsFormHidden('action', 'template_save')); |
||||
110 | $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||||
111 | $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
||||
112 | $ret = '<br><strong>' . _AM_NEWBB_PERM_TEMPLATE . '</strong><br>' . _AM_NEWBB_PERM_TEMPLATE_DESC . '<br>'; |
||||
113 | $ret .= "<form name='template' id='template' method='post'>\n<table width='100%' class='outer' cellspacing='1'>\n"; |
||||
114 | $ret .= implode("\n", $elements); |
||||
115 | $ret .= '<tr align="left" valign="top"><td class="head"></td><td class="even" style="text-align:center;">'; |
||||
116 | $ret .= $tray->render(); |
||||
117 | $ret .= '</td></tr>'; |
||||
118 | $ret .= '</table></form>'; |
||||
119 | echo $ret; |
||||
120 | require_once __DIR__ . '/admin_footer.php'; |
||||
121 | break; |
||||
122 | case 'template_save': |
||||
123 | // $res = $newbbpermHandler->setTemplate($_POST['perms'], $groupid = 0); |
||||
124 | $res = $newbbpermHandler->setTemplate(Request::getArray('perms', '', 'POST'), $groupid = 0); |
||||
0 ignored issues
–
show
|
|||||
125 | if ($res) { |
||||
126 | redirect_header('admin_permissions.php', 2, _AM_NEWBB_PERM_TEMPLATE_CREATED); |
||||
127 | } else { |
||||
128 | redirect_header('admin_permissions.php?action=template', 2, _AM_NEWBB_PERM_TEMPLATE_ERROR); |
||||
129 | } |
||||
130 | break; |
||||
131 | // exit(); |
||||
132 | |||||
133 | case 'apply': |
||||
134 | $perm_template = $newbbpermHandler->getTemplate(); |
||||
135 | if (null === $perm_template) { |
||||
136 | redirect_header('admin_permissions.php?action=template', 2, _AM_NEWBB_PERM_TEMPLATE); |
||||
137 | } |
||||
138 | xoops_cp_header(); |
||||
139 | $adminObject->displayNavigation(basename(__FILE__)); |
||||
140 | echo "<legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_PERM_ACTION . '</legend>'; |
||||
141 | $opform = new \XoopsSimpleForm(_AM_NEWBB_PERM_ACTION_HELP_APPLY, 'actionform', 'admin_permissions.php', 'get'); |
||||
142 | $op_select = new \XoopsFormSelect('', 'action'); |
||||
143 | $op_select->setExtra('onchange="document.forms.actionform.submit()"'); |
||||
144 | $op_select->addOptionArray( |
||||
145 | [ |
||||
146 | 'no' => _SELECT, |
||||
147 | 'template' => _AM_NEWBB_PERM_TEMPLATE, |
||||
148 | 'apply' => _AM_NEWBB_PERM_TEMPLATEAPP, |
||||
149 | ] |
||||
150 | ); |
||||
151 | $opform->addElement($op_select); |
||||
152 | $opform->display(); |
||||
153 | |||||
154 | /** @var Newbb\CategoryHandler $categoryHandler */ |
||||
155 | $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); |
||||
156 | $criteriaCategory = new \CriteriaCompo(new \Criteria('cat_id')); |
||||
157 | $criteriaCategory->setSort('cat_order'); |
||||
158 | $categories = $categoryHandler->getList($criteriaCategory); |
||||
159 | |||||
160 | /** @var Newbb\ForumHandler $forumHandler */ |
||||
161 | $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); |
||||
162 | $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); |
||||
163 | foreach (array_keys($forums) as $c) { |
||||
164 | $fm_options[-1 * $c - 1000] = ' '; |
||||
165 | $fm_options[-1 * $c] = '[' . $categories[$c] . ']'; |
||||
166 | foreach (array_keys($forums[$c]) as $f) { |
||||
167 | $fm_options[$f] = $forums[$c][$f]['prefix'] . $forums[$c][$f]['forum_name']; |
||||
168 | } |
||||
169 | } |
||||
170 | unset($forums, $categories); |
||||
171 | |||||
172 | $fmform = new \XoopsThemeForm(_AM_NEWBB_PERM_TEMPLATEAPP, 'fmform', 'admin_permissions.php', 'post', true); |
||||
173 | $fm_select = new \XoopsFormSelect(_AM_NEWBB_PERM_FORUMS, 'forums', null, 10, true); |
||||
174 | $fm_select->addOptionArray($fm_options); |
||||
175 | $fmform->addElement($fm_select); |
||||
176 | $tray = new \XoopsFormElementTray(''); |
||||
177 | $tray->addElement(new \XoopsFormHidden('action', 'apply_save')); |
||||
178 | $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||||
179 | $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset')); |
||||
180 | $fmform->addElement($tray); |
||||
181 | $fmform->display(); |
||||
182 | require_once __DIR__ . '/admin_footer.php'; |
||||
183 | break; |
||||
184 | case 'apply_save': |
||||
185 | if (!Request::getArray('forums', '', 'POST')) { |
||||
186 | break; |
||||
187 | } |
||||
188 | foreach (Request::getArray('forums', '', 'POST') as $forum) { |
||||
189 | if ($forum < 1) { |
||||
190 | continue; |
||||
191 | } |
||||
192 | $newbbpermHandler->applyTemplate($forum, $module_id); |
||||
193 | } |
||||
194 | $cacheHelper = Newbb\Utility::cleanCache(); |
||||
0 ignored issues
–
show
Are you sure the assignment to
$cacheHelper is correct as XoopsModules\Newbb\Utility::cleanCache() targeting XoopsModules\Newbb\Utility::cleanCache() seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||
195 | //$cacheHelper->delete('permission'); |
||||
196 | redirect_header('admin_permissions.php', 2, _AM_NEWBB_PERM_TEMPLATE_APPLIED); |
||||
197 | break; |
||||
198 | default: |
||||
199 | xoops_cp_header(); |
||||
200 | |||||
201 | $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); |
||||
202 | $criteriaCategory = new \CriteriaCompo(new \Criteria('cat_id')); |
||||
203 | $criteriaCategory->setSort('cat_order'); |
||||
204 | $categories = $categoryHandler->getList($criteriaCategory); |
||||
205 | |||||
206 | if (0 === count($categories)) { |
||||
207 | redirect_header('admin_cat_manager.php', 2, _AM_NEWBB_CREATENEWCATEGORY); |
||||
208 | } |
||||
209 | |||||
210 | $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); |
||||
211 | $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); |
||||
0 ignored issues
–
show
array_keys($categories) of type array is incompatible with the type integer expected by parameter $cat_id of XoopsModules\Newbb\ForumHandler::getTree() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
212 | |||||
213 | if (0 === count($forums)) { |
||||
214 | redirect_header('admin_forum_manager.php', 2, _AM_NEWBB_CREATENEWFORUM); |
||||
215 | } |
||||
216 | |||||
217 | $adminObject->displayNavigation(basename(__FILE__)); |
||||
218 | echo "<legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_PERM_ACTION . '</legend>'; |
||||
219 | $opform = new \XoopsSimpleForm(_AM_NEWBB_PERM_ACTION_HELP, 'actionform', 'admin_permissions.php', 'get'); |
||||
220 | $op_select = new \XoopsFormSelect('', 'action'); |
||||
221 | $op_select->setExtra('onchange="document.forms.actionform.submit()"'); |
||||
222 | $op_select->addOptionArray( |
||||
223 | [ |
||||
224 | 'no' => _SELECT, |
||||
225 | 'template' => _AM_NEWBB_PERM_TEMPLATE, |
||||
226 | 'apply' => _AM_NEWBB_PERM_TEMPLATEAPP, |
||||
227 | 'default' => _AM_NEWBB_PERM_SETBYGROUP, |
||||
228 | ] |
||||
229 | ); |
||||
230 | $opform->addElement($op_select); |
||||
231 | $opform->display(); |
||||
232 | |||||
233 | $op_options = ['category' => _AM_NEWBB_CAT_ACCESS]; |
||||
234 | $fm_options = [ |
||||
235 | 'category' => [ |
||||
236 | 'title' => _AM_NEWBB_CAT_ACCESS, |
||||
237 | 'item' => 'category_access', |
||||
238 | 'desc' => '', |
||||
239 | 'anonymous' => true, |
||||
240 | ], |
||||
241 | ]; |
||||
242 | foreach ($perms as $perm) { |
||||
243 | $op_options[$perm] = constant('_AM_NEWBB_CAN_' . mb_strtoupper($perm)); |
||||
244 | $fm_options[$perm] = [ |
||||
245 | 'title' => constant('_AM_NEWBB_CAN_' . mb_strtoupper($perm)), |
||||
246 | 'item' => 'forum_' . $perm, |
||||
247 | 'desc' => '', |
||||
248 | 'anonymous' => true, |
||||
249 | ]; |
||||
250 | } |
||||
251 | |||||
252 | $op_keys = array_keys($op_options); |
||||
253 | $op = mb_strtolower(Request::getCmd('op', Request::getCmd('op', '', 'COOKIE'), 'GET')); |
||||
254 | if (empty($op)) { |
||||
255 | $op = $op_keys[0]; |
||||
256 | setcookie('op', isset($op_keys[1]) ? $op_keys[1] : ''); |
||||
257 | } elseif (false !== ($key = array_search($op, $op_keys, true))) { |
||||
258 | setcookie('op', isset($op_keys[$key + 1]) ? $op_keys[$key + 1] : ''); |
||||
259 | } |
||||
260 | |||||
261 | $opform = new \XoopsSimpleForm('', 'opform', 'admin_permissions.php', 'get'); |
||||
262 | $op_select = new \XoopsFormSelect('', 'op', $op); |
||||
263 | $op_select->setExtra('onchange="document.forms.opform.submit()"'); |
||||
264 | $op_select->addOptionArray($op_options); |
||||
265 | $opform->addElement($op_select); |
||||
266 | $opform->display(); |
||||
267 | |||||
268 | $perm_desc = ''; |
||||
269 | |||||
270 | $form = new Newbb\GroupPermForm($fm_options[$op]['title'], $module_id, $fm_options[$op]['item'], $fm_options[$op]['desc'], 'admin/admin_permissions.php', $fm_options[$op]['anonymous']); |
||||
0 ignored issues
–
show
The call to
XoopsModules\Newbb\GroupPermForm::__construct() has too many arguments starting with $fm_options[$op]['anonymous'] .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. Please note the @ignore annotation hint above. ![]() |
|||||
271 | |||||
272 | $categoryHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Category'); |
||||
273 | $criteriaCategory = new \CriteriaCompo(new \Criteria('cat_id')); |
||||
274 | $criteriaCategory->setSort('cat_order'); |
||||
275 | $categories = $categoryHandler->getList($criteriaCategory); |
||||
276 | if ('category' === $op) { |
||||
277 | foreach (array_keys($categories) as $key) { |
||||
278 | $form->addItem($key, $categories[$key]); |
||||
279 | } |
||||
280 | unset($categories); |
||||
281 | } else { |
||||
282 | $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum'); |
||||
283 | $forums = $forumHandler->getTree(array_keys($categories), 0, 'all'); |
||||
284 | if (count($forums) > 0) { |
||||
285 | foreach (array_keys($forums) as $c) { |
||||
286 | $key_c = -1 * $c; |
||||
287 | $form->addItem($key_c, '<strong>[' . $categories[$c] . ']</strong>'); |
||||
288 | foreach (array_keys($forums[$c]) as $f) { |
||||
289 | $pid = $forums[$c][$f]['parent_forum'] ?: $key_c; |
||||
290 | $form->addItem($f, $forums[$c][$f]['prefix'] . $forums[$c][$f]['forum_name'], $pid); |
||||
291 | } |
||||
292 | } |
||||
293 | } |
||||
294 | unset($forums, $categories); |
||||
295 | } |
||||
296 | $form->display(); |
||||
297 | echo '<fieldset>'; |
||||
298 | echo '<legend> ' . _MI_NEWBB_ADMENU_PERMISSION . ' </legend>'; |
||||
299 | echo _AM_NEWBB_HELP_PERMISSION_TAB; |
||||
300 | echo '</fieldset>'; |
||||
301 | // Since we can not control the permission update, a trick is used here |
||||
302 | /** var Newbb\PermissionHandler $permissionHandler */ |
||||
303 | $permissionHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Permission'); |
||||
304 | $permissionHandler->createPermData(); |
||||
305 | $cacheHelper = Newbb\Utility::cleanCache(); |
||||
0 ignored issues
–
show
Are you sure the assignment to
$cacheHelper is correct as XoopsModules\Newbb\Utility::cleanCache() targeting XoopsModules\Newbb\Utility::cleanCache() seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||
306 | //$cacheHelper->delete('permission'); |
||||
307 | require_once __DIR__ . '/admin_footer.php'; |
||||
308 | break; |
||||
309 | } |
||||
310 |
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. Please note the @ignore annotation hint above.