[P2-php-svn] [770] expack:

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 1月 11日 (月) 02:32:45 JST


Revision: 770
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=770
Author:   rsk
Date:     2010-01-11 02:32:45 +0900 (Mon, 11 Jan 2010)

Log Message:
-----------
expack:
- P2KeyValueStore のラッパーとして P2DataStore ファミリーを追加。
- パスワード変更時に確認のため新しいパスワードを2回入力するようにした。
- お気にスレや最近読んだスレ等の更新に時間がかかるリストは
  更新ボタンの2度押しを予防するようにした。
- P2DataStore のクリーンアップと、SQLite 3 ベースの全文検索のため
  PHP 5.3 専用にすることも検討している。
  (PHP 5.3 のバンドル版 libsqlite3 は FTS3 が有効でビルドされるが
   PHP 5.2 のものは FTS3 をサポートしていないバージョンである)

Modified Paths:
--------------
    p2ex/trunk/conf/conf.inc.php
    p2ex/trunk/lib/P2KeyValueStore/Binary.php
    p2ex/trunk/lib/P2KeyValueStore/Compressing.php
    p2ex/trunk/lib/P2KeyValueStore/Serializing.php
    p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php
    p2ex/trunk/lib/P2KeyValueStore.php
    p2ex/trunk/lib/P2Util.php
    p2ex/trunk/lib/post_form_options.inc.php
    p2ex/trunk/lib/sb_toolbar.inc.php
    p2ex/trunk/login.php
    p2ex/trunk/post.php

Added Paths:
-----------
    p2ex/trunk/lib/P2DataStore/
    p2ex/trunk/lib/P2DataStore/AbstractDataStore.php
    p2ex/trunk/lib/P2DataStore/CookieStore.php
    p2ex/trunk/lib/P2DataStore/PostDataStore.php


-------------- next part --------------
Modified: p2ex/trunk/conf/conf.inc.php
===================================================================
--- p2ex/trunk/conf/conf.inc.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/conf/conf.inc.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -319,7 +319,8 @@
     $_conf['orig_favita_brd']   = $_conf['favita_brd'];
     $_conf['orig_favlist_idx']  = $_conf['favlist_idx'];
 
