<?php
function strjoin($str, $st, $end) {
    if (empty($str))
        return '';
    return $st . $str . $end;
}
function splitdict($data){
    $datas = explode('|', $data);
    if(substr($datas[0], 0, 4) == 'ciy_')
        return array('dictciy', $datas[0]);
    if(strpos($datas[0],'.') !== false)
        return array('dictstr', $datas[0]);
    $ind = strpos($datas[0], '_');
    if($ind === false || $ind > 4)
        return array('dictcata', $datas[0]);
    return array('dictdb', $datas[0]);
}
function calfld($post) {
    $total = $post->getint('total');
    $flds = array();

    for ($i = 0; $i < $total; $i++) {
        $col = $post->get('col_' . $i);
        if (empty($col))
            continue;
        $fld = array();
        $fld['col'] = $col;
        $chks = explode(',',$post->get('bchk_' . $i));
        $fld['bviw'] = in_array('bviw', $chks);
        $fld['bdup'] = in_array('bdup', $chks);
        $fld['bimp'] = in_array('bimp', $chks);
        $fld['bsrt'] = in_array('bsrt', $chks);
        $fld['breq'] = in_array('breq', $chks);
        $fld['bqry'] = in_array('bqry', $chks);
        $fld['bmin'] = in_array('bmin', $chks);
        $fld['bout'] = in_array('bout', $chks);
        $fld['set'] = getstrparam($post->get('set_' . $i, '', 'all'));
        if(!isset($fld['set']['noup']))
            $fld['set']['noup'] = '';
        if(!isset($fld['set']['listload']))
            $fld['set']['listload'] = '';
        if(!isset($fld['set']['nocmn']))
            $fld['set']['nocmn'] = '';
        $fld['name'] = $post->get('name_' . $i);
        $fld['type'] = $post->get('type_' . $i);
        $fld['cate'] = $post->get('cate_' . $i);
        $fld['data'] = $post->get('data_' . $i);
        $fld['align'] = $post->get('align_' . $i);
        $fld['show'] = $post->getbool('show_' . $i);
        $flds[] = $fld;
    }
    return $flds;
}
function flddata($data, $idx, $def) {
    $strs = explode(',', $data);
    if($idx < count($strs)){
        if(empty($strs[$idx]))
            return $def;
        return $strs[$idx];
    }
    return $def;
}
function json_createphp() {
    $post = new \ciy\post();
    require_once 'code_pc_php.php';
    $codex = code_pc_php($post);
    return succjson(array('source' => $codex));
}

function json_creatembvue3() {
    $post = new \ciy\post();
    require_once 'code_mb_vue3.php';
    $codex = code_mbvue3($post);
    return succjson(array('source' => $codex));
}
