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 | * This program is distributed in the hope that it will be useful, |
||||||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
10 | */ |
||||||
11 | |||||||
12 | /** |
||||||
13 | * @copyright XOOPS Project https://xoops.org/ |
||||||
14 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||||||
15 | * @package |
||||||
16 | * @since |
||||||
17 | * @author XOOPS Development Team, Kazumi Ono (AKA onokazu) |
||||||
18 | */ |
||||||
19 | |||||||
20 | use Xmf\Request; |
||||||
21 | |||||||
22 | if (!is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid())) { |
||||||
23 | exit('Access Denied'); |
||||||
24 | } |
||||||
25 | require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; |
||||||
26 | require XOOPS_ROOT_PATH . '/modules/system/admin/blocksadmin/blocksadmin.php'; |
||||||
27 | |||||||
28 | $op = Request::getCmd('op', 'list', 'POST'); |
||||||
29 | $bid = Request::getInt('bid', 0, 'POST'); |
||||||
30 | |||||||
31 | $opArray = ['edit', 'delete', 'delete_ok', 'clone']; |
||||||
32 | $temp = $op = Request::getString('op', '', 'GET'); |
||||||
33 | if (isset($temp)) { |
||||||
34 | if (in_array($temp, $opArray, true)) { |
||||||
35 | $op = $temp; |
||||||
36 | $bid = Request::getInt('bid', 0, 'GET'); |
||||||
37 | } |
||||||
38 | } |
||||||
39 | |||||||
40 | //if (\Xmf\Request::hasVar('previewblock', 'POST')) { |
||||||
41 | if (Request::hasVar('previewblock', 'POST')) { |
||||||
42 | //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||||||
43 | // exit('Invalid Referer'); |
||||||
44 | //} |
||||||
45 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
46 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||||||
47 | } |
||||||
48 | |||||||
49 | if (empty($bid)) { |
||||||
50 | exit('Invalid bid.'); |
||||||
51 | } |
||||||
52 | |||||||
53 | $bside = Request::getInt('bside', 0, 'POST'); |
||||||
54 | $bweight = Request::getInt('bweight', 0, 'POST'); |
||||||
55 | $bvisible = Request::getInt('bvisible', 0, 'POST'); |
||||||
56 | $bmodule = Request::getArray('bmodule', [], 'POST'); |
||||||
57 | $btitle = Request::getString('btitle', '', 'POST'); |
||||||
58 | $bcontent = Request::getString('bcontent', '', 'POST'); |
||||||
59 | $bctype = Request::getString('bctype', '', 'POST'); |
||||||
60 | $bcachetime = Request::getInt('bcachetime', 0, 'POST'); |
||||||
61 | |||||||
62 | xoops_cp_header(); |
||||||
63 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||||||
64 | $xoopsTpl = new \XoopsTpl(); |
||||||
65 | $xoopsTpl->caching = 0; |
||||||
66 | $block['bid'] = $bid; |
||||||
67 | |||||||
68 | if ('clone_ok' === $op) { |
||||||
69 | $block['form_title'] = _AM_CLONEBLOCK; |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
70 | $block['submit_button'] = _CLONE; |
||||||
71 | $myblock = new \XoopsBlock(); |
||||||
72 | $myblock->setVar('block_type', 'C'); |
||||||
73 | } else { |
||||||
74 | $op = 'update'; |
||||||
75 | $block['form_title'] = _AM_EDITBLOCK; |
||||||
0 ignored issues
–
show
|
|||||||
76 | $block['submit_button'] = _SUBMIT; |
||||||
77 | $myblock = new \XoopsBlock($bid); |
||||||
78 | $block['name'] = $myblock->getVar('name'); |
||||||
79 | } |
||||||
80 | |||||||
81 | $myts = \MyTextSanitizer::getInstance(); |
||||||
82 | $myblock->setVar('title', $myts->stripSlashesGPC($btitle)); |
||||||
83 | $myblock->setVar('content', $myts->stripSlashesGPC($bcontent)); |
||||||
84 | // $dummyhtml = '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'"><meta http-equiv="content-language" content="'._LANGCODE.'"><title>'.$xoopsConfig['sitename'].'</title><link rel="stylesheet" type="text/css" media="all" href="'.getcss($xoopsConfig['theme_set']).'"></head><body><table><tr><th>'.$myblock->getVar('title').'</th></tr><tr><td>'.$myblock->getContent('S', $bctype).'</td></tr></table></body></html>'; |
||||||
85 | |||||||
86 | /* $dummyfile = '_dummyfile_'.time().'.html'; |
||||||
87 | $fp = fopen(XOOPS_CACHE_PATH.'/'.$dummyfile, 'w'); |
||||||
88 | fwrite($fp, $dummyhtml); |
||||||
89 | fclose($fp);*/ |
||||||
90 | $block['edit_form'] = false; |
||||||
91 | $block['template'] = ''; |
||||||
92 | $block['op'] = $op; |
||||||
93 | $block['side'] = $bside; |
||||||
94 | $block['weight'] = $bweight; |
||||||
95 | $block['visible'] = $bvisible; |
||||||
96 | $block['title'] = $myblock->getVar('title', 'E'); |
||||||
97 | $block['content'] = $myblock->getVar('content', 'n'); |
||||||
98 | $block['modules'] = $bmodule; |
||||||
99 | $block['ctype'] = isset($bctype) ? $bctype : $myblock->getVar('c_type'); |
||||||
100 | $block['is_custom'] = true; |
||||||
101 | $block['cachetime'] = $bcachetime; |
||||||
102 | echo '<a href="myblocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . $block['form_title'] . '<br><br>'; |
||||||
0 ignored issues
–
show
|
|||||||
103 | require dirname(__DIR__) . '/admin/myblockform.php'; //GIJ |
||||||
104 | //echo '<a href="admin.php?fct=blocksadmin">'. _AM_BADMIN .'</a> <span style="font-weight:bold;">»»</span> '.$block['form_title'].'<br><br>'; |
||||||
105 | //require XOOPS_ROOT_PATH.'/modules/system/admin/blocksadmin/blockform.php'; |
||||||
106 | // $xoopsGTicket->addTicketXoopsFormElement($form, __LINE__, 1800, 'myblocksadmin'); //GIJ |
||||||
107 | $form->display(); |
||||||
108 | |||||||
109 | $original_level = error_reporting(E_ALL); |
||||||
110 | echo " |
||||||
111 | <table width='100%' class='outer' cellspacing='1'> |
||||||
112 | <tr> |
||||||
113 | <th>" . $myblock->getVar('title') . "</th> |
||||||
114 | </tr> |
||||||
115 | <tr> |
||||||
116 | <td class='odd'>" . $myblock->getContent('S', $bctype) . "</td> |
||||||
117 | </tr> |
||||||
118 | </table>\n"; |
||||||
119 | error_reporting($original_level); |
||||||
120 | |||||||
121 | xoops_cp_footer(); |
||||||
122 | /* echo '<script type="text/javascript"> |
||||||
123 | preview_window = openWithSelfMain("'.XOOPS_URL.'/modules/system/admin.php?fct=blocksadmin&op=previewpopup&file='.$dummyfile.'", "popup", 250, 200); |
||||||
124 | </script>';*/ |
||||||
125 | |||||||
126 | exit(); |
||||||
127 | } |
||||||
128 | |||||||
129 | /* if ($op == 'previewpopup') { |
||||||
130 | if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||||||
131 | exit('Invalid Referer'); |
||||||
132 | } |
||||||
133 | $file = str_replace('..', '', XOOPS_CACHE_PATH.'/'.trim($_GET['file'])); |
||||||
134 | if (file_exists($file)) { |
||||||
135 | require $file; |
||||||
136 | @unlink($file); |
||||||
137 | } |
||||||
138 | exit(); |
||||||
139 | } */ |
||||||
140 | |||||||
141 | /* if ($op == "list") { |
||||||
142 | xoops_cp_header(); |
||||||
143 | list_blocks(); |
||||||
144 | xoops_cp_footer(); |
||||||
145 | exit(); |
||||||
146 | } */ |
||||||
147 | |||||||
148 | if ('order' === $op) { |
||||||
149 | //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||||||
150 | // exit('Invalid Referer'); |
||||||
151 | //} |
||||||
152 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
153 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||||||
154 | } |
||||||
155 | |||||||
156 | $side = Request::getArray('side', [], 'POST'); |
||||||
157 | $visible = Request::getArray('visible', [], 'POST'); |
||||||
158 | |||||||
159 | // if ( !empty($_POST['oldside']) ) { $oldside = $_POST['oldside']; } |
||||||
160 | // if ( !empty($_POST['oldweight']) ) { $oldweight = $_POST['oldweight']; } |
||||||
161 | // if ( !empty($_POST['oldvisible']) ) { $oldvisible = $_POST['oldvisible']; } |
||||||
162 | |||||||
163 | $bid = Request::getArray('bid', [], 'POST'); |
||||||
164 | // GIJ start |
||||||
165 | foreach (array_keys($bid) as $i) { |
||||||
166 | if ($side[$i] < 0) { |
||||||
167 | $visible[$i] = 0; |
||||||
168 | $side[$i] = -1; |
||||||
169 | } else { |
||||||
170 | $visible[$i] = 1; |
||||||
171 | } |
||||||
172 | |||||||
173 | // $bmodule = (isset($_POST['bmodule'][$i]) && is_array($_POST['bmodule'][$i])) ? $_POST['bmodule'][$i] : array(-1); |
||||||
174 | $bmodule = Request::getArray('bmodule', [-1], 'POST'); |
||||||
175 | |||||||
176 | $weight = Request::getInt('weight', 0, 'POST'); |
||||||
177 | $title = Request::getString('title', '', 'POST'); |
||||||
178 | $bcachetime = Request::getInt('bcachetime', 0, 'POST'); |
||||||
179 | |||||||
180 | myblocksadmin_update_block($i, $side[$i], $weight[$i], $visible[$i], $title[$i], null, null, $bcachetime[$i], $bmodule, []); |
||||||
181 | |||||||
182 | // if ( $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i] || $oldside[$i] != $side[$i] ) |
||||||
183 | // order_block($bid[$i], $weight[$i], $visible[$i], $side[$i]); |
||||||
184 | } |
||||||
185 | $query4redirect = '?dirname=' . urlencode(strip_tags(mb_substr(Request::getString('query4redirect', '', 'POST'), 9))); |
||||||
186 | redirect_header("myblocksadmin.php$query4redirect", 1, _AM_DBUPDATED); |
||||||
187 | // GIJ end |
||||||
188 | } |
||||||
189 | |||||||
190 | if ('order2' === $op) { |
||||||
191 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
192 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||||||
193 | } |
||||||
194 | |||||||
195 | $addblock = Request::getArray('addblock', null, 'POST'); |
||||||
196 | if (isset($addblock) && is_array($addblock)) { |
||||||
197 | // addblock |
||||||
198 | foreach ($addblock as $bid => $val) { |
||||||
199 | myblocksadmin_update_blockinstance(0, 0, 0, 0, '', null, null, 0, [], [], (int)$bid); |
||||||
200 | } |
||||||
201 | } else { |
||||||
202 | // else change order |
||||||
203 | $side = Request::getArray('side', [], 'POST'); |
||||||
204 | $visible = Request::getArray('visible', [], 'POST'); |
||||||
205 | $id = Request::getArray('id', [], 'POST'); |
||||||
206 | |||||||
207 | foreach (array_keys($id) as $i) { |
||||||
208 | // separate side and visible |
||||||
209 | if ($side[$i] < 0) { |
||||||
210 | $visible[$i] = 0; |
||||||
211 | $side[$i] = -1; // for not to destroy the original position |
||||||
212 | } else { |
||||||
213 | $visible[$i] = 1; |
||||||
214 | } |
||||||
215 | |||||||
216 | // $bmodule = (isset($_POST['bmodule'][$i]) && is_array($_POST['bmodule'][$i])) ? $_POST['bmodule'][$i] : array(-1); |
||||||
217 | |||||||
218 | $bmodule = Request::getArray('bmodule', [-1], 'POST'); |
||||||
219 | |||||||
220 | $weight = Request::getInt('weight', 0, 'POST'); |
||||||
221 | $title = Request::getString('title', '', 'POST'); |
||||||
222 | $bcachetime = Request::getInt('bcachetime', 0, 'POST'); |
||||||
223 | |||||||
224 | // myblocksadmin_update_blockinstance($i, $side[$i], $_POST['weight'][$i], $visible[$i], $_POST['title'][$i], null, null, $_POST['bcachetime'][$i], $bmodule, array()); |
||||||
225 | myblocksadmin_update_blockinstance($i, $side[$i], $weight[$i], $visible[$i], $title[$i], null, null, $bcachetime[$i], $bmodule, []); |
||||||
226 | } |
||||||
227 | } |
||||||
228 | |||||||
229 | $query4redirect = '?dirname=' . urlencode(strip_tags(mb_substr(Request::getString('query4redirect', '', 'POST'), 9))); |
||||||
230 | redirect_header("myblocksadmin.php$query4redirect", 1, _MD_AM_DBUPDATED); |
||||||
0 ignored issues
–
show
|
|||||||
231 | } |
||||||
232 | |||||||
233 | /* if ($op == 'save') { |
||||||
234 | if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||||||
235 | exit('Invalid Referer'); |
||||||
236 | } |
||||||
237 | if ( ! $GLOBALS['xoopsSecurity']->check() ) { |
||||||
238 | redirect_header(XOOPS_URL.'/',3,$GLOBALS['xoopsSecurity']->getErrors()); |
||||||
239 | } |
||||||
240 | if ( !empty($_POST['bside']) ) { $bside = (int)($_POST['bside']); } else { $bside = 0; } |
||||||
241 | if ( !empty($_POST['bweight']) ) { $bweight = (int)($_POST['bweight']); } else { $bweight = 0; } |
||||||
242 | if ( !empty($_POST['bvisible']) ) { $bvisible = (int)($_POST['bvisible']); } else { $bvisible = 0; } |
||||||
243 | if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = array(); } |
||||||
244 | if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } |
||||||
245 | if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } |
||||||
246 | if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } |
||||||
247 | if ( !empty($_POST['bcachetime']) ) { $bcachetime = (int)($_POST['bcachetime']); } else { $bcachetime = 0; } |
||||||
248 | save_block($bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bmodule, $bcachetime); |
||||||
249 | exit(); |
||||||
250 | } */ |
||||||
251 | |||||||
252 | if ('update' === $op) { |
||||||
253 | //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||||||
254 | // exit('Invalid Referer'); |
||||||
255 | //} |
||||||
256 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
257 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||||||
258 | } |
||||||
259 | /* if ( !empty($_POST['bside']) ) { $bside = (int)($_POST['bside']); } else { $bside = 0; } |
||||||
260 | if ( !empty($_POST['bweight']) ) { $bweight = (int)($_POST['bweight']); } else { $bweight = 0; } |
||||||
261 | if ( !empty($_POST['bvisible']) ) { $bvisible = (int)($_POST['bvisible']); } else { $bvisible = 0; } |
||||||
262 | if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } |
||||||
263 | if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } |
||||||
264 | if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } |
||||||
265 | if ( !empty($_POST['bcachetime']) ) { $bcachetime = (int)($_POST['bcachetime']); } else { $bcachetime = 0; } |
||||||
266 | if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = array(); } |
||||||
267 | if ( !empty($_POST['options']) ) { $options = $_POST['options']; } else { $options = array(); } |
||||||
268 | update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options);*/ |
||||||
269 | |||||||
270 | $bside = Request::getInt('bside', 0, 'POST'); |
||||||
271 | $bweight = Request::getInt('bweight', 0, 'POST'); |
||||||
272 | $bvisible = Request::getInt('bvisible', 0, 'POST'); |
||||||
273 | $btitle = Request::getString('btitle', '', 'POST'); |
||||||
274 | $bcontent = Request::getString('bcontent', '', 'POST'); |
||||||
275 | $bctype = Request::getString('bctype', '', 'POST'); |
||||||
276 | $bcachetime = Request::getInt('bcachetime', 0, 'POST'); |
||||||
277 | // $bmodule = (isset($_POST['bmodule']) && is_array($_POST['bmodule'])) ? $_POST['bmodule'] : array(-1); // GIJ + |
||||||
278 | $bmodule = Request::getArray('bmodule', [-1], 'POST'); |
||||||
279 | $options = Request::getArray('options', [], 'POST'); |
||||||
280 | |||||||
281 | $msg = myblocksadmin_update_block($_POST['bid'], $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options); // GIJ ! |
||||||
282 | redirect_header('myblocksadmin.php', 1, $msg); |
||||||
283 | } |
||||||
284 | |||||||
285 | if ('delete_ok' === $op) { |
||||||
286 | //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||||||
287 | // exit('Invalid Referer'); |
||||||
288 | //} |
||||||
289 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
290 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||||||
291 | } |
||||||
292 | // delete_block_ok($bid); GIJ imported from blocksadmin.php |
||||||
293 | $myblock = new \XoopsBlock($bid); |
||||||
294 | if ('D' !== $myblock->getVar('block_type') && 'C' !== $myblock->getVar('block_type')) { |
||||||
295 | redirect_header('myblocksadmin.php', 4, 'Invalid block'); |
||||||
296 | } |
||||||
297 | $myblock->delete(); |
||||||
0 ignored issues
–
show
The method
delete() 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. ![]() |
|||||||
298 | if (!defined('XOOPS_ORETEKI') && '' !== $myblock->getVar('template')) { |
||||||
299 | $tplfileHandler = xoops_getHandler('tplfile'); |
||||||
300 | $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
||||||
0 ignored issues
–
show
The method
find() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsTplfileHandler or XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
301 | if (count($btemplate) > 0) { |
||||||
302 | $tplman->delete($btemplate[0]); |
||||||
303 | } |
||||||
304 | } |
||||||
305 | redirect_header('myblocksadmin.php', 1, _AM_DBUPDATED); |
||||||
306 | // |
||||||
307 | // end of delete_block_ok() GIJ |
||||||
308 | } |
||||||
309 | |||||||
310 | if ('delete' === $op) { |
||||||
311 | xoops_cp_header(); |
||||||
312 | // delete_block($bid); GIJ imported from blocksadmin.php |
||||||
313 | $myblock = new \XoopsBlock($bid); |
||||||
314 | if ('S' === $myblock->getVar('block_type')) { |
||||||
315 | $message = _AM_SYSTEMCANT; |
||||||
0 ignored issues
–
show
|
|||||||
316 | redirect_header('admin.php?fct=blocksadmin', 4, $message); |
||||||
317 | } elseif ('M' === $myblock->getVar('block_type')) { |
||||||
318 | $message = _AM_MODULECANT; |
||||||
0 ignored issues
–
show
|
|||||||
319 | redirect_header('admin.php?fct=blocksadmin', 4, $message); |
||||||
320 | } else { |
||||||
321 | xoops_confirm([ |
||||||
322 | 'fct' => 'blocksadmin', |
||||||
323 | 'op' => 'delete_ok', |
||||||
324 | 'bid' => $myblock->getVar('bid'), |
||||||
325 | ], 'admin.php', sprintf(_AM_RUSUREDEL, $myblock->getVar('title'))); |
||||||
0 ignored issues
–
show
It seems like
$myblock->getVar('title') can also be of type array and array ; however, parameter $args of sprintf() does only seem to accept string , 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
![]() |
|||||||
326 | } |
||||||
327 | // end of delete_block() GIJ |
||||||
328 | xoops_cp_footer(); |
||||||
329 | exit(); |
||||||
330 | } |
||||||
331 | |||||||
332 | if ('edit' === $op) { |
||||||
333 | xoops_cp_header(); |
||||||
334 | // edit_block($bid); GIJ imported from blocksadmin.php |
||||||
335 | $myblock = new \XoopsBlock($bid); |
||||||
336 | |||||||
337 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
338 | $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; |
||||||
339 | $result = $db->query($sql); |
||||||
340 | $modules = []; |
||||||
341 | while (false !== ($row = $db->fetchArray($result))) { |
||||||
342 | $modules[] = (int)$row['module_id']; |
||||||
343 | } |
||||||
344 | $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); |
||||||
345 | $block = [ |
||||||
346 | 'form_title' => _AM_EDITBLOCK, |
||||||
347 | 'name' => $myblock->getVar('name'), |
||||||
348 | 'side' => $myblock->getVar('side'), |
||||||
349 | 'weight' => $myblock->getVar('weight'), |
||||||
350 | 'visible' => $myblock->getVar('visible'), |
||||||
351 | 'title' => $myblock->getVar('title', 'E'), |
||||||
352 | 'content' => $myblock->getVar('content', 'n'), |
||||||
353 | 'modules' => $modules, |
||||||
354 | 'is_custom' => $is_custom, |
||||||
355 | 'ctype' => $myblock->getVar('c_type'), |
||||||
356 | 'cachetime' => $myblock->getVar('bcachetime'), |
||||||
357 | 'op' => 'update', |
||||||
358 | 'bid' => $myblock->getVar('bid'), |
||||||
359 | 'edit_form' => $myblock->getOptions(), |
||||||
360 | 'template' => $myblock->getVar('template'), |
||||||
361 | 'options' => $myblock->getVar('options'), |
||||||
362 | 'submit_button' => _SUBMIT, |
||||||
363 | ]; |
||||||
364 | |||||||
365 | echo '<a href="myblocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_EDITBLOCK . '<br><br>'; |
||||||
366 | require dirname(__DIR__) . '/admin/myblockform.php'; //GIJ |
||||||
367 | // $xoopsGTicket->addTicketXoopsFormElement($form, __LINE__, 1800, 'myblocksadmin'); //GIJ |
||||||
368 | $form->display(); |
||||||
369 | // end of edit_block() GIJ |
||||||
370 | xoops_cp_footer(); |
||||||
371 | exit(); |
||||||
372 | } |
||||||
373 | |||||||
374 | if ('clone' === $op) { |
||||||
375 | xoops_cp_header(); |
||||||
376 | $myblock = new \XoopsBlock($bid); |
||||||
377 | |||||||
378 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
379 | $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; |
||||||
380 | $result = $db->query($sql); |
||||||
381 | $modules = []; |
||||||
382 | while (false !== ($row = $db->fetchArray($result))) { |
||||||
383 | $modules[] = (int)$row['module_id']; |
||||||
384 | } |
||||||
385 | $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); |
||||||
386 | $block = [ |
||||||
387 | 'form_title' => _AM_CLONEBLOCK, |
||||||
388 | 'name' => $myblock->getVar('name'), |
||||||
389 | 'side' => $myblock->getVar('side'), |
||||||
390 | 'weight' => $myblock->getVar('weight'), |
||||||
391 | 'visible' => $myblock->getVar('visible'), |
||||||
392 | 'content' => $myblock->getVar('content', 'N'), |
||||||
393 | 'title' => $myblock->getVar('title', 'E'), |
||||||
394 | 'modules' => $modules, |
||||||
395 | 'is_custom' => $is_custom, |
||||||
396 | 'ctype' => $myblock->getVar('c_type'), |
||||||
397 | 'cachetime' => $myblock->getVar('bcachetime'), |
||||||
398 | 'op' => 'clone_ok', |
||||||
399 | 'bid' => $myblock->getVar('bid'), |
||||||
400 | 'edit_form' => $myblock->getOptions(), |
||||||
401 | 'template' => $myblock->getVar('template'), |
||||||
402 | 'options' => $myblock->getVar('options'), |
||||||
403 | 'submit_button' => _CLONE, |
||||||
404 | ]; |
||||||
405 | echo '<a href="myblocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_CLONEBLOCK . '<br><br>'; |
||||||
406 | require dirname(__DIR__) . '/admin/myblockform.php'; |
||||||
407 | // $xoopsGTicket->addTicketXoopsFormElement($form, __LINE__, 1800, 'myblocksadmin'); //GIJ |
||||||
408 | $form->display(); |
||||||
409 | xoops_cp_footer(); |
||||||
410 | exit(); |
||||||
411 | } |
||||||
412 | |||||||
413 | if ('clone_ok' === $op) { |
||||||
414 | // Ticket Check |
||||||
415 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
416 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||||||
417 | } |
||||||
418 | |||||||
419 | $block = new \XoopsBlock($bid); |
||||||
420 | |||||||
421 | // block type check |
||||||
422 | $block_type = $block->getVar('block_type'); |
||||||
423 | if ('C' !== $block_type && 'M' !== $block_type && 'D' !== $block_type) { |
||||||
424 | redirect_header('myblocksadmin.php', 4, 'Invalid block'); |
||||||
425 | } |
||||||
426 | |||||||
427 | // if (empty($_POST['options'])) { |
||||||
428 | // $options = array(); |
||||||
429 | // } elseif (is_array($_POST['options'])) { |
||||||
430 | // $options = $_POST['options']; |
||||||
431 | // } else { |
||||||
432 | // $options = explode('|', $_POST['options']); |
||||||
433 | // } |
||||||
434 | |||||||
435 | $options = Request::getArray('options', [], 'POST'); |
||||||
436 | if (!empty($options) && (!is_array($options))) { |
||||||
0 ignored issues
–
show
|
|||||||
437 | $options = explode('|', Request::getString('options', '', 'POST')); |
||||||
438 | } |
||||||
439 | |||||||
440 | // for backward compatibility |
||||||
441 | // $cblock =& $block->clone(); or $cblock =& $block->xoopsClone(); |
||||||
442 | $cblock = new \XoopsBlock(); |
||||||
443 | foreach ($block->vars as $k => $v) { |
||||||
444 | $cblock->assignVar($k, $v['value']); |
||||||
445 | } |
||||||
446 | $cblock->setNew(); |
||||||
447 | |||||||
448 | $myts = \MyTextSanitizer::getInstance(); |
||||||
449 | $cblock->setVar('side', Request::getInt('bside', 0, 'POST')); |
||||||
450 | $cblock->setVar('weight', Request::getInt('bweight', 0, 'POST')); |
||||||
451 | $cblock->setVar('visible', Request::getInt('bvisible', 0, 'POST')); |
||||||
452 | $cblock->setVar('title', Request::getString('btitle', '', 'POST')); |
||||||
453 | $cblock->setVar('content', Request::getString('bcontent', '', 'POST')); |
||||||
454 | $cblock->setVar('c_type', Request::getString('bctype', '', 'POST')); |
||||||
455 | $cblock->setVar('bcachetime', Request::getInt('bcachetime', 0, 'POST')); |
||||||
456 | if (isset($options) && (count($options) > 0)) { |
||||||
457 | $options = implode('|', $options); |
||||||
458 | $cblock->setVar('options', $options); |
||||||
459 | } |
||||||
460 | $cblock->setVar('bid', 0); |
||||||
461 | $cblock->setVar('block_type', 'C' === $block_type ? 'C' : 'D'); |
||||||
462 | $cblock->setVar('func_num', 255); |
||||||
463 | $newid = $cblock->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. ![]() |
|||||||
464 | if (!$newid) { |
||||||
465 | xoops_cp_header(); |
||||||
466 | $cblock->getHtmlErrors(); |
||||||
467 | xoops_cp_footer(); |
||||||
468 | exit(); |
||||||
469 | } |
||||||
470 | /* if ($cblock->getVar('template') != '') { |
||||||
471 | $tplfileHandler = xoops_getHandler('tplfile'); |
||||||
472 | $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
||||||
473 | if (count($btemplate) > 0) { |
||||||
474 | $tplclone =& $btemplate[0]->clone(); |
||||||
475 | $tplclone->setVar('tpl_id', 0); |
||||||
476 | $tplclone->setVar('tpl_refid', $newid); |
||||||
477 | $tplman->insert($tplclone); |
||||||
478 | } |
||||||
479 | } */ |
||||||
480 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
481 | // $bmodule = (isset($_POST['bmodule']) && is_array($_POST['bmodule'])) ? $_POST['bmodule'] : array(-1); // GIJ + |
||||||
482 | $bmodule = Request::getArray('bmodule', [-1], 'POST'); |
||||||
483 | foreach ($bmodule as $bmid) { |
||||||
484 | $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')'; |
||||||
485 | $db->query($sql); |
||||||
486 | } |
||||||
487 | |||||||
488 | /* global $xoopsUser; |
||||||
489 | $groups =& $xoopsUser->getGroups(); |
||||||
490 | $count = count($groups); |
||||||
491 | for ($i = 0; $i < $count; ++$i) { |
||||||
492 | $sql = "INSERT INTO ".$db->prefix('group_permission')." (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (".$groups[$i].", ".$newid.", 1, 'block_read')"; |
||||||
493 | $db->query($sql); |
||||||
494 | } |
||||||
495 | */ |
||||||
496 | |||||||
497 | $sql = 'SELECT gperm_groupid FROM ' . $db->prefix('group_permission') . " WHERE gperm_name='block_read' AND gperm_modid='1' AND gperm_itemid='$bid'"; |
||||||
498 | $result = $db->query($sql); |
||||||
499 | while (false !== (list($gid) = $db->fetchRow($result))) { |
||||||
500 | $sql = 'INSERT INTO ' . $db->prefix('group_permission') . " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ($gid, $newid, 1, 'block_read')"; |
||||||
501 | $db->query($sql); |
||||||
502 | } |
||||||
503 | |||||||
504 | redirect_header('myblocksadmin.php', 1, _AM_DBUPDATED); |
||||||
505 | } |
||||||
506 | |||||||
507 | // import from modules/system/admin/blocksadmin/blocksadmin.php |
||||||
508 | /** |
||||||
509 | * @param $bid |
||||||
510 | * @param $bside |
||||||
511 | * @param $bweight |
||||||
512 | * @param $bvisible |
||||||
513 | * @param $btitle |
||||||
514 | * @param $bcontent |
||||||
515 | * @param $bctype |
||||||
516 | * @param $bcachetime |
||||||
517 | * @param $bmodule |
||||||
518 | * @param array $options |
||||||
519 | * @return string |
||||||
520 | */ |
||||||
521 | function myblocksadmin_update_block( |
||||||
522 | $bid, |
||||||
523 | $bside, |
||||||
524 | $bweight, |
||||||
525 | $bvisible, |
||||||
526 | $btitle, |
||||||
527 | $bcontent, |
||||||
528 | $bctype, |
||||||
529 | $bcachetime, |
||||||
530 | $bmodule, |
||||||
531 | $options = []) |
||||||
532 | { |
||||||
533 | global $xoopsConfig; |
||||||
534 | /* if (empty($bmodule)) { |
||||||
535 | xoops_cp_header(); |
||||||
536 | xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); |
||||||
537 | xoops_cp_footer(); |
||||||
538 | exit(); |
||||||
539 | } */ |
||||||
540 | $myblock = new \XoopsBlock($bid); |
||||||
541 | // $myblock->setVar('side', $bside); GIJ - |
||||||
542 | if ($bside >= 0) { |
||||||
543 | $myblock->setVar('side', $bside); |
||||||
544 | } // GIJ + |
||||||
545 | $myblock->setVar('weight', $bweight); |
||||||
546 | $myblock->setVar('visible', $bvisible); |
||||||
547 | $myblock->setVar('title', $btitle); |
||||||
548 | if (isset($bcontent)) { |
||||||
549 | $myblock->setVar('content', $bcontent); |
||||||
550 | } |
||||||
551 | if (isset($bctype)) { |
||||||
552 | $myblock->setVar('c_type', $bctype); |
||||||
553 | } |
||||||
554 | $myblock->setVar('bcachetime', $bcachetime); |
||||||
555 | if (isset($options) && (count($options) > 0)) { |
||||||
556 | $options = implode('|', $options); |
||||||
557 | $myblock->setVar('options', $options); |
||||||
558 | } |
||||||
559 | if ('C' === $myblock->getVar('block_type')) { |
||||||
560 | switch ($myblock->getVar('c_type')) { |
||||||
561 | case 'H': |
||||||
562 | $name = _AM_CUSTOMHTML; |
||||||
0 ignored issues
–
show
|
|||||||
563 | break; |
||||||
564 | case 'P': |
||||||
565 | $name = _AM_CUSTOMPHP; |
||||||
0 ignored issues
–
show
|
|||||||
566 | break; |
||||||
567 | case 'S': |
||||||
568 | $name = _AM_CUSTOMSMILE; |
||||||
0 ignored issues
–
show
|
|||||||
569 | break; |
||||||
570 | default: |
||||||
571 | $name = _AM_CUSTOMNOSMILE; |
||||||
0 ignored issues
–
show
|
|||||||
572 | break; |
||||||
573 | } |
||||||
574 | $myblock->setVar('name', $name); |
||||||
575 | } |
||||||
576 | $msg = _AM_DBUPDATED; |
||||||
577 | if (false !== $myblock->store()) { |
||||||
578 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||||
579 | $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $db->prefix('block_module_link'), $bid); |
||||||
580 | $db->query($sql); |
||||||
581 | foreach ($bmodule as $bmid) { |
||||||
582 | $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $db->prefix('block_module_link'), $bid, (int)$bmid); |
||||||
583 | $db->query($sql); |
||||||
584 | } |
||||||
585 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||||||
586 | $xoopsTpl = new \XoopsTpl(); |
||||||
587 | $xoopsTpl->caching = 2; |
||||||
588 | if ('' !== $myblock->getVar('template')) { |
||||||
589 | if ($xoopsTpl->is_cached('db:' . $myblock->getVar('template'))) { |
||||||
590 | if (!$xoopsTpl->clear_cache('db:' . $myblock->getVar('template'))) { |
||||||
591 | $msg = 'Unable to clear cache for block ID' . $bid; |
||||||
592 | } |
||||||
593 | } |
||||||
594 | } else { |
||||||
595 | if ($xoopsTpl->is_cached('db:system_dummy.tpl', 'block' . $bid)) { |
||||||
596 | if (!$xoopsTpl->clear_cache('db:system_dummy.tpl', 'block' . $bid)) { |
||||||
597 | $msg = 'Unable to clear cache for block ID' . $bid; |
||||||
598 | } |
||||||
599 | } |
||||||
600 | } |
||||||
601 | } else { |
||||||
602 | $msg = 'Failed update of block. ID:' . $bid; |
||||||
603 | } |
||||||
604 | // redirect_header('admin.php?fct=blocksadmin&t='.time(),1,$msg); |
||||||
605 | // exit(); GIJ - |
||||||
606 | return $msg; // GIJ + |
||||||
607 | } |
||||||
608 | |||||||
609 | // update block instance for 2.2 |
||||||
610 | /** |
||||||
611 | * @param $id |
||||||
612 | * @param $bside |
||||||
613 | * @param $bweight |
||||||
614 | * @param $bvisible |
||||||
615 | * @param $btitle |
||||||
616 | * @param $bcontent |
||||||
617 | * @param $bctype |
||||||
618 | * @param $bcachetime |
||||||
619 | * @param $bmodule |
||||||
620 | * @param array $options |
||||||
621 | * @param null $bid |
||||||
0 ignored issues
–
show
|
|||||||
622 | * @return string |
||||||
623 | */ |
||||||
624 | function myblocksadmin_update_blockinstance( |
||||||
625 | $id, |
||||||
626 | $bside, |
||||||
627 | $bweight, |
||||||
628 | $bvisible, |
||||||
629 | $btitle, |
||||||
630 | $bcontent, |
||||||
0 ignored issues
–
show
The parameter
$bcontent 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. ![]() |
|||||||
631 | $bctype, |
||||||
0 ignored issues
–
show
The parameter
$bctype 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. ![]() |
|||||||
632 | $bcachetime, |
||||||
633 | $bmodule, |
||||||
634 | $options = [], |
||||||
635 | $bid = null) |
||||||
636 | { |
||||||
637 | global $xoopsDB; |
||||||
638 | |||||||
639 | $instanceHandler = xoops_getHandler('blockinstance'); |
||||||
640 | $blockHandler = xoops_getHandler('block'); |
||||||
641 | if ($id > 0) { |
||||||
642 | // update |
||||||
643 | $instance = $instanceHandler->get($id); |
||||||
644 | if ($bside >= 0) { |
||||||
645 | $instance->setVar('side', $bside); |
||||||
646 | } |
||||||
647 | if (!empty($options)) { |
||||||
648 | $instance->setVar('options', $options); |
||||||
649 | } |
||||||
650 | } else { |
||||||
651 | // insert |
||||||
652 | $instance = $instanceHandler->create(); |
||||||
653 | $instance->setVar('bid', $bid); |
||||||
654 | $instance->setVar('side', $bside); |
||||||
655 | $block = $blockHandler->get($bid); |
||||||
656 | $instance->setVar('options', $block->getVar('options')); |
||||||
657 | if (empty($btitle)) { |
||||||
658 | $btitle = $block->getVar('name'); |
||||||
659 | } |
||||||
660 | } |
||||||
661 | $instance->setVar('weight', $bweight); |
||||||
662 | $instance->setVar('visible', $bvisible); |
||||||
663 | $instance->setVar('title', $btitle); |
||||||
664 | // if( isset( $bcontent ) ) $instance->setVar('content', $bcontent); |
||||||
665 | // if( isset( $bctype ) ) $instance->setVar('c_type', $bctype); |
||||||
666 | $instance->setVar('bcachetime', $bcachetime); |
||||||
667 | |||||||
668 | if ($instanceHandler->insert($instance)) { |
||||||
0 ignored issues
–
show
Are you sure the usage of
$instanceHandler->insert($instance) targeting XoopsObjectHandler::insert() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
669 | $GLOBALS['xoopsDB']->query('DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('block_module_link') . ' WHERE block_id=' . $instance->getVar('instanceid')); |
||||||
670 | foreach ($bmodule as $mid) { |
||||||
671 | $page = explode('-', $mid); |
||||||
672 | $mid = $page[0]; |
||||||
673 | $pageid = $page[1]; |
||||||
674 | $GLOBALS['xoopsDB']->query('INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('block_module_link') . ' VALUES (' . $instance->getVar('instanceid') . ', ' . (int)$mid . ', ' . (int)$pageid . ')'); |
||||||
675 | } |
||||||
676 | |||||||
677 | return _MD_AM_DBUPDATED; |
||||||
0 ignored issues
–
show
|
|||||||
678 | } |
||||||
679 | |||||||
680 | return 'Failed update of block instance. ID:' . $id; |
||||||
681 | /* // NAME for CUSTOM BLOCK |
||||||
682 | if ( $instance->getVar('block_type') == 'C') { |
||||||
683 | switch ( $instance->getVar('c_type') ) { |
||||||
684 | case 'H': |
||||||
685 | $name = _AM_CUSTOMHTML; |
||||||
686 | break; |
||||||
687 | case 'P': |
||||||
688 | $name = _AM_CUSTOMPHP; |
||||||
689 | break; |
||||||
690 | case 'S': |
||||||
691 | $name = _AM_CUSTOMSMILE; |
||||||
692 | break; |
||||||
693 | default: |
||||||
694 | $name = _AM_CUSTOMNOSMILE; |
||||||
695 | break; |
||||||
696 | } |
||||||
697 | $instance->setVar('name', $name); |
||||||
698 | } |
||||||
699 | */ |
||||||
700 | /* // CLEAR TEMPLATE CACHE |
||||||
701 | require_once XOOPS_ROOT_PATH.'/class/template.php'; |
||||||
702 | $xoopsTpl = new \XoopsTpl(); |
||||||
703 | $xoopsTpl->caching=(2); |
||||||
704 | if ($instance->getVar('template') != '') { |
||||||
705 | if ($xoopsTpl->is_cached('db:'.$instance->getVar('template'))) { |
||||||
706 | if (!$xoopsTpl->clear_cache('db:'.$instance->getVar('template'))) { |
||||||
707 | $msg = 'Unable to clear cache for block ID'.$bid; |
||||||
708 | } |
||||||
709 | } |
||||||
710 | } else { |
||||||
711 | if ($xoopsTpl->is_cached('db:system_dummy.tpl', 'block'.$bid)) { |
||||||
712 | if (!$xoopsTpl->clear_cache('db:system_dummy.tpl', 'block'.$bid)) { |
||||||
713 | $msg = 'Unable to clear cache for block ID'.$bid; |
||||||
714 | } |
||||||
715 | } |
||||||
716 | } |
||||||
717 | */ |
||||||
718 | } |
||||||
719 | |||||||
720 | // TODO edit2, delete2, customblocks |
||||||
721 |