Esempio n. 1
0
function plugin_attach_action()
{
    global $vars, $_attach_messages;
    // Backward compatible
    if (isset($vars['openfile'])) {
        $vars['file'] = $vars['openfile'];
        $vars['pcmd'] = 'open';
    }
    if (isset($vars['delfile'])) {
        $vars['file'] = $vars['delfile'];
        $vars['pcmd'] = 'delete';
    }
    $pcmd = isset($vars['pcmd']) ? $vars['pcmd'] : '';
    $refer = isset($vars['refer']) ? $vars['refer'] : '';
    $pass = isset($vars['pass']) ? $vars['pass'] : NULL;
    $page = isset($vars['page']) ? $vars['page'] : '';
    if ($refer != '' && is_pagename($refer)) {
        if (in_array($pcmd, array('info', 'open', 'list'))) {
            check_readable($refer);
        } else {
            check_editable($refer);
        }
    }
    // Dispatch
    if (isset($_FILES['attach_file'])) {
        // Upload
        return attach_upload($_FILES['attach_file'], $refer, $pass);
    } else {
        switch ($pcmd) {
            case 'delete':
                /*FALLTHROUGH*/
            /*FALLTHROUGH*/
            case 'freeze':
            case 'unfreeze':
                if (PKWK_READONLY) {
                    die_message('PKWK_READONLY prohibits editing');
                }
        }
        switch ($pcmd) {
            case 'info':
                return attach_info();
            case 'delete':
                return attach_delete();
            case 'open':
                return attach_open();
            case 'list':
                return attach_list();
            case 'freeze':
                return attach_freeze(TRUE);
            case 'unfreeze':
                return attach_freeze(FALSE);
            case 'rename':
                return attach_rename();
            case 'upload':
                return attach_showform();
        }
        if ($page == '' || !is_page($page)) {
            return attach_list();
        } else {
            return attach_showform();
        }
    }
}
Esempio n. 2
0
function plugin_attach_action()
{
    global $vars, $_attach_messages, $_string;
    // Backward compatible
    if (isset($vars['openfile'])) {
        $vars['file'] = $vars['openfile'];
        $vars['pcmd'] = 'open';
    }
    if (isset($vars['delfile'])) {
        $vars['file'] = $vars['delfile'];
        $vars['pcmd'] = 'delete';
    }
    $pcmd = isset($vars['pcmd']) ? $vars['pcmd'] : NULL;
    $refer = isset($vars['refer']) ? $vars['refer'] : NULL;
    $pass = isset($vars['pass']) ? $vars['pass'] : NULL;
    $page = isset($vars['page']) ? $vars['page'] : $refer;
    if (!empty($page)) {
        $wiki = Factory::Wiki($page);
        if ($wiki->isValied()) {
            // メソッドによってパーミッションを分ける
            if (in_array($pcmd, array('info', 'open', 'list'))) {
                // 読み込み許可
                $wiki->checkReadable();
            } else {
                // 書き込み許可があるか
                $wiki->checkEditable();
            }
        }
    }
    if (in_array($pcmd, array('delete', 'freeze', 'unfreeze'))) {
        if (Auth::check_role('readonly')) {
            Utility::dieMessage($_string['error_prohibit']);
        }
    }
    switch ($pcmd) {
        case 'info':
            return attach_info();
        case 'delete':
            return attach_delete();
        case 'open':
            return attach_open();
        case 'list':
            return attach_list($page);
        case 'freeze':
            return attach_freeze(TRUE);
        case 'unfreeze':
            return attach_freeze(FALSE);
        case 'rename':
            return attach_rename();
        default:
        case 'upload':
            return attach_showform();
        case 'form':
            return array('msg' => str_replace('$1', $refer, $_attach_messages['msg_upload']), 'body' => attach_form($refer));
        case 'post':
            return attach_upload($page, $pass);
        case 'progress':
            return PluginRenderer::getUploadProgress();
    }
    return empty($page) || !$wiki->isValied() ? attach_list() : attach_showform();
}