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ðbv·é + * [eBeBNX̽ßÌîêÛNX + */ + +require_once P2_LIB_DIR . '/P2KeyValueStore.php'; + +// {{{ AbstractDataStore + +abstract class AbstractDataStore +{ + // {{{ properties + + static private $_kvs = array(); + + // }}} + // {{{ _getKVS() + + /** + * f[^ðÛ¶·éP2KeyValueStoreIuWFNgðæ¾·é + * + * @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µÄP2KeyValueStoreIuWFNgðæ¾·é + * + * »ÝÍ self::getKVS() ÌsűêæèºÌ\bhð + * TuNXÉRsyÆ¢¤Û竪ÉßÄ«¢ÀÆÈÁÄ¢é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ÇNX + */ + +require_once P2_LIB_DIR . '/P2DataStore/AbstractDataStore.php'; + +// {{{ CookieStore + +class CookieStore extends AbstractDataStore +{ + // {{{ getKVS() + + /** + * CookieðÛ¶·éP2KeyValueStoreIuWFNgðæ¾·é + * + * @param void + * @return P2KeyValueStore + */ + static public function getKVS() + { + return self::_getKVS($GLOBALS['_conf']['cookie_db_path']); + } + + // }}} + // {{{ AbstractDataStore.php ©çÌRsy / 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; + } + } + + // }}} + // }}} Rsy±±ÜÅ +} + +// }}} + +/* + * 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[^ÇNX + */ + +require_once P2_LIB_DIR . '/P2DataStore/AbstractDataStore.php'; + +// {{{ PostDataStore + +class PostDataStore extends AbstractDataStore +{ + // {{{ getKVS() + + /** + * «Ýf[^ðÛ¶·éP2KeyValueStoreIuWFNgðæ¾·é + * + * @param void + * @return P2KeyValueStore + */ + static public function getKVS() + { + return self::_getKVS($GLOBALS['_conf']['post_db_path']); + } + + // }}} + // {{{ AbstractDataStore.php ©çÌRsy / 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; + } + } + + // }}} + // }}} Rsy±±ÜÅ + // {{{ getKeyForBackup() + + /** + * «ÝobNAbv̽ßÌ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() + + /** + * ·×ÄÌ«ÝobNAbvÜ½Í + * wè³ê½[U[Ì«ÝobNAbvðí·é + * + * @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[^ðBase64GR[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[^ðBase64fR[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[^ðWJ·é @@ -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ðVACY·é @@ -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ðAVACY·é @@ -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[ðGR[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[ðfR[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ðGR[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ðfR[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; /** * SQLite3f[^x[XÌpX @@ -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 @@ * RXgN^ * 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() /** * vyA[hXe[ggð쬷é @@ -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¶ñÉGR[h·é @@ -311,13 +311,13 @@ * @param string $key * @return string */ - protected function _encodeKey($key) + public function encodeKey($key) { return (string)$key; } // }}} - // {{{ _decodeKey() + // {{{ decodeKey() /** * L[ðfR[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¶ñÉGR[h·é @@ -339,13 +339,13 @@ * @param string $value * @return string */ - protected function _encodeValue($value) + public function encodeValue($value) { return (string)$value; } // }}} - // {{{ _decodeValue() + // {{{ decodeValue() /** * lðfR[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() + + /** + * gpµÄ¢éPDOIuWFNgðÔ· + * + * @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() - - /** - * ²ÆÌ«ÝÝè¨æÑXbh²ÆÌ«Ý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¸sf[^Æ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¸sf[^ -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}&bbs={$aThreadList->bbs}&spmode={$aThreadList->spmode}{$norefresh_q}&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=\'XV...\';this.disabled=true;'; +} else { + $refresh_button_hook = ''; +} + //=========================================================== // HTMLvg //=========================================================== @@ -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="XV"> {$sb_disp_num_ht} + <input type="hidden" name="submit_refresh" value="1"> + <input type="button" value="XV" 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(); // [UFØ +$csrfid = P2Util::getCsrfId(__FILE__); + //========================================================= // «oµpÏ //========================================================= @@ -39,15 +41,22 @@ //==================================================== // [Uo^ //==================================================== -if (isset($_POST['form_login_pass'])) { +if (isset($_POST['form_new_login_pass'])) { + if (!isset($_POST['csrfid']) or $_POST['csrfid'] != $csrfid) { + p2die('s³È|XgÅ·'); + } + $new_login_pass = $_POST['form_new_login_pass']; + // üÍ`FbN - 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']}ð¼ppÅü͵ĺ³¢B</p>"; + } elseif ($new_login_pass != $_POST['form_new_login_pass2']) { + $_info_msg_ht .= "<p>rep2 error: {$p_str['password']} Æ {$p_str['password']} (mF) ªêvµÜ¹ñŵ½B</p>"; // pX[hÏXo^ð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Ø[Uo^tH[ //==================================================== -$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']} (mF):<br> + <input type="password" name="form_new_login_pass2"><br> <input type="submit" name="submit" value="ÏXo^"> -</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']} (mF)</td> + <td><input type="password" name="form_new_login_pass2"></td> + </tr> + </table> + <input type="submit" name="submit" value="ÏXo^"> +</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(); // [UFØ @@ -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 - VKXbhì¬'; } 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); // |XgÀ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¸sL^ðí if ($posted) { - $post_store->delete($post_backup_id); + PostDataStore::delete($post_backup_key); } //=============================================