redirect_header('myblocksadmin.php', 4, 'Invalid block');
 }
 if (empty($_POST['options'])) {
     $options = array();
 } else {
     if (is_array($_POST['options'])) {
         $options = $_POST['options'];
     } else {
         $options = explode('|', $_POST['options']);
     }
 }
 // for backward compatibility
 // $cblock =& $block->clone(); or $cblock =& $block->xoopsClone();
 $cblock = new XoopsBlock();
 foreach ($block->vars as $k => $v) {
     $cblock->assignVar($k, $v['value']);
 }
 $cblock->setNew();
 $myts =& MyTextSanitizer::getInstance();
 $cblock->setVar('side', $_POST['bside']);
 $cblock->setVar('weight', $_POST['bweight']);
 $cblock->setVar('visible', $_POST['bvisible']);
 $cblock->setVar('title', $_POST['btitle']);
 $cblock->setVar('content', @$_POST['bcontent']);
 $cblock->setVar('c_type', @$_POST['bctype']);
 $cblock->setVar('bcachetime', $_POST['bcachetime']);
 if (isset($options) && count($options) > 0) {
     $options = implode('|', $options);
     $cblock->setVar('options', $options);
 }
 $cblock->setVar('bid', 0);
 function do_clone($bid)
 {
     $bid = intval($bid);
     $request = $this->fetchRequest4Block($bid);
     $block = new XoopsBlock($bid);
     if (!$block->getVar('bid')) {
         die('Invalid bid');
     }
     if (!$this->canClone($block)) {
         die('Invalid block_type');
     }
     if (empty($_POST['options'])) {
         $options = array();
     } else {
         if (is_array($_POST['options'])) {
             $options = $_POST['options'];
         } else {
             $options = explode('|', $_POST['options']);
         }
     }
     // for backward compatibility
     // $cblock =& $block->clone(); or $cblock =& $block->xoopsClone();
     $cblock = new XoopsBlock();
     foreach ($block->vars as $k => $v) {
         $cblock->assignVar($k, $v['value']);
     }
     $cblock->setNew();
     $cblock->setVar('bid', 0);
     $cblock->setVar('block_type', $block->getVar('block_type') == 'C' ? 'C' : 'D');
     $cblock->setVar('func_num', $this->find_func_num_vacancy($block->getVar('mid')));
     // store the block into DB as a new one
     $newbid = $cblock->store();
     if (!$newbid) {
         return $cblock->getHtmlErrors();
     }
     // update the block by the request
     $this->update_block($newbid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array());
     // block_module_link update
     $this->updateBlockModuleLink($newbid, $request['bmodule']);
     // group_permission update
     $this->updateBlockReadGroupPerm($newbid, $request['bgroup']);
     return _MD_A_MYBLOCKSADMIN_DBUPDATED;
 }