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

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 1月 13日 (水) 13:36:03 JST


Revision: 773
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=773
Author:   rsk
Date:     2010-01-13 13:36:03 +0900 (Wed, 13 Jan 2010)

Log Message:
-----------
expack:
- rev.100113.1300.
- 元スレを開くアンカーへのマウスオーバーでレス表示範囲 (1, 1-10,1-100,
  最新50, 全部) を指定して開くポップアップメニューを表示するようにした。
- 投稿フォームを開くアンカーの文字列をrep2 1.8.xや公式p2にあわせて「書込」に変更。
- P2KeyValueStoreやImageCache2をオートロード機構を使うように変更。
- バージョンアップ時の自動マイグレーション処理を改良。
- コマンドライン版ImageMagickを使った画像サムネイル作成が失敗する不具合を修正。
- その他、コードのクリーンアップ。

Modified Paths:
--------------
    p2ex/trunk/conf/conf.inc.php
    p2ex/trunk/conf/conf_admin.inc.php
    p2ex/trunk/cookie.php
    p2ex/trunk/editpref.php
    p2ex/trunk/httpcmd.php
    p2ex/trunk/ic2.php
    p2ex/trunk/ic2_fitimage.php
    p2ex/trunk/ic2_getinfo.php
    p2ex/trunk/ic2_getter.php
    p2ex/trunk/ic2_manager.php
    p2ex/trunk/ic2_mkthumb.php
    p2ex/trunk/ic2_setrank.php
    p2ex/trunk/ic2_setter.php
    p2ex/trunk/ic2_viewtable.php
    p2ex/trunk/index.php
    p2ex/trunk/iv2.php
    p2ex/trunk/lib/HostCheck.php
    p2ex/trunk/lib/P2Client.php
    p2ex/trunk/lib/P2DataStore/AbstractDataStore.php
    p2ex/trunk/lib/P2DataStore/CookieStore.php
    p2ex/trunk/lib/P2DataStore/PostDataStore.php
    p2ex/trunk/lib/P2KeyValueStore/Iterator.php
    p2ex/trunk/lib/P2KeyValueStore.php
    p2ex/trunk/lib/P2Util.php
    p2ex/trunk/lib/ResHist.php
    p2ex/trunk/lib/Session.php
    p2ex/trunk/lib/ShowThreadK.php
    p2ex/trunk/lib/Thumbnailer/Common.php
    p2ex/trunk/lib/Thumbnailer/Gd.php
    p2ex/trunk/lib/Thumbnailer/Imagemagick.php
    p2ex/trunk/lib/Thumbnailer/Imagick.php
    p2ex/trunk/lib/bootstrap.php
    p2ex/trunk/lib/expack/ExpackLoader.php
    p2ex/trunk/lib/expack/ic2/DataObject/BlackList.php
    p2ex/trunk/lib/expack/ic2/DataObject/Common.php
    p2ex/trunk/lib/expack/ic2/DataObject/Errors.php
    p2ex/trunk/lib/expack/ic2/DataObject/Images.php
    p2ex/trunk/lib/expack/ic2/Thumbnailer.php
    p2ex/trunk/lib/expack/rss/getimage.inc.php
    p2ex/trunk/lib/menu.inc.php
    p2ex/trunk/lib/read_footer.inc.php
    p2ex/trunk/lib/read_footer_k.inc.php
    p2ex/trunk/lib/read_header.inc.php
    p2ex/trunk/lib/read_header_k.inc.php
    p2ex/trunk/lib/sb_footer.inc.php
    p2ex/trunk/lib/sb_footer_k.inc.php
    p2ex/trunk/lib/sb_header.inc.php
    p2ex/trunk/lib/sb_print.inc.php
    p2ex/trunk/lib/sb_print_k.inc.php
    p2ex/trunk/lib/sb_toolbar.inc.php
    p2ex/trunk/read_new.php
    p2ex/trunk/read_new_k.php
    p2ex/trunk/style/style_css.inc
    p2ex/trunk/style/subject_css.inc

Added Paths:
-----------
    p2ex/trunk/js/motolspopup.js
    p2ex/trunk/lib/P2KeyValueStore/Codec/
    p2ex/trunk/lib/P2KeyValueStore/Codec/Binary.php
    p2ex/trunk/lib/P2KeyValueStore/Codec/Compressing.php
    p2ex/trunk/lib/P2KeyValueStore/Codec/Default.php
    p2ex/trunk/lib/P2KeyValueStore/Codec/Interface.php
    p2ex/trunk/lib/P2KeyValueStore/Codec/Serializing.php
    p2ex/trunk/lib/P2KeyValueStore/Codec/ShiftJIS.php
    p2ex/trunk/lib/P2KeyValueStore/FunctionCache/
    p2ex/trunk/lib/P2KeyValueStore/FunctionCache/Proxy.php
    p2ex/trunk/lib/P2KeyValueStore/FunctionCache.php
    p2ex/trunk/lib/P2KeyValueStore/Result.php
    p2ex/trunk/lib/Thumbnailer/
    p2ex/trunk/lib/expack/ic2/DatabaseManager.php
    p2ex/trunk/lib/expack/ic2/ImageInfo.php
    p2ex/trunk/lib/expack/ic2/ParameterUtility.php
    p2ex/trunk/lib/expack/ic2/bootstrap.php
    p2ex/trunk/lib/migrators/
    p2ex/trunk/lib/migrators/100113_1300.php
    p2ex/trunk/lib/migrators/yymmdd_hhmm.php

Removed Paths:
-------------
    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/expack/ic2/Thumbnailer/
    p2ex/trunk/lib/expack/ic2/buildimgcell.inc.php
    p2ex/trunk/lib/expack/ic2/findexec.inc.php
    p2ex/trunk/lib/expack/ic2/getvalidvalue.inc.php
    p2ex/trunk/lib/expack/ic2/loadconfig.inc.php
    p2ex/trunk/lib/expack/ic2/managedb.inc.php


-------------- next part --------------
Modified: p2ex/trunk/conf/conf.inc.php
===================================================================
--- p2ex/trunk/conf/conf.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/conf/conf.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -7,7 +7,7 @@
 // ƒo[ƒWƒ‡ƒ“î•ñ
 $_conf = array(
     'p2version' => '1.7.29+1.8.x',  // rep2‚̃o[ƒWƒ‡ƒ“
-    'p2expack'  => '100105.2345',   // Šg’£ƒpƒbƒN‚̃o[ƒWƒ‡ƒ“
+    'p2expack'  => '100113.1300',   // Šg’£ƒpƒbƒN‚̃o[ƒWƒ‡ƒ“
     'p2name'    => 'expack',        // rep2‚Ì–¼‘O
 );
 
@@ -136,9 +136,6 @@
         define('P2_OS_WINDOWS', 0);
     }
 
-    $DIR_SEP = DIRECTORY_SEPARATOR;
-    $PATH_SEP = PATH_SEPARATOR;
-
     // ƒkƒ‹ƒoƒCƒg’萔
     // mbstring.script_encoding = SJIS-win ‚¾‚Æ
     // "\0", "\x00" ˆÈ~‚ªƒJƒbƒg‚³‚ê‚é‚̂ŁAchr()ŠÖ”‚ðŽg‚¤
@@ -156,44 +153,43 @@
     define('P2_CONF_DIR', dirname(__FILE__)); // __DIR__ @php-5.3
 
     define('P2_BASE_DIR', dirname(P2_CONF_DIR));
-    $P2_BASE_DIR_S = P2_BASE_DIR . $DIR_SEP;
 
     // Šî–{“I‚È‹@”\‚ð’ñ‹Ÿ‚·‚é‚·‚郉ƒCƒuƒ‰ƒŠ
-    define('P2_LIB_DIR', $P2_BASE_DIR_S . 'lib');
+    define('P2_LIB_DIR', P2_BASE_DIR . '/lib');
 
     // ‚¨‚Ü‚¯“I‚È‹@”\‚ð’ñ‹Ÿ‚·‚é‚·‚郉ƒCƒuƒ‰ƒŠ
-    define('P2EX_LIB_DIR', $P2_BASE_DIR_S . 'lib' . $DIR_SEP . 'expack');
+    define('P2EX_LIB_DIR', P2_BASE_DIR . '/lib/expack');
 
     // ƒXƒ^ƒCƒ‹ƒV[ƒg
-    define('P2_STYLE_DIR', $P2_BASE_DIR_S . 'style');
+    define('P2_STYLE_DIR', P2_BASE_DIR . '/style');
 
     // ƒXƒLƒ“
-    define('P2_SKIN_DIR', $P2_BASE_DIR_S . 'skin');
-    define('P2_USER_SKIN_DIR', $P2_BASE_DIR_S . 'user_skin');
+    define('P2_SKIN_DIR', P2_BASE_DIR . '/skin');
+    define('P2_USER_SKIN_DIR', P2_BASE_DIR . '/user_skin');
 
     // PEARƒCƒ“ƒXƒg[ƒ‹ƒfƒBƒŒƒNƒgƒŠAŒŸõƒpƒX‚ɒljÁ‚³‚ê‚é
