function block_parse_template($str_template, &$arr)
{
    $arr['makethumb'] = strexists($str_template, '{picwidth}') ? 1 : 0;
    $arr['getpic'] = strexists($str_template, '{pic}') ? 1 : 0;
    $arr['getsummary'] = strexists($str_template, '{summary}') ? 1 : 0;
    $arr['settarget'] = strexists($str_template, '{target}') ? 1 : 0;
    $arr['moreurl'] = strexists($str_template, '{moreurl}') ? 1 : 0;
    $fields = block_parse_fields($str_template);
    $arr['fields'] = serialize($fields);
    $template = array();
    $template['raw'] = $str_template;
    $template['header'] = $template['footer'] = '';
    $template['loop'] = $template['loopplus'] = $template['order'] = $template['orderplus'] = $template['index'] = $template['indexplus'] = array();
    $match = array();
    if (preg_match('/\\[loop\\](.*?)\\[\\/loop]/is', $str_template, $match)) {
        $template['loop'] = trim($match[1]);
    }
    $match = array();
    if (preg_match_all('/\\[(loop\\d)\\](.*?)\\[\\/\\1]/is', $str_template, $match)) {
        foreach ($match[1] as $key => $value) {
            $content = trim($match[2][$key]);
            $k = intval(str_replace('loop', '', $value));
            $template['loopplus'][$k] = $content;
        }
    }
    $match = array();
    if (preg_match_all('/\\[order=(\\d+|odd|even)\\](.*?)\\[\\/order]/is', $str_template, $match)) {
        foreach ($match[1] as $key => $order) {
            $template['order'][$order] = trim($match[2][$key]);
        }
    }
    $match = array();
    if (preg_match_all('/\\[(order\\d+)=(\\d+|odd|even)\\](.*?)\\[\\/\\1]/is', $str_template, $match)) {
        foreach ($match[1] as $key => $value) {
            $content = trim($match[3][$key]);
            $order = $match[2][$key];
            $k = intval(str_replace('order', '', $value));
            $template['orderplus'][$k][$order] = $content;
        }
    }
    $match = array();
    if (preg_match_all('/\\[index=(\\d+)\\](.*?)\\[\\/index]/is', $str_template, $match)) {
        foreach ($match[1] as $key => $order) {
            $template['index'][$order] = trim($match[2][$key]);
        }
    }
    $match = array();
    if (preg_match_all('/\\[(index\\d+)=(\\d+)\\](.*?)\\[\\/\\1]/is', $str_template, $match)) {
        foreach ($match[1] as $key => $value) {
            $content = trim($match[3][$key]);
            $order = intval($match[2][$key]);
            $k = intval(str_replace('index', '', $value));
            $template['indexplus'][$k][$order] = $content;
        }
    }
    $arr['template'] = serialize($template);
    $arr['hash'] = substr(md5($arr['blockclass'] . '|' . $arr['template']), 8, 8);
}
                 break;
             case 'int':
                 $itemfields[$key] = intval($value);
                 break;
             case 'string':
                 $itemfields[$key] = dhtmlspecialchars($value);
                 break;
             default:
                 $itemfields[$key] = $value;
         }
     }
 }
 $showfields = array();
 if (empty($thestyle['fields'])) {
     $template = block_build_template($thestyle['template']);
     $thestyle['fields'] = block_parse_fields($template);
     C::t('common_block_style')->update(intval($thestyle['styleid']), array('fields' => serialize($thestyle['fields'])));
 }
 foreach ($thestyle['fields'] as $fieldname) {
     $showfields[$fieldname] = "1";
 }
 if (submitcheck('itemsubmit') || submitcheck('recommendsubmit') || submitcheck('verifydatasubmit') || submitcheck('managedatasubmit')) {
     $item['bid'] = $block['bid'];
     $item['displayorder'] = intval($_POST['displayorder']);
     $item['startdate'] = !empty($_POST['startdate']) ? strtotime($_POST['startdate']) : 0;
     $item['enddate'] = !empty($_POST['enddate']) ? strtotime($_POST['enddate']) : 0;
     $item['itemtype'] = !empty($_POST['locked']) ? '1' : '2';
     $item['title'] = dhtmlspecialchars($_POST['title']);
     $item['url'] = $_POST['url'];
     $block['param']['summarylength'] = empty($block['param']['summarylength']) ? 80 : $block['param']['summarylength'];
     $block['param']['titlelength'] = empty($block['param']['titlelength']) ? 40 : $block['param']['titlelength'];