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

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 1月 10日 (日) 01:57:35 JST


Revision: 767
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=767
Author:   rsk
Date:     2010-01-10 01:57:35 +0900 (Sun, 10 Jan 2010)

Log Message:
-----------
expack:
- リファクタリングを実行。
-- conf/conf.inc.php の処理の一部を lib/bootstrap.php に移動。
-- conf/conf.inc.php でロードされているクラスファイルを
   別の箇所でもロードしていたのを削除。
- 書き込みCookieの保存などにP2KeyValueStoreを使うようにした。
-- TODO: P2KeyValueStoreを直接使っている箇所をクラスに切り出す。
- 板ごとに「Beで書き込む」「公式p2で書き込む」を記憶するようにした。
- host,bbs,key,lsにHTMLの特殊文字が含まれていないか
  常にチェックするようにした。
- Login::$_user_u を使うべき箇所で Login::$_user を使っていたのを修正。
- iPhone用スタイルシートのtypoを修正。

Modified Paths:
--------------
    p2ex/trunk/conf/conf.inc.php
    p2ex/trunk/conf/conf_admin.inc.php
    p2ex/trunk/conf/ip_emobile.php
    p2ex/trunk/css/iphone.css
    p2ex/trunk/edit_user_font.php
    p2ex/trunk/info_js.php
    p2ex/trunk/lib/BbsMap.php
    p2ex/trunk/lib/BrdCtl.php
    p2ex/trunk/lib/BrdMenu.php
    p2ex/trunk/lib/HostCheck.php
    p2ex/trunk/lib/Login.php
    p2ex/trunk/lib/P2Client.php
    p2ex/trunk/lib/P2HttpExt.php
    p2ex/trunk/lib/P2Util.php
    p2ex/trunk/lib/PresetManager.php
    p2ex/trunk/lib/Thread.php
    p2ex/trunk/lib/ThreadRead.php
    p2ex/trunk/lib/dele.inc.php
    p2ex/trunk/lib/expack/fixed_name.inc.php
    p2ex/trunk/lib/expack/rss/common.inc.php
    p2ex/trunk/lib/expack/rss/parser.inc.php
    p2ex/trunk/lib/expack/rss/setrss.inc.php
    p2ex/trunk/lib/login2ch.inc.php
    p2ex/trunk/lib/post_form_options.inc.php
    p2ex/trunk/lib/read_footer.inc.php
    p2ex/trunk/lib/read_machibbs.inc.php
    p2ex/trunk/lib/read_new.inc.php
    p2ex/trunk/lib/read_res_hist.inc.php
    p2ex/trunk/lib/read_shitaraba.inc.php
    p2ex/trunk/lib/setbookmark.inc.php
    p2ex/trunk/lib/setfav.inc.php
    p2ex/trunk/lib/setfavita.inc.php
    p2ex/trunk/lib/setpalace.inc.php
    p2ex/trunk/lib/settaborn.inc.php
    p2ex/trunk/lib/settaborn_off.inc.php
    p2ex/trunk/lib/subject_new.inc.php
    p2ex/trunk/menu_i.php
    p2ex/trunk/post.php
    p2ex/trunk/post_form.php
    p2ex/trunk/read_filter_k.php
    p2ex/trunk/subject.php

Added Paths:
-----------
    p2ex/trunk/lib/bootstrap.php


-------------- next part --------------
Modified: p2ex/trunk/conf/conf.inc.php
===================================================================
--- p2ex/trunk/conf/conf.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/conf/conf.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -74,956 +74,274 @@
     global $_conf, $_info_msg_ht, $_login, $_p2session;
     global $conf_user_def, $conf_user_rules, $conf_user_rad, $conf_user_sel;
 