-    define('P2_PEAR_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'includes');
+    define('P2_PEAR_DIR', P2_BASE_DIR . '/includes');
 
     // PEAR‚ðƒnƒbƒN‚µ‚½ƒtƒ@ƒCƒ‹—pƒfƒBƒŒƒNƒgƒŠA’ʏí‚ÌPEAR‚æ‚è—Dæ“I‚ÉŒŸõƒpƒX‚ɒljÁ‚³‚ê‚é
     // Cache/Container/db.php(PEAR::Cache)‚ªMySQL”›‚肾‚Á‚½‚̂ŁA”Ä—p“I‚É‚µ‚½‚à‚Ì‚ð’u‚¢‚Ä‚¢‚é
     // include_path‚ð’ljÁ‚·‚é‚̂̓pƒtƒH[ƒ}ƒ“ƒX‚ɉe‹¿‚ð‹y‚Ú‚·‚½‚߁A–{“–‚É•K—v‚ȏꍇ‚Ì‚Ý’è‹`
     if (defined('P2_USE_PEAR_HACK')) {
-        define('P2_PEAR_HACK_DIR', $P2_BASE_DIR_S . 'lib' . $DIR_SEP . 'pear_hack');
+        define('P2_PEAR_HACK_DIR', P2_BASE_DIR . '/lib/pear_hack');
     }
 
     // ƒRƒ}ƒ“ƒhƒ‰ƒCƒ“ƒc[ƒ‹
-    define('P2_CLI_DIR', $P2_BASE_DIR_S . 'cli');
+    define('P2_CLI_DIR', P2_BASE_DIR . '/cli');
 
     // ŒŸõƒpƒX‚ðƒZƒbƒg
     $include_path = '';
     if (defined('P2_PEAR_HACK_DIR')) {
-        $include_path .= P2_PEAR_HACK_DIR . $PATH_SEP;
+        $include_path .= P2_PEAR_HACK_DIR . PATH_SEPARATOR;
     }
     if (is_dir(P2_PEAR_DIR)) {
-        $include_path .= P2_PEAR_DIR . $PATH_SEP;
+        $include_path .= P2_PEAR_DIR . PATH_SEPARATOR;
     } else {
         $paths = array();
-        foreach (explode($PATH_SEP, get_include_path()) as $dir) {
+        foreach (explode(PATH_SEPARATOR, get_include_path()) as $dir) {
             if (is_dir($dir)) {
                 $dir = realpath($dir);
                 if ($dir != P2_BASE_DIR) {
@@ -202,21 +198,18 @@
             }
         }
         if (count($paths)) {
-            $include_path .= implode($PATH_SEP, array_unique($paths)) . $PATH_SEP;
+            $include_path .= implode(PATH_SEPARATOR, array_unique($paths)) . PATH_SEPARATOR;
         }
     }
     $include_path .= P2_BASE_DIR; // fallback
     set_include_path($include_path);
 
-    $P2_CONF_DIR_S = P2_CONF_DIR . $DIR_SEP;
-    $P2_LIB_DIR_S = P2_LIB_DIR . $DIR_SEP;
-
     // }}}
     // {{{ ŠÂ‹«ƒ`ƒFƒbƒN‚ƃfƒoƒbƒO
 
     // ƒ†[ƒeƒBƒŠƒeƒB‚ð“ǂݍž‚Þ
-    include $P2_LIB_DIR_S . 'P2Util.php';
-    include $P2_LIB_DIR_S . 'p2util.inc.php';
+    include P2_LIB_DIR . '/P2Util.php';
+    include P2_LIB_DIR . '/p2util.inc.php';
 
     // “®ìŠÂ‹«‚ðŠm”F (—vŒ‚ð–ž‚½‚µ‚Ä‚¢‚é‚È‚çƒRƒƒ“ƒgƒAƒEƒg‰Â)
     p2checkenv(__LINE__);
@@ -251,7 +244,7 @@
     // {{{ ŠÇ—ŽÒ—pÝ’èetc.
 
     // ŠÇ—ŽÒ—pÝ’è‚ð“ǂݍž‚Ý
-    include $P2_CONF_DIR_S . 'conf_admin.inc.php';
+    include P2_CONF_DIR . '/conf_admin.inc.php';
 
     // ƒfƒBƒŒƒNƒgƒŠ‚̐â‘΃pƒX‰»
     $_conf['data_dir'] = p2_realpath($_conf['data_dir']);
@@ -260,24 +253,24 @@
     $_conf['pref_dir'] = p2_realpath($_conf['pref_dir']);
 
     // ŠÇ——p•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
-    $_conf['admin_dir'] = $_conf['data_dir'] . $DIR_SEP . 'admin';
+    $_conf['admin_dir'] = $_conf['data_dir'] . '/admin';
 
     // cache •Û‘¶ƒfƒBƒŒƒNƒgƒŠ
     // 2005/06/29 $_conf['pref_dir'] . '/p2_cache' ‚æ‚è•ÏX
-    $_conf['cache_dir'] = $_conf['data_dir'] . $DIR_SEP . 'cache';
+    $_conf['cache_dir'] = $_conf['data_dir'] . '/cache';
 
     // Cookie •Û‘¶ƒfƒBƒŒƒNƒgƒŠ
     // 2008/09/09 $_conf['pref_dir'] . '/p2_cookie' ‚æ‚è•ÏX
-    $_conf['cookie_dir'] = $_conf['data_dir'] . $DIR_SEP . 'cookie';
+    $_conf['cookie_dir'] = $_conf['data_dir'] . '/cookie';
 
     // ƒRƒ“ƒpƒCƒ‹‚³‚ꂽƒeƒ“ƒvƒŒ[ƒg‚Ì•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
-    $_conf['compile_dir'] = $_conf['data_dir'] . $DIR_SEP . 'compile';
+    $_conf['compile_dir'] = $_conf['data_dir'] . '/compile';
 
     // ƒZƒbƒVƒ‡ƒ“ƒf[ƒ^•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
-    $_conf['session_dir'] = $_conf['data_dir'] . $DIR_SEP . 'session';
+    $_conf['session_dir'] = $_conf['data_dir'] . '/session';
 
     // ƒeƒ“ƒ|ƒ‰ƒŠƒfƒBƒŒƒNƒgƒŠ
-    $_conf['tmp_dir'] = $_conf['data_dir'] . $DIR_SEP . 'tmp';
+    $_conf['tmp_dir'] = $_conf['data_dir'] . '/tmp';
 
     // ƒo[ƒWƒ‡ƒ“ID‚ð“ñdˆø—p•„‚âƒqƒAƒhƒLƒ…ƒƒ“ƒg“à‚É–„‚ߍž‚Þ‚½‚߂̕ϐ”
     $_conf['p2_version_id'] = P2_VERSION_ID;
@@ -293,34 +286,38 @@
     // }}}
     // {{{ •Ï”Ý’è
 
-    $pref_dir_s = $_conf['pref_dir'] . $DIR_SEP;
+    $preferences = array(
+        'favita_brd'        => 'p2_favita.brd',         // ‚¨‹C‚ɔ (brd)
+        'favlist_idx'       => 'p2_favlist.idx',        // ‚¨‹C‚ɃXƒŒ (idx)
+        'recent_idx'        => 'p2_recent.idx',         // Å‹ß“Ç‚ñ‚¾ƒXƒŒ (idx)
+        'palace_idx'        => 'p2_palace.idx',         // ƒXƒŒ‚Ì“a“° (idx)
+        'res_hist_idx'      => 'p2_res_hist.idx',       // ‘‚«ž‚݃ƒO (idx)
+        'res_hist_dat'      => 'p2_res_hist.dat',       // ‘‚«ž‚݃ƒOƒtƒ@ƒCƒ‹ (dat)
+        'res_hist_dat_php'  => 'p2_res_hist.dat.php',   // ‘‚«ž‚݃ƒOƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
+        'idpw2ch_php'       => 'p2_idpw2ch.php',        // 2ch ID”FØÝ’èƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
+        'sid2ch_php'        => 'p2_sid2ch.php',         // 2ch ID”FØƒZƒbƒVƒ‡ƒ“ID‹L˜^ƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
+        'auth_user_file'    => 'p2_auth_user.php',      // ”FØƒ†[ƒUÝ’èƒtƒ@ƒCƒ‹(ƒf[ƒ^PHP)
+        'auth_imodeid_file' => 'p2_auth_imodeid.php',   // docomo iƒ‚[ƒhID”FØƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
+        'auth_docomo_file'  => 'p2_auth_docomo.php',    // docomo ’[––»‘¢”ԍ†”FØƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
+        'auth_ez_file'      => 'p2_auth_ez.php',        // EZweb ƒTƒuƒXƒNƒ‰ƒCƒoID”FØƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
+        'auth_jp_file'      => 'p2_auth_jp.php',        // SoftBank ’[––ƒVƒŠƒAƒ‹”ԍ†”FØƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
+        'login_log_file'    => 'p2_login.log.php',      // ƒƒOƒCƒ“—š—ð (ƒf[ƒ^PHP)
+        'login_failed_log_file' => 'p2_login_failed.dat.php',   // ƒƒOƒCƒ“Ž¸”s—š—ð (ƒf[ƒ^PHP)
+    );
+    foreach ($preferences as $k => $v) {
+        $_conf[$k] = $_conf['pref_dir'] . '/' . $v;
+    }
 
-    $_conf['favita_brd']        = $pref_dir_s . 'p2_favita.brd';        // ‚¨‹C‚ɔ (brd)
-    $_conf['favlist_idx']       = $pref_dir_s . 'p2_favlist.idx';       // ‚¨‹C‚ɃXƒŒ (idx)
-    $_conf['recent_idx']        = $pref_dir_s . 'p2_recent.idx';        // Å‹ß“Ç‚ñ‚¾ƒXƒŒ (idx)
-    $_conf['palace_idx']        = $pref_dir_s . 'p2_palace.idx';        // ƒXƒŒ‚Ì“a“° (idx)
-    $_conf['res_hist_idx']      = $pref_dir_s . 'p2_res_hist.idx';      // ‘‚«ž‚݃ƒO (idx)
-    $_conf['res_hist_dat']      = $pref_dir_s . 'p2_res_hist.dat';      // ‘‚«ž‚݃ƒOƒtƒ@ƒCƒ‹ (dat)
-    $_conf['res_hist_dat_php']  = $pref_dir_s . 'p2_res_hist.dat.php';  // ‘‚«ž‚݃ƒOƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
-    $_conf['idpw2ch_php']       = $pref_dir_s . 'p2_idpw2ch.php';       // 2ch ID”FØÝ’èƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
-    $_conf['sid2ch_php']        = $pref_dir_s . 'p2_sid2ch.php';        // 2ch ID”FØƒZƒbƒVƒ‡ƒ“ID‹L˜^ƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
-    $_conf['auth_user_file']    = $pref_dir_s . 'p2_auth_user.php';     // ”FØƒ†[ƒUÝ’èƒtƒ@ƒCƒ‹(ƒf[ƒ^PHP)
-    $_conf['auth_imodeid_file'] = $pref_dir_s . 'p2_auth_imodeid.php';  // docomo iƒ‚[ƒhID”FØƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
-    $_conf['auth_docomo_file']  = $pref_dir_s . 'p2_auth_docomo.php';   // docomo ’[––»‘¢”ԍ†”FØƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
-    $_conf['auth_ez_file']      = $pref_dir_s . 'p2_auth_ez.php';       // EZweb ƒTƒuƒXƒNƒ‰ƒCƒoID”FØƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
-    $_conf['auth_jp_file']      = $pref_dir_s . 'p2_auth_jp.php';       // SoftBank ’[––ƒVƒŠƒAƒ‹”ԍ†”FØƒtƒ@ƒCƒ‹ (ƒf[ƒ^PHP)
-    $_conf['login_log_file']    = $pref_dir_s . 'p2_login.log.php';     // ƒƒOƒCƒ“—š—ð (ƒf[ƒ^PHP)
-    $_conf['login_failed_log_file'] = $pref_dir_s . 'p2_login_failed.dat.php';  // ƒƒOƒCƒ“Ž¸”s—š—ð (ƒf[ƒ^PHP)
-
-    $_conf['matome_cache_path'] = $pref_dir_s . 'matome_cache';
+    $_conf['matome_cache_path'] = $_conf['pref_dir'] . '/matome_cache';
     $_conf['matome_cache_ext']  = '.htm';
     $_conf['matome_cache_max']  = 3; // —\”õƒLƒƒƒbƒVƒ…‚̐”
 
     $_conf['orig_favita_brd']   = $_conf['favita_brd'];
     $_conf['orig_favlist_idx']  = $_conf['favlist_idx'];
 
-    $_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';
+    $_conf['cookie_db_path']    = $_conf['db_dir'] . '/p2_cookies.sqlite3';
+    $_conf['post_db_path']      = $_conf['db_dir'] . '/p2_post_data.sqlite3';
+    $_conf['hostcheck_db_path'] = $_conf['db_dir'] . '/p2_hostcheck_cache.sqlite3';
 
     // •â³
     if ($_conf['expack.use_pecl_http'] && !extension_loaded('http')) {
@@ -336,7 +333,7 @@
 
     // }}}
 
-    include $P2_LIB_DIR_S . 'bootstrap.php';
+    include P2_LIB_DIR . '/bootstrap.php';
 }
 
 // }}}
@@ -381,16 +378,13 @@
         }
     }
 
-    // ƒZ[ƒtƒ‚[ƒh
-    if (ini_get('safe_mode')) {
-        p2die('ƒZ[ƒtƒ‚[ƒh‚Å“®ì‚·‚éPHP‚Å‚ÍŽg‚¦‚Ü‚¹‚ñB');
-    }
-
-    // register_globals, magic_quotes_gpc, mbstring.encoding_translation
+    // —LŒø‚¾‚Æ“®ì‚µ‚È‚¢php.iniƒfƒBƒŒƒNƒeƒBƒu
     $directives = array(
+        'safe_mode',
         'register_globals',
         'magic_quotes_gpc',
         'mbstring.encoding_translation',
+        'session.cookie_httponly',
     );
     foreach ($directives as $directive) {
         if (ini_get($directive)) {
@@ -438,7 +432,66 @@
 }
 
 // }}}
+// {{{ p2checkmigration()
 
+/**
+ * ƒ}ƒCƒOƒŒ[ƒVƒ‡ƒ“‚Ì•K—v‚ª‚ ‚é‚©‚Ç‚¤‚©‚ðƒ`ƒFƒbƒN
+ *
+ * @param   string  $config_version
+ * @return  array
+ */
+function p2checkmigration($config_version)
+{
+    // "yymmdd.hhmm" Œ`Ž®‚̃}ƒCƒOƒŒ[ƒVƒ‡ƒ“‚ª•K—v‚ȕύX‚Ì‚ ‚Á‚½ƒo[ƒWƒ‡ƒ“”ԍ†‚Ì”z—ñ
+    // ’l‚̓†ƒj[ƒN‚©‚¸‡‚Ƀ\[ƒg‚³‚ê‚Ä‚¢‚È‚¯‚ê‚΂Ȃç‚È‚¢
+    $versions = array(
+        '100113.1300',
+    );
+
+    $migrators = array();
+    $found = false;
+
+    foreach ($versions as $version) {
+        if ($found || version_compare($config_version, $version, '<')) {
+            $found = true;
+            $migrator_name = str_replace('.', '_', $version);
+            $migrator_func = 'p2_migrate_' . $migrator_name;
+            $migrator_file = '/migrators/' . $migrator_name . '.php';
+            $migrators[$migrator_func] = $migrator_file;
+        }
+    }
+
+    if ($found) {
+        return $migrators;
+    } else {
+        return null;
+    }
+}
+
+// }}}
+// {{{ p2migrate()
+
+/**
+ * ƒ}ƒCƒOƒŒ[ƒVƒ‡ƒ“‚ðŽÀs
+ *
+ * @param array $user_conf ŒÃ‚¢ƒ†[ƒU[Ý’è
+ * @param array $migrators ƒ}ƒCƒOƒŒ[ƒVƒ‡ƒ“ŠÖ”‚̃ŠƒXƒg
+ * @return array V‚µ‚¢ƒ†[ƒU[Ý’è
+ */
+function p2migrate(array $user_conf, array $migrators)
+{
+    global $_conf;
+
+    foreach ($migrators as $migrator_func => $migrator_file) {
+        include P2_LIB_DIR . $migrator_file;
+        $user_conf = $migrator_func($_conf, $user_conf);
+    }
+
+    return $user_conf;
+}
+
+// }}}
+
 /*
  * Local Variables:
  * mode: php

Modified: p2ex/trunk/conf/conf_admin.inc.php
===================================================================
--- p2ex/trunk/conf/conf_admin.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/conf/conf_admin.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -22,6 +22,8 @@
 // ‰ŠúÝ’èƒf[ƒ^•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
 $_conf['pref_dir'] = "./data";      // ("./data")
 
+// SQLite3ƒf[ƒ^ƒx[ƒX•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
+$_conf['db_dir'] = "./data/db";     // ("./data/db")
 
 // «—ˆ“I‚ɂ͈ȉº‚̂悤‚É‚µ‚½‚¢—\’è
 // $_conf['dat_dir']  = $_conf['data_dir'] . '/dat';

Modified: p2ex/trunk/cookie.php
===================================================================
--- p2ex/trunk/cookie.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/cookie.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -18,11 +18,9 @@
 {$return_path}?check_regist_cookie=1&amp;regist_cookie={$_REQUEST['regist_cookie']}{$_conf['k_at_a']}
 EOP;
 
-
 $next_url = str_replace('&amp;', '&', $next_url);
 
-$sid_q = defined('SID') ? '&'.strip_tags(SID) : '';
-header('Location: '.$next_url.$sid_q);
+header('Location: '.$next_url);
 exit;
 
 /*

Modified: p2ex/trunk/editpref.php
===================================================================
--- p2ex/trunk/editpref.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/editpref.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -381,10 +381,9 @@
     if (file_exists($file)) {
         $filemtime = filemtime($file);
         $date = date('Y/m/d G:i:s', $filemtime);
-        $b = filesize($file)/1024;
-        $kb = round($b, 0);
+        $kib = round(filesize($file) / 1024, 0);
         $url = 'read_new.php?cview=1' . $ai . '&amp;filemtime=' . $filemtime . $_conf['k_at_a'];
-        $links[] = '<a href="'.$url.'" target="read">'.$date.'</a> '.$kb.'KB';
+        $links[] = '<a href="' . $url . '" target="read">' . $date . '</a> ' . $kib . 'KiB';
     }
 }
 if (!empty($links)) {

Modified: p2ex/trunk/httpcmd.php
===================================================================
--- p2ex/trunk/httpcmd.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/httpcmd.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -235,7 +235,9 @@
 
 case 'ic2':
     if (isset($_REQUEST['switch'])) {
-        require_once P2EX_LIB_DIR . '/ic2/Switch.php';
+        if (!class_exists('IC2_Switch', false)) {
+            include P2EX_LIB_DIR . '/ic2/Switch.php';
+        }
         $switch = (bool)$_REQUEST['switch'];
         if (IC2_Switch::set($switch, !empty($_REQUEST['mobile']))) {
             if ($switch) {

Modified: p2ex/trunk/ic2.php
===================================================================
--- p2ex/trunk/ic2.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/ic2.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -19,14 +19,8 @@
 // {{{ ‰Šú‰»
 
 // ƒ‰ƒCƒuƒ‰ƒŠ“ǂݍž‚Ý
-require_once 'PEAR.php';
-require_once 'DB/DataObject.php';
 require_once 'HTTP/Client.php';
-require_once P2EX_LIB_DIR . '/ic2/findexec.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php';
-require_once P2EX_LIB_DIR . '/ic2/Thumbnailer.php';
+require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
 
 // Žó‚¯•t‚¯‚éMIMEƒ^ƒCƒv
 $mimemap = array('image/jpeg' => '.jpg', 'image/png' => '.png', 'image/gif' => '.gif');
@@ -419,10 +413,7 @@
     } else {
         $clamscan = 'clamscan';
     }
-    if (findexec($clamscan, $searchpath)) {
-        if ($searchpath) {
-            $clamscan = $searchpath . DIRECTORY_SEPARATOR . $clamscan;
-        }
+    if ($clamscan = ic2_findexec($clamscan, $searchpath)) {
         $scan_command = $clamscan . ' --stdout ' . escapeshellarg(realpath($tmpfile));
         $scan_result  = @exec($scan_command, $scan_stdout, $scan_result);
         if ($scan_result == 1) {
@@ -818,7 +809,6 @@
             }
 
             $k_at_a = str_replace('&amp;', '&', $_conf['k_at_a']);
-            $sid_at_a = str_replace('&amp;', '&', $_conf['sid_at_a']);
             $setrank_url = "ic2.php?{$img_q}&t={$thumb}&r=0{$k_at_a}";
 
             $flexy->setData('stars', $stars);
@@ -833,7 +823,7 @@
                     $link = $path;
                 }
                 $r = ($ini['General']['redirect'] == 1) ? 1 : 2;
-                $preview = "{$_SERVER['SCRIPT_NAME']}?o=1&r={$r}&t={$t}&{$img_q}{$k_at_a}{$sid_at_a}";
+                $preview = "{$_SERVER['SCRIPT_NAME']}?o=1&r={$r}&t={$t}&{$img_q}{$k_at_a}";
                 $flexy->setData('preview', $preview);
                 $flexy->setData('link', $link);
                 $flexy->setData('info', null);

Modified: p2ex/trunk/ic2_fitimage.php
===================================================================
--- p2ex/trunk/ic2_fitimage.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/ic2_fitimage.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -6,8 +6,7 @@
 // {{{ p2Šî–{Ý’è“ǂݍž‚Ý&”FØ
 
 require_once './conf/conf.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php';
-require_once P2EX_LIB_DIR . '/ic2/Thumbnailer.php';
+require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
 
 $_login->authorize();
 

Modified: p2ex/trunk/ic2_getinfo.php
===================================================================
--- p2ex/trunk/ic2_getinfo.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/ic2_getinfo.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -29,13 +29,7 @@
 }
 
 // ƒ‰ƒCƒuƒ‰ƒŠ“ǂݍž‚Ý
-require_once 'PEAR.php';
-require_once 'DB.php';
-require_once 'DB/DataObject.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php';
-require_once P2EX_LIB_DIR . '/ic2/Thumbnailer.php';
+require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
 
 // }}}
 // {{{ execute

Modified: p2ex/trunk/ic2_getter.php
===================================================================
--- p2ex/trunk/ic2_getter.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/ic2_getter.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -22,10 +22,7 @@
 require_once 'HTML/QuickForm.php';
 require_once 'HTML/QuickForm/Renderer/ObjectFlexy.php';
 require_once 'HTML/Template/Flexy.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php';
-require_once P2EX_LIB_DIR . '/ic2/Thumbnailer.php';
+require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
 
 // ƒ|ƒbƒvƒAƒbƒvƒEƒCƒ“ƒhƒEH
 if (empty($_GET['popup'])) {

Modified: p2ex/trunk/ic2_manager.php
===================================================================
--- p2ex/trunk/ic2_manager.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/ic2_manager.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -19,10 +19,8 @@
 // {{{ ‰Šú‰»
 
 // ƒ‰ƒCƒuƒ‰ƒŠ“ǂݍž‚Ý
-require_once 'PEAR.php';
-require_once 'DB.php';
 require_once 'HTML/Template/Flexy.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
+require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
 
 // Ý’è“ǂݍž‚Ý
 $ini = ic2_loadconfig();
@@ -52,8 +50,6 @@
 
         case 'dropZero':
         case 'dropAborn':
-            require_once P2EX_LIB_DIR . '/ic2/managedb.inc.php';
-
             if ($_POST['action'] == 'dropZero') {
                 $where = $db->quoteIdentifier('rank') . ' = 0';
                 if (isset($_POST['dropZeroLimit'])) {
@@ -89,7 +85,7 @@
                 break;
             }
             $target = $result[0];
-            $removed_files = manageDB_remove($target, $to_blacklist);
+            $removed_files = IC2_DatabaseManager::remove($target, $to_blacklist);
             $flexy->setData('toBlackList', $to_blacklist);
             break;
 

Modified: p2ex/trunk/ic2_mkthumb.php
===================================================================
--- p2ex/trunk/ic2_mkthumb.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/ic2_mkthumb.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -21,11 +21,7 @@
     exit;
 }*/
 
-require_once 'PEAR.php';
-require_once 'DB/DataObject.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
-require_once P2EX_LIB_DIR . '/ic2/Thumbnailer.php';
+require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
 
 // {{{ ƒŠƒNƒGƒXƒgƒpƒ‰ƒ[ƒ^‚̏ˆ—
 

Modified: p2ex/trunk/ic2_setrank.php
===================================================================
--- p2ex/trunk/ic2_setrank.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/ic2_setrank.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -39,12 +39,7 @@
 }
 
 // ƒ‰ƒCƒuƒ‰ƒŠ“ǂݍž‚Ý
-require_once 'PEAR.php';
-require_once 'DB.php';
-require_once 'DB/DataObject.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php';
+require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
 
 // }}}
 // {{{ execute
@@ -70,12 +65,11 @@
 
     if ($remove) {
         global $_info_msg_ht;
-        require_once P2EX_LIB_DIR . '/ic2/managedb.inc.php';
 
         $orig_info_msg_ht = $_info_msg_ht;
         $_info_msg_ht = '';
 
-        $removed_files = manageDB_remove(array($finder->id), $rank < 0);
+        $removed_files = IC2_DatabaseManager::remove(array($finder->id), $rank < 0);
         if ($code != 0 && $_info_msg_ht === '') {
             $code = 1;
         } else {

Modified: p2ex/trunk/ic2_setter.php
===================================================================
--- p2ex/trunk/ic2_setter.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/ic2_setter.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -19,10 +19,7 @@
 // {{{ ƒ‰ƒCƒuƒ‰ƒŠ“ǂݍž‚Ý
 
 require_once 'HTML/Template/Flexy.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php';
-require_once P2EX_LIB_DIR . '/ic2/Thumbnailer.php';
+require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
 
 // }}}
 // {{{ config

Modified: p2ex/trunk/ic2_viewtable.php
===================================================================
--- p2ex/trunk/ic2_viewtable.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/ic2_viewtable.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -19,12 +19,8 @@
 // {{{ ‰Šú‰»
 
 // ƒ‰ƒCƒuƒ‰ƒŠ“ǂݍž‚Ý
-require_once 'PEAR.php';
-require_once 'DB/DataObject.php';
 require_once 'HTML/Template/Flexy.php';
-require_once P2EX_LIB_DIR . '/ic2/findexec.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
+require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
 
 // }}}
 // {{{ Ý’è‚ƏÁ‹Ž
@@ -39,13 +35,11 @@
 $mode = $_REQUEST['table'];
 switch ($mode) {
     case 'errlog':
-        require_once P2EX_LIB_DIR . '/ic2/DataObject/Errors.php';
         $table = new IC2_DataObject_Errors;
         $table->orderBy('occured ASC');
         $title = 'ƒGƒ‰[ƒƒO';
         break;
     case 'blacklist':
-        require_once P2EX_LIB_DIR . '/ic2/DataObject/BlackList.php';
         $table = new IC2_DataObject_BlackList;
         $table->orderBy('uri ASC');
         $title = 'ƒuƒ‰ƒbƒNƒŠƒXƒg';
@@ -99,11 +93,11 @@
     switch ($mode) {
         case 'errlog':
             $flexy->setData('data_renderer_errlog', TRUE);
-            $flexy->setData('data', ic2dumptable_errlog($table));
+            $flexy->setData('data', ic2_dump_table_errlog($table));
             break;
         case 'blacklist':
             $flexy->setData('data_renderer_blacklist', TRUE);
-            $flexy->setData('data', ic2dumptable_blacklist($table));
+            $flexy->setData('data', ic2_dump_table_blacklist($table));
             break;
     }
 }
@@ -114,12 +108,12 @@
 
 // }}}
 // {{{ ŠÖ”
-// {{{ ic2dumptable_errlog()
+// {{{ ic2_dump_table_errlog()
 
 /**
  * ƒGƒ‰[ƒƒO‚ðŽæ“¾‚·‚é
  */
-function ic2dumptable_errlog($dbdo)
+function ic2_dump_table_errlog($dbdo)
 {
     $data = array();
     while ($dbdo->fetch()) {
@@ -134,12 +128,12 @@
 }
 
 // }}}
-// {{{ ic2dumptable_blacklist()
+// {{{ ic2_dump_table_blacklist()
 
 /**
  * ƒuƒ‰ƒbƒNƒŠƒXƒg‚ðŽæ“¾‚·‚é
  */
-function ic2dumptable_blacklist($dbdo)
+function ic2_dump_table_blacklist($dbdo)
 {
     $data = array();
     while ($dbdo->fetch()) {

Modified: p2ex/trunk/index.php
===================================================================
--- p2ex/trunk/index.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/index.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -30,7 +30,7 @@
     //=========================================================
     // urlŽw’肪‚ ‚ê‚΁A‚»‚̂܂܃XƒŒƒbƒh“Ç‚Ý‚Ö”ò‚΂·
     if (!empty($_GET['url']) || !empty($_GET['nama_url'])) {
-        header('Location: '.$me_dir_url.'/read.php?'.$_SERVER['QUERY_STRING']);
+        header('Location: '.$me_dir_url . '/read.php?' . $_SERVER['QUERY_STRING']);
         exit;
     }
     if ($_conf['iphone']) {
@@ -47,7 +47,7 @@
     $title_page = "title.php";
 
     if (!empty($_GET['url']) || !empty($_GET['nama_url'])) {
-        $htm['read_page'] = "read.php?".$_SERVER['QUERY_STRING'];
+        $htm['read_page'] = 'read.php?' . $_SERVER['QUERY_STRING'];
     } else {
         if (!empty($_conf['first_page'])) {
             $htm['read_page'] = $_conf['first_page'];

Modified: p2ex/trunk/iv2.php
===================================================================
--- p2ex/trunk/iv2.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/iv2.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -44,25 +44,14 @@
 // {{{ ‰Šú‰»
 
 // ƒ‰ƒCƒuƒ‰ƒŠ“ǂݍž‚Ý
-require_once 'PEAR.php';
 require_once 'Cache.php';
 require_once 'Cache/Function.php';
-require_once 'DB.php';
-require_once 'DB/DataObject.php';
 require_once 'HTML/QuickForm.php';
 require_once 'HTML/QuickForm/Renderer/ObjectFlexy.php';
 require_once 'HTML/Template/Flexy.php';
 require_once 'HTML/Template/Flexy/Element.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php';
-require_once P2EX_LIB_DIR . '/ic2/Thumbnailer.php';
+require_once P2EX_LIB_DIR . '/ic2/bootstrap.php';
 require_once P2EX_LIB_DIR . '/ic2/QuickForm/Rules.php';
-require_once P2EX_LIB_DIR . '/ic2/EditForm.php';
-require_once P2EX_LIB_DIR . '/ic2/managedb.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/getvalidvalue.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/buildimgcell.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/Matrix.php';
 
 // }}}
 // {{{ config
@@ -337,16 +326,16 @@
 // ŒŸØ
 $qf->validate();
 $sv = $qf->getSubmitValues();
-$page      = getValidValue('page',   $_defaults['page'], 'intval');
-$cols      = getValidValue('cols',   $_defaults['cols'], 'intval');
-$rows      = getValidValue('rows',   $_defaults['rows'], 'intval');
-$order     = getValidValue('order',  $_defaults['order']);
-$sort      = getValidValue('sort',   $_defaults['sort'] );
-$field     = getValidValue('field',  $_defaults['field']);
-$key       = getValidValue('key',    $_defaults['key']);
-$threshold = getValidValue('threshold', $_defaults['threshold'], 'intval');
-$compare   = getValidValue('compare',   $_defaults['compare']);
-$mode      = getValidValue('mode',      $_defaults['mode'], 'intval');
+$page      = IC2_ParameterUtility::getValidValue('page',   $_defaults['page'], 'intval');
+$cols      = IC2_ParameterUtility::getValidValue('cols',   $_defaults['cols'], 'intval');
+$rows      = IC2_ParameterUtility::getValidValue('rows',   $_defaults['rows'], 'intval');
+$order     = IC2_ParameterUtility::getValidValue('order',  $_defaults['order']);
+$sort      = IC2_ParameterUtility::getValidValue('sort',   $_defaults['sort'] );
+$field     = IC2_ParameterUtility::getValidValue('field',  $_defaults['field']);
+$key       = IC2_ParameterUtility::getValidValue('key',    $_defaults['key']);
+$threshold = IC2_ParameterUtility::getValidValue('threshold', $_defaults['threshold'], 'intval');
+$compare   = IC2_ParameterUtility::getValidValue('compare',   $_defaults['compare']);
+$mode      = IC2_ParameterUtility::getValidValue('mode',      $_defaults['mode'], 'intval');
 
 // Œg‘Ñ—p‚É’²®
 if ($_conf['ktai']) {
@@ -477,14 +466,14 @@
     // ˆêŠ‡‚Ńpƒ‰ƒ[ƒ^•ÏX
     case 1:
         // ƒ‰ƒ“ƒN‚ð•ÏX
-        $newrank = intoRange($_POST['setrank'], -1, 5);
-        manageDB_setRank($target, $newrank);
+        $newrank = IC2_ParameterUtility::intoRange($_POST['setrank'], -1, 5);
+        IC2_DatabaseManager::setRank($target, $newrank);
         // ƒƒ‚‚ð’ljÁ
         if (!empty($_POST['addmemo'])) {
             $newmemo = get_magic_quotes_gpc() ? stripslashes($_POST['addmemo']) : $_POST['addmemo'];
             $newmemo = $icdb->uniform($newmemo, 'CP932');
             if ($newmemo !== '') {
-                 manageDB_addMemo($target, $newmemo);
+                 IC2_DatabaseManager::addMemo($target, $newmemo);
             }
         }
         break;
@@ -520,13 +509,14 @@
 
         // î•ñ‚ðXV
         if (count($updated) > 0) {
-            manageDB_update($updated);
+            IC2_DatabaseManager::update($updated);
         }
 
         // íœi•ƒuƒ‰ƒbƒNƒŠƒXƒg‘—‚èj
         if (count($removed) > 0) {
             foreach ($removed as $id => $to_blacklist) {
-                $removed_files = array_merge($removed_files, manageDB_remove(array($id), $to_blacklist));
+                $removed_files = array_merge($removed_files,
+                                             IC2_DatabaseManager::remove(array($id), $to_blacklist));
             }
             if ($to_blacklist) {
                 if ($no_blacklist) {
@@ -549,7 +539,8 @@
 } elseif ($mode == 1 && isset($_POST['edit_remove']) && !empty($_POST['change'])) {
     $target = array_unique(array_map('intval', $_POST['change']));
     $to_blacklist = !empty($_POST['edit_toblack']);
-    $removed_files = array_merge($removed_files, manageDB_remove($target, $to_blacklist));
+    $removed_files = array_merge($removed_files,
+                                 IC2_DatabaseManager::remove($target, $to_blacklist));
     $flexy->setData('toBlackList', $to_blacklist);
 }
 
@@ -795,7 +786,7 @@
     } else {
         $k_backto = '';
     }
-    $sid_at_a = str_replace('&amp;', '&', $_conf['sid_at_a']);
+
     while ($icdb->fetch()) {
         // ŒŸõŒ‹‰Ê‚ð”z—ñ‚É‚µAƒŒƒ“ƒ_ƒŠƒ“ƒO—p‚Ì—v‘f‚ð•t‰Á
         // ”z—ñ‚Ç‚¤‚µ‚È‚ç+‰‰ŽZŽq‚Å—v‘f‚ð’ljÁ‚Å‚«‚é
@@ -818,7 +809,7 @@
 
         // •\Ž¦—p•Ï”‚ðÝ’è
         if ($enable_cache) {
-            $add = $cache->call('ic2_image_extra_info', $img);
+            $add = $cache->call('IC2_ImageInfo::getExtraInfo', $img);
             if ($mode == 1) {
                 $chk = IC2_EditForm::imgChecker($img); // ”äŠr“IŒy‚¢‚̂ŃLƒƒƒbƒVƒ…‚µ‚È‚¢
                 $add += $chk;
@@ -827,7 +818,7 @@
                 $add += $mng;
             }
         } else {
-            $add = ic2_image_extra_info($img);
+            $add = IC2_ImageInfo::getExtraInfo($img);
             if ($mode == 1) {
                 $chk = IC2_EditForm::imgChecker($img);
                 $add += $chk;
@@ -841,7 +832,8 @@
             $add['thumb_k'] = $add['thumb'] = 'img/ic_removed.png';
             $add['t_width'] = $add['t_height'] = 32;
             $to_blacklist = false;
-            $removed_files = array_merge($removed_files, manageDB_remove(array($img['id'], $to_blacklist)));
+            $removed_files = array_merge($removed_files,
+                                         IC2_DatabaseManager::remove(array($img['id'], $to_blacklist)));
             $flexy->setData('toBlackList', $to_blacklist);
         } else {
             if (!file_exists($add['thumb'])) {
@@ -852,7 +844,6 @@
                 } else {
                     $add['thumb'] .= '&uri=' . rawurlencode($img['uri']);
                 }
-                $add['thumb'] .= $sid_at_a;
             }
             if ($_conf['ktai']) {
                 $add['thumb_k'] = 'ic2.php?r=0&t=2';
@@ -861,14 +852,14 @@
                 } else {
                     $add['thumb_k'] .= '&uri=' . rawurlencode($img['uri']);
                 }
-                $add['thumb_k'] .= $k_backto . $sid_at_a;
+                $add['thumb_k'] .= $k_backto;
             }
         }
         $item = array_merge($img, $add, $status);
 
         // Exifî•ñ‚ðŽæ“¾
         if ($show_exif && file_exists($add['src']) && $img['mime'] == 'image/jpeg') {
-            $item['exif'] = $enable_cache ? $cache->call('ic2_read_exif', $add['src']) : ic2_read_exif($add['src']);
+            $item['exif'] = $enable_cache ? $cache->call('IC2_ImageInfo::getExifData', $add['src']) : IC2_ImageInfo::getExifData($add['src']);
         } else {
             $item['exif'] = null;
         }

Added: p2ex/trunk/js/motolspopup.js
===================================================================
--- p2ex/trunk/js/motolspopup.js	                        (rev 0)
+++ p2ex/trunk/js/motolspopup.js	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,76 @@
+/**
+ * rep2expack - ƒŒƒX‚Ì•\Ž¦”͈͂ðŽw’肵‚ÄŒ³ƒXƒŒ‚ðŠJ‚­ƒ|ƒbƒvƒAƒbƒv‚ð•\Ž¦/”ñ•\Ž¦‚·‚é
+ */
+
+var _MOTOLSPOPUP_PARAMETERS = [
+	{ 'label': '>>1',    'parameter': '1' },
+	{ 'label': '1-10',   'parameter': '1-10' },
+	{ 'label': '1-100',  'parameter': '1-100' },
+	{ 'label': 'ÅV50', 'parameter': 'l50' },
+	{ 'label': '‘S•”',   'parameter': '' }
+];
+
+function showMotoLsPopUp(event, origin, title)
+{
+	var div, baseUrl, url, anchor, i, l;
+
+	l = _MOTOLSPOPUP_PARAMETERS.length;
+
+	div = document.getElementById('motols');
+	if (!div) {
+		div = document.createElement('div');
+		div.id = 'motols';
+		div.className = 'popup_element';
+		div.onmouseover = showMotoLsPopUpDo;
+		div.onmouseout = hideMotoLsPopUp;
+
+		for (i = 0; i < l; i++) {
+			anchor = document.createElement('a');
+			anchor.appendChild(document.createTextNode(_MOTOLSPOPUP_PARAMETERS[i].label));
+			div.appendChild(anchor);
+		}
+
+		document.body.insertBefore(div, document.body.firstChild);
+	}
+
+	if (title) {
+		title += '\n';
+	} else {
+		title = '';
+	}
+
+	//var target = origin.hasAttribute('target') ? origin.getAttribute('target') : null;
+	baseUrl = origin.getAttribute('href');
+	for (i = 0; i < l; i++) {
+		anchor = div.childNodes[i];
+		url = baseUrl + _MOTOLSPOPUP_PARAMETERS[i].parameter;
+		anchor.setAttribute('href', url);
+		anchor.setAttribute('title', title + url);
+		/*if (tgt) {
+			anchor.setAttribute('target', tgt);
+		}*/
+	}
+
+	showMotoLsPopUpDo(event);
+}
+
+function showMotoLsPopUpDo(event)
+{
+	showResPopUp('motols', event || window.event);
+}
+
+function hideMotoLsPopUp()
+{
+	hideResPopUp('motols');
+}
+
+/*
+ * Local Variables:
+ * mode: javascript
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ */
+/* vim: set syn=javascript fenc=cp932 ai noet ts=4 sw=4 sts=4 fdm=marker: */

Modified: p2ex/trunk/lib/HostCheck.php
===================================================================
--- p2ex/trunk/lib/HostCheck.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/HostCheck.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -70,11 +70,10 @@
             return $function($remote);
         }
 
-        $cache_db = $_conf['cache_dir'] . '/hostcheck_gethostby.sq3';
-        if (!file_exists($cache_db)) {
-            FileCtl::mkdir_for($cache_db);
+        if (!file_exists($_conf['hostcheck_db_path'])) {
+            FileCtl::mkdir_for($_conf['hostcheck_db_path']);
         }
-        $kvs = P2KeyValueStore::getStore($cache_db);
+        $kvs = P2KeyValueStore::getStore($_conf['hostcheck_db_path']);
 
         $result = $kvs->get($remote, $lifeTime);
         if ($result !== null) {

Modified: p2ex/trunk/lib/P2Client.php
===================================================================
--- p2ex/trunk/lib/P2Client.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2Client.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -129,7 +129,7 @@
         try {
             $cookieSavePath = $cookieSaveDir . DIRECTORY_SEPARATOR . self::COOKIE_STORE_NAME;
             $cookieStore = P2KeyValueStore::getStore($cookieSavePath,
-                                                     P2KeyValueStore::KVS_SERIALIZING);
+                                                     P2KeyValueStore::CODEC_SERIALIZING);
         } catch (Exception $e) {
             throw new P2Exception(get_class($e) . ': ' . $e->getMessage());
         }

Modified: p2ex/trunk/lib/P2DataStore/AbstractDataStore.php
===================================================================
--- p2ex/trunk/lib/P2DataStore/AbstractDataStore.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2DataStore/AbstractDataStore.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -2,6 +2,9 @@
 /**
  * rep2expack - P2KeyValueStore‚ðƒ‰ƒbƒv‚·‚é
  * ƒ†[ƒeƒBƒŠƒeƒBƒNƒ‰ƒX‚Ì‚½‚ß‚ÌŠî’ê’ŠÛƒNƒ‰ƒX
+ *
+ * P2KeyValueStore‚Írep2‚Ɉˑ¶‚¹‚¸’P‘Ì‚ÅŽg‚¦‚邪A
+ * P2DataStore‚Írep2‚ÅŽg‚¤‚½‚߂ɐ݌v‚³‚ê‚Ä‚¢‚éB
  */
 
 require_once P2_LIB_DIR . '/P2KeyValueStore.php';
@@ -12,6 +15,11 @@
 {
     // {{{ properties
 
+    /**
+     * P2KeyValueStoreƒIƒuƒWƒFƒNƒg‚ð•ÛŽ‚·‚é˜A‘z”z—ñ
+     *
+     * @var array
+     */
     static private $_kvs = array();
 
     // }}}
@@ -25,12 +33,14 @@
      * @return P2KeyValueStore
      */
     static protected function _getKVS($databasePath,
-                                      $type = P2KeyValueStore::KVS_SERIALIZING)
+                                      $type = P2KeyValueStore::CODEC_SERIALIZING)
     {
         global $_conf;
 
-        if (array_key_exists($databasePath, self::$_kvs)) {
-            return self::$_kvs[$databasePath];
+        $id = $type . ':' . $databasePath;
+
+        if (array_key_exists($id, self::$_kvs)) {
+            return self::$_kvs[$id];
         }
 
         if (!file_exists($databasePath) && !is_dir(dirname($databasePath))) {
@@ -39,7 +49,7 @@
 
         try {
             $kvs = P2KeyValueStore::getStore($databasePath, $type);
-            self::$_kvs[$databasePath] = $kvs;
+            self::$_kvs[$id] = $kvs;
         } catch (Exception $e) {
             p2die(get_class($e) . ': ' . $e->getMessage());
         }
@@ -133,8 +143,11 @@
             return $kvs->clear();
         }
 
-        $pattern = str_replace(array('%', '_'), array('\\%', '\\_'), $kvs->encodeKey($prefix));
-        $stmt = $kvs->prepare('DELETE FROM $__table WHERE arkey LIKE :pattern ESCAPE :escape', true);
+        $pattern = str_replace(array(  '%',   '_',   '\\'),
+                               array('\\%', '\\_', '\\\\'),
+                               $kvs->encodeKey($prefix));
+        $query = 'DELETE FROM $__table WHERE $__key LIKE :pattern ESCAPE :escape';
+        $stmt = $kvs->prepare($query);
         $stmt->bindValue(':pattern', $pattern);
         $stmt->bindValue(':escape', '\\');
 

Modified: p2ex/trunk/lib/P2DataStore/CookieStore.php
===================================================================
--- p2ex/trunk/lib/P2DataStore/CookieStore.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2DataStore/CookieStore.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -94,8 +94,11 @@
             return $kvs->clear();
         }
 
-        $pattern = str_replace(array('%', '_'), array('\\%', '\\_'), $kvs->encodeKey($prefix));
-        $stmt = $kvs->prepare('DELETE FROM $__table WHERE arkey LIKE :pattern ESCAPE :escape', true);
+        $pattern = str_replace(array(  '%',   '_',   '\\'),
+                               array('\\%', '\\_', '\\\\'),
+                               $kvs->encodeKey($prefix));
+        $query = 'DELETE FROM $__table WHERE $__key LIKE :pattern ESCAPE :escape';
+        $stmt = $kvs->prepare($query);
         $stmt->bindValue(':pattern', $pattern);
         $stmt->bindValue(':escape', '\\');
 

Modified: p2ex/trunk/lib/P2DataStore/PostDataStore.php
===================================================================
--- p2ex/trunk/lib/P2DataStore/PostDataStore.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2DataStore/PostDataStore.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -94,8 +94,11 @@
             return $kvs->clear();
         }
 
-        $pattern = str_replace(array('%', '_'), array('\\%', '\\_'), $kvs->encodeKey($prefix));
-        $stmt = $kvs->prepare('DELETE FROM $__table WHERE arkey LIKE :pattern ESCAPE :escape', true);
+        $pattern = str_replace(array(  '%',   '_',   '\\'),
+                               array('\\%', '\\_', '\\\\'),
+                               $kvs->encodeKey($prefix));
+        $query = 'DELETE FROM $__table WHERE $__key LIKE :pattern ESCAPE :escape';
+        $stmt = $kvs->prepare($query);
         $stmt->bindValue(':pattern', $pattern);
         $stmt->bindValue(':escape', '\\');
 

Deleted: p2ex/trunk/lib/P2KeyValueStore/Binary.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Binary.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2KeyValueStore/Binary.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,52 +0,0 @@
-<?php
-require_once dirname(__FILE__) . '/../P2KeyValueStore.php';
-
-// {{{ P2KeyValueStore_Binary
-
-/**
- * ƒoƒCƒiƒŠƒf[ƒ^‚ð‰i‘±‰»‚·‚é
- */
-class P2KeyValueStore_Binary extends P2KeyValueStore
-{
-    // {{{ encodeValue()
-
-    /**
-     * ƒf[ƒ^‚ðBase64ƒGƒ“ƒR[ƒh‚·‚é
-     *
-     * @param string $value
-     * @return string
-     */
-    public function encodeValue($value)
-    {
-        return base64_encode($value);
-    }
-
-    // }}}
-    // {{{ decodeValue()
-
-    /**
-     * ƒf[ƒ^‚ðBase64ƒfƒR[ƒh‚·‚é
-     *
-     * @param string $value
-     * @return string
-     */
-    public function decodeValue($value)
-    {
-        return base64_decode($value);
-    }
-
-    // }}}
-}
-
-// }}}
-
-/*
- * 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:

Copied: p2ex/trunk/lib/P2KeyValueStore/Codec/Binary.php (from rev 771, p2ex/trunk/lib/P2KeyValueStore/Binary.php)
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Codec/Binary.php	                        (rev 0)
+++ p2ex/trunk/lib/P2KeyValueStore/Codec/Binary.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,79 @@
+<?php
+
+// {{{ P2KeyValueStore_Codec_Binary
+
+/**
+ * ƒoƒCƒiƒŠƒf[ƒ^—pCodec
+ */
+class P2KeyValueStore_Codec_Binary implements P2KeyValueStore_Codec_Interface
+{
+    // {{{ encodeKey()
+
+    /**
+     * ƒL[‚Í‚»‚Ì‚Ü‚Ü
+     *
+     * @param string $key
+     * @return string
+     */
+    public function encodeKey($key)
+    {
+        return $key;
+    }
+
+    // }}}
+    // {{{ decodeKey()
+
+    /**
+     * ƒL[‚Í‚»‚Ì‚Ü‚Ü
+     *
+     * @param string $key
+     * @return string
+     */
+    public function decodeKey($key)
+    {
+        return $key;
+    }
+
+    // }}}
+    // {{{ encodeValue()
+
+    /**
+     * ƒf[ƒ^‚ðBase64ƒGƒ“ƒR[ƒh‚·‚é
+     *
+     * @param string $value
+     * @return string
+     */
+    public function encodeValue($value)
+    {
+        return base64_encode($value);
+    }
+
+    // }}}
+    // {{{ decodeValue()
+
+    /**
+     * ƒf[ƒ^‚ðBase64ƒfƒR[ƒh‚·‚é
+     *
+     * @param string $value
+     * @return string
+     */
+    public function decodeValue($value)
+    {
+        return base64_decode($value);
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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:

Copied: p2ex/trunk/lib/P2KeyValueStore/Codec/Compressing.php (from rev 771, p2ex/trunk/lib/P2KeyValueStore/Compressing.php)
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Codec/Compressing.php	                        (rev 0)
+++ p2ex/trunk/lib/P2KeyValueStore/Codec/Compressing.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,51 @@
+<?php
+
+// {{{ P2KeyValueStore_Codec_Compressing
+
+/**
+ * ƒTƒCƒY‚Ì‘å‚«‚¢ƒf[ƒ^‚ðˆ³k‚·‚éCodec
+ */
+class P2KeyValueStore_Codec_Compressing extends P2KeyValueStore_Codec_Binary
+{
+    // {{{ encodeValue()
+
+    /**
+     * ƒf[ƒ^‚ðˆ³k‚·‚é
+     *
+     * @param string $value
+     * @return string
+     */
+    public function encodeValue($value)
+    {
+        return parent::encodeValue(gzdeflate($value, 6));
+    }
+
+    // }}}
+    // {{{ decodeValue()
+
+    /**
+     * ƒf[ƒ^‚ð“WŠJ‚·‚é
+     *
+     * @param string $value
+     * @return string
+     */
+    public function decodeValue($value)
+    {
+        return gzinflate(parent::decodeValue($value));
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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/P2KeyValueStore/Codec/Default.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Codec/Default.php	                        (rev 0)
+++ p2ex/trunk/lib/P2KeyValueStore/Codec/Default.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,79 @@
+<?php
+
+// {{{ P2KeyValueStore_Codec_Default
+
+/**
+ * ‰½‚à‚µ‚È‚¢Codec
+ */
+class P2KeyValueStore_Codec_Default implements P2KeyValueStore_Codec_Interface
+{
+    // {{{ encodeKey()
+
+    /**
+     * ƒL[‚Í‚»‚Ì‚Ü‚Ü
+     *
+     * @param string $key
+     * @return string
+     */
+    public function encodeKey($key)
+    {
+        return $key;
+    }
+
+    // }}}
+    // {{{ decodeKey()
+
+    /**
+     * ƒL[‚Í‚»‚Ì‚Ü‚Ü
+     *
+     * @param string $key
+     * @return string
+     */
+    public function decodeKey($key)
+    {
+        return $key;
+    }
+
+    // }}}
+    // {{{ encodeValue()
+
+    /**
+     * ’l‚Í‚»‚Ì‚Ü‚Ü
+     *
+     * @param string $value
+     * @return string
+     */
+    public function encodeValue($value)
+    {
+        return $value;
+    }
+
+    // }}}
+    // {{{ decodeValue()
+
+    /**
+     * ’l‚Í‚»‚Ì‚Ü‚Ü
+     *
+     * @param string $value
+     * @return string
+     */
+    public function decodeValue($value)
+    {
+        return $value;
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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/P2KeyValueStore/Codec/Interface.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Codec/Interface.php	                        (rev 0)
+++ p2ex/trunk/lib/P2KeyValueStore/Codec/Interface.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,67 @@
+<?php
+
+// {{{ P2KeyValueStore_Codec_Interface
+
+/**
+ * P2KeyValueStore‚ªŽg‚¤Codec‚̃Cƒ“ƒ^[ƒtƒFƒCƒX’è‹`
+ */
+interface P2KeyValueStore_Codec_Interface
+{
+    // {{{ encodeKey()
+
+    /**
+     * ƒL[‚ðUTF-8 (or US-ASCII) •¶Žš—ñ‚ɃGƒ“ƒR[ƒh‚·‚é
+     *
+     * @param string $key
+     * @return string
+     */
+    public function encodeKey($key);
+
+    // }}}
+    // {{{ decodeKey()
+
+    /**
+     * ƒL[‚ðƒfƒR[ƒh‚·‚é
+     *
+     * @param string $key
+     * @return string
+     */
+    public function decodeKey($key);
+
+    // }}}
+    // {{{ encodeValue()
+
+    /**
+     * ’l‚ðUTF-8 (or US-ASCII) •¶Žš—ñ‚ɃGƒ“ƒR[ƒh‚·‚é
+     *
+     * @param string $value
+     * @return string
+     */
+    public function encodeValue($value);
+
+    // }}}
+    // {{{ decodeValue()
+
+    /**
+     * ’l‚ðƒfƒR[ƒh‚·‚é
+     *
+     * @param string $value
+     * @return string
+     */
+    public function decodeValue($value);
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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:

Copied: p2ex/trunk/lib/P2KeyValueStore/Codec/Serializing.php (from rev 771, p2ex/trunk/lib/P2KeyValueStore/Serializing.php)
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Codec/Serializing.php	                        (rev 0)
+++ p2ex/trunk/lib/P2KeyValueStore/Codec/Serializing.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,51 @@
+<?php
+
+// {{{ P2KeyValueStore_Codec_Serializing
+
+/**
+ * ’l‚ðƒVƒŠƒAƒ‰ƒCƒYEƒAƒ“ƒVƒŠƒAƒ‰ƒCƒY‚·‚éCodec
+ */
+class P2KeyValueStore_Codec_Serializing extends P2KeyValueStore_Codec_Compressing
+{
+    // {{{ encodeValue()
+
+    /**
+     * ’l‚ðƒVƒŠƒAƒ‰ƒCƒY‚·‚é
+     *
+     * @param mixed $value
+     * @return string
+     */
+    public function encodeValue($value)
+    {
+        return parent::encodeValue(serialize($value));
+    }
+
+    // }}}
+    // {{{ decodeValue()
+
+    /**
+     * ’l‚ðƒAƒ“ƒVƒŠƒAƒ‰ƒCƒY‚·‚é
+     *
+     * @param string $value
+     * @return mixed
+     */
+    public function decodeValue($value)
+    {
+        return unserialize(parent::decodeValue($value));
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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:

Copied: p2ex/trunk/lib/P2KeyValueStore/Codec/ShiftJIS.php (from rev 771, p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php)
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Codec/ShiftJIS.php	                        (rev 0)
+++ p2ex/trunk/lib/P2KeyValueStore/Codec/ShiftJIS.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,107 @@
+<?php
+
+// {{{ P2KeyValueStore_Codec_ShiftJIS
+
+/**
+ * Shift_JIS (SJIS-win=CP932) ‚Ì•¶Žš—ñ‚ðUTF-8‚É•ÏŠ·E•œŒ³‚·‚éCodec
+ */
+class P2KeyValueStore_Codec_ShiftJIS implements P2KeyValueStore_Codec_Interface
+{
+    // {{{ _encode()
+
+    /**
+     * Shift_JIS‚Ì•¶Žš—ñ‚ðUTF-8‚É•ÏŠ·‚·‚é
+     *
+     * @param string $str
+     * @return string
+     */
+    static private function _encode($str)
+    {
+        return mb_convert_encoding($str, 'UTF-8', 'SJIS-win');
+    }
+
+    // }}}
+    // {{{ _decode()
+
+    /**
+     * UTF-8‚Ì•¶Žš—ñ‚ðShift_JIS‚É•ÏŠ·‚·‚é
+     *
+     * @param string $str
+     * @return string
+     */
+    static private function _decode($str)
+    {
+        return mb_convert_encoding($str, 'SJIS-win', 'UTF-8');
+    }
+
+    // }}}
+    // {{{ encodeKey()
+
+    /**
+     * ƒL[‚ðƒGƒ“ƒR[ƒh‚·‚é
+     *
+     * @param string $key
+     * @return string
+     */
+    public function encodeKey($key)
+    {
+        return self::_encode($key);
+    }
+
+    // }}}
+    // {{{ decodeKey()
+
+    /**
+     * ƒL[‚ðƒfƒR[ƒh‚·‚é
+     *
+     * @param string $key
+     * @return string
+     */
+    public function decodeKey($key)
+    {
+        return self::_decode($key);
+    }
+
+    // }}}
+    // {{{ encodeValue()
+
+    /**
+     * ’l‚ðƒGƒ“ƒR[ƒh‚·‚é
+     *
+     * @param string $value
+     * @return string
+     */
+    public function encodeValue($value)
+    {
+        return self::_encode($value);
+    }
+
+    // }}}
+    // {{{ decodeValue()
+
+    /**
+     * ’l‚ðƒfƒR[ƒh‚·‚é
+     *
+     * @param string $value
+     * @return string
+     */
+    public function decodeValue($value)
+    {
+        return self::_decode($value);
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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:

Deleted: p2ex/trunk/lib/P2KeyValueStore/Compressing.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Compressing.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2KeyValueStore/Compressing.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,52 +0,0 @@
-<?php
-require_once dirname(__FILE__) . '/Binary.php';
-
-// {{{ P2KeyValueStore_Compressing
-
-/**
- * ƒTƒCƒY‚Ì‘å‚«‚¢ƒf[ƒ^‚ðˆ³k‚µ‚ĉi‘±‰»‚·‚é
- */
-class P2KeyValueStore_Compressing extends P2KeyValueStore_Binary
-{
-    // {{{ encodeValue()
-
-    /**
-     * ƒf[ƒ^‚ðˆ³k‚·‚é
-     *
-     * @param string $value
-     * @return string
-     */
-    public function encodeValue($value)
-    {
-        return parent::encodeValue(gzdeflate($value, 6));
-    }
-
-    // }}}
-    // {{{ decodeValue()
-
-    /**
-     * ƒf[ƒ^‚ð“WŠJ‚·‚é
-     *
-     * @param string $value
-     * @return string
-     */
-    public function decodeValue($value)
-    {
-        return gzinflate(parent::decodeValue($value));
-    }
-
-    // }}}
-}
-
-// }}}
-
-/*
- * 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/P2KeyValueStore/FunctionCache/Proxy.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/FunctionCache/Proxy.php	                        (rev 0)
+++ p2ex/trunk/lib/P2KeyValueStore/FunctionCache/Proxy.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,133 @@
+<?php
+
+// {{{ P2KeyValueStore_FunctionCache
+
+/**
+ * P2KeyValueStore_FunctionCache‚ðŽg‚¤ŠÖ”ŒÄ‚яo‚µƒvƒƒLƒV
+ */
+class P2KeyValueStore_FunctionCache_Proxy
+{
+    // {{{ properties
+
+    private $_cache;
+    private $_function;
+    private $_prependedParameters;
+    private $_appendedParameters;
+    private $_lifeTime;
+
+    // }}}
+    // {{{ __construct()
+
+    /**
+     * @param P2KeyValueStore_FunctionCache $cache
+     * @param callable $function
+     * @throws InvalidArgumentException
+     */
+    public function __construct(P2KeyValueStore_FunctionCache $cache, $function)
+    {
+        if (!is_callable($function)) {
+            throw new InvalidArgumentException('Non-callable value was given');
+        }
+        $this->_cache = $cache;
+        $this->_function = $function;
+        $this->_prependedParameters = array();
+        $this->_appendedParameters = array();
+        $this->_lifeTime = -1;
+    }
+
+    // }}}
+    // {{{ __invoke()
+
+    /**
+     * @param mixed $...
+     * @return mixed
+     * @see P2KeyValueStore_FunctionCache_Proxy::invoke()
+     */
+    public function __invoke()
+    {
+        $parameters = $this->_prependedParameters;
+        $arguments = func_get_args();
+        foreach ($arguments as $parameter) {
+            $parameters[] = $parameter;
+        }
+        foreach ($this->_appendedParameters as $parameter) {
+            $parameters[] = $parameter;
+        }
+
+        $oldLifeTime = $this->_cache->setLifeTime($this->_lifeTime);
+        $result = $this->_cache->invoke($this->_function, $parameters);
+        $this->_cache->setLifeTime($oldLifeTime);
+
+        return $result;
+    }
+
+    // }}}
+    // {{{ invoke()
+
+    /**
+     * @param mixed $...
+     * @return mixed
+     */
+    public function invoke()
+    {
+        $args = func_get_args();
+        if (count($args)) {
+            return call_user_func_array(array($this, '__invoke'), $args);
+        } else {
+            return $this->__invoke();
+        }
+    }
+
+    // }}}
+    // {{{ prependParameters()
+
+    /**
+     * @param mixed $...
+     * @return void
+     */
+    public function prependParameters()
+    {
+        $this->_prependedParameters = func_get_args();
+    }
+
+    // }}}
+    // {{{ appendParameters()
+
+    /**
+     * @param mixed $...
+     * @return void
+     */
+    public function appendParameters()
+    {
+        $this->_appendedParameters = func_get_args();
+    }
+
+    // }}}
+    // {{{ setLifeTime()
+
+    /**
+     * @param int $lifeTime
+     * @return int
+     */
+    public function setLifeTime($lifeTime = -1)
+    {
+        $oldLifeTime = $this->_lifeTime;
+        $this->_lifeTime = $lifeTime;
+        return $oldLifeTime;
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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/P2KeyValueStore/FunctionCache.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/FunctionCache.php	                        (rev 0)
+++ p2ex/trunk/lib/P2KeyValueStore/FunctionCache.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,135 @@
+<?php
+
+// {{{ P2KeyValueStore_FunctionCache
+
+/**
+ * P2KeyValueStore‚ðŽg‚¤ŠÖ”ŒÄ‚яo‚µƒLƒƒƒbƒVƒ…
+ */
+class P2KeyValueStore_FunctionCache
+{
+    // {{{ properties
+
+    private $_kvs;
+    private $_lifeTime;
+
+    // }}}
+    // {{{ __construct()
+
+    /**
+     * @param P2KeyValueStore $kvs
+     * @param callable $function
+     */
+    public function __construct(P2KeyValueStore $kvs)
+    {
+        $this->_kvs = $kvs;
+        $this->_lifeTime = -1;
+    }
+
+    // }}}
+    // {{{ getProxy()
+
+    /**
+     * @param callable $function
+     * @return P2KeyValueStore_FunctionCache_Proxy
+     * @throws InvalidArgumentException
+     */
+    public function getProxy($function)
+    {
+        $proxy = new P2KeyValueStore_FunctionCache_Proxy($this, $function);
+        $proxy->setLifeTime($this->_lifeTime);
+        return $proxy;
+    }
+
+    // }}}
+    // {{{ invoke()
+
+    /**
+     * @param callable $function
+     * @param array $parameters
+     * @return mixed
+     * @throws InvalidArgumentException
+     */
+    public function invoke($function, array $parameters = array())
+    {
+        if (!is_callable($function)) {
+            throw new InvalidArgumentException('Non-callable value was given');
+        }
+
+        // ŠÖ”–¼
+        if (is_string($function)) {
+            $name = $function;
+        } elseif (is_object($function)) {
+            $name = get_class($function) . '->__invoke';
+        } elseif (is_object($function[0])) {
+            $name = get_class($function[0]) . '->' . $function[1];
+        } else {
+            $name = $function[0] . '::' . $function[1];
+        }
+
+        // ƒL[
+        $key = strtolower($name) . '(';
+        if ($n = count($parameters)) {
+            $key .= $n . ':' . md5(serialize($parameters));
+        } else {
+            $key .= 'void';
+        }
+        $key .= ')';
+
+        // ƒLƒƒƒbƒVƒ…‚ðŽæ“¾
+        $record = $this->_kvs->getRaw($key);
+        if ($record && !$record->isExpired($this->_lifeTime)) {
+            return $this->_kvs->getCodec()->decodeValue($record->value);
+        }
+
+        // ‚È‚¯‚ê‚Ί֐”‚ðŽÀs
+        if ($n) {
+            if ($n == 1 && !is_array($function)) {
+                $value = $function(reset($parameters));
+            } else {
+                $value = call_user_func_array($function, $parameters);
+            }
+        } elseif (is_array($function)) {
+            $value = call_user_func($function);
+        } else {
+            $value = $function();
+        }
+
+        // ƒLƒƒƒbƒVƒ…‚É•Û‘¶
+        if ($record) {
+            $this->_kvs->update($key, $value);
+        } else {
+            $this->_kvs->set($key, $value);
+        }
+
+        return $value;
+    }
+
+    // }}}
+    // {{{ setLifeTime()
+
+    /**
+     * @param int $lifeTime
+     * @return int
+     */
+    public function setLifeTime($lifeTime = -1)
+    {
+        $oldLifeTime = $this->_lifeTime;
+        $this->_lifeTime = $lifeTime;
+        return $oldLifeTime;
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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/Iterator.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Iterator.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2KeyValueStore/Iterator.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,5 +1,4 @@
 <?php
-require_once dirname(__FILE__) . '/../P2KeyValueStore.php';
 
 // {{{ P2KeyValueStore_Iterator
 

Added: p2ex/trunk/lib/P2KeyValueStore/Result.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Result.php	                        (rev 0)
+++ p2ex/trunk/lib/P2KeyValueStore/Result.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,231 @@
+<?php
+
+// {{{ P2KeyValueStore_Result
+
+/**
+ * P2KeyValueStore‚ÅPDOStatement::fetch()‚ÌŒ‹‰Ê‚ðŠi”[‚·‚é
+ */
+class P2KeyValueStore_Result implements ArrayAccess
+{
+    // {{{ properties
+
+    /**
+     * PDO::FETCH_INTO ‚Å‘ã“ü‚³‚ê‚éƒvƒƒpƒeƒB
+     * P2KeyValueStore ‚ÅŽg‚¤ƒe[ƒuƒ‹‚ÌŠeƒJƒ‰ƒ€–¼‚Æ“¯‚¶
+     */
+    public $id;
+    public $arkey;
+    public $value;
+    public $mtime;
+    public $sort_order;
+
+    /**
+     * ArrayAccess‚̃ƒ\ƒbƒh‚ŃAƒNƒZƒX‚Å‚«‚éƒL[‚Æ
+     * ŽÀÛ‚̃vƒƒpƒeƒB–¼‚̑Ήž•\
+     */
+    static protected $_keyMap = array(
+        0 => 'id',
+        1 => 'arkey',
+        2 => 'value',
+        3 => 'mtime',
+        4 => 'sort_order',
+        'id' => 'id',
+        'key' => 'arkey',
+        'arkey' => 'arkey',
+        'value' => 'value',
+        'mtime' => 'mtime',
+        'order' => 'sort_order',
+        'sort_order' => 'sort_order',
+    );
+
+    // }}}
+    // {{{ isExpired()
+
+    /**
+     * —LŒøŠúŒÀØ‚ê‚̃`ƒFƒbƒN‚ðs‚¤
+     *
+     * @param int $lifeTime
+     * @return bool
+     */
+    public function isExpired($lifeTime)
+    {
+        if ($lifeTime > -1 && $this->mtime < time() - $lifeTime) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    // }}}
+    // {{{ toArray()
+
+    /**
+     * Œ‹‰ÊƒZƒbƒg‚ð˜A‘z”z—ñ‚É•ÏŠ·‚·‚é
+     *
+     * @param P2KeyValueStore_Codec_Interface $codec
+     * @return array
+     */
+    public function toArray(P2KeyValueStore_Codec_Interface $codec = null)
+    {
+        if ($codc === null) {
+            $key = $this->arkey;
+            $value = $this->value;
+        } else {
+            $key = $codec->decodeKey($this->arkey);
+            $value = $codec->decodeValue($this->value);
+        }
+
+        return array(
+            'id' => (int)$this->id,
+            'key' => $key,
+            'value' => $value,
+            'mtime' => (int)$this->mtime,
+            'order' => (int)$this->sort_order,
+        );
+    }
+
+    // }}}
+    // {{{ toObject()
+
+    /**
+     * Œ‹‰ÊƒZƒbƒg‚ð•Ê‚Ì”CˆÓ‚̃IƒuƒWƒFƒNƒg‚É•ÏŠ·‚·‚é
+     *
+     * @param P2KeyValueStore_Codec_Interface $codec
+     * @param mixed $object
+     * @return array
+     */
+    public function toObject($object = null, P2KeyValueStore_Codec_Interface $codec = null)
+    {
+        $properties = $this->toArray($codec);
+
+        if ($object === null) {
+            return (object)$properties; // stdClass
+        }
+
+        if (!is_object($object)) {
+            $object = new $object;
+        }
+        foreach ($properties as $key => $value) {
+            $object->$key = $value;
+        }
+
+        return $object;
+    }
+
+    // }}}
+    // {{{ clear()
+
+    /**
+     * ƒvƒƒpƒeƒB‚ðƒŠƒZƒbƒg‚·‚é
+     *
+     * @param void
+     * @return void
+     */
+    public function clear()
+    {
+        $this->id = null;
+        $this->arkey = null;
+        $this->value = null;
+        $this->mtime = null;
+        $this->sort_order = null;
+    }
+
+    // }}}
+    // {{{ offsetExists()
+
+    /**
+     * ArrayAccess::offsetExists()
+     *
+     * @param string $offset
+     * @return string
+     */
+    public function offsetExists($offset)
+    {
+        return self::_resolveOffset($offset) !== false;
+    }
+
+    // }}}
+    // {{{ offsetGet()
+
+    /**
+     * ArrayAccess::offsetGet()
+     *
+     * @param string $offset
+     * @return mixed
+     */
+    public function offsetGet($offset)
+    {
+        if ($name = self::_resolveOffset($offset)) {
+            return $this->$name;
+        } else {
+            return null;
+        }
+    }
+
+    // }}}
+    // {{{ offsetSet()
+
+    /**
+     * ArrayAccess::offsetSet()
+     *
+     * @param string $offset
+     * @param string $value
+     * @return void
+     */
+    public function offsetSet($offset, $value)
+    {
+        if ($name = self::_resolveOffset($offset)) {
+            $this->$name = $value;
+        }
+    }
+
+    // }}}
+    // {{{ offsetUnset()
+
+    /**
+     * ArrayAccess::offsetUnset()
+     *
+     * @param string $offset
+     * @return void
+     */
+    public function offsetUnset($offset)
+    {
+        if ($name = self::_resolveOffset($offset)) {
+            $this->$name = null;
+        }
+    }
+
+    // }}}
+    // {{{ _resolveOffset()
+
+    /**
+     * ArrayAccess‚̃ƒ\ƒbƒh‚É—^‚¦‚ç‚ꂽƒIƒtƒZƒbƒg‚Æ
+     * ŽÀÛ‚̃vƒƒpƒeƒB–¼‚Ì‰ðŒˆ‚ð‚·‚é
+     *
+     * @param string $offset
+     * @return string
+     */
+    static protected function _resolveOffset($offset)
+    {
+        if (array_key_exists($offset, self::$_keyMap)) {
+            return self::$_keyMap[$offset];
+        } 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:

Deleted: p2ex/trunk/lib/P2KeyValueStore/Serializing.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/Serializing.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2KeyValueStore/Serializing.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,52 +0,0 @@
-<?php
-require_once dirname(__FILE__) . '/Compressing.php';
-
-// {{{ P2KeyValueStore_Serializing
-
-/**
- * ’l‚ðƒVƒŠƒAƒ‰ƒCƒY‚µ‚ĉi‘±‰»‚·‚é
- */
-class P2KeyValueStore_Serializing extends P2KeyValueStore_Compressing
-{
-    // {{{ encodeValue()
-
-    /**
-     * ’l‚ðƒVƒŠƒAƒ‰ƒCƒY‚·‚é
-     *
-     * @param mixed $value
-     * @return string
-     */
-    public function encodeValue($value)
-    {
-        return parent::encodeValue(serialize($value));
-    }
-
-    // }}}
-    // {{{ decodeValue()
-
-    /**
-     * ’l‚ðƒAƒ“ƒVƒŠƒAƒ‰ƒCƒY‚·‚é
-     *
-     * @param string $value
-     * @return mixed
-     */
-    public function decodeValue($value)
-    {
-        return unserialize(parent::decodeValue($value));
-    }
-
-    // }}}
-}
-
-// }}}
-
-/*
- * 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:

Deleted: p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2KeyValueStore/ShiftJIS.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,108 +0,0 @@
-<?php
-require_once dirname(__FILE__) . '/../P2KeyValueStore.php';
-
-// {{{ P2KeyValueStore_ShiftJIS
-
-/**
- * Shift_JIS‚Ì•¶Žš—ñ‚ðUTF-8‚É•ÏŠ·‚µ‚ĉi‘±‰»‚·‚é
- */
-class P2KeyValueStore_ShiftJIS extends P2KeyValueStore
-{
-    // {{{ _encode()
-
-    /**
-     * Shift_JIS (SJIS-win=CP932) ‚Ì•¶Žš—ñ‚ðUTF-8‚É•ÏŠ·‚·‚é
-     *
-     * @param string $str
-     * @return string
-     */
-    private function _encode($str)
-    {
-        return mb_convert_encoding($str, 'UTF-8', 'SJIS-win');
-    }
-
-    // }}}
-    // {{{ _decode()
-
-    /**
-     * UTF-8‚Ì•¶Žš—ñ‚ðShift_JIS (CP932) ‚É•ÏŠ·‚·‚é
-     *
-     * @param string $str
-     * @return string
-     */
-    private function _decode($str)
-    {
-        return mb_convert_encoding($str, 'SJIS-win', 'UTF-8');
-    }
-
-    // }}}
-    // {{{ encodeKey()
-
-    /**
-     * ƒL[‚ðƒGƒ“ƒR[ƒh‚·‚é
-     *
-     * @param string $key
-     * @return string
-     */
-    public function encodeKey($key)
-    {
-        return $this->_encode($key);
-    }
-
-    // }}}
-    // {{{ decodeKey()
-
-    /**
-     * ƒL[‚ðƒfƒR[ƒh‚·‚é
-     *
-     * @param string $key
-     * @return string
-     */
-    public function decodeKey($key)
-    {
-        return $this->_decode($key);
-    }
-
-    // }}}
-    // {{{ encodeValue()
-
-    /**
-     * ’l‚ðƒGƒ“ƒR[ƒh‚·‚é
-     *
-     * @param string $value
-     * @return string
-     */
-    public function encodeValue($value)
-    {
-        return $this->_encode($value);
-    }
-
-    // }}}
-    // {{{ decodeValue()
-
-    /**
-     * ’l‚ðƒfƒR[ƒh‚·‚é
-     *
-     * @param string $value
-     * @return string
-     */
-    public function decodeValue($value)
-    {
-        return $this->_decode($value);
-    }
-
-    // }}}
-}
-
-// }}}
-
-/*
- * 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.php
===================================================================
--- p2ex/trunk/lib/P2KeyValueStore.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2KeyValueStore.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,5 +1,5 @@
 <?php
-require_once dirname(__FILE__) . '/P2KeyValueStore/Iterator.php';
+require_once dirname(__FILE__) . '/P2KeyValueStore/Codec/Interface.php';
 
 // {{{ P2KeyValueStore
 
@@ -34,21 +34,26 @@
     const Q_CLEAR       = 'DELETE FROM $__table';
     const Q_GC          = 'DELETE FROM $__table WHERE mtime < :expires';
 
-    const KVS_DEFAULT       = 'default';
-    const KVS_BINARY        = 'Binary';
-    const KVS_COMPRESSING   = 'Compressing';
-    const KVS_SHIFTJS       = 'ShiftJIS';
-    const KVS_SERIALIZING   = 'Serializing';
+    const CODEC_DEFAULT     = 'P2KeyValueStore_Codec_Default';
+    const CODEC_BINARY      = 'P2KeyValueStore_Codec_Binary';
+    const CODEC_COMPRESSING = 'P2KeyValueStore_Codec_Compressing';
+    const CODEC_SHIFTJIS    = 'P2KeyValueStore_Codec_ShiftJIS';
+    const CODEC_SERIALIZING = 'P2KeyValueStore_Codec_Serializing';
 
+    const MEMORY_DATABASE   = ':memory:';
+
     // }}}
-    // {{{ staric private properties
+    // {{{ static private properties
 
     /**
-     * ƒf[ƒ^ƒx[ƒX–ˆ‚ɈêˆÓ‚ÈPDO,PDOStatement,P2KeyValueStore‚̃Cƒ“ƒXƒ^ƒ“ƒX‚ð•ÛŽ‚·‚é”z—ñ
+     * ŠeŽíƒIƒuƒWƒFƒNƒg‚ð•ÛŽ‚·‚é”z—ñŒQ
      *
      * @var array
      */
-    static private $_objects = array();
+    static private $_pdoCache   = array();
+    static private $_stmtCache  = array();
+    static private $_kvsCache   = array();
+    static private $_codecCache = array();
 
     // }}}
     // {{{ private properties
@@ -61,19 +66,33 @@
     private $_pdo;
 
     /**
-     * SQLite3ƒf[ƒ^ƒx[ƒX‚̃pƒX
+     * PDO‚̃Cƒ“ƒXƒ^ƒ“ƒX‚ɑΉž‚·‚éˆêˆÓ‚È’l
      *
      * @var string
      */
-    private $_path;
+    private $_pdoId;
 
     /**
+     * Codec‚̃Cƒ“ƒXƒ^ƒ“ƒX
+     *
+     * @var P2KeyValueStore_Codec_Interface
+     */
+    private $_codec;
+
+    /**
      * Ž¯•ÊŽq‚Æ‚µ‚ăNƒH[ƒgÏ‚݂̃e[ƒuƒ‹–¼
      *
      * @var string
      */
     private $_quotedTableName;
 
+    /**
+     * Žg‚¢‰ñ‚µ—p‚ÌŒ‹‰ÊƒZƒbƒgƒIƒuƒWƒFƒNƒg
+     *
+     * @var P2KeyValueStore_Result
+     */
+    private $_sharedResult;
+
     // }}}
     // {{{ getStore()
 
@@ -81,96 +100,54 @@
      * ƒVƒ“ƒOƒ‹ƒgƒ“ƒƒ\ƒbƒh
      *
      * @param string $fileName
-     * @param string $type
-     * @param string &$openedPath
+     * @param string $codec
      * @return P2KeyValueStore
-     * @throws InvalidArgumentException, UnexpectedValueException, RuntimeException, PDOException
+     * @throws PDOException
      */
-    static public function getStore($fileName, $type = self::KVS_DEFAULT, &$openedPath = null)
+    static public function getStore($fileName, $codec = self::CODEC_DEFAULT)
     {
-        // ˆø”‚ÌŒ^‚ðƒ`ƒFƒbƒN
-        if (!is_string($fileName)) {
-            throw new InvalidArgumentException('Parameter #1 \'$fileName\' should be a string value');
+        // ƒIƒuƒWƒFƒNƒgID‚ƃe[ƒuƒ‹–¼‚ðŒˆ’è
+        if (is_object($codec)) {
+            $className = get_class($codec);
+        } else {
+            $className = $codec;
         }
-        if (!is_string($type)) {
-            throw new InvalidArgumentException('Parameter #2 \'$className\' should be a string value');
+        $lcName = strtolower($className);
+        if (strpos($lcName, 'p2keyvaluestore_codec_') === 0) {
+            $codecId = substr($lcName, 22);
+        } else {
+            $codecId = 'user_' . $lcName;
         }
+        $kvsId = $lcName . ':' . $fileName;
+        $tableName = 'kvs_' . $codecId;
 
-        // ƒNƒ‰ƒX–¼‚ðƒ`ƒFƒbƒN
-        if ($type == self::KVS_DEFAULT) {
-            $className = 'P2KeyValueStore';
-        } else {
-            $className = 'P2KeyValueStore_' . $type;
+        // P2KeyValueStore‚̃LƒƒƒbƒVƒ…‚ðŠm”F
+        if (array_key_exists($kvsId, self::$_kvsCache)) {
+            return self::$_kvsCache[$kvsId];
         }
-        if (strcasecmp($className, 'P2KeyValueStore') != 0) {
-            if (!class_exists($className, false)) {
-                include dirname(__FILE__) . '/P2KeyValueStore/' . $type . '.php';
-                if (!class_exists($className, false)) {
-                    throw new UnexpectedValueException("Class '{$className}' is not declared");
-                }
-            }
-            if (!is_subclass_of($className, 'P2KeyValueStore')) {
-                throw new UnexpectedValueException("Class '{$className}' is not a subclass of P2KeyValueStore");
-            }
-        }
 
-        // ƒf[ƒ^ƒx[ƒXƒtƒ@ƒCƒ‹‚ðƒ`ƒFƒbƒN
-        if ($fileName == ':memory:') {
-            $path = $fileName;
-            $createTable = true;
-        } elseif (file_exists($fileName)) {
-            if (!is_file($fileName)) {
-                throw new RuntimeException("'{$fileName}' is not a standard file");
-            }
-            if (!is_writable($fileName)) {
-                throw new RuntimeException("File '{$fileName}' is not writable");
-            }
-            $path = realpath($fileName);
-            $createTable = false;
+        // PDO‚̃LƒƒƒbƒVƒ…‚ðŠm”F
+        if (array_key_exists($fileName, self::$_pdoCache)) {
+            $pdo = self::$_pdoCache[$fileName];
         } else {
-            if (strpos($fileName, '/') !== false ||
-                (strncasecmp(PHP_OS, 'WIN', 3) == 0 && strpos($fileName, '\\') !== false))
-            {
-                $dirName = dirname($fileName);
-                $baseName = basename($fileName);
-            } else {
-                $dirName = getcwd();
-                $baseName = $fileName;
-            }
-            if (!is_string($dirName) || !is_dir($dirName)) {
-                throw new RuntimeException("No directory for '{$fileName}'");
-            }
-            if (!is_writable($dirName)) {
-                throw new RuntimeException("Directory '{$dirName}' is not writable");
-            }
-            $path = realpath($dirName) . DIRECTORY_SEPARATOR . $baseName;
-            $createTable = true;
+            $pdo = new PDO('sqlite:' . $fileName);
+            self::$_pdoCache[$fileName] = $pdo;
         }
 
-        $lcname = strtolower($className);
-        $tableName = 'kvs_' . $lcname;
-        $openedPath = $path;
-
-        // ƒCƒ“ƒXƒ^ƒ“ƒX‚ðì¬‚µAÃ“I•Ï”‚É•ÛŽ
-        if (array_key_exists($path, self::$_objects)) {
-            if (array_key_exists($lcname, self::$_objects[$path]['persisters'])) {
-                $kvs = self::$_objects[$path]['persisters'][$lcname];
+        // Codec‚̃LƒƒƒbƒVƒ…‚ðŠm”F
+        if (!is_object($codec)) {
+            if (array_key_exists($codecId, self::$_codecCache)) {
+                $codec = self::$_codecCache[$codecId];
             } else {
-                $pdo = self::$_objects[$path]['connection'];
-                $kvs = new $className($pdo, $path, $tableName);
-                self::$_objects[$path]['persisters'][$lcname] = $kvs;
+                $codec = new $className;
+                self::$_codecCache[$codecId] = $codec;
             }
-        } else {
-            $pdo = new PDO('sqlite:' . $path);
-            $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-            $kvs = new $className($pdo, $path, $tableName);
-            self::$_objects[$path] = array(
-                'connection' => $pdo,
-                'statements' => array(),
-                'persisters' => array($lcname => $kvs),
-            );
         }
 
+        // P2KeyValueStore‚̃Cƒ“ƒXƒ^ƒ“ƒX‚ðì¬
+        $kvs = new P2KeyValueStore($pdo, $codec, $tableName);
+        self::$_kvsCache[$kvsId] = $kvs;
+
         return $kvs;
     }
 
@@ -182,19 +159,27 @@
      * getStore()‚©‚çŒÄ‚яo‚³‚ê‚é
      *
      * @param PDO $pdo
-     * @param string $path
+     * @param P2KeyValueStore_Codec_Interface $codec
      * @param string $tableName
      * @throws PDOException
      */
-    private function __construct(PDO $pdo, $path, $tableName)
+    public function __construct(PDO $pdo,
+                                P2KeyValueStore_Codec_Interface $codec,
+                                $tableName)
     {
         $this->_pdo = $pdo;
-        $this->_path = $path;
+        $this->_pdoId = spl_object_hash($pdo);
+        $this->_codec = $codec;
         $this->_quotedTableName = '"' . str_replace('"', '""', $tableName) . '"';
+        $this->_sharedResult = new P2KeyValueStore_Result;
 
+        if (!array_key_exists($this->_pdoId, self::$_stmtCache)) {
+            self::$_stmtCache[$this->_pdoId] = array();
+        }
+
         // ƒe[ƒuƒ‹‚ª‘¶Ý‚·‚é‚©‚𒲂×
         $stmt = $pdo->prepare(self::Q_TABLEEXISTS);
-        $stmt->bindValue(':table', $tableName, PDO::PARAM_STR);
+        $stmt->bindValue(':table', $tableName);
         $stmt->execute();
         $exists = $stmt->fetchColumn();
         $stmt->closeCursor();
@@ -207,30 +192,31 @@
     }
 
     // }}}
-    // {{{ prepare()
+    // {{{ _prepare()
 
     /**
-     * ƒvƒŠƒyƒA[ƒhƒXƒe[ƒgƒƒ“ƒg‚ðì¬‚·‚é
+     * ƒvƒŠƒyƒA[ƒhƒXƒe[ƒgƒƒ“ƒg‚ðì¬‚·‚é (“à•”—p)
      *
      * @param string $query
      * @param bool $isTemporary
+     * @param bool $forwardOnly
      * @return PDOStatement
      * @throws PDOException
      */
-    public function prepare($query, $isTemporary = false)
+    protected function _prepare($query, $isTemporary = false, $forwardOnly = true)
     {
         $query = str_replace('$__table', $this->_quotedTableName, $query);
 
-        if (!$isTemporary && array_key_exists($query, self::$_objects[$this->_path]['statements'])) {
-            $stmt = self::$_objects[$this->_path]['statements'][$query];
+        if (!$isTemporary && array_key_exists($query, self::$_stmtCache[$this->_pdoId])) {
+            $stmt = self::$_stmtCache[$this->_pdoId][$query];
         } else {
-            if (strncmp($query, 'SELECT ', 7) == 0) {
+            if ($forwardOnly && strncmp($query, 'SELECT ', 7) == 0) {
                 $stmt = $this->_pdo->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
             } else {
                 $stmt = $this->_pdo->prepare($query);
             }
             if (!$isTemporary) {
-                self::$_objects[$this->_path]['statements'][$query] = $stmt;
+                self::$_stmtCache[$this->_pdoId][$query] = $stmt;
             }
         }
 
@@ -238,6 +224,27 @@
     }
 
     // }}}
+    // {{{ prepare()
+
+    /**
+     * ƒvƒŠƒyƒA[ƒhƒXƒe[ƒgƒƒ“ƒg‚ðì¬‚·‚é
+     *
+     * @param string $query
+     * @param bool $forwardOnly
+     * @return PDOStatement
+     * @throws PDOException
+     * @see P2KeyValueStore::_prepare()
+     */
+    public function prepare($query, $forwardOnly = true)
+    {
+        return $this->_prepare(str_replace(array('$__key', '$__value'),
+                                           array( 'arkey',    'value'),
+                                           $query),
+                               true,
+                               $forwardOnly);
+    }
+
+    // }}}
     // {{{ buildOrderBy()
 
     /**
@@ -253,25 +260,31 @@
         }
 
         $terms = array();
-        foreach ($orderBy as $column => $ascending) {
-            $direction = $ascending ? 'ASC' : 'DESC';
-            switch ($column) {
-                case 'id':
-                    $terms[] = 'id ' . $direction;
-                    break;
-                case 'key':
-                    $terms[] = 'arkey ' . $direction;
-                    break;
-                case 'value':
-                    $terms[] = 'value ' . $direction;
-                    break;
-                case 'mtime':
-                    $terms[] = 'mtime ' . $direction;
-                    break;
-                case 'order':
-                    $terms[] = 'sort_order ' . $direction;
-                    break;
+        $mapping = array(
+            'id' => 'id',
+            'key' => 'arkey',
+            'arkey' => 'arkey',
+            'value' => 'value',
+            'mtime' => 'mtime',
+            'order' => 'sort_order',
+            'sort_order' => 'sort_order',
+        );
+
+        foreach ($orderBy as $column => $direction) {
+            $column = strtolower($column);
+            if (array_key_exists($column, $mapping)) {
+                $condition = $mapping[$column] . ' ';
+                if (strcasecmp($direction, 'ASC') == 0) {
+                    $condition .= 'ASC';
+                } elseif (strcasecmp($direction, 'DESC') == 0) {
+                    $condition .= 'DESC';
+                } elseif (0 < (int)$direction) {
+                    $condition .= 'ASC';
+                } else {
+                    $condition .= 'DESC';
+                }
             }
+            $terms[] = $condition;
         }
 
         if (count($terms)) {
@@ -303,62 +316,6 @@
     }
 
     // }}}
-    // {{{ encodeKey()
-
-    /**
-     * ƒL[‚ðUTF-8 or US-ASCII•¶Žš—ñ‚ɃGƒ“ƒR[ƒh‚·‚é
-     *
-     * @param string $key
-     * @return string
-     */
-    public function encodeKey($key)
-    {
-        return (string)$key;
-    }
-
-    // }}}
-    // {{{ decodeKey()
-
-    /**
-     * ƒL[‚ðƒfƒR[ƒh‚·‚é
-     *
-     * @param string $key
-     * @return string
-     */
-    public function decodeKey($key)
-    {
-        return $key;
-    }
-
-    // }}}
-    // {{{ encodeValue()
-
-    /**
-     * ’l‚ðUTF-8 or US-ASCII•¶Žš—ñ‚ɃGƒ“ƒR[ƒh‚·‚é
-     *
-     * @param string $value
-     * @return string
-     */
-    public function encodeValue($value)
-    {
-        return (string)$value;
-    }
-
-    // }}}
-    // {{{ decodeValue()
-
-    /**
-     * ’l‚ðƒfƒR[ƒh‚·‚é
-     *
-     * @param string $value
-     * @return string
-     */
-    public function decodeValue($value)
-    {
-        return $value;
-    }
-
-    // }}}
     // {{{ exists()
 
     /**
@@ -368,18 +325,19 @@
      * @param int $lifeTime
      * @return bool
      */
-    public function exists($key, $lifeTime = null)
+    public function exists($key, $lifeTime = -1)
     {
-        $stmt = $this->prepare(self::Q_EXSITS);
-        $stmt->setFetchMode(PDO::FETCH_ASSOC);
-        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
+        $stmt = $this->_prepare(self::Q_EXSITS);
+        $stmt->setFetchMode(PDO::FETCH_INTO, $this->_sharedResult);
+        $stmt->bindValue(':key', $this->_codec->encodeKey($key));
         $stmt->execute();
         $row = $stmt->fetch();
         $stmt->closeCursor();
+
         if ($row === false) {
             return false;
-        } elseif ($lifeTime !== null && $row['mtime'] < time() - $lifeTime) {
-            $this->deleteById($row['id']);
+        } elseif ($row->isExpired()) {
+            $this->deleteById($row->id);
             return false;
         } else {
             return true;
@@ -397,23 +355,24 @@
      * @param int $lifeTime
      * @return array
      */
-    public function findById($id, $lifeTime = null)
+    public function findById($id, $lifeTime = -1)
     {
-        $stmt = $this->prepare(self::Q_FINDBYID);
-        $stmt->setFetchMode(PDO::FETCH_ASSOC);
-        $stmt->bindValue(':id', (int)$id, PDO::PARAM_INT);
+        $stmt = $this->_prepare(self::Q_FINDBYID);
+        $stmt->setFetchMode(PDO::FETCH_INTO, $this->_sharedResult);
+        $stmt->bindValue(':id', $id, PDO::PARAM_INT);
         $stmt->execute();
         $row = $stmt->fetch();
         $stmt->closeCursor();
+
         if ($row === false) {
             return null;
-        } elseif ($lifeTime !== null && $row['mtime'] < time() - $lifeTime) {
+        } elseif ($row->isExpired()) {
             $this->deleteById($id);
             return null;
         } else {
             return array(
-                'key' => $this->decodeKey($row['arkey']),
-                'value' => $this->decodeValue($row['value']),
+                'key' => $this->_codec->decodeKey($row->key),
+                'value' => $this->_codec->decodeValue($row->value),
             );
         }
     }
@@ -428,55 +387,47 @@
      * @param int $lifeTime
      * @return string
      */
-    public function get($key, $lifeTime = null)
+    public function get($key, $lifeTime = -1)
     {
-        $stmt = $this->prepare(self::Q_GET);
-        $stmt->setFetchMode(PDO::FETCH_ASSOC);
-        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
+        $stmt = $this->_prepare(self::Q_GET);
+        $stmt->setFetchMode(PDO::FETCH_INTO, $this->_sharedResult);
+        $stmt->bindValue(':key', $this->_codec->encodeKey($key));
         $stmt->execute();
         $row = $stmt->fetch();
         $stmt->closeCursor();
+
         if ($row === false) {
             return null;
-        } elseif ($lifeTime !== null && $row['mtime'] < time() - $lifeTime) {
-            $this->deleteById($row['id']);
+        } elseif ($row->isExpired()) {
+            $this->deleteById($row->id);
             return null;
         } else {
-            return $this->decodeValue($row['value']);
+            return $this->_codec->decodeValue($row->value);
         }
     }
 
     // }}}
-    // {{{ getDetail()
+    // {{{ getRaw()
 
     /**
-     * ƒL[‚ɑΉž‚·‚郌ƒR[ƒh‚ðŽæ“¾‚·‚é
+     * ƒL[‚ɑΉž‚·‚錋‰ÊƒZƒbƒgƒIƒuƒWƒFƒNƒg‚ðŽæ“¾‚·‚é
      *
      * @param string $key
-     * @param int $lifeTime
-     * @return array
+     * @return P2KeyValueStore_Result
      */
-    public function getDetail($key, $lifeTime = null)
+    public function getRaw($key)
     {
-        $stmt = $this->prepare(self::Q_GET);
-        $stmt->setFetchMode(PDO::FETCH_ASSOC);
-        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
+        $stmt = $this->_prepare(self::Q_GET);
+        $stmt->setFetchMode(PDO::FETCH_CLASS, 'P2KeyValueStore_Result');
+        $stmt->bindValue(':key', $this->_codec->encodeKey($key));
         $stmt->execute();
         $row = $stmt->fetch();
         $stmt->closeCursor();
+
         if ($row === false) {
             return null;
-        } elseif ($lifeTime !== null && $row['mtime'] < time() - $lifeTime) {
-            $this->deleteById($row['id']);
-            return null;
         } else {
-            return array(
-                'id' => (int)$row['id'],
-                'key' => $this->decodeKey($row['arkey']),
-                'value' => $this->decodeValue($row['value']),
-                'mtime' => (int)$row['mtime'],
-                'order' => (int)$row['sort_order'],
-            );
+            return $row;
         }
     }
 
@@ -490,35 +441,33 @@
      * @param array $orderBy
      * @param int $limit
      * @param int $offset
-     * @param bool $getDetails
+     * @param bool $getRaw
      * @return array
      */
-    public function getAll(array $orderBy = null, $limit = null, $offset = null, $getDetails = false)
+    public function getAll(array $orderBy = null,
+                           $limit = null, $offset = null,
+                           $getRaw = false)
     {
         $query = self::Q_GETALL
                . $this->buildOrderBy($orderBy)
                . $this->buildLimit($limit, $offset);
-        $stmt = $this->prepare($query, true);
-        $stmt->setFetchMode(PDO::FETCH_ASSOC);
+        $stmt = $this->_prepare($query, true);
         $stmt->execute();
+
         $values = array();
-        if ($getDetails) {
+        if ($getRaw) {
+            $stmt->setFetchMode(PDO::FETCH_CLASS, 'P2KeyValueStore_Result');
             while ($row = $stmt->fetch()) {
-                $key = $this->decodeKey($row['arkey']);
-                $values[$key] = array(
-                    'id' => (int)$row['id'],
-                    'key' => $key,
-                    'value' => $this->decodeValue($row['value']),
-                    'mtime' => (int)$row['mtime'],
-                    'order' => (int)$row['sort_order'],
-                );
+                $values[$this->_codec->decodeKey($row->key)] = $row;
             }
         } else {
+            $stmt->setFetchMode(PDO::FETCH_INTO, $this->_sharedResult);
             while ($row = $stmt->fetch()) {
-                $values[$this->decodeKey($row['arkey'])] = $this->decodeValue($row['value']);
+                $value = $this->_codec->decodeValue($row->value);
+                $values[$this->_codec->decodeKey($row->key)] = $value;
             }
         }
-        $stmt->closeCursor();
+
         return $values;
     }
 
@@ -540,15 +489,10 @@
         $query = self::Q_GETIDS
                . $this->buildOrderBy($orderBy)
                . $this->buildLimit($limit, $offset);
-        $stmt = $this->prepare($query, true);
-        $stmt->setFetchMode(PDO::FETCH_COLUMN, 0);
+        $stmt = $this->_prepare($query, true);
         $stmt->execute();
-        $ids = array();
-        while (($id = $stmt->fetch()) !== false) {
-            $ids[] = (int)$id;
-        }
-        $stmt->closeCursor();
-        return $ids;
+
+        return $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
     }
 
     // }}}
@@ -568,14 +512,15 @@
         $query = self::Q_GETKEYS
                . $this->buildOrderBy($orderBy)
                . $this->buildLimit($limit, $offset);
-        $stmt = $this->prepare($query, true);
+        $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->_codec->decodeKey($key);
         }
-        $stmt->closeCursor();
+
         return $keys;
     }
 
@@ -592,10 +537,10 @@
      */
     public function set($key, $value, $order = 0)
     {
-        $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);
+        $stmt = $this->_prepare(self::Q_SET);
+        $stmt->bindValue(':key', $this->_codec->encodeKey($key));
+        $stmt->bindValue(':value', $this->_codec->encodeValue($value));
+        $stmt->bindValue(':order', $order, PDO::PARAM_INT);
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
         } else {
@@ -616,10 +561,10 @@
      */
     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->bindValue(':order', (int)$order, PDO::PARAM_INT);
+        $stmt = $this->_prepare(self::Q_UPDATE);
+        $stmt->bindValue(':key', $this->_codec->encodeKey($key));
+        $stmt->bindValue(':value', $this->_codec->encodeValue($value));
+        $stmt->bindValue(':order', $order, PDO::PARAM_INT);
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
         } else {
@@ -639,12 +584,12 @@
      */
     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->_codec->encodeKey($key));
         if ($time === null) {
             $stmt->bindValue(':mtime', null, PDO::PARAM_NULL);
         } else {
-            $stmt->bindValue(':mtime', (int)$time, PDO::PARAM_INT);
+            $stmt->bindValue(':mtime', $time, PDO::PARAM_INT);
         }
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
@@ -665,9 +610,9 @@
      */
     public function setOrder($key, $order)
     {
-        $stmt = $this->prepare(self::Q_SETORDER);
-        $stmt->bindValue(':key', $this->encodeKey($key), PDO::PARAM_STR);
-        $stmt->bindValue(':order', (int)$order, PDO::PARAM_INT);
+        $stmt = $this->_prepare(self::Q_SETORDER);
+        $stmt->bindValue(':key', $this->_codec->encodeKey($key));
+        $stmt->bindValue(':order', $order, PDO::PARAM_INT);
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
         } else {
@@ -686,8 +631,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->_codec->encodeKey($key));
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
         } else {
@@ -706,8 +651,8 @@
      */
     public function deleteById($id)
     {
-        $stmt = $this->prepare(self::Q_DELETEBYID);
-        $stmt->bindValue(':id', (int)$id, PDO::PARAM_INT);
+        $stmt = $this->_prepare(self::Q_DELETEBYID);
+        $stmt->bindValue(':id', $id, PDO::PARAM_INT);
         if ($stmt->execute()) {
             return $stmt->rowCount() == 1;
         } else {
@@ -726,7 +671,7 @@
      */
     public function clear()
     {
-        $stmt = $this->prepare(self::Q_CLEAR, true);
+        $stmt = $this->_prepare(self::Q_CLEAR, true);
         if ($stmt->execute()) {
             return $stmt->rowCount();
         } else {
@@ -745,7 +690,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();
@@ -766,7 +711,7 @@
      */
     public function vacuum()
     {
-        self::$_objects[$this->_path]['statements'] = array();
+        self::$_stmtCache[$this->_pdoId] = array();
         $this->_pdo->exec('VACUUM');
     }
 
@@ -783,10 +728,11 @@
      */
     public function count()
     {
-        $stmt = $this->prepare(self::Q_COUNT);
+        $stmt = $this->_prepare(self::Q_COUNT);
         $stmt->execute();
         $ret = (int)$stmt->fetchColumn();
         $stmt->closeCursor();
+
         return $ret;
     }
 
@@ -870,20 +816,65 @@
     /**
      * Žg—p‚µ‚Ä‚¢‚éPDOƒIƒuƒWƒFƒNƒg‚ð•Ô‚·
      *
-     * @param &$quotedTableName
+     * @param void
      * @return PDO
      */
-    public function getPDO(&$quotedTableName = null)
+    public function getPDO()
     {
-        $quotedTableName = $this->_quotedTableName;
         return $this->_pdo;
     }
 
     // }}}
+    // {{{ getCodec()
+
+    /**
+     * Žg—p‚µ‚Ä‚¢‚éCodecƒIƒuƒWƒFƒNƒg‚ð•Ô‚·
+     *
+     * @param void
+     * @return P2KeyValueStore_Codec_Interface
+     */
+    public function getCodec()
+    {
+        return $this->_codec;
+    }
+
+    // }}}
+    // {{{ getTableName()
+
+    /**
+     * ƒNƒH[ƒgÏ‚݂̃e[ƒuƒ‹–¼‚ð•Ô‚·
+     *
+     * @param void
+     * @return string
+     */
+    public function getTableName()
+    {
+        return $this->_quotedTableName;
+    }
+
+    // }}}
+    // {{{ loadClass()
+
+    /**
+     * ƒNƒ‰ƒXƒ[ƒ_[
+     *
+     * @string $name
+     * @return void
+     */
+    static public function loadClass($name)
+    {
+        if (strncmp($name, 'P2KeyValueStore_', 16) === 0) {
+            include dirname(__FILE__) . '/' . str_replace('_', '/', $name) . '.php';
+        }
+    }
+
+    // }}}
 }
 
 // }}}
 
+spl_autoload_register('P2KeyValueStore::loadClass');
+
 /*
  * Local Variables:
  * mode: php

Modified: p2ex/trunk/lib/P2Util.php
===================================================================
--- p2ex/trunk/lib/P2Util.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/P2Util.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1029,6 +1029,18 @@
     }
 
     // }}}
+    // }}}
+    // {{{ isBrowserAndroid()
+
+    /**
+     * ƒuƒ‰ƒEƒU‚ªAndroidh‚È‚çtrue‚ð•Ô‚·
+     */
+    static public function isBrowserAndroid()
+    {
+        return (strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false);
+    }
+
+    // }}}
     // {{{ isUrlWikipediaJa()
 
     /**
@@ -1817,13 +1829,13 @@
             require P2_LIB_DIR . '/P2Client.php';
         }
 
-        if (!is_dir($_conf['cookie_dir'])) {
-            FileCtl::mkdir_r($_conf['cookie_dir']);
+        if (!is_dir($_conf['db_dir'])) {
+            FileCtl::mkdir_r($_conf['db_dir']);
         }
 
         try {
             return new P2Client($_conf['p2_2ch_mail'], $_conf['p2_2ch_pass'],
-                                $_conf['cookie_dir'], (bool)$_conf['p2_2ch_ignore_cip']);
+                                $_conf['db_dir'], (bool)$_conf['p2_2ch_ignore_cip']);
         } catch (P2Exception $e) {
             p2die($e->getMessage());
         }

Modified: p2ex/trunk/lib/ResHist.php
===================================================================
--- p2ex/trunk/lib/ResHist.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/ResHist.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -116,8 +116,6 @@
     {
         global $_conf, $STYLE;
 
-        $sid_q = (defined('SID')) ? '&amp;' . strip_tags(SID) : '';
-
         // Pager €”õ
         $perPage = 100;
         $params = array(
@@ -160,10 +158,10 @@
                     $footer_q = "#r{$lf}";
                 }
                 $time = time();
-                $href_ht = $_conf['read_php'] . "?host=" . $a_res->host . "&amp;bbs=" . $a_res->bbs . "&amp;key=" . $a_res->key . $ls_q . "{$_conf['k_at_a']}&amp;nt={$time}{$footer_q}";
+                $href_ht = "{$_conf['read_php']}?host={$a_res->host}&amp;bbs={$a_res->bbs}&amp;key={$a_res->key}{$ls_q}{$_conf['k_at_a']}&amp;nt={$time}{$footer_q}";
             }
             $info_view_ht = <<<EOP
-        <a href="info.php?host={$a_res->host}&amp;bbs={$a_res->bbs}&amp;key={$a_res->key}{$_conf['k_at_a']}" target="_self" onclick="return OpenSubWin('info.php?host={$a_res->host}&amp;bbs={$a_res->bbs}&amp;key={$a_res->key}&amp;popup=1{$sid_q}',{$STYLE['info_pop_size']},0,0)">î•ñ</a>
+        <a href="info.php?host={$a_res->host}&amp;bbs={$a_res->bbs}&amp;key={$a_res->key}{$_conf['k_at_a']}" target="_self" onclick="return OpenSubWin('info.php?host={$a_res->host}&amp;bbs={$a_res->bbs}&amp;key={$a_res->key}&amp;popup=1',{$STYLE['info_pop_size']},0,0)">î•ñ</a>
 EOP;
 
             $res_ht = "<div class=\"res\">\n";

Modified: p2ex/trunk/lib/Session.php
===================================================================
--- p2ex/trunk/lib/Session.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/Session.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -78,7 +78,6 @@
             $snm = session_name();
             $sid = session_id();
             output_add_rewrite_var($snm, $sid);
-            $GLOBALS['_conf']['sid_at_a'] = '&amp;' . rawurlencode($snm) . '=' . rawurlencode($sid);
         }
 
         /*

Modified: p2ex/trunk/lib/ShowThreadK.php
===================================================================
--- p2ex/trunk/lib/ShowThreadK.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/ShowThreadK.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -288,7 +288,7 @@
             if (($ng_type & self::NG_AA) && P2_AAS_AVAILABLE) {
                 $aas_url = "aas.php?host={$this->thread->host}&amp;bbs={$this->thread->bbs}&amp;key={$this->thread->key}&amp;resnum={$i}";
                 if (P2_AAS_AVAILABLE == 2) {
-                    $aas_txt = "<img src=\"{$aas_url}{$_conf['k_at_a']}&amp;inline=1{$_conf['sid_at_a']}\">";
+                    $aas_txt = "<img src=\"{$aas_url}{$_conf['k_at_a']}&amp;inline=1\">";
                 } else {
                     $aas_txt = "AAS";
                 }
@@ -1005,7 +1005,7 @@
                             } else {
                                 $prv_url = "ic2.php?r={$r_type}&amp;t=1&amp;uri={$url_en}";
                             }
-                            $img_str = "<img src=\"{$prv_url}{$_conf['sid_at_a']}\">";
+                            $img_str = "<img src=\"{$prv_url}\">";
                         }
                         $inline_preview_done = true;
                     } else {
@@ -1035,7 +1035,7 @@
 
                 // ƒCƒ“ƒ‰ƒCƒ“ƒvƒŒƒrƒ…[‚ª—LŒø‚ŁAƒTƒ€ƒlƒCƒ‹•\Ž¦§ŒÀ”ˆÈ“à‚È‚ç
                 if ($this->thumbnailer->ini['General']['inline'] == 1 && $inline_preview_flag) {
-                    $img_str = "<img src=\"ic2.php?r=2&amp;t=1&amp;uri={$url_en}{$this->img_memo_query}{$_conf['sid_at_a']}\">";
+                    $img_str = "<img src=\"ic2.php?r=2&amp;t=1&amp;uri={$url_en}{$this->img_memo_query}\">";
                     $inline_preview_done = true;
                 } else {
                     $img_url .= $this->img_memo_query;

Modified: p2ex/trunk/lib/Thumbnailer/Common.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/Thumbnailer/Common.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/Thumbnailer/Common.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -6,22 +6,6 @@
 
 require_once 'PEAR.php';
 
-// {{{ _thumbnailer_common_unlink_tempfile()
-
-/**
- * Remove the temporary file.
- *
- * @param string $file
- * @return void
- */
-function _thumbnailer_common_unlink_tempfile($file)
-{
-    if (file_exists($file)) {
-        @unlink($file);
-    }
-}
-
-// }}}
 // {{{ Thumbnailer_Common
 
 /**
@@ -319,7 +303,7 @@
     protected function _tempnam()
     {
         $tmp = tempnam($this->_tempDir, 'thumb_temp_');
-        register_shutdown_function('_thumbnailer_common_unlink_tempfile', $tmp);
+        register_shutdown_function('Thumbnailer_Common::removeTemporaryFile', $tmp);
         return $tmp;
     }
 
@@ -352,6 +336,22 @@
     }
 
     // }}}
+    // {{{ removeTemporaryFile()
+
+    /**
+     * Removes the temporary file.
+     *
+     * @param string $filename
+     * @return void
+     */
+    static public function removeTemporaryFile($filename)
+    {
+        if (file_exists($filename)) {
+            @unlink($filename);
+        }
+    }
+
+    // }}
 }
 
 // }}}

Modified: p2ex/trunk/lib/Thumbnailer/Gd.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/Thumbnailer/Gd.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/Thumbnailer/Gd.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -4,8 +4,6 @@
  * PHP Version 5
  */
 
-require_once dirname(__FILE__) . '/Common.php';
-
 // {{{ Thumbnailer_Gd
 
 /**

Modified: p2ex/trunk/lib/Thumbnailer/Imagemagick.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/Thumbnailer/Imagemagick.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/Thumbnailer/Imagemagick.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -4,8 +4,6 @@
  * PHP Version 5
  */
 
-require_once dirname(__FILE__) . '/Common.php';
-
 // {{{ Thumbnailer_Imagemagick
 
 /**
@@ -15,11 +13,31 @@
 {
     // {{{ properties
 
-    protected $_imagemagick_convert = 'convert';
-    protected $_imagemagick_version_gte6 = true;
-    protected $_imagemagick_have_flatten = true;
+    protected $_imageMagickConvert = 'convert';
+    protected $_imageMagickVersion6 = true;
+    protected $_imageMagickSupportsFlatten = true;
+    protected $_imageMagickSupportsAdjoin = true;
 
     // }}}
+    // {{{ __construct
+
+    /**
+     * Constructor
+     *
+     * @param string $path
+     */
+    public function __construct($path = null)
+    {
+        if ($path !== null) {
+            $this->setImageMagickConvertPath($path);
+        }
+
+        if (strncasecmp(PHP_OS, 'win', 3) == 0) {
+            $this->_imageMagickSupportsAdjoin = false;
+        }
+    }
+
+    // }}}
     // {{{ setImageMagickConvertPath()
 
     /**
@@ -32,16 +50,16 @@
     {
         if (is_file($path) && is_executable($path)) {
             $convert = escapeshellarg($path);
-            $this->_imagemagick_convert = $convert;
+            $this->_imageMagickConvert = $convert;
 
             $output = null;
             @exec("$convert --version 2>&1", $output);
             if ($output && preg_match('/Version: ImageMagick (([0-9.]+)-[0-9]+)/', $output[0], $v)) {
-                $this->_imagemagick_version_gte6 = version_compare($v[2], '6.0.0',   'ge');
-                $this->_imagemagick_have_flatten = version_compare($v[1], '6.3.6-2', 'ge');
+                $this->_imageMagickVersion6 = version_compare($v[2], '6.0.0',   'ge');
+                $this->_imageMagickSupportsFlatten = version_compare($v[1], '6.3.6-2', 'ge');
             } else {
-                $this->_imagemagick_version_gte6 = false;
-                $this->_imagemagick_have_flatten = false;
+                $this->_imageMagickVersion6 = false;
+                $this->_imageMagickSupportsFlatten = false;
             }
         }
     }
@@ -136,29 +154,37 @@
      */
     protected function _convert($source, $size)
     {
-        $source = (!$source || $source == '-') ? '-' : escapeshellarg($source);
+        if ($source === '' || $source === null) {
+            $source = '-';
+        }
         extract($size);
 
-        $command = $this->_imagemagick_convert;
+        $command = $this->_imageMagickConvert;
 
         // Œ³‚̃TƒCƒY‚ðŽw’è
-        $command .= sprintf(' -size %dx%d', $w, $h);
+        $command .= sprintf(' -size "%dx%d"', $w, $h);
 
         // •¡”ƒtƒŒ[ƒ€‚©‚ç‚È‚é‰æ‘œ‚©‚à‚µ‚ê‚È‚¢‚Æ‚«
-        if ($this->_imagemagick_have_flatten) {
-            $command .= ' -flatten';
+        if (preg_match('/\\.gif$/i', $source)) {
+            if ($this->_imageMagickSupportsFlatten && !$this->doesTrimming()) {
+                $command .= ' -flatten';
+            }
+            if ($this->_imageMagickSupportsAdjoin) {
+                $source .= '[0]';
+            }
         }
-        if (!$this->windows && preg_match('/\\.gif$/', $source)) {
-            $command .= ' +adjoin';
-            $source .= '[0]';
+
+        // ƒGƒXƒP[ƒv
+        if ($source != '-') {
+            $source =  escapeshellarg($source);
         }
 
         // ƒNƒƒbƒv‚µ‚ăpƒCƒv
         if ($this->doesTrimming()) {
-            $command .= sprintf(' -format PNG -crop %dx%d+%d+%d %s - | %s -size %dx%d',
+            $command .= sprintf(' -format PNG -crop "%dx%d+%d+%d" %s - | %s -size "%dx%d"',
                                 $sw, $sh, $sx, $sy,
                                 $source,
-                                $this->_imagemagick_convert,
+                                $this->_imageMagickConvert,
                                 $sw, $sh);
             $source = '-';
         }
@@ -168,7 +194,8 @@
         if ($degrees = $this->getRotation()) {
             $bgcolor = $this->getBgColor();
             $command .= sprintf(' -rotate %d', $degrees);
-            $command .= sprintf(' -background rgb(%d,%d,%d)', $bgcolor[0], $bgcolor[1], $bgcolor[2]);
+            $command .= sprintf(' -background "rgb(%d,%d,%d)"',
+                                $bgcolor[0], $bgcolor[1], $bgcolor[2]);
             if ($degrees % 180 == 90) {
                 $_t = $tw;
                 $tw = $th;
@@ -177,17 +204,17 @@
         }
 
         // ƒTƒ€ƒlƒCƒ‹‚̃TƒCƒY‚ðŽw’èEƒƒ^ƒf[ƒ^‚͏œ‹Ž
-        if ($this->_imagemagick_version_gte6) {
+        if ($this->_imageMagickVersion6) {
             if ($this->doesResampling()) {
-                $command .= sprintf(' -thumbnail %dx%d!', $tw, $th);
+                $command .= sprintf(' -thumbnail "%dx%d!"', $tw, $th);
             } else {
                 $command .= ' -strip';
             }
         } else {
             if ($this->doesResampling()) {
-                $command .= sprintf(' -scale %dx%d!', $tw, $th);
+                $command .= sprintf(' -scale "%dx%d!"', $tw, $th);
             }
-            $command .= " +profile '*'";
+            $command .= ' +profile "*"';
         }
 
         // ƒTƒ€ƒlƒCƒ‹‚̉摜Œ`Ž®‚Æ•iŽ¿

Modified: p2ex/trunk/lib/Thumbnailer/Imagick.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/Thumbnailer/Imagick.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/Thumbnailer/Imagick.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -4,8 +4,6 @@
  * PHP Version 5
  */
 
-require_once dirname(__FILE__) . '/Common.php';
-
 // {{{ Thumbnailer_Imagick
 
 /**

Modified: p2ex/trunk/lib/bootstrap.php
===================================================================
--- p2ex/trunk/lib/bootstrap.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/bootstrap.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -5,14 +5,83 @@
  */
 
 require_once 'Net/UserAgent/Mobile.php';
-require_once $P2_LIB_DIR_S . 'Session.php';
-require_once $P2_LIB_DIR_S . 'Login.php';
+require_once P2_LIB_DIR . '/Session.php';
+require_once P2_LIB_DIR . '/Login.php';
 
+// {{{ ƒ†[ƒU[Ý’è “Çž
+
+// ƒ†[ƒU[Ý’èƒtƒ@ƒCƒ‹
+$_conf['conf_user_file'] = $_conf['pref_dir'] . '/conf_user.srd.cgi';
+
+// ƒ†[ƒU[Ý’肪‚ ‚ê‚Γǂݍž‚Þ
+if (file_exists($_conf['conf_user_file'])) {
+    if ($cont = file_get_contents($_conf['conf_user_file'])) {
+        $conf_user = unserialize($cont);
+    } else {
+        $conf_user = null;
+    }
+
+    // ‰½‚ç‚©‚Ì——R‚ц[ƒU[Ý’èƒtƒ@ƒCƒ‹‚ª‰ó‚ê‚Ä‚¢‚½‚ç
+    if (!is_array($conf_user)) {
+        if (unlink($_conf['conf_user_file'])) {
+            $_info_msg_ht .= '<p>ƒ†[ƒU[Ý’èƒtƒ@ƒCƒ‹‚ª‰ó‚ê‚Ä‚¢‚½‚̂ō폜‚µ‚Ü‚µ‚½B</p>';
+            $conf_user = array();
+        } else {
+            $dispname = '$_conf[\'pref_dir\']/' . basename($_conf['conf_user_file']);
+            p2die("‰ó‚ê‚Ä‚¢‚郆[ƒU[Ý’èƒtƒ@ƒCƒ‹ {$dispname} ‚ðíœ‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½B");
+        }
+    }
+
+    // ƒ†[ƒU[Ý’è‚̃o[ƒWƒ‡ƒ“‚ðƒ`ƒFƒbƒN
+    if (array_key_exists('.', $conf_user) &&
+        preg_match('/^\\d{6}\\.\\d{4}$/', $conf_user['.']))
+    {
+        $config_version = $conf_user['.'];
+    } else {
+        $config_version = '000000.0000';
+    }
+
+    if ($config_version !== $_conf['p2expack']) {
+        // Ý’è‚̍XV
+        if ($migrators = p2checkmigration($config_version)) {
+            $conf_user = p2migrate($conf_user, $migrators);
+        }
+
+        // ƒfƒtƒHƒ‹ƒgÝ’è‚ð“ǂݍž‚݁Aƒ†[ƒU[Ý’è‚Æ‚Æ‚à‚Ƀ}[ƒW
+        include P2_CONF_DIR . '/conf_user_def.inc.php';
+        $_conf = array_merge($_conf, $conf_user_def, $conf_user);
+        $creae_config_cache = true;
+    } else {
+        // ƒLƒƒƒbƒVƒ…‚³‚ê‚Ä‚¢‚½ƒ†[ƒU[Ý’è‚ðƒ}[ƒW
+        $_conf = array_merge($_conf, $conf_user);
+        $creae_config_cache = false;
+    }
+} else {
+    // ƒfƒtƒHƒ‹ƒgÝ’è‚ð“ǂݍž‚݁Aƒ}[ƒW
+    include P2_CONF_DIR . '/conf_user_def.inc.php';
+    $_conf = array_merge($_conf, $conf_user_def);
+    $creae_config_cache = true;
+}
+
+// V‚µ‚¢ƒ†[ƒU[Ý’è‚ðƒLƒƒƒbƒVƒ…
+if ($creae_config_cache) {
+    $conf_user = array('.' => $_conf['p2expack']);
+    foreach ($conf_user_def as $k => $v) {
+        $conf_user[$k] = $_conf[$k];
+    }
+    $cont = serialize($conf_user);
+    if (FileCtl::file_write_contents($_conf['conf_user_file'], $cont) === false) {
+        $dispname = '$_conf[\'pref_dir\']/' . basename($_conf['conf_user_file']);
+        p2die("ƒ†[ƒU[Ý’èƒtƒ@ƒCƒ‹ {$dispname} ‚ɏ‘‚«ž‚ß‚Ü‚¹‚ñ‚Å‚µ‚½B");
+    }
+}
+
+// }}}
 // {{{ ƒzƒXƒgƒ`ƒFƒbƒN
 
 if ($_conf['secure']['auth_host'] || $_conf['secure']['auth_bbq']) {
     if (!class_exists('HostCheck', false)) {
-        include $P2_LIB_DIR_S . 'HostCheck.php';
+        include P2_LIB_DIR . '/HostCheck.php';
     }
     if (($_conf['secure']['auth_host'] && HostCheck::getHostAuth() == false) ||
         ($_conf['secure']['auth_bbq'] && HostCheck::getHostBurned() == true)
@@ -22,16 +91,9 @@
 }
 
 // }}}
-// {{{ ƒŠƒNƒGƒXƒg•Ï”‚̏ˆ—
+// {{{ ƒŠƒNƒGƒXƒg•Ï”‚ÌŒŸØ‚Æ•¶ŽšƒR[ƒh•ÏŠ·
 
-// V‹KƒƒOƒCƒ“‚ƃƒ“ƒo[ƒƒOƒCƒ“‚Ì“¯ŽžŽw’è‚Í‚ ‚肦‚È‚¢‚̂ŁAƒGƒ‰[‚ðo‚·
-if (isset($_POST['submit_new']) && isset($_POST['submit_member'])) {
-    p2die('–³Œø‚ÈURL‚Å‚·B');
-}
-
 /**
- * ƒŠƒNƒGƒXƒg•Ï”‚ÌŒŸØ‚Æ•¶ŽšƒR[ƒh•ÏŠ·
- *
  * “ú–{Œê‚ð“ü—Í‚·‚é‰Â”\«‚Ì‚ ‚éƒtƒH[ƒ€‚ɂ͉B‚µ—v‘f‚Å
  * ƒGƒ“ƒR[ƒfƒBƒ“ƒO”»’è—p‚Ì•¶Žš—ñ‚ðŽdž‚ñ‚Å‚¢‚é
  *
@@ -42,25 +104,30 @@
 
     // NULLƒoƒCƒgƒAƒ^ƒbƒN‚ƃXƒNƒŠƒvƒgƒCƒ“ƒWƒFƒNƒVƒ‡ƒ“‚ÌŒŸØA
     // ƒGƒ“ƒR[ƒfƒBƒ“ƒO”»’è—p•¶Žš—ñ‚̎擾
-    if (!empty($_GET)) {
-        array_walk_recursive($_GET, 'p2_scan_nullbyte');
-        p2_scan_script_injection($_GET);
-        if (array_key_exists('_hint', $_GET)) {
-            $hint = $_GET['_hint'];
-        }
-    }
     if (!empty($_POST)) {
+        // V‹KƒƒOƒCƒ“‚ƃƒ“ƒo[ƒƒOƒCƒ“‚Ì“¯ŽžŽw’è‚Í‚ ‚肦‚È‚¢‚̂ŁAƒGƒ‰[‚ðo‚·
+        if (isset($_POST['submit_new']) && isset($_POST['submit_member'])) {
+            p2die('–³Œø‚ȃŠƒNƒGƒXƒg‚Å‚·B');
+        }
+
         array_walk_recursive($_POST, 'p2_scan_nullbyte');
         p2_scan_script_injection($_POST);
         if (array_key_exists('_hint', $_POST)) {
             $hint = $_POST['_hint'];
         }
     }
+    if (!empty($_GET)) {
+        array_walk_recursive($_GET, 'p2_scan_nullbyte');
+        p2_scan_script_injection($_GET);
+        if (array_key_exists('_hint', $_GET)) {
+            $hint = $_GET['_hint'];
+        }
+    }
 
     // ƒGƒ“ƒR[ƒfƒBƒ“ƒO”»’è
     if ($hint) {
         $request_encoding = mb_detect_encoding($hint, 'ASCII,UTF-8,SJIS-win');
-        if (!strcasecmp($request_encoding, 'ASCII')) {
+        if ($request_encoding == 'ASCII') {
             p2die('•s³‚ȃGƒ“ƒR[ƒfƒBƒ“ƒO”»’èƒqƒ“ƒg‚Å‚·B');
         }
     } else {
@@ -68,7 +135,7 @@
     }
 
     // UTF-8‚È‚çShift_JIS‚É•ÏŠ·
-    if (!strcasecmp($request_encoding, 'UTF-8')) {
+    if ($request_encoding == 'UTF-8') {
         mb_convert_variables('SJIS-win', 'UTF-8', $_GET, $_POST);
     }
 
@@ -97,8 +164,8 @@
 
 $mobile = Net_UserAgent_Mobile::singleton();
 
-// iPhone, iPod Touch
-if (P2Util::isBrowserIphone()) {
+// iPhone, iPod Touch or Android
+if (P2Util::isBrowserIphone() || P2Util::isBrowserAndroid()) {
     $_conf['ktai'] = true;
     $_conf['iphone'] = true;
     $_conf['input_type_search'] = true;
@@ -111,9 +178,13 @@
         $_conf['input_type_search'] = true;
         $_conf['accept_charset'] = 'UTF-8';
 
-    // Windows Mobile, Œg‘уQ[ƒ€‹@
-    } elseif (P2Util::isClientOSWindowsCE() || P2Util::isBrowserNintendoDS() || P2Util::isBrowserPSP()) {
+    // Windows Mobile, 
+    } elseif (P2Util::isClientOSWindowsCE()) {
         $_conf['ktai'] = true;
+
+    // Œg‘уQ[ƒ€‹@
+    } elseif (P2Util::isBrowserNintendoDS() || P2Util::isBrowserPSP()) {
+        $_conf['ktai'] = true;
     }
 
 // Œg‘Ñ
@@ -204,89 +275,8 @@
 }
 
 // }}}
-// {{{ ƒ†[ƒUÝ’è “Çž
+// {{{ ƒ†[ƒU[Ý’è‚Ì’²®ˆ—
 
-// ƒ†[ƒUÝ’èƒtƒ@ƒCƒ‹
-$_conf['conf_user_file'] = $_conf['pref_dir'] . '/conf_user.srd.cgi';
-
-// ‹ŒŒ`Ž®ƒtƒ@ƒCƒ‹‚ðƒRƒs[
-$conf_user_file_old = $_conf['pref_dir'] . '/conf_user.inc.php';
-if (!file_exists($_conf['conf_user_file']) && file_exists($conf_user_file_old)) {
-    $old_cont = DataPhp::getDataPhpCont($conf_user_file_old);
-    FileCtl::make_datafile($_conf['conf_user_file'], $_conf['conf_user_perm']);
-    if (FileCtl::file_write_contents($_conf['conf_user_file'], $old_cont) === false) {
-        $_info_msg_ht .= '<p>‹ŒŒ`Ž®ƒ†[ƒUÝ’è‚̃Rƒs[‚ÉŽ¸”s‚µ‚Ü‚µ‚½B</p>';
-    }
-}
-
-// ƒ†[ƒUÝ’肪‚ ‚ê‚Γǂݍž‚Þ
-if (file_exists($_conf['conf_user_file'])) {
-    if ($cont = file_get_contents($_conf['conf_user_file'])) {
-        $conf_user = unserialize($cont);
-    } else {
-        $conf_user = null;
-    }
-
-    // ‰½‚ç‚©‚Ì——R‚ц[ƒUÝ’èƒtƒ@ƒCƒ‹‚ª‰ó‚ê‚Ä‚¢‚½‚ç
-    if (!is_array($conf_user)) {
-        if (unlink($_conf['conf_user_file'])) {
-            $_info_msg_ht .= '<p>ƒ†[ƒUÝ’èƒtƒ@ƒCƒ‹‚ª‰ó‚ê‚Ä‚¢‚½‚Ì‚Å”jŠü‚µ‚Ü‚µ‚½B</p>';
-        } else {
-            $_info_msg_ht .= '<p>ƒ†[ƒUÝ’èƒtƒ@ƒCƒ‹‚ª‰ó‚ê‚Ä‚¢‚Ü‚·‚ªA”jŠü‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½B<br>&quot;';
-            $_info_msg_ht .= htmlspecialchars($_conf['conf_user_file'], ENT_QUOTES);
-            $_info_msg_ht .= '&quot; ‚ðŽè“®‚ō폜‚µ‚Ä‚­‚¾‚³‚¢B</p>';
-        }
-        $conf_user = array();
-        $conf_user_mtime = 0;
-    } else {
-        $conf_user_mtime = filemtime($_conf['conf_user_file']);
-    }
-
-    // ƒ†[ƒUÝ’èƒtƒ@ƒCƒ‹‚ƃfƒtƒHƒ‹ƒgÝ’èƒtƒ@ƒCƒ‹‚̍XV“úŽž‚ðƒ`ƒFƒbƒN
-    if (!isset($conf_user['.']) ||
-        $conf_user['.'] != P2_VERSION_ID ||
-        filemtime(__FILE__) > $conf_user_mtime ||
-        filemtime($P2_CONF_DIR_S . 'conf_user_def.inc.php')    > $conf_user_mtime ||
-        filemtime($P2_CONF_DIR_S . 'conf_user_def_ex.inc.php') > $conf_user_mtime ||
-        filemtime($P2_CONF_DIR_S . 'conf_user_def_i.inc.php')  > $conf_user_mtime)
-    {
-        // ƒfƒtƒHƒ‹ƒgÝ’è‚ð“ǂݍž‚Þ
-        include $P2_CONF_DIR_S . 'conf_user_def.inc.php';
-
-        // Ý’è‚̍XV
-        if (!array_key_exists('mobile.link_youtube', $conf_user)) {
-            if (!function_exists('p2_conf_user_update_080908')) {
-                include $P2_LIB_DIR_S . 'conf_user_updater.inc.php';
-            }
-            $conf_user = p2_conf_user_update_080908($conf_user);
-        }
-
-        $_conf = array_merge($_conf, $conf_user_def, $conf_user);
-
-        // V‚µ‚¢ƒ†[ƒUÝ’è‚ðƒLƒƒƒbƒVƒ…
-        $conf_user = array('.' => P2_VERSION_ID);
-        foreach ($conf_user_def as $k => $v) {
-            $conf_user[$k] = $_conf[$k];
-        }
-        if (FileCtl::file_write_contents($_conf['conf_user_file'], serialize($conf_user)) === false) {
-            $_info_msg_ht .= '<p>ƒ†[ƒUÝ’è‚̃LƒƒƒbƒVƒ…‚ÉŽ¸”s‚µ‚Ü‚µ‚½</p>';
-        }
-
-    // ƒ†[ƒUÝ’èƒtƒ@ƒCƒ‹‚̍XV“úŽž‚Ì•û‚ªV‚µ‚¢ê‡‚́AƒfƒtƒHƒ‹ƒgÝ’è‚𖳎‹
-    } else {
-        $_conf = array_merge($_conf, $conf_user);
-    }
-
-    unset($cont, $conf_user);
-} else {
-    // ƒfƒtƒHƒ‹ƒgÝ’è‚ð“ǂݍž‚Þ
-    include $P2_CONF_DIR_S . 'conf_user_def.inc.php';
-    $_conf = array_merge($_conf, $conf_user_def);
-}
-
-// }}}
-// {{{ ƒ†[ƒUÝ’è‚Ì’²®ˆ—
-
 $_conf['ext_win_target_at'] = ($_conf['ext_win_target']) ? " target=\"{$_conf['ext_win_target']}\"" : '';
 $_conf['bbs_win_target_at'] = ($_conf['bbs_win_target']) ? " target=\"{$_conf['bbs_win_target']}\"" : '';
 
@@ -294,7 +284,7 @@
     if ($_conf['get_new_res'] == 'all') {
         $_conf['get_new_res_l'] = $_conf['get_new_res'];
     } else {
-        $_conf['get_new_res_l'] = 'l'.$_conf['get_new_res'];
+        $_conf['get_new_res_l'] = 'l' . $_conf['get_new_res'];
     }
 } else {
     $_conf['get_new_res_l'] = 'l200';
@@ -308,7 +298,7 @@
 // {{{ ƒfƒUƒCƒ“Ý’è “Çž
 
 $skin_name = $default_skin_name = 'conf_user_style';
-$skin = $P2_CONF_DIR_S . 'conf_user_style.inc.php';
+$skin = P2_CONF_DIR . '/conf_user_style.inc.php';
 if (!$_conf['ktai'] && $_conf['expack.skin.enabled']) {
     // •Û‘¶‚³‚ê‚Ä‚¢‚éƒXƒLƒ“–¼
     $saved_skin_name = null;
@@ -347,12 +337,12 @@
             if ($skin_name == $default_skin_name) {
                 break;
             }
-            $user_skin_path = P2_USER_SKIN_DIR . DIRECTORY_SEPARATOR . $skin_name . '.php';
+            $user_skin_path = P2_USER_SKIN_DIR . '/' . $skin_name . '.php';
             if (file_exists($user_skin_path)) {
                 $skin = $user_skin_path;
                 break;
             }
-            $bundled_skin_path = P2_SKIN_DIR . DIRECTORY_SEPARATOR . $skin_name . '.php';
+            $bundled_skin_path = P2_SKIN_DIR . '/' . $skin_name . '.php';
             if (file_exists($bundled_skin_path)) {
                 $skin = $bundled_skin_path;
                 break;
@@ -363,7 +353,7 @@
 
 if (!file_exists($skin)) {
     $skin_name = 'conf_user_style';
-    $skin = $P2_CONF_DIR_S . 'conf_user_style.inc.php';
+    $skin = P2_CONF_DIR . '/conf_user_style.inc.php';
 }
 $skin_en = rawurlencode($skin_name) . '&amp;_=' . P2_VERSION_ID;
 if ($_conf['view_forced_by_query']) {
@@ -371,9 +361,9 @@
 }
 
 // ƒfƒtƒHƒ‹ƒgÝ’è‚ð“ǂݍž‚ñ‚Å
-include $P2_CONF_DIR_S . 'conf_user_style.inc.php';
+include P2_CONF_DIR . '/conf_user_style.inc.php';
 // ƒXƒLƒ“‚ŏ㏑‚«
-if ($skin != $P2_CONF_DIR_S . 'conf_user_style.inc.php') {
+if ($skin != P2_CONF_DIR . '/conf_user_style.inc.php') {
     include $skin;
 }
 
@@ -396,7 +386,7 @@
 
 if (!$_conf['ktai']) {
     if (!function_exists('p2_fontconfig_apply_custom')) {
-        include $P2_LIB_DIR_S . 'fontconfig.inc.php';
+        include P2_LIB_DIR . '/fontconfig.inc.php';
     }
 
     if ($_conf['expack.am.enabled']) {
@@ -532,7 +522,7 @@
         switch ($_conf['mobile.display_accesskey']) {
         case 2:
             if (!function_exists('p2_get_emoji')) {
-                include $P2_LIB_DIR_S . 'emoji.inc.php';
+                include P2_LIB_DIR . '/emoji.inc.php';
             }
             $emoji = p2_get_emoji($mobile);
             //$emoji = p2_get_emoji(Net_UserAgent_Mobile::factory('KDDI-SA31 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0'));
@@ -636,8 +626,6 @@
 // –¼‘O‚́AƒZƒbƒVƒ‡ƒ“ƒNƒbƒL[‚ð”jŠü‚·‚é‚Æ‚«‚Ì‚½‚߂ɁAƒZƒbƒVƒ‡ƒ“—˜—p‚Ì—L–³‚ÉŠÖ‚í‚炸Ý’è‚·‚é
 session_name('PS');
 
-$_conf['sid_at_a'] = '';
-
 // {{{ ƒZƒbƒVƒ‡ƒ“ƒf[ƒ^•Û‘¶ƒfƒBƒŒƒNƒgƒŠ‚ðƒ`ƒFƒbƒN
 
 if ($_conf['session_save'] == 'p2' and session_module_name() == 'files') {
@@ -660,16 +648,22 @@
 // •¡”‚Ì‚¨‹C‚ɃZƒbƒg‚ðŽg‚¤‚Æ‚«
 if ($_conf['expack.misc.multi_favs']) {
     if (!class_exists('FavSetManager', false)) {
-        include $P2_LIB_DIR_S . 'FavSetManager.php';
+        include P2_LIB_DIR . '/FavSetManager.php';
     }
     // Ø‚è‘Ö‚¦•\Ž¦—p‚É‘S‚Ä‚Ì‚¨‹C‚ɃXƒŒE‚¨‹C‚ɔ‚ð“ǂݍž‚ñ‚Å‚¨‚­
     FavSetManager::loadAllFavSet();
     // ‚¨‹C‚ɃZƒbƒg‚ðØ‚è‘Ö‚¦‚é
     FavSetManager::switchFavSet();
 } else {
-    $_conf['m_favlist_set'] = $_conf['m_favlist_set_at_a'] = $_conf['m_favlist_set_input_ht'] = '';
-    $_conf['m_favita_set']  = $_conf['m_favita_set_at_a']  = $_conf['m_favita_set_input_ht']  = '';
-    $_conf['m_rss_set']     = $_conf['m_rss_set_at_a']     = $_conf['m_rss_set_input_ht']     = '';
+    $_conf['m_favlist_set'] = '';
+    $_conf['m_favlist_set_at_a'] = '';
+    $_conf['m_favlist_set_input_ht'] = '';
+    $_conf['m_favita_set'] = '';
+    $_conf['m_favita_set_at_a'] = '';
+    $_conf['m_favita_set_input_ht'] = '';
+    $_conf['m_rss_set'] = '';
+    $_conf['m_rss_set_at_a'] = '';
+    $_conf['m_rss_set_input_ht'] = '';
 }
 
 // }}}

Modified: p2ex/trunk/lib/expack/ExpackLoader.php
===================================================================
--- p2ex/trunk/lib/expack/ExpackLoader.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ExpackLoader.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -112,11 +112,7 @@
         if ((!$_conf['ktai'] && $_conf['expack.ic2.enabled'] % 2 == 1) ||
             ($_conf['ktai'] && $_conf['expack.ic2.enabled'] >= 2))
         {
-            self::loadFunction('ic2_loadconfig',        'ic2/loadconfig.inc.php');
-            self::loadClass('IC2_DataObject_Images',    'ic2/DataObject/Images.php');
-            self::loadClass('IC2_DataObject_BlackList', 'ic2/DataObject/BlackList.php');
-            self::loadClass('IC2_DataObject_Errors',    'ic2/DataObject/Errors.php');
-            self::loadClass('IC2_Thumbnailer',          'ic2/Thumbnailer.php');
+            self::loadFunction('ic2_loadconfig', 'ic2/bootstrap.php');
             define('P2_IMAGECACHE_AVAILABLE', 2);
         } else {
             define('P2_IMAGECACHE_AVAILABLE', 0);
@@ -199,7 +195,7 @@
         if ($_conf['iphone']) {
             $aShowThread->aas_rotate = '&#x21BB;';
         } elseif ($_conf['ktai']) {
-            $mobile = &Net_UserAgent_Mobile::singleton();
+            $mobile = Net_UserAgent_Mobile::singleton();
             /**
              * @link http://www.nttdocomo.co.jp/service/imode/make/content/pictograph/
              * @link http://www.au.kddi.com/ezfactory/tec/spec/3.html

Modified: p2ex/trunk/lib/expack/ic2/DataObject/BlackList.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/DataObject/BlackList.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ic2/DataObject/BlackList.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,14 +1,5 @@
 <?php
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
 
-// {{{ constants
-
-define('P2_IMAGECACHE_BLACKLIST_NOMORE', 0);
-define('P2_IMAGECACHE_BLACKLIST_ABORN', 1);
-define('P2_IMAGECACHE_BLACKLIST_VIRUS', 2);
-
-// }}}
 // {{{ IC2_DataObject_BlackList
 
 class IC2_DataObject_BlackList extends IC2_DataObject_Common

Modified: p2ex/trunk/lib/expack/ic2/DataObject/Common.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/DataObject/Common.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ic2/DataObject/Common.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,7 +1,4 @@
 <?php
-require_once 'DB.php';
-require_once 'DB/DataObject.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
 
 // {{{ IC2_DataObject_Common
 

Modified: p2ex/trunk/lib/expack/ic2/DataObject/Errors.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/DataObject/Errors.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ic2/DataObject/Errors.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,6 +1,4 @@
 <?php
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
 
 // {{{ IC2_DataObject_Errors
 

Modified: p2ex/trunk/lib/expack/ic2/DataObject/Images.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/DataObject/Images.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ic2/DataObject/Images.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,23 +1,5 @@
 <?php
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/BlackList.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Errors.php';
 
-// {{{ constants
-
-define('P2_IMAGECACHE_OK',     0);
-define('P2_IMAGECACHE_ABORN',  1);
-define('P2_IMAGECACHE_BROKEN', 2);
-define('P2_IMAGECACHE_LARGE',  3);
-define('P2_IMAGECACHE_VIRUS',  4);
-
-// }}}
-// {{{ GLOBALS
-
-$GLOBALS['_P2_GETIMAGE_CACHE'] = array();
-
-// }}}
 // {{{ IC2_DataObject_Images
 
 class IC2_DataObject_Images extends IC2_DataObject_Common

Copied: p2ex/trunk/lib/expack/ic2/DatabaseManager.php (from rev 772, p2ex/trunk/lib/expack/ic2/managedb.inc.php)
===================================================================
--- p2ex/trunk/lib/expack/ic2/DatabaseManager.php	                        (rev 0)
+++ p2ex/trunk/lib/expack/ic2/DatabaseManager.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,286 @@
+<?php
+
+// {{{ IC2_DatabaseManager
+
+/**
+ * ImageCache2 - ‰æ‘œî•ñ‚𑀍삷‚éƒNƒ‰ƒX
+ */
+class IC2_DatabaseManager
+{
+    // {{{ update()
+
+    /**
+     * ‰æ‘œî•ñ‚ðXV
+     */
+    static public function update($updated)
+    {
+        if (empty($updated)) {
+            return;
+        }
+        if (!is_array($updated)) {
+            global $_info_msg_ht;
+            $_info_msg_ht .= '<p>WARNING! IC2_DatabaseManager::update(): •s³‚Ȉø”</p>';
+            return;
+        }
+
+        // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚ÌŠJŽn
+        $ta = new IC2_DataObject_Images;
+        $db = $ta->getDatabaseConnection();
+        if ($db->phptype == 'pgsql') {
+            $ta->query('BEGIN');
+        } elseif ($db->phptype == 'sqlite') {
+            $db->query('BEGIN;');
+        }
+
+        // ‰æ‘œƒf[ƒ^‚ðXV
+        foreach ($updated as $id => $data) {
+            $icdb = new IC2_DataObject_Images;
+            $icdb->whereAdd("id = $id");
+            if ($icdb->find(true)) {
+                // ƒƒ‚‚ðXV
+                if ($icdb->memo != $data['memo']) {
+                    $memo = new IC2_DataObject_Images;
+                    $memo->memo = (strlen($data['memo']) > 0) ? $data['memo'] : '';
+                    $memo->whereAdd("id = $id");
+                    $memo->update();
+                }
+                // ƒ‰ƒ“ƒN‚ðXV
+                if ($icdb->rank != $data['rank']) {
+                    $rank = new IC2_DataObject_Images;
+                    $rank->rank = $data['rank'];
+                    $rank->whereAddQuoted('size', '=', $icdb->size);
+                    $rank->whereAddQuoted('md5',  '=', $icdb->md5);
+                    $rank->whereAddQuoted('mime', '=', $icdb->mime);
+                    $rank->update();
+                }
+            }
+        }
+
+        // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚̃Rƒ~ƒbƒg
+        if ($db->phptype == 'pgsql') {
+            $ta->query('COMMIT');
+        } elseif ($db->phptype == 'sqlite') {
+            $db->query('COMMIT;');
+        }
+    }
+
+    // }}}
+    // {{{ remove()
+
+    /**
+     * ‰æ‘œ‚ðíœ
+     */
+    static public function remove($target, $to_blacklist = false)
+    {
+        $removed_files = array();
+        if (empty($target)) {
+            return $removed_files;
+        }
+        if (!is_array($target)) {
+            if (is_integer($target) || ctype_digit($target)) {
+                $id = (int) $target;
+                if ($id > 0) {
+                    $target = array($id);
+                } else {
+                    return $removed_files;
+                }
+            } else {
+                global $_info_msg_ht;
+                $_info_msg_ht .= '<p>WARNING! IC2_DatabaseManager::remove(): •s³‚Ȉø”</p>';
+                return $removed_files;
+            }
+        }
+
+        // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚ÌŠJŽn
+        $ta = new IC2_DataObject_Images;
+        $db = $ta->getDatabaseConnection();
+        if ($db->phptype == 'pgsql') {
+            $ta->query('BEGIN');
+        } elseif ($db->phptype == 'sqlite') {
+            $db->query('BEGIN;');
+        }
+
+        // ‰æ‘œ‚ðíœ
+        foreach ($target as $id) {
+            $icdb = new IC2_DataObject_Images;
+            $icdb->whereAdd("id = {$id}");
+
+            if ($icdb->find(true)) {
+                // ƒLƒƒƒbƒVƒ…‚µ‚Ä‚¢‚éƒtƒ@ƒCƒ‹‚ðíœ
+                $t1 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_PC);
+                $t2 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_MOBILE);
+                $t3 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_INTERMD);
+                $srcPath = $t1->srcPath($icdb->size, $icdb->md5, $icdb->mime);
+                $t1Path = $t1->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
+                $t2Path = $t2->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
+                $t3Path = $t3->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
+                if (file_exists($srcPath)) {
+                    unlink($srcPath);
+                    $removed_files[] = $srcPath;
+                }
+                if (file_exists($t1Path)) {
+                    unlink($t1Path);
+                    $removed_files[] = $t1Path;
+                }
+                if (file_exists($t2Path)) {
+                    unlink($t2Path);
+                    $removed_files[] = $t2Path;
+                }
+                if (file_exists($t3Path)) {
+                    unlink($t3Path);
+                    $removed_files[] = $t3Path;
+                }
+
+                // ƒuƒ‰ƒbƒNƒŠƒXƒg‘—‚è‚̏€”õ
+                if ($to_blacklist) {
+                    $_blacklist = new IC2_DataObject_BlackList;
+                    $_blacklist->size = $icdb->size;
+                    $_blacklist->md5  = $icdb->md5;
+                    if ($icdb->mime == 'clamscan/infected' || $icdb->rank == -4) {
+                        $_blacklist->type = 2;
+                    } elseif ($icdb->rank < 0) {
+                        $_blacklist->type = 1;
+                    } else {
+                        $_blacklist->type = 0;
+                    }
+                }
+
+                // “¯ˆê‰æ‘œ‚ðŒŸõ
+                $remover = new IC2_DataObject_Images;
+                $remover->whereAddQuoted('size', '=', $icdb->size);
+                $remover->whereAddQuoted('md5',  '=', $icdb->md5);
+                //$remover->whereAddQuoted('mime', '=', $icdb->mime); // Size‚ÆMD5‚ŏ\•ª
+                $remover->find();
+                while ($remover->fetch()) {
+                    // ƒuƒ‰ƒbƒNƒŠƒXƒg‘—‚è‚É‚·‚é
+                    if ($to_blacklist) {
+                        $blacklist = clone $_blacklist;
+                        $blacklist->uri = $remover->uri;
+                        $blacklist->insert();
+                    }
+                    // ƒe[ƒuƒ‹‚©‚ç–•Á
+                    $remover->delete();
+                }
+            }
+        }
+
+        // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚̃Rƒ~ƒbƒg
+        if ($db->phptype == 'pgsql') {
+            $ta->query('COMMIT');
+        } elseif ($db->phptype == 'sqlite') {
+            $db->query('COMMIT;');
+        }
+
+        return $removed_files;
+    }
+
+    // }}}
+    // {{{ setRank()
+
+    /**
+     * ƒ‰ƒ“ƒN‚ðÝ’è
+     */
+    static public function setRank($target, $rank)
+    {
+        if (empty($target)) {
+            return;
+        }
+        if (!is_array($target)) {
+            if (is_integer($updated) || ctype_digit($updated)) {
+                $id = (int)$updated;
+                if ($id > 0) {
+                    $updated = array($id);
+                } else {
+                    return;
+                }
+            } else {
+                global $_info_msg_ht;
+                $_info_msg_ht .= '<p>WARNING! IC2_DatabaseManager::setRank(): •s³‚Ȉø”</p>';
+                return $removed_files;
+            }
+        }
+
+        $icdb = new IC2_DataObject_Images;
+        $icdb->rank = $rank;
+        foreach ($target as $id) {
+            $icdb->whereAdd("id = $id", 'OR');
+        }
+        $icdb->update();
+    }
+
+    // }}}
+    // {{{ addMemo()
+
+    /**
+     * ƒƒ‚‚ð’ljÁ
+     */
+    static public function addMemo($target, $memo)
+    {
+        if (empty($target)) {
+            return;
+        }
+        if (!is_array($target)) {
+            if (is_integer($updated) || ctype_digit($updated)) {
+                $id = (int)$updated;
+                if ($id > 0) {
+                    $updated = array($id);
+                } else {
+                    return;
+                }
+            } else {
+                global $_info_msg_ht;
+                $_info_msg_ht .= '<p>WARNING! IC2_DatabaseManager::addMemo(): •s³‚Ȉø”</p>';
+                return $removed_files;
+            }
+        }
+
+        // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚ÌŠJŽn
+        $ta = new IC2_DataObject_Images;
+        $db = $ta->getDatabaseConnection();
+        if ($db->phptype == 'pgsql') {
+            $ta->query('BEGIN');
+        } elseif ($db->phptype == 'sqlite') {
+            $db->query('BEGIN;');
+        }
+
+        // ƒƒ‚‚ÉŽw’蕶Žš—ñ‚ªŠÜ‚Ü‚ê‚Ä‚¢‚È‚¯‚ê‚΍XV
+        foreach ($target as $id) {
+            $find = new IC2_DataObject_Images;
+            $find->whereAdd("id = $id");
+            if ($find->find(true) && strpos($find->memo, $memo) === false) {
+                $update = new IC2_DataObject_Images;
+                $update->whereAdd("id = $id");
+                if (strlen($find->memo) > 0) {
+                    $update->memo = $find->memo . ' ' . $memo;
+                } else {
+                    $update->memo = $memo;
+                }
+                $update->update();
+                unset($update);
+            }
+            unset($find);
+        }
+
+        // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚̃Rƒ~ƒbƒg
+        if ($db->phptype == 'pgsql') {
+            $ta->query('COMMIT');
+        } elseif ($db->phptype == 'sqlite') {
+            $db->query('COMMIT;');
+        }
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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:

Copied: p2ex/trunk/lib/expack/ic2/ImageInfo.php (from rev 772, p2ex/trunk/lib/expack/ic2/buildimgcell.inc.php)
===================================================================
--- p2ex/trunk/lib/expack/ic2/ImageInfo.php	                        (rev 0)
+++ p2ex/trunk/lib/expack/ic2/ImageInfo.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,95 @@
+<?php
+
+// {{{ IC2_ImageInfo
+
+/**
+ * ImageCache2 - ‰æ‘œî•ñŽæ“¾—pƒ†[ƒeƒBƒŠƒeƒBƒNƒ‰ƒX
+ */
+class IC2_ImageInfo
+{
+    // {{{ getExtraInfo()
+
+    static public function getExtraInfo($img)
+    {
+        global $_conf, $ini, $icdb, $thumb;
+
+        // ’·‚·‚¬‚éURI‚͐܂è•Ô‚·
+        if (strlen($img['uri']) > 45) {
+            $w = explode("\n", wordwrap($img['uri'], 45, "\n", 1));
+            $w = array_map('htmlspecialchars', $w);
+            $add['uri_w'] = implode('<br />', $w);
+        } else {
+            $add['uri_w'] = $img['uri'];
+        }
+
+        if ($img['mime'] == 'clamscan/infected') {
+
+            // ƒEƒBƒ‹ƒX‚ÉŠ´õ‚µ‚Ä‚¢‚½ƒtƒ@ƒCƒ‹‚Ì‚Æ‚«
+            $add['src'] = './img/x04.png';
+            $add['thumb'] = './img/x04.png';
+            $add['t_width'] = 32;
+            $add['t_height'] = 32;
+
+        } else {
+
+            // ƒ\[ƒX‚ƃTƒ€ƒlƒCƒ‹‚̃pƒX‚ðŽæ“¾
+            $add['src'] = $thumb->srcPath($icdb->size, $icdb->md5, $icdb->mime);
+            $add['thumb'] = $thumb->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
+
+            // ƒTƒ€ƒlƒCƒ‹‚̏c‰¡‚Ì‘å‚«‚³‚ðŒvŽZ
+            $m = explode('x', $thumb->calc($icdb->width, $icdb->height));
+            $add['t_width'] = (int)$m[0];
+            $add['t_height'] = (int)$m[1];
+
+        }
+
+        // ƒ\[ƒX‚̃tƒ@ƒCƒ‹ƒTƒCƒY‚̏‘Ž®‚𐮂¦‚é
+        if ($img['size'] > 1024 * 1024) {
+            $add['size_f'] = number_format($img['size'] / (1024 * 1024), 1) . 'MB';
+        } elseif ($img['size'] > 1024) {
+            $add['size_f'] = number_format($img['size'] / 1024, 1) . 'KB';
+        } else {
+            $add['size_f'] = $img['size'] . 'B';
+        }
+
+        // “ú•t‚̏‘Ž®‚𐮂¦‚é
+        $add['date'] = date('Y-m-d (D) H:i:s', $img['time']);
+
+        return $add;
+    }
+
+    // }}}
+    // {{{ getExifData()
+
+    static public function getExifData($path)
+    {
+        $exif = @exif_read_data($path, '', true, false);
+        if ($exif) {
+            // ƒoƒCƒiƒŠ‚ŁA‚µ‚©‚àƒf[ƒ^ƒTƒCƒY‚ª‘å‚«‚¢—v‘f‚ðíœ
+            if (isset($exif['MakerNote'])) {
+                unset($exif['MakerNote']);
+            }
+            if (isset($exif['EXIF']) && isset($exif['EXIF']['MakerNote'])) {
+                unset($exif['EXIF']['MakerNote']);
+            }
+            return $exif;
+        } else {
+            return null;
+        }
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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:

Copied: p2ex/trunk/lib/expack/ic2/ParameterUtility.php (from rev 772, p2ex/trunk/lib/expack/ic2/getvalidvalue.inc.php)
===================================================================
--- p2ex/trunk/lib/expack/ic2/ParameterUtility.php	                        (rev 0)
+++ p2ex/trunk/lib/expack/ic2/ParameterUtility.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,70 @@
+<?php
+
+// {{{ IC2_ParameterUtility
+
+/**
+ * ImageCache2 - ƒŠƒNƒGƒXƒg•Ï”‚Ì‹¸³ƒ†[ƒeƒBƒŠƒeƒBƒNƒ‰ƒX
+ */
+class IC2_ParameterUtility
+{
+    // {{{ getValidValue()
+
+    /**
+     * Submit‚³‚ꂽ’l‚ª‘Ó–‚È‚çiƒtƒBƒ‹ƒ^‚ð“K—p‚µ‚āj•Ô‚µA‚»‚¤‚Å‚È‚¯‚ê‚΃fƒtƒHƒ‹ƒg’l‚ð“K—p‚·‚é
+     *
+     * ƒ‰ƒWƒIƒ{ƒ^ƒ“‚âƒ`ƒFƒbƒNƒ{ƒbƒNƒXAHTML_QuickForm‚̃Oƒ‹[ƒv‚É‚Í”ñ‘Ήž
+     * HTML_QuickForm‚ðŒp³‚µ‚½ƒNƒ‰ƒX‚̃ƒ\ƒbƒh‚Æ‚µ‚ÄŽÀ‘•‚·‚ׂ«
+     */
+    static public function getValidValue($key, $default, $filter = '')
+    {
+        global $qf, $qfe;
+        $value = $qf->getSubmitValue($key);
+        if (is_null($value) || $qf->getElementError($key)) {
+            if ($qfe[$key]->getType() == 'select') {
+                $qfe[$key]->setSelected($default);
+            } else {
+                $qfe[$key]->setValue($default);
+            }
+            return $default;
+        }
+        return (strlen($filter) > 0) ? $filter($value) : $value;
+    }
+
+    // }}}
+    // {{{ intoRange()
+
+    /**
+     * ”’l‚ðŽw’肳‚ꂽ”͈͂ɖ³—–‰Ÿ‚µž‚ß‚éŠÖ”
+     */
+    static public function intoRange($int)
+    {
+        $a = func_get_args();
+        $r = array_map('intval', $a);
+        $g = func_num_args();
+        $int = $r[0];
+        switch ($g) {
+            case 1: return $int;
+            case 2: $min = 0; $max = $r[1]; break;
+            default: $min = $r[1]; $max = $r[2];
+        }
+        if ($min > $max) {
+            list($min, $max) = array($max, $min);
+        }
+        return max($min, min($max, intval($int)));
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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/expack/ic2/Thumbnailer.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/Thumbnailer.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ic2/Thumbnailer.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -3,11 +3,6 @@
  * rep2expack - ImageCache2
  */
 
-require_once P2EX_LIB_DIR . '/ic2/findexec.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php';
-
 // {{{ IC2_Thumbnailer
 
 class IC2_Thumbnailer
@@ -57,7 +52,6 @@
     );
     // @var array $mimemap, MIMEƒ^ƒCƒv‚ÆŠg’£Žq‚̑Ήž•\
     public $mimemap = array('image/jpeg' => '.jpg', 'image/png' => '.png', 'image/gif' => '.gif');
-    public $windows;        // @var bool    ƒT[ƒoOS‚ªWindows‚©”Û‚©
 
     // }}}
     // {{{ constructor
@@ -80,14 +74,12 @@
             $this->intermd = false;
         }
 
-        $this->windows = (bool)P2_OS_WINDOWS;
-
         // Ý’è
         $this->ini = ic2_loadconfig();
 
         // ƒf[ƒ^ƒx[ƒX‚ɐڑ±
         $icdb = new IC2_DataObject_Images;
-        $this->db = &$icdb->getDatabaseConnection();
+        $this->db = $icdb->getDatabaseConnection();
         if (DB::isError($this->db)) {
             $this->error($this->db->getMessage());
         }
@@ -119,7 +111,7 @@
                 $this->driver = 'imagemagick';
             case 'imagemagick': // ImageMagick ‚Ì convert ƒRƒ}ƒ“ƒh
                 $searchpath = $this->ini['General']['magick'];
-                if (!findexec('convert', $searchpath)) {
+                if (!ic2_findexec('convert', $searchpath)) {
                     $this->error('ImageMagick‚ªŽg‚¦‚Ü‚¹‚ñB');
                 }
                 if ($searchpath) {
@@ -291,17 +283,7 @@
 
         // ƒCƒ[ƒWƒhƒ‰ƒCƒo‚ɃTƒ€ƒlƒCƒ‹ì¬ˆ—‚ð‚³‚¹‚é
         $convertorClass = 'Thumbnailer_' . ucfirst(strtolower($this->driver));
-        if ($convertorClass == 'Thumbnailer_Imagick') {
-            if (!class_exists('Imagick', false)) {
-                $convertorClass = 'Thumbnailer_Imagick09';
-            }
-        }
 
-        if (!class_exists($convertorClass, false)) {
-            require dirname(__FILE__) . DIRECTORY_SEPARATOR .
-                    str_replace('_', DIRECTORY_SEPARATOR, $convertorClass) . '.php';
-        }
-
         $convertor = new $convertorClass();
         $convertor->setBgColor($this->bgcolor[0], $this->bgcolor[1], $this->bgcolor[2]);
         $convertor->setHttp(true);
@@ -504,7 +486,7 @@
         }
         $sql = 'SELECT MAX(' . $this->db->quoteIdentifier('id') . ') + 1 FROM '
              . $this->db->quoteIdentifier($this->ini['General']['table']) . ';';
-        $nextid = &$this->db->getOne($sql);
+        $nextid = $this->db->getOne($sql);
         if (DB::isError($nextid) || !$nextid) {
             $nextid = 1;
         }

Added: p2ex/trunk/lib/expack/ic2/bootstrap.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/bootstrap.php	                        (rev 0)
+++ p2ex/trunk/lib/expack/ic2/bootstrap.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,148 @@
+<?php
+/**
+ * rep2expack - ImageCache2 ‰Šú‰»ƒXƒNƒŠƒvƒg
+ */
+
+require_once 'DB.php';
+require_once 'DB/DataObject.php';
+
+// {{{ GLOBALS
+
+$GLOBALS['_P2_GETIMAGE_CACHE'] = array();
+
+// }}}
+// {{{ constants
+
+define('P2_IMAGECACHE_OK',     0);
+define('P2_IMAGECACHE_ABORN',  1);
+define('P2_IMAGECACHE_BROKEN', 2);
+define('P2_IMAGECACHE_LARGE',  3);
+define('P2_IMAGECACHE_VIRUS',  4);
+
+define('P2_IMAGECACHE_BLACKLIST_NOMORE', 0);
+define('P2_IMAGECACHE_BLACKLIST_ABORN',  1);
+define('P2_IMAGECACHE_BLACKLIST_VIRUS',  2);
+
+// }}}
+// {{{ ic2_loadconfig()
+
+/**
+ * ƒ†[ƒUÝ’è“ǂݍž‚݊֐”
+ *
+ * @param void
+ * @return array
+ */
+function ic2_loadconfig()
+{
+    static $ini = null;
+
+    if (is_null($ini)) {
+        include P2_CONF_DIR . '/conf_ic2.inc.php';
+
+        $ini = array();
+        $_ic2conf = preg_grep('/^expack\\.ic2\\.\\w+\\.\\w+$/', array_keys($_conf));
+        foreach ($_ic2conf as $key) {
+            $p = explode('.', $key);
+            $cat = ucfirst($p[2]);
+            $name = $p[3];
+            if (!isset($ini[$cat])) {
+                $ini[$cat] = array();
+            }
+            $ini[$cat][$name] = $_conf[$key];
+        }
+
+        // DB_DataObject‚̐ݒè
+        $_dao_options = &PEAR::getStaticProperty('DB_DataObject', 'options');
+        if (!is_array($_dao_options)) {
+            $_dao_options = array();
+        }
+        $_dao_options['database'] = $ini['General']['dsn'];
+        $_dao_options['debug'] = false;
+        $_dao_options['quote_identifiers'] = true;
+        $_dao_options['db_driver'] = 'DB';
+    }
+
+    return $ini;
+}
+
+// }}}
+// {{{ ic2_findexec()
+
+/**
+ * ŽÀsƒtƒ@ƒCƒ‹ŒŸõŠÖ”
+ *
+ * $search_path‚©‚çŽÀsƒtƒ@ƒCƒ‹$command‚ðŒŸõ‚·‚é
+ * Œ©‚‚©‚ê‚΃pƒX‚ðƒGƒXƒP[ƒv‚µ‚Ä•Ô‚·i$escape‚ª‹U‚È‚ç‚»‚Ì‚Ü‚Ü•Ô‚·j
+ * Œ©‚‚©‚ç‚È‚¯‚ê‚Îfalse‚ð•Ô‚·
+ *
+ * @param string $command
+ * @param string $search_path
+ * @param bool $escape
+ * @return string
+ */
+function ic2_findexec($command, $search_path = '', $escape = true)
+{
+    // Windows‚©A‚»‚Ì‘¼‚ÌOS‚©
+    if (P2_OS_WINDOWS) {
+        if (strtolower(strrchr($command, '.')) != '.exe') {
+            $command .= '.exe';
+        }
+        $check = function_exists('is_executable') ? 'is_executable' : 'file_exists';
+    } else {
+        $check = 'is_executable';
+    }
+
+    // $search_path‚ª‹ó‚Ì‚Æ‚«‚͊‹«•Ï”PATH‚©‚猟õ‚·‚é
+    if ($search_path == '') {
+        $search_dirs = explode(PATH_SEPARATOR, getenv('PATH'));
+    } else {
+        $search_dirs = explode(PATH_SEPARATOR, $search_path);
+    }
+
+    // ŒŸõ
+    foreach ($search_dirs as $path) {
+        $path = realpath($path);
+        if ($path === false || !is_dir($path)) {
+            continue;
+        }
+        if ($check($path . DIRECTORY_SEPARATOR . $command)) {
+            return ($escape ? escapeshellarg($command) : $command);
+        }
+    }
+
+    // Œ©‚‚©‚ç‚È‚©‚Á‚½
+    return false;
+}
+
+// }}}
+// {{{ ic2_load_class()
+
+/**
+ * ƒNƒ‰ƒXƒ[ƒ_[
+ *
+ * @string $name
+ * @return void
+ */
+function ic2_load_class($name)
+{
+    if (strncmp($name, 'IC2_', 3) === 0) {
+        include P2EX_LIB_DIR . '/ic2/' . str_replace('_', '/', substr($name, 3)) . '.php';
+    } elseif (strncmp($name, 'Thumbnailer_', 12) === 0) {
+        include P2_LIB_DIR . '/' . str_replace('_', '/', $name) . '.php';
+    }
+}
+
+// }}}
+
+spl_autoload_register('ic2_load_class');
+
+/*
+ * 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:

Deleted: p2ex/trunk/lib/expack/ic2/buildimgcell.inc.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/buildimgcell.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ic2/buildimgcell.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,88 +0,0 @@
-<?php
-/**
- * ImageCache2 - ˆê——•\Ž¦—pƒ†[ƒeƒBƒŠƒeƒBŠÖ”
- */
-
-// {{{ ic2_image_extra_info()
-
-function ic2_image_extra_info($img)
-{
-    global $_conf, $ini, $icdb, $thumb;
-
-    // ’·‚·‚¬‚éURI‚͐܂è•Ô‚·
-    if (strlen($img['uri']) > 45) {
-        $w = explode("\n", wordwrap($img['uri'], 45, "\n", 1));
-        $w = array_map('htmlspecialchars', $w);
-        $add['uri_w'] = implode('<br />', $w);
-    } else {
-        $add['uri_w'] = $img['uri'];
-    }
-
-    if ($img['mime'] == 'clamscan/infected') {
-
-        // ƒEƒBƒ‹ƒX‚ÉŠ´õ‚µ‚Ä‚¢‚½ƒtƒ@ƒCƒ‹‚Ì‚Æ‚«
-        $add['src'] = './img/x04.png';
-        $add['thumb'] = './img/x04.png';
-        $add['t_width'] = 32;
-        $add['t_height'] = 32;
-
-    } else {
-
-        // ƒ\[ƒX‚ƃTƒ€ƒlƒCƒ‹‚̃pƒX‚ðŽæ“¾
-        $add['src'] = $thumb->srcPath($icdb->size, $icdb->md5, $icdb->mime);
-        $add['thumb'] = $thumb->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
-
-        // ƒTƒ€ƒlƒCƒ‹‚̏c‰¡‚Ì‘å‚«‚³‚ðŒvŽZ
-        $m = explode('x', $thumb->calc($icdb->width, $icdb->height));
-        $add['t_width'] = (int)$m[0];
-        $add['t_height'] = (int)$m[1];
-
-    }
-
-    // ƒ\[ƒX‚̃tƒ@ƒCƒ‹ƒTƒCƒY‚̏‘Ž®‚𐮂¦‚é
-    if ($img['size'] > 1024 * 1024) {
-        $add['size_f'] = number_format($img['size'] / (1024 * 1024), 1) . 'MB';
-    } elseif ($img['size'] > 1024) {
-        $add['size_f'] = number_format($img['size'] / 1024, 1) . 'KB';
-    } else {
-        $add['size_f'] = $img['size'] . 'B';
-    }
-
-    // “ú•t‚̏‘Ž®‚𐮂¦‚é
-    $add['date'] = date('Y-m-d (D) H:i:s', $img['time']);
-
-    return $add;
-}
-
-// }}}
-// {{{ ic2_read_exif()
-
-function ic2_read_exif($path)
-{
-    $exif = @exif_read_data($path, '', true, false);
-    if ($exif) {
-        // ƒoƒCƒiƒŠ‚ŁA‚µ‚©‚àƒf[ƒ^ƒTƒCƒY‚ª‘å‚«‚¢—v‘f‚ðíœ
-        if (isset($exif['MakerNote'])) {
-            unset($exif['MakerNote']);
-        }
-        if (isset($exif['EXIF']) && isset($exif['EXIF']['MakerNote'])) {
-            unset($exif['EXIF']['MakerNote']);
-        }
-        return $exif;
-    } else {
-        return null;
-    }
-}
-
-// }}}
-
-/*
- * 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:

Deleted: p2ex/trunk/lib/expack/ic2/findexec.inc.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/findexec.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ic2/findexec.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,58 +0,0 @@
-<?php
-/**
- * ImageCache2 - ŽÀsƒtƒ@ƒCƒ‹ŒŸõŠÖ”
- */
-
-// {{{ findexec()
-
-/**
- * $search_path‚©‚çŽÀsƒtƒ@ƒCƒ‹$command‚ðŒŸõ‚·‚é
- * Œ©‚‚©‚ê‚΃pƒX‚ðƒGƒXƒP[ƒv‚µ‚Ä•Ô‚·i$escape‚ª‹U‚È‚ç‚»‚Ì‚Ü‚Ü•Ô‚·j
- * Œ©‚‚©‚ç‚È‚¯‚ê‚Îfalse‚ð•Ô‚·
- */
-function findexec($command, $search_path = '', $escape = true)
-{
-    // Windows‚©A‚»‚Ì‘¼‚ÌOS‚©
-    if (P2_OS_WINDOWS) {
-        if (strtolower(strrchr($command, '.')) != '.exe') {
-            $command .= '.exe';
-        }
-        $check = function_exists('is_executable') ? 'is_executable' : 'file_exists';
-    } else {
-        $check = 'is_executable';
-    }
-
-    // $search_path‚ª‹ó‚Ì‚Æ‚«‚͊‹«•Ï”PATH‚©‚猟õ‚·‚é
-    if ($search_path == '') {
-        $search_dirs = explode(PATH_SEPARATOR, getenv('PATH'));
-    } else {
-        $search_dirs = explode(PATH_SEPARATOR, $search_path);
-    }
-
-    // ŒŸõ
-    foreach ($search_dirs as $path) {
-        $path = realpath($path);
-        if ($path === false || !is_dir($path)) {
-            continue;
-        }
-        if ($check($path . DIRECTORY_SEPARATOR . $command)) {
-            return ($escape ? escapeshellarg($command) : $command);
-        }
-    }
-
-    // Œ©‚‚©‚ç‚È‚©‚Á‚½
-    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:

Deleted: p2ex/trunk/lib/expack/ic2/getvalidvalue.inc.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/getvalidvalue.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ic2/getvalidvalue.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,63 +0,0 @@
-<?php
-/**
- * ImageCache2 - ƒŠƒNƒGƒXƒg•Ï”‚Ì‹¸³ƒ†[ƒeƒBƒŠƒeƒBŠÖ”
- */
-
-// {{{ getValidValue()
-
-/**
- * Submit‚³‚ꂽ’l‚ª‘Ó–‚È‚çiƒtƒBƒ‹ƒ^‚ð“K—p‚µ‚āj•Ô‚µA‚»‚¤‚Å‚È‚¯‚ê‚΃fƒtƒHƒ‹ƒg’l‚ð“K—p‚·‚é
- *
- * ƒ‰ƒWƒIƒ{ƒ^ƒ“‚âƒ`ƒFƒbƒNƒ{ƒbƒNƒXAHTML_QuickForm‚̃Oƒ‹[ƒv‚É‚Í”ñ‘Ήž
- * HTML_QuickForm‚ðŒp³‚µ‚½ƒNƒ‰ƒX‚̃ƒ\ƒbƒh‚Æ‚µ‚ÄŽÀ‘•‚·‚ׂ«
- */
-function getValidValue($key, $default, $filter = '')
-{
-    global $qf, $qfe;
-    $value = $qf->getSubmitValue($key);
-    if (is_null($value) || $qf->getElementError($key)) {
-        if ($qfe[$key]->getType() == 'select') {
-            $qfe[$key]->setSelected($default);
-        } else {
-            $qfe[$key]->setValue($default);
-        }
-        return $default;
-    }
-    return (strlen($filter) > 0) ? $filter($value) : $value;
-}
-
-// }}}
-// {{{ intoRange()
-
-/**
- * ”’l‚ðŽw’肳‚ꂽ”͈͂ɖ³—–‰Ÿ‚µž‚ß‚éŠÖ”
- */
-function intoRange($int)
-{
-    $a = func_get_args();
-    $r = array_map('intval', $a);
-    $g = func_num_args();
-    $int = $r[0];
-    switch ($g) {
-        case 1: return $int;
-        case 2: $min = 0; $max = $r[1]; break;
-        default: $min = $r[1]; $max = $r[2];
-    }
-    if ($min > $max) {
-        list($min, $max) = array($max, $min);
-    }
-    return max($min, min($max, intval($int)));
-}
-
-// }}}
-
-/*
- * 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:

Deleted: p2ex/trunk/lib/expack/ic2/loadconfig.inc.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/loadconfig.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ic2/loadconfig.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,54 +0,0 @@
-<?php
-/**
- * ImageCache2 - ƒ†[ƒUÝ’è“ǂݍž‚݊֐”
- */
-
-require_once 'DB/DataObject.php';
-
-// {{{ ic2_loadconfig()
-
-function ic2_loadconfig()
-{
-    static $ini = null;
-
-    if (is_null($ini)) {
-        include P2_CONF_DIR . '/conf_ic2.inc.php';
-
-        $ini = array();
-        $_ic2conf = preg_grep('/^expack\\.ic2\\.\\w+\\.\\w+$/', array_keys($_conf));
-        foreach ($_ic2conf as $key) {
-            $p = explode('.', $key);
-            $cat = ucfirst($p[2]);
-            $name = $p[3];
-            if (!isset($ini[$cat])) {
-                $ini[$cat] = array();
-            }
-            $ini[$cat][$name] = $_conf[$key];
-        }
-
-        // DB_DataObject‚̐ݒè
-        $_dao_options = &PEAR::getStaticProperty('DB_DataObject', 'options');
-        if (!is_array($_dao_options)) {
-            $_dao_options = array();
-        }
-        $_dao_options['database'] = $ini['General']['dsn'];
-        $_dao_options['debug'] = false;
-        $_dao_options['quote_identifiers'] = true;
-        $_dao_options['db_driver'] = 'DB';
-    }
-
-    return $ini;
-}
-
-// }}}
-
-/*
- * 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:

Deleted: p2ex/trunk/lib/expack/ic2/managedb.inc.php
===================================================================
--- p2ex/trunk/lib/expack/ic2/managedb.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/ic2/managedb.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -1,284 +0,0 @@
-<?php
-/**
- * ImageCache2 - ‰æ‘œî•ñ‚𑀍삷‚éŠÖ”
- */
-
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Common.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php';
-require_once P2EX_LIB_DIR . '/ic2/DataObject/BlackList.php';
-require_once P2EX_LIB_DIR . '/ic2/Thumbnailer.php';
-
-// {{{ manageDB_update()
-
-/**
- * ‰æ‘œî•ñ‚ðXV
- */
-function manageDB_update($updated)
-{
-    if (empty($updated)) {
-        return;
-    }
-    if (!is_array($updated)) {
-        global $_info_msg_ht;
-        $_info_msg_ht .= '<p>WARNING! manageDB_update(): •s³‚Ȉø”</p>';
-        return;
-    }
-
-    // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚ÌŠJŽn
-    $ta = new IC2_DataObject_Images;
-    $db = $ta->getDatabaseConnection();
-    if ($db->phptype == 'pgsql') {
-        $ta->query('BEGIN');
-    } elseif ($db->phptype == 'sqlite') {
-        $db->query('BEGIN;');
-    }
-
-    // ‰æ‘œƒf[ƒ^‚ðXV
-    foreach ($updated as $id => $data) {
-        $icdb = new IC2_DataObject_Images;
-        $icdb->whereAdd("id = $id");
-        if ($icdb->find(true)) {
-            // ƒƒ‚‚ðXV
-            if ($icdb->memo != $data['memo']) {
-                $memo = new IC2_DataObject_Images;
-                $memo->memo = (strlen($data['memo']) > 0) ? $data['memo'] : '';
-                $memo->whereAdd("id = $id");
-                $memo->update();
-            }
-            // ƒ‰ƒ“ƒN‚ðXV
-            if ($icdb->rank != $data['rank']) {
-                $rank = new IC2_DataObject_Images;
-                $rank->rank = $data['rank'];
-                $rank->whereAddQuoted('size', '=', $icdb->size);
-                $rank->whereAddQuoted('md5',  '=', $icdb->md5);
-                $rank->whereAddQuoted('mime', '=', $icdb->mime);
-                $rank->update();
-            }
-        }
-    }
-
-    // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚̃Rƒ~ƒbƒg
-    if ($db->phptype == 'pgsql') {
-        $ta->query('COMMIT');
-    } elseif ($db->phptype == 'sqlite') {
-        $db->query('COMMIT;');
-    }
-}
-
-// }}}
-// {{{ manageDB_remove()
-
-/**
- * ‰æ‘œ‚ðíœ
- */
-function manageDB_remove($target, $to_blacklist = false)
-{
-    $removed_files = array();
-    if (empty($target)) {
-        return $removed_files;
-    }
-    if (!is_array($target)) {
-        if (is_integer($target) || ctype_digit($target)) {
-            $id = (int) $target;
-            if ($id > 0) {
-                $target = array($id);
-            } else {
-                return $removed_files;
-            }
-        } else {
-            global $_info_msg_ht;
-            $_info_msg_ht .= '<p>WARNING! manageDB_remove(): •s³‚Ȉø”</p>';
-            return $removed_files;
-        }
-    }
-
-    // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚ÌŠJŽn
-    $ta = new IC2_DataObject_Images;
-    $db = $ta->getDatabaseConnection();
-    if ($db->phptype == 'pgsql') {
-        $ta->query('BEGIN');
-    } elseif ($db->phptype == 'sqlite') {
-        $db->query('BEGIN;');
-    }
-
-    // ‰æ‘œ‚ðíœ
-    foreach ($target as $id) {
-        $icdb = new IC2_DataObject_Images;
-        $icdb->whereAdd("id = {$id}");
-
-        if ($icdb->find(true)) {
-            // ƒLƒƒƒbƒVƒ…‚µ‚Ä‚¢‚éƒtƒ@ƒCƒ‹‚ðíœ
-            $t1 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_PC);
-            $t2 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_MOBILE);
-            $t3 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_INTERMD);
-            $srcPath = $t1->srcPath($icdb->size, $icdb->md5, $icdb->mime);
-            $t1Path = $t1->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
-            $t2Path = $t2->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
-            $t3Path = $t3->thumbPath($icdb->size, $icdb->md5, $icdb->mime);
-            if (file_exists($srcPath)) {
-                unlink($srcPath);
-                $removed_files[] = $srcPath;
-            }
-            if (file_exists($t1Path)) {
-                unlink($t1Path);
-                $removed_files[] = $t1Path;
-            }
-            if (file_exists($t2Path)) {
-                unlink($t2Path);
-                $removed_files[] = $t2Path;
-            }
-            if (file_exists($t3Path)) {
-                unlink($t3Path);
-                $removed_files[] = $t3Path;
-            }
-
-            // ƒuƒ‰ƒbƒNƒŠƒXƒg‘—‚è‚̏€”õ
-            if ($to_blacklist) {
-                $_blacklist = new IC2_DataObject_BlackList;
-                $_blacklist->size = $icdb->size;
-                $_blacklist->md5  = $icdb->md5;
-                if ($icdb->mime == 'clamscan/infected' || $icdb->rank == -4) {
-                    $_blacklist->type = 2;
-                } elseif ($icdb->rank < 0) {
-                    $_blacklist->type = 1;
-                } else {
-                    $_blacklist->type = 0;
-                }
-            }
-
-            // “¯ˆê‰æ‘œ‚ðŒŸõ
-            $remover = new IC2_DataObject_Images;
-            $remover->whereAddQuoted('size', '=', $icdb->size);
-            $remover->whereAddQuoted('md5',  '=', $icdb->md5);
-            //$remover->whereAddQuoted('mime', '=', $icdb->mime); // Size‚ÆMD5‚ŏ\•ª
-            $remover->find();
-            while ($remover->fetch()) {
-                // ƒuƒ‰ƒbƒNƒŠƒXƒg‘—‚è‚É‚·‚é
-                if ($to_blacklist) {
-                    $blacklist = clone $_blacklist;
-                    $blacklist->uri = $remover->uri;
-                    $blacklist->insert();
-                }
-                // ƒe[ƒuƒ‹‚©‚ç–•Á
-                $remover->delete();
-            }
-        }
-    }
-
-    // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚̃Rƒ~ƒbƒg
-    if ($db->phptype == 'pgsql') {
-        $ta->query('COMMIT');
-    } elseif ($db->phptype == 'sqlite') {
-        $db->query('COMMIT;');
-    }
-
-    return $removed_files;
-}
-
-// }}}
-// {{{ manageDB_setRank()
-
-/**
- * ƒ‰ƒ“ƒN‚ðÝ’è
- */
-function manageDB_setRank($target, $rank)
-{
-    if (empty($target)) {
-        return;
-    }
-    if (!is_array($target)) {
-        if (is_integer($updated) || ctype_digit($updated)) {
-            $id = (int)$updated;
-            if ($id > 0) {
-                $updated = array($id);
-            } else {
-                return;
-            }
-        } else {
-            global $_info_msg_ht;
-            $_info_msg_ht .= '<p>WARNING! manageDB_setRank(): •s³‚Ȉø”</p>';
-            return $removed_files;
-        }
-    }
-
-    $icdb = new IC2_DataObject_Images;
-    $icdb->rank = $rank;
-    foreach ($target as $id) {
-        $icdb->whereAdd("id = $id", 'OR');
-    }
-    $icdb->update();
-}
-
-// }}}
-// {{{ manageDB_addMemo()
-
-/**
- * ƒƒ‚‚ð’ljÁ
- */
-function manageDB_addMemo($target, $memo)
-{
-    if (empty($target)) {
-        return;
-    }
-    if (!is_array($target)) {
-        if (is_integer($updated) || ctype_digit($updated)) {
-            $id = (int)$updated;
-            if ($id > 0) {
-                $updated = array($id);
-            } else {
-                return;
-            }
-        } else {
-            global $_info_msg_ht;
-            $_info_msg_ht .= '<p>WARNING! manageDB_addMemo(): •s³‚Ȉø”</p>';
-            return $removed_files;
-        }
-    }
-
-    // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚ÌŠJŽn
-    $ta = new IC2_DataObject_Images;
-    $db = $ta->getDatabaseConnection();
-    if ($db->phptype == 'pgsql') {
-        $ta->query('BEGIN');
-    } elseif ($db->phptype == 'sqlite') {
-        $db->query('BEGIN;');
-    }
-
-    // ƒƒ‚‚ÉŽw’蕶Žš—ñ‚ªŠÜ‚Ü‚ê‚Ä‚¢‚È‚¯‚ê‚΍XV
-    foreach ($target as $id) {
-        $find = new IC2_DataObject_Images;
-        $find->whereAdd("id = $id");
-        if ($find->find(true) && strpos($find->memo, $memo) === false) {
-            $update = new IC2_DataObject_Images;
-            $update->whereAdd("id = $id");
-            if (strlen($find->memo) > 0) {
-                $update->memo = $find->memo . ' ' . $memo;
-            } else {
-                $update->memo = $memo;
-            }
-            $update->update();
-            unset($update);
-        }
-        unset($find);
-    }
-
-    // ƒgƒ‰ƒ“ƒUƒNƒVƒ‡ƒ“‚̃Rƒ~ƒbƒg
-    if ($db->phptype == 'pgsql') {
-        $ta->query('COMMIT');
-    } elseif ($db->phptype == 'sqlite') {
-        $db->query('COMMIT;');
-    }
-}
-
-// }}}
-
-/*
- * 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/expack/rss/getimage.inc.php
===================================================================
--- p2ex/trunk/lib/expack/rss/getimage.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/expack/rss/getimage.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -3,8 +3,7 @@
  * rep2expck - RSS‰æ‘œƒLƒƒƒbƒVƒ…
  */
 
-require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php';
-require_once P2EX_LIB_DIR . '/ic2/Thumbnailer.php';
+require_once P2EX_LIB_DIR . '/bootstrap.php';
 
 // {{{ rss_get_image()
 

Modified: p2ex/trunk/lib/menu.inc.php
===================================================================
--- p2ex/trunk/lib/menu.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/menu.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -332,8 +332,9 @@
 // ¡ImageCache2
 //==============================================================
 if ($_conf['expack.ic2.enabled']) {
-    require_once P2EX_LIB_DIR . '/ic2/Switch.php';
-
+    if (!class_exists('IC2_Switch', false)) {
+        include P2EX_LIB_DIR . '/ic2/Switch.php';
+    }
     if (IC2_Switch::get()) {
         $ic2sw = array('inline', 'none');
     } else {

Added: p2ex/trunk/lib/migrators/100113_1300.php
===================================================================
--- p2ex/trunk/lib/migrators/100113_1300.php	                        (rev 0)
+++ p2ex/trunk/lib/migrators/100113_1300.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,163 @@
+<?php
+/**
+ * rep2expack - ƒo[ƒWƒ‡ƒ“ƒAƒbƒvŽž‚̈ڍsŽx‰‡
+ */
+
+// {{{ p2_migrate_100113_1300()
+
+/**
+ * rev.100113.1300
+ *
+ * @param array $core_conf rep2ƒRƒA‚̐ݒè
+ * @param array $user_conf ŒÃ‚¢ƒ†[ƒU[Ý’è
+ * @return array V‚µ‚¢ƒ†[ƒU[Ý’è
+ */
+function p2_migrate_100113_1300(array $core_conf, array $user_conf)
+{
+    $data_dir   = $core_conf['data_dir'];
+    $db_dir     = $core_conf['db_dir'];
+    $cache_dir  = $core_conf['cache_dir'];
+    $cookie_dir = $core_conf['cookie_dir'];
+
+    // {{{ ƒzƒXƒgƒ`ƒFƒbƒN‚Ìgethostbyaddr()ƒLƒƒƒbƒVƒ…
+
+    $old_hostcheck_db = $cache_dir . '/hostcheck_gethostby.sq3';
+    $new_hostcheck_db = $core_conf['hostcheck_db_path'];
+
+    _100113_1300_rename_db($old_hostcheck_db, $new_hostcheck_db);
+    _100113_1300_rename_table($new_hostcheck_db, 'kvs_p2keyvaluestore', 'kvs_default');
+    _100113_1300_rename_table($new_hostcheck_db, 'kvs_keyvaluestore', 'kvs_default');
+
+    // }}}
+    // {{{ ŒöŽ®p2ƒNƒ‰ƒCƒAƒ“ƒg‚ÌCookieƒXƒgƒŒ[ƒW
+
+    $old_p2_cookie_db1 = $cookie_dir . '/p2_2ch_net_cookies.sqlite3';
+    $old_p2_cookie_db2 = $cookie_dir . '/p2_2ch_net_cookie.sq3';
+    $new_p2_cookie_db = $db_dir . '/p2_2ch_net_cookies.sqlite3';
+
+    _100113_1300_rename_db($old_p2_cookie_db1, $new_p2_cookie_db);
+    _100113_1300_rename_db($old_p2_cookie_db2, $new_p2_cookie_db);
+    _100113_1300_rename_table($new_p2_cookie_db, 'kvs_p2keyvaluestore_serializing', 'kvs_serializing');
+
+    // }}}
+    // {{{ “Še—pCookieƒXƒgƒŒ[ƒW
+
+    $old_cookie_db = $cookie_dir . '/p2_cookies.sqlite3';
+    $new_cookie_db = $core_conf['cookie_db_path'];
+
+    _100113_1300_rename_db($old_cookie_db, $new_cookie_db);
+    _100113_1300_rename_table($new_cookie_db, 'kvs_p2keyvaluestore_serializing', 'kvs_serializing');
+
+    // }}}
+    // {{{ ‘‚«ž‚݃f[ƒ^‚̃oƒbƒNƒAƒbƒvƒXƒgƒŒ[ƒW
+
+    $old_post_db = $cookie_dir . '/p2_post_data.sqlite3';
+    $new_post_db = $core_conf['post_db_path'];
+
+    _100113_1300_rename_db($old_post_db, $new_post_db);
+    _100113_1300_rename_table($new_post_db, 'kvs_p2keyvaluestore_serializing', 'kvs_serializing');
+
+    // }}}
+
+    return $user_conf;
+}
+
+// }}}
+// {{{ _100113_1300_rename_db
+
+/**
+ * SQLite3ƒf[ƒ^ƒx[ƒX‚ðƒŠƒl[ƒ€‚·‚é
+ *
+ * @param string $old_name
+ * @param string $new_name
+ * @return void
+ */
+function _100113_1300_rename_db($old_name, $new_name)
+{
+    if (DIRECTORY_SEPARATOR != '/') {
+        $old_name = str_replace('/', DIRECTORY_SEPARATOR, $old_name);
+        $new_name = str_replace('/', DIRECTORY_SEPARATOR, $new_name);
+    }
+
+    if ($old_name == $new_name) {
+        return;
+    }
+
+    if (file_exists($old_name)) {
+        if (file_exists($new_name)) {
+            unlink($old_name);
+        } else {
+            $dir = dirname($new_name);
+            if (!is_dir($dir)) {
+                mkdir($dir, 0777, true);
+            }
+            rename($old_name, $new_name);
+        }
+        clearstatcache();
+    }
+}
+
+// }}}
+// {{{ _100113_1300_rename_table
+
+/**
+ * SQLite3ƒe[ƒuƒ‹‚ðƒŠƒl[ƒ€‚·‚é
+ *
+ * @param string $database
+ * @param string $old_name
+ * @param string $new_name
+ * @return void
+ */
+function _100113_1300_rename_table($database, $old_name, $new_name)
+{
+    if (!file_exists($database) || $old_name == $new_name) {
+        return;
+    }
+
+    $pdo = new PDO('sqlite:' . realpath($database));
+    $tableChecker = $pdo->prepare('SELECT 1 FROM sqlite_master WHERE type = \'table\' AND name = :name LIMIT 1');
+
+    $tableChecker->bindValue(':name', $old_name);
+    $tableChecker->execute();
+    if ($tableChecker->fetchColumn()) {
+        $tableChecker->closeCursor();
+        $tableChecker->bindValue(':name', $new_name);
+        $tableChecker->execute();
+        if ($tableChecker->fetchColumn()) {
+            $tableChecker->closeCursor();
+            $query = 'DROP TABLE ' . _100113_1300_quote_identifier($old_name);
+        } else {
+            $query = 'ALTER TABLE ' . _100113_1300_quote_identifier($old_name)
+                   . ' RENAME TO ' . _100113_1300_quote_identifier($new_name);
+        }
+        unset($tableChecker);
+        $pdo->exec($query);
+    }
+}
+
+// }}}
+// {{{ _100113_1300_quote_identifier
+
+/**
+ * SQLite3ƒe[ƒuƒ‹–¼‚ðƒNƒH[ƒg‚·‚é
+ *
+ * @param string $identifier
+ * @return string
+ */
+function _100113_1300_quote_identifier($identifier)
+{
+    return '"' . str_replace('"', '""', $identifier) . '"';
+}
+
+// }}}
+
+/*
+ * 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/migrators/yymmdd_hhmm.php
===================================================================
--- p2ex/trunk/lib/migrators/yymmdd_hhmm.php	                        (rev 0)
+++ p2ex/trunk/lib/migrators/yymmdd_hhmm.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -0,0 +1,31 @@
+<?php
+/**
+ * rep2expack - ƒo[ƒWƒ‡ƒ“ƒAƒbƒvŽž‚̈ڍsŽx‰‡
+ */
+
+// {{{ p2_migrate_yymmdd_hhmm()
+
+/**
+ * yymmdd_hhmm ‚ðŽÀÛ‚̃o[ƒWƒ‡ƒ“”ԍ†‚É’uŠ·‚µ‚Ċ֐”‚Ì’†g‚ð‹Lq‚·‚é
+ *
+ * @param array $core_conf rep2ƒRƒA‚̐ݒè
+ * @param array $user_conf ŒÃ‚¢ƒ†[ƒU[Ý’è
+ * @return array V‚µ‚¢ƒ†[ƒU[Ý’è
+ */
+function p2_migrate_yymmdd_hhmm(array $core_conf, array $user_conf)
+{
+    return $user_conf;
+}
+
+// }}}
+
+/*
+ * 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/read_footer.inc.php
===================================================================
--- p2ex/trunk/lib/read_footer.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/read_footer.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -44,8 +44,6 @@
 }
 
 // ============================================================
-$sid_q = (defined('SID')) ? '&amp;'.strip_tags(SID) : '';
-
 if ($aThread->rescount or ($_GET['one'] && !$aThread->diedat)) { // and (!$_GET['renzokupop'])
 
     if (!$aThread->diedat) {
@@ -55,7 +53,7 @@
 EOP;
         } else {
             $htm['dores'] = <<<EOP
-<a href="post_form.php?host={$aThread->host}{$bbs_q}{$key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}" target="_self" onclick="return OpenSubWin('post_form.php?host={$aThread->host}{$bbs_q}{$key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}&amp;popup=1{$sid_q}',{$STYLE['post_pop_size']},1,0)"{$onmouse_showform_ht}>{$dores_st}</a>
+<a href="post_form.php?{$host_bbs_key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}" target="_self" onclick="return OpenSubWin('post_form.php?{$host_bbs_key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}&amp;popup=1',{$STYLE['post_pop_size']},1,0)"{$onmouse_showform_ht}>{$dores_st}</a>
 EOP;
         }
 
@@ -92,10 +90,10 @@
     // {{{ ƒtƒBƒ‹ƒ^ƒqƒbƒg‚ª‚ ‚Á‚½ê‡AŽŸX‚Æ‘±‚«‚ð“Ç‚Þ‚ðXV
     /*
     //if (!$read_navi_next_isInvisible) {
-    $read_navi_next = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->resrange['to']}-{$after_rnum}{$offline_range_q}&amp;nt={$newtime}{$read_navi_next_anchor}\">{$next_st}{$rnum_range}</a>";
+    $read_navi_next = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->resrange['to']}-{$after_rnum}{$offline_range_q}&amp;nt={$newtime}{$read_navi_next_anchor}\">{$next_st}{$rnum_range}</a>";
     //}
 
-    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->resrange['to']}-{$offline_q}\" accesskey=\"r\">{$tuduki_st}</a>";
+    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->resrange['to']}-{$offline_q}\" accesskey=\"r\">{$tuduki_st}</a>";
     */
 
     if (!empty($GLOBALS['last_hit_resnum'])) {
@@ -104,10 +102,10 @@
             $read_navi_next_anchor = "#r{$aThread->rescount}";
         }
         $after_rnum = $GLOBALS['last_hit_resnum'] + $rnum_range;
-        $read_navi_next = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$GLOBALS['last_hit_resnum']}-{$after_rnum}{$offline_range_q}&amp;nt={$newtime}{$read_navi_next_anchor}\">{$next_st}{$rnum_range}</a>";
+        $read_navi_next = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$GLOBALS['last_hit_resnum']}-{$after_rnum}{$offline_range_q}&amp;nt={$newtime}{$read_navi_next_anchor}\">{$next_st}{$rnum_range}</a>";
 
         // u‘±‚«‚ð“ǂށv
-        $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$GLOBALS['last_hit_resnum']}-{$offline_q}\" accesskey=\"r\">{$tuduki_st}</a>";
+        $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$GLOBALS['last_hit_resnum']}-{$offline_q}\" accesskey=\"r\">{$tuduki_st}</a>";
     }
     // }}}
 
@@ -118,10 +116,10 @@
     <tr>
         <td class="lblock">
             {$q_ichi}
-            <a href="{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls=all">{$all_st}</a>
+            <a href="{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls=all">{$all_st}</a>
             {$read_navi_previous}
             {$read_navi_next}
-            <a href="{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls=l{$latest_show_res_num}">{$latest_st}{$latest_show_res_num}</a>
+            <a href="{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls=l{$latest_show_res_num}">{$latest_st}{$latest_show_res_num}</a>
             {$htm['goto']}
             | {$read_footer_navi_new}
             | {$htm['dores']}

Modified: p2ex/trunk/lib/read_footer_k.inc.php
===================================================================
--- p2ex/trunk/lib/read_footer_k.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/read_footer_k.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -37,7 +37,7 @@
 EOP;
         } else {
             $dores_ht = <<<EOP
-<a href="post_form.php?host={$aThread->host}{$bbs_q}{$key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['res']}{$holdhandlers_at}>{$_conf['k_accesskey_st']['res']}{$dores_st}</a>
+<a href="post_form.php?{$host_bbs_key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['res']}{$holdhandlers_at}>{$_conf['k_accesskey_st']['res']}{$dores_st}</a>
 EOP;
         }
     } else {
@@ -92,7 +92,9 @@
 if ($_conf['iphone']) {
     // ImageCache2
     if ($_conf['expack.ic2.enabled']) {
-        require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
+        if (!function_exists('ic2_loadconfig')) {
+            include P2EX_LIB_DIR . '/ic2/bootstrap.php';
+        }
         $ic2conf = ic2_loadconfig();
         if ($ic2conf['Thumb1']['width'] > 80) {
             include P2EX_LIB_DIR . '/ic2/templates/info-v.tpl.html';

Modified: p2ex/trunk/lib/read_header.inc.php
===================================================================
--- p2ex/trunk/lib/read_header.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/read_header.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -4,30 +4,31 @@
  */
 
 // •Ï”
-$diedat_msg = "";
+$diedat_msg = '';
 
-$info_st        = "î•ñ";
-$delete_st      = "íœ";
-$all_st         = "‘S•”";
-$prev_st        = "‘O";
-$next_st        = "ŽŸ";
-$shinchaku_st   = "V’…ƒŒƒX‚Ì•\Ž¦";
-$midoku_st      = "–¢“ǃŒƒX‚Ì•\Ž¦";
-$tuduki_st      = "‘±‚«‚ð“Ç‚Þ";
-$moto_thre_st   = "Œ³ƒXƒŒ";
-$siml_thre_st   = "Ž—ƒXƒŒ"; // "—ÞŽ—ƒXƒŒ"
-$latest_st      = "ÅV";
-$dores_st       = "ƒŒƒX";
-$aborn_st       = "‚ ‚Ú‚ñ";
+$info_st        = 'î•ñ';
+$delete_st      = 'íœ';
+$all_st         = '‘S•”';
+$prev_st        = '‘O';
+$next_st        = 'ŽŸ';
+$shinchaku_st   = 'V’…ƒŒƒX‚Ì•\Ž¦';
+$midoku_st      = '–¢“ǃŒƒX‚Ì•\Ž¦';
+$tuduki_st      = '‘±‚«‚ð“Ç‚Þ';
+$moto_thre_st   = 'Œ³ƒXƒŒ';
+$siml_thre_st   = 'Ž—ƒXƒŒ'; // '—ÞŽ—ƒXƒŒ'
+$latest_st      = 'ÅV';
+$dores_st       = '‘ž'; // 'ƒŒƒX';
+$aborn_st       = '‚ ‚Ú‚ñ';
 
-$motothre_url = $aThread->getMotoThread();
+$motothre_url = $aThread->getMotoThread(false, '');
 $ttitle_en = base64_encode($aThread->ttitle);
 $ttitle_urlen = rawurlencode($ttitle_en);
-$ttitle_en_q = "&amp;ttitle_en=" . $ttitle_urlen;
-$bbs_q = "&amp;bbs=" . $aThread->bbs;
-$key_q = "&amp;key=" . $aThread->key;
-$popup_q = "&amp;popup=1";
-$offline_q = "&amp;offline=1";
+$ttitle_en_q = '&amp;ttitle_en=' . $ttitle_urlen;
+$bbs_q = '&amp;bbs=' . $aThread->bbs;
+$key_q = '&amp;key=' . $aThread->key;
+$host_bbs_key_q = 'host=' . $aThread->host . $bbs_q . $key_q;
+$popup_q = '&amp;popup=1';
+$offline_q = '&amp;offline=1';
 
 //=================================================================
 // ƒwƒbƒ_
@@ -37,17 +38,17 @@
 $rnum_range = 100;
 $latest_show_res_num = 50; // ÅVXX
 
-$read_navi_range = "";
+$read_navi_range = '';
 
 //----------------------------------------------
 // $read_navi_range -- 1- 101- 201-
 for ($i = 1; $i <= $aThread->rescount; $i = $i + $rnum_range) {
-    $offline_range_q = "";
+    $offline_range_q = '';
     $ito = $i + $rnum_range - 1;
     if ($ito <= $aThread->gotnum) {
         $offline_range_q = $offline_q;
     }
-    $read_navi_range = $read_navi_range . "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$i}-{$ito}{$offline_range_q}\">{$i}-</a>\n";
+    $read_navi_range = $read_navi_range . "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$i}-{$ito}{$offline_range_q}\">{$i}-</a>\n";
 
 }
 
@@ -67,8 +68,8 @@
 //}
 
 if (!$read_navi_previous_isInvisible) {
-    $read_navi_previous = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$before_rnum}-{$aThread->resrange['start']}{$offline_q}{$read_navi_previous_anchor}\">{$prev_st}{$rnum_range}</a>";
-    $read_navi_previous_header = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$before_rnum}-{$aThread->resrange['start']}{$offline_q}#r{$aThread->resrange['start']}\">{$prev_st}{$rnum_range}</a>";
+    $read_navi_previous = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$before_rnum}-{$aThread->resrange['start']}{$offline_q}{$read_navi_previous_anchor}\">{$prev_st}{$rnum_range}</a>";
+    $read_navi_previous_header = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$before_rnum}-{$aThread->resrange['start']}{$offline_q}#r{$aThread->resrange['start']}\">{$prev_st}{$rnum_range}</a>";
 } else {
     $read_navi_previous = '';
     $read_navi_previous_header = '';
@@ -90,22 +91,22 @@
 }
 $after_rnum = $aThread->resrange['to'] + $rnum_range;
 
-$offline_range_q = "";
+$offline_range_q = '';
 if ($after_rnum <= $aThread->gotnum) {
     $offline_range_q = $offline_q;
 }
 
 //if (!$read_navi_next_isInvisible) {
-$read_navi_next = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->resrange['to']}-{$after_rnum}{$offline_range_q}&amp;nt={$newtime}{$read_navi_next_anchor}\">{$next_st}{$rnum_range}</a>";
+$read_navi_next = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->resrange['to']}-{$after_rnum}{$offline_range_q}&amp;nt={$newtime}{$read_navi_next_anchor}\">{$next_st}{$rnum_range}</a>";
 //}
 
 //----------------------------------------------
 // $read_footer_navi_new  ‘±‚«‚ð“Ç‚Þ V’…ƒŒƒX‚Ì•\Ž¦
 
 if ($aThread->resrange['to'] == $aThread->rescount) {
-    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->rescount}-&amp;nt={$newtime}#r{$aThread->rescount}\" accesskey=\"r\">{$shinchaku_st}</a>";
+    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->rescount}-&amp;nt={$newtime}#r{$aThread->rescount}\" accesskey=\"r\">{$shinchaku_st}</a>";
 } else {
-    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->resrange['to']}-{$offline_q}\" accesskey=\"r\">{$tuduki_st}</a>";
+    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->resrange['to']}-{$offline_q}\" accesskey=\"r\">{$tuduki_st}</a>";
 }
 
 
@@ -124,8 +125,6 @@
 //====================================================================
 // HTMLƒvƒŠƒ“ƒg
 //====================================================================
-$sid_q = (defined('SID')) ? '&amp;'.strip_tags(SID) : '';
-
 // ƒc[ƒ‹ƒo[•”•ªHTML =======
 
 // ‚¨‹C‚Ƀ}[ƒNÝ’è
@@ -141,7 +140,7 @@
     $favtitle = ((!isset($favlist_titles[0]) || $favlist_titles[0] == '') ? '‚¨‹C‚ɃXƒŒ' : $favlist_titles[0]) . ($favdo ? '‚ɒljÁ' : '‚©‚çŠO‚·');
     $setnum_q = '&amp;setnum=0';
     $toolbar_setfav_ht .= <<<EOP
-<span class="favdo set0"><a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$favdo_q}{$setnum_q}{$sid_q}" target="info" onclick="return setFavJs('host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$sid_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read', this, '0');" title="{$favtitle}">{$favmark}</a></span>
+<span class="favdo set0"><a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$favdo_q}{$setnum_q}" target="info" onclick="return setFavJs('{$host_bbs_key_q}{$ttitle_en_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read', this, '0');" title="{$favtitle}">{$favmark}</a></span>
 EOP;
     for ($i = 1; $i <= $_conf['expack.misc.favset_num']; $i++) {
         $favdo = (!empty($aThread->favs[$i])) ? 0 : 1;
@@ -150,7 +149,7 @@
         $favtitle = ((!isset($favlist_titles[$i]) || $favlist_titles[$i] == '') ? '‚¨‹C‚ɃXƒŒ' . $i : $favlist_titles[$i]) . ($favdo ? '‚ɒljÁ' : '‚©‚çŠO‚·');
         $setnum_q = '&amp;setnum=' . $i;
         $toolbar_setfav_ht .= <<<EOP
-|<span class="favdo set{$i}"><a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$favdo_q}{$setnum_q}{$sid_q}" target="info" onclick="return setFavJs('host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$sid_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read', this, '{$i}');" title="{$favtitle}">{$favmark}</a></span>
+|<span class="favdo set{$i}"><a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$favdo_q}{$setnum_q}" target="info" onclick="return setFavJs('{$host_bbs_key_q}{$ttitle_en_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read', this, '{$i}');" title="{$favtitle}">{$favmark}</a></span>
 EOP;
     }
     $toolbar_setfav_ht .= ']';
@@ -160,18 +159,18 @@
     $favmark = $favdo ? '+' : 'š';
     $favtitle = $favdo ? '‚¨‹C‚ɃXƒŒ‚ɒljÁ' : '‚¨‹C‚ɃXƒŒ‚©‚çŠO‚·';
     $toolbar_setfav_ht = <<<EOP
-<span class="favdo"><a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$favdo_q}{$sid_q}" target="info" onclick="return setFavJs('host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$sid_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read', this);" title="{$favtitle}">‚¨‹C‚É{$favmark}</a></span>
+<span class="favdo"><a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$favdo_q}" target="info" onclick="return setFavJs('{$host_bbs_key_q}{$ttitle_en_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read', this);" title="{$favtitle}">‚¨‹C‚É{$favmark}</a></span>
 EOP;
 }
 
 $toolbar_right_ht = <<<EOTOOLBAR
-            <a href="{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$key_q}" target="subject" title="”‚ðŠJ‚­">{$itaj_hd}</a>
-            <a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}" target="info" onclick="return OpenSubWin('info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$popup_q}{$sid_q}',{$STYLE['info_pop_size']},0,0)" title="ƒXƒŒƒbƒhî•ñ‚ð•\Ž¦">{$info_st}</a>
+            <a href="{$_conf['subject_php']}?{$host_bbs_key_q}" target="subject" title="”‚ðŠJ‚­">{$itaj_hd}</a>
+            <a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}" target="info" onclick="return OpenSubWin('info.php?{$host_bbs_key_q}{$ttitle_en_q}{$popup_q}',{$STYLE['info_pop_size']},0,0)" title="ƒXƒŒƒbƒhî•ñ‚ð•\Ž¦">{$info_st}</a>
             {$toolbar_setfav_ht}
-            <span><a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}&amp;dele=true" target="info" onclick="return deleLog('host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$sid_q}', {$STYLE['info_pop_size']}, 'read', this);" title="ƒƒO‚ðíœ‚·‚é">{$delete_st}</a></span>
-<!--            <a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}&amp;taborn=2" target="info" onclick="return OpenSubWin('info.php?host={$aThread->host}{$bbs_q}&amp;key={$aThread->key}{$ttitle_en_q}&amp;popup=2&amp;taborn=2{$sid_q}',{$STYLE['info_pop_size']},0,0)" title="ƒXƒŒƒbƒh‚Ì‚ ‚ځ[‚ñó‘Ô‚ðƒgƒOƒ‹‚·‚é">{$aborn_st}</a> -->
-            <a href="{$motothre_url}" title="”ƒT[ƒoã‚̃IƒŠƒWƒiƒ‹ƒXƒŒ‚ð•\Ž¦">{$moto_thre_st}</a>
-            <a href="{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$key_q}{$similar_q}" target="subject" title="ƒ^ƒCƒgƒ‹‚ªŽ—‚Ä‚¢‚éƒXƒŒƒbƒh‚ðŒŸõ">{$siml_thre_st}</a>
+            <span><a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}&amp;dele=true" target="info" onclick="return deleLog('{$host_bbs_key_q}{$ttitle_en_q}', {$STYLE['info_pop_size']}, 'read', this);" title="ƒƒO‚ðíœ‚·‚é">{$delete_st}</a></span>
+<!--            <a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}&amp;taborn=2" target="info" onclick="return OpenSubWin('info.php?{$host_bbs_key_q}{$ttitle_en_q}&amp;popup=2&amp;taborn=2',{$STYLE['info_pop_size']},0,0)" title="ƒXƒŒƒbƒh‚Ì‚ ‚ځ[‚ñó‘Ô‚ðƒgƒOƒ‹‚·‚é">{$aborn_st}</a> -->
+            <a href="{$motothre_url}" title="”ƒT[ƒoã‚̃IƒŠƒWƒiƒ‹ƒXƒŒ‚ð•\Ž¦" onmouseover="showMotoLsPopUp(event, this)" onmouseout="hideMotoLsPopUp()">{$moto_thre_st}</a>
+            <a href="{$_conf['subject_php']}?{$host_bbs_key_q}{$similar_q}" target="subject" title="ƒ^ƒCƒgƒ‹‚ªŽ—‚Ä‚¢‚éƒXƒŒƒbƒh‚ðŒŸõ">{$siml_thre_st}</a>
 EOTOOLBAR;
 
 //=====================================
@@ -191,6 +190,7 @@
     <script type="text/javascript" src="js/basic.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/respopup.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/htmlpopup.js?{$_conf['p2_version_id']}"></script>
+    <script type="text/javascript" src="js/motolspopup.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/ngabornctl.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/setfavjs.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/delelog.js?{$_conf['p2_version_id']}"></script>\n
@@ -275,7 +275,7 @@
 EOP;
 
 echo $_info_msg_ht;
-$_info_msg_ht = "";
+$_info_msg_ht = '';
 
 // ƒXƒŒ‚ª”ƒT[ƒo‚É‚È‚¯‚ê‚Î ============================
 if ($aThread->diedat) {
@@ -405,10 +405,10 @@
 <table{$id_header} class="toolbar">
     <tr>
         <td class="lblock">
-            <a href="{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls=all">{$all_st}</a>
+            <a href="{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls=all">{$all_st}</a>
             {$read_navi_range}
             {$read_navi_previous_header}
-            <a href="{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls=l{$latest_show_res_num}">{$latest_st}{$latest_show_res_num}</a> {$htm['goto']}
+            <a href="{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls=l{$latest_show_res_num}">{$latest_st}{$latest_show_res_num}</a> {$htm['goto']}
         </td>
         <td class="rblock">{$htm['p2frame']} {$toolbar_right_ht}</td>
         <td class="rblock"><a href="#footer">¥</a></td>

Modified: p2ex/trunk/lib/read_header_k.inc.php
===================================================================
--- p2ex/trunk/lib/read_header_k.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/read_header_k.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -17,11 +17,12 @@
 $dores_st = '攴';
 $find_st = 'õ';
 
-$motothre_url = $aThread->getMotoThread();
+$motothre_url = $aThread->getMotoThread(false, '1-10');
 $ttitle_en = rawurlencode(base64_encode($aThread->ttitle));
 $ttitle_en_q = '&amp;ttitle_en=' . $ttitle_en;
 $bbs_q = '&amp;bbs=' . $aThread->bbs;
 $key_q = '&amp;key=' . $aThread->key;
+$host_bbs_key_q = 'host=' . $aThread->host . $bbs_q . $key_q;
 $offline_q = '&amp;offline=1';
 
 $do_filtering = (isset($GLOBALS['word']) && strlen($GLOBALS['word']) > 0);
@@ -60,7 +61,7 @@
 //----------------------------------------------
 // $htm['read_navi_range'] -- 1- 101- 201-
 
-$htm['read_navi_range'] = "<a{$pointer_header_at} href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls=1-{$rnum_range}{$offline_range_q}{$_conf['k_at_a']}\"{$_conf['k_accesskey_at'][1]}>1-</a>\t";
+$htm['read_navi_range'] = "<a{$pointer_header_at} href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls=1-{$rnum_range}{$offline_range_q}{$_conf['k_at_a']}\"{$_conf['k_accesskey_at'][1]}>1-</a>\t";
 
 
 //----------------------------------------------
@@ -79,8 +80,8 @@
 //}
 
 if (!$read_navi_previous_isInvisible) {
-    $read_navi_previous = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$before_rnum}-{$aThread->resrange['start']}n{$offline_q}{$_conf['k_at_a']}{$read_navi_previous_anchor}\">{$prev_st}</a>";
-    $read_navi_previous_btm = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$before_rnum}-{$aThread->resrange['start']}n{$offline_q}{$_conf['k_at_a']}{$read_navi_previous_anchor}\"{$_conf['k_accesskey_at']['prev']}>{$_conf['k_accesskey_st']['prev']}{$prev_st}</a>";
+    $read_navi_previous = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$before_rnum}-{$aThread->resrange['start']}n{$offline_q}{$_conf['k_at_a']}{$read_navi_previous_anchor}\">{$prev_st}</a>";
+    $read_navi_previous_btm = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$before_rnum}-{$aThread->resrange['start']}n{$offline_q}{$_conf['k_at_a']}{$read_navi_previous_anchor}\"{$_conf['k_accesskey_at']['prev']}>{$_conf['k_accesskey_st']['prev']}{$prev_st}</a>";
 }
 
 //----------------------------------------------
@@ -103,35 +104,35 @@
 $after_rnum = $aThread->resrange['to'] + $rnum_range;
 
 if (!$read_navi_next_isInvisible) {
-    $read_navi_next = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->resrange['to']}-{$after_rnum}n{$offline_q}&amp;nt={$newtime}{$_conf['k_at_a']}{$read_navi_next_anchor}\">{$next_st}</a>";
-    $read_navi_next_btm = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->resrange['to']}-{$after_rnum}n{$offline_q}&amp;nt={$newtime}{$_conf['k_at_a']}{$read_navi_next_anchor}\"{$_conf['k_accesskey_at']['next']}>{$_conf['k_accesskey_st']['next']}{$next_st}</a>";
+    $read_navi_next = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->resrange['to']}-{$after_rnum}n{$offline_q}&amp;nt={$newtime}{$_conf['k_at_a']}{$read_navi_next_anchor}\">{$next_st}</a>";
+    $read_navi_next_btm = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->resrange['to']}-{$after_rnum}n{$offline_q}&amp;nt={$newtime}{$_conf['k_at_a']}{$read_navi_next_anchor}\"{$_conf['k_accesskey_at']['next']}>{$_conf['k_accesskey_st']['next']}{$next_st}</a>";
 }
 
 //----------------------------------------------
 // $read_footer_navi_new  ‘±‚«‚ð“Ç‚Þ V’…ƒŒƒX‚Ì•\Ž¦
 
 if ($aThread->resrange['to'] == $aThread->rescount) {
-    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->rescount}-n&amp;nt={$newtime}{$_conf['k_at_a']}#r{$aThread->rescount}\">{$shinchaku_st}</a>";
-    $read_footer_navi_new_btm = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->rescount}-n&amp;nt={$newtime}{$_conf['k_at_a']}#r{$aThread->rescount}\"{$_conf['k_accesskey_at']['next']}>{$_conf['k_accesskey_st']['next']}{$shinchaku_st}</a>";
+    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->rescount}-n&amp;nt={$newtime}{$_conf['k_at_a']}#r{$aThread->rescount}\">{$shinchaku_st}</a>";
+    $read_footer_navi_new_btm = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->rescount}-n&amp;nt={$newtime}{$_conf['k_at_a']}#r{$aThread->rescount}\"{$_conf['k_accesskey_at']['next']}>{$_conf['k_accesskey_st']['next']}{$shinchaku_st}</a>";
 }
 
 if (!$read_navi_next_isInvisible) {
     $read_navi_latest = <<<EOP
-<a href="{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls=l{$latest_show_res_num}{$_conf['k_at_a']}">{$latest_st}{$latest_show_res_num}</a>
+<a href="{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls=l{$latest_show_res_num}{$_conf['k_at_a']}">{$latest_st}{$latest_show_res_num}</a>
 EOP;
     $time = time();
     $read_navi_latest_btm = <<<EOP
-<a href="{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls=l{$latest_show_res_num}&amp;dummy={$time}{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['latest']}>{$_conf['k_accesskey_st']['latest']}{$latest_st}{$latest_show_res_num}</a>
+<a href="{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls=l{$latest_show_res_num}&amp;dummy={$time}{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['latest']}>{$_conf['k_accesskey_st']['latest']}{$latest_st}{$latest_show_res_num}</a>
 EOP;
 }
 
 // {{{ ŒŸõ
 
 $read_navi_filter = <<<EOP
-<a href="read_filter_k.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$_conf['k_at_a']}">{$find_st}</a>
+<a href="read_filter_k.php?{$host_bbs_key_q}{$ttitle_en_q}{$_conf['k_at_a']}">{$find_st}</a>
 EOP;
 $read_navi_filter_btm = <<<EOP
-<a href="read_filter_k.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['filter']}>{$_conf['k_accesskey_st']['filter']}{$find_st}</a>
+<a href="read_filter_k.php?{$host_bbs_key_q}{$ttitle_en_q}{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['filter']}>{$_conf['k_accesskey_st']['filter']}{$find_st}</a>
 EOP;
 
 // }}}
@@ -191,11 +192,11 @@
 $similar_q = '&amp;itaj_en=' . rawurlencode(base64_encode($aThread->itaj)) . '&amp;method=similar&amp;word=' . rawurlencode($aThread->ttitle_hc) . '&amp;refresh=1';
 $itaj_hd = htmlspecialchars($aThread->itaj, ENT_QUOTES);
 $toolbar_right_ht = <<<EOTOOLBAR
-<a href="{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$key_q}{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['up']}>{$_conf['k_accesskey_st']['up']}{$itaj_hd}</a>
-<a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['info']}>{$_conf['k_accesskey_st']['info']}{$info_st}</a>
-<a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}&amp;dele=1{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['dele']}>{$_conf['k_accesskey_st']['dele']}{$delete_st}</a>
+<a href="{$_conf['subject_php']}?{$host_bbs_key_q}{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['up']}>{$_conf['k_accesskey_st']['up']}{$itaj_hd}</a>
+<a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['info']}>{$_conf['k_accesskey_st']['info']}{$info_st}</a>
+<a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}&amp;dele=1{$_conf['k_at_a']}"{$_conf['k_accesskey_at']['dele']}>{$_conf['k_accesskey_st']['dele']}{$delete_st}</a>
 <a href="{$motothre_url}" target="_blank">{$moto_thre_st}</a>
-<a href="{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$key_q}{$similar_q}{$_conf['k_at_a']}">{$siml_thre_st}</a>
+<a href="{$_conf['subject_php']}?{$host_bbs_key_q}{$similar_q}{$_conf['k_at_a']}">{$siml_thre_st}</a>
 EOTOOLBAR;
 // }}}
 

Modified: p2ex/trunk/lib/sb_footer.inc.php
===================================================================
--- p2ex/trunk/lib/sb_footer.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/sb_footer.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -4,8 +4,8 @@
  * for subject.php
  */
 
-$bbs_q = "&amp;bbs=".$aThreadList->bbs;
-$sid_q = (defined('SID')) ? '&amp;'.strip_tags(SID) : '';
+$bbs_q = '&amp;bbs=' . $aThreadList->bbs;
+$host_bbs_q = 'host=' . $aThreadList->host . $bbs_q;
 
 $have_sb_footer_links = false;
 
@@ -14,7 +14,7 @@
 $dat_soko_ht = '';
 if(!$aThreadList->spmode or $aThreadList->spmode=="taborn"){
     $dat_soko_ht =<<<EOP
-    <a href="{$_conf['subject_php']}?host={$aThreadList->host}{$bbs_q}{$norefresh_q}&amp;spmode=soko" target="_self">dat‘qŒÉ</a> |
+    <a href="{$_conf['subject_php']}?{$host_bbs_q}{$norefresh_q}&amp;spmode=soko" target="_self">dat‘qŒÉ</a> |
 EOP;
     $have_sb_footer_links = true;
 }
@@ -23,7 +23,7 @@
 $taborn_link_ht = '';
 if ($ta_num) {
     $taborn_link_ht = <<<EOP
-    <a href="{$_conf['subject_php']}?host={$aThreadList->host}{$bbs_q}{$norefresh_q}&amp;spmode=taborn" target="_self">‚ ‚ځ[‚ñ’†‚̃XƒŒƒbƒh (<span id="ta_num">{$ta_num}</span>)</a> |
+    <a href="{$_conf['subject_php']}?{$host_bbs_q}{$norefresh_q}&amp;spmode=taborn" target="_self">‚ ‚ځ[‚ñ’†‚̃XƒŒƒbƒh (<span id="ta_num">{$ta_num}</span>)</a> |
 EOP;
     $have_sb_footer_links = true;
 }
@@ -42,10 +42,10 @@
 $import_dat_ht = '';
 if (!$aThreadList->spmode) {
     $buildnewthread_ht = <<<EOP
-    <a href="post_form.php?host={$aThreadList->host}{$bbs_q}&amp;newthread=true" target="_self" onclick="return OpenSubWin('post_form.php?host={$aThreadList->host}{$bbs_q}&amp;newthread=true&amp;popup=1{$sid_q}',{$STYLE['post_pop_size']},1,0)">V‹KƒXƒŒƒbƒhì¬</a>
+    <a href="post_form.php?{$host_bbs_q}&amp;newthread=true" target="_self" onclick="return OpenSubWin('post_form.php?{$host_bbs_q}&amp;newthread=true&amp;popup=1',{$STYLE['post_pop_size']},1,0)">V‹KƒXƒŒƒbƒhì¬</a>
 EOP;
     $import_dat_ht = <<<EOP
- | <a href="import.php?host={$aThreadList->host}{$bbs_q}" onclick="return OpenSubWin('import.php?host={$aThreadList->host}{$bbs_q}', 600, 380, 0, 0);" target="_self">dat‚̃Cƒ“ƒ|[ƒg</a>
+ | <a href="import.php?{$host_bbs_q}" onclick="return OpenSubWin('import.php?{$host_bbs_q}', 600, 380, 0, 0);" target="_self">dat‚̃Cƒ“ƒ|[ƒg</a>
 EOP;
     $have_sb_footer_links = true;
 }

Modified: p2ex/trunk/lib/sb_footer_k.inc.php
===================================================================
--- p2ex/trunk/lib/sb_footer_k.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/sb_footer_k.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -7,9 +7,10 @@
 //=================================================
 //ƒtƒbƒ^ƒvƒŠƒ“ƒg
 //=================================================
-$mae_ht = "";
-$tugi_ht = "";
-$bbs_q = "&amp;bbs=".$aThreadList->bbs;
+$mae_ht = '';
+$tugi_ht = '';
+$bbs_q = '&amp;bbs=' . $aThreadList->bbs;
+$host_bbs_q = 'host=' . $aThreadList->host . $bbs_q;
 
 if (!empty($GLOBALS['wakati_words'])) {
     $word_at = '&amp;method=similar&amp;word=' . rawurlencode($GLOBALS['wakati_word']);
@@ -166,7 +167,7 @@
 // ƒXƒyƒVƒƒƒ‹ƒ‚[ƒh‚Å‚È‚¯‚ê‚΁A‚Ü‚½‚Í‚ ‚ځ[‚ñƒŠƒXƒg‚È‚ç
 if (!$aThreadList->spmode or $aThreadList->spmode == "taborn") {
     $dat_soko_ht = <<<EOP
- <a href="{$_conf['subject_php']}?host={$aThreadList->host}{$bbs_q}{$norefresh_q}&amp;spmode=soko{$_conf['k_at_a']}">dat‘qŒÉ</a>
+ <a href="{$_conf['subject_php']}?{$host_bbs_q}{$norefresh_q}&amp;spmode=soko{$_conf['k_at_a']}">dat‘qŒÉ</a>
 EOP;
 } else {
     $dat_soko_ht = '';
@@ -177,7 +178,7 @@
 
 if ($ta_num) {
     $taborn_link_ht = <<<EOP
- <a href="{$_conf['subject_php']}?host={$aThreadList->host}{$bbs_q}{$norefresh_q}&amp;spmode=taborn{$_conf['k_at_a']}">±ÎÞÝ’†({$ta_num})</a>
+ <a href="{$_conf['subject_php']}?{$host_bbs_q}{$norefresh_q}&amp;spmode=taborn{$_conf['k_at_a']}">±ÎÞÝ’†({$ta_num})</a>
 EOP;
 } else {
     $taborn_link_ht = '';
@@ -188,7 +189,7 @@
 
 if (!$aThreadList->spmode) {
     $buildnewthread_ht = <<<EOP
- <a href="post_form.php?host={$aThreadList->host}{$bbs_q}&amp;newthread=1{$_conf['k_at_a']}">½Ú—§‚Ä</a>
+ <a href="post_form.php?{$host_bbs_q}&amp;newthread=1{$_conf['k_at_a']}">½Ú—§‚Ä</a>
 EOP;
 } else {
     $buildnewthread_ht = '';

Modified: p2ex/trunk/lib/sb_header.inc.php
===================================================================
--- p2ex/trunk/lib/sb_header.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/sb_header.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -156,7 +156,7 @@
 EOP;
 
 $filter_form_ht = <<<EOP
-        <form class="toolbar" method="GET" action="subject.php" accept-charset="{$_conf['accept_charset']}" target="_self">
+        <form class="toolbar" method="GET" action="{$_conf['subject_php']}" accept-charset="{$_conf['accept_charset']}" target="_self">
             {$sb_form_hidden_ht}
             <input type="text" name="word" value="{$hd['word']}" size="16">{$sb_form_method_ht}
             {$input_find_cont_ht}
@@ -212,6 +212,8 @@
     <script type="text/javascript" src="js/setfavjs.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/settabornjs.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/delelog.js?{$_conf['p2_version_id']}"></script>
+    <script type="text/javascript" src="js/respopup.js?{$_conf['p2_version_id']}"></script>
+    <script type="text/javascript" src="js/motolspopup.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/jquery.pack.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript">
     //<![CDATA[
@@ -329,7 +331,7 @@
 include P2_LIB_DIR . '/sb_toolbar.inc.php';
 
 echo $_info_msg_ht;
-$_info_msg_ht = "";
+$_info_msg_ht = '';
 
 echo <<<EOP
 {$taborn_check_ht}{$check_form_ht}

Modified: p2ex/trunk/lib/sb_print.inc.php
===================================================================
--- p2ex/trunk/lib/sb_print.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/sb_print.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -109,6 +109,12 @@
 
     $sortq_common = $sortq_spmode . $sortq_host . $sortq_ita;
 
+    if (!empty($_REQUEST['find_cont']) && strlen($GLOBALS['word_fm']) > 0) {
+        $word_q = '&amp;word=' . rawurlencode($GLOBALS['word']) . '&amp;method=' . rawurlencode($GLOBALS['sb_filter']['method']);
+    } else {
+        $word_q = '';
+    }
+
     //=====================================================
     // ƒe[ƒuƒ‹ƒwƒbƒ_
     //=====================================================
@@ -196,13 +202,6 @@
     } else {
         $spmode_q = '';
     }
-    $sid = defined('SID') ? strip_tags(SID) : '';
-    if ($sid === '') {
-        $sid_q = $sid_js = '';
-    } else {
-        $sid_q = "&amp;{$sid}";
-        $sid_js = "+'{$sid_q}'";
-    }
 
     $i = 0;
     foreach ($aThreadList->threads as $aThread) {
@@ -210,7 +209,7 @@
         $midoku_ari = false;
         $anum_ht = ''; // #r1
 
-        $base_q = "host={$aThread->host}&amp;bbs={$aThread->bbs}&amp;key={$aThread->key}";
+        $host_bbs_key_q = "host={$aThread->host}&amp;bbs={$aThread->bbs}&amp;key={$aThread->key}";
 
         if ($aThreadList->spmode != 'taborn') {
             if (!$aThread->torder) { $aThread->torder = $i; }
@@ -230,7 +229,7 @@
             $row_class .= ' r_read'; // read‚͉ߋŽ•ªŽŒ
 
             // $ttitle_en_q ‚͐ߌ¸È—ª
-            $delelog_js = "return wrapDeleLog('{$base_q}{$sid_q}',this);";
+            $delelog_js = "return wrapDeleLog('{$host_bbs_key_q}',this);";
             $title_at = ' title="ƒNƒŠƒbƒN‚·‚é‚ƃƒOíœ"';
 
             $anum_ht = sprintf('#r%d', min($aThread->rescount, $aThread->rescount - $aThread->nunum + 1 - $_conf['respointer']));
@@ -240,7 +239,7 @@
                 $row_class .= ' r_offline';
                 // JavaScript‚Å‚ÌŠm”Fƒ_ƒCƒAƒƒO‚ ‚è
                 $unum_ht_c = <<<EOP
-<a class="un_n" href="{$_conf['subject_php']}?{$base_q}{$spmode_q}&amp;dele=true" target="_self" onclick="if (!window.confirm('ƒƒO‚ðíœ‚µ‚Ü‚·‚©H')) {return false;} {$delelog_js}"{$title_at}>-</a>
+<a class="un_n" href="{$_conf['subject_php']}?{$host_bbs_key_q}{$spmode_q}&amp;dele=true" target="_self" onclick="if (!window.confirm('ƒƒO‚ðíœ‚µ‚Ü‚·‚©H')) {return false;} {$delelog_js}"{$title_at}>-</a>
 EOP;
 
             // V’…‚ ‚è
@@ -248,13 +247,13 @@
                 $row_class .= ' r_new';
                 $midoku_ari = true;
                 $unum_ht_c = <<<EOP
-<a id="un{$i}" class="un_a" href="{$_conf['subject_php']}?{$base_q}{$spmode_q}&amp;dele=true" target="_self" onclick="{$delelog_js}"{$title_at}>{$aThread->unum}</a>
+<a id="un{$i}" class="un_a" href="{$_conf['subject_php']}?{$host_bbs_key_q}{$spmode_q}&amp;dele=true" target="_self" onclick="{$delelog_js}"{$title_at}>{$aThread->unum}</a>
 EOP;
 
             // subject.txt‚É‚Í‚ ‚邪AV’…‚È‚µ
             } else {
                 $unum_ht_c = <<<EOP
-<a class="un" href="{$_conf['subject_php']}?{$base_q}{$spmode_q}&amp;dele=true" target="_self" onclick="{$delelog_js}"{$title_at}>{$aThread->unum}</a>
+<a class="un" href="{$_conf['subject_php']}?{$host_bbs_key_q}{$spmode_q}&amp;dele=true" target="_self" onclick="{$delelog_js}"{$title_at}>{$aThread->unum}</a>
 EOP;
             }
         }
@@ -284,7 +283,7 @@
 
                 // $ttitle_en_q ‚à•t‚¯‚½•û‚ª‚¢‚¢‚ªAß–ñ‚Ì‚½‚ߏȗª‚·‚é
                 $td['fav'] = <<<EOP
-<td{$class_t}><a class="fav" href="info.php?{$base_q}{$favdo_q}" target="info" onclick="return wrapSetFavJs('{$base_q}','{$favdo}',this);" title="{$favtitle}">{$favmark}</a></td>\n
+<td{$class_t}><a class="fav" href="info.php?{$host_bbs_key_q}{$favdo_q}" target="info" onclick="return wrapSetFavJs('{$host_bbs_key_q}','{$favdo}',this);" title="{$favtitle}">{$favmark}</a></td>\n
 EOP;
             }
         }
@@ -297,7 +296,7 @@
             $torder_st = $aThread->torder;
         }
         $torder_ht = <<<EOP
-<a id="to{$i}" class="info" href="info.php?{$base_q}" target="_self" onclick="return wrapOpenSubWin(this.href.toString(){$sid_js})">{$torder_st}</a>
+<a id="to{$i}" class="info" href="info.php?{$host_bbs_key_q}" target="_self" onclick="return wrapOpenSubWin(this.href.toString())">{$torder_st}</a>
 EOP;
 
         // title =================================================
@@ -326,10 +325,14 @@
         }
 
         // Œ³ƒXƒŒ
-        $moto_thre_ht = "";
+        $moto_thre_ht = '';
         if ($_conf['sb_show_motothre']) {
             if (!$aThread->isKitoku()) {
-                $moto_thre_ht = '<a class="thre_title" href="' . htmlspecialchars($aThread->getMotoThread()) . '">E</a> ';
+                $moto_thre_ht = '<a class="thre_title moto_thre" href="'
+                              . htmlspecialchars($aThread->getMotoThread(false, ''), ENT_QUOTES)
+                              . '"'
+                              . ' onmouseover="showMotoLsPopUp(event, this, this.nextSibling.innerText)"'
+                              . ' onmouseout="hideMotoLsPopUp()">E</a>';
             }
         }
 
@@ -342,24 +345,20 @@
         }
 
         // ƒXƒŒƒŠƒ“ƒN
-        if (!empty($_REQUEST['find_cont']) && strlen($GLOBALS['word_fm']) > 0) {
-            $word_q = '&amp;word=' . rawurlencode($GLOBALS['word']) . '&amp;method=' . rawurlencode($GLOBALS['sb_filter']['method']);
+        if ($word_q) {
             $rescount_q = '';
             $offline_q = '&amp;offline=true';
             $anum_ht = '';
-        } else {
-            $word_q = '';
         }
-        $thre_url = "{$_conf['read_php']}?{$base_q}{$rescount_q}{$offline_q}{$word_q}{$anum_ht}";
+        $thre_url = "{$_conf['read_php']}?{$host_bbs_key_q}{$rescount_q}{$offline_q}{$word_q}{$anum_ht}";
 
-
         $chUnColor_js = ($midoku_ari) ? "chUnColor('{$i}');" : '';
         $change_color = " onclick=\"chTtColor('{$i}');{$chUnColor_js}\"";
 
         // ƒIƒ“ƒŠ[>>1
         if ($only_one_bool) {
             $td['one'] = <<<EOP
-<td{$class_t}><a href="{$_conf['read_php']}?{$base_q}&amp;one=true">&gt;&gt;1</a></td>\n
+<td{$class_t}><a href="{$_conf['read_php']}?{$host_bbs_key_q}&amp;one=true">&gt;&gt;1</a></td>\n
 EOP;
         }
 
@@ -386,7 +385,7 @@
             } elseif ($aThreadList->spmode == 'palace') {
                 $setkey = 'setpal';
             }
-            $narabikae_a = "{$_conf['subject_php']}?{$base_q}{$spmode_q}{$sb_view_q}";
+            $narabikae_a = "{$_conf['subject_php']}?{$host_bbs_key_q}{$spmode_q}{$sb_view_q}";
 
             $td['edit'] = <<<EOP
 <td{$class_te}>
@@ -401,7 +400,7 @@
         // Å‹ß“Ç‚ñ‚¾ƒXƒŒ‚̉ðœ
         if ($aThreadList->spmode == 'recent') {
             $td['offrec'] = <<<EOP
-<td{$class_tc}><a href="info.php?{$base_q}&amp;offrec=true" target="_self" onclick="return offrec_ajax(this);">~</a></td>\n
+<td{$class_tc}><a href="info.php?{$host_bbs_key_q}&amp;offrec=true" target="_self" onclick="return offrec_ajax(this);">~</a></td>\n
 EOP;
         }
 

Modified: p2ex/trunk/lib/sb_print_k.inc.php
===================================================================
--- p2ex/trunk/lib/sb_print_k.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/sb_print_k.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -17,7 +17,7 @@
     //=================================================
 
     if (!$aThreadList->threads) {
-        if ($aThreadList->spmode == "fav" && $sb_view == "shinchaku") {
+        if ($aThreadList->spmode == 'fav' && $sb_view == 'shinchaku') {
             echo '<p class="empty-subject">‚¨‹C‚ɽڂɐV’…‚È‚©‚Á‚½‚Û</p>';
         } else {
             echo '<p class="empty-subject">ŠY“–»ÌÞ¼Þª¸Ä‚Í‚È‚©‚Á‚½‚Û</p>';
@@ -36,17 +36,17 @@
     // >>1
     if (strpos($aThreadList->bbs, 'news') !== false || $aThreadList->bbs == 'bizplus') {
         // ‘qŒÉ‚͏œ‚­
-        if ($aThreadList->spmode != "soko") {
+        if ($aThreadList->spmode != 'soko') {
             $only_one_bool = true;
         }
     }
 
     // ”–¼
-    if ($aThreadList->spmode and $aThreadList->spmode != "taborn" and $aThreadList->spmode != "soko") {
+    if ($aThreadList->spmode and $aThreadList->spmode != 'taborn' and $aThreadList->spmode != 'soko') {
         $ita_name_bool = true;
     }
 
-    $norefresh_q = "&amp;norefresh=1";
+    $norefresh_q = '&amp;norefresh=1';
 
     // ƒ\[ƒg ==================================================
 
@@ -83,8 +83,9 @@
         $anum_ht = ""; //#r1
         $htm = array('ita' => '', 'rnum' => '', 'unum' => '', 'sim' => '');
 
-        $bbs_q = "&amp;bbs=".$aThread->bbs;
-        $key_q = "&amp;key=".$aThread->key;
+        $bbs_q = '&amp;bbs=' . $aThread->bbs;
+        $key_q = '&amp;key=' . $aThread->key;
+        $host_bbs_key_q = 'host=' . $aThread->host . $bbs_q . $key_q;
         $offline_q = '';
 
         if ($aThreadList->spmode!="taborn") {
@@ -168,7 +169,7 @@
         } else {
             $torder_st = $aThread->torder;
         }
-        $torder_ht = "<a id=\"to{$i}\" class=\"info\" href=\"info.php?host={$aThread->host}{$bbs_q}{$key_q}{$_conf['k_at_a']}\">{$torder_st}</a>";
+        $torder_ht = "<a id=\"to{$i}\" class=\"info\" href=\"info.php?{$host_bbs_key_q}{$_conf['k_at_a']}\">{$torder_st}</a>";
         */
         $torder_ht = $aThread->torder;
 
@@ -209,14 +210,14 @@
             }
         }
 
-        $thre_url = "{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}";
+        $thre_url = "{$_conf['read_php']}?{$host_bbs_key_q}";
         if ($_conf['iphone']) {
             $thre_url .= '&amp;ttitle_en=' . rawurlencode(base64_encode($aThread->ttitle));
         }
         $thre_url .= "{$rescount_q}{$offline_q}{$_conf['k_at_a']}{$anum_ht}";
 
         // ƒIƒ“ƒŠ[>>1
-        $onlyone_url = "{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;one=true&amp;k_continue=1{$_conf['k_at_a']}";
+        $onlyone_url = "{$_conf['read_php']}?{$host_bbs_key_q}&amp;one=true&amp;k_continue=1{$_conf['k_at_a']}";
         if ($only_one_bool) {
             $one_ht = "<a href=\"{$onlyone_url}\">&gt;&gt;1</a>";
         }

Modified: p2ex/trunk/lib/sb_toolbar.inc.php
===================================================================
--- p2ex/trunk/lib/sb_toolbar.inc.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/lib/sb_toolbar.inc.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -53,7 +53,7 @@
     <tr>
         <td class="toolbar-title">{$ptitle_ht}</td>
         <td class="toolbar-update">
-            <form class="toolbar" method="GET" action="subject.php" accept-charset="{$_conf['accept_charset']}" target="_self">
+            <form class="toolbar" method="GET" action="{$_conf['subject_php']}" accept-charset="{$_conf['accept_charset']}" target="_self">
                 {$sb_form_hidden_ht}
                 {$sb_disp_num_ht}
                 <input type="hidden" name="submit_refresh" value="1">

Modified: p2ex/trunk/read_new.php
===================================================================
--- p2ex/trunk/read_new.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/read_new.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -39,14 +39,12 @@
     $GLOBALS['rnum_all_range'] = $_conf['rnum_all_range'];
 }
 
-$sb_view = "shinchaku";
-$newtime = date("gis");
+$sb_view = 'shinchaku';
+$newtime = date('gis');
 
 $online_num = 0;
 $newthre_num = 0;
 
-$sid_q = (defined('SID')) ? '&amp;'.strip_tags(SID) : '';
-
 //=================================================
 // ”‚̎w’è
 //=================================================
@@ -155,6 +153,7 @@
     <script type="text/javascript" src="js/basic.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/respopup.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/htmlpopup.js?{$_conf['p2_version_id']}"></script>
+    <script type="text/javascript" src="js/motolspopup.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/ngabornctl.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/setfavjs.js?{$_conf['p2_version_id']}"></script>
     <script type="text/javascript" src="js/delelog.js?{$_conf['p2_version_id']}"></script>\n
@@ -392,7 +391,7 @@
 function readNew($aThread)
 {
     global $_conf, $newthre_num, $STYLE;
-    global $_info_msg_ht, $sid_q, $word;
+    global $_info_msg_ht, $word;
     static $favlist_titles = null;
 
     if ($_conf['expack.misc.multi_favs'] && is_null($favlist_titles)) {
@@ -466,14 +465,15 @@
     //==================================================================
     // ƒwƒbƒ_ •\Ž¦
     //==================================================================
-    $motothre_url = $aThread->getMotoThread();
+    $motothre_url = $aThread->getMotoThread(false, '');
 
     $ttitle_en = base64_encode($aThread->ttitle);
     $ttitle_urlen = rawurlencode($ttitle_en);
-    $ttitle_en_q ="&amp;ttitle_en=".$ttitle_urlen;
-    $bbs_q = "&amp;bbs=".$aThread->bbs;
-    $key_q = "&amp;key=".$aThread->key;
-    $popup_q = "&amp;popup=1";
+    $ttitle_en_q = '&amp;ttitle_en=' . $ttitle_urlen;
+    $bbs_q = '&amp;bbs=' . $aThread->bbs;
+    $key_q = '&amp;key=' . $aThread->key;
+    $host_bbs_key_q = 'host=' . $aThread->host . $bbs_q . $key_q;
+    $popup_q = '&amp;popup=1';
 
     // require_once P2_LIB_DIR . '/read_header.inc.php';
 
@@ -524,20 +524,21 @@
     // $read_footer_navi_new  ‘±‚«‚ð“Ç‚Þ V’…ƒŒƒX‚Ì•\Ž¦
     $newtime = date("gis");  // ƒŠƒ“ƒN‚ðƒNƒŠƒbƒN‚µ‚Ä‚àÄ“Ǎž‚µ‚È‚¢Žd—l‚ɑ΍R‚·‚éƒ_ƒ~[ƒNƒGƒŠ[
 
-    $info_st = "î•ñ";
-    $delete_st = "íœ";
-    $prev_st = "‘O";
-    $next_st = "ŽŸ";
+    $info_st = 'î•ñ';
+    $delete_st = 'íœ';
+    $prev_st = '‘O';
+    $next_st = 'ŽŸ';
+    $dores_st = '‘ž';
 
-    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->rescount}-&amp;nt=$newtime#r{$aThread->rescount}\">V’…ƒŒƒX‚Ì•\Ž¦</a>";
+    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->rescount}-&amp;nt=$newtime#r{$aThread->rescount}\">V’…ƒŒƒX‚Ì•\Ž¦</a>";
 
     if (!empty($_conf['disable_res'])) {
         $dores_ht = <<<EOP
-          <a href="{$motothre_url}" target="_blank">ƒŒƒX</a>
+          <a href="{$motothre_url}" target="_blank">{$dores_st}</a>
 EOP;
     } else {
         $dores_ht = <<<EOP
-        <a href="post_form.php?host={$aThread->host}{$bbs_q}{$key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}" target='_self' onclick="return OpenSubWin('post_form.php?host={$aThread->host}{$bbs_q}{$key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}{$popup_q}&amp;from_read_new=1{$sid_q}',{$STYLE['post_pop_size']},1,0)">ƒŒƒX</a>
+        <a href="post_form.php?{$host_bbs_key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}" target='_self' onclick="return OpenSubWin('post_form.php?{$host_bbs_key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}{$popup_q}&amp;from_read_new=1',{$STYLE['post_pop_size']},1,0)">{$dores_st}</a>
 EOP;
     }
 
@@ -555,7 +556,7 @@
         $favtitle = $favlist_titles[0] . ($favdo ? '‚ɒljÁ' : '‚©‚çŠO‚·');
         $setnum_q = '&amp;setnum=0';
         $toolbar_setfav_ht .= <<<EOP
-<span class="favdo set0"><a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$favdo_q}{$setnum_q}{$sid_q}" target="info" onclick="return setFavJs('host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$sid_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read_new', this, '0');" title="{$favtitle}">{$favmark}</a></span>
+<span class="favdo set0"><a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$favdo_q}{$setnum_q}" target="info" onclick="return setFavJs('{$host_bbs_key_q}{$ttitle_en_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read_new', this, '0');" title="{$favtitle}">{$favmark}</a></span>
 EOP;
         for ($i = 1; $i <= $_conf['expack.misc.favset_num']; $i++) {
             $favdo = (!empty($aThread->favs[$i])) ? 0 : 1;
@@ -564,7 +565,7 @@
             $favtitle = $favlist_titles[$i] . ($favdo ? '‚ɒljÁ' : '‚©‚çŠO‚·');
             $setnum_q = '&amp;setnum=' . $i;
             $toolbar_setfav_ht .= <<<EOP
-|<span class="favdo set{$i}"><a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$favdo_q}{$setnum_q}{$sid_q}" target="info" onclick="return setFavJs('host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$sid_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read_new', this, '{$i}');" title="{$favtitle}">{$favmark}</a></span>
+|<span class="favdo set{$i}"><a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$favdo_q}{$setnum_q}" target="info" onclick="return setFavJs('{$host_bbs_key_q}{$ttitle_en_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read_new', this, '{$i}');" title="{$favtitle}">{$favmark}</a></span>
 EOP;
         }
         $toolbar_setfav_ht .= ']';
@@ -574,18 +575,18 @@
         $favmark = $favdo ? '+' : 'š';
         $favtitle = $favdo ? '‚¨‹C‚ɃXƒŒ‚ɒljÁ' : '‚¨‹C‚ɃXƒŒ‚©‚çŠO‚·';
         $toolbar_setfav_ht = <<<EOP
-<span class="favdo"><a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$favdo_q}{$sid_q}" target="info" onclick="return setFavJs('host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$sid_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read_new', this, '0');" title="{$favtitle}">‚¨‹C‚É{$favmark}</a></span>
+<span class="favdo"><a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$favdo_q}" target="info" onclick="return setFavJs('{$host_bbs_key_q}{$ttitle_en_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read_new', this, '0');" title="{$favtitle}">‚¨‹C‚É{$favmark}</a></span>
 EOP;
     }
 
     $toolbar_right_ht = <<<EOTOOLBAR
-            <a href="{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$key_q}" target="subject" title="”‚ðŠJ‚­">{$itaj_hd}</a>
-            <a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$sid_q}" target="info" onclick="return OpenSubWin('info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$popup_q}{$sid_q}',{$STYLE['info_pop_size']},1,0)" title="ƒXƒŒƒbƒhî•ñ‚ð•\Ž¦">{$info_st}</a>
+            <a href="{$_conf['subject_php']}?{$host_bbs_key_q}" target="subject" title="”‚ðŠJ‚­">{$itaj_hd}</a>
+            <a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}" target="info" onclick="return OpenSubWin('info.php?{$host_bbs_key_q}{$ttitle_en_q}{$popup_q}',{$STYLE['info_pop_size']},1,0)" title="ƒXƒŒƒbƒhî•ñ‚ð•\Ž¦">{$info_st}</a>
             {$toolbar_setfav_ht}
-            <span><a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}&amp;dele=true" target="info" onclick="return deleLog('host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$sid_q}', {$STYLE['info_pop_size']}, 'read_new', this);" title="ƒƒO‚ðíœ‚·‚é">{$delete_st}</a></span>
-<!--            <a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}&amp;taborn=2" target="info" onclick="return OpenSubWin('info.php?host={$aThread->host}{$bbs_q}&amp;key={$aThread->key}{$ttitle_en_q}&amp;popup=2&amp;taborn=2{$sid_q}',{$STYLE['info_pop_size']},0,0)" title="ƒXƒŒƒbƒh‚Ì‚ ‚ځ[‚ñó‘Ô‚ðƒgƒOƒ‹‚·‚é">‚ ‚Ú‚ñ</a> -->
-            <a href="{$motothre_url}" title="”ƒT[ƒoã‚̃IƒŠƒWƒiƒ‹ƒXƒŒ‚ð•\Ž¦">Œ³ƒXƒŒ</a>
-            <a href="{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$key_q}{$similar_q}" target="subject" title="ƒ^ƒCƒgƒ‹‚ªŽ—‚Ä‚¢‚éƒXƒŒƒbƒh‚ðŒŸõ">Ž—ƒXƒŒ</a>
+            <span><a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}&amp;dele=true" target="info" onclick="return deleLog('{$host_bbs_key_q}{$ttitle_en_q}', {$STYLE['info_pop_size']}, 'read_new', this);" title="ƒƒO‚ðíœ‚·‚é">{$delete_st}</a></span>
+<!--            <a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}&amp;taborn=2" target="info" onclick="return OpenSubWin('info.php?{$host_bbs_key_q}{$ttitle_en_q}&amp;popup=2&amp;taborn=2',{$STYLE['info_pop_size']},0,0)" title="ƒXƒŒƒbƒh‚Ì‚ ‚ځ[‚ñó‘Ô‚ðƒgƒOƒ‹‚·‚é">‚ ‚Ú‚ñ</a> -->
+            <a href="{$motothre_url}" title="”ƒT[ƒoã‚̃IƒŠƒWƒiƒ‹ƒXƒŒ‚ð•\Ž¦" onmouseover="showMotoLsPopUp(event, this)" onmouseout="hideMotoLsPopUp()">Œ³ƒXƒŒ</a>
+            <a href="{$_conf['subject_php']}?{$host_bbs_key_q}{$similar_q}" target="subject" title="ƒ^ƒCƒgƒ‹‚ªŽ—‚Ä‚¢‚éƒXƒŒƒbƒh‚ðŒŸõ">Ž—ƒXƒŒ</a>
 EOTOOLBAR;
 
     // ƒŒƒX‚Ì‚·‚΂₳
@@ -605,7 +606,7 @@
     $read_footer_ht = <<<EOP
 <table class="toolbar">
     <tr>
-        <td class="lblock">{$res1['body']} | <a href="{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;offline=1&amp;rescount={$aThread->rescount}#r{$aThread->rescount}">{$aThread->ttitle_hd}</a> | {$dores_ht} {$dsize_ht} {$spd_ht}</td>
+        <td class="lblock">{$res1['body']} | <a href="{$_conf['read_php']}?{$host_bbs_key_q}&amp;offline=1&amp;rescount={$aThread->rescount}#r{$aThread->rescount}">{$aThread->ttitle_hd}</a> | {$dores_ht} {$dsize_ht} {$spd_ht}</td>
         <td class="rblock">{$toolbar_right_ht}</td>
         <td class="rblock"><a href="#ntt{$newthre_num}">£</a></td>
     </tr>

Modified: p2ex/trunk/read_new_k.php
===================================================================
--- p2ex/trunk/read_new_k.php	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/read_new_k.php	2010-01-13 04:36:03 UTC (rev 773)
@@ -439,6 +439,7 @@
     $ttitle_en_q = '&amp;ttitle_en=' . $ttitle_en;
     $bbs_q = '&amp;bbs=' . $aThread->bbs;
     $key_q = '&amp;key=' . $aThread->key;
+    $host_bbs_key_q = 'host=' . $aThread->host . $bbs_q . $key_q;
     $popup_q = '&amp;popup=1';
 
     // require_once P2_LIB_DIR . '/read_header.inc.php';
@@ -495,6 +496,7 @@
     $delete_st = 'í';
     $prev_st = '‘O';
     $next_st = 'ŽŸ';
+    //$dores_st = '攴';
 
     // •\Ž¦”͈Í
     if ($aThread->resrange['start'] == $aThread->resrange['to']) {
@@ -504,16 +506,16 @@
     }
     $read_range_ht = "{$read_range_on}/{$aThread->rescount}";
 
-    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->rescount}-&amp;nt={$newtime}{$_conf['k_at_a']}#r{$aThread->rescount}\" target=\"_blank\">V’…Ú½‚Ì•\Ž¦</a>";
+    $read_footer_navi_new = "<a href=\"{$_conf['read_php']}?{$host_bbs_key_q}&amp;ls={$aThread->rescount}-&amp;nt={$newtime}{$_conf['k_at_a']}#r{$aThread->rescount}\" target=\"_blank\">V’…Ú½‚Ì•\Ž¦</a>";
 
     /*
     if (!empty($_conf['disable_res'])) {
         $dores_ht = <<<EOP
-<a href="{$motothre_url}" target="_blank">攴</a>
+<a href="{$motothre_url}" target="_blank">{$dores_st}</a>
 EOP;
     } else {
         $dores_ht = <<<EOP
-<a href="post_form.php?host={$aThread->host}{$bbs_q}{$key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}{$_conf['k_at_a']}">攴</a>
+<a href="post_form.php?{$host_bbs_key_q}&amp;rescount={$aThread->rescount}{$ttitle_en_q}{$_conf['k_at_a']}">{$dores_st}</a>
 EOP;
     }
     */