-    $_conf['cookie_file_path']  = $_conf['cookie_dir'] . $DIR_SEP . 'p2_cookies.sqlite3';
+    $_conf['cookie_db_path']    = $_conf['cookie_dir'] . $DIR_SEP . 'p2_cookies.sqlite3';
+    $_conf['post_db_path']      = $_conf['cookie_dir'] . $DIR_SEP . 'p2_post_data.sqlite3';
 
     // •â³
     if ($_conf['expack.use_pecl_http'] && !extension_loaded('http')) {

Added: p2ex/trunk/lib/P2DataStore/AbstractDataStore.php
===================================================================
--- p2ex/trunk/lib/P2DataStore/AbstractDataStore.php	                        (rev 0)
+++ p2ex/trunk/lib/P2DataStore/AbstractDataStore.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -0,0 +1,162 @@
+<?php
+/**
+ * rep2expack - P2KeyValueStore‚ðƒ‰ƒbƒv‚·‚é
+ * ƒ†[ƒeƒBƒŠƒeƒBƒNƒ‰ƒX‚Ì‚½‚ß‚ÌŠî’ê’ŠÛƒNƒ‰ƒX
+ */
+
+require_once P2_LIB_DIR . '/P2KeyValueStore.php';
+
+// {{{ AbstractDataStore
+
+abstract class AbstractDataStore
+{
+    // {{{ properties
+
+    static private $_kvs = array();
+
+    // }}}
+    // {{{ _getKVS()
+
+    /**
+     * ƒf[ƒ^‚ð•Û‘¶‚·‚éP2KeyValueStoreƒIƒuƒWƒFƒNƒg‚ðŽæ“¾‚·‚é
+     *
+     * @param string $databasePath
+     * @param string $type
+     * @return P2KeyValueStore
+     */
+    static protected function _getKVS($databasePath,
+                                      $type = P2KeyValueStore::KVS_SERIALIZING)
+    {
+        global $_conf;
+
+        if (array_key_exists($databasePath, self::$_kvs)) {
+            return self::$_kvs[$databasePath];
+        }
+
+        if (!file_exists($databasePath) && !is_dir(dirname($databasePath))) {
+            FileCtl::mkdir_for($databasePath);
+        }
+
+        try {
+            $kvs = P2KeyValueStore::getStore($databasePath, $type);
+            self::$_kvs[$databasePath] = $kvs;
+        } catch (Exception $e) {
+            p2die(get_class($e) . ': ' . $e->getMessage());
+        }
+
+        return $kvs;
+    }
+
+    // }}}
+    // {{{ getKVS()
+
+    /**
+     * _getKVS() ‚ðŒÄ‚яo‚µ‚ÄP2KeyValueStoreƒIƒuƒWƒFƒNƒg‚ðŽæ“¾‚·‚é
+     *
+     * Œ»Ý‚Í self::getKVS() ‚Ì“s‡‚Å‚±‚ê‚æ‚艺‚̃ƒ\ƒbƒh‚ð
+     * ƒTƒuƒNƒ‰ƒX‚ɃRƒsƒy‚Æ‚¢‚¤•ÛŽç«‚ª‹É‚߂Ĉ«‚¢ŽÀ‘•‚Æ‚È‚Á‚Ä‚¢‚éB
+     * «—ˆ‚Í PHP 5.3 ”›‚è‚É‚µ‚Ä static::getKVS() ‚ɕύX‚µ‚½‚¢B
+     *
+     * @param void
+     * @return P2KeyValueStore
+     */
+    abstract static public function getKVS();
+
+    // }}}
+    // {{{ get()
+
+    /**
+     * ƒf[ƒ^‚ðŽæ“¾‚·‚é
+     *
+     * @param string $key
+     * @return mixed
+     * @see P2KeyValueStore::get()
+     */
+    static public function get($key)
+    {
+        return self::getKVS()->get($key);
+    }
+
+    // }}}
+    // {{{ set()
+
+    /**
+     * ƒf[ƒ^‚ð•Û‘¶‚·‚é
+     *
+     * @param string $key
+     * @param mixed $value
+     * @return bool
+     * @see P2KeyValueStore::exists(),
+     *      P2KeyValueStore::set(),
+     *      P2KeyValueStore::update()
+     */
+    static public function set($key, $value)
+    {
+        $kvs = self::getKVS();
+        if ($kvs->exists($key)) {
+            return $kvs->update($key, $value);
+        } else {
+            return $kvs->set($key, $value);
+        }
+    }
+
+    // }}}
+    // {{{ delete()
+
+    /**
+     * ƒf[ƒ^‚ðíœ‚·‚é
+     *
+     * @param string $key
+     * @return bool
+     * @see P2KeyValueStore::delete()
+     */
+    static public function delete($key)
+    {
+        return self::getKVS()->delete($key);
+    }
+
+    // }}}
+    // {{{ clear()
+
+    /**
+     * ‚·‚ׂẴf[ƒ^‚Ü‚½‚̓L[‚ªŽw’肳‚ꂽÚ“ªŽ«‚ÅŽn‚Ü‚éƒf[ƒ^‚ðíœ‚·‚é
+     *
+     * @param string $prefix
+     * @return int
+     * @see P2KeyValueStore::clear()
+     */
+    static public function clear($prefix = null)
+    {
+        $kvs = self::getKVS();
+
+        if ($prefix === null) {
+            return $kvs->clear();
+        }
+
+        $pattern = str_replace(array('%', '_'), array('\\%', '\\_'), $kvs->encodeKey($prefix));
+        $stmt = $kvs->prepare('DELETE FROM $__table WHERE arkey LIKE :pattern ESCAPE :escape', true);
+        $stmt->bindValue(':pattern', $pattern);
+        $stmt->bindValue(':escape', '\\');
+
+        if ($stmt->execute()) {
+            return $stmt->rowCount();
+        } else {
+            return false;
+        }
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Added: p2ex/trunk/lib/P2DataStore/CookieStore.php
===================================================================
--- p2ex/trunk/lib/P2DataStore/CookieStore.php	                        (rev 0)
+++ p2ex/trunk/lib/P2DataStore/CookieStore.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -0,0 +1,124 @@
+<?php
+/**
+ * rep2expack - CookieŠÇ—ƒNƒ‰ƒX
+ */
+
+require_once P2_LIB_DIR . '/P2DataStore/AbstractDataStore.php';
+
+// {{{ CookieStore
+
+class CookieStore extends AbstractDataStore
+{
+    // {{{ getKVS()
+
+    /**
+     * Cookie‚ð•Û‘¶‚·‚éP2KeyValueStoreƒIƒuƒWƒFƒNƒg‚ðŽæ“¾‚·‚é
+     *
+     * @param void
+     * @return P2KeyValueStore
+     */
+    static public function getKVS()
+    {
+        return self::_getKVS($GLOBALS['_conf']['cookie_db_path']);
+    }
+
+    // }}}
+    // {{{ AbstractDataStore.php ‚©‚ç‚̃Rƒsƒy / PHP 5.3 ‚Ì’x‰„Ã“I‘©”›‚ðŽg‚Á‚č폜‚µ‚½‚¢
+    // {{{ get()
+
+    /**
+     * ƒf[ƒ^‚ðŽæ“¾‚·‚é
+     *
+     * @param string $key
+     * @return mixed
+     * @see P2KeyValueStore::get()
+     */
+    static public function get($key)
+    {
+        return self::getKVS()->get($key);
+    }
+
+    // }}}
+    // {{{ set()
+
+    /**
+     * ƒf[ƒ^‚ð•Û‘¶‚·‚é
+     *
+     * @param string $key
+     * @param mixed $value
+     * @return bool
+     * @see P2KeyValueStore::exists(),
+     *      P2KeyValueStore::set(),
+     *      P2KeyValueStore::update()
+     */
+    static public function set($key, $value)
+    {
+        $kvs = self::getKVS();
+        if ($kvs->exists($key)) {
+            return $kvs->update($key, $value);
+        } else {
+            return $kvs->set($key, $value);
+        }
+    }
+
+    // }}}
+    // {{{ delete()
+
+    /**
+     * ƒf[ƒ^‚ðíœ‚·‚é
+     *
+     * @param string $key
+     * @return bool
+     * @see P2KeyValueStore::delete()
+     */
+    static public function delete($key)
+    {
+        return self::getKVS()->delete($key);
+    }
+
+    // }}}
+    // {{{ clear()
+
+    /**
+     * ‚·‚ׂẴf[ƒ^‚Ü‚½‚̓L[‚ªŽw’肳‚ꂽÚ“ªŽ«‚ÅŽn‚Ü‚éƒf[ƒ^‚ðíœ‚·‚é
+     *
+     * @param string $prefix
+     * @return int
+     * @see P2KeyValueStore::clear()
+     */
+    static public function clear($prefix = null)
+    {
+        $kvs = self::getKVS();
+
+        if ($prefix === null) {
+            return $kvs->clear();
+        }
+
+        $pattern = str_replace(array('%', '_'), array('\\%', '\\_'), $kvs->encodeKey($prefix));
+        $stmt = $kvs->prepare('DELETE FROM $__table WHERE arkey LIKE :pattern ESCAPE :escape', true);
+        $stmt->bindValue(':pattern', $pattern);
+        $stmt->bindValue(':escape', '\\');
+
+        if ($stmt->execute()) {
+            return $stmt->rowCount();
+        } else {
+            return false;
+        }
+    }
+
+    // }}}
+    // }}} ƒRƒsƒy‚±‚±‚Ü‚Å
+}
+
+// }}}
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Added: p2ex/trunk/lib/P2DataStore/PostDataStore.php
===================================================================
--- p2ex/trunk/lib/P2DataStore/PostDataStore.php	                        (rev 0)
+++ p2ex/trunk/lib/P2DataStore/PostDataStore.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -0,0 +1,219 @@
+<?php
+/**
+ * rep2expack - ‘‚«ž‚݃f[ƒ^ŠÇ—ƒNƒ‰ƒX
+ */
+
+require_once P2_LIB_DIR . '/P2DataStore/AbstractDataStore.php';
+
+// {{{ PostDataStore
+
+class PostDataStore extends AbstractDataStore
+{
+    // {{{ getKVS()
+
+    /**
+     * ‘‚«ž‚݃f[ƒ^‚ð•Û‘¶‚·‚éP2KeyValueStoreƒIƒuƒWƒFƒNƒg‚ðŽæ“¾‚·‚é
+     *
+     * @param void
+     * @return P2KeyValueStore
+     */
+    static public function getKVS()
+    {
+        return self::_getKVS($GLOBALS['_conf']['post_db_path']);
+    }
+
+    // }}}
+    // {{{ AbstractDataStore.php ‚©‚ç‚̃Rƒsƒy / PHP 5.3 ‚Ì’x‰„Ã“I‘©”›‚ðŽg‚Á‚č폜‚µ‚½‚¢
+    // {{{ get()
+
+    /**
+     * ƒf[ƒ^‚ðŽæ“¾‚·‚é
+     *
+     * @param string $key
+     * @return mixed
+     * @see P2KeyValueStore::get()
+     */
+    static public function get($key)
+    {
+        return self::getKVS()->get($key);
+    }
+
+    // }}}
+    // {{{ set()
+
+    /**
+     * ƒf[ƒ^‚ð•Û‘¶‚·‚é
+     *
+     * @param string $key
+     * @param mixed $value
+     * @return bool
+     * @see P2KeyValueStore::exists(),
+     *      P2KeyValueStore::set(),
+     *      P2KeyValueStore::update()
+     */
+    static public function set($key, $value)
+    {
+        $kvs = self::getKVS();
+        if ($kvs->exists($key)) {
+            return $kvs->update($key, $value);
+        } else {
+            return $kvs->set($key, $value);
+        }
+    }
+
+    // }}}
+    // {{{ delete()
+
+    /**
+     * ƒf[ƒ^‚ðíœ‚·‚é
+     *
+     * @param string $key
+     * @return bool
+     * @see P2KeyValueStore::delete()
+     */
+    static public function delete($key)
+    {
+        return self::getKVS()->delete($key);
+    }
+
+    // }}}
+    // {{{ clear()
+
+    /**
+     * ‚·‚ׂẴf[ƒ^‚Ü‚½‚̓L[‚ªŽw’肳‚ꂽÚ“ªŽ«‚ÅŽn‚Ü‚éƒf[ƒ^‚ðíœ‚·‚é
+     *
+     * @param string $prefix
+     * @return int
+     * @see P2KeyValueStore::clear()
+     */
+    static public function clear($prefix = null)
+    {
+        $kvs = self::getKVS();
+
+        if ($prefix === null) {
+            return $kvs->clear();
+        }
+
+        $pattern = str_replace(array('%', '_'), array('\\%', '\\_'), $kvs->encodeKey($prefix));
+        $stmt = $kvs->prepare('DELETE FROM $__table WHERE arkey LIKE :pattern ESCAPE :escape', true);
+        $stmt->bindValue(':pattern', $pattern);
+        $stmt->bindValue(':escape', '\\');
+
+        if ($stmt->execute()) {
+            return $stmt->rowCount();
+        } else {
+            return false;
+        }
+    }
+
+    // }}}
+    // }}} ƒRƒsƒy‚±‚±‚Ü‚Å
+    // {{{ getKeyForBackup()
+
+    /**
+     * ‘‚«ž‚݃oƒbƒNƒAƒbƒv‚Ì‚½‚߂̃L[‚ðŽæ“¾‚·‚é
+     *
+     * @param string $host
+     * @param string $bbs
+     * @param numeric $key
+     * @param bool $newthread
+     */
+    static public function getKeyForBackup($host, $bbs, $key, $newthread = false)
+    {
+        if ($newthread) {
+            $key = 'new';
+        }
+        return 'backup:' . self::_getKeySuffix($host, $bbs, $key);
+    }
+
+    // }}}
+    // {{{ getKeyForConfig()
+
+    /**
+     * ”Â/ƒXƒŒ‚²‚Ƃ̏‘‚«ž‚ݐݒè‚Ì‚½‚߂̃L[‚ðŽæ“¾‚·‚é
+     *
+     * @param string $host
+     * @param string $bbs
+     * @param numeric $key
+     * @param bool $newthread
+     */
+    static public function getKeyForConfig($host, $bbs, $key = null)
+    {
+        if ($key === null) {
+            $key = '';
+        }
+        return 'config:' . self::_getKeySuffix($host, $bbs, $key);
+    }
+
+    // }}}
+    // {{{ _getKeySuffix()
+
+    /**
+     * ƒL[‚̐ڔöŽ«‚𐶐¬‚·‚é
+     *
+     * @param string $host
+     * @param string $bbs
+     * @param string $key
+     * @param bool $newthread
+     */
+    static private function _getKeySuffix($host, $bbs, $key)
+    {
+        global $_login;
+
+        return rtrim($_login->user_u . P2Util::pathForHostBbs($host, $bbs) . $key, '/');
+    }
+
+    // }}}
+    // {{{ clearBackup()
+
+    /**
+     * ‚·‚ׂĂ̏‘‚«ž‚݃oƒbƒNƒAƒbƒv‚Ü‚½‚Í
+     * Žw’肳‚ꂽƒ†[ƒU[‚̏‘‚«ž‚݃oƒbƒNƒAƒbƒv‚ðíœ‚·‚é
+     *
+     * @param string $user
+     * @return int
+     * @see AbstractDataStore::clear()
+     */
+    static public function clearBackup($user = null)
+    {
+        $prefix = 'backup:';
+        if ($user !== null) {
+            $prefix .= $user . '/';
+        }
+        return self::clear($prefix);
+    }
+
+    // }}}
+    // {{{ clearConfig()
+
+    /**
+     * ‚·‚ׂĂ̏‘‚«ž‚ݐݒè‚Ü‚½‚ÍŽw’肳‚ꂽƒ†[ƒU[‚̏‘‚«ž‚ݐݒè‚ðíœ‚·‚é
+     *
+     * @param string $user
+     * @return int
+     * @see AbstractDataStore::clear()
+     */
+    static public function clearConfig($user = null)
+    {
+        $prefix = 'config:';
+        if ($user !== null) {
+            $prefix .= $user . '/';
+        }
+        return self::clear($prefix);
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Modified: p2ex/trunk/lib/P2KeyValueStore/Binary.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Binary.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/lib/P2KeyValueStore/Binary.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -8,7 +8,7 @@
  */
 class P2KeyValueStore_Binary extends P2KeyValueStore
 {
-    // {{{ _encodeValue()
+    // {{{ encodeValue()
 
     /**
      * ƒf[ƒ^‚ðBase64ƒGƒ“ƒR[ƒh‚·‚é
@@ -16,13 +16,13 @@
      * @param string $value
      * @return string
      */
-    protected function _encodeValue($value)
+    public function encodeValue($value)
     {
         return base64_encode($value);
     }
 
     // }}}
-    // {{{ _decodeValue()
+    // {{{ decodeValue()
 
     /**
      * ƒf[ƒ^‚ðBase64ƒfƒR[ƒh‚·‚é
@@ -30,7 +30,7 @@
      * @param string $value
      * @return string
      */
-    protected function _decodeValue($value)
+    public function decodeValue($value)
     {
         return base64_decode($value);
     }

Modified: p2ex/trunk/lib/P2KeyValueStore/Compressing.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Compressing.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/lib/P2KeyValueStore/Compressing.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -8,7 +8,7 @@
  */
 class P2KeyValueStore_Compressing extends P2KeyValueStore_Binary
 {
-    // {{{ _encodeValue()
+    // {{{ encodeValue()
 
     /**
      * ƒf[ƒ^‚ðˆ³k‚·‚é
@@ -16,13 +16,13 @@
      * @param string $value
      * @return string
      */
-    protected function _encodeValue($value)
+    public function encodeValue($value)
     {
-        return parent::_encodeValue(gzdeflate($value, 6));
+        return parent::encodeValue(gzdeflate($value, 6));
     }
 
     // }}}
-    // {{{ _decodeValue()
+    // {{{ decodeValue()
 
     /**
      * ƒf[ƒ^‚ð“WŠJ‚·‚é
@@ -30,9 +30,9 @@
      * @param string $value
      * @return string
      */
-    protected function _decodeValue($value)
+    public function decodeValue($value)
     {
-        return gzinflate(parent::_decodeValue($value));
+        return gzinflate(parent::decodeValue($value));
     }
 
     // }}}

Modified: p2ex/trunk/lib/P2KeyValueStore/Serializing.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Serializing.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/lib/P2KeyValueStore/Serializing.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -8,7 +8,7 @@
  */
 class P2KeyValueStore_Serializing extends P2KeyValueStore_Compressing
 {
-    // {{{ _encodeValue()
+    // {{{ encodeValue()
 
     /**
      * ’l‚ðƒVƒŠƒAƒ‰ƒCƒY‚·‚é
@@ -16,13 +16,13 @@
      * @param mixed $value
      * @return string
      */
-    protected function _encodeValue($value)
+    public function encodeValue($value)
     {
-        return parent::_encodeValue(serialize($value));
+        return parent::encodeValue(serialize($value));
     }
 
     // }}}
-    // {{{ _decodeValue()
+    // {{{ decodeValue()
 
     /**
      * ’l‚ðƒAƒ“ƒVƒŠƒAƒ‰ƒCƒY‚·‚é
@@ -30,9 +30,9 @@
      * @param string $value
      * @return mixed
      */
-    protected function _decodeValue($value)
+    public function decodeValue($value)
     {
-        return unserialize(parent::_decodeValue($value));
+        return unserialize(parent::decodeValue($value));
     }
 
     // }}}

Modified: p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -11,14 +11,14 @@
     // {{{ _encode()
 
     /**
-     * Shift_JIS (CP932) ‚Ì•¶Žš—ñ‚ðUTF-8‚É•ÏŠ·‚·‚é
+     * Shift_JIS (SJIS-win=CP932) ‚Ì•¶Žš—ñ‚ðUTF-8‚É•ÏŠ·‚·‚é
      *
      * @param string $str
      * @return string
      */
     private function _encode($str)
     {
-        return mb_convert_encoding($str, 'UTF-8', 'CP932');
+        return mb_convert_encoding($str, 'UTF-8', 'SJIS-win');
     }
 
     // }}}
@@ -32,11 +32,11 @@
      */
     private function _decode($str)
     {
-        return mb_convert_encoding($str, 'CP932', 'UTF-8');
+        return mb_convert_encoding($str, 'SJIS-win', 'UTF-8');
     }
 
     // }}}
-    // {{{ _encodeKey()
+    // {{{ encodeKey()
 
     /**
      * ƒL[‚ðƒGƒ“ƒR[ƒh‚·‚é
@@ -44,13 +44,13 @@
      * @param string $key
      * @return string
      */
-    protected function _encodeKey($key)
+    public function encodeKey($key)
     {
         return $this->_encode($key);
     }
 
     // }}}
-    // {{{ _decodeKey()
+    // {{{ decodeKey()
 
     /**
      * ƒL[‚ðƒfƒR[ƒh‚·‚é
@@ -58,13 +58,13 @@
      * @param string $key
      * @return string
      */
-    protected function _decodeKey($key)
+    public function decodeKey($key)
     {
         return $this->_decode($key);
     }
 
     // }}}
-    // {{{ _encodeValue()
+    // {{{ encodeValue()
 
     /**
      * ’l‚ðƒGƒ“ƒR[ƒh‚·‚é
@@ -72,13 +72,13 @@
      * @param string $value
      * @return string
      */
-    protected function _encodeValue($value)
+    public function encodeValue($value)
     {
         return $this->_encode($value);
     }
 
     // }}}
-    // {{{ _decodeValue()
+    // {{{ decodeValue()
 
     /**
      * ’l‚ðƒfƒR[ƒh‚·‚é
@@ -86,7 +86,7 @@
      * @param string $value
      * @return string
      */
-    protected function _decodeValue($value)
+    public function decodeValue($value)
     {
         return $this->_decode($value);
     }

Modified: p2ex/trunk/lib/P2KeyValueStore.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/lib/P2KeyValueStore.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -25,13 +25,13 @@
     const Q_GETALL      = 'SELECT * FROM $__table';
     const Q_GETIDS      = 'SELECT id FROM $__table';
     const Q_GETKEYS     = 'SELECT arkey FROM $__table';
-    const Q_SAVE        = 'INSERT INTO $__table (arkey, value, sort_order) VALUES (:key, :value, :order)';
+    const Q_SET         = 'INSERT INTO $__table (arkey, value, sort_order) VALUES (:key, :value, :order)';
     const Q_UPDATE      = 'UPDATE $__table SET value = :value, mtime = strftime(\'%s\',\'now\'), sort_order = :order WHERE arkey = :key';
     const Q_TOUCH       = 'UPDATE $__table SET mtime = (CASE WHEN :mtime IS NULL THEN strftime(\'%s\',\'now\') ELSE :mtime END) WHERE arkey = :key';
     const Q_SETORDER    = 'UPDATE $__table SET sort_order = :order WHERE arkey = :key';
     const Q_DELETE      = 'DELETE FROM $__table WHERE arkey = :key';
     const Q_DELETEBYID  = 'DELETE FROM $__table WHERE id = :id';
-    const Q_CLEAN       = 'DELETE FROM $__table';
+    const Q_CLEAR       = 'DELETE FROM $__table';
     const Q_GC          = 'DELETE FROM $__table WHERE mtime < :expires';
 
     const KVS_DEFAULT       = 'default';
@@ -58,7 +58,7 @@
      *
      * @var PDO
      */
-    private $_conn;
+    private $_pdo;
 
     /**
      * SQLite3ƒf[ƒ^ƒx[ƒX‚̃pƒX
@@ -156,16 +156,16 @@
             if (array_key_exists($lcname, self::$_objects[$path]['persisters'])) {
                 $kvs = self::$_objects[$path]['persisters'][$lcname];
             } else {
-                $conn = self::$_objects[$path]['connection'];
-                $kvs = new $className($conn, $path, $tableName);
+                $pdo = self::$_objects[$path]['connection'];
+                $kvs = new $className($pdo, $path, $tableName);
                 self::$_objects[$path]['persisters'][$lcname] = $kvs;
             }
         } else {
-            $conn = new PDO('sqlite:' . $path);
-            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-            $kvs = new $className($conn, $path, $tableName);
+            $pdo = new PDO('sqlite:' . $path);
+            $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+            $kvs = new $className($pdo, $path, $tableName);
             self::$_objects[$path] = array(
-                'connection' => $conn,
+                'connection' => $pdo,
                 'statements' => array(),
                 'persisters' => array($lcname => $kvs),
             );
@@ -181,19 +181,19 @@
      * ƒRƒ“ƒXƒgƒ‰ƒNƒ^
      * getStore()‚©‚çŒÄ‚яo‚³‚ê‚é
      *
-     * @param PDO $conn
+     * @param PDO $pdo
      * @param string $path
      * @param string $tableName
      * @throws PDOException
      */
-    private function __construct(PDO $conn, $path, $tableName)
+    private function __construct(PDO $pdo, $path, $tableName)
     {
-        $this->_conn = $conn;
+        $this->_pdo = $pdo;
         $this->_path = $path;
         $this->_quotedTableName = '"' . str_replace('"', '""', $tableName) . '"';
 
         // ƒe[ƒuƒ‹‚ª‘¶Ý‚·‚é‚©‚𒲂×
-        $stmt = $conn->prepare(self::Q_TABLEEXISTS);
+        $stmt = $pdo->prepare(self::Q_TABLEEXISTS);
         $stmt->bindValue(':table', $tableName, PDO::PARAM_STR);
         $stmt->execute();
         $exists = $stmt->fetchColumn();
@@ -202,12 +202,12 @@
 
         // –³‚¯‚ê‚΍ì‚é
         if (!$exists) {
-            $conn->exec(str_replace('$__table', $this->_quotedTableName, self::Q_CREATETABLE));
+            $pdo->exec(str_replace('$__table', $this->_quotedTableName, self::Q_CREATETABLE));
         }
     }
 
     // }}}
-    // {{{ _prepare()
+    // {{{ prepare()
 
     /**
      * ƒvƒŠƒyƒA[ƒhƒXƒe[ƒgƒƒ“ƒg‚ðì¬‚·‚é
@@ -217,7 +217,7 @@
      * @return PDOStatement
      * @throws PDOException
      */
-    private function _prepare($query, $isTemporary = false)
+    public function prepare($query, $isTemporary = false)
     {
         $query = str_replace('$__table', $this->_quotedTableName, $query);
 
@@ -225,9 +225,9 @@
             $stmt = self::$_objects[$this->_path]['statements'][$query];
         } else {
             if (strncmp($query, 'SELECT ', 7) == 0) {
-                $stmt = $this->_conn->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
+                $stmt = $this->_pdo->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
             } else {
-                $stmt = $this->_conn->prepare($query);
+                $stmt = $this->_pdo->prepare($query);
             }
             if (!$isTemporary) {
                 self::$_objects[$this->_path]['statements'][$query] = $stmt;
@@ -238,7 +238,7 @@
     }
 
     // }}}
-    // {{{ _buildOrderBy()
+    // {{{ buildOrderBy()
 
     /**
      * ƒŒƒR[ƒh‚ð‚܂Ƃ߂Ď擾‚·‚éÛ‚ÌOREDER BY‹å‚𐶐¬‚·‚é
@@ -246,7 +246,7 @@
      * @param array $orderBy
      * @return string
      */
-    private function _buildOrderBy(array $orderBy = null)
+    public function buildOrderBy(array $orderBy = null)
     {
         if ($orderBy === null) {
             return ' ORDER BY sort_order ASC, arkey ASC';
@@ -282,7 +282,7 @@
     }
 
     // }}}
-    // {{{ _buildLimit()
+    // {{{ buildLimit()
 
     /**
      * ƒŒƒR[ƒh‚ð‚܂Ƃ߂Ď擾‚·‚éÛ‚ÌLIMIT‹å‚ÆOFFSET‹å‚𐶐¬‚·‚é
@@ -291,7 +291,7 @@
      * @param int $offset
      * @return string
      */
-    private function _buildLimit($limit = null, $offset = null)
+    public function buildLimit($limit = null, $offset = null)
     {
         if ($limit === null) {
             return '';
@@ -303,7 +303,7 @@
     }
 
     // }}}
-    // {{{ _encodeKey()
+    // {{{ encodeKey()
 
     /**
      * ƒL[‚ðUTF-8 or US-ASCII•¶Žš—ñ‚ɃGƒ“ƒR[ƒh‚·‚é
@@ -311,13 +311,13 @@
      * @param string $key
      * @return string
      */
-    protected function _encodeKey($key)
+    public function encodeKey($key)
     {
         return (string)$key;
     }
 
     // }}}
-    // {{{ _decodeKey()
+    // {{{ decodeKey()
 
     /**
      * ƒL[‚ðƒfƒR[ƒh‚·‚é
@@ -325,13 +325,13 @@
      * @param string $key
      * @return string
      */
-    protected function _decodeKey($key)
+    public function decodeKey($key)
     {
         return $key;
     }
 
     // }}}
-    // {{{ _encodeValue()
+    // {{{ encodeValue()
 
     /**
      * ’l‚ðUTF-8 or US-ASCII•¶Žš—ñ‚ɃGƒ“ƒR[ƒh‚·‚é
@@ -339,13 +339,13 @@
      * @param string $value
      * @return string
      */
-    protected function _encodeValue($value)
+    public function encodeValue($value)
     {
         return (string)$value;
     }
 
     // }}}
-    // {{{ _decodeValue()
+    // {{{ decodeValue()
 
     /**
      * ’l‚ðƒfƒR[ƒh‚·‚é
@@ -353,7 +353,7 @@
      * @param string $value
      * @return string
      */
-    protected function _decodeValue($value)
+    public function decodeValue($value)
     {
         return $value;
     }
@@ -370,9 +370,9 @@
      */
     public function exists($key, $lifeTime = null)
     {
-        $stmt = $this->_prepare(self::Q_EXSITS);
+        $stmt = $this->prepare(self::Q_EXSITS);
         $stmt->setFetchMode(PDO::FETCH_ASSOC);
-        $stmt->bindValue(':key', $this->_encodeKey($key), PDO::PARAM_STR);
+        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
         $stmt->execute();
         $row = $stmt->fetch();
         $stmt->closeCursor();
@@ -399,7 +399,7 @@
      */
     public function findById($id, $lifeTime = null)
     {
-        $stmt = $this->_prepare(self::Q_FINDBYID);
+        $stmt = $this->prepare(self::Q_FINDBYID);
         $stmt->setFetchMode(PDO::FETCH_ASSOC);
         $stmt->bindValue(':id', (int)$id, PDO::PARAM_INT);
         $stmt->execute();
@@ -412,8 +412,8 @@
             return null;
         } else {
             return array(
-                'key' => $this->_decodeKey($row['arkey']),
-                'value' => $this->_decodeValue($row['value']),
+                'key' => $this->decodeKey($row['arkey']),
+                'value' => $this->decodeValue($row['value']),
             );
         }
     }
@@ -430,9 +430,9 @@
      */
     public function get($key, $lifeTime = null)
     {
-        $stmt = $this->_prepare(self::Q_GET);
+        $stmt = $this->prepare(self::Q_GET);
         $stmt->setFetchMode(PDO::FETCH_ASSOC);
-        $stmt->bindValue(':key', $this->_encodeKey($key), PDO::PARAM_STR);
+        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
         $stmt->execute();
         $row = $stmt->fetch();
         $stmt->closeCursor();
@@ -442,7 +442,7 @@
             $this->deleteById($row['id']);
             return null;
         } else {
-            return $this->_decodeValue($row['value']);
+            return $this->decodeValue($row['value']);
         }
     }
 
@@ -458,9 +458,9 @@
      */
     public function getDetail($key, $lifeTime = null)
     {
-        $stmt = $this->_prepare(self::Q_GET);
+        $stmt = $this->prepare(self::Q_GET);
         $stmt->setFetchMode(PDO::FETCH_ASSOC);
-        $stmt->bindValue(':key', $this->_encodeKey($key), PDO::PARAM_STR);
+        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
         $stmt->execute();
         $row = $stmt->fetch();
         $stmt->closeCursor();
@@ -472,8 +472,8 @@
         } else {
             return array(
                 'id' => (int)$row['id'],
-                'key' => $this->_decodeKey($row['arkey']),
-                'value' => $this->_decodeValue($row['value']),
+                'key' => $this->decodeKey($row['arkey']),
+                'value' => $this->decodeValue($row['value']),
                 'mtime' => (int)$row['mtime'],
                 'order' => (int)$row['sort_order'],
             );
@@ -496,26 +496,26 @@
     public function getAll(array $orderBy = null, $limit = null, $offset = null, $getDetails = false)
     {
         $query = self::Q_GETALL
-               . $this->_buildOrderBy($orderBy)
-               . $this->_buildLimit($limit, $offset);
-        $stmt = $this->_prepare($query, true);
+               . $this->buildOrderBy($orderBy)
+               . $this->buildLimit($limit, $offset);
+        $stmt = $this->prepare($query, true);
         $stmt->setFetchMode(PDO::FETCH_ASSOC);
         $stmt->execute();
         $values = array();
         if ($getDetails) {
             while ($row = $stmt->fetch()) {
-                $key = $this->_decodeKey($row['arkey']);
+                $key = $this->decodeKey($row['arkey']);
                 $values[$key] = array(
                     'id' => (int)$row['id'],
                     'key' => $key,
-                    'value' => $this->_decodeValue($row['value']),
+                    'value' => $this->decodeValue($row['value']),
                     'mtime' => (int)$row['mtime'],
                     'order' => (int)$row['sort_order'],
                 );
             }
         } else {
             while ($row = $stmt->fetch()) {
-                $values[$this->_decodeKey($row['arkey'])] = $this->_decodeValue($row['value']);
+                $values[$this->decodeKey($row['arkey'])] = $this->decodeValue($row['value']);
             }
         }
         $stmt->closeCursor();
@@ -538,9 +538,9 @@
     public function getIds(array $orderBy = null, $limit = null, $offset = null)
     {
         $query = self::Q_GETIDS
-               . $this->_buildOrderBy($orderBy)
-               . $this->_buildLimit($limit, $offset);
-        $stmt = $this->_prepare($query, true);
+               . $this->buildOrderBy($orderBy)
+               . $this->buildLimit($limit, $offset);
+        $stmt = $this->prepare($query, true);
         $stmt->setFetchMode(PDO::FETCH_COLUMN, 0);
         $stmt->execute();
         $ids = array();
@@ -566,14 +566,14 @@
     public function getKeys(array $orderBy = null, $limit = null, $offset = null)
     {
         $query = self::Q_GETKEYS
-               . $this->_buildOrderBy($orderBy)
-               . $this->_buildLimit($limit, $offset);
-        $stmt = $this->_prepare($query, true);
+               . $this->buildOrderBy($orderBy)
+               . $this->buildLimit($limit, $offset);
+        $stmt = $this->prepare($query, true);
         $stmt->setFetchMode(PDO::FETCH_COLUMN, 0);
         $stmt->execute();
         $keys = array();
         while (($key = $stmt->fetch()) !== false) {
-            $keys[] = $this->_decodeKey($key);
+            $keys[] = $this->decodeKey($key);
         }
         $stmt->closeCursor();
         return $keys;
@@ -592,9 +592,9 @@
      */
     public function set($key, $value, $order = 0)
     {
-        $stmt = $this->_prepare(self::Q_SAVE);
-        $stmt->bindValue(':key', $this->_encodeKey($key), PDO::PARAM_STR);
-        $stmt->bindValue(':value', $this->_encodeValue($value), PDO::PARAM_STR);
+        $stmt = $this->prepare(self::Q_SET);
+        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
+        $stmt->bindValue(':value', $this->encodeValue($value), PDO::PARAM_STR);
         $stmt->bindValue(':order', (int)$order, PDO::PARAM_INT);
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
@@ -616,9 +616,9 @@
      */
     public function update($key, $value, $order = 0)
     {
-        $stmt = $this->_prepare(self::Q_UPDATE);
-        $stmt->bindValue(':key', $this->_encodeKey($key), PDO::PARAM_STR);
-        $stmt->bindValue(':value', $this->_encodeValue($value), PDO::PARAM_STR);
+        $stmt = $this->prepare(self::Q_UPDATE);
+        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
+        $stmt->bindValue(':value', $this->encodeValue($value), PDO::PARAM_STR);
         $stmt->bindValue(':order', (int)$order, PDO::PARAM_INT);
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
@@ -639,8 +639,8 @@
      */
     public function touch($key, $time = null)
     {
-        $stmt = $this->_prepare(self::Q_TOUCH);
-        $stmt->bindValue(':key', $this->_encodeKey($key), PDO::PARAM_STR);
+        $stmt = $this->prepare(self::Q_TOUCH);
+        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
         if ($time === null) {
             $stmt->bindValue(':mtime', null, PDO::PARAM_NULL);
         } else {
@@ -665,8 +665,8 @@
      */
     public function setOrder($key, $order)
     {
-        $stmt = $this->_prepare(self::Q_SETORDER);
-        $stmt->bindValue(':key', $this->_encodeKey($key), PDO::PARAM_STR);
+        $stmt = $this->prepare(self::Q_SETORDER);
+        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
         $stmt->bindValue(':order', (int)$order, PDO::PARAM_INT);
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
@@ -686,8 +686,8 @@
      */
     public function delete($key)
     {
-        $stmt = $this->_prepare(self::Q_DELETE);
-        $stmt->bindValue(':key', $this->_encodeKey($key), PDO::PARAM_STR);
+        $stmt = $this->prepare(self::Q_DELETE);
+        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
         } else {
@@ -706,7 +706,7 @@
      */
     public function deleteById($id)
     {
-        $stmt = $this->_prepare(self::Q_DELETEBYID);
+        $stmt = $this->prepare(self::Q_DELETEBYID);
         $stmt->bindValue(':id', (int)$id, PDO::PARAM_INT);
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
@@ -716,7 +716,7 @@
     }
 
     // }}}
-    // {{{ clean()
+    // {{{ clear()
 
     /**
      * ‚·‚ׂẴŒƒR[ƒh‚ðíœ‚·‚é
@@ -724,9 +724,9 @@
      * @param void
      * @return int
      */
-    public function clean()
+    public function clear()
     {
-        $stmt = $this->_prepare(self::Q_CLEAN, true);
+        $stmt = $this->prepare(self::Q_CLEAR, true);
         if ($stmt->execute()) {
             return $stmt->rowCount();
         } else {
@@ -745,7 +745,7 @@
      */
     public function gc($lifeTime)
     {
-        $stmt = $this->_prepare(self::Q_GC, true);
+        $stmt = $this->prepare(self::Q_GC, true);
         $stmt->bindValue(':expires', time() - $lifeTime, PDO::PARAM_INT);
         if ($stmt->execute()) {
             return $stmt->rowCount();
@@ -767,7 +767,7 @@
     public function vacuum()
     {
         self::$_objects[$this->_path]['statements'] = array();
-        $this->_conn->exec('VACUUM');
+        $this->_pdo->exec('VACUUM');
     }
 
     // }}}
@@ -783,7 +783,7 @@
      */
     public function count()
     {
-        $stmt = $this->_prepare(self::Q_COUNT);
+        $stmt = $this->prepare(self::Q_COUNT);
         $stmt->execute();
         $ret = (int)$stmt->fetchColumn();
         $stmt->closeCursor();
@@ -865,6 +865,21 @@
     }
 
     // }}}
+    // {{{ getPDO()
+
+    /**
+     * Žg—p‚µ‚Ä‚¢‚éPDOƒIƒuƒWƒFƒNƒg‚ð•Ô‚·
+     *
+     * @param &$quotedTableName
+     * @return PDO
+     */
+    public function getPDO(&$quotedTableName = null)
+    {
+        $quotedTableName = $this->_quotedTableName;
+        return $this->_pdo;
+    }
+
+    // }}}
 }
 
 // }}}

Modified: p2ex/trunk/lib/P2Util.php
===================================================================
--- p2ex/trunk/lib/P2Util.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/lib/P2Util.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -429,49 +429,15 @@
         if (DIRECTORY_SEPARATOR != '/') {
             $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
         }
-        if (!$with_slashes) {
+        if ($with_slashes) {
+            $path .= '/';
+        } else {
             $path = trim($path, '/');
         }
         return $path;
     }
 
     // }}}
-    // {{{ getPostDataStore()
-
-    /**
-     * ”‚²‚Ƃ̏‘‚«ž‚ݐݒ肨‚æ‚уXƒŒƒbƒh‚²‚Ƃ̏‘‚«ž‚݃f[ƒ^‚ð•Û‘¶‚·‚éƒf[ƒ^ƒx[ƒX‚ð•Ô‚·
-     *
-     * @param void
-     * @return P2KeyValueStore
-     */
-    static public function getPostDataStore()
-    {
-        global $_conf;
-
-        if (self::$_postDataStore !== null) {
-            return self::$_postDataStore;
-        }
-
-        if (!class_exists('P2KeyValueStore', false)) {
-            require P2_LIB_DIR . '/P2KeyValueStore.php';
-        }
-
-        if (!is_dir($_conf['cookie_dir'])) {
-            FileCtl::mkdir_r($_conf['cookie_dir']);
-        }
-
-        try {
-            $databasePath = $_conf['cookie_dir'] . DIRECTORY_SEPARATOR . 'p2_post_data.sqlite3';
-            self::$_postDataStore = P2KeyValueStore::getStore($databasePath,
-                                                              P2KeyValueStore::KVS_SERIALIZING);
-        } catch (Exception $e) {
-            p2die($e->getMessage());
-        }
-
-        return self::$_postDataStore;
-    }
-
-    // }}}
     // {{{ getListNaviRange()
 
     /**

Modified: p2ex/trunk/lib/post_form_options.inc.php
===================================================================
--- p2ex/trunk/lib/post_form_options.inc.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/lib/post_form_options.inc.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -5,6 +5,7 @@
 
 require_once P2_LIB_DIR . '/SettingTxt.php';
 require_once P2_LIB_DIR . '/StrCtl.php';
+require_once P2_LIB_DIR . '/P2DataStore/PostDataStore.php';
 
 $js = array();
 
@@ -92,22 +93,11 @@
 // }}}
 // {{{ ƒf[ƒ^ƒx[ƒX‚©‚ç‘O‰ñ‚ÌPOSTŽ¸”sƒf[ƒ^‚Æberes/p2res‚̐ݒè‚ð“Ǎž‚Ý
 
-if (!isset($_login)) {
-    $_login = $GLOBALS['_login'];
-}
-$post_id_suffix = $_login->user_u . P2Util::pathForHostBbs($host, $bbs);
-$post_backup_id = 'backup:' . $post_id_suffix;
-$post_config_id = 'config:' . $post_id_suffix;
-if (!empty($_REQUEST['newthread'])) {
-    $post_backup_id .= 'new';
-} else {
-    $post_backup_id .= $key;
-}
+$post_backup_key = PostDataStore::getKeyForBackup($host, $bbs, $key, !empty($_REQUEST['newthread']));
+$post_config_key = PostDataStore::getKeyForConfig($host, $bbs);
 
-$post_store = P2Util::getPostDataStore();
-
 // ‘O‰ñ‚ÌPOSTŽ¸”sƒf[ƒ^
-if ($post_backup = $post_store->get($post_backup_id)) {
+if ($post_backup = PostDataStore::get($post_backup_key)) {
     $hd['FROM'] = htmlspecialchars($post_backup['FROM'], ENT_QUOTES, 'Shift_JIS');
     $hd['mail'] = htmlspecialchars($post_backup['mail'], ENT_QUOTES, 'Shift_JIS');
     $hd['MESSAGE'] = htmlspecialchars($post_backup['MESSAGE'], ENT_QUOTES, 'Shift_JIS');
@@ -115,7 +105,7 @@
 }
 
 // beres/p2res
-if ($post_config = $post_store->get($post_config_id)) {
+if ($post_config = PostDataStore::get($post_config_key)) {
     if ($post_config['beres']) {
         $hd['beres_checked'] = ' checked';
     }

Modified: p2ex/trunk/lib/sb_toolbar.inc.php
===================================================================
--- p2ex/trunk/lib/sb_toolbar.inc.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/lib/sb_toolbar.inc.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -18,11 +18,11 @@
 $new_matome_i++;
 
 // ‘qŒÉ‚Å‚È‚¯‚ê‚Î
-if ($aThreadList->spmode != "soko") {
+if ($aThreadList->spmode != 'soko') {
     if ($shinchaku_attayo) {
         $shinchaku_num_ht = " (<span id=\"smynum{$new_matome_i}\" class=\"matome_num\">{$shinchaku_num}</span>)";
     } else {
-        $shinchaku_num_ht = "";
+        $shinchaku_num_ht = '';
     }
     $shinchaku_matome_ht =<<<EOP
 <a id="smy{$new_matome_i}" class="matome" href="{$_conf['read_new_php']}?host={$aThreadList->host}&amp;bbs={$aThreadList->bbs}&amp;spmode={$aThreadList->spmode}{$norefresh_q}&amp;nt={$newtime}" onclick="chNewAllColor();">V’…‚Ü‚Æ‚ß“Ç‚Ý{$shinchaku_num_ht}</a>
@@ -32,15 +32,19 @@
 
 $sb_tool_i++;
 if ($sb_tool_i == 1) {
-    $sb_tool_anchor = <<<EOP
-<a class="toolanchor" href="#sbtoolbar2" target="_self">¥</a>
-EOP;
+    $sb_tool_anchor = '<a class="toolanchor" href="#sbtoolbar2" target="_self">¥</a>';
 } elseif ($sb_tool_i == 2) {
-    $sb_tool_anchor = <<<EOP
-<a class="toolanchor" href="#sbtoolbar1" target="_self">£</a>
-EOP;
+    $sb_tool_anchor = '<a class="toolanchor" href="#sbtoolbar1" target="_self">£</a>';
+} else {
+    $sb_tool_anchor = '';
 }
 
+if ($aThreadList->spmode && $aThreadList->spmode != 'soko' && $aThreadList->spmode != 'taborn') {
+    $refresh_button_hook = 'this.value=\'XV’†...\';this.disabled=true;';
+} else {
+    $refresh_button_hook = '';
+}
+
 //===========================================================
 // HTMLƒvƒŠƒ“ƒg
 //===========================================================
@@ -51,8 +55,9 @@
         <td class="toolbar-update">
             <form class="toolbar" method="GET" action="subject.php" accept-charset="{$_conf['accept_charset']}" target="_self">
                 {$sb_form_hidden_ht}
-                <input type="submit" name="submit_refresh" value="XV">
                 {$sb_disp_num_ht}
+                <input type="hidden" name="submit_refresh" value="1">
+                <input type="button" value="XV" onclick="{$refresh_button_hook};this.form.submit();">
             </form>
         </td>
         <td class="toolbar-filter">{$filter_form_ht}</td>

Modified: p2ex/trunk/login.php
===================================================================
--- p2ex/trunk/login.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/login.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -7,6 +7,8 @@
 
 $_login->authorize(); // ƒ†[ƒU”FØ
 
+$csrfid = P2Util::getCsrfId(__FILE__);
+
 //=========================================================
 // ‘‚«o‚µ—p•Ï”
 //=========================================================
@@ -39,15 +41,22 @@
 //====================================================
 // ƒ†[ƒU“o˜^ˆ—
 //====================================================
-if (isset($_POST['form_login_pass'])) {
+if (isset($_POST['form_new_login_pass'])) {
+    if (!isset($_POST['csrfid']) or $_POST['csrfid'] != $csrfid) {
+        p2die('•s³‚ȃ|ƒXƒg‚Å‚·');
+    }
 
+    $new_login_pass = $_POST['form_new_login_pass'];
+
     // “ü—̓`ƒFƒbƒN
-    if (!preg_match('/^[0-9A-Za-z_]+$/', $_POST['form_login_pass'])) {
+    if (!preg_match('/^[0-9A-Za-z_]+$/', $new_login_pass)) {
         $_info_msg_ht .= "<p>rep2 error: {$p_str['password']}‚𔼊p‰p”Žš‚Å“ü—Í‚µ‚ĉº‚³‚¢B</p>";
+    } elseif ($new_login_pass != $_POST['form_new_login_pass2']) {
+        $_info_msg_ht .= "<p>rep2 error: {$p_str['password']} ‚Æ {$p_str['password']} (Šm”F) ‚ªˆê’v‚µ‚Ü‚¹‚ñ‚Å‚µ‚½B</p>";
 
     // ƒpƒXƒ[ƒh•ÏX“o˜^ˆ—‚ðs‚¤
     } else {
-        $crypted_login_pass = sha1($_POST['form_login_pass']);
+        $crypted_login_pass = sha1($new_login_pass);
         $auth_user_cont = <<<EOP
 <?php
 \$rec_login_user_u = '{$_login->user_u}';
@@ -168,18 +177,41 @@
 //====================================================
 // ”FØƒ†[ƒU“o˜^ƒtƒH[ƒ€
 //====================================================
-$login_form_ht = <<<EOP
+if ($_conf['ktai']) {
+    $login_form_ht = <<<EOP
+<hr>
 <form id="login_change" method="POST" action="{$_SERVER['SCRIPT_NAME']}" target="_self">
     {$p_str['password']}‚̕ύX<br>
     {$_conf['k_input_ht']}
-    V‚µ‚¢{$p_str['password']}: <input type="password" name="form_login_pass">
-    <br>
+    <input type="hidden" name="csrfid" value="{$csrfid}">
+    V‚µ‚¢{$p_str['password']}:<br>
+    <input type="password" name="form_new_login_pass"><br>
+    V‚µ‚¢{$p_str['password']} (Šm”F):<br>
+    <input type="password" name="form_new_login_pass2"><br>
     <input type="submit" name="submit" value="•ÏX“o˜^">
-</form>\n
+</form>
+<hr>
+<div class="center">{$_conf['k_to_index_ht']}</div>
 EOP;
-
-if ($_conf['ktai']) {
-    $login_form_ht = '<hr>'.$login_form_ht;
+} else {
+    $login_form_ht = <<<EOP
+<form id="login_change" method="POST" action="{$_SERVER['SCRIPT_NAME']}" target="_self">
+    {$p_str['password']}‚̕ύX<br>
+    {$_conf['k_input_ht']}
+    <input type="hidden" name="csrfid" value="{$csrfid}">
+    <table border="0">
+        <tr>
+            <td>V‚µ‚¢{$p_str['password']}</td>
+            <td><input type="password" name="form_new_login_pass"></td>
+        </tr>
+        <tr>
+            <td>V‚µ‚¢{$p_str['password']} (Šm”F)</td>
+            <td><input type="password" name="form_new_login_pass2"></td>
+        </tr>
+    </table>
+    <input type="submit" name="submit" value="•ÏX“o˜^">
+</form>
+EOP;
 }
 
 //=========================================================
@@ -237,10 +269,6 @@
 
 echo $login_form_ht;
 
-if ($_conf['ktai']) {
-    echo "<hr><div class=\"center\">{$_conf['k_to_index_ht']}</div>";
-}
-
 echo '</body></html>';
 
 /*

Modified: p2ex/trunk/post.php
===================================================================
--- p2ex/trunk/post.php	2010-01-10 11:34:07 UTC (rev 769)
+++ p2ex/trunk/post.php	2010-01-10 17:32:45 UTC (rev 770)
@@ -4,7 +4,8 @@
  */
 
 require_once './conf/conf.inc.php';
-require_once P2_LIB_DIR . '/P2KeyValueStore.php';
+require_once P2_LIB_DIR . '/P2DataStore/CookieStore.php';
+require_once P2_LIB_DIR . '/P2DataStore/PostDataStore.php';
 
 $_login->authorize(); // ƒ†[ƒU”FØ
 
@@ -156,20 +157,17 @@
     }
 }
 
-$post_id_suffix = $_login->user_u . P2Util::pathForHostBbs($host, $bbs);
-$post_backup_id = 'backup:' . $post_id_suffix;
-$post_config_id = 'config:' . $post_id_suffix;
 if (!empty($_POST['newthread'])) {
-    $post_backup_id .= 'new';
     $ptitle = 'rep2 - V‹KƒXƒŒƒbƒhì¬';
 } else {
-    $post_backup_id .= $key;
     $ptitle = 'rep2 - ƒŒƒX‘‚«ž‚Ý';
 }
 
+$post_backup_key = PostDataStore::getKeyForBackup($host, $bbs, $key, !empty($_REQUEST['newthread']));
+$post_config_key = PostDataStore::getKeyForConfig($host, $bbs);
+
 // Ý’è‚ð•Û‘¶
-$post_store = P2Util::getPostDataStore();
-$post_store->set($post_config_id, array(
+PostDataStore::set($post_config_key, array(
     'beres' => !empty($_REQUEST['beres']),
     'p2res' => !empty($_REQUEST['p2res']),
 ));
@@ -179,7 +177,7 @@
 //================================================================
 
 // ‘‚«ž‚Ý‚ðˆêŽž“I‚É•Û‘¶
-$post_store->set($post_backup_id, $post_cache);
+PostDataStore::set($post_backup_key, $post_cache);
 
 // ƒ|ƒXƒgŽÀs
 if (!empty($_POST['p2res']) && empty($_POST['newthread'])) {
@@ -193,25 +191,18 @@
         FileCtl::mkdir_for($_conf['cookie_file_path']);
     }
 
-    try {
-        $cookie_store = P2KeyValueStore::getStore($_conf['cookie_file_path'],
-                                                  P2KeyValueStore::KVS_SERIALIZING);
-    } catch (Exception $e) {
-        p2die(get_class($e) . ': ' . $e->getMessage());
-    }
-
     $cookie_key = $_login->user_u . '/' . P2Util::normalizeHostName($host);
-    if ($p2cookies = $cookie_store->get($cookie_key)) {
+    if ($p2cookies = CookieStore::get($cookie_key)) {
         if (is_array($p2cookies)) {
             if (array_key_exists('expires', $p2cookies)) {
                 // ŠúŒÀØ‚ê‚È‚ç”jŠü
                 if (time() > strtotime($p2cookies['expires'])) {
-                    $cookie_store->delete($cookie_key);
+                    CookieStore::delete($cookie_key);
                     $p2cookies = null;
                 }
             }
         } else {
-            $cookie_store->delete($cookie_key);
+            CookieStore::delete($cookie_key);
             $p2cookies = null;
         }
     } else {
@@ -223,13 +214,13 @@
 
     // cookie •Û‘¶
     if ($p2cookies) {
-        $cookie_store->set($cookie_key, $p2cookies);
+        CookieStore::set($cookie_key, $p2cookies);
     }
 }
 
 // “ŠeŽ¸”s‹L˜^‚ðíœ
 if ($posted) {
-    $post_store->delete($post_backup_id);
+    PostDataStore::delete($post_backup_key);
 }
 
 //=============================================



P2-php-svn メーリングリストの案内
Back to archive index