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 (https://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 | |||
30 | if (!empty($_POST['bid'])) { |
||
31 | $bid = Request::getInt('bid', 0, 'POST'); |
||
32 | } |
||
33 | |||
34 | if (Request::hasVar('op', 'GET')) { |
||
35 | if ('edit' === $_GET['op'] || 'delete' === $_GET['op'] || 'delete_ok' === $_GET['op'] |
||
36 | || 'clone' === $_GET['op'] /* || $_GET['op'] == 'previewpopup'*/) { |
||
37 | $op = $_GET['op']; |
||
38 | $bid = Request::getInt('bid', 0, 'GET'); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | if (Request::hasVar('previewblock', 'POST')) { |
||
43 | //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||
44 | // exit('Invalid Referer'); |
||
45 | //} |
||
46 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
47 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||
48 | } |
||
49 | |||
50 | if (empty($bid)) { |
||
51 | exit('Invalid bid.'); |
||
52 | } |
||
53 | |||
54 | $bside = Request::getInt('bside', 0, 'POST'); |
||
55 | $bweight = Request::getInt('bweight', 0, 'POST'); |
||
56 | $bvisible = Request::getInt('bvisible', 0, 'POST'); |
||
57 | $bmodule = Request::getArray('bmodule', [], 'POST'); |
||
58 | $btitle = Request::getString('btitle', '', 'POST'); |
||
59 | $bcontent = Request::getString('bcontent', '', 'POST'); |
||
60 | $bctype = Request::getString('bctype', '', 'POST'); |
||
61 | $bcachetime = Request::getInt('bcachetime', 0, 'POST'); |
||
62 | |||
63 | xoops_cp_header(); |
||
64 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||
65 | $xoopsTpl = new \XoopsTpl(); |
||
66 | $xoopsTpl->caching = 0; |
||
67 | $block['bid'] = $bid; |
||
68 | |||
69 | if ('clone_ok' === $op) { |
||
70 | $block['form_title'] = _AM_CLONEBLOCK; |
||
71 | $block['submit_button'] = _CLONE; |
||
72 | $myblock = new \XoopsBlock(); |
||
73 | $myblock->setVar('block_type', 'C'); |
||
74 | } else { |
||
75 | $op = 'update'; |
||
76 | $block['form_title'] = _AM_EDITBLOCK; |
||
77 | $block['submit_button'] = _SUBMIT; |
||
78 | $myblock = new \XoopsBlock($bid); |
||
79 | $block['name'] = $myblock->getVar('name'); |
||
80 | } |
||
81 | |||
82 | $myts = \MyTextSanitizer::getInstance(); |
||
83 | $myblock->setVar('title', $btitle); |
||
84 | $myblock->setVar('content', $bcontent); |
||
85 | // $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>'; |
||
86 | |||
87 | /* $dummyfile = '_dummyfile_'.time().'.html'; |
||
88 | $fp = fopen(XOOPS_CACHE_PATH.'/'.$dummyfile, 'w'); |
||
89 | fwrite($fp, $dummyhtml); |
||
90 | fclose($fp);*/ |
||
91 | $block['edit_form'] = false; |
||
92 | $block['template'] = ''; |
||
93 | $block['op'] = $op; |
||
94 | $block['side'] = $bside; |
||
95 | $block['weight'] = $bweight; |
||
96 | $block['visible'] = $bvisible; |
||
97 | $block['title'] = $myblock->getVar('title', 'E'); |
||
98 | $block['content'] = $myblock->getVar('content', 'E'); |
||
99 | $block['modules'] = &$bmodule; |
||
100 | $block['ctype'] = $bctype ?? $myblock->getVar('c_type'); |
||
101 | $block['is_custom'] = true; |
||
102 | $block['cachetime'] = $bcachetime; |
||
103 | echo '<a href="myblocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . $block['form_title'] . '<br><br>'; |
||
104 | require_once dirname(__DIR__) . '/admin/myblockform.php'; //GIJ |
||
105 | //echo '<a href="admin.php?fct=blocksadmin">'. _AM_BADMIN .'</a> <span style="font-weight:bold;">»»</span> '.$block['form_title'].'<br><br>'; |
||
106 | //require_once XOOPS_ROOT_PATH.'/modules/system/admin/blocksadmin/blockform.php'; |
||
107 | // $form->addElement($xoopsGTicket->getTicketXoopsForm(__LINE__));//GIJ |
||
108 | $form->display(); |
||
109 | |||
110 | $original_level = error_reporting(E_ALL); |
||
111 | echo " |
||
112 | <table width='100%' class='outer' cellspacing='1'> |
||
113 | <tr> |
||
114 | <th>" . $myblock->getVar('title') . "</th> |
||
115 | </tr> |
||
116 | <tr> |
||
117 | <td class='odd'>" . $myblock->getContent('S', $bctype) . "</td> |
||
118 | </tr> |
||
119 | </table>\n"; |
||
120 | error_reporting($original_level); |
||
121 | |||
122 | xoops_cp_footer(); |
||
123 | /* echo '<script type="text/javascript"> |
||
124 | preview_window = openWithSelfMain("'.XOOPS_URL.'/modules/system/admin.php?fct=blocksadmin&op=previewpopup&file='.$dummyfile.'", "popup", 250, 200); |
||
125 | </script>';*/ |
||
126 | |||
127 | exit(); |
||
128 | } |
||
129 | |||
130 | /* if ($op == 'previewpopup') { |
||
131 | if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||
132 | exit('Invalid Referer'); |
||
133 | } |
||
134 | $file = str_replace('..', '', XOOPS_CACHE_PATH.'/'.trim($_GET['file'])); |
||
135 | if (file_exists($file)) { |
||
136 | require_once $file; |
||
137 | @unlink($file); |
||
138 | } |
||
139 | exit(); |
||
140 | } */ |
||
141 | |||
142 | /* if ($op == "list") { |
||
143 | xoops_cp_header(); |
||
144 | list_blocks(); |
||
145 | xoops_cp_footer(); |
||
146 | exit(); |
||
147 | } */ |
||
148 | |||
149 | if ('order' === $op) { |
||
150 | //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||
151 | // exit('Invalid Referer'); |
||
152 | //} |
||
153 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
154 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||
155 | } |
||
156 | if (Request::hasVar('side', 'POST')) { |
||
157 | $side = $_POST['side']; |
||
158 | } |
||
159 | // if ( !empty($_POST['weight']) ) { $weight = $_POST['weight']; } |
||
160 | if (Request::hasVar('visible', 'POST')) { |
||
161 | $visible = $_POST['visible']; |
||
162 | } |
||
163 | // if ( !empty($_POST['oldside']) ) { $oldside = $_POST['oldside']; } |
||
164 | // if ( !empty($_POST['oldweight']) ) { $oldweight = $_POST['oldweight']; } |
||
165 | // if ( !empty($_POST['oldvisible']) ) { $oldvisible = $_POST['oldvisible']; } |
||
166 | if (Request::hasVar('bid', 'POST')) { |
||
167 | $bid = $_POST['bid']; |
||
168 | } else { |
||
169 | $bid = []; |
||
170 | } |
||
171 | // GIJ start |
||
172 | foreach (array_keys($bid) as $i) { |
||
173 | if ($side[$i] < 0) { |
||
174 | $visible[$i] = 0; |
||
175 | $side[$i] = -1; |
||
176 | } else { |
||
177 | $visible[$i] = 1; |
||
178 | } |
||
179 | |||
180 | $bmodule = (isset($_POST['bmodule'][$i]) |
||
181 | && is_array($_POST['bmodule'][$i])) ? $_POST['bmodule'][$i] : [-1]; |
||
182 | |||
183 | myblocksadmin_update_block($i, $side[$i], $_POST['weight'][$i], $visible[$i], $_POST['title'][$i], null, null, $_POST['bcachetime'][$i], $bmodule, []); |
||
184 | |||
185 | // if ( $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i] || $oldside[$i] != $side[$i] ) |
||
186 | // order_block($bid[$i], $weight[$i], $visible[$i], $side[$i]); |
||
187 | } |
||
188 | $query4redirect = '?dirname=' . urlencode(strip_tags(mb_substr($_POST['query4redirect'], 9))); |
||
189 | redirect_header("myblocksadmin.php$query4redirect", 1, _AM_DBUPDATED); |
||
190 | // GIJ end |
||
191 | } |
||
192 | |||
193 | /* if ($op == 'save') { |
||
194 | if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||
195 | exit('Invalid Referer'); |
||
196 | } |
||
197 | if ( ! $GLOBALS['xoopsSecurity']->check() ) { |
||
198 | redirect_header(XOOPS_URL.'/',3,$GLOBALS['xoopsSecurity']->getErrors()); |
||
199 | } |
||
200 | if ( !empty($_POST['bside']) ) { $bside = (int)($_POST['bside']); } else { $bside = 0; } |
||
201 | if ( !empty($_POST['bweight']) ) { $bweight = (int)($_POST['bweight']); } else { $bweight = 0; } |
||
202 | if ( !empty($_POST['bvisible']) ) { $bvisible = (int)($_POST['bvisible']); } else { $bvisible = 0; } |
||
203 | if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = []; } |
||
204 | if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } |
||
205 | if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } |
||
206 | if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } |
||
207 | if ( !empty($_POST['bcachetime']) ) { $bcachetime = (int)($_POST['bcachetime']); } else { $bcachetime = 0; } |
||
208 | save_block($bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bmodule, $bcachetime); |
||
209 | exit(); |
||
210 | } */ |
||
211 | |||
212 | if ('update' === $op) { |
||
213 | //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||
214 | // exit('Invalid Referer'); |
||
215 | //} |
||
216 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
217 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||
218 | } |
||
219 | /* if ( !empty($_POST['bside']) ) { $bside = (int)($_POST['bside']); } else { $bside = 0; } |
||
220 | if ( !empty($_POST['bweight']) ) { $bweight = (int)($_POST['bweight']); } else { $bweight = 0; } |
||
221 | if ( !empty($_POST['bvisible']) ) { $bvisible = (int)($_POST['bvisible']); } else { $bvisible = 0; } |
||
222 | if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } |
||
223 | if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } |
||
224 | if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } |
||
225 | if ( !empty($_POST['bcachetime']) ) { $bcachetime = (int)($_POST['bcachetime']); } else { $bcachetime = 0; } |
||
226 | if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = []; } |
||
227 | if ( !empty($_POST['options']) ) { $options = $_POST['options']; } else { $options = []; } |
||
228 | update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options);*/ |
||
229 | |||
230 | $bcachetime = Request::getInt('bcachetime', 0, 'POST'); |
||
231 | $options = $_POST['options'] ?? []; |
||
232 | $bcontent = Request::getString('bcontent', '', 'POST'); |
||
233 | $bctype = Request::getString('bctype', '', 'POST'); |
||
234 | $bmodule = (isset($_POST['bmodule']) && is_array($_POST['bmodule'])) ? $_POST['bmodule'] : [-1]; // GIJ + |
||
235 | $msg = myblocksadmin_update_block($_POST['bid'], $_POST['bside'], $_POST['bweight'], $_POST['bvisible'], $_POST['btitle'], $bcontent, $bctype, $bcachetime, $bmodule, $options); // GIJ ! |
||
236 | redirect_header('myblocksadmin.php', 1, $msg); |
||
237 | } |
||
238 | |||
239 | if ('delete_ok' === $op) { |
||
240 | //if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
||
241 | // exit('Invalid Referer'); |
||
242 | //} |
||
243 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
244 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||
245 | } |
||
246 | // delete_block_ok($bid); GIJ imported from blocksadmin.php |
||
247 | $myblock = new \XoopsBlock($bid); |
||
248 | if ('D' !== $myblock->getVar('block_type') && 'C' !== $myblock->getVar('block_type')) { |
||
249 | redirect_header('myblocksadmin.php', 4, 'Invalid block'); |
||
250 | } |
||
251 | $myblock->delete(); |
||
252 | if (!defined('XOOPS_ORETEKI') && '' !== $myblock->getVar('template')) { |
||
253 | /** @var \XoopsTplfileHandler $tplfileHandler */ |
||
254 | $tplfileHandler = xoops_getHandler('tplfile'); |
||
255 | $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
||
256 | if (count($btemplate) > 0) { |
||
257 | $tplman->delete($btemplate[0]); |
||
258 | } |
||
259 | } |
||
260 | redirect_header('myblocksadmin.php', 1, _AM_DBUPDATED); |
||
261 | // end of delete_block_ok() GIJ |
||
262 | } |
||
263 | |||
264 | if ('delete' === $op) { |
||
265 | xoops_cp_header(); |
||
266 | // delete_block($bid); GIJ imported from blocksadmin.php |
||
267 | $myblock = new \XoopsBlock($bid); |
||
268 | if ('S' === $myblock->getVar('block_type')) { |
||
269 | $message = _AM_SYSTEMCANT; |
||
270 | redirect_header('admin.php?fct=blocksadmin', 4, $message); |
||
271 | } elseif ('M' === $myblock->getVar('block_type')) { |
||
272 | $message = _AM_MODULECANT; |
||
273 | redirect_header('admin.php?fct=blocksadmin', 4, $message); |
||
274 | } else { |
||
275 | xoops_confirm(['fct' => 'blocksadmin', 'op' => 'delete_ok', 'bid' => $myblock->getVar('bid')], 'admin.php', sprintf(_AM_RUSUREDEL, $myblock->getVar('title'))); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
276 | } |
||
277 | // end of delete_block() GIJ |
||
278 | xoops_cp_footer(); |
||
279 | exit(); |
||
280 | } |
||
281 | |||
282 | if ('edit' === $op) { |
||
283 | xoops_cp_header(); |
||
284 | // edit_block($bid); GIJ imported from blocksadmin.php |
||
285 | $myblock = new \XoopsBlock($bid); |
||
286 | |||
287 | $db = \XoopsDatabaseFactory:: getDatabaseConnection(); |
||
288 | $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; |
||
289 | $result = $db->query($sql); |
||
290 | $modules = []; |
||
291 | while (false !== ($row = $db->fetchArray($result))) { |
||
292 | $modules[] = (int)$row['module_id']; |
||
293 | } |
||
294 | $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); |
||
295 | $block = [ |
||
296 | 'form_title' => _AM_EDITBLOCK, |
||
297 | 'name' => $myblock->getVar('name'), |
||
298 | 'side' => $myblock->getVar('side'), |
||
299 | 'weight' => $myblock->getVar('weight'), |
||
300 | 'visible' => $myblock->getVar('visible'), |
||
301 | 'title' => $myblock->getVar('title', 'E'), |
||
302 | 'content' => $myblock->getVar('content', 'E'), |
||
303 | 'modules' => $modules, |
||
304 | 'is_custom' => $is_custom, |
||
305 | 'ctype' => $myblock->getVar('c_type'), |
||
306 | 'cachetime' => $myblock->getVar('bcachetime'), |
||
307 | 'op' => 'update', |
||
308 | 'bid' => $myblock->getVar('bid'), |
||
309 | 'edit_form' => $myblock->getOptions(), |
||
310 | 'template' => $myblock->getVar('template'), |
||
311 | 'options' => $myblock->getVar('options'), |
||
312 | 'submit_button' => _SUBMIT, |
||
313 | ]; |
||
314 | |||
315 | echo '<a href="myblocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_EDITBLOCK . '<br><br>'; |
||
316 | require_once dirname(__DIR__) . '/admin/myblockform.php'; //GIJ |
||
317 | // $form->addElement($xoopsGTicket->getTicketXoopsForm(__LINE__));//GIJ |
||
318 | $form->display(); |
||
319 | // end of edit_block() GIJ |
||
320 | xoops_cp_footer(); |
||
321 | exit(); |
||
322 | } |
||
323 | |||
324 | if ('clone' === $op) { |
||
325 | xoops_cp_header(); |
||
326 | $myblock = new \XoopsBlock($bid); |
||
327 | |||
328 | $db = \XoopsDatabaseFactory:: getDatabaseConnection(); |
||
329 | $sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; |
||
330 | $result = $db->query($sql); |
||
331 | $modules = []; |
||
332 | while (false !== ($row = $db->fetchArray($result))) { |
||
333 | $modules[] = (int)$row['module_id']; |
||
334 | } |
||
335 | $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); |
||
336 | $block = [ |
||
337 | 'form_title' => _AM_CLONEBLOCK, |
||
338 | 'name' => $myblock->getVar('name'), |
||
339 | 'side' => $myblock->getVar('side'), |
||
340 | 'weight' => $myblock->getVar('weight'), |
||
341 | 'visible' => $myblock->getVar('visible'), |
||
342 | 'content' => $myblock->getVar('content', 'N'), |
||
343 | 'title' => $myblock->getVar('title', 'E'), |
||
344 | 'modules' => $modules, |
||
345 | 'is_custom' => $is_custom, |
||
346 | 'ctype' => $myblock->getVar('c_type'), |
||
347 | 'cachetime' => $myblock->getVar('bcachetime'), |
||
348 | 'op' => 'clone_ok', |
||
349 | 'bid' => $myblock->getVar('bid'), |
||
350 | 'edit_form' => $myblock->getOptions(), |
||
351 | 'template' => $myblock->getVar('template'), |
||
352 | 'options' => $myblock->getVar('options'), |
||
353 | 'submit_button' => _CLONE, |
||
354 | ]; |
||
355 | echo '<a href="myblocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_CLONEBLOCK . '<br><br>'; |
||
356 | require_once dirname(__DIR__) . '/admin/myblockform.php'; |
||
357 | // $form->addElement($xoopsGTicket->getTicketXoopsForm(__LINE__));//GIJ |
||
358 | $form->display(); |
||
359 | xoops_cp_footer(); |
||
360 | exit(); |
||
361 | } |
||
362 | |||
363 | if ('clone_ok' === $op) { |
||
364 | // Ticket Check |
||
365 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
366 | redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); |
||
367 | } |
||
368 | |||
369 | $block = new \XoopsBlock($bid); |
||
370 | |||
371 | // block type check |
||
372 | $block_type = $block->getVar('block_type'); |
||
373 | if ('C' !== $block_type && 'M' !== $block_type && 'D' !== $block_type) { |
||
374 | redirect_header('myblocksadmin.php', 4, 'Invalid block'); |
||
375 | } |
||
376 | |||
377 | if (empty($_POST['options'])) { |
||
378 | $options = []; |
||
379 | } elseif (is_array($_POST['options'])) { |
||
380 | $options = $_POST['options']; |
||
381 | } else { |
||
382 | $options = explode('|', $_POST['options']); |
||
383 | } |
||
384 | |||
385 | // for backward compatibility |
||
386 | // $cblock = $block->clone(); or $cblock = $block->xoopsClone(); |
||
387 | $cblock = new \XoopsBlock(); |
||
388 | foreach ($block->vars as $k => $v) { |
||
389 | $cblock->assignVar($k, $v['value']); |
||
390 | } |
||
391 | $cblock->setNew(); |
||
392 | |||
393 | $cblock->setVar('side', $_POST['bside']); |
||
394 | $cblock->setVar('weight', $_POST['bweight']); |
||
395 | $cblock->setVar('visible', $_POST['bvisible']); |
||
396 | $cblock->setVar('title', $_POST['btitle']); |
||
397 | //$cblock->setVar('content', $bcontent); |
||
398 | //$cblock->setVar('title', $btitle); |
||
399 | $cblock->setVar('bcachetime', $_POST['bcachetime']); |
||
400 | if (isset($options) && (count($options) > 0)) { |
||
401 | $options = implode('|', $options); |
||
402 | $cblock->setVar('options', $options); |
||
403 | } |
||
404 | $cblock->setVar('bid', 0); |
||
405 | $cblock->setVar('block_type', 'C' === $block_type ? 'C' : 'D'); |
||
406 | $cblock->setVar('func_num', 255); |
||
407 | $newid = $cblock->store(); |
||
408 | if (!$newid) { |
||
409 | xoops_cp_header(); |
||
410 | $cblock->getHtmlErrors(); |
||
411 | xoops_cp_footer(); |
||
412 | exit(); |
||
413 | } |
||
414 | /* if ($cblock->getVar('template') != '') { |
||
415 | $tplfileHandler = xoops_getHandler('tplfile'); |
||
416 | $btemplate = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
||
417 | if (count($btemplate) > 0) { |
||
418 | $tplclone = $btemplate[0]->clone(); |
||
419 | $tplclone->setVar('tpl_id', 0); |
||
420 | $tplclone->setVar('tpl_refid', $newid); |
||
421 | $tplman->insert($tplclone); |
||
422 | } |
||
423 | } */ |
||
424 | $db = \XoopsDatabaseFactory:: getDatabaseConnection(); |
||
425 | $bmodule = (isset($_POST['bmodule']) && is_array($_POST['bmodule'])) ? $_POST['bmodule'] : [-1]; // GIJ + |
||
426 | foreach ($bmodule as $bmid) { |
||
427 | $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')'; |
||
428 | $db->query($sql); |
||
429 | } |
||
430 | |||
431 | /* global $xoopsUser; |
||
432 | $groups = $xoopsUser->getGroups(); |
||
433 | $count = count($groups); |
||
434 | for ($i = 0; $i < $count; ++$i) { |
||
435 | $sql = "INSERT INTO ".$db->prefix('group_permission')." (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (".$groups[$i].", ".$newid.", 1, 'block_read')"; |
||
436 | $db->query($sql); |
||
437 | } |
||
438 | */ |
||
439 | |||
440 | $sql = 'SELECT gperm_groupid FROM ' . $db->prefix('group_permission') . " WHERE gperm_name='block_read' AND gperm_modid='1' AND gperm_itemid='$bid'"; |
||
441 | $result = $db->query($sql); |
||
442 | while (list($gid) = $db->fetchRow($result)) { |
||
443 | $sql = 'INSERT INTO ' . $db->prefix('group_permission') . " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ($gid, $newid, 1, 'block_read')"; |
||
444 | $db->query($sql); |
||
445 | } |
||
446 | |||
447 | redirect_header('myblocksadmin.php', 1, _AM_DBUPDATED); |
||
448 | } |
||
449 | |||
450 | // import from modules/system/admin/blocksadmin/blocksadmin.php |
||
451 | /** |
||
452 | * @param $bid |
||
453 | * @param $bside |
||
454 | * @param $bweight |
||
455 | * @param $bvisible |
||
456 | * @param $btitle |
||
457 | * @param $bcontent |
||
458 | * @param $bctype |
||
459 | * @param $bcachetime |
||
460 | * @param $bmodule |
||
461 | * @param array $options |
||
462 | * |
||
463 | * @return string |
||
464 | */ |
||
465 | function myblocksadmin_update_block( |
||
466 | $bid, |
||
467 | $bside, |
||
468 | $bweight, |
||
469 | $bvisible, |
||
470 | $btitle, |
||
471 | $bcontent, |
||
472 | $bctype, |
||
473 | $bcachetime, |
||
474 | $bmodule, |
||
475 | $options = [] |
||
476 | ) { |
||
477 | global $xoopsConfig; |
||
478 | /* if (empty($bmodule)) { |
||
479 | xoops_cp_header(); |
||
480 | xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN)); |
||
481 | xoops_cp_footer(); |
||
482 | exit(); |
||
483 | } */ |
||
484 | $myblock = new \XoopsBlock($bid); |
||
485 | // $myblock->setVar('side', $bside); GIJ - |
||
486 | if ($bside >= 0) { |
||
487 | $myblock->setVar('side', $bside); |
||
488 | } // GIJ + |
||
489 | $myblock->setVar('weight', $bweight); |
||
490 | $myblock->setVar('visible', $bvisible); |
||
491 | $myblock->setVar('title', $btitle); |
||
492 | if (isset($bcontent)) { |
||
493 | $myblock->setVar('content', $bcontent); |
||
494 | } |
||
495 | if (isset($bctype)) { |
||
496 | $myblock->setVar('c_type', $bctype); |
||
497 | } |
||
498 | $myblock->setVar('bcachetime', $bcachetime); |
||
499 | if (isset($options) && (count($options) > 0)) { |
||
500 | $options = implode('|', $options); |
||
501 | $myblock->setVar('options', $options); |
||
502 | } |
||
503 | if ('C' === $myblock->getVar('block_type')) { |
||
504 | switch ($myblock->getVar('c_type')) { |
||
505 | case 'H': |
||
506 | $name = _AM_CUSTOMHTML; |
||
507 | break; |
||
508 | case 'P': |
||
509 | $name = _AM_CUSTOMPHP; |
||
510 | break; |
||
511 | case 'S': |
||
512 | $name = _AM_CUSTOMSMILE; |
||
513 | break; |
||
514 | default: |
||
515 | $name = _AM_CUSTOMNOSMILE; |
||
516 | break; |
||
517 | } |
||
518 | $myblock->setVar('name', $name); |
||
519 | } |
||
520 | $msg = _AM_DBUPDATED; |
||
521 | if (false !== $myblock->store()) { |
||
522 | $db = \XoopsDatabaseFactory:: getDatabaseConnection(); |
||
523 | $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $db->prefix('block_module_link'), $bid); |
||
524 | $db->query($sql); |
||
525 | foreach ($bmodule as $bmid) { |
||
526 | $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $db->prefix('block_module_link'), $bid, (int)$bmid); |
||
527 | $db->query($sql); |
||
528 | } |
||
529 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||
530 | $xoopsTpl = new \XoopsTpl(); |
||
531 | $xoopsTpl->caching = 2; |
||
532 | if ('' !== $myblock->getVar('template')) { |
||
533 | if ($xoopsTpl->is_cached('db:' . $myblock->getVar('template'))) { |
||
534 | if (!$xoopsTpl->clear_cache('db:' . $myblock->getVar('template'))) { |
||
535 | $msg = 'Unable to clear cache for block ID' . $bid; |
||
536 | } |
||
537 | } |
||
538 | } elseif ($xoopsTpl->is_cached('db:system_dummy.tpl', 'block' . $bid)) { |
||
539 | if (!$xoopsTpl->clear_cache('db:system_dummy.tpl', 'block' . $bid)) { |
||
540 | $msg = 'Unable to clear cache for block ID' . $bid; |
||
541 | } |
||
542 | } |
||
543 | } else { |
||
544 | $msg = 'Failed update of block. ID:' . $bid; |
||
545 | } |
||
546 | // redirect_header('admin.php?fct=blocksadmin&t='.time(),1,$msg); |
||
547 | // exit(); GIJ - |
||
548 | return $msg; // GIJ + |
||
549 | } |
||
550 |