| 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 |  |  |         $tplfileHandler = xoops_getHandler('tplfile'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |         $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         if (count($btemplate) > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |             $tplman->delete($btemplate[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |     redirect_header('myblocksadmin.php', 1, _AM_DBUPDATED); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     // end of delete_block_ok() GIJ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | if ('delete' === $op) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |     xoops_cp_header(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |     // delete_block($bid); GIJ imported from blocksadmin.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |     $myblock = new \XoopsBlock($bid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |     if ('S' === $myblock->getVar('block_type')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |         $message = _AM_SYSTEMCANT; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |         redirect_header('admin.php?fct=blocksadmin', 4, $message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |     } elseif ('M' === $myblock->getVar('block_type')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |         $message = _AM_MODULECANT; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |         redirect_header('admin.php?fct=blocksadmin', 4, $message); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |         xoops_confirm(['fct' => 'blocksadmin', 'op' => 'delete_ok', 'bid' => $myblock->getVar('bid')], 'admin.php', sprintf(_AM_RUSUREDEL, $myblock->getVar('title'))); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |     // end of delete_block() GIJ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |     xoops_cp_footer(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |     exit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | if ('edit' === $op) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |     xoops_cp_header(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |     // edit_block($bid); GIJ imported from blocksadmin.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |     $myblock = new \XoopsBlock($bid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |     $db      = \XoopsDatabaseFactory:: getDatabaseConnection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |     $sql     = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |     $result  = $db->query($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |     $modules = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |     while (false !== ($row = $db->fetchArray($result))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |         $modules[] = (int)$row['module_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |     $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |     $block     = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |         'form_title'    => _AM_EDITBLOCK, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |         'name'          => $myblock->getVar('name'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         'side'          => $myblock->getVar('side'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |         'weight'        => $myblock->getVar('weight'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |         'visible'       => $myblock->getVar('visible'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |         'title'         => $myblock->getVar('title', 'E'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |         'content'       => $myblock->getVar('content', 'E'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |         'modules'       => $modules, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |         'is_custom'     => $is_custom, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |         'ctype'         => $myblock->getVar('c_type'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |         'cachetime'     => $myblock->getVar('bcachetime'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |         'op'            => 'update', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |         'bid'           => $myblock->getVar('bid'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |         'edit_form'     => $myblock->getOptions(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |         'template'      => $myblock->getVar('template'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |         'options'       => $myblock->getVar('options'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |         'submit_button' => _SUBMIT, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |     echo '<a href="myblocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_EDITBLOCK . '<br><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |     require_once dirname(__DIR__) . '/admin/myblockform.php'; //GIJ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |     //    $form->addElement($xoopsGTicket->getTicketXoopsForm(__LINE__));//GIJ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |     $form->display(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |     // end of edit_block() GIJ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |     xoops_cp_footer(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |     exit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | if ('clone' === $op) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |     xoops_cp_header(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |     $myblock = new \XoopsBlock($bid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |     $db      = \XoopsDatabaseFactory:: getDatabaseConnection(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |     $sql     = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |     $result  = $db->query($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |     $modules = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |     while (false !== ($row = $db->fetchArray($result))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |         $modules[] = (int)$row['module_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |     $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |     $block     = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |         'form_title'    => _AM_CLONEBLOCK, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |         'name'          => $myblock->getVar('name'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |         'side'          => $myblock->getVar('side'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |         'weight'        => $myblock->getVar('weight'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |         'visible'       => $myblock->getVar('visible'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |         'content'       => $myblock->getVar('content', 'N'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |         'title'         => $myblock->getVar('title', 'E'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |         'modules'       => $modules, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |         'is_custom'     => $is_custom, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         'ctype'         => $myblock->getVar('c_type'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |         'cachetime'     => $myblock->getVar('bcachetime'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |         'op'            => 'clone_ok', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |         'bid'           => $myblock->getVar('bid'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |         'edit_form'     => $myblock->getOptions(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |         'template'      => $myblock->getVar('template'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |         'options'       => $myblock->getVar('options'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |         'submit_button' => _CLONE, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |     echo '<a href="myblocksadmin.php">' . _AM_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_CLONEBLOCK . '<br><br>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |     require_once dirname(__DIR__) . '/admin/myblockform.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |     //    $form->addElement($xoopsGTicket->getTicketXoopsForm(__LINE__));//GIJ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |     $form->display(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |     xoops_cp_footer(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |     exit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | if ('clone_ok' === $op) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |     // Ticket Check | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |     if (!$GLOBALS['xoopsSecurity']->check()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |         redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |     $block = new \XoopsBlock($bid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |     // block type check | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |     $block_type = $block->getVar('block_type'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |     if ('C' !== $block_type && 'M' !== $block_type && 'D' !== $block_type) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |         redirect_header('myblocksadmin.php', 4, 'Invalid block'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |     if (empty($_POST['options'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |         $options = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |     } elseif (is_array($_POST['options'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |             $options = $_POST['options']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |             $options = explode('|', $_POST['options']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 544 |  |  |     } else { | 
            
                                                        
            
                                    
            
            
                | 545 |  |  |         $msg = 'Failed update of block. ID:' . $bid; | 
            
                                                        
            
                                    
            
            
                | 546 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 547 |  |  |     // redirect_header('admin.php?fct=blocksadmin&t='.time(),1,$msg); | 
            
                                                        
            
                                    
            
            
                | 548 |  |  |     // exit(); GIJ - | 
            
                                                        
            
                                    
            
            
                | 549 |  |  |     return $msg; // GIJ + | 
            
                                                        
            
                                    
            
            
                | 550 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 551 |  |  |  |