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(); } } } } } } }
function plugin_rename_action() { global $_string; // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits this'); if (Auth::check_role('readonly')) { die_message($_string['prohibit']); } $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'); } else { if (preg_match(Wiki::INVALIED_PAGENAME_PATTERN, $page)) { die_message($_string['illegal_chars']); } } } // Phase one or three return plugin_rename_regex($arr0, $arr1); } else { // $method == 'page' $page = plugin_rename_getvar('page'); $refer = plugin_rename_getvar('refer'); // Check Illigal Chars if (preg_match(Wiki::INVALIED_PAGENAME_PATTERN, $page)) { die_message($_string['illegal_chars']); } if (empty($refer)) { return plugin_rename_phase1(); } else { if (!is_page($refer)) { return plugin_rename_phase1('notpage', $refer); } else { if (is_cantedit($refer)) { return plugin_rename_phase1('norename', $refer); } else { if (empty($page) && is_page($refer)) { return plugin_rename_phase2(); } else { if (!is_pagename($page)) { return plugin_rename_phase2('notvalid'); } else { // Phase three return plugin_rename_refer(); } } } } } } }