Пример #1
0
function qblog_update($force = FALSE)
{
    static $updated = FALSE;
    if ($updated) {
        return;
    }
    $updated = TRUE;
    // update caches
    // qblog_recent.dat
    // qblog_categories.dat
    // qblog_archived.dat
    // *.qbc.dat
    qblog_update_post($force);
    qblog_update_recent($force);
    qblog_update_categories($force);
    qblog_update_archives($force);
    return;
}
Пример #2
0
function plugin_qblog_rename_category()
{
    global $vars, $qblog_default_cat;
    $vars['hash'] = 'category';
    // カテゴリの変更元と変更する名前を取得
    $newname = trim($vars['cat_name']);
    $orgname = trim($vars['org_cat_name']);
    if ($newname == '') {
        $vars['qblog_error'] = '新しいカテゴリー名を指定してください。';
        return FALSE;
    }
    $orgfile = CACHEQBLOG_DIR . encode($orgname) . '.qbc.dat';
    $newfile = CACHEQBLOG_DIR . encode($newname) . '.qbc.dat';
    if (file_exists($newfile)) {
        $vars['qblog_error'] = '指定したカテゴリーは、既に存在します。';
        return FALSE;
    }
    // デフォルトカテゴリの登録
    if ($orgname == $qblog_default_cat) {
        if (exist_plugin("qhmsetting")) {
            $params = array();
            $params['qblog_default_cat'] = $newname;
            $_SESSION['qhmsetting'] = $params;
            plugin_qhmsetting_update_ini();
            $qblog_default_cat = $newname;
        } else {
            $vars['qblog_error'] = 'このバージョンでは、初期カテゴリー名が変更できません。';
            return FALSE;
        }
    }
    // カテゴリの変更元の記事を取得
    $pages = array();
    if (file_exists($orgfile)) {
        $pages = explode("\n", file_get_contents($orgfile));
    }
    // ページ名.qbp.datのカテゴリ名を変更
    foreach ($pages as $page) {
        $file = CACHEQBLOG_DIR . encode($page) . '.qbp.dat';
        if (file_exists($file)) {
            $data = unserialize(file_get_contents($file));
            $data['category'] = $newname;
            file_put_contents($file, serialize($data), LOCK_EX);
        }
    }
    // カテゴリファイルのrename
    rename($orgfile, $newfile);
    // qblog_categories.dat の変更
    qblog_update_categories(TRUE);
    $vars['phase'] = 'rename_category';
    return TRUE;
}