@@ -521,7 +523,7 @@
     // ƒc[ƒ‹ƒo[•”•ªHTML =======
     if ($spmode) {
         $toolbar_itaj_ht = <<<EOP
- (<a href="{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$key_q}{$_conf['k_at_a']}" target="_blank">{$itaj_hd}</a>)
+ (<a href="{$_conf['subject_php']}?{$host_bbs_key_q}{$_conf['k_at_a']}" target="_blank">{$itaj_hd}</a>)
 EOP;
     } else {
         $toolbar_itaj_ht = '';
@@ -529,8 +531,8 @@
 
     /*
     $toolbar_right_ht .= <<<EOTOOLBAR
-<a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$_conf['k_at_a']}">{$info_st}</a>
-<a href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}&amp;dele=true{$_conf['k_at_a']}">{$delete_st}</a>
+<a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$_conf['k_at_a']}">{$info_st}</a>
+<a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}&amp;dele=true{$_conf['k_at_a']}">{$delete_st}</a>
 <a href="{$motothre_url}" target="_blank">Œ³½Ú</a>\n
 EOTOOLBAR;
     */
@@ -538,10 +540,10 @@
     $read_footer_ht = <<<EOP
 <div id="ntt_bt{$newthre_num}" name="ntt_bt{$newthre_num}" class="read_new_toolbar">
 {$read_range_ht}
-<a class="button" href="info.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$_conf['k_at_a']}" target="_blank">{$info_st}</a>
-<a class="button" href="spm_k.php?host={$aThread->host}{$bbs_q}{$key_q}&amp;ls={$aThread->ls}&amp;spm_default={$aThread->resrange['to']}&amp;from_read_new=1{$_conf['k_at_a']}" target="_blank">“Á</a>
+<a class="button" href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$_conf['k_at_a']}" target="_blank">{$info_st}</a>
+<a class="button" href="spm_k.php?{$host_bbs_key_q}&amp;ls={$aThread->ls}&amp;spm_default={$aThread->resrange['to']}&amp;from_read_new=1{$_conf['k_at_a']}" target="_blank">“Á</a>
 <br>
-<a href="{$_conf['read_php']}?host={$aThread->host}{$bbs_q}{$key_q}&amp;offline=1&amp;rescount={$aThread->rescount}{$_conf['k_at_a']}#r{$aThread->rescount}" target="_blank">{$aThread->ttitle_hd}</a>{$toolbar_itaj_ht}
+<a href="{$_conf['read_php']}?{$host_bbs_key_q}&amp;offline=1&amp;rescount={$aThread->rescount}{$_conf['k_at_a']}#r{$aThread->rescount}" target="_blank">{$aThread->ttitle_hd}</a>{$toolbar_itaj_ht}
 <a class="button" href="#ntt{$newthre_num}">£</a>
 </div>
 <hr>\n
@@ -617,7 +619,9 @@
 if ($_conf['iphone']) {
     // ImageCache2
     if ($_conf['expack.ic2.enabled']) {
-        require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php';
+        if (!function_exists('ic2_loadconfig')) {
+            include P2EX_LIB_DIR . '/ic2/bootstrap.php';
+        }
         $ic2conf = ic2_loadconfig();
         if ($ic2conf['Thumb1']['width'] > 80) {
             include P2EX_LIB_DIR . '/ic2/templates/info-v.tpl.html';

Modified: p2ex/trunk/style/style_css.inc
===================================================================
--- p2ex/trunk/style/style_css.inc	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/style/style_css.inc	2010-01-13 04:36:03 UTC (rev 773)
@@ -95,6 +95,50 @@
 
 EOSTYLE;
 
+// {{{ ”Ä—pƒ|ƒbƒvƒAƒbƒv‚ÆŒ³ƒXƒŒƒŠƒ“ƒNƒ|ƒbƒvƒAƒbƒv (ƒŒƒXƒ|ƒbƒvƒAƒbƒv‚Ì—¬—p)
+
+if (!isset($STYLE['respop_bgcolor']))	{ $STYLE['respop_bgcolor'] = '#ffffcc'; }
+if (!isset($STYLE['respop_background'])) { $STYLE['respop_background'] = ''; }
+$respop_background = "background:{$STYLE['respop_bgcolor']} {$STYLE['respop_background']};";
+
+if (!isset($STYLE['respop_b_style'])) { $STYLE['respop_b_style'] = 'solid'; }
+if (!isset($STYLE['respop_b_width'])) { $STYLE['respop_b_width'] = '1px';   }
+if (!isset($STYLE['respop_b_color'])) { $STYLE['respop_b_color'] = 'black'; }
+$respop_border = "border:{$STYLE['respop_b_style']} {$STYLE['respop_b_width']} {$STYLE['respop_b_color']};";
+
+$respop_color = '';
+if (isset($STYLE['respop_color']) && strlen($STYLE['respop_color']) > 0) {
+	$respop_color = "color:{$STYLE['respop_color']};";
+}
+
+	echo <<<EOSTYLE
+
+.popup_element {
+	position: absolute;
+	visibility: hidden; /* •’i‚͉B‚µ‚Ä‚¨‚­*/
+	{$respop_background}
+	{$respop_border}
+	{$respop_color}
+	font-size:{$STYLE['respop_fontsize']};
+	margin: 0;
+	padding: 8px;
+}
+
+div#motols {
+	padding: 1px 2px;
+}
+
+div#motols a {
+	display: block;
+	margin: 0;
+	padding: 3px;
+	line-height: 100%;
+}
+
+EOSTYLE;
+
+// }}}
+
 // ƒXƒ^ƒCƒ‹‚̏㏑‚«
 if (isset($MYSTYLE) && is_array($MYSTYLE)) {
 	require_once P2_STYLE_DIR . '/mystyle_css.php';

Modified: p2ex/trunk/style/subject_css.inc
===================================================================
--- p2ex/trunk/style/subject_css.inc	2010-01-13 00:37:02 UTC (rev 772)
+++ p2ex/trunk/style/subject_css.inc	2010-01-13 04:36:03 UTC (rev 773)
@@ -183,6 +183,9 @@
 
 {$thre_title_underline_css}
 
+/* Œ³ƒXƒŒƒŠƒ“ƒN */
+a.moto_thre { margin-right: 0.5em; }
+
 /* ƒXƒŒˆê——‚̔ԍ† */
 a.info { color: {$STYLE['sb_order_color']}; }
 a.info:hover { color: {$STYLE['sb_tacolor_h']}; }



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