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 | * You may not change or alter any portion of this comment or credits |
||||||
4 | * of supporting developers from this source code or any supporting source code |
||||||
5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
6 | * |
||||||
7 | * PHP version 5 |
||||||
8 | * |
||||||
9 | * @category Module |
||||||
10 | * @author XOOPS Development Team |
||||||
11 | * @copyright XOOPS Project |
||||||
12 | * @link https://xoops.org |
||||||
13 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||||||
14 | */ |
||||||
15 | |||||||
16 | use Xmf\Module\Admin; |
||||||
17 | use Xmf\Request; |
||||||
18 | use XoopsModules\Statistics\{ |
||||||
19 | Helper |
||||||
20 | }; |
||||||
21 | /** @var Admin $adminObject */ |
||||||
22 | /** @var Helper $helper */ |
||||||
23 | |||||||
24 | require __DIR__ . '/admin_header.php'; |
||||||
25 | |||||||
26 | $moduleDirName = basename(dirname(__DIR__)); |
||||||
27 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName |
||||||
28 | |||||||
29 | $helper->loadLanguage('blocksadmin'); |
||||||
30 | |||||||
31 | if (!is_object($GLOBALS['xoopsUser']) || !is_object($xoopsModule) |
||||||
32 | || !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { |
||||||
33 | exit(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403')); |
||||||
34 | } |
||||||
35 | if ($GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { |
||||||
36 | require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; |
||||||
37 | $op = 'list'; |
||||||
38 | if (isset($_POST)) { |
||||||
39 | foreach ($_POST as $k => $v) { |
||||||
40 | ${$k} = $v; |
||||||
41 | } |
||||||
42 | } |
||||||
43 | /* |
||||||
44 | if (Request::hasVar('op', 'GET')) { |
||||||
45 | if ('edit' === $_GET['op'] || 'delete' === $_GET['op'] || 'delete_ok' === $_GET['op'] || 'clone' === $_GET['op'] |
||||||
46 | || 'edit' === $_GET['op']) { |
||||||
47 | $op = $_GET['op']; |
||||||
48 | $bid = \Xmf\Request::getInt('bid', 0, 'GET'); |
||||||
49 | } |
||||||
50 | */ |
||||||
51 | |||||||
52 | $op = Request::getString('op', $op); |
||||||
53 | if (in_array($op, ['edit', 'delete', 'delete_ok', 'clone'])) { |
||||||
54 | $bid = Request::getInt('bid', 0, 'GET'); |
||||||
55 | } |
||||||
56 | |||||||
57 | function listBlocks() |
||||||
58 | { |
||||||
59 | global $xoopsModule, $pathIcon16; |
||||||
60 | require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||||||
61 | $moduleDirName = basename(dirname(__DIR__)); |
||||||
62 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName |
||||||
63 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
64 | |||||||
65 | $adminObject = Admin::getInstance(); |
||||||
66 | $adminObject->displayNavigation(basename(__FILE__)); |
||||||
67 | |||||||
68 | xoops_loadLanguage('admin', 'system'); |
||||||
69 | xoops_loadLanguage('admin/blocksadmin', 'system'); |
||||||
70 | xoops_loadLanguage('admin/groups', 'system'); |
||||||
71 | |||||||
72 | /** @var \XoopsModuleHandler $moduleHandler */ |
||||||
73 | $moduleHandler = xoops_getHandler('module'); |
||||||
74 | /** @var \XoopsMemberHandler $memberHandler */ |
||||||
75 | $memberHandler = xoops_getHandler('member'); |
||||||
76 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||||||
77 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||||
78 | $groups = $memberHandler->getGroups(); |
||||||
79 | $criteria = new \CriteriaCompo(new \Criteria('hasmain', 1)); |
||||||
80 | $criteria->add(new \Criteria('isactive', 1)); |
||||||
81 | $moduleList = $moduleHandler->getList($criteria); |
||||||
82 | $moduleList[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE; |
||||||
83 | $moduleList[0] = _AM_SYSTEM_BLOCKS_ALLPAGES; |
||||||
84 | ksort($moduleList); |
||||||
85 | echo " |
||||||
86 | <h4 style='text-align:left;'>" . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</h4>'; |
||||||
87 | echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>"; |
||||||
88 | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
||||||
89 | echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'> |
||||||
90 | <tr valign='middle'><th align='center'>" |
||||||
91 | . constant('CO_' . $moduleDirNameUpper . '_' . 'TITLE') |
||||||
92 | . "</th><th align='center' nowrap='nowrap'>" |
||||||
93 | . constant('CO_' . $moduleDirNameUpper . '_' . 'SIDE') |
||||||
94 | . '<br>' |
||||||
95 | . _LEFT |
||||||
96 | . '-' |
||||||
97 | . _CENTER |
||||||
98 | . '-' |
||||||
99 | . _RIGHT |
||||||
100 | . "</th><th align='center'>" |
||||||
101 | . constant('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT') |
||||||
102 | . "</th><th align='center'>" |
||||||
103 | . constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE') |
||||||
104 | . "</th><th align='center'>" |
||||||
105 | . _AM_SYSTEM_BLOCKS_VISIBLEIN |
||||||
106 | . "</th><th align='center'>" |
||||||
107 | . _AM_SYSTEM_ADGS |
||||||
108 | . "</th><th align='center'>" |
||||||
109 | . _AM_SYSTEM_BLOCKS_BCACHETIME |
||||||
110 | . "</th><th align='center'>" |
||||||
111 | . constant('CO_' . $moduleDirNameUpper . '_' . 'ACTION') |
||||||
112 | . '</th></tr> |
||||||
113 | '; |
||||||
114 | $blockArray = \XoopsBlock::getByModule($xoopsModule->mid()); |
||||||
0 ignored issues
–
show
|
|||||||
115 | $blockCount = count($blockArray); |
||||||
0 ignored issues
–
show
|
|||||||
116 | $class = 'even'; |
||||||
117 | $cachetimes = [ |
||||||
118 | '0' => _NOCACHE, |
||||||
119 | '30' => sprintf(_SECONDS, 30), |
||||||
120 | '60' => _MINUTE, |
||||||
121 | '300' => sprintf(_MINUTES, 5), |
||||||
122 | '1800' => sprintf(_MINUTES, 30), |
||||||
123 | '3600' => _HOUR, |
||||||
124 | '18000' => sprintf(_HOURS, 5), |
||||||
125 | '86400' => _DAY, |
||||||
126 | '259200' => sprintf(_DAYS, 3), |
||||||
127 | '604800' => _WEEK, |
||||||
128 | '2592000' => _MONTH, |
||||||
129 | ]; |
||||||
130 | foreach ($blockArray as $i) { |
||||||
131 | $groupsPerms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid')); |
||||||
132 | $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid'); |
||||||
133 | $result = $db->query($sql); |
||||||
134 | $modules = []; |
||||||
135 | while (false !== ($row = $db->fetchArray($result))) { |
||||||
136 | $modules[] = (int)$row['module_id']; |
||||||
137 | } |
||||||
138 | |||||||
139 | $cachetimeOptions = ''; |
||||||
140 | foreach ($cachetimes as $cachetime => $cachetimeName) { |
||||||
141 | if ($i->getVar('bcachetime') == $cachetime) { |
||||||
142 | $cachetimeOptions .= "<option value='$cachetime' selected='selected'>$cachetimeName</option>\n"; |
||||||
143 | } else { |
||||||
144 | $cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n"; |
||||||
145 | } |
||||||
146 | } |
||||||
147 | |||||||
148 | $sel0 = $sel1 = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = $ssel5 = $ssel6 = $ssel7 = ''; |
||||||
149 | if (1 === $i->getVar('visible')) { |
||||||
150 | $sel1 = ' checked'; |
||||||
151 | } else { |
||||||
152 | $sel0 = ' checked'; |
||||||
153 | } |
||||||
154 | if (XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) { |
||||||
155 | $ssel0 = ' checked'; |
||||||
156 | } elseif (XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) { |
||||||
157 | $ssel1 = ' checked'; |
||||||
158 | } elseif (XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) { |
||||||
159 | $ssel2 = ' checked'; |
||||||
160 | } elseif (XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) { |
||||||
161 | $ssel4 = ' checked'; |
||||||
162 | } elseif (XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) { |
||||||
163 | $ssel3 = ' checked'; |
||||||
164 | } elseif (XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) { |
||||||
165 | $ssel5 = ' checked'; |
||||||
166 | } elseif (XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) { |
||||||
167 | $ssel6 = ' checked'; |
||||||
168 | } elseif (XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) { |
||||||
169 | $ssel7 = ' checked'; |
||||||
170 | } |
||||||
171 | if ('' === $i->getVar('title')) { |
||||||
172 | $title = ' '; |
||||||
173 | } else { |
||||||
174 | $title = $i->getVar('title'); |
||||||
175 | } |
||||||
176 | $name = $i->getVar('name'); |
||||||
0 ignored issues
–
show
|
|||||||
177 | echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" |
||||||
178 | . $i->getVar('bid') |
||||||
179 | . "]' value='" |
||||||
180 | . $title |
||||||
181 | . "'></td><td class='$class' align='center' nowrap='nowrap'> |
||||||
182 | <div align='center' > |
||||||
183 | <input type='radio' name='side[" |
||||||
184 | . $i->getVar('bid') |
||||||
185 | . "]' value='" |
||||||
186 | . XOOPS_CENTERBLOCK_LEFT |
||||||
187 | . "'$ssel2> |
||||||
188 | <input type='radio' name='side[" |
||||||
189 | . $i->getVar('bid') |
||||||
190 | . "]' value='" |
||||||
191 | . XOOPS_CENTERBLOCK_CENTER |
||||||
192 | . "'$ssel3> |
||||||
193 | <input type='radio' name='side[" |
||||||
194 | . $i->getVar('bid') |
||||||
195 | . "]' value='" |
||||||
196 | . XOOPS_CENTERBLOCK_RIGHT |
||||||
197 | . "'$ssel4> |
||||||
198 | </div> |
||||||
199 | <div> |
||||||
200 | <span style='float:right;'><input type='radio' name='side[" |
||||||
201 | . $i->getVar('bid') |
||||||
202 | . "]' value='" |
||||||
203 | . XOOPS_SIDEBLOCK_RIGHT |
||||||
204 | . "'$ssel1></span> |
||||||
205 | <div align='left'><input type='radio' name='side[" |
||||||
206 | . $i->getVar('bid') |
||||||
207 | . "]' value='" |
||||||
208 | . XOOPS_SIDEBLOCK_LEFT |
||||||
209 | . "'$ssel0></div> |
||||||
210 | </div> |
||||||
211 | <div align='center'> |
||||||
212 | <input type='radio' name='side[" |
||||||
213 | . $i->getVar('bid') |
||||||
214 | . "]' value='" |
||||||
215 | . XOOPS_CENTERBLOCK_BOTTOMLEFT |
||||||
216 | . "'$ssel5> |
||||||
217 | <input type='radio' name='side[" |
||||||
218 | . $i->getVar('bid') |
||||||
219 | . "]' value='" |
||||||
220 | . XOOPS_CENTERBLOCK_BOTTOM |
||||||
221 | . "'$ssel7> |
||||||
222 | <input type='radio' name='side[" |
||||||
223 | . $i->getVar('bid') |
||||||
224 | . "]' value='" |
||||||
225 | . XOOPS_CENTERBLOCK_BOTTOMRIGHT |
||||||
226 | . "'$ssel6> |
||||||
227 | </div> |
||||||
228 | </td><td class='$class' align='center'><input type='text' name='weight[" |
||||||
229 | . $i->getVar('bid') |
||||||
230 | . "]' value='" |
||||||
231 | . $i->getVar('weight') |
||||||
232 | . "' size='5' maxlength='5'></td><td class='$class' align='center' nowrap><input type='radio' name='visible[" |
||||||
233 | . $i->getVar('bid') |
||||||
234 | . "]' value='1'$sel1>" |
||||||
235 | . _YES |
||||||
236 | . " <input type='radio' name='visible[" |
||||||
237 | . $i->getVar('bid') |
||||||
238 | . "]' value='0'$sel0>" |
||||||
239 | . _NO |
||||||
240 | . '</td>'; |
||||||
241 | |||||||
242 | echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>"; |
||||||
243 | foreach ($moduleList as $k => $v) { |
||||||
244 | echo "<option value='$k'" . (in_array($k, $modules) ? 'selected' : '') . ">$v</option>"; |
||||||
245 | } |
||||||
246 | echo '</select></td>'; |
||||||
247 | |||||||
248 | echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>"; |
||||||
249 | foreach ($groups as $grp) { |
||||||
250 | echo "<option value='" . $grp->getVar('groupid') . "' " . (in_array($grp->getVar('groupid'), $groupsPerms) ? 'selected' : '') . '>' . $grp->getVar('name') . '</option>'; |
||||||
251 | } |
||||||
252 | echo '</select></td>'; |
||||||
253 | |||||||
254 | // Cache lifetime |
||||||
255 | echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select> |
||||||
256 | </td>'; |
||||||
257 | |||||||
258 | // Actions |
||||||
259 | |||||||
260 | echo "<td class='$class' align='center'><a href='blocksadmin.php?op=edit&bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'> |
||||||
261 | </a> <a href='blocksadmin.php?op=clone&bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'> |
||||||
262 | </a>"; |
||||||
263 | if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) { |
||||||
264 | echo " <a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&op=delete&bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'> |
||||||
265 | </a>"; |
||||||
266 | } |
||||||
267 | echo " |
||||||
268 | <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'> |
||||||
269 | <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'> |
||||||
270 | <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'> |
||||||
271 | <input type='hidden' name='oldvisible[" . $i->getVar('bid') . "]' value='" . $i->getVar('visible') . "'> |
||||||
272 | <input type='hidden' name='oldgroups[" . $i->getVar('groups') . "]' value='" . $i->getVar('groups') . "'> |
||||||
273 | <input type='hidden' name='oldbcachetime[" . $i->getVar('bid') . "]' value='" . $i->getVar('bcachetime') . "'> |
||||||
274 | <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'> |
||||||
275 | </td></tr> |
||||||
276 | "; |
||||||
277 | $class = ('even' === $class) ? 'odd' : 'even'; |
||||||
278 | } |
||||||
279 | echo "<tr><td class='foot' align='center' colspan='8'> |
||||||
280 | <input type='hidden' name='op' value='order'> |
||||||
281 | " . $GLOBALS['xoopsSecurity']->getTokenHTML() . " |
||||||
282 | <input type='submit' name='submit' value='" . _SUBMIT . "'> |
||||||
283 | </td></tr></table> |
||||||
284 | </form> |
||||||
285 | <br><br>"; |
||||||
286 | } |
||||||
287 | |||||||
288 | /** |
||||||
289 | * @param int $bid |
||||||
290 | */ |
||||||
291 | function cloneBlock($bid) |
||||||
292 | { |
||||||
293 | require_once __DIR__ . '/admin_header.php'; |
||||||
294 | |||||||
295 | xoops_cp_header(); |
||||||
296 | |||||||
297 | $adminObject = Admin::getInstance(); |
||||||
298 | $adminObject->displayNavigation(basename(__FILE__)); |
||||||
299 | $moduleDirName = basename(dirname(__DIR__)); |
||||||
300 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName |
||||||
301 | xoops_loadLanguage('admin', 'system'); |
||||||
302 | xoops_loadLanguage('admin/blocksadmin', 'system'); |
||||||
303 | xoops_loadLanguage('admin/groups', 'system'); |
||||||
304 | |||||||
305 | // mpu_adm_menu(); |
||||||
306 | $myblock = new \XoopsBlock($bid); |
||||||
307 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
308 | $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; |
||||||
309 | $result = $db->query($sql); |
||||||
310 | $modules = []; |
||||||
311 | while (false !== ($row = $db->fetchArray($result))) { |
||||||
312 | $modules[] = (int)$row['module_id']; |
||||||
313 | } |
||||||
314 | $isCustom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); |
||||||
315 | $block = [ |
||||||
0 ignored issues
–
show
|
|||||||
316 | 'title' => $myblock->getVar('title') . ' Clone', |
||||||
317 | 'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'), |
||||||
318 | 'name' => $myblock->getVar('name'), |
||||||
319 | 'side' => $myblock->getVar('side'), |
||||||
320 | 'weight' => $myblock->getVar('weight'), |
||||||
321 | 'visible' => $myblock->getVar('visible'), |
||||||
322 | 'content' => $myblock->getVar('content', 'N'), |
||||||
323 | 'modules' => $modules, |
||||||
324 | 'is_custom' => $isCustom, |
||||||
325 | 'ctype' => $myblock->getVar('c_type'), |
||||||
326 | 'bcachetime' => $myblock->getVar('bcachetime'), |
||||||
327 | 'op' => 'clone_ok', |
||||||
328 | 'bid' => $myblock->getVar('bid'), |
||||||
329 | 'edit_form' => $myblock->getOptions(), |
||||||
330 | 'template' => $myblock->getVar('template'), |
||||||
331 | 'options' => $myblock->getVar('options'), |
||||||
332 | ]; |
||||||
333 | echo '<a href="blocksadmin.php">' . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>'; |
||||||
334 | require_once __DIR__ . '/blockform.php'; |
||||||
335 | /** @var XoopsThemeForm $form */ |
||||||
336 | $form->display(); |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
337 | // xoops_cp_footer(); |
||||||
338 | require_once __DIR__ . '/admin_footer.php'; |
||||||
339 | exit(); |
||||||
0 ignored issues
–
show
|
|||||||
340 | } |
||||||
341 | |||||||
342 | /** |
||||||
343 | * @param int $bid |
||||||
344 | * @param string $bside |
||||||
345 | * @param int $bweight |
||||||
346 | * @param bool $bvisible |
||||||
347 | * @param int $bcachetime |
||||||
348 | * @param array $bmodule |
||||||
349 | * @param null|array|string $options |
||||||
350 | */ |
||||||
351 | function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options = null) |
||||||
352 | { |
||||||
353 | xoops_loadLanguage('admin', 'system'); |
||||||
354 | xoops_loadLanguage('admin/blocksadmin', 'system'); |
||||||
355 | xoops_loadLanguage('admin/groups', 'system'); |
||||||
356 | |||||||
357 | $block = new \XoopsBlock($bid); |
||||||
358 | $clone = $block->xoopsClone(); |
||||||
359 | if (empty($bmodule)) { |
||||||
360 | xoops_cp_header(); |
||||||
361 | xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); |
||||||
362 | xoops_cp_footer(); |
||||||
363 | exit(); |
||||||
0 ignored issues
–
show
|
|||||||
364 | } |
||||||
365 | $clone->setVar('side', $bside); |
||||||
366 | $clone->setVar('weight', $bweight); |
||||||
367 | $clone->setVar('visible', $bvisible); |
||||||
368 | //$clone->setVar('content', $_POST['bcontent']); |
||||||
369 | $clone->setVar('title', Request::getString('btitle', '', 'POST')); |
||||||
370 | $clone->setVar('bcachetime', $bcachetime); |
||||||
371 | if ($options && is_array($options)) { |
||||||
372 | $options = implode('|', $options); |
||||||
373 | $clone->setVar('options', $options); |
||||||
374 | } |
||||||
375 | $clone->setVar('bid', 0); |
||||||
376 | if ('C' === $block->getVar('block_type') || 'E' === $block->getVar('block_type')) { |
||||||
377 | $clone->setVar('block_type', 'E'); |
||||||
378 | } else { |
||||||
379 | $clone->setVar('block_type', 'D'); |
||||||
380 | } |
||||||
381 | $newid = $clone->store(); |
||||||
382 | if (!$newid) { |
||||||
383 | xoops_cp_header(); |
||||||
384 | $clone->getHtmlErrors(); |
||||||
385 | xoops_cp_footer(); |
||||||
386 | exit(); |
||||||
0 ignored issues
–
show
|
|||||||
387 | } |
||||||
388 | if ('' !== $clone->getVar('template')) { |
||||||
389 | /** @var \XoopsTplfileHandler $tplfileHandler */ |
||||||
390 | $tplfileHandler = xoops_getHandler('tplfile'); |
||||||
391 | $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
||||||
392 | if (count($btemplate) > 0) { |
||||||
393 | $tplclone = $btemplate[0]->xoopsClone(); |
||||||
394 | $tplclone->setVar('tpl_id', 0); |
||||||
395 | $tplclone->setVar('tpl_refid', $newid); |
||||||
396 | $tplfileHandler->insert($tplclone); |
||||||
397 | } |
||||||
398 | } |
||||||
399 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
400 | foreach ($bmodule as $bmid) { |
||||||
401 | $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')'; |
||||||
402 | $db->query($sql); |
||||||
403 | } |
||||||
404 | $groups = &$GLOBALS['xoopsUser']->getGroups(); |
||||||
405 | $count = count($groups); |
||||||
406 | for ($i = 0; $i < $count; ++$i) { |
||||||
407 | $sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $groups[$i] . ', ' . $newid . ", 1, 'block_read')"; |
||||||
408 | $db->query($sql); |
||||||
409 | } |
||||||
410 | redirect_header('blocksadmin.php?op=listar', 1, _AM_DBUPDATED); |
||||||
411 | } |
||||||
412 | |||||||
413 | /** |
||||||
414 | * @param int $bid |
||||||
415 | * @param string $title |
||||||
416 | * @param int $weight |
||||||
417 | * @param bool $visible |
||||||
418 | * @param string $side |
||||||
419 | * @param int $bcachetime |
||||||
420 | * @param int $bmodule |
||||||
421 | */ |
||||||
422 | function setOrder($bid, $title, $weight, $visible, $side, $bcachetime, $bmodule) |
||||||
0 ignored issues
–
show
The parameter
$bmodule is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
423 | { |
||||||
424 | $myblock = new \XoopsBlock($bid); |
||||||
425 | $myblock->setVar('title', $title); |
||||||
426 | $myblock->setVar('weight', $weight); |
||||||
427 | $myblock->setVar('visible', $visible); |
||||||
428 | $myblock->setVar('side', $side); |
||||||
429 | $myblock->setVar('bcachetime', $bcachetime); |
||||||
430 | $myblock->store(); |
||||||
0 ignored issues
–
show
The method
store() does not exist on XoopsBlock .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
431 | } |
||||||
432 | |||||||
433 | /** |
||||||
434 | * @param int $bid |
||||||
435 | */ |
||||||
436 | function editBlock($bid) |
||||||
437 | { |
||||||
438 | require_once __DIR__ . '/admin_header.php'; |
||||||
439 | xoops_cp_header(); |
||||||
440 | $adminObject = Admin::getInstance(); |
||||||
441 | $adminObject->displayNavigation(basename(__FILE__)); |
||||||
442 | $moduleDirName = basename(dirname(__DIR__)); |
||||||
443 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName |
||||||
444 | xoops_loadLanguage('admin', 'system'); |
||||||
445 | xoops_loadLanguage('admin/blocksadmin', 'system'); |
||||||
446 | xoops_loadLanguage('admin/groups', 'system'); |
||||||
447 | // mpu_adm_menu(); |
||||||
448 | $myblock = new \XoopsBlock($bid); |
||||||
449 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
450 | $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; |
||||||
451 | $result = $db->query($sql); |
||||||
452 | $modules = []; |
||||||
453 | while (false !== ($row = $db->fetchArray($result))) { |
||||||
454 | $modules[] = (int)$row['module_id']; |
||||||
455 | } |
||||||
456 | $isCustom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); |
||||||
457 | $block = [ |
||||||
0 ignored issues
–
show
|
|||||||
458 | 'title' => $myblock->getVar('title'), |
||||||
459 | 'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK'), |
||||||
460 | // 'name' => $myblock->getVar('name'), |
||||||
461 | 'side' => $myblock->getVar('side'), |
||||||
462 | 'weight' => $myblock->getVar('weight'), |
||||||
463 | 'visible' => $myblock->getVar('visible'), |
||||||
464 | 'content' => $myblock->getVar('content', 'N'), |
||||||
465 | 'modules' => $modules, |
||||||
466 | 'is_custom' => $isCustom, |
||||||
467 | 'ctype' => $myblock->getVar('c_type'), |
||||||
468 | 'bcachetime' => $myblock->getVar('bcachetime'), |
||||||
469 | 'op' => 'edit_ok', |
||||||
470 | 'bid' => $myblock->getVar('bid'), |
||||||
471 | 'edit_form' => $myblock->getOptions(), |
||||||
472 | 'template' => $myblock->getVar('template'), |
||||||
473 | 'options' => $myblock->getVar('options'), |
||||||
474 | ]; |
||||||
475 | echo '<a href="blocksadmin.php">' . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>'; |
||||||
476 | require_once __DIR__ . '/blockform.php'; |
||||||
477 | /** @var XoopsThemeForm $form */ |
||||||
478 | $form->display(); |
||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
479 | // xoops_cp_footer(); |
||||||
480 | require_once __DIR__ . '/admin_footer.php'; |
||||||
481 | exit(); |
||||||
0 ignored issues
–
show
|
|||||||
482 | } |
||||||
483 | |||||||
484 | /** |
||||||
485 | * @param int $bid |
||||||
486 | * @param string $btitle |
||||||
487 | * @param string $bside |
||||||
488 | * @param int $bweight |
||||||
489 | * @param bool $bvisible |
||||||
490 | * @param int $bcachetime |
||||||
491 | * @param array $bmodule |
||||||
492 | * @param null|array|string $options |
||||||
493 | * @param null|array $groups |
||||||
494 | */ |
||||||
495 | function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups) |
||||||
496 | { |
||||||
497 | $myblock = new XoopsBlock($bid); |
||||||
498 | $myblock->setVar('title', $btitle); |
||||||
499 | $myblock->setVar('weight', $bweight); |
||||||
500 | $myblock->setVar('visible', $bvisible); |
||||||
501 | $myblock->setVar('side', $bside); |
||||||
502 | $myblock->setVar('bcachetime', $bcachetime); |
||||||
503 | $helper = Helper::getInstance(); |
||||||
504 | $helper->loadLanguage('common'); |
||||||
505 | //update block options |
||||||
506 | if (isset($options)) { |
||||||
507 | $optionsCount = count($options); |
||||||
0 ignored issues
–
show
It seems like
$options can also be of type string ; however, parameter $var of count() does only seem to accept Countable|array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
508 | if ($optionsCount > 0) { |
||||||
509 | //Convert array values to comma-separated |
||||||
510 | for ($i = 0; $i < $optionsCount; ++$i) { |
||||||
511 | if (is_array($options[$i])) { |
||||||
512 | $options[$i] = implode(',', $options[$i]); |
||||||
513 | } |
||||||
514 | } |
||||||
515 | $options = implode('|', $options); |
||||||
0 ignored issues
–
show
It seems like
$options can also be of type string ; however, parameter $pieces of implode() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
516 | $myblock->setVar('options', $options); |
||||||
517 | } |
||||||
518 | } |
||||||
519 | $myblock->store(); |
||||||
520 | |||||||
521 | global $xoopsDB; |
||||||
522 | |||||||
523 | $moduleDirName = basename(dirname(__DIR__)); |
||||||
524 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName |
||||||
525 | |||||||
526 | if (!empty($bmodule) && count($bmodule) > 0) { |
||||||
527 | $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $xoopsDB->prefix('block_module_link'), $bid); |
||||||
528 | $xoopsDB->query($sql); |
||||||
529 | if (in_array(0, $bmodule)) { |
||||||
530 | $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $xoopsDB->prefix('block_module_link'), $bid, 0); |
||||||
531 | $xoopsDB->query($sql); |
||||||
532 | } else { |
||||||
533 | foreach ($bmodule as $bmid) { |
||||||
534 | $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $xoopsDB->prefix('block_module_link'), $bid, (int)$bmid); |
||||||
535 | $xoopsDB->query($sql); |
||||||
536 | } |
||||||
537 | } |
||||||
538 | } |
||||||
539 | $sql = sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $xoopsDB->prefix('group_permission'), $bid); |
||||||
540 | $xoopsDB->query($sql); |
||||||
541 | if (!empty($groups)) { |
||||||
542 | foreach ($groups as $grp) { |
||||||
543 | $sql = sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $xoopsDB->prefix('group_permission'), $grp, $bid); |
||||||
544 | $xoopsDB->query($sql); |
||||||
545 | } |
||||||
546 | } |
||||||
547 | redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); |
||||||
548 | } |
||||||
549 | |||||||
550 | if ('list' === $op) { |
||||||
551 | xoops_cp_header(); |
||||||
552 | // mpu_adm_menu(); |
||||||
553 | listBlocks(); |
||||||
554 | require_once __DIR__ . '/admin_footer.php'; |
||||||
555 | exit(); |
||||||
556 | } |
||||||
557 | |||||||
558 | if ('order' === $op) { |
||||||
559 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
560 | redirect_header($_SERVER['PHP_SELF'], 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
||||||
561 | } |
||||||
562 | foreach (array_keys($bid) as $i) { |
||||||
563 | if ($oldtitle[$i] != $title[$i] || $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i] |
||||||
564 | || $oldside[$i] != $side[$i] |
||||||
565 | || $oldbcachetime[$i] != $bcachetime[$i]) { |
||||||
566 | setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]); |
||||||
567 | } |
||||||
568 | if (!empty($bmodule[$i]) && count($bmodule[$i]) > 0) { |
||||||
569 | $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $xoopsDB->prefix('block_module_link'), $bid[$i]); |
||||||
570 | $xoopsDB->query($sql); |
||||||
571 | if (in_array(0, $bmodule[$i])) { |
||||||
572 | $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $xoopsDB->prefix('block_module_link'), $bid[$i], 0); |
||||||
573 | $xoopsDB->query($sql); |
||||||
574 | } else { |
||||||
575 | foreach ($bmodule[$i] as $bmid) { |
||||||
576 | $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $xoopsDB->prefix('block_module_link'), $bid[$i], (int)$bmid); |
||||||
577 | $xoopsDB->query($sql); |
||||||
578 | } |
||||||
579 | } |
||||||
580 | } |
||||||
581 | $sql = sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $xoopsDB->prefix('group_permission'), $bid[$i]); |
||||||
582 | $xoopsDB->query($sql); |
||||||
583 | if (!empty($groups[$i])) { |
||||||
584 | foreach ($groups[$i] as $grp) { |
||||||
585 | $sql = sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $xoopsDB->prefix('group_permission'), $grp, $bid[$i]); |
||||||
586 | $xoopsDB->query($sql); |
||||||
587 | } |
||||||
588 | } |
||||||
589 | } |
||||||
590 | redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); |
||||||
591 | } |
||||||
592 | if ('clone' === $op) { |
||||||
593 | cloneBlock($bid); |
||||||
594 | } |
||||||
595 | |||||||
596 | if ('edit' === $op) { |
||||||
597 | editBlock($bid); |
||||||
598 | } |
||||||
599 | |||||||
600 | if ('edit_ok' === $op) { |
||||||
601 | updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups); |
||||||
602 | } |
||||||
603 | |||||||
604 | if ('clone_ok' === $op) { |
||||||
605 | isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options); |
||||||
606 | } |
||||||
607 | } else { |
||||||
608 | echo constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'); |
||||||
609 | } |
||||||
610 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.