function ctagtrans($tname, $tstr)
{
    $tag = o_tag_arr($tname, stripslashes($tstr));
    if (empty($tag['tclass'])) {
        return '{c$' . $tname . ' ' . stripslashes($tstr) . '{/c$' . $tname . '}';
    }
    //先转模板中的标识
    oreplace($tag['template'], 'c');
    //标识中只转复合标识
    //再转标识本身的设置
    $needstrans = '';
    if (in_array($tag['tclass'], array('archives', 'alarchives', 'arcscount'))) {
        $needstrans = 'caids,ccidson,cosource,ccids,atsource,chids';
    } elseif (in_array($tag['tclass'], array('archive'))) {
        $needstrans = 'album';
    } elseif (in_array($tag['tclass'], array('catalogs', 'mcatalogs'))) {
        $needstrans = 'urlmode,listby,caids,cainherit,coinherit,cosource,ccids';
    } elseif (in_array($tag['tclass'], array('cnode'))) {
        $needstrans = 'listby,casource,cosource1';
    } elseif (in_array($tag['tclass'], array('nownav'))) {
        $needstrans = 'urlmode';
    } elseif (in_array($tag['tclass'], array('acontext'))) {
        $needstrans = 'atid,atsource';
    } elseif (in_array($tag['tclass'], array('context'))) {
        $needstrans = 'ccid';
    } elseif (in_array($tag['tclass'], array('farchives'))) {
        $needstrans = 'fcasource';
    } elseif (in_array($tag['tclass'], array('commus'))) {
        $needstrans = 'cuid';
    } elseif (in_array($tag['tclass'], array('members', 'memscount'))) {
        $needstrans = 'ugid,mchids';
    } elseif (in_array($tag['tclass'], array('channels'))) {
        $needstrans = 'chids';
    } elseif (in_array($tag['tclass'], array('mchannels'))) {
        $needstrans = 'mchids';
    }
    $tstr = otagreplace($tstr, $needstrans);
    $tstr = str_replace('#<#template#>#', $tag['template'], $tstr);
    return '{c$' . $tname . ' ' . stripslashes($tstr) . '{/c$' . $tname . '}';
}
 foreach ($octags as $k => $v) {
     $tagsarr[] = array('ctag', $k);
 }
 $tagsarr[] = array('utags', '');
 $outags = oread_cache('utags', '', '', 'template');
 foreach ($outags as $k => $v) {
     $tagsarr[] = array('utag', $k);
 }
 foreach ($tagsarr as $k => $v) {
     $ocache = oread_cache($v[0], $v[1], '', 'template');
     if (!$v[1]) {
         cache2file($ocache, $v[0], $v[0], $nsid);
     } else {
         if (!empty($ocache['template'])) {
             oreplace($ocache['template'], 'p');
             oreplace($ocache['template'], 'c');
         }
         cache2file($ocache, cache_name($v[0], $v[1]), $v[0], $nsid);
     }
 }
 //将一些站点信息写入进来
 $omconfigs = oread_cache('mconfigs', '', '', 'cache');
 $sqlstr = '';
 foreach (array('cmslogo', 'cmstitle', 'cmskeyword', 'cmsdescription', 'hometpl') as $var) {
     isset($omconfigs[$var]) && ($sqlstr .= ($sqlstr ? ',' : '') . "{$var}='" . addslashes($omconfigs[$var]) . "'");
 }
 $db->query("UPDATE {$tblprefix}subsites SET {$sqlstr} WHERE sid='{$nsid}'");
 updatecache('subsites');
 $stepeds['templates'] = 1;
 ocache2file($stepeds, 'stepeds');
 amessage('operatesuc', '?entry=subsetup&action=templates');