Ejemplo n.º 1
0
function plugin_rename_action()
{
    global $whatsnew;
    // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits this');
    if (auth::check_role('readonly')) {
        die_message('PKWK_READONLY prohibits this');
    }
    $method = plugin_rename_getvar('method');
    if ($method == 'regex') {
        $src = plugin_rename_getvar('src');
        if ($src == '') {
            return plugin_rename_phase1();
        }
        $src_pattern = '/' . preg_quote($src, '/') . '/';
        $arr0 = preg_grep($src_pattern, auth::get_existpages());
        if (!is_array($arr0) || empty($arr0)) {
            return plugin_rename_phase1('nomatch');
        }
        $dst = plugin_rename_getvar('dst');
        $arr1 = preg_replace($src_pattern, $dst, $arr0);
        foreach ($arr1 as $page) {
            if (!is_pagename($page)) {
                return plugin_rename_phase1('notvalid');
            }
        }
        return plugin_rename_regex($arr0, $arr1);
    } else {
        // $method == 'page'
        $page = plugin_rename_getvar('page');
        $refer = plugin_rename_getvar('refer');
        if ($refer === '') {
            return plugin_rename_phase1();
        } else {
            if (!is_page($refer)) {
                return plugin_rename_phase1('notpage', $refer);
            } else {
                if ($refer === $whatsnew) {
                    return plugin_rename_phase1('norename', $refer);
                } else {
                    if ($page === '' || $page === $refer) {
                        return plugin_rename_phase2();
                    } else {
                        if (!is_pagename($page)) {
                            return plugin_rename_phase2('notvalid');
                        } else {
                            return plugin_rename_refer();
                        }
                    }
                }
            }
        }
    }
}
Ejemplo n.º 2
0
function plugin_rename_refer()
{
    $page = plugin_rename_getvar('page');
    $refer = plugin_rename_getvar('refer');
    if (is_cantedit($page)) {
        return plugin_rename_phase2('notvalid');
    }
    $pages[encode($refer)] = encode($page);
    if (plugin_rename_getvar('related') != '') {
        $from = strip_bracket($refer);
        $to = strip_bracket($page);
        foreach (plugin_rename_getrelated($refer) as $_page) {
            $pages[encode($_page)] = encode(str_replace($from, $to, $_page));
        }
    }
    return plugin_rename_phase3($pages);
}