Ejemplo n.º 1
0
function plugin_rename_phase4($pages, $files, $exists)
{
    global $now, $_rename_messages;
    if (plugin_rename_getvar('exist') == '') {
        foreach ($exists as $key => $arr) {
            unset($files[$key]);
        }
    }
    set_time_limit(0);
    foreach ($files as $page => $arr) {
        foreach ($arr as $old => $new) {
            if (isset($exists[$page][$old]) && $exists[$page][$old]) {
                unlink($new);
            }
            rename($old, $new);
            // Update link database (BugTrack/327) arino
            //links_update($old);
            //links_update($new);
            $links = new Relational();
            $links->update($old);
            $links->update($new);
        }
    }
    $wiki = Factory::Wiki(PLUGIN_RENAME_LOGPAGE);
    $postdata = $wiki->get();
    $postdata[] = '*' . $now . "\n";
    if (plugin_rename_getvar('method') == 'regex') {
        $postdata[] = '-' . $_rename_messages['msg_regex'] . "\n";
        $postdata[] = '--From:[[' . plugin_rename_getvar('src') . ']]' . "\n";
        $postdata[] = '--To:[[' . plugin_rename_getvar('dst') . ']]' . "\n";
    } else {
        $postdata[] = '-' . $_rename_messages['msg_page'] . "\n";
        $postdata[] = '--From:[[' . plugin_rename_getvar('refer') . ']]' . "\n";
        $postdata[] = '--To:[[' . plugin_rename_getvar('page') . ']]' . "\n";
    }
    if (!empty($exists)) {
        $postdata[] = "\n" . $_rename_messages['msg_result'] . "\n";
        foreach ($exists as $page => $arr) {
            $postdata[] = '-' . decode($page) . $_rename_messages['msg_arrow'] . decode($pages[$page]) . "\n";
            foreach ($arr as $ofile => $nfile) {
                $postdata[] = '--' . $ofile . $_rename_messages['msg_arrow'] . $nfile . "\n";
            }
        }
        $postdata[] = '----' . "\n";
    }
    foreach ($pages as $old => $new) {
        $postdata[] = '-' . decode($old) . $_rename_messages['msg_arrow'] . decode($new) . "\n";
    }
    // At this time, collision detection is not implemented
    $wiki->set($postdata);
    //未定義
    //	cache_timestamp_touch();
    $page = plugin_rename_getvar('page');
    if ($page == '') {
        $page = PLUGIN_RENAME_LOGPAGE;
    }
    // Redirection
    if (!pkwk_headers_sent()) {
        header('Location: ' . get_page_location_uri($page));
    }
    exit;
}