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