$editcat['upid'] = $cate['upid'];
     $editcat['dateline'] = TIMESTAMP;
     $editcat['uid'] = $_G['uid'];
     $editcat['username'] = $_G['username'];
     $_GET['catid'] = C::t('portal_category')->insert($editcat, true);
     $cachearr[] = 'diytemplatename';
 }
 if (!empty($domain)) {
     C::t('common_domain')->insert(array('domain' => $domain, 'domainroot' => $_G['setting']['domain']['root']['channel'], 'id' => $_GET['catid'], 'idtype' => 'channel'));
     $cachearr[] = 'setting';
 }
 if ($_GET['listprimaltplname'] && (empty($cate['primaltplname']) || $cate['primaltplname'] != $primaltplname)) {
     remakediytemplate($primaltplname, 'portal/list_' . $_GET['catid'], $_GET['catname'], getdiydirectory($cate['primaltplname']));
 }
 if ($cate['articleprimaltplname'] != $viewprimaltplname) {
     remakediytemplate($viewprimaltplname, 'portal/view_' . $_GET['catid'], $_GET['catname'] . '-' . cplang('portalcategory_viewpage'), getdiydirectory($cate['articleprimaltplname']));
 }
 include_once libfile('function/cache');
 updatecache('portalcategory');
 loadcache('portalcategory', true);
 $portalcategory = $_G['cache']['portalcategory'];
 require libfile('class/blockpermission');
 $tplpermsission =& template_permission::instance();
 $tplpre = 'portal/list_';
 require libfile('class/portalcategory');
 $categorypermsission =& portal_category::instance();
 if ($operation == 'add') {
     if ($cate['upid'] && $_GET['catid']) {
         if (!$editcat['notinheritedblock']) {
             $tplpermsission->remake_inherited_perm($tplpre . $_GET['catid'], $tplpre . $cate['upid']);
         }
     $editcat['upid'] = $cate['upid'];
     $editcat['dateline'] = TIMESTAMP;
     $editcat['uid'] = $_G['uid'];
     $editcat['username'] = $_G['username'];
     $_G['gp_catid'] = DB::insert('portal_category', $editcat, TRUE);
     $cachearr[] = 'diytemplatename';
 }
 if (!empty($domain)) {
     DB::insert('common_domain', array('domain' => $domain, 'domainroot' => addslashes($_G['setting']['domain']['root']['channel']), 'id' => $_G['gp_catid'], 'idtype' => 'channel'));
     $cachearr[] = 'setting';
 }
 if ($_G['gp_listprimaltplname'] && (empty($cate['primaltplname']) || $cate['primaltplname'] != $primaltplname)) {
     remakediytemplate($primaltplname, 'portal/list_' . $_G['gp_catid'], stripslashes($_G['gp_catname']));
 }
 if ($cate['articleprimaltplname'] != $viewprimaltplname) {
     remakediytemplate($viewprimaltplname, 'portal/view_' . $_G['gp_catid'], stripslashes($_G['gp_catname']) . '-' . cplang('portalcategory_viewpage'));
 }
 include_once libfile('function/cache');
 updatecache('portalcategory');
 loadcache('portalcategory', true);
 $portalcategory = $_G['cache']['portalcategory'];
 require libfile('class/blockpermission');
 $tplpermsission =& template_permission::instance();
 $tplpre = 'portal/list_';
 require libfile('class/portalcategory');
 $categorypermsission =& portal_category::instance();
 if ($operation == 'add') {
     if ($cate['upid'] && $_G['gp_catid']) {
         if (!$editcat['notinheritedblock']) {
             $tplpermsission->remake_inherited_perm($tplpre . $_G['gp_catid'], $tplpre . $cate['upid']);
         }