示例#1
0
function plugin_update_tinycode_do()
{
    global $defaultpage;
    //dbがなければ、自動的に作られる
    add_tinycode($defaultpage);
    //file add
    $exists = get_existpages();
    $tcodes = get_tiny_table();
    $list = array_diff($exists, $tcodes);
    foreach ($list as $v) {
        add_tinycode($v);
    }
    //file del
    $tcodes = get_tiny_table();
    $list = array_diff($tcodes, $exists);
    foreach ($list as $v) {
        del_tinycode($v);
    }
}
示例#2
0
function plugin_rename_proceed($pages, $files, $exists, $redirect = TRUE)
{
    global $now;
    $qm = get_qm();
    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);
            // linkデータベースを更新する BugTrack/327 arino
            links_update($old);
            links_update($new);
        }
    }
    $postdata = get_source(PLUGIN_RENAME_LOGPAGE);
    $postdata[] = '*' . $now . "\n";
    if (plugin_rename_getvar('method') == 'regex') {
        $postdata[] = '-' . $qm->m['plg_rename']['regex'] . "\n";
        $postdata[] = '--From:[[' . plugin_rename_getvar('src') . ']]' . "\n";
        $postdata[] = '--To:[[' . plugin_rename_getvar('dst') . ']]' . "\n";
    } else {
        $postdata[] = '-' . $qm->m['plg_rename']['page'] . "\n";
        $postdata[] = '--From:[[' . plugin_rename_getvar('refer') . ']]' . "\n";
        $postdata[] = '--To:[[' . plugin_rename_getvar('page') . ']]' . "\n";
    }
    if (!empty($exists)) {
        $postdata[] = "\n" . $qm->m['plg_rename']['result'] . "\n";
        foreach ($exists as $page => $arr) {
            $postdata[] = '-' . decode($page) . $qm->m['plg_rename']['arrow'] . decode($pages[$page]) . "\n";
            foreach ($arr as $ofile => $nfile) {
                $postdata[] = '--' . $ofile . $qm->m['plg_rename']['arrow'] . $nfile . "\n";
            }
        }
        $postdata[] = '----' . "\n";
    }
    foreach ($pages as $old => $new) {
        $postdata[] = '-' . decode($old) . $qm->m['plg_rename']['arrow'] . decode($new) . "\n";
        // tinycodeの追加
        add_tinycode(decode($new));
    }
    // 更新の衝突はチェックしない。
    // ファイルの書き込み
    page_write(PLUGIN_RENAME_LOGPAGE, join('', $postdata));
    //リダイレクト
    $page = plugin_rename_getvar('page');
    if ($page == '') {
        $page = PLUGIN_RENAME_LOGPAGE;
    }
    if ($redirect) {
        pkwk_headers_sent();
        header('Location: ' . get_script_uri() . '?' . rawurlencode($page));
        exit;
    }
}
示例#3
0
文件: file.php 项目: big2men/qhm
function file_write($dir, $page, $str, $notimestamp = FALSE)
{
    global $notify, $notify_diff_only, $notify_subject;
    global $whatsdeleted, $maxshow_deleted;
    global $qblog_page_re;
    $qm = get_qm();
    if (PKWK_READONLY) {
        return;
    }
    // Do nothing
    if ($dir != DATA_DIR && $dir != DIFF_DIR) {
        die($qm->m['file']['err_invalid_dir']);
    }
    $page = strip_bracket($page);
    $file = $dir . encode($page) . '.txt';
    $file_exists = file_exists($file);
    // ----
    // Record last modified date for QHM cache func.
    $lm_file = CACHE_DIR . QHM_LASTMOD;
    file_put_contents($lm_file, date('Y-m-d H:i:s'));
    // ----
    // Delete?
    if ($dir == DATA_DIR && $str === '') {
        // Page deletion
        if (!$file_exists) {
            return;
        }
        // Ignore null posting for DATA_DIR
        // Update RecentDeleted (Add the $page)
        add_recent($page, $whatsdeleted, '', $maxshow_deleted);
        //QBlog 記事 であれば、削除処理を呼び出す
        if (preg_match($qblog_page_re, $page)) {
            qblog_remove_post($page);
        }
        // Remove the page
        unlink($file);
        // Update RecentDeleted, and remove the page from RecentChanges
        lastmodified_add($whatsdeleted, $page);
        // Clear is_page() cache
        is_page($page, TRUE);
        return;
    } else {
        if ($dir == DIFF_DIR && $str === " \n") {
            return;
            // Ignore null posting for DIFF_DIR
        }
    }
    // ----
    // File replacement (Edit)
    if (!is_pagename($page)) {
        die_message(str_replace('$1', htmlspecialchars($page), str_replace('$2', 'WikiName', $qm->m['fmt_err_invalidiwn'])));
    }
    $str = rtrim(preg_replace('/' . "\r" . '/', '', $str)) . "\n";
    $timestamp = $file_exists && $notimestamp ? filemtime($file) : FALSE;
    $fp = fopen($file, 'a') or die($qm->replace('file.err_not_writable', h(basename($dir)), encode($page)));
    set_file_buffer($fp, 0);
    flock($fp, LOCK_EX);
    ftruncate($fp, 0);
    rewind($fp);
    fputs($fp, $str);
    flock($fp, LOCK_UN);
    fclose($fp);
    if ($timestamp) {
        pkwk_touch_file($file, $timestamp);
    }
    // Optional actions
    if ($dir == DATA_DIR) {
        // Update RecentChanges (Add or renew the $page)
        if ($timestamp === FALSE) {
            lastmodified_add($page);
        }
        add_tinycode($page);
        // Command execution per update
        if (defined('PKWK_UPDATE_EXEC') && PKWK_UPDATE_EXEC) {
            system(PKWK_UPDATE_EXEC . ' > /dev/null &');
        }
    } else {
        if ($dir == DIFF_DIR && $notify) {
            if ($notify_diff_only) {
                $str = preg_replace('/^[^-+].*\\n/m', '', $str);
            }
            $footer['ACTION'] = 'Page update';
            $footer['PAGE'] =& $page;
            $footer['URI'] = get_script_uri() . '?' . rawurlencode($page);
            $footer['USER_AGENT'] = TRUE;
            $footer['REMOTE_ADDR'] = TRUE;
            if (isset($_SESSION['usr'])) {
                $str .= "\n\n " . $qm->replace('file.lbl_editor', $_SESSION['usr']) . "\n";
            }
            pkwk_mail_notify($notify_subject, $str, $footer) or die($qm->m['file']['err_mail_failed']);
        }
    }
    is_page($page, TRUE);
    // Clear is_page() cache
}