}
    $ts = $_POST['base_template_set'] == 'path_info' ? 'path_info/' : 'default/';
    fudcopy($root . $ts, $root_nn, '!.*!', true);
    umask($u);
}
if (isset($_POST['thm_theme']) && !$edit) {
    $thm = new fud_theme();
    $thm->add();
    compile_all($thm->theme, $thm->lang, $thm->name);
} else {
    if (isset($_POST['edit'])) {
        $thm = new fud_theme();
        if ($edit == 1) {
            $thm->name = 'default';
        }
        $thm->sync((int) $_POST['edit']);
        compile_all($thm->theme, $thm->lang, $thm->name);
        $edit = '';
    } else {
        if (isset($_GET['rebuild']) && ($data = db_saq('SELECT theme, lang, name FROM ' . $DBHOST_TBL_PREFIX . 'themes WHERE id=' . (int) $_GET['rebuild']))) {
            compile_all($data[0], $data[1], $data[2]);
        } else {
            if (isset($_GET['edit']) && ($c = db_arr_assoc('SELECT * FROM ' . $DBHOST_TBL_PREFIX . 'themes WHERE id=' . $edit))) {
                foreach ($c as $k => $v) {
                    ${'thm_' . $k} = $v;
                }
                $thm_t_default = $c['theme_opt'] & 2;
                $thm_enabled = $c['theme_opt'] & 1;
            } else {
                if (isset($_GET['del']) && (int) $_GET['del'] > 1) {
                    fud_theme::delete((int) $_GET['del']);