$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']);
             } else {
                 if (isset($_GET['optimize']) && $is_tok && ($t_name = q_singleval('SELECT name FROM ' . $DBHOST_TBL_PREFIX . 'themes WHERE id=' . (int) $_GET['optimize']))) {
                     /* optimize *.php files */
                     $path = $WWW_ROOT_DISK . 'theme/' . $t_name;
                     $dir = opendir($path);
                     $path .= '/';
                     while ($f = readdir($dir)) {
                         if ($f == '.' || $f == '..') {
                             continue;
                         }
                         if (@is_file($path . $f) && substr($f, -4) == '.php') {
                             $toks = token_get_all(file_get_contents($path . $f));
                             while (get_func_usage($toks)) {
                             }
                             clean_code($path . $f, $toks);