Пример #1
0
            }
        }
        wpfb_print_json($props);
        exit;
    case 'new-cat':
        if (!WPFB_Core::CurUserCanCreateCat()) {
            die('-1');
        }
        wpfb_loadclass('Admin');
        $result = WPFB_Admin::InsertCategory($_POST);
        if (isset($result['error']) && $result['error']) {
            wpfb_print_json(array('error' => $result['error']));
            exit;
        }
        $cat = $result['cat'];
        $args = WPFB_Output::fileBrowserArgs($_POST['args']);
        $filesel = $args['type'] === 'fileselect';
        $catsel = $args['type'] === 'catselect';
        wpfb_print_json(array('error' => 0, 'id' => $cat->GetId(), 'name' => $cat->GetTitle(), 'id_str' => $args['idp'] . 'cat-' . $cat->cat_id, 'url' => $cat->GetUrl(), 'text' => WPFB_Output::fileBrowserCatItemText($catsel, $filesel, $cat, $args['onselect'], empty($_REQUEST['is_admin']) ? 'filebrowser' : 'filebrowser_admin'), 'classes' => $filesel || $catsel ? 'folder' : null));
        exit;
    case 'change-category':
        wpfb_loadclass('File', 'Admin');
        $item = WPFB_Item::GetById($_POST['id'], $_POST['type']);
        if ($item && $item->CurUserCanEdit()) {
            $res = $item->ChangeCategoryOrName($_POST['new_cat_id']);
            wpfb_print_json($res);
        } else {
            die('-1');
        }
        exit;
}
Пример #2
0
            die('-1');
        }
        wpfb_print_json(get_user_option('wpfb_set_' . $_REQUEST['name']));
        exit;
    case 'attach-file':
        wpfb_loadclass('File');
        if (!current_user_can('upload_files') || empty($_REQUEST['post_id']) || empty($_REQUEST['file_id']) || !($file = WPFB_File::GetFile($_REQUEST['file_id']))) {
            die('-1');
        }
        $file->SetPostId($_REQUEST['post_id']);
        die('1');
    case 'ftag_proposal':
        $tag = @$_REQUEST['tag'];
        $tags = (array) get_option(WPFB_OPT_NAME . '_ftags');
        // sorted!
        $props = array();
        if (($n = count($tags)) > 0) {
            $ks = array_keys($tags);
            for ($i = 0; $i < $n; $i++) {
                if (stripos($ks[$i], $tag) === 0) {
                    while ($i < $n && stripos($ks[$i], $tag) === 0) {
                        $props[] = array('t' => $ks[$i], 'n' => $tags[$ks[$i]]);
                        $i++;
                    }
                    //break;
                }
            }
        }
        wpfb_print_json($props);
        exit;
}