-// ƒGƒ‰[o—͐ݒè
-if (defined('E_DEPRECATED')) {
-    error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
-} else {
-    error_reporting(E_ALL & ~(E_NOTICE | E_STRICT));
-}
-
-// {{{ Šî–{•Ï”
-
-$_conf['p2web_url']             = 'http://akid.s17.xrea.com/';
-$_conf['p2ime_url']             = 'http://akid.s17.xrea.com/p2ime.php';
-$_conf['favrank_url']           = 'http://akid.s17.xrea.com/favrank/favrank.php';
-$_conf['expack.web_url']        = 'http://page2.skr.jp/rep2/';
-$_conf['expack.download_url']   = 'http://page2.skr.jp/rep2/downloads.html';
-$_conf['expack.history_url']    = 'http://page2.skr.jp/rep2/history.html';
-$_conf['expack.tgrep_url']      = 'http://page2.xrea.jp/tgrep/search';
-$_conf['expack.ime_url']        = 'http://page2.skr.jp/gate.php';
-$_conf['menu_php']              = 'menu.php';
-$_conf['subject_php']           = 'subject.php';
-$_conf['read_php']              = 'read.php';
-$_conf['read_new_php']          = 'read_new.php';
-$_conf['read_new_k_php']        = 'read_new_k.php';
-
-// }}}
-// {{{ ŠÂ‹«Ý’è
-
-// ƒfƒoƒbƒO
-//$debug = !empty($_GET['debug']);
-
-putenv('LC_CTYPE=C');
-
-// ƒ^ƒCƒ€ƒ][ƒ“‚ðƒZƒbƒg
-date_default_timezone_set('Asia/Tokyo');
-
-// ƒXƒNƒŠƒvƒgŽÀs§ŒÀŽžŠÔ (•b)
-if (!defined('P2_CLI_RUN')) {
-    set_time_limit(60); // (60) 
-}
-
-// Ž©“®ƒtƒ‰ƒbƒVƒ…‚ðƒIƒt‚É‚·‚é
-ob_implicit_flush(0);
-
-// ƒNƒ‰ƒCƒAƒ“ƒg‚©‚çÚ‘±‚ðØ‚ç‚ê‚Ä‚àˆ—‚𑱍s‚·‚é
-// ignore_user_abort(1);
-
-// file($filename, FILE_IGNORE_NEW_LINES) ‚Å CR/LF/CR+LF ‚Ì‚¢‚¸‚ê‚às––‚Æ‚µ‚Ĉµ‚¤
-ini_set('auto_detect_line_endings', 1);
-
-// session.trans_sid—LŒøŽž ‚â output_add_rewrite_var(), http_build_query() “™‚Ő¶¬E•ÏX‚³‚ê‚é
-// URL‚ÌGETƒpƒ‰ƒ[ƒ^‹æØ‚蕶Žš(—ñ)‚ð"&"‚É‚·‚éBiƒfƒtƒHƒ‹ƒg‚Í"&"j
-ini_set('arg_separator.output', '&');
-
-// ƒŠƒNƒGƒXƒgID‚ðÝ’è (ƒRƒXƒg‚ª‘å‚«‚¢Š„‚ÉŽg‚Á‚Ä‚¢‚È‚¢‚Ì‚Å”pŽ~)
-//define('P2_REQUEST_ID', substr($_SERVER['REQUEST_METHOD'], 0, 1) . md5(serialize($_REQUEST)));
-
-// Windows ‚È‚ç
-if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
-    // Windows
-    defined('PATH_SEPARATOR') or define('PATH_SEPARATOR', ';');
-    defined('DIRECTORY_SEPARATOR') or define('DIRECTORY_SEPARATOR', '\\');
-    define('P2_OS_WINDOWS', 1);
-} else {
-    defined('PATH_SEPARATOR') or define('PATH_SEPARATOR', ':');
-    defined('DIRECTORY_SEPARATOR') or define('DIRECTORY_SEPARATOR', '/');
-    define('P2_OS_WINDOWS', 0);
-}
-
-// mbstring.script_encoding = SJIS-win ‚¾‚Æ "\0", "\x00" ˆÈ~‚ªƒJƒbƒg‚³‚ê‚é‚Ì‚Å
-define('P2_NULLBYTE', chr(0));
-
-// }}}
-// {{{ P2Util::header_content_type() ‚ð•s—v‚É‚·‚邨‚Ü‚¶‚È‚¢
-
-ini_set('default_mimetype', 'text/html');
-ini_set('default_charset', 'Shift_JIS');
-
-// }}}
-// {{{ ƒ‰ƒCƒuƒ‰ƒŠ—ނ̃pƒXÝ’è
-
-define('P2_CONF_DIR', dirname(__FILE__)); // __DIR__ @php-5.3
-
-define('P2_BASE_DIR', dirname(P2_CONF_DIR));
-
-// Šî–{“I‚È‹@”\‚ð’ñ‹Ÿ‚·‚é‚·‚郉ƒCƒuƒ‰ƒŠ
-define('P2_LIB_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'lib');
-
-// ‚¨‚Ü‚¯“I‚È‹@”\‚ð’ñ‹Ÿ‚·‚é‚·‚郉ƒCƒuƒ‰ƒŠ
-define('P2EX_LIB_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'expack');
-
-// ƒXƒ^ƒCƒ‹ƒV[ƒg
-define('P2_STYLE_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'style');
-
-// ƒXƒLƒ“
-define('P2_SKIN_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'skin');
-define('P2_USER_SKIN_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'user_skin');
-
-// PEARƒCƒ“ƒXƒg[ƒ‹ƒfƒBƒŒƒNƒgƒŠAŒŸõƒpƒX‚ɒljÁ‚³‚ê‚é
-define('P2_PEAR_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . '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 . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pear_hack');
-}
-
-// ƒRƒ}ƒ“ƒhƒ‰ƒCƒ“ƒc[ƒ‹
-define('P2_CLI_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'cli');
-
-// ŒŸõƒpƒX‚ðƒZƒbƒg
-$include_path = '';
-if (defined('P2_PEAR_HACK_DIR')) {
-    $include_path .= P2_PEAR_HACK_DIR . PATH_SEPARATOR;
-}
-if (is_dir(P2_PEAR_DIR)) {
-    $include_path .= P2_PEAR_DIR . PATH_SEPARATOR;
-} else {
-    $paths = array();
-    foreach (explode(PATH_SEPARATOR, get_include_path()) as $dir) {
-        if (is_dir($dir)) {
-            $dir = realpath($dir);
-            if ($dir != P2_BASE_DIR) {
-                $paths[] = $dir;
-            }
-        }
+    // ƒGƒ‰[o—͐ݒè
+    if (defined('E_DEPRECATED')) {
+        error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
+    } else {
+        error_reporting(E_ALL & ~(E_NOTICE | E_STRICT));
     }
-    if (count($paths)) {
-        $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 . DIRECTORY_SEPARATOR;
-$P2_LIB_DIR_S = P2_LIB_DIR . DIRECTORY_SEPARATOR;
+    // {{{ Šî–{•Ï”
 
-// }}}
-// {{{ ŠÂ‹«ƒ`ƒFƒbƒN‚ƃfƒoƒbƒO
+    $_conf['p2web_url']             = 'http://akid.s17.xrea.com/';
+    $_conf['p2ime_url']             = 'http://akid.s17.xrea.com/p2ime.php';
+    $_conf['favrank_url']           = 'http://akid.s17.xrea.com/favrank/favrank.php';
+    $_conf['expack.web_url']        = 'http://page2.skr.jp/rep2/';
+    $_conf['expack.download_url']   = 'http://page2.skr.jp/rep2/downloads.html';
+    $_conf['expack.history_url']    = 'http://page2.skr.jp/rep2/history.html';
+    $_conf['expack.tgrep_url']      = 'http://page2.xrea.jp/tgrep/search';
+    $_conf['expack.ime_url']        = 'http://page2.skr.jp/gate.php';
+    $_conf['menu_php']              = 'menu.php';
+    $_conf['subject_php']           = 'subject.php';
+    $_conf['read_php']              = 'read.php';
+    $_conf['read_new_php']          = 'read_new.php';
+    $_conf['read_new_k_php']        = 'read_new_k.php';
 
-// ƒ†[ƒeƒBƒŠƒeƒB‚ð“ǂݍž‚Þ
-require_once $P2_LIB_DIR_S . 'DataPhp.php';
-require_once $P2_LIB_DIR_S . 'FileCtl.php';
-require_once $P2_LIB_DIR_S . 'P2Util.php';
-require_once $P2_LIB_DIR_S . 'p2util.inc.php';
+    // }}}
+    // {{{ ŠÂ‹«Ý’è
 
-// “®ìŠÂ‹«‚ðŠm”F (—vŒ‚ð–ž‚½‚µ‚Ä‚¢‚é‚È‚çƒRƒƒ“ƒgƒAƒEƒg‰Â)
-p2checkenv(__LINE__);
+    // ƒfƒoƒbƒO
+    //$debug = !empty($_GET['debug']);
 
-if ($debug) {
-    if (!class_exists('Benchmark_Profiler', false)) {
-        require 'Benchmark/Profiler.php';
-    }
-    $profiler = new Benchmark_Profiler(true);
-    // print_memory_usage();
-    register_shutdown_function('print_memory_usage');
-}
+    putenv('LC_CTYPE=C');
 
-// }}}
-// {{{ •¶ŽšƒR[ƒh‚ÌŽw’è
+    // ƒ^ƒCƒ€ƒ][ƒ“‚ðƒZƒbƒg
+    date_default_timezone_set('Asia/Tokyo');
 
-//mb_detect_order("CP932,CP51932,ASCII");
-mb_internal_encoding('CP932');
-mb_http_output('pass');
-mb_substitute_character(63); // •¶ŽšƒR[ƒh•ÏŠ·‚ÉŽ¸”s‚µ‚½•¶Žš‚ª "?" ‚É‚È‚é
-//mb_substitute_character(0x3013); // ¬
-//ob_start('mb_output_handler');
-
-if (function_exists('mb_ereg_replace')) {
-    define('P2_MBREGEX_AVAILABLE', 1);
-    mb_regex_encoding('CP932');
-} else {
-    define('P2_MBREGEX_AVAILABLE', 0);
-}
-
-// }}}
-// {{{ ŠÇ—ŽÒ—pÝ’èetc.
-
-// ŠÇ—ŽÒ—pÝ’è‚ð“ǂݍž‚Ý
-require_once $P2_CONF_DIR_S . 'conf_admin.inc.php';
-
-// ƒfƒBƒŒƒNƒgƒŠ‚̐â‘΃pƒX‰»
-$_conf['data_dir'] = p2_realpath($_conf['data_dir']);
-$_conf['dat_dir']  = p2_realpath($_conf['dat_dir']);
-$_conf['idx_dir']  = p2_realpath($_conf['idx_dir']);
-$_conf['pref_dir'] = p2_realpath($_conf['pref_dir']);
-
-// ŠÇ——p•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
-$_conf['admin_dir'] = $_conf['data_dir'] . DIRECTORY_SEPARATOR . 'admin';
-
-// cache •Û‘¶ƒfƒBƒŒƒNƒgƒŠ
-// 2005/06/29 $_conf['pref_dir'] . '/p2_cache' ‚æ‚è•ÏX
-$_conf['cache_dir'] = $_conf['data_dir'] . DIRECTORY_SEPARATOR . 'cache';
-
-// Cookie •Û‘¶ƒfƒBƒŒƒNƒgƒŠ
-// 2008/09/09 $_conf['pref_dir'] . '/p2_cookie' ‚æ‚è•ÏX
-$_conf['cookie_dir'] = $_conf['data_dir'] . DIRECTORY_SEPARATOR . 'cookie';
-
-// ƒRƒ“ƒpƒCƒ‹‚³‚ꂽƒeƒ“ƒvƒŒ[ƒg‚Ì•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
-$_conf['compile_dir'] = $_conf['data_dir'] . DIRECTORY_SEPARATOR . 'compile';
-
-// ƒZƒbƒVƒ‡ƒ“ƒf[ƒ^•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
-$_conf['session_dir'] = $_conf['data_dir'] . DIRECTORY_SEPARATOR . 'session';
-
-// ƒeƒ“ƒ|ƒ‰ƒŠƒfƒBƒŒƒNƒgƒŠ
-$_conf['tmp_dir'] = $_conf['data_dir'] . DIRECTORY_SEPARATOR . 'tmp';
-
-// ƒo[ƒWƒ‡ƒ“ID‚ð“ñdˆø—p•„‚âƒqƒAƒhƒLƒ…ƒƒ“ƒg“à‚É–„‚ߍž‚Þ‚½‚߂̕ϐ”
-$_conf['p2_version_id'] = P2_VERSION_ID;
-
-// •¶ŽšƒR[ƒhŽ©“®”»’è—p‚̃qƒ“ƒg•¶Žš—ñ
-$_conf['detect_hint'] = 'ž';
-$_conf['detect_hint_input_ht'] = '<input type="hidden" name="_hint" value="ž">';
-$_conf['detect_hint_input_xht'] = '<input type="hidden" name="_hint" value="ž" />';
-//$_conf['detect_hint_utf8'] = mb_convert_encoding('ž', 'UTF-8', 'CP932');
-$_conf['detect_hint_q'] = '_hint=%81%9D%81%9E'; // rawurlencode($_conf['detect_hint'])
-$_conf['detect_hint_q_utf8'] = '_hint=%E2%97%8E%E2%97%87'; // rawurlencode($_conf['detect_hint_utf8'])
-
-// }}}
-// {{{ •Ï”Ý’è
-
-$pref_dir_s = $_conf['pref_dir'] . DIRECTORY_SEPARATOR;
-
-$_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_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_file_name']  = 'p2_cookie.txt';
-
-// •â³
-if ($_conf['expack.use_pecl_http'] && !extension_loaded('http')) {
-    if (!($_conf['expack.use_pecl_http'] == 2 && $_conf['expack.dl_pecl_http'])) {
-        $_conf['expack.use_pecl_http'] = 0;
+    // ƒXƒNƒŠƒvƒgŽÀs§ŒÀŽžŠÔ (•b)
+    if (!defined('P2_CLI_RUN')) {
+        set_time_limit(60); // (60)
     }
-}
 
-// ƒRƒ}ƒ“ƒhƒ‰ƒCƒ“ƒ‚[ƒh‚Å‚Í‚±‚±‚Ü‚Å
-if (defined('P2_CLI_RUN')) {
-    return;
-}
+    // Ž©“®ƒtƒ‰ƒbƒVƒ…‚ðƒIƒt‚É‚·‚é
+    ob_implicit_flush(0);
 
-// }}}
-// {{{ ƒzƒXƒgƒ`ƒFƒbƒN
+    // ƒNƒ‰ƒCƒAƒ“ƒg‚©‚çÚ‘±‚ðØ‚ç‚ê‚Ä‚àˆ—‚𑱍s‚·‚é
+    // ignore_user_abort(1);
 
-if ($_conf['secure']['auth_host'] || $_conf['secure']['auth_bbq']) {
-    require_once $P2_LIB_DIR_S . 'HostCheck.php';
-    if (($_conf['secure']['auth_host'] && HostCheck::getHostAuth() == false) ||
-        ($_conf['secure']['auth_bbq'] && HostCheck::getHostBurned() == true)
-    ) {
-        HostCheck::forbidden();
-    }
-}
+    // file($filename, FILE_IGNORE_NEW_LINES) ‚Å CR/LF/CR+LF ‚Ì‚¢‚¸‚ê‚às––‚Æ‚µ‚Ĉµ‚¤
+    ini_set('auto_detect_line_endings', 1);
 
-// }}}
-// {{{ ƒŠƒNƒGƒXƒg•Ï”‚̏ˆ—
+    // session.trans_sid—LŒøŽž ‚â output_add_rewrite_var(), http_build_query() “™‚Ő¶¬E•ÏX‚³‚ê‚é
+    // URL‚ÌGETƒpƒ‰ƒ[ƒ^‹æØ‚蕶Žš(—ñ)‚ð"&amp;"‚É‚·‚éBiƒfƒtƒHƒ‹ƒg‚Í"&"j
+    ini_set('arg_separator.output', '&amp;');
 
-// 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ƒgID‚ðÝ’è (ƒRƒXƒg‚ª‘å‚«‚¢Š„‚ÉŽg‚Á‚Ä‚¢‚È‚¢‚Ì‚Å”pŽ~)
+    //define('P2_REQUEST_ID', substr($_SERVER['REQUEST_METHOD'], 0, 1) . md5(serialize($_REQUEST)));
 
-/**
- * ƒŠƒNƒGƒXƒg•Ï”‚ðˆêŠ‡‚ŃNƒH[ƒgœ‹Ž••¶ŽšƒR[ƒh•ÏŠ·
- *
- * “ú–{Œê‚ð“ü—Í‚·‚é‰Â”\«‚Ì‚ ‚éƒtƒH[ƒ€‚ɂ͉B‚µ—v‘f‚Å
- * ƒGƒ“ƒR[ƒfƒBƒ“ƒO”»’è—p‚Ì•¶Žš—ñ‚ðŽdž‚ñ‚Å‚¢‚é
- *
- * $_COOKIE ‚Í $_REQUEST ‚ÉŠÜ‚ß‚È‚¢
- */
-if (!empty($_GET) || !empty($_POST)) {
-    if (isset($_REQUEST['_hint'])) {
-        // "CP932" ‚Í "SJIS-win" ‚̃GƒCƒŠƒAƒX‚ŁA"SJIS-win" ‚Æ "SJIS" ‚Í•Ê•¨
-        // "CP51932", "eucJP-win", "EUC-JP" ‚Í‚»‚ꂼ‚ê•Ê•¨ (libmbfl“I‚ȈӖ¡‚Å)
-        $request_encoding = mb_detect_encoding($_REQUEST['_hint'], 'UTF-8,CP51932,CP932');
-        if ($request_encoding == 'SJIS-win') {
-            $request_encoding = false;
-        }
+    // Windows ‚È‚ç
+    if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
+        // Windows
+        defined('PATH_SEPARATOR') or define('PATH_SEPARATOR', ';');
+        defined('DIRECTORY_SEPARATOR') or define('DIRECTORY_SEPARATOR', '\\');
+        define('P2_OS_WINDOWS', 1);
     } else {
-        $request_encoding = 'UTF-8,CP51932,CP932';
+        defined('PATH_SEPARATOR') or define('PATH_SEPARATOR', ':');
+        defined('DIRECTORY_SEPARATOR') or define('DIRECTORY_SEPARATOR', '/');
+        define('P2_OS_WINDOWS', 0);
     }
 
-    if (get_magic_quotes_gpc()) {
-        $_GET = array_map('stripslashes_r', $_GET);
-        $_POST = array_map('stripslashes_r', $_POST);
-    }
+    $DIR_SEP = DIRECTORY_SEPARATOR;
+    $PATH_SEP = PATH_SEPARATOR;
 
-    if ($request_encoding) {
-        mb_convert_variables('CP932', $request_encoding, $_GET, $_POST);
-    }
+    // mbstring.script_encoding = SJIS-win ‚¾‚Æ "\0", "\x00" ˆÈ~‚ªƒJƒbƒg‚³‚ê‚é‚Ì‚Å
+    define('P2_NULLBYTE', chr(0));
 
-    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
-        $_POST = array_map('nullfilter_r', $_POST);
-        if (count($_GET)) {
-            $_GET = array_map('nullfilter_r', $_GET);
-            $_REQUEST = array_merge($_GET, $_POST);
-        } else {
-            $_REQUEST = $_POST;
-        }
-    } else {
-        $_GET = array_map('nullfilter_r', $_GET);
-        $_REQUEST = $_GET;
-    }
-} else {
-    $_REQUEST = array();
-}
+    // }}}
+    // {{{ P2Util::header_content_type() ‚ð•s—v‚É‚·‚邨‚Ü‚¶‚È‚¢
 
-// }}}
-// {{{ ’[––”»’è
+    ini_set('default_mimetype', 'text/html');
+    ini_set('default_charset', 'Shift_JIS');
 
-require_once 'Net/UserAgent/Mobile.php';
+    // }}}
+    // {{{ ƒ‰ƒCƒuƒ‰ƒŠ—ނ̃pƒXÝ’è
 
-$_conf['ktai'] = false;
-$_conf['iphone'] = false;
-$_conf['input_type_search'] = false;
+    define('P2_CONF_DIR', dirname(__FILE__)); // __DIR__ @php-5.3
 
-$_conf['accesskey'] = 'accesskey';
-$_conf['accept_charset'] = 'Shift_JIS';
-$_conf['extra_headers_ht'] = '';
+    define('P2_BASE_DIR', dirname(P2_CONF_DIR));
+    $P2_BASE_DIR_S = P2_BASE_DIR . $DIR_SEP;
 
-$support_cookies = true;
+    // Šî–{“I‚È‹@”\‚ð’ñ‹Ÿ‚·‚é‚·‚郉ƒCƒuƒ‰ƒŠ
+    define('P2_LIB_DIR', $P2_BASE_DIR_S . 'lib');
 
-$mobile = Net_UserAgent_Mobile::singleton();
+    // ‚¨‚Ü‚¯“I‚È‹@”\‚ð’ñ‹Ÿ‚·‚é‚·‚郉ƒCƒuƒ‰ƒŠ
+    define('P2EX_LIB_DIR', $P2_BASE_DIR_S . 'lib' . $DIR_SEP . 'expack');
 
-// iPhone, iPod Touch
-if (P2Util::isBrowserIphone()) {
-    $_conf['ktai'] = true;
-    $_conf['iphone'] = true;
-    $_conf['input_type_search'] = true;
-    $_conf['accept_charset'] = 'UTF-8';
+    // ƒXƒ^ƒCƒ‹ƒV[ƒg
+    define('P2_STYLE_DIR', $P2_BASE_DIR_S . 'style');
 
-// PC“™
-} elseif ($mobile->isNonMobile()) {
-    // Safari
-    if (P2Util::isBrowserSafariGroup()) {
-        $_conf['input_type_search'] = true;
-        $_conf['accept_charset'] = 'UTF-8';
+    // ƒXƒLƒ“
+    define('P2_SKIN_DIR', $P2_BASE_DIR_S . 'skin');
+    define('P2_USER_SKIN_DIR', $P2_BASE_DIR_S . 'user_skin');
 
-    // Windows Mobile, Œg‘уQ[ƒ€‹@
-    } elseif (P2Util::isClientOSWindowsCE() || P2Util::isBrowserNintendoDS() || P2Util::isBrowserPSP()) {
-        $_conf['ktai'] = true;
-    }
+    // PEARƒCƒ“ƒXƒg[ƒ‹ƒfƒBƒŒƒNƒgƒŠAŒŸõƒpƒX‚ɒljÁ‚³‚ê‚é
+    define('P2_PEAR_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'includes');
 
-// Œg‘Ñ
-} else {
-    $_conf['ktai'] = true;
-
-    // NTT docomo iƒ‚[ƒh
-    if ($mobile->isDoCoMo()) {
-        $support_cookies = false;
-
-    // au EZweb
-    //} elseif ($mobile->isEZweb()) {
-    //    $support_cookies = true;
-
-    // SoftBank Mobile
-    } elseif ($mobile->isSoftBank()) {
-        // 3GCŒ^’[––‚Ínonumber‘®«‚ðƒTƒ|[ƒg‚µ‚È‚¢‚Ì‚Åaccesskey‚ðŽg‚¤
-        if (!$mobile->isType3GC()) {
-            $_conf['accesskey'] = 'DIRECTKEY';
-            // 3GCŒ^’[––‚ÆWŒ^’[––ˆÈŠO‚ÍCookie‚ðƒTƒ|[ƒg‚µ‚È‚¢
-            if (!$mobile->isTypeW()) {
-                $support_cookies = false;
-            }
-        }
-
-    // WILLCOM AIR-EDGE
-    //} elseif ($mobile->isWillcom()) {
-    //    $support_cookies = true;
-
-    // ‚»‚Ì‘¼
-    //} else {
-    //    $support_cookies = true;
+    // 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');
     }
-}
 
-// }}}
-// {{{ ƒNƒGƒŠ[‚É‚æ‚é‹­§ƒrƒ…[Žw’è
+    // ƒRƒ}ƒ“ƒhƒ‰ƒCƒ“ƒc[ƒ‹
+    define('P2_CLI_DIR', $P2_BASE_DIR_S . 'cli');
 
-// b=pc ‚Í‚Ü‚¾ƒŠƒ“ƒNæ‚ªŠ®‘S‚Å‚È‚¢?
-// b=i ‚ÍCSS‚ÅWebKit‚Ì“ÆŽ©Šg’£/æsŽÀ‘•ƒvƒƒpƒeƒB‚𑽗p‚µ‚Ä‚¢‚é
-
-$_conf['b'] = $_conf['client_type'] = ($_conf['iphone'] ? 'i' : ($_conf['ktai'] ? 'k' : 'pc'));
-$_conf['view_forced_by_query'] = false;
-$_conf['k_at_a'] = '';
-$_conf['k_at_q'] = '';
-$_conf['k_input_ht'] = '';
-
-if (isset($_REQUEST['b'])) {
-    switch ($_REQUEST['b']) {
-
-    // ‹­§PCƒrƒ…[Žw’è
-    case 'pc':
-        if ($_conf['b'] != 'pc') {
-            $_conf['b'] = 'pc';
-            $_conf['ktai'] = false;
-            $_conf['iphone'] = false;
-        }
-        break;
-
-    // ‹­§iPhoneƒrƒ…[Žw’è
-    case 'i':
-        if ($_conf['b'] != 'i') {
-            $_conf['b'] = 'i';
-            $_conf['ktai'] = true;
-            $_conf['iphone'] = true;
-        }
-        break;
-
-    // ‹­§Œg‘уrƒ…[Žw’è
-    case 'k':
-        if ($_conf['b'] != 'k') {
-            $_conf['b'] = 'k';
-            $_conf['ktai'] = true;
-            $_conf['iphone'] = false;
-        }
-        break;
-
-    } // endswitch
-
-    // ‹­§ƒrƒ…[Žw’肳‚ê‚Ä‚¢‚½‚È‚ç
-    if ($_conf['b'] != $_conf['client_type']) {
-        $_conf['view_forced_by_query'] = true;
-        $_conf['k_at_a'] = '&amp;b=' . $_conf['b'];
-        $_conf['k_at_q'] = '?b=' . $_conf['b'];
-        $_conf['k_input_ht'] = '<input type="hidden" name="b" value="' . $_conf['b'] . '">';
-        //output_add_rewrite_var('b', $_conf['b']);
+    // ŒŸõƒpƒX‚ðƒZƒbƒg
+    $include_path = '';
+    if (defined('P2_PEAR_HACK_DIR')) {
+        $include_path .= P2_PEAR_HACK_DIR . $PATH_SEP;
     }
-}
-
-// }}}
-// {{{ ƒ†[ƒ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);
+    if (is_dir(P2_PEAR_DIR)) {
+        $include_path .= P2_PEAR_DIR . $PATH_SEP;
     } 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>';
+        $paths = array();
+        foreach (explode($PATH_SEP, get_include_path()) as $dir) {
+            if (is_dir($dir)) {
+                $dir = realpath($dir);
+                if ($dir != P2_BASE_DIR) {
+                    $paths[] = $dir;
+                }
+            }
         }
-        $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Ý’è‚ð“ǂݍž‚Þ
-        require_once $P2_CONF_DIR_S . 'conf_user_def.inc.php';
-
-        // Ý’è‚̍XV
-        if (!array_key_exists('mobile.link_youtube', $conf_user)) {
-            require_once $P2_LIB_DIR_S . 'conf_user_updater.inc.php';
-            $conf_user = conf_user_update_080908($conf_user);
+        if (count($paths)) {
+            $include_path .= implode($PATH_SEP, array_unique($paths)) . $PATH_SEP;
         }
-
-        $_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);
     }
+    $include_path .= P2_BASE_DIR; // fallback
+    set_include_path($include_path);
 
-    unset($cont, $conf_user);
-} else {
-    // ƒfƒtƒHƒ‹ƒgÝ’è‚ð“ǂݍž‚Þ
-    require_once $P2_CONF_DIR_S . 'conf_user_def.inc.php';
-    $_conf = array_merge($_conf, $conf_user_def);
-}
+    $P2_CONF_DIR_S = P2_CONF_DIR . $DIR_SEP;
+    $P2_LIB_DIR_S = P2_LIB_DIR . $DIR_SEP;
 
-// }}}
-// {{{ ƒ†[ƒUÝ’è‚Ì’²®ˆ—
+    // }}}
+    // {{{ ŠÂ‹«ƒ`ƒFƒbƒN‚ƃfƒoƒbƒO
 
-$_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']}\"" : '';
+    // ƒ†[ƒeƒBƒŠƒeƒB‚ð“ǂݍž‚Þ
+    include $P2_LIB_DIR_S . 'P2Util.php';
+    include $P2_LIB_DIR_S . 'p2util.inc.php';
 
-if ($_conf['get_new_res']) {
-    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'];
-    }
-} else {
-    $_conf['get_new_res_l'] = 'l200';
-}
+    // “®ìŠÂ‹«‚ðŠm”F (—vŒ‚ð–ž‚½‚µ‚Ä‚¢‚é‚È‚çƒRƒƒ“ƒgƒAƒEƒg‰Â)
+    p2checkenv(__LINE__);
 
-if ($_conf['expack.user_agent']) {
-    ini_set('user_agent', $_conf['expack.user_agent']);
-}
-
-// }}}
-// {{{ ƒfƒUƒCƒ“Ý’è “Çž
-
-$skin_name = $default_skin_name = 'conf_user_style';
-$skin = $P2_CONF_DIR_S . 'conf_user_style.inc.php';
-if (!$_conf['ktai'] && $_conf['expack.skin.enabled']) {
-    // •Û‘¶‚³‚ê‚Ä‚¢‚éƒXƒLƒ“–¼
-    $saved_skin_name = null;
-    if (file_exists($_conf['expack.skin.setting_path'])) {
-        $saved_skin_name = rtrim(file_get_contents($_conf['expack.skin.setting_path']));
-        if (!preg_match('/^[0-9A-Za-z_\\-]+$/', $saved_skin_name)) {
-            $saved_skin_name = null;
+    if ($debug) {
+        if (!class_exists('Benchmark_Profiler', false)) {
+            require 'Benchmark/Profiler.php';
         }
-    } else {
-        FileCtl::make_datafile($_conf['expack.skin.setting_path'], $_conf['expack.skin.setting_perm']);
+        $profiler = new Benchmark_Profiler(true);
+        // print_memory_usage();
+        register_shutdown_function('print_memory_usage');
     }
 
-    // ƒŠƒNƒGƒXƒg‚ÅŽw’肳‚ꂽƒXƒLƒ“–¼
-    $new_skin_name = null;
-    if (array_key_exists('skin', $_REQUEST) && is_string($_REQUEST['skin'])) {
-        $new_skin_name = $_REQUEST['skin'];
-        if (!preg_match('/^[0-9A-Za-z_\\-]+$/', $new_skin_name)) {
-            $new_skin_name = null;
-        } elseif ($new_skin_name != $saved_skin_name) {
-            FileCtl::file_write_contents($_conf['expack.skin.setting_path'], $new_skin_name);
-        }
-    }
+    // }}}
+    // {{{ •¶ŽšƒR[ƒh‚ÌŽw’è
 
-    // ƒŠƒNƒGƒXƒg‚ÅŽw’肳‚ꂽˆêŽžƒXƒLƒ“–¼
-    $tmp_skin_name = null;
-    if (array_key_exists('tmp_skin', $_REQUEST) && is_string($_REQUEST['tmp_skin'])) {
-        $tmp_skin_name = $_REQUEST['tmp_skin'];
-        if (!preg_match('/^[0-9A-Za-z_\\-]+$/', $tmp_skin_name)) {
-            $tmp_skin_name = null;
-        }
-    }
+    //mb_detect_order("CP932,CP51932,ASCII");
+    mb_internal_encoding('CP932');
+    mb_http_output('pass');
+    mb_substitute_character(63); // •¶ŽšƒR[ƒh•ÏŠ·‚ÉŽ¸”s‚µ‚½•¶Žš‚ª "?" ‚É‚È‚é
+    //mb_substitute_character(0x3013); // ¬
+    //ob_start('mb_output_handler');
 
-    // ƒXƒLƒ“ŒŸõ
-    foreach (array($tmp_skin_name, $new_skin_name, $saved_skin_name, $default_skin_name) as $skin_name) {
-        if ($skin_name !== null) {
-            if ($skin_name == $default_skin_name) {
-                break;
-            }
-            $user_skin_path = P2_USER_SKIN_DIR . DIRECTORY_SEPARATOR . $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';
-            if (file_exists($bundled_skin_path)) {
-                $skin = $bundled_skin_path;
-                break;
-            }
-        }
+    if (function_exists('mb_ereg_replace')) {
+        define('P2_MBREGEX_AVAILABLE', 1);
+        mb_regex_encoding('CP932');
+    } else {
+        define('P2_MBREGEX_AVAILABLE', 0);
     }
-}
 
-if (!file_exists($skin)) {
-    $skin_name = 'conf_user_style';
-    $skin = $P2_CONF_DIR_S . 'conf_user_style.inc.php';
-}
-$skin_en = rawurlencode($skin_name) . '&amp;_=' . P2_VERSION_ID;
-if ($_conf['view_forced_by_query']) {
-    $skin_en .= $_conf['k_at_a'];
-}
+    // }}}
+    // {{{ ŠÇ—ŽÒ—pÝ’èetc.
 
-// ƒfƒtƒHƒ‹ƒgÝ’è‚ð“ǂݍž‚ñ‚Å
-include $P2_CONF_DIR_S . 'conf_user_style.inc.php';
-// ƒXƒLƒ“‚ŏ㏑‚«
-if ($skin != $P2_CONF_DIR_S . 'conf_user_style.inc.php') {
-    include $skin;
-}
+    // ŠÇ—ŽÒ—pÝ’è‚ð“ǂݍž‚Ý
+    include $P2_CONF_DIR_S . 'conf_admin.inc.php';
 
-// }}}
-// {{{ ƒfƒUƒCƒ“Ý’è‚Ì’²®ˆ—
+    // ƒfƒBƒŒƒNƒgƒŠ‚̐â‘΃pƒX‰»
+    $_conf['data_dir'] = p2_realpath($_conf['data_dir']);
+    $_conf['dat_dir']  = p2_realpath($_conf['dat_dir']);
+    $_conf['idx_dir']  = p2_realpath($_conf['idx_dir']);
+    $_conf['pref_dir'] = p2_realpath($_conf['pref_dir']);
 
-$skin_uniq = P2_VERSION_ID;
+    // ŠÇ——p•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
+    $_conf['admin_dir'] = $_conf['data_dir'] . $DIR_SEP . 'admin';
 
-foreach ($STYLE as $K => $V) {
-    if (empty($V)) {
-        $STYLE[$K] = '';
-    } elseif (strpos($K, 'fontfamily') !== false) {
-        $STYLE[$K] = p2_correct_css_fontfamily($V);
-    } elseif (strpos($K, 'color') !== false) {
-        $STYLE[$K] = p2_correct_css_color($V);
-    } elseif (strpos($K, 'background') !== false) {
-        $STYLE[$K] = "url('" . p2_escape_css_url($V) . "')";
-    }
-}
+    // cache •Û‘¶ƒfƒBƒŒƒNƒgƒŠ
+    // 2005/06/29 $_conf['pref_dir'] . '/p2_cache' ‚æ‚è•ÏX
+    $_conf['cache_dir'] = $_conf['data_dir'] . $DIR_SEP . 'cache';
 
-if (!$_conf['ktai']) {
-    require_once $P2_LIB_DIR_S . 'fontconfig.inc.php';
+    // Cookie •Û‘¶ƒfƒBƒŒƒNƒgƒŠ
+    // 2008/09/09 $_conf['pref_dir'] . '/p2_cookie' ‚æ‚è•ÏX
+    $_conf['cookie_dir'] = $_conf['data_dir'] . $DIR_SEP . 'cookie';
 
-    if ($_conf['expack.am.enabled']) {
-        $_conf['expack.am.fontfamily'] = p2_correct_css_fontfamily($_conf['expack.am.fontfamily']);
-        if ($STYLE['fontfamily']) {
-            $_conf['expack.am.fontfamily'] .= '","' . $STYLE['fontfamily'];
-        }
-    }
+    // ƒRƒ“ƒpƒCƒ‹‚³‚ꂽƒeƒ“ƒvƒŒ[ƒg‚Ì•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
+    $_conf['compile_dir'] = $_conf['data_dir'] . $DIR_SEP . 'compile';
 
-    fontconfig_apply_custom();
-}
+    // ƒZƒbƒVƒ‡ƒ“ƒf[ƒ^•Û‘¶ƒfƒBƒŒƒNƒgƒŠ
+    $_conf['session_dir'] = $_conf['data_dir'] . $DIR_SEP . 'session';
 
-// }}}
-// {{{ Œg‘сEiPhone—p•Ï”
+    // ƒeƒ“ƒ|ƒ‰ƒŠƒfƒBƒŒƒNƒgƒŠ
+    $_conf['tmp_dir'] = $_conf['data_dir'] . $DIR_SEP . 'tmp';
 
-// iPhone—pHTMLƒwƒbƒ_—v‘f
-if ($_conf['client_type'] == 'i') {
-    switch ($_conf['b']) {
+    // ƒo[ƒWƒ‡ƒ“ID‚ð“ñdˆø—p•„‚âƒqƒAƒhƒLƒ…ƒƒ“ƒg“à‚É–„‚ߍž‚Þ‚½‚߂̕ϐ”
+    $_conf['p2_version_id'] = P2_VERSION_ID;
 
-    // ‹­§PCƒrƒ…[Žž
-    case 'pc':
-        $_conf['extra_headers_ht'] .= <<<EOS
-<meta name="format-detection" content="telephone=no">
-<link rel="apple-touch-icon" type="image/png" href="img/touch-icon/p2-serif.png">
-<style type="text/css">body { -webkit-text-size-adjust: none; }</style>
-EOS;
-        break;
+    // •¶ŽšƒR[ƒhŽ©“®”»’è—p‚̃qƒ“ƒg•¶Žš—ñ
+    $_conf['detect_hint'] = 'ž';
+    $_conf['detect_hint_input_ht'] = '<input type="hidden" name="_hint" value="ž">';
+    $_conf['detect_hint_input_xht'] = '<input type="hidden" name="_hint" value="ž" />';
+    //$_conf['detect_hint_utf8'] = mb_convert_encoding('ž', 'UTF-8', 'CP932');
+    $_conf['detect_hint_q'] = '_hint=%81%9D%81%9E'; // rawurlencode($_conf['detect_hint'])
+    $_conf['detect_hint_q_utf8'] = '_hint=%E2%97%8E%E2%97%87'; // rawurlencode($_conf['detect_hint_utf8'])
 
-    // ‹­§Œg‘уrƒ…[Žž
-    case 'k':
-        $_conf['extra_headers_ht'] .= <<<EOS
-<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes">
-<meta name="format-detection" content="telephone=no">
-<link rel="apple-touch-icon" type="image/png" href="img/touch-icon/p2-serif.png">
-<style type="text/css">
-body { word-break: normal; word-break: break-all; -webkit-text-size-adjust: none; }
-* { font-family: sans-serif; font-size: medium; line-height: 150%; }
-h1 { font-size: xx-large; }
-h2 { font-size: x-large; }
-h3 { font-size: large; }
-</style>
-EOS;
-        break;
+    // }}}
+    // {{{ •Ï”Ý’è
 
-    // ƒ³iPhoneƒrƒ…[
-    case 'i':
-    default:
-        $_conf['extra_headers_ht'] .= <<<EOS
-<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes">
-<meta name="format-detection" content="telephone=no">
-<link rel="apple-touch-icon" type="image/png" href="img/touch-icon/p2-serif.png">
-<link rel="stylesheet" type="text/css" media="screen" href="css/iphone.css?{$_conf['p2_version_id']}">
-<script type="text/javascript" src="js/iphone.js?{$_conf['p2_version_id']}"></script>
-EOS;
+    $pref_dir_s = $_conf['pref_dir'] . $DIR_SEP;
 
-    } // endswitch
+    $_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)
 
-// ‹­§iPhoneƒrƒ…[Žž
-} elseif ($_conf['iphone']) {
-    $_conf['extra_headers_ht'] .= <<<EOS
-<link rel="stylesheet" type="text/css" media="screen" href="css/iphone.css?{$_conf['p2_version_id']}">
-<script type="text/javascript" src="js/iphone.js?{$_conf['p2_version_id']}"></script>
-EOS;
-}
+    $_conf['matome_cache_path'] = $pref_dir_s . 'matome_cache';
+    $_conf['matome_cache_ext']  = '.htm';
+    $_conf['matome_cache_max']  = 3; // —\”õƒLƒƒƒbƒVƒ…‚̐”
 
-// iPhone—pƒXƒLƒ“
-if ($_conf['iphone'] && isset($_conf['expack.iphone.skin'])) {
-    if (strpos($_conf['expack.iphone.skin'], DIRECTORY_SEPARATOR) === false) {
-        $iskin = 'skin/iphone/' . $iskin . '.css';
-        if (file_exists($iskin)) {
-            $iskin_mtime = filemtime($iskin);
-            $_conf['extra_headers_ht'] .= <<<EOS
-<link rel="stylesheet" type="text/css" media="screen" href="{$iskin}?{$iskin_mtime}">
-EOS;
-        }
-    }
-}
+    $_conf['orig_favita_brd']   = $_conf['favita_brd'];
+    $_conf['orig_favlist_idx']  = $_conf['favlist_idx'];
 
-// Œg‘Ñ—puƒgƒbƒv‚É–ß‚évƒŠƒ“ƒN‚Æaccesskey
-if ($_conf['ktai']) {
-    // iPhone
-    if ($_conf['iphone']) {
-        $_conf['k_accesskey_at'] = array_fill(0, 10, '');
-        $_conf['k_accesskey_at']['*'] = '';
-        $_conf['k_accesskey_at']['#'] = '';
-        foreach ($_conf['k_accesskey'] as $name => $key) {
-            $_conf['k_accesskey_at'][$name] = '';
-        }
+    $_conf['cookie_file_path']  = $_conf['cookie_dir'] . $DIR_SEP . 'p2_cookies.sqlite3';
 
-        $_conf['k_accesskey_st'] = $_conf['k_accesskey_at'];
-
-        $_conf['k_to_index_ht'] = <<<EOP
-<a href="index.php{$_conf['k_at_q']}" class="button">TOP</a>
-EOP;
-
-    // ‚»‚Ì‘¼
-    } else {
-        // SoftBank Mobile
-        if ($_conf['accesskey'] == 'DIRECTKEY') {
-            $_conf['k_accesskey_at'] = array(
-                '0' => ' directkey="0" nonumber',
-                '1' => ' directkey="1" nonumber',
-                '2' => ' directkey="2" nonumber',
-                '3' => ' directkey="3" nonumber',
-                '4' => ' directkey="4" nonumber',
-                '5' => ' directkey="5" nonumber',
-                '6' => ' directkey="6" nonumber',
-                '7' => ' directkey="7" nonumber',
-                '8' => ' directkey="8" nonumber',
-                '9' => ' directkey="9" nonumber',
-                '*' => ' directkey="*" nonumber',
-                '#' => ' directkey="#" nonumber',
-            );
-
-        // ‚»‚Ì‘¼
-        } else {
-            $_conf['k_accesskey_at'] = array(
-                '0' => ' accesskey="0"',
-                '1' => ' accesskey="1"',
-                '2' => ' accesskey="2"',
-                '3' => ' accesskey="3"',
-                '4' => ' accesskey="4"',
-                '5' => ' accesskey="5"',
-                '6' => ' accesskey="6"',
-                '7' => ' accesskey="7"',
-                '8' => ' accesskey="8"',
-                '9' => ' accesskey="9"',
-                '*' => ' accesskey="*"',
-                '#' => ' accesskey="#"',
-            );
+    // •â³
+    if ($_conf['expack.use_pecl_http'] && !extension_loaded('http')) {
+        if (!($_conf['expack.use_pecl_http'] == 2 && $_conf['expack.dl_pecl_http'])) {
+            $_conf['expack.use_pecl_http'] = 0;
         }
-
-        switch ($_conf['mobile.display_accesskey']) {
-        case 2:
-            require_once $P2_LIB_DIR_S . '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'));
-            $_conf['k_accesskey_st'] = array(
-                '0' => $emoji[0],
-                '1' => $emoji[1],
-                '2' => $emoji[2],
-                '3' => $emoji[3],
-                '4' => $emoji[4],
-                '5' => $emoji[5],
-                '6' => $emoji[6],
-                '7' => $emoji[7],
-                '8' => $emoji[8],
-                '9' => $emoji[9],
-                '*' => $emoji['*'],
-                '#' => $emoji['#'],
-            );
-            break;
-        case 0:
-            $_conf['k_accesskey_st'] = array_fill(0, 10, '');
-            $_conf['k_accesskey_st']['*'] = '';
-            $_conf['k_accesskey_st']['#'] = '';
-            break;
-        case 1:
-        default:
-            $_conf['k_accesskey_st'] = array(
-                0 => '0.', 1 => '1.', 2 => '2.', 3 => '3.', 4 => '4.',
-                5 => '5.', 6 => '6.', 7 => '7.', 8 => '8.', 9 => '9.',
-                '*' => '*.', '#' => '#.'
-            );
-        }
-
-        foreach ($_conf['k_accesskey'] as $name => $key) {
-            $_conf['k_accesskey_at'][$name] = $_conf['k_accesskey_at'][$key];
-            $_conf['k_accesskey_st'][$name] = $_conf['k_accesskey_st'][$key];
-        }
-
-        $_conf['k_to_index_ht'] = <<<EOP
-<a href="index.php{$_conf['k_at_q']}"{$_conf['k_accesskey_at'][0]}>{$_conf['k_accesskey_st'][0]}TOP</a>
-EOP;
     }
-}
 
-// }}}
-// {{{ Œg‘Ñ—pƒJƒ‰[ƒŠƒ“ƒO‚Ì’²®ˆ—
-
-$_conf['k_colors'] = '';
-
-if ($_conf['ktai']) {
-    // Šî–{F
-    if (!$_conf['iphone']) {
-        if ($_conf['mobile.background_color']) {
-            $_conf['k_colors'] .= ' bgcolor="' . htmlspecialchars($_conf['mobile.background_color']) . '"';
-        }
-        if ($_conf['mobile.text_color']) {
-            $_conf['k_colors'] .= ' text="' . htmlspecialchars($_conf['mobile.text_color']) . '"';
-        }
-        if ($_conf['mobile.link_color']) {
-            $_conf['k_colors'] .= ' link="' . htmlspecialchars($_conf['mobile.link_color']) . '"';
-        }
-        if ($_conf['mobile.vlink_color']) {
-            $_conf['k_colors'] .= ' vlink="' . htmlspecialchars($_conf['mobile.vlink_color']) . '"';
-        }
+    // ƒRƒ}ƒ“ƒhƒ‰ƒCƒ“ƒ‚[ƒh‚Å‚Í‚±‚±‚Ü‚Å
+    if (defined('P2_CLI_RUN')) {
+        return;
     }
 
-    // •¶ŽšF
-    if ($_conf['mobile.newthre_color']) {
-        $STYLE['mobile_subject_newthre_color'] = htmlspecialchars($_conf['mobile.newthre_color']);
-    }
-    if ($_conf['mobile.newres_color']) {
-        $STYLE['mobile_read_newres_color']    = htmlspecialchars($_conf['mobile.newres_color']);
-        $STYLE['mobile_subject_newres_color'] = htmlspecialchars($_conf['mobile.newres_color']);
-    }
-    if ($_conf['mobile.ttitle_color']) {
-        $STYLE['mobile_read_ttitle_color'] = htmlspecialchars($_conf['mobile.ttitle_color']);
-    }
-    if ($_conf['mobile.ngword_color']) {
-        $STYLE['mobile_read_ngword_color'] = htmlspecialchars($_conf['mobile.ngword_color']);
-    }
-    if ($_conf['mobile.onthefly_color']) {
-        $STYLE['mobile_read_onthefly_color'] = htmlspecialchars($_conf['mobile.onthefly_color']);
-    }
+    // }}}
 
-    // ƒ}[ƒJ[
-    if ($_conf['mobile.match_color']) {
-        if ($_conf['iphone']) {
-            $_conf['extra_headers_ht'] .= sprintf('<style type="text/css">b.filtering, span.matched { color: %s; }</style>',
-                                                  htmlspecialchars($_conf['mobile.match_color']));
-            $_conf['k_filter_marker'] = '<span class="matched">\\1</span>';
-        } else {
-            $_conf['k_filter_marker'] = '<font color="' . htmlspecialchars($_conf['mobile.match_color']) . '">\\1</font>';
-        }
-    } else {
-        $_conf['k_filter_marker'] = false;
-    }
+    include $P2_LIB_DIR_S . 'bootstrap.php';
 }
 
 // }}}
-// {{{ ƒZƒbƒVƒ‡ƒ“
-
-// –¼‘O‚́AƒZƒbƒVƒ‡ƒ“ƒNƒbƒL[‚ð”jŠü‚·‚é‚Æ‚«‚Ì‚½‚߂ɁAƒZƒbƒVƒ‡ƒ“—˜—p‚Ì—L–³‚ÉŠÖ‚í‚炸Ý’è‚·‚é
-session_name('PS');
-
-$_conf['sid_at_a'] = '';
-
-require_once $P2_LIB_DIR_S . 'Session.php';
-
-// {{{ ƒZƒbƒVƒ‡ƒ“ƒf[ƒ^•Û‘¶ƒfƒBƒŒƒNƒgƒŠ‚ðƒ`ƒFƒbƒN
-
-if ($_conf['session_save'] == 'p2' and session_module_name() == 'files') {
-    if (!is_dir($_conf['session_dir'])) {
-        FileCtl::mkdir_r($_conf['session_dir']);
-    } elseif (!is_writable($_conf['session_dir'])) {
-        p2die("ƒZƒbƒVƒ‡ƒ“ƒf[ƒ^•Û‘¶ƒfƒBƒŒƒNƒgƒŠ ({$_conf['session_dir']}) ‚ɏ‘‚«ž‚ÝŒ ŒÀ‚ª‚ ‚è‚Ü‚¹‚ñB");
-    }
-
-    session_save_path($_conf['session_dir']);
-}
-
-// }}}
-
-$_p2session = new Session(null, null, $support_cookies);
-
-// }}}
-// {{{ ‚¨‹C‚ɃZƒbƒg
-
-// •¡”‚Ì‚¨‹C‚ɃZƒbƒg‚ðŽg‚¤‚Æ‚«
-if ($_conf['expack.misc.multi_favs']) {
-    if (!class_exists('FavSetManager', false)) {
-        include $P2_LIB_DIR_S . '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']     = '';
-}
-
-// }}}
-// {{{ misc.
-
-// DOCTYPE HTML éŒ¾
-$_conf['doctype'] = '';
-$ie_strict = false;
-if (!$_conf['ktai'] || $_conf['client_type'] != 'k') {
-    if ($ie_strict || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') === false) {
-        $_conf['doctype'] = <<<EODOC
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-        "http://www.w3.org/TR/html4/loose.dtd">\n
-EODOC;
-    } else {
-        $_conf['doctype'] = <<<EODOC
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n
-EODOC;
-    }
-}
-
-// XHTMLƒwƒbƒ_—v‘f
-if (defined('P2_OUTPUT_XHTML')) {
-    $_conf['extra_headers_xht'] = preg_replace('/<((?:link|meta) .+?)>/', '<\\1 />', $_conf['extra_headers_ht']);
-}
-
-// ƒƒOƒCƒ“ƒNƒ‰ƒX‚̃Cƒ“ƒXƒ^ƒ“ƒX¶¬iƒƒOƒCƒ“ƒ†[ƒU‚ªŽw’肳‚ê‚Ä‚¢‚È‚¯‚ê‚΁A‚±‚ÌŽž“_‚эƒOƒCƒ“ƒtƒH[ƒ€•\Ž¦‚Ɂj
-require_once $P2_LIB_DIR_S . 'Login.php';
-$_login = new Login();
-
-// ‚¨‚Ü‚¶‚È‚¢
-//$a = ceil(1/2);
-//$b = floor(1/3);
-//$c = round(1/4, 1);
-
-// }}}
-}
-
-// }}}
 // {{{ p2checkenv()
 
 /**
@@ -1039,6 +357,19 @@
     $required_version = '5.2.8';
     $recommended_version52 = '5.2.12';
     $recommended_version53 = '5.3.1';
+    $required_extensions = array(
+        'dom',
+        'json',
+        'libxml',
+        'mbstring',
+        'pcre',
+        'pdo',
+        'pdo_sqlite',
+        'session',
+        'spl',
+        //'xsl',
+        'zlib',
+    );
 
     // PHP‚̃o[ƒWƒ‡ƒ“
     if (version_compare($php_version, $required_version, '<')) {
@@ -1046,7 +377,7 @@
     }
 
     // •K{Šg’£ƒ‚ƒWƒ…[ƒ‹
-    foreach (array('json', 'mbstring', 'pcre', 'pdo', 'pdo_sqlite', 'session', 'zlib') as $ext) {
+    foreach ($required_extensions as $ext) {
         if (!extension_loaded($ext)) {
             p2die("{$ext} Šg’£ƒ‚ƒWƒ…[ƒ‹‚ªƒ[ƒh‚³‚ê‚Ä‚¢‚Ü‚¹‚ñB");
         }
@@ -1067,7 +398,9 @@
     }
 
     // eAccelerator
-    if (extension_loaded('eaccelerator') && version_compare(EACCELERATOR_VERSION, '0.9.5.2', '<')) {
+    if (extension_loaded('eaccelerator') &&
+        version_compare(EACCELERATOR_VERSION, '0.9.5.2', '<'))
+    {
         $err = 'eAccelerator‚ðXV‚µ‚Ä‚­‚¾‚³‚¢B';
         $ev = EACCELERATOR_VERSION;
         $msg = <<<EOP
@@ -1103,21 +436,7 @@
 }
 
 // }}}
-// {{{ __autoload()
 
-/**
- * PEAR‚Å‘æ2ˆø”‚ðfalse‚É‚¹‚¸‚Éclass_exists()‚ð“Ç‚ñ‚Å‚¢‚é‰Â”\«‚ª‚ ‚é‚Ì‚Å
- * __autoload()‚ðŽg‚¤‚Ì‚Í•|‚¢
- */
-/*function __autoload($name)
-{
-    if (preg_match('/^[A-Za-z_][0-9A-Za-z_]*$/', $name)) {
-        require_once str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php';
-    }
-}*/
-
-// }}}
-
 /*
  * Local Variables:
  * mode: php

Modified: p2ex/trunk/conf/conf_admin.inc.php
===================================================================
--- p2ex/trunk/conf/conf_admin.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/conf/conf_admin.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -135,7 +135,7 @@
 // ----------------------------------------------------------------------
 // {{{ Šg’£ƒpƒbƒN
 
-require_once P2_CONF_DIR . '/conf_admin_ex.inc.php';
+include P2_CONF_DIR . '/conf_admin_ex.inc.php';
 
 // }}}
 

Modified: p2ex/trunk/conf/ip_emobile.php
===================================================================
--- p2ex/trunk/conf/ip_emobile.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/conf/ip_emobile.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -10,12 +10,14 @@
  * @link http://whois.nic.ad.jp/cgi-bin/whois_gw
  */
 
-$host = '/\\.pool\\.e(?:mnet|-?mobile)\\.ne\\.jp$/';
+$host = '/\\.pool\\.e(?:mnet|-mobile)\\.ne\\.jp$/';
 
 $band = array(
     '60.254.192.0/18',      // JPNIC Whois Gateway
+    '114.48.0.0/14',        // JPNIC Whois Gateway
     '117.55.0.0/17',        // JPNIC Whois Gateway
     //'117.55.1.224/27',    // http://developer.emnet.ne.jp/ipaddress.html
+    '119.72.0.0/16',        // JPNIC Whois Gateway
 );
 
 /*

Modified: p2ex/trunk/css/iphone.css
===================================================================
--- p2ex/trunk/css/iphone.css	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/css/iphone.css	2010-01-09 16:57:35 UTC (rev 767)
@@ -223,7 +223,7 @@
 div.res.aborned {
 	margin: 0;
 	padding: 0;
-	fonr-size: xx-small;
+	font-size: xx-small;
 	line-height: 100%;
 }
 

Modified: p2ex/trunk/edit_user_font.php
===================================================================
--- p2ex/trunk/edit_user_font.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/edit_user_font.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -48,7 +48,6 @@
         $current_fontconfig = array('enabled' => false, 'custom' => array());
     }
 } else {
-    require_once P2_LIB_DIR . '/FileCtl.php';
     FileCtl::make_datafile($_conf['expack.skin.fontconfig_path'], $_conf['expack.skin.fontconfig_perm']);
     $current_fontconfig = array('enabled' => false, 'custom' => array());
 }

Modified: p2ex/trunk/info_js.php
===================================================================
--- p2ex/trunk/info_js.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/info_js.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -4,7 +4,6 @@
  */
 
 require_once './conf/conf.inc.php';
-require_once P2_LIB_DIR . '/P2Util.php';
 require_once P2_LIB_DIR . '/Thread.php';
 
 $_login->authorize(); // ƒ†[ƒU”FØ

Modified: p2ex/trunk/lib/BbsMap.php
===================================================================
--- p2ex/trunk/lib/BbsMap.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/BbsMap.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -1,6 +1,4 @@
 <?php
-require_once P2_LIB_DIR . '/P2Util.php';
-require_once P2_LIB_DIR . '/FileCtl.php';
 
 // {{{ BbsMap
 

Modified: p2ex/trunk/lib/BrdCtl.php
===================================================================
--- p2ex/trunk/lib/BrdCtl.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/BrdCtl.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -1,6 +1,5 @@
 <?php
 
-require_once P2_LIB_DIR . '/FileCtl.php';
 require_once P2_LIB_DIR . '/BrdMenu.php';
 
 // {{{ BrdCtl

Modified: p2ex/trunk/lib/BrdMenu.php
===================================================================
--- p2ex/trunk/lib/BrdMenu.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/BrdMenu.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -1,7 +1,5 @@
 <?php
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ BrdMenu
 
 /**

Modified: p2ex/trunk/lib/HostCheck.php
===================================================================
--- p2ex/trunk/lib/HostCheck.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/HostCheck.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -2,7 +2,6 @@
 // ƒAƒNƒZƒXŒ³ƒzƒXƒg‚ðƒ`ƒFƒbƒN‚·‚éŠÖ”ŒQƒNƒ‰ƒX
 
 require_once P2_CONF_DIR . '/conf_hostcheck.php';
-require_once P2_LIB_DIR . '/FileCtl.php';
 require_once P2_LIB_DIR . '/P2KeyValueStore.php';
 
 // {{{ HostCheck

Modified: p2ex/trunk/lib/Login.php
===================================================================
--- p2ex/trunk/lib/Login.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/Login.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -1,6 +1,5 @@
 <?php
 
-require_once P2_LIB_DIR . '/FileCtl.php';
 require_once P2_LIB_DIR . '/Session.php';
 
 // {{{ Login

Modified: p2ex/trunk/lib/P2Client.php
===================================================================
--- p2ex/trunk/lib/P2Client.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/P2Client.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -15,7 +15,7 @@
     /**
      * Cookie‚ð•Û‘¶‚·‚éSQLite3ƒf[ƒ^ƒx[ƒX‚̃tƒ@ƒCƒ‹–¼
      */
-    const COOKIE_STORE_NAME = 'p2_2ch_net_cookie.sq3';
+    const COOKIE_STORE_NAME = 'p2_2ch_net_cookies.sqlite3';
 
     /**
      * ŒöŽ®P2‚ÌURI‚ÆŠeƒGƒ“ƒgƒŠƒ|ƒCƒ“ƒg
@@ -53,6 +53,7 @@
      * HTTPƒŠƒNƒGƒXƒg‚̌Œèƒpƒ‰ƒ[ƒ^
      */
     const REQUEST_DATA_CHARACTER_SET_DETECTION_HINT = 'ž';
+    const REQUEST_DATA_LS_LAST1_NO_FIRST = 'l1n';
 
     /**
      * “ǂݍž‚ݐ³”Û”»’è‚Ì‚½‚ß‚Ì•¶Žš—ñ
@@ -135,6 +136,7 @@
 
         if ($cookieManager = $cookieStore->get($loginId)) {
             if (!$cookieManager instanceof HTTP_Client_CookieManager) {
+                $cookieStore->delete($loginId);
                 throw new Exception('Cannot restore the cookie manager.');
             }
         } else {
@@ -236,12 +238,7 @@
      */
     public function readThread($host, $bbs, $key, $ls = '1', &$response = null)
     {
-        $getData = array(
-            self::REQUEST_PARAMETER_HOST => rawurlencode($host),
-            self::REQUEST_PARAMETER_BBS  => rawurlencode($bbs),
-            self::REQUEST_PARAMETER_KEY  => rawurlencode($key),
-            self::REQUEST_PARAMETER_LS   => rawurlencode($ls),
-        );
+        $getData = $this->setupGetData($host, $bbs, $key, $ls);
         $uri = self::P2_ROOT_URI . self::SCRIPT_NAME_READ;
         $response = $this->httpGet($uri, $getData, true);
         $dom = new P2DOM($response['body']);
@@ -280,7 +277,9 @@
         // ƒXƒŒƒbƒh‚Ì—L–³‚ðŠm‚©‚߂邽‚߁A‚Ü‚¸ read.php ‚ð’@‚­B
         // dat—Ž‚¿Œã‚ɃzƒXƒg‚ªˆÚ“]‚µ‚½ê‡AˆÚ“]Œã‚̃zƒXƒg–¼‚ŃAƒNƒZƒX‚µ‚Ä‚à
         // ƒXƒŒƒbƒhî•ñ‚ðŽæ“¾‚Å‚«‚È‚©‚Á‚½‚Ƃ̃ƒbƒZ[ƒW‚ª•\Ž¦‚³‚ê‚éB
-        $html = $this->readThread($host, $bbs, $key, 'l1n', $response);
+        $html = $this->readThread($host, $bbs, $key,
+                                  self::REQUEST_DATA_LS_LAST1_NO_FIRST,
+                                  $response);
         if ($html === null) {
             return null;
         }
@@ -300,11 +299,7 @@
         }
 
         // dat‚ðŽæ“¾‚·‚éB
-        $getData = array(
-            self::REQUEST_PARAMETER_HOST => rawurlencode($host),
-            self::REQUEST_PARAMETER_BBS  => rawurlencode($bbs),
-            self::REQUEST_PARAMETER_KEY  => rawurlencode($key),
-        );
+        $getData = $this->setupGetData($host, $bbs, $key);
         $uri = self::P2_ROOT_URI . self::SCRIPT_NAME_DAT;
         $response = $this->httpGet($uri, $getData, true);
 
@@ -338,7 +333,9 @@
         // csrfId‚ðŽæ“¾‚µA‚©‚ÂŒöŽ®p2‚ÌŠù“Ç‚ðÅV‚̏ó‘Ô‚É‚·‚邽‚߁A‚Ü‚¸ read.php ‚ð’@‚­B
         // ’ʐM—Ê‚ðß–ñ‚Å‚«‚é‚悤‚É ls=l1n ‚Æ‚µ‚Ä‚¢‚éB
         // popup=1 ‚͏‘‚«ž‚ÝŒã‚̃y[ƒW‚ɃŠƒ_ƒCƒŒƒNƒg‚³‚¹‚È‚¢‚½‚߁B
-        $html = $this->readThread($host, $bbs, $key, 'l1n', $response);
+        $html = $this->readThread($host, $bbs, $key,
+                                  self::REQUEST_DATA_LS_LAST1_NO_FIRST,
+                                  $response);
         if ($html === null) {
             return false;
         }
@@ -349,21 +346,8 @@
             throw new P2Exception('Post form not found.');
         }
 
-        $uri = self::P2_ROOT_URI . self::SCRIPT_NAME_POST;
-
-        // CookieŠm”FŒã‚ÌPOST‚Å‚Ì•¶Žš‰»‚¯—\–h‚Ì‚½‚ß
-        // URLƒGƒ“ƒR[ƒhÏ‚Ý‚Ì’l‚ð—pˆÓ‚µ‚Ä‚¨‚¢‚čđã“ü‚·‚éB
-        $hintEncoded = rawurlencode(self::REQUEST_DATA_CHARACTER_SET_DETECTION_HINT);
-        $nameEncoded = rawurlencode($name);
-        $mailEncoded = rawurlencode($mail);
-        $messageEncoded = rawurlencode($message);
-
         // POST‚·‚éƒf[ƒ^‚ð—pˆÓB
-        $postData = $this->getFormValues($dom, $form);
-        $postData[self::REQUEST_PARAMETER_CHARACTER_SET_DETECTION_HINT] = $hintEncoded;
-        $postData[self::REQUEST_PARAMETER_NAME] = $nameEncoded;
-        $postData[self::REQUEST_PARAMETER_MAIL] = $mailEncoded;
-        $postData[self::REQUEST_PARAMETER_MESSAGE] = $messageEncoded;
+        $postData = $this->setupPostData($dom, $form, $name, $mail, $message);
         $postData[self::REQUEST_PARAMETER_POPUP] = '1';
         if ($beRes) {
             $postData[self::REQUEST_PARAMETER_BERES] = '1';
@@ -372,6 +356,7 @@
         }
 
         // POSTŽÀsB
+        $uri = self::P2_ROOT_URI . self::SCRIPT_NAME_POST;
         $response = $this->httpPost($uri, $postData, true);
 
         // CookieŠm”F‚̏ꍇ‚͍ÄPOSTB
@@ -383,11 +368,7 @@
             $expression = './/form[contains(@action, "' . self::SCRIPT_NAME_POST . '")]';
             $result = $dom->query($expression);
             if ($result instanceof DOMNodeList && $result->length > 0) {
-                $postData = $this->getFormValues($dom, $result->item(0));
-                $postData[self::REQUEST_PARAMETER_CHARACTER_SET_DETECTION_HINT] = $hintEncoded;
-                $postData[self::REQUEST_PARAMETER_NAME] = $nameEncoded;
-                $postData[self::REQUEST_PARAMETER_MAIL] = $mailEncoded;
-                $postData[self::REQUEST_PARAMETER_MESSAGE] = $messageEncoded;
+                $postData = $this->setupPostData($dom, $result->item(0), $name, $mail, $message);
                 $response = $this->httpPost($uri, $postData, true);
             } else {
                 return false;
@@ -516,6 +497,58 @@
     }
 
     // }}}
+    // {{{ setupGetData()
+
+    /**
+     * ƒXƒŒƒbƒh‚ð“Ç‚Þ‚½‚ß‚Ì‹¤’ʃpƒ‰ƒ[ƒ^‚Ì”z—ñ‚𐶐¬‚·‚é
+     *
+     * @param string $host
+     * @param string $bbs
+     * @param string $key
+     * @return array
+     */
+    protected function setupGetData($host, $bbs, $key, $ls = null)
+    {
+        $data = array(
+            self::REQUEST_PARAMETER_HOST => rawurlencode($host),
+            self::REQUEST_PARAMETER_BBS => rawurlencode($bbs),
+            self::REQUEST_PARAMETER_KEY => rawurlencode($key),
+        );
+        if ($ls !== null) {
+            $data[self::REQUEST_PARAMETER_LS] = rawurlencode($ls);
+        }
+
+        return $data;
+    }
+
+    // }}}
+    // {{{ setupPostData()
+
+    /**
+     * ƒXƒŒƒbƒh‚ɏ‘‚«ž‚Þ‚½‚ß‚Ì‹¤’ʃpƒ‰ƒ[ƒ^‚Ì”z—ñ‚𐶐¬‚·‚é
+     *
+     * @param P2DOM $dom
+     * @param DOMElement $form
+     * @param string $key
+     * @param string $name
+     * @param string $mail
+     * @param string $message
+     * @return array
+     */
+    protected function setupPostData(P2DOM $dom, DOMElement $form,
+                                     $name, $mail, $message)
+    {
+        $data = $this->getFormValues($dom, $form);
+        $data[self::REQUEST_PARAMETER_CHARACTER_SET_DETECTION_HINT] =
+            rawurlencode(self::REQUEST_DATA_CHARACTER_SET_DETECTION_HINT);
+        $data[self::REQUEST_PARAMETER_NAME] = rawurlencode($name);
+        $data[self::REQUEST_PARAMETER_MAIL] = rawurlencode($mail);
+        $data[self::REQUEST_PARAMETER_MESSAGE] = rawurlencode($message);
+
+        return $data;
+    }
+
+    // }}}
 }
 
 // }}}

Modified: p2ex/trunk/lib/P2HttpExt.php
===================================================================
--- p2ex/trunk/lib/P2HttpExt.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/P2HttpExt.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,9 +3,6 @@
  * rep2expack feat. pecl_http
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-require_once P2_LIB_DIR . '/P2Util.php';
-
 // {{{ CONSTANTS
 
 define('P2HTTPEXT_DEBUG', 0);

Modified: p2ex/trunk/lib/P2Util.php
===================================================================
--- p2ex/trunk/lib/P2Util.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/P2Util.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -56,6 +56,13 @@
      */
     static private $_hostIsJbbsShitaraba = array();
 
+    /**
+     * ”‚²‚Ƃ̏‘‚«ž‚ݐݒ肨‚æ‚уXƒŒƒbƒh‚²‚Ƃ̏‘‚«ž‚݃f[ƒ^‚ð•Û‘¶‚·‚éƒf[ƒ^ƒx[ƒX
+     *
+     * @var P2KeyValueStore
+     */
+    static private $_postDataStore = null;
+
     // }}}
     // {{{ fileDownload()
 
@@ -382,22 +389,89 @@
     }
 
     // }}}
-    // {{{ getFailedPostFilePath()
+    // {{{ pathForHost()
 
     /**
-     *  failed_post_file ‚̃pƒX‚𓾂éŠÖ”
+     * host‚ɑΉž‚·‚é”Ä—p‚̃pƒX‚ð•Ô‚·
+     *
+     * @param string $host
+     * @param bool $with_slashes
+     * @return string
+     * @see P2Util::_p2DirOfHost()
      */
-    static public function getFailedPostFilePath($host, $bbs, $key = false)
+    static public function pathForHost($host, $with_slashes = true)
     {
-        if ($key) {
-            $filename = $key.'.failed.data.php';
-        } else {
-            $filename = 'failed.data.php';
+        $path = self::_p2DirOfHost('', $host, $with_slashes);
+        if (DIRECTORY_SEPARATOR != '/') {
+            $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
         }
-        return $failed_post_file = self::idxDirOfHostBbs($host, $bbs) . $filename;
+        if (!$with_slashes) {
+            $path = trim($path, '/');
+        }
+        return $path;
     }
 
     // }}}
+    // {{{ pathForHostBbs()
+
+    /**
+     * host,bbs‚ɑΉž‚·‚é”Ä—p‚̃pƒX‚ð•Ô‚·
+     *
+     * @param string $host
+     * @param string $bbs
+     * @param bool $with_slash
+     * @return string
+     * @see P2Util::_p2DirOfHost()
+     */
+    static public function pathForHostBbs($host, $bbs, $with_slashes = true)
+    {
+        $path = self::_p2DirOfHost('', $host, true) . $bbs;
+        if (DIRECTORY_SEPARATOR != '/') {
+            $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
+        }
+        if (!$with_slashes) {
+            $path = trim($path, '/');
+        }
+        return $path;
+    }
+
+    // }}}
+    // {{{ getPostDataStore()
+
+    /**
+     * ”‚²‚Ƃ̏‘‚«ž‚ݐݒ肨‚æ‚уXƒŒƒbƒh‚²‚Ƃ̏‘‚«ž‚݃f[ƒ^‚ð•Û‘¶‚·‚éƒf[ƒ^ƒx[ƒX‚ð•Ô‚·
+     *
+     * @param void
+     * @return P2KeyValueStore
+     */
+    static public function getPostDataStore()
+    {
+        global $_conf;
+
+        if (self::$_postDataStore !== null) {
+            return self::$_postDataStore;
+        }
+
+        if (!class_exists('P2KeyValueStore', false)) {
+            require P2_LIB_DIR . '/P2KeyValueStore.php';
+        }
+
+        if (!is_dir($_conf['cookie_dir'])) {
+            FileCtl::mkdir_r($_conf['cookie_dir']);
+        }
+
+        try {
+            $databasePath = $_conf['cookie_dir'] . DIRECTORY_SEPARATOR . 'p2_post_data.sqlite3';
+            self::$_postDataStore = P2KeyValueStore::getStore($databasePath,
+                                                              P2KeyValueStore::KVS_SERIALIZING);
+        } catch (Exception $e) {
+            p2die($e->getMessage());
+        }
+
+        return self::$_postDataStore;
+    }
+
+    // }}}
     // {{{ getListNaviRange()
 
     /**
@@ -491,49 +565,6 @@
     }
 
     // }}}
-    // {{{ cachePathForCookie()
-
-    /**
-     * ƒzƒXƒg‚©‚çƒNƒbƒL[ƒtƒ@ƒCƒ‹ƒpƒX‚ð•Ô‚·
-     */
-    static public function cachePathForCookie($host)
-    {
-        global $_conf;
-
-        $host = self::normalizeHostName($host);
-
-        if (preg_match('/[^.0-9A-Za-z.\\-_]/', $host)) {
-            if (self::isHostJbbsShitaraba($host)) {
-                if (DIRECTORY_SEPARATOR == '/') {
-                    $cookie_host_dir = $_conf['cookie_dir'] . DIRECTORY_SEPARATOR . $host;
-                } else {
-                    $cookie_host_dir = $_conf['cookie_dir'] . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $host);
-                }
-            } else {
-                $cookie_host_dir = $_conf['cookie_dir'] . DIRECTORY_SEPARATOR . rawurlencode($host);
-                /*
-                if (DIRECTORY_SEPARATOR == '/') {
-                    $old_cookie_host_dir = $_conf['cookie_dir'] . DIRECTORY_SEPARATOR . $host;
-                } else {
-                    $old_cookie_host_dir = $_conf['cookie_dir'] . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $host);
-                }
-                if (is_dir($old_cookie_host_dir)) {
-                    rename($old_cookie_host_dir, $cookie_host_dir);
-                    clearstatcache();
-                }
-                */
-            }
-        } else {
-            $cookie_host_dir = $_conf['cookie_dir'] . DIRECTORY_SEPARATOR . $host;
-        }
-        $cachefile = $cookie_host_dir . DIRECTORY_SEPARATOR . $_conf['cookie_file_name'];
-
-        FileCtl::mkdir_for($cachefile);
-
-        return $cachefile;
-    }
-
-    // }}}
     // {{{ throughIme()
 
     /**
@@ -1117,7 +1148,7 @@
     {
         global $_login;
 
-        return $_login->user . $_SERVER['SERVER_NAME'] . $_SERVER['SERVER_SOFTWARE'];
+        return $_login->user_u . $_SERVER['SERVER_NAME'] . $_SERVER['SERVER_SOFTWARE'];
     }
 
     // }}}
@@ -1130,7 +1161,7 @@
     {
         global $_login;
 
-        $key = $_login->user . $_login->pass_x . $_SERVER['HTTP_USER_AGENT'] . $salt;
+        $key = $_login->user_u . $_login->pass_x . $_SERVER['HTTP_USER_AGENT'] . $salt;
         if (array_key_exists('login_microtime', $_SESSION)) {
             $key .= $_SESSION['login_microtime'];
         }
@@ -1820,6 +1851,10 @@
             require P2_LIB_DIR . '/P2Client.php';
         }
 
+        if (!is_dir($_conf['cookie_dir'])) {
+            FileCtl::mkdir_r($_conf['cookie_dir']);
+        }
+
         try {
             return new P2Client($_conf['p2_2ch_mail'], $_conf['p2_2ch_pass'],
                                 $_conf['cookie_dir'], (bool)$_conf['p2_2ch_ignore_cip']);

Modified: p2ex/trunk/lib/PresetManager.php
===================================================================
--- p2ex/trunk/lib/PresetManager.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/PresetManager.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,8 +3,6 @@
  * rep2expack - ’èŒ^•¶ŠÇ—ƒNƒ‰ƒX
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ constants
 
 define('PRESETMANAGER_REAF_FIRST',    0);

Modified: p2ex/trunk/lib/Thread.php
===================================================================
--- p2ex/trunk/lib/Thread.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/Thread.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -1,5 +1,4 @@
 <?php
-require_once P2_LIB_DIR . '/FileCtl.php';
 
 // {{{ Thread
 

Modified: p2ex/trunk/lib/ThreadRead.php
===================================================================
--- p2ex/trunk/lib/ThreadRead.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/ThreadRead.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,7 +3,6 @@
  * rep2 - ƒXƒŒƒbƒh ƒŠ[ƒh ƒNƒ‰ƒX
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
 require_once P2_LIB_DIR . '/Thread.php';
 
 // {{{ ThreadRead

Added: p2ex/trunk/lib/bootstrap.php
===================================================================
--- p2ex/trunk/lib/bootstrap.php	                        (rev 0)
+++ p2ex/trunk/lib/bootstrap.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -0,0 +1,708 @@
+<?php
+/**
+ * rep2expack - ‰Šú‰»ƒXƒNƒŠƒvƒg
+ * conf/conf.inc.php ‚Ì p2configure() ‚©‚ç“ǂݍž‚Ü‚ê‚éB
+ */
+
+// {{{ ƒzƒXƒgƒ`ƒFƒbƒN
+
+if ($_conf['secure']['auth_host'] || $_conf['secure']['auth_bbq']) {
+    require_once $P2_LIB_DIR_S . 'HostCheck.php';
+    if (($_conf['secure']['auth_host'] && HostCheck::getHostAuth() == false) ||
+        ($_conf['secure']['auth_bbq'] && HostCheck::getHostBurned() == true)
+    ) {
+        HostCheck::forbidden();
+    }
+}
+
+// }}}
+// {{{ ƒŠƒNƒGƒXƒg•Ï”‚̏ˆ—
+
+// 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•Ï”‚ðˆêŠ‡‚ŃNƒH[ƒgœ‹Ž••¶ŽšƒR[ƒh•ÏŠ·
+ *
+ * “ú–{Œê‚ð“ü—Í‚·‚é‰Â”\«‚Ì‚ ‚éƒtƒH[ƒ€‚ɂ͉B‚µ—v‘f‚Å
+ * ƒGƒ“ƒR[ƒfƒBƒ“ƒO”»’è—p‚Ì•¶Žš—ñ‚ðŽdž‚ñ‚Å‚¢‚é
+ *
+ * $_COOKIE ‚Í $_REQUEST ‚ÉŠÜ‚ß‚È‚¢
+ */
+if (!empty($_GET) || !empty($_POST)) {
+    if (isset($_REQUEST['_hint'])) {
+        // "CP932" ‚Í "SJIS-win" ‚̃GƒCƒŠƒAƒX‚ŁA"SJIS-win" ‚Æ "SJIS" ‚Í•Ê•¨
+        // "CP51932", "eucJP-win", "EUC-JP" ‚Í‚»‚ꂼ‚ê•Ê•¨ (libmbfl“I‚ȈӖ¡‚Å)
+        $request_encoding = mb_detect_encoding($_REQUEST['_hint'], 'UTF-8,CP51932,CP932');
+        if ($request_encoding == 'SJIS-win') {
+            $request_encoding = false;
+        }
+    } else {
+        $request_encoding = 'UTF-8,CP51932,CP932';
+    }
+
+    if (get_magic_quotes_gpc()) {
+        $_GET = array_map('stripslashes_r', $_GET);
+        $_POST = array_map('stripslashes_r', $_POST);
+    }
+
+    if ($request_encoding) {
+        mb_convert_variables('CP932', $request_encoding, $_GET, $_POST);
+    }
+
+    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+        $_POST = array_map('nullfilter_r', $_POST);
+        if (count($_GET)) {
+            $_GET = array_map('nullfilter_r', $_GET);
+            $_REQUEST = array_merge($_GET, $_POST);
+        } else {
+            $_REQUEST = $_POST;
+        }
+    } else {
+        $_GET = array_map('nullfilter_r', $_GET);
+        $_REQUEST = $_GET;
+    }
+
+    // ŠÈˆÕƒXƒNƒŠƒvƒgƒCƒ“ƒWƒFƒNƒVƒ‡ƒ“‘΍ô
+    foreach (array('host', 'bbs', 'key', 'ls') as $_k) {
+        if (array_key_exists($_k, $_REQUEST)) {
+            $_v = $_REQUEST[$_k];
+            if (htmlspecialchars($_v, ENT_QUOTES) != $_v) {
+                p2die('ƒŠƒNƒGƒXƒgƒpƒ‰ƒ[ƒ^‚É•s³‚È•¶Žš‚ª‚ ‚è‚Ü‚·B');
+            }
+        }
+    }
+} else {
+    $_REQUEST = array();
+}
+
+// }}}
+// {{{ ’[––”»’è
+
+require_once 'Net/UserAgent/Mobile.php';
+
+$_conf['ktai'] = false;
+$_conf['iphone'] = false;
+$_conf['input_type_search'] = false;
+
+$_conf['accesskey'] = 'accesskey';
+$_conf['accept_charset'] = 'Shift_JIS';
+$_conf['extra_headers_ht'] = '';
+
+$support_cookies = true;
+
+$mobile = Net_UserAgent_Mobile::singleton();
+
+// iPhone, iPod Touch
+if (P2Util::isBrowserIphone()) {
+    $_conf['ktai'] = true;
+    $_conf['iphone'] = true;
+    $_conf['input_type_search'] = true;
+    $_conf['accept_charset'] = 'UTF-8';
+
+// PC“™
+} elseif ($mobile->isNonMobile()) {
+    // Safari
+    if (P2Util::isBrowserSafariGroup()) {
+        $_conf['input_type_search'] = true;
+        $_conf['accept_charset'] = 'UTF-8';
+
+    // Windows Mobile, Œg‘уQ[ƒ€‹@
+    } elseif (P2Util::isClientOSWindowsCE() || P2Util::isBrowserNintendoDS() || P2Util::isBrowserPSP()) {
+        $_conf['ktai'] = true;
+    }
+
+// Œg‘Ñ
+} else {
+    $_conf['ktai'] = true;
+
+    // NTT docomo iƒ‚[ƒh
+    if ($mobile->isDoCoMo()) {
+        $support_cookies = false;
+
+    // au EZweb
+    //} elseif ($mobile->isEZweb()) {
+    //    $support_cookies = true;
+
+    // SoftBank Mobile
+    } elseif ($mobile->isSoftBank()) {
+        // 3GCŒ^’[––‚Ínonumber‘®«‚ðƒTƒ|[ƒg‚µ‚È‚¢‚Ì‚Åaccesskey‚ðŽg‚¤
+        if (!$mobile->isType3GC()) {
+            $_conf['accesskey'] = 'DIRECTKEY';
+            // 3GCŒ^’[––‚ÆWŒ^’[––ˆÈŠO‚ÍCookie‚ðƒTƒ|[ƒg‚µ‚È‚¢
+            if (!$mobile->isTypeW()) {
+                $support_cookies = false;
+            }
+        }
+
+    // WILLCOM AIR-EDGE
+    //} elseif ($mobile->isWillcom()) {
+    //    $support_cookies = true;
+
+    // ‚»‚Ì‘¼
+    //} else {
+    //    $support_cookies = true;
+    }
+}
+
+// }}}
+// {{{ ƒNƒGƒŠ[‚É‚æ‚é‹­§ƒrƒ…[Žw’è
+
+// b=pc ‚Í‚Ü‚¾ƒŠƒ“ƒNæ‚ªŠ®‘S‚Å‚È‚¢?
+// b=i ‚ÍCSS‚ÅWebKit‚Ì“ÆŽ©Šg’£/æsŽÀ‘•ƒvƒƒpƒeƒB‚𑽗p‚µ‚Ä‚¢‚é
+
+$_conf['b'] = $_conf['client_type'] = ($_conf['iphone'] ? 'i' : ($_conf['ktai'] ? 'k' : 'pc'));
+$_conf['view_forced_by_query'] = false;
+$_conf['k_at_a'] = '';
+$_conf['k_at_q'] = '';
+$_conf['k_input_ht'] = '';
+
+if (isset($_REQUEST['b'])) {
+    switch ($_REQUEST['b']) {
+
+    // ‹­§PCƒrƒ…[Žw’è
+    case 'pc':
+        if ($_conf['b'] != 'pc') {
+            $_conf['b'] = 'pc';
+            $_conf['ktai'] = false;
+            $_conf['iphone'] = false;
+        }
+        break;
+
+    // ‹­§iPhoneƒrƒ…[Žw’è
+    case 'i':
+        if ($_conf['b'] != 'i') {
+            $_conf['b'] = 'i';
+            $_conf['ktai'] = true;
+            $_conf['iphone'] = true;
+        }
+        break;
+
+    // ‹­§Œg‘уrƒ…[Žw’è
+    case 'k':
+        if ($_conf['b'] != 'k') {
+            $_conf['b'] = 'k';
+            $_conf['ktai'] = true;
+            $_conf['iphone'] = false;
+        }
+        break;
+
+    } // endswitch
+
+    // ‹­§ƒrƒ…[Žw’肳‚ê‚Ä‚¢‚½‚È‚ç
+    if ($_conf['b'] != $_conf['client_type']) {
+        $_conf['view_forced_by_query'] = true;
+        $_conf['k_at_a'] = '&amp;b=' . $_conf['b'];
+        $_conf['k_at_q'] = '?b=' . $_conf['b'];
+        $_conf['k_input_ht'] = '<input type="hidden" name="b" value="' . $_conf['b'] . '">';
+        //output_add_rewrite_var('b', $_conf['b']);
+    }
+}
+
+// }}}
+// {{{ ƒ†[ƒ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Ý’è‚ð“ǂݍž‚Þ
+        require_once $P2_CONF_DIR_S . 'conf_user_def.inc.php';
+
+        // Ý’è‚̍XV
+        if (!array_key_exists('mobile.link_youtube', $conf_user)) {
+            require_once $P2_LIB_DIR_S . 'conf_user_updater.inc.php';
+            $conf_user = 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Ý’è‚ð“ǂݍž‚Þ
+    require_once $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']}\"" : '';
+
+if ($_conf['get_new_res']) {
+    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'];
+    }
+} else {
+    $_conf['get_new_res_l'] = 'l200';
+}
+
+if ($_conf['expack.user_agent']) {
+    ini_set('user_agent', $_conf['expack.user_agent']);
+}
+
+// }}}
+// {{{ ƒfƒUƒCƒ“Ý’è “Çž
+
+$skin_name = $default_skin_name = 'conf_user_style';
+$skin = $P2_CONF_DIR_S . 'conf_user_style.inc.php';
+if (!$_conf['ktai'] && $_conf['expack.skin.enabled']) {
+    // •Û‘¶‚³‚ê‚Ä‚¢‚éƒXƒLƒ“–¼
+    $saved_skin_name = null;
+    if (file_exists($_conf['expack.skin.setting_path'])) {
+        $saved_skin_name = rtrim(file_get_contents($_conf['expack.skin.setting_path']));
+        if (!preg_match('/^[0-9A-Za-z_\\-]+$/', $saved_skin_name)) {
+            $saved_skin_name = null;
+        }
+    } else {
+        FileCtl::make_datafile($_conf['expack.skin.setting_path'], $_conf['expack.skin.setting_perm']);
+    }
+
+    // ƒŠƒNƒGƒXƒg‚ÅŽw’肳‚ꂽƒXƒLƒ“–¼
+    $new_skin_name = null;
+    if (array_key_exists('skin', $_REQUEST) && is_string($_REQUEST['skin'])) {
+        $new_skin_name = $_REQUEST['skin'];
+        if (!preg_match('/^[0-9A-Za-z_\\-]+$/', $new_skin_name)) {
+            $new_skin_name = null;
+        } elseif ($new_skin_name != $saved_skin_name) {
+            FileCtl::file_write_contents($_conf['expack.skin.setting_path'], $new_skin_name);
+        }
+    }
+
+    // ƒŠƒNƒGƒXƒg‚ÅŽw’肳‚ꂽˆêŽžƒXƒLƒ“–¼
+    $tmp_skin_name = null;
+    if (array_key_exists('tmp_skin', $_REQUEST) && is_string($_REQUEST['tmp_skin'])) {
+        $tmp_skin_name = $_REQUEST['tmp_skin'];
+        if (!preg_match('/^[0-9A-Za-z_\\-]+$/', $tmp_skin_name)) {
+            $tmp_skin_name = null;
+        }
+    }
+
+    // ƒXƒLƒ“ŒŸõ
+    foreach (array($tmp_skin_name, $new_skin_name, $saved_skin_name, $default_skin_name) as $skin_name) {
+        if ($skin_name !== null) {
+            if ($skin_name == $default_skin_name) {
+                break;
+            }
+            $user_skin_path = P2_USER_SKIN_DIR . DIRECTORY_SEPARATOR . $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';
+            if (file_exists($bundled_skin_path)) {
+                $skin = $bundled_skin_path;
+                break;
+            }
+        }
+    }
+}
+
+if (!file_exists($skin)) {
+    $skin_name = 'conf_user_style';
+    $skin = $P2_CONF_DIR_S . 'conf_user_style.inc.php';
+}
+$skin_en = rawurlencode($skin_name) . '&amp;_=' . P2_VERSION_ID;
+if ($_conf['view_forced_by_query']) {
+    $skin_en .= $_conf['k_at_a'];
+}
+
+// ƒfƒtƒHƒ‹ƒgÝ’è‚ð“ǂݍž‚ñ‚Å
+include $P2_CONF_DIR_S . 'conf_user_style.inc.php';
+// ƒXƒLƒ“‚ŏ㏑‚«
+if ($skin != $P2_CONF_DIR_S . 'conf_user_style.inc.php') {
+    include $skin;
+}
+
+// }}}
+// {{{ ƒfƒUƒCƒ“Ý’è‚Ì’²®ˆ—
+
+$skin_uniq = P2_VERSION_ID;
+
+foreach ($STYLE as $K => $V) {
+    if (empty($V)) {
+        $STYLE[$K] = '';
+    } elseif (strpos($K, 'fontfamily') !== false) {
+        $STYLE[$K] = p2_correct_css_fontfamily($V);
+    } elseif (strpos($K, 'color') !== false) {
+        $STYLE[$K] = p2_correct_css_color($V);
+    } elseif (strpos($K, 'background') !== false) {
+        $STYLE[$K] = "url('" . p2_escape_css_url($V) . "')";
+    }
+}
+
+if (!$_conf['ktai']) {
+    require_once $P2_LIB_DIR_S . 'fontconfig.inc.php';
+
+    if ($_conf['expack.am.enabled']) {
+        $_conf['expack.am.fontfamily'] = p2_correct_css_fontfamily($_conf['expack.am.fontfamily']);
+        if ($STYLE['fontfamily']) {
+            $_conf['expack.am.fontfamily'] .= '","' . $STYLE['fontfamily'];
+        }
+    }
+
+    fontconfig_apply_custom();
+}
+
+// }}}
+// {{{ Œg‘сEiPhone—p•Ï”
+
+// iPhone—pHTMLƒwƒbƒ_—v‘f
+if ($_conf['client_type'] == 'i') {
+    switch ($_conf['b']) {
+
+    // ‹­§PCƒrƒ…[Žž
+    case 'pc':
+        $_conf['extra_headers_ht'] .= <<<EOS
+<meta name="format-detection" content="telephone=no">
+<link rel="apple-touch-icon" type="image/png" href="img/touch-icon/p2-serif.png">
+<style type="text/css">body { -webkit-text-size-adjust: none; }</style>
+EOS;
+        break;
+
+    // ‹­§Œg‘уrƒ…[Žž
+    case 'k':
+        $_conf['extra_headers_ht'] .= <<<EOS
+<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes">
+<meta name="format-detection" content="telephone=no">
+<link rel="apple-touch-icon" type="image/png" href="img/touch-icon/p2-serif.png">
+<style type="text/css">
+body { word-break: normal; word-break: break-all; -webkit-text-size-adjust: none; }
+* { font-family: sans-serif; font-size: medium; line-height: 150%; }
+h1 { font-size: xx-large; }
+h2 { font-size: x-large; }
+h3 { font-size: large; }
+</style>
+EOS;
+        break;
+
+    // ƒ³iPhoneƒrƒ…[
+    case 'i':
+    default:
+        $_conf['extra_headers_ht'] .= <<<EOS
+<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes">
+<meta name="format-detection" content="telephone=no">
+<link rel="apple-touch-icon" type="image/png" href="img/touch-icon/p2-serif.png">
+<link rel="stylesheet" type="text/css" media="screen" href="css/iphone.css?{$_conf['p2_version_id']}">
+<script type="text/javascript" src="js/iphone.js?{$_conf['p2_version_id']}"></script>
+EOS;
+
+    } // endswitch
+
+// ‹­§iPhoneƒrƒ…[Žž
+} elseif ($_conf['iphone']) {
+    $_conf['extra_headers_ht'] .= <<<EOS
+<link rel="stylesheet" type="text/css" media="screen" href="css/iphone.css?{$_conf['p2_version_id']}">
+<script type="text/javascript" src="js/iphone.js?{$_conf['p2_version_id']}"></script>
+EOS;
+}
+
+// iPhone—pƒXƒLƒ“
+if ($_conf['iphone'] && isset($_conf['expack.iphone.skin'])) {
+    if (strpos($_conf['expack.iphone.skin'], DIRECTORY_SEPARATOR) === false) {
+        $iskin = 'skin/iphone/' . $iskin . '.css';
+        if (file_exists($iskin)) {
+            $iskin_mtime = filemtime($iskin);
+            $_conf['extra_headers_ht'] .= <<<EOS
+<link rel="stylesheet" type="text/css" media="screen" href="{$iskin}?{$iskin_mtime}">
+EOS;
+        }
+    }
+}
+
+// Œg‘Ñ—puƒgƒbƒv‚É–ß‚évƒŠƒ“ƒN‚Æaccesskey
+if ($_conf['ktai']) {
+    // iPhone
+    if ($_conf['iphone']) {
+        $_conf['k_accesskey_at'] = array_fill(0, 10, '');
+        $_conf['k_accesskey_at']['*'] = '';
+        $_conf['k_accesskey_at']['#'] = '';
+        foreach ($_conf['k_accesskey'] as $name => $key) {
+            $_conf['k_accesskey_at'][$name] = '';
+        }
+
+        $_conf['k_accesskey_st'] = $_conf['k_accesskey_at'];
+
+        $_conf['k_to_index_ht'] = <<<EOP
+<a href="index.php{$_conf['k_at_q']}" class="button">TOP</a>
+EOP;
+
+    // ‚»‚Ì‘¼
+    } else {
+        // SoftBank Mobile
+        if ($_conf['accesskey'] == 'DIRECTKEY') {
+            $_conf['k_accesskey_at'] = array(
+                '0' => ' directkey="0" nonumber',
+                '1' => ' directkey="1" nonumber',
+                '2' => ' directkey="2" nonumber',
+                '3' => ' directkey="3" nonumber',
+                '4' => ' directkey="4" nonumber',
+                '5' => ' directkey="5" nonumber',
+                '6' => ' directkey="6" nonumber',
+                '7' => ' directkey="7" nonumber',
+                '8' => ' directkey="8" nonumber',
+                '9' => ' directkey="9" nonumber',
+                '*' => ' directkey="*" nonumber',
+                '#' => ' directkey="#" nonumber',
+            );
+
+        // ‚»‚Ì‘¼
+        } else {
+            $_conf['k_accesskey_at'] = array(
+                '0' => ' accesskey="0"',
+                '1' => ' accesskey="1"',
+                '2' => ' accesskey="2"',
+                '3' => ' accesskey="3"',
+                '4' => ' accesskey="4"',
+                '5' => ' accesskey="5"',
+                '6' => ' accesskey="6"',
+                '7' => ' accesskey="7"',
+                '8' => ' accesskey="8"',
+                '9' => ' accesskey="9"',
+                '*' => ' accesskey="*"',
+                '#' => ' accesskey="#"',
+            );
+        }
+
+        switch ($_conf['mobile.display_accesskey']) {
+        case 2:
+            require_once $P2_LIB_DIR_S . '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'));
+            $_conf['k_accesskey_st'] = array(
+                '0' => $emoji[0],
+                '1' => $emoji[1],
+                '2' => $emoji[2],
+                '3' => $emoji[3],
+                '4' => $emoji[4],
+                '5' => $emoji[5],
+                '6' => $emoji[6],
+                '7' => $emoji[7],
+                '8' => $emoji[8],
+                '9' => $emoji[9],
+                '*' => $emoji['*'],
+                '#' => $emoji['#'],
+            );
+            break;
+        case 0:
+            $_conf['k_accesskey_st'] = array_fill(0, 10, '');
+            $_conf['k_accesskey_st']['*'] = '';
+            $_conf['k_accesskey_st']['#'] = '';
+            break;
+        case 1:
+        default:
+            $_conf['k_accesskey_st'] = array(
+                0 => '0.', 1 => '1.', 2 => '2.', 3 => '3.', 4 => '4.',
+                5 => '5.', 6 => '6.', 7 => '7.', 8 => '8.', 9 => '9.',
+                '*' => '*.', '#' => '#.'
+            );
+        }
+
+        foreach ($_conf['k_accesskey'] as $name => $key) {
+            $_conf['k_accesskey_at'][$name] = $_conf['k_accesskey_at'][$key];
+            $_conf['k_accesskey_st'][$name] = $_conf['k_accesskey_st'][$key];
+        }
+
+        $_conf['k_to_index_ht'] = <<<EOP
+<a href="index.php{$_conf['k_at_q']}"{$_conf['k_accesskey_at'][0]}>{$_conf['k_accesskey_st'][0]}TOP</a>
+EOP;
+    }
+}
+
+// }}}
+// {{{ Œg‘Ñ—pƒJƒ‰[ƒŠƒ“ƒO‚Ì’²®ˆ—
+
+$_conf['k_colors'] = '';
+
+if ($_conf['ktai']) {
+    // Šî–{F
+    if (!$_conf['iphone']) {
+        if ($_conf['mobile.background_color']) {
+            $_conf['k_colors'] .= ' bgcolor="' . htmlspecialchars($_conf['mobile.background_color']) . '"';
+        }
+        if ($_conf['mobile.text_color']) {
+            $_conf['k_colors'] .= ' text="' . htmlspecialchars($_conf['mobile.text_color']) . '"';
+        }
+        if ($_conf['mobile.link_color']) {
+            $_conf['k_colors'] .= ' link="' . htmlspecialchars($_conf['mobile.link_color']) . '"';
+        }
+        if ($_conf['mobile.vlink_color']) {
+            $_conf['k_colors'] .= ' vlink="' . htmlspecialchars($_conf['mobile.vlink_color']) . '"';
+        }
+    }
+
+    // •¶ŽšF
+    if ($_conf['mobile.newthre_color']) {
+        $STYLE['mobile_subject_newthre_color'] = htmlspecialchars($_conf['mobile.newthre_color']);
+    }
+    if ($_conf['mobile.newres_color']) {
+        $STYLE['mobile_read_newres_color']    = htmlspecialchars($_conf['mobile.newres_color']);
+        $STYLE['mobile_subject_newres_color'] = htmlspecialchars($_conf['mobile.newres_color']);
+    }
+    if ($_conf['mobile.ttitle_color']) {
+        $STYLE['mobile_read_ttitle_color'] = htmlspecialchars($_conf['mobile.ttitle_color']);
+    }
+    if ($_conf['mobile.ngword_color']) {
+        $STYLE['mobile_read_ngword_color'] = htmlspecialchars($_conf['mobile.ngword_color']);
+    }
+    if ($_conf['mobile.onthefly_color']) {
+        $STYLE['mobile_read_onthefly_color'] = htmlspecialchars($_conf['mobile.onthefly_color']);
+    }
+
+    // ƒ}[ƒJ[
+    if ($_conf['mobile.match_color']) {
+        if ($_conf['iphone']) {
+            $_conf['extra_headers_ht'] .= sprintf('<style type="text/css">b.filtering, span.matched { color: %s; }</style>',
+                                                  htmlspecialchars($_conf['mobile.match_color']));
+            $_conf['k_filter_marker'] = '<span class="matched">\\1</span>';
+        } else {
+            $_conf['k_filter_marker'] = '<font color="' . htmlspecialchars($_conf['mobile.match_color']) . '">\\1</font>';
+        }
+    } else {
+        $_conf['k_filter_marker'] = false;
+    }
+}
+
+// }}}
+// {{{ ƒZƒbƒVƒ‡ƒ“
+
+// –¼‘O‚́AƒZƒbƒVƒ‡ƒ“ƒNƒbƒL[‚ð”jŠü‚·‚é‚Æ‚«‚Ì‚½‚߂ɁAƒZƒbƒVƒ‡ƒ“—˜—p‚Ì—L–³‚ÉŠÖ‚í‚炸Ý’è‚·‚é
+session_name('PS');
+
+$_conf['sid_at_a'] = '';
+
+require_once $P2_LIB_DIR_S . 'Session.php';
+
+// {{{ ƒZƒbƒVƒ‡ƒ“ƒf[ƒ^•Û‘¶ƒfƒBƒŒƒNƒgƒŠ‚ðƒ`ƒFƒbƒN
+
+if ($_conf['session_save'] == 'p2' and session_module_name() == 'files') {
+    if (!is_dir($_conf['session_dir'])) {
+        FileCtl::mkdir_r($_conf['session_dir']);
+    } elseif (!is_writable($_conf['session_dir'])) {
+        p2die("ƒZƒbƒVƒ‡ƒ“ƒf[ƒ^•Û‘¶ƒfƒBƒŒƒNƒgƒŠ ({$_conf['session_dir']}) ‚ɏ‘‚«ž‚ÝŒ ŒÀ‚ª‚ ‚è‚Ü‚¹‚ñB");
+    }
+
+    session_save_path($_conf['session_dir']);
+}
+
+// }}}
+
+$_p2session = new Session(null, null, $support_cookies);
+
+// }}}
+// {{{ ‚¨‹C‚ɃZƒbƒg
+
+// •¡”‚Ì‚¨‹C‚ɃZƒbƒg‚ðŽg‚¤‚Æ‚«
+if ($_conf['expack.misc.multi_favs']) {
+    if (!class_exists('FavSetManager', false)) {
+        include $P2_LIB_DIR_S . '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']     = '';
+}
+
+// }}}
+// {{{ misc.
+
+// DOCTYPE HTML éŒ¾
+$_conf['doctype'] = '';
+$ie_strict = false;
+if (!$_conf['ktai'] || $_conf['client_type'] != 'k') {
+    if ($ie_strict || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') === false) {
+        $_conf['doctype'] = <<<EODOC
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+        "http://www.w3.org/TR/html4/loose.dtd">\n
+EODOC;
+    } else {
+        $_conf['doctype'] = <<<EODOC
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n
+EODOC;
+    }
+}
+
+// XHTMLƒwƒbƒ_—v‘f
+if (defined('P2_OUTPUT_XHTML')) {
+    $_conf['extra_headers_xht'] = preg_replace('/<((?:link|meta) .+?)>/', '<\\1 />', $_conf['extra_headers_ht']);
+}
+
+// ƒƒOƒCƒ“ƒNƒ‰ƒX‚̃Cƒ“ƒXƒ^ƒ“ƒX¶¬iƒƒOƒCƒ“ƒ†[ƒU‚ªŽw’肳‚ê‚Ä‚¢‚È‚¯‚ê‚΁A‚±‚ÌŽž“_‚эƒOƒCƒ“ƒtƒH[ƒ€•\Ž¦‚Ɂj
+require_once $P2_LIB_DIR_S . 'Login.php';
+$_login = new Login();
+
+// }}}
+
+/*
+ * 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/dele.inc.php
===================================================================
--- p2ex/trunk/lib/dele.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/dele.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,7 +3,6 @@
  * rep2 - ƒXƒŒƒbƒhƒf[ƒ^ADAT‚ðíœ‚·‚邽‚߂̊֐”ŒS
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
 require_once P2_LIB_DIR . '/setfav.inc.php';
 require_once P2_LIB_DIR . '/setpalace.inc.php';
 

Modified: p2ex/trunk/lib/expack/fixed_name.inc.php
===================================================================
--- p2ex/trunk/lib/expack/fixed_name.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/expack/fixed_name.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -4,7 +4,6 @@
  */
 
 require_once P2_LIB_DIR . '/SjisPersister.php';
-require_once P2_LIB_DIR . '/P2Util.php';
 
 // {{{ fixed_name_get_persister()
 

Modified: p2ex/trunk/lib/expack/rss/common.inc.php
===================================================================
--- p2ex/trunk/lib/expack/rss/common.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/expack/rss/common.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,7 +3,6 @@
  * rep2expack - RSSƒ†[ƒeƒBƒŠƒeƒBŠÖ”
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
 require_once 'PEAR.php';
 
 // {{{ rss_get_save_path()

Modified: p2ex/trunk/lib/expack/rss/parser.inc.php
===================================================================
--- p2ex/trunk/lib/expack/rss/parser.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/expack/rss/parser.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,7 +3,6 @@
  * rep2expack - RSS Parser
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
 require_once P2EX_LIB_DIR . '/rss/common.inc.php';
 require_once 'XML/RSS.php';
 

Modified: p2ex/trunk/lib/expack/rss/setrss.inc.php
===================================================================
--- p2ex/trunk/lib/expack/rss/setrss.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/expack/rss/setrss.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,7 +3,6 @@
  * rep2expack - RSSƒŠƒXƒg‚̏ˆ—
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
 require_once P2EX_LIB_DIR . '/rss/parser.inc.php';
 
 // {{{ •Ï”

Modified: p2ex/trunk/lib/login2ch.inc.php
===================================================================
--- p2ex/trunk/lib/login2ch.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/login2ch.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -4,7 +4,6 @@
  */
 
 require_once './conf/conf.inc.php';
-require_once P2_LIB_DIR . '/FileCtl.php';
 require_once P2_LIB_DIR . '/Wap.php';
 
 // {{{ login2ch()

Modified: p2ex/trunk/lib/post_form_options.inc.php
===================================================================
--- p2ex/trunk/lib/post_form_options.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/post_form_options.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -18,6 +18,8 @@
 $hd['mail'] = '';
 $hd['MESSAGE'] = '';
 $hd['subject'] = '';
+$hd['beres_checked'] = '';
+$hd['p2res_checked'] = '';
 
 $htm['beres'] = '';
 $htm['p2res'] = '';
@@ -88,31 +90,61 @@
 }
 
 // }}}
+// {{{ ƒf[ƒ^ƒx[ƒX‚©‚ç‘O‰ñ‚ÌPOSTŽ¸”sƒf[ƒ^‚Æberes/p2res‚̐ݒè‚ð“Ǎž‚Ý
 
-// ‘O‰ñ‚ÌPOSTŽ¸”s‚ª‚ ‚ê‚ΌĂяo‚µ
-$failed_post_file = P2Util::getFailedPostFilePath($host, $bbs, $key);
-if ($cont_srd = DataPhp::getDataPhpCont($failed_post_file)) {
-    $last_posted = unserialize($cont_srd);
+if (!isset($_login)) {
+    $_login = $GLOBALS['_login'];
+}
+$post_id_suffix = $_login->user_u . P2Util::pathForHostBbs($host, $bbs);
+$post_backup_id = 'backup:' . $post_id_suffix;
+$post_config_id = 'config:' . $post_id_suffix;
+if (!empty($_REQUEST['newthread'])) {
+    $post_backup_id .= 'new';
+} else {
+    $post_backup_id .= $key;
+}
 
-    // ‚܂Ƃ߂ăTƒjƒ^ƒCƒY
-    $last_posted = array_map(create_function('$n', 'return htmlspecialchars($n, ENT_QUOTES);'), $last_posted);
-    //$addslashesS = create_function('$str', 'return str_replace("\'", "\\\'", $str);');
-    //$last_posted = array_map($addslashesS, $last_posted);
+$post_store = P2Util::getPostDataStore();
 
-    $hd['FROM'] = $last_posted['FROM'];
-    $hd['mail'] = $last_posted['mail'];
-    $hd['MESSAGE'] = $last_posted['MESSAGE'];
-    $hd['subject'] = $last_posted['subject'];
+// ‘O‰ñ‚ÌPOSTŽ¸”sƒf[ƒ^
+if ($post_backup = $post_store->get($post_backup_id)) {
+    $hd['FROM'] = htmlspecialchars($post_backup['FROM'], ENT_QUOTES, 'Shift_JIS');
+    $hd['mail'] = htmlspecialchars($post_backup['mail'], ENT_QUOTES, 'Shift_JIS');
+    $hd['MESSAGE'] = htmlspecialchars($post_backup['MESSAGE'], ENT_QUOTES, 'Shift_JIS');
+    $hd['subject'] = htmlspecialchars($post_backup['subject'], ENT_QUOTES, 'Shift_JIS');
 }
 
+// beres/p2res
+if ($post_config = $post_store->get($post_config_id)) {
+    if ($post_config['beres']) {
+        $hd['beres_checked'] = ' checked';
+    }
+    if ($post_config['p2res']) {
+        $hd['p2res_checked'] = ' checked';
+    }
+}
+
+// }}}
+// {{{ –¼‘O‚ƃ[ƒ‹‚̍ŏI’²®
+
 // ‹ó”’‚̓†[ƒUÝ’è’l‚É•ÏŠ·
-$hd['FROM'] = ($hd['FROM'] == '') ? htmlspecialchars($_conf['my_FROM'], ENT_QUOTES) : $hd['FROM'];
-$hd['mail'] = ($hd['mail'] == '') ? htmlspecialchars($_conf['my_mail'], ENT_QUOTES) : $hd['mail'];
+if ($hd['FROM'] === '') {
+    $hd['FROM'] = htmlspecialchars($_conf['my_FROM'], ENT_QUOTES, 'Shift_JIS');
+}
+if ($hd['mail'] === '') {
+    $hd['mail'] = htmlspecialchars($_conf['my_mail'], ENT_QUOTES, 'Shift_JIS');
+}
 
 // P2NULL‚Í‹ó”’‚É•ÏŠ·
-$hd['FROM'] = ($hd['FROM'] == 'P2NULL') ? '' : $hd['FROM'];
-$hd['mail'] = ($hd['mail'] == 'P2NULL') ? '' : $hd['mail'];
+if ($hd['FROM'] === 'P2NULL') {
+    $hd['FROM'] = '';
+}
+if ($hd['mail'] === 'P2NULL') {
+    $hd['mail'] = '';
+}
 
+// }}}
+// {{{ textarea‚Ì‘®«
 
 // ŽQl ƒNƒ‰ƒVƒbƒN COLS='60' ROWS='8'
 $mobile = Net_UserAgent_Mobile::singleton();
@@ -132,17 +164,8 @@
     $wrap_at = ' wrap="soft"';
 }
 
-// Be.2ch
-if (P2Util::isHost2chs($host) and $_conf['be_2ch_code'] && $_conf['be_2ch_mail']) {
-    $htm['beres'] = '<input type="checkbox" id="beres" name="beres" value="1"><label for="beres">BE‚ŏ‘‚«ž‚Þ</label>';
-}
+// {{{ PC—p sage ƒ`ƒFƒbƒNƒ{ƒbƒNƒX
 
-// ŒöŽ®p2
-if ((P2Util::isHost2chs($host) || P2Util::isHostMachiBbs($host)) && $_conf['p2_2ch_mail'] && $_conf['p2_2ch_pass']) {
-    $htm['p2res'] = '<input type="checkbox" id="p2res" name="p2res" value="1"><label for="p2res">ŒöŽ®p2‚ŏ‘‚«ž‚Þ</label>';
-}
-
-// PC—p sage checkbox
 if (!$_conf['ktai']) {
     $on_check_sage = ' onchange="checkSage();"';
     $htm['sage_cb'] = <<<EOP
@@ -152,14 +175,29 @@
     $on_check_sage = '';
 }
 
-// {{{ 2chœ‘‚«ž‚Ý
+// }}}
+// {{{ œ/Be/ŒöŽ®p2 ‘‚«ž‚Ý ƒ`ƒFƒbƒNƒ{ƒbƒNƒX
 
+//  2chœ‘‚«ž‚Ý
 if (P2Util::isHost2chs($host) and file_exists($_conf['sid2ch_php'])) {
-    $htm['maru_post'] = <<<EOP
-<span title="2chœID‚ÌŽg—p"><input id="maru" name="maru" type="checkbox" value="1"><label for="maru">œ</label></span>
-EOP;
+    $htm['maru_post'] = '<span title="2chœID‚ÌŽg—p"><input type="checkbox" id="maru" name="maru" value="1">'
+                      . '<label for="maru">œ</label></span>';
 }
 
+// Be
+if (P2Util::isHost2chs($host) and $_conf['be_2ch_code'] && $_conf['be_2ch_mail']) {
+    $htm['beres'] = '<input type="checkbox" id="beres" name="beres" value="1"'. $hd['beres_checked'] . '>'
+                  . '<label for="beres">Be‚ŏ‘‚«ž‚Þ</label>';
+}
+
+// ŒöŽ®p2
+if ((P2Util::isHost2chs($host) || P2Util::isHostMachiBbs($host)) &&
+    $_conf['p2_2ch_mail'] && $_conf['p2_2ch_pass'])
+{
+    $htm['p2res'] = '<input type="checkbox" id="p2res" name="p2res" value="1"'. $hd['p2res_checked'] . '>'
+                  . '<label for="p2res">ŒöŽ®p2‚ŏ‘‚«ž‚Þ</label>';
+}
+
 // }}}
 // {{{ ‘‚«ž‚݃uƒƒbƒN—pƒ`ƒFƒbƒNƒ{ƒbƒNƒX
 

Modified: p2ex/trunk/lib/read_footer.inc.php
===================================================================
--- p2ex/trunk/lib/read_footer.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/read_footer.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,8 +3,6 @@
  * rep2 - ƒXƒŒƒbƒh•\Ž¦ -  ƒtƒbƒ^•”•ª -  for read.php
  */
 
-require_once P2_LIB_DIR . '/DataPhp.php';
-
 //=====================================================================
 // ¡ƒtƒbƒ^
 //=====================================================================

Modified: p2ex/trunk/lib/read_machibbs.inc.php
===================================================================
--- p2ex/trunk/lib/read_machibbs.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/read_machibbs.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,8 +3,6 @@
  * rep2 - ‚Ü‚¿BBS—p‚̊֐”
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ machiDownload()
 
 /**

Modified: p2ex/trunk/lib/read_new.inc.php
===================================================================
--- p2ex/trunk/lib/read_new.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/read_new.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,8 +3,6 @@
  * rep2 - for read_new.php, read_new_k.php
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ saveMatomeCache()
 
 /**

Modified: p2ex/trunk/lib/read_res_hist.inc.php
===================================================================
--- p2ex/trunk/lib/read_res_hist.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/read_res_hist.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,8 +3,6 @@
  * rep2 - ‘‚«ž‚Ý—š—ð ‚Ì‚½‚߂̊֐”ŒQ
  */
 
-require_once P2_LIB_DIR . '/DataPhp.php';
-
 // {{{ deleMsg()
 
 /**

Modified: p2ex/trunk/lib/read_shitaraba.inc.php
===================================================================
--- p2ex/trunk/lib/read_shitaraba.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/read_shitaraba.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -5,8 +5,6 @@
  * ŠeŽíBBS‚ɑΉž‚Å‚«‚éƒvƒƒtƒ@ƒCƒ‹ƒNƒ‰ƒX‚Ý‚½‚¢‚È‚Ì‚ðì‚肽‚¢‚à‚Ì‚¾BB aki
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ shitarabaDownload()
 
 /**

Modified: p2ex/trunk/lib/setbookmark.inc.php
===================================================================
--- p2ex/trunk/lib/setbookmark.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/setbookmark.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,8 +3,6 @@
  * rep2expack - ƒuƒbƒNƒ}[ƒN“o˜^E‰ðœ
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ setbookmark()
 
 /**

Modified: p2ex/trunk/lib/setfav.inc.php
===================================================================
--- p2ex/trunk/lib/setfav.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/setfav.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -14,8 +14,6 @@
  * ƒXƒŒƒbƒh•\Ž¦Žž‚Ì‚¨‹C‚ɃXƒŒ•\Ž¦ ¨ ƒXƒŒƒbƒh.idx ‚ðŽQÆ
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ setFav()
 
 /**

Modified: p2ex/trunk/lib/setfavita.inc.php
===================================================================
--- p2ex/trunk/lib/setfavita.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/setfavita.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,8 +3,6 @@
  * rep2 - ‚¨‹C‚ɔ‚̏ˆ—
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ setFavIta()
 
 /**

Modified: p2ex/trunk/lib/setpalace.inc.php
===================================================================
--- p2ex/trunk/lib/setpalace.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/setpalace.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,8 +3,6 @@
  * rep2 - “a“°“ü‚èŠÖŒW‚̏ˆ—
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ setPal()
 
 /**

Modified: p2ex/trunk/lib/settaborn.inc.php
===================================================================
--- p2ex/trunk/lib/settaborn.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/settaborn.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,8 +3,6 @@
  * rep2 - ƒXƒŒƒbƒh‚ ‚ځ[‚ñ‚̊֐”
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ settaborn()
 
 /**

Modified: p2ex/trunk/lib/settaborn_off.inc.php
===================================================================
--- p2ex/trunk/lib/settaborn_off.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/settaborn_off.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -3,8 +3,6 @@
  * rep2 - ƒXƒŒƒbƒh‚ ‚ځ[‚ñ•¡”ˆêŠ‡‰ðœˆ—
  */
 
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 // {{{ settaborn_off()
 
 /**

Modified: p2ex/trunk/lib/subject_new.inc.php
===================================================================
--- p2ex/trunk/lib/subject_new.inc.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/lib/subject_new.inc.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -8,7 +8,6 @@
 
 require_once P2_LIB_DIR . '/ThreadList.php';
 require_once P2_LIB_DIR . '/Thread.php';
-require_once P2_LIB_DIR . '/FileCtl.php';
 
 $_newthre_num = 0;
 $shinchaku_num = 0;

Modified: p2ex/trunk/menu_i.php
===================================================================
--- p2ex/trunk/menu_i.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/menu_i.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -300,7 +300,7 @@
 
 <div id="login_info" class="panel" title="ƒƒOƒCƒ“î•ñ">
 <h2>”FØƒ†[ƒU</h2>
-<p><strong><?php echo $_login->user; ?></strong> - <?php echo date('Y/m/d (D) G:i:s'); ?></p>
+<p><strong><?php echo $_login->user_u; ?></strong> - <?php echo date('Y/m/d (D) G:i:s'); ?></p>
 <?php if ($_conf['login_log_rec'] && $_conf['last_login_log_show']) { ?>
 <h2>‘O‰ñ‚̃ƒOƒCƒ“</h2>
 <pre style="word-wrap:break-word;word-break:break-all"><?php

Modified: p2ex/trunk/post.php
===================================================================
--- p2ex/trunk/post.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/post.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -4,6 +4,7 @@
  */
 
 require_once './conf/conf.inc.php';
+require_once P2_LIB_DIR . '/P2KeyValueStore.php';
 
 $_login->authorize(); // ƒ†[ƒU”FØ
 
@@ -76,22 +77,7 @@
 }
 
 // }}}
-// {{{ ƒNƒbƒL[‚̓ǂݍž‚Ý
 
-$cookie_file = P2Util::cachePathForCookie($host);
-if ($cookie_cont = FileCtl::file_read_contents($cookie_file)) {
-    $p2cookies = unserialize($cookie_cont);
-    if ($p2cookies['expires']) {
-        if (time() > strtotime($p2cookies['expires'])) { // ŠúŒÀØ‚ê‚È‚ç”jŠü
-            // echo "<p>ŠúŒÀØ‚ê‚̃NƒbƒL[‚ðíœ‚µ‚Ü‚µ‚½</p>";
-            unlink($cookie_file);
-            unset($cookie_cont, $p2cookies);
-        }
-    }
-}
-
-// }}}
-
 // ‚µ‚½‚ç‚΂ÌlivedoorˆÚ“]‚ɑΉžBpostæ‚ðlivedoor‚Æ‚·‚éB
 $host = P2Util::adjustHostJbbs($host);
 
@@ -170,44 +156,80 @@
     }
 }
 
+$post_id_suffix = $_login->user_u . P2Util::pathForHostBbs($host, $bbs);
+$post_backup_id = 'backup:' . $post_id_suffix;
+$post_config_id = 'config:' . $post_id_suffix;
 if (!empty($_POST['newthread'])) {
+    $post_backup_id .= 'new';
     $ptitle = 'rep2 - V‹KƒXƒŒƒbƒhì¬';
 } else {
+    $post_backup_id .= $key;
     $ptitle = 'rep2 - ƒŒƒX‘‚«ž‚Ý';
 }
 
+// Ý’è‚ð•Û‘¶
+$post_store = P2Util::getPostDataStore();
+$post_store->set($post_config_id, array(
+    'beres' => !empty($_REQUEST['beres']),
+    'p2res' => !empty($_REQUEST['p2res']),
+));
+
 //================================================================
 // ‘‚«ž‚ݏˆ—
 //================================================================
 
 // ‘‚«ž‚Ý‚ðˆêŽž“I‚É•Û‘¶
-$failed_post_file = P2Util::getFailedPostFilePath($host, $bbs, $key);
-$cont = serialize($post_cache);
-DataPhp::writeDataPhp($failed_post_file, $cont, $_conf['res_write_perm']);
+$post_store->set($post_backup_id, $post_cache);
 
 // ƒ|ƒXƒgŽÀs
 if (!empty($_POST['p2res']) && empty($_POST['newthread'])) {
     // ŒöŽ®p2‚ŏ‘‚«ž‚Ý
     $posted = postIt2($host, $bbs, $key, $FROM, $mail, $MESSAGE);
 } else {
+    // cookie “ǂݍž‚Ý
+    if (!file_exists($_conf['cookie_file_path']) &&
+        dirname($_conf['cookie_file_path']) != $_conf['cookie_dir'])
+    {
+        FileCtl::mkdir_for($_conf['cookie_file_path']);
+    }
+
+    try {
+        $cookie_store = P2KeyValueStore::getStore($_conf['cookie_file_path'],
+                                                  P2KeyValueStore::KVS_SERIALIZING);
+    } catch (Exception $e) {
+        p2die(get_class($e) . ': ' . $e->getMessage());
+    }
+
+    $cookie_key = $_login->user_u . '/' . P2Util::normalizeHostName($host);
+    if ($p2cookies = $cookie_store->get($cookie_key)) {
+        if (is_array($p2cookies)) {
+            if (array_key_exists('expires', $p2cookies)) {
+                // ŠúŒÀØ‚ê‚È‚ç”jŠü
+                if (time() > strtotime($p2cookies['expires'])) {
+                    $cookie_store->delete($cookie_key);
+                    $p2cookies = null;
+                }
+            }
+        } else {
+            $cookie_store->delete($cookie_key);
+            $p2cookies = null;
+        }
+    } else {
+        $p2cookies = null;
+    }
+
     // ’¼Ú‘‚«ž‚Ý
     $posted = postIt($host, $bbs, $key, $post);
 
     // cookie •Û‘¶
-    FileCtl::make_datafile($cookie_file, $_conf['p2_perm']); // ‚È‚¯‚ê‚ΐ¶¬
     if ($p2cookies) {
-        $cookie_cont = serialize($p2cookies);
+        $cookie_store->set($cookie_key, $p2cookies);
     }
-    if ($cookie_cont) {
-        if (FileCtl::file_write_contents($cookie_file, $cookie_cont) === false) {
-            p2die('cannot write file.');
-        }
-    }
 }
 
 // “ŠeŽ¸”s‹L˜^‚ðíœ
-if ($posted && file_exists($failed_post_file)) {
-    unlink($failed_post_file);
+if ($posted) {
+    $post_store->delete($post_backup_id);
 }
 
 //=============================================
@@ -451,17 +473,20 @@
 
         } else {
             $l = fgets($fp, 164000);
-            //echo $l ."<br>"; // for debug
-            $response_header_ht .= $l."<br>";
+            //echo $l .'<br>'; // for debug
+            $response_header_ht .= $l . '<br>';
             // ƒNƒbƒL[ƒLƒ^
-            if (preg_match("/Set-Cookie: (.+?)\r\n/", $l, $matches)) {
-                //echo "<p>".$matches[0]."</p>"; //
-                $cgroups = explode(";", $matches[1]);
+            if (preg_match('/Set-Cookie: (.+?)\\r\\n/', $l, $matches)) {
+                //echo '<p>' . $matches[0] . '</p>'; //
+                $cgroups = explode(';', $matches[1]);
                 if ($cgroups) {
                     foreach ($cgroups as $v) {
-                        if (preg_match("/(.+)=(.*)/", $v, $m)) {
+                        if (preg_match('/(.+)=(.*)/', $v, $m)) {
                             $k = ltrim($m[1]);
-                            if ($k != "path") {
+                            if ($k != 'path') {
+                                if (!$p2cookies) {
+                                    $p2cookies = array();
+                                }
                                 $p2cookies[$k] = $m[2];
                             }
                         }
@@ -470,17 +495,17 @@
                 if ($p2cookies) {
                     unset($cookies_to_send);
                     foreach ($p2cookies as $cname => $cvalue) {
-                        if ($cname != "expires") {
+                        if ($cname != 'expires') {
                             $cookies_to_send .= " {$cname}={$cvalue};";
                         }
                     }
                     $newcookies = "Cookie:{$cookies_to_send}\r\n";
 
-                    $request = preg_replace("/Cookie: .*?\r\n/", $newcookies, $request);
+                    $request = preg_replace('/Cookie: .*?\\r\\n/', $newcookies, $request);
                 }
 
             // “]‘—‚͏‘‚«ž‚ݐ¬Œ÷‚Æ”»’f
-            } elseif (preg_match("/^Location: /", $l, $matches)) {
+            } elseif (preg_match('/^Location: /', $l, $matches)) {
                 $post_seikou = true;
             }
             if ($l == "\r\n") {
@@ -540,12 +565,6 @@
  */
 function postIt2($host, $bbs, $key, $FROM, $mail, $MESSAGE)
 {
-    global $_conf;
-
-    if (!is_dir($_conf['cookie_dir'])) {
-        FileCtl::mkdir_r($_conf['cookie_dir']);
-    }
-
     if (P2Util::isHostBe2chNet($host) || !empty($_REQUEST['beres'])) {
         $beRes = true;
     } else {

Modified: p2ex/trunk/post_form.php
===================================================================
--- p2ex/trunk/post_form.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/post_form.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -24,7 +24,10 @@
 $popup = isset($_GET['popup']) ? intval($_GET['popup']) : 0;
 
 $itaj = P2Util::getItaName($host, $bbs);
-if (!$itaj) { $itaj = $bbs; }
+if (!$itaj) {
+    $itaj = $bbs;
+}
+$itaj_hd = htmlspecialchars($itaj, ENT_QUOTES, 'Shift_JIS', false);
 
 $ttitle_en = isset($_GET['ttitle_en']) ? $_GET['ttitle_en'] : '';
 $ttitle = (strlen($ttitle_en) > 0) ? base64_decode($ttitle_en) : '';
@@ -33,7 +36,7 @@
 $key_idx = P2Util::idxDirOfHostBbs($host, $bbs) . $key . '.idx';
 
 // ƒtƒH[ƒ€‚̃IƒvƒVƒ‡ƒ““ǂݍž‚Ý
-require_once P2_LIB_DIR . '/post_form_options.inc.php';
+include P2_LIB_DIR . '/post_form_options.inc.php';
 
 // •\Ž¦Žw’è
 if (!$_conf['ktai']) {
@@ -44,28 +47,28 @@
 
 // {{{ ƒXƒŒ—§‚Ä‚È‚ç
 if (!empty($_GET['newthread'])) {
-    $ptitle = "{$itaj} - V‹KƒXƒŒƒbƒhì¬";
+    $ptitle = "{$itaj_hd} - V‹KƒXƒŒƒbƒhì¬";
 
     // machibbsAJBBS@‚µ‚½‚ç‚Î ‚È‚ç
     if (P2Util::isHostMachiBbs($host) or P2Util::isHostJbbsShitaraba($host)) {
-        $submit_value = "V‹K‘‚«ž‚Ý";
+        $submit_value = 'V‹K‘‚«ž‚Ý';
     // 2ch‚È‚ç
     } else {
-        $submit_value = "V‹KƒXƒŒƒbƒhì¬";
+        $submit_value = 'V‹KƒXƒŒƒbƒhì¬';
     }
 
     $htm['subject'] = <<<EOP
 <b><span{$class_ttitle}>ƒ^ƒCƒgƒ‹</span></b>F<input type="text" name="subject"{$sub_size_at} value="{$hd['subject']}"><br>
 EOP;
     if ($_conf['ktai']) {
-        $htm['subject'] = "<a href=\"{$_conf['subject_php']}?host={$host}&amp;bbs={$bbs}{$_conf['k_at_a']}\">{$itaj}</a><br>".$htm['subject'];
+        $htm['subject'] = "<a href=\"{$_conf['subject_php']}?host={$host}&amp;bbs={$bbs}{$_conf['k_at_a']}\">{$itaj_hd}</a><br>".$htm['subject'];
     }
-    $newthread_hidden_ht = "<input type=\"hidden\" name=\"newthread\" value=\"1\">";
+    $newthread_hidden_ht = '<input type="hidden" name="newthread" value="1">';
 // }}}
 
 // {{{ ‘‚«ž‚Ý‚È‚ç
 } else {
-    $ptitle = "{$itaj} - ƒŒƒX‘‚«ž‚Ý";
+    $ptitle = "{$itaj_hd} - ƒŒƒX‘‚«ž‚Ý";
 
     $submit_value = "‘‚«ž‚Þ";
 

Modified: p2ex/trunk/read_filter_k.php
===================================================================
--- p2ex/trunk/read_filter_k.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/read_filter_k.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -21,8 +21,6 @@
 /**
  * ‘O‰ñƒtƒBƒ‹ƒ^’l“ǂݍž‚Ý
  */
-require_once P2_LIB_DIR . '/FileCtl.php';
-
 $cachefile = $_conf['pref_dir'] . '/p2_res_filter.txt';
 
 $res_filter_cont = FileCtl::file_read_contents($cachefile);

Modified: p2ex/trunk/subject.php
===================================================================
--- p2ex/trunk/subject.php	2010-01-05 14:48:56 UTC (rev 766)
+++ p2ex/trunk/subject.php	2010-01-09 16:57:35 UTC (rev 767)
@@ -1129,11 +1129,11 @@
                 updateThreadTitleAborn($aborn_threads, $k);
                 return true;
             }*/
-             if ($re_method($v['word'], $subject)) {
+            if ($re_method($v['word'], $subject)) {
                 updateThreadTitleAborn($aborn_threads, $k);
                 return true;
             }
-       // ‘啶Žš¬•¶Žš‚𖳎‹
+        // ‘啶Žš¬•¶Žš‚𖳎‹
         } elseif ($v['ignorecase']) {
             if (stripos($subject, $v['word']) !== false) {
                 updateThreadTitleAborn($aborn_threads, $k);



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