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

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 1月 5日 (火) 21:50:04 JST


Revision: 765
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=765
Author:   rsk
Date:     2010-01-05 21:50:04 +0900 (Tue, 05 Jan 2010)

Log Message:
-----------
expack:
- rev.100105.2130.
- スレッドタイトルあぼーん機能を実装。
- 公式p2のCookie認証時にIPアドレスの同一性をチェックするか
  どうかを選択する設定項目を追加。
- クライアントがCookieをサポートするか否かで自動的に php.ini
  ディレクティブ session.use_cookies と session.use_only_cookies
  を切り替えるようにした。
- rep2ルートディレクトリに user_skin ディレクトリがある場合、
  そこからもスキンを読み込むようにした。
-- user_skin ディレクトリは skin ディレクトリよりも優先される。
-- スキンファイル名は正規表現 ^[0-9A-Za-z_\-]\.php$ に
   マッチしなければならない。
- PHPのバージョン警告メッセージをtitle.phpにだけ表示するようにした。
- その他、内部的に少し変更。

Modified Paths:
--------------
    p2ex/trunk/conf/conf.inc.php
    p2ex/trunk/conf/conf_user_def.inc.php
    p2ex/trunk/edit_aborn_word.php
    p2ex/trunk/edit_conf_user.php
    p2ex/trunk/editfile.php
    p2ex/trunk/editpref.php
    p2ex/trunk/lib/NgAbornCtl.php
    p2ex/trunk/lib/P2Client.php
    p2ex/trunk/lib/P2Util.php
    p2ex/trunk/lib/Session.php
    p2ex/trunk/subject.php


-------------- next part --------------
Modified: p2ex/trunk/conf/conf.inc.php
===================================================================
--- p2ex/trunk/conf/conf.inc.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/conf/conf.inc.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -7,7 +7,7 @@
 // ƒo[ƒWƒ‡ƒ“î•ñ
 $_conf = array(
     'p2version' => '1.7.29+1.8.x',  // rep2‚̃o[ƒWƒ‡ƒ“
-    'p2expack'  => '100103.1800',   // Šg’£ƒpƒbƒN‚̃o[ƒWƒ‡ƒ“
+    'p2expack'  => '100105.2130',   // Šg’£ƒpƒbƒN‚̃o[ƒWƒ‡ƒ“
     'p2name'    => 'expack',        // rep2‚Ì–¼‘O
 );
 
@@ -168,6 +168,7 @@
 
 // ƒ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');
@@ -623,21 +624,60 @@
 // }}}
 // {{{ ƒfƒUƒCƒ“Ý’è “Çž
 
-$skin_name = 'conf_user_style';
+$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'])) {
-        $skin_name = rtrim(file_get_contents($_conf['expack.skin.setting_path']));
-        $skin = P2_SKIN_DIR . DIRECTORY_SEPARATOR . $skin_name . '.php';
+        $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']);
     }
-    if (isset($_REQUEST['skin']) && preg_match('/^\\w+$/', $_REQUEST['skin']) && $skin_name != $_REQUEST['skin']) {
-        $skin_name = $_REQUEST['skin'];
-        $skin = P2_SKIN_DIR . DIRECTORY_SEPARATOR . $skin_name . '.php';
-        FileCtl::file_write_contents($_conf['expack.skin.setting_path'], $skin_name);
+
+    // ƒŠƒ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';
@@ -927,18 +967,8 @@
 
 // }}}
 
-$_p2session = new Session();
+$_p2session = new Session(null, null, $support_cookies);
 
-if (!$support_cookies) {
-    if (ini_get('session.use_only_cookies')) {
-        p2die('Session unavailable', 'php.ini ‚Å session.use_only_cookies ‚ª On ‚É‚È‚Á‚Ä‚¢‚Ü‚·B');
-    }
-    if (!ini_get('session.use_trans_sid')) {
-        output_add_rewrite_var(session_name(), session_id());
-        $_conf['sid_at_a'] = '&' . rawurldecode(session_name()) . '=' . rawurldecode(session_id());
-    }
-}
-
 // }}}
 // {{{ ‚¨‹C‚ɃZƒbƒg
 
@@ -1007,7 +1037,8 @@
 
     $php_version = phpversion();
     $required_version = '5.2.8';
-    $recommended_version = '5.2.10';
+    $recommended_version52 = '5.2.12';
+    $recommended_version53 = '5.3.1';
 
     // PHP‚̃o[ƒWƒ‡ƒ“
     if (version_compare($php_version, $required_version, '<')) {
@@ -1048,15 +1079,24 @@
     }
 
     // „§ƒo[ƒWƒ‡ƒ“
-    if ($check_recommended && version_compare($php_version, $recommended_version, '<')) {
-        $conf_php = htmlspecialchars(__FILE__, ENT_QUOTES);
-        $_info_msg_ht .= <<<EOP
+    if ($check_recommended) {
+        if (version_compare($php_version, '5.3.0-dev', '>=')) {
+            $recommended_version = $recommended_version53;
+        } else {
+            $recommended_version = $recommended_version52;
+        }
+        if (version_compare($php_version, $recommended_version, '<')) {
+            // title.php ‚̂݃ƒbƒZ[ƒW‚ð•\Ž¦
+            if (basename($_SERVER['PHP_SELF'], '.php') == 'title') {
+                $_info_msg_ht .= <<<EOP
 <p><strong>„§ƒo[ƒWƒ‡ƒ“‚æ‚èŒÃ‚¢PHP‚Å“®ì‚µ‚Ä‚¢‚Ü‚·B</strong><em>(PHP {$php_version})</em><br>
-PHP {$recommended_version} ˆÈ~‚ɃAƒbƒvƒf[ƒg‚·‚邱‚Æ‚ð‚¨‚·‚·‚ß‚µ‚Ü‚·B<br>
-<small>i‚±‚̃ƒbƒZ[ƒW‚ð•\Ž¦‚µ‚È‚¢‚悤‚É‚·‚é‚É‚Í {$conf_php} ‚Ì {$check_recommended} s–Ú‚Ì
-&quot;p2checkenv(__LINE__);&quot; ‚ð quot;p2checkenv(false);&quot; ‚ɏ‘‚«Š·‚¦‚Ä‚­‚¾‚³‚¢j</small></p>
+PHP {$recommended_version} ˆÈ~‚ɃAƒbƒvƒf[ƒg‚·‚邱‚Æ‚ð‚¨‚·‚·‚ß‚µ‚Ü‚·B</p>
+<p style="font-size:smaller">‚±‚̃ƒbƒZ[ƒW‚ð•\Ž¦‚µ‚È‚¢‚悤‚É‚·‚é‚É‚Í <em>{\$rep2_directory}</em>/conf/conf.inc.php ‚Ì {$check_recommended} s–ځA<br>
+<samp>p2checkenv(__LINE__);</samp> ‚ð <samp>p2checkenv(false);</samp> ‚ɏ‘‚«Š·‚¦‚Ä‚­‚¾‚³‚¢B</p>
 EOP;
-        return false;
+            }
+            return false;
+        }
     }
 
     return true;

Modified: p2ex/trunk/conf/conf_user_def.inc.php
===================================================================
--- p2ex/trunk/conf/conf_user_def.inc.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/conf/conf_user_def.inc.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -22,6 +22,10 @@
 // p2.2ch.net‚̃ƒOƒCƒ“ƒpƒXƒ[ƒh
 $conf_user_def['p2_2ch_pass'] = ""; // ("")
 
+// p2.2ch.net Cookie”FØŽž‚ÉIPƒAƒhƒŒƒX‚Ì“¯ˆê«‚ðƒ`ƒFƒbƒN
+$conf_user_def['p2_2ch_ignore_cip'] = 0; // (0)
+$conf_user_rad['p2_2ch_ignore_cip'] = array('0' => 'ƒ`ƒFƒbƒN‚·‚é', '1' => 'ƒ`ƒFƒbƒN‚µ‚È‚¢');
+
 // }}}
 // {{{ PATH
 

Modified: p2ex/trunk/edit_aborn_word.php
===================================================================
--- p2ex/trunk/edit_aborn_word.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/edit_aborn_word.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -7,35 +7,34 @@
 
 $_login->authorize(); // ƒ†[ƒU”FØ
 
-define('P2_SALT_EDIT_ABORN_WORD', basename(__FILE__));
+$filename = isset($_REQUEST['file']) ? $_REQUEST['file'] : '';
 
-$path = isset($_REQUEST['path']) ? $_REQUEST['path'] : '';
-$path_ht = htmlspecialchars($path, ENT_QUOTES);
-
+$csrfid = P2Util::getCsrfId(__FILE__ . $filename);
 if (!empty($_POST['submit_save']) || !empty($_POST['submit_default'])) {
-    if (!isset($_POST['csrfid']) or $_POST['csrfid'] != P2Util::getCsrfId(P2_SALT_EDIT_ABORN_WORD)) {
+    if (!isset($_POST['csrfid']) or $_POST['csrfid'] != $csrfid) {
         p2die('•s³‚ȃ|ƒXƒg‚Å‚·');
     }
 }
 
 $writable_files = array(
-    "p2_aborn_name.txt", "p2_aborn_mail.txt", "p2_aborn_msg.txt", "p2_aborn_id.txt",
-    "p2_ng_name.txt", "p2_ng_mail.txt", "p2_ng_msg.txt", "p2_ng_id.txt",
-    //"p2_aborn_res.txt",
+    'p2_aborn_thread.txt' => '‚ ‚ځ[‚ñƒXƒŒƒbƒhƒ^ƒCƒgƒ‹',
+    'p2_aborn_name.txt'   => '‚ ‚ځ[‚ñƒl[ƒ€',
+    'p2_aborn_mail.txt'   => '‚ ‚ځ[‚ñƒ[ƒ‹',
+    'p2_aborn_msg.txt'    => '‚ ‚ځ[‚ñƒƒbƒZ[ƒW',
+    'p2_aborn_id.txt'     => '‚ ‚ځ[‚ñID',
+    'p2_ng_name.txt'      => 'NGƒl[ƒ€',
+    'p2_ng_mail.txt'      => 'NGƒ[ƒ‹',
+    'p2_ng_msg.txt'       => 'NGƒƒbƒZ[ƒW',
+    'p2_ng_id.txt'        => 'NGID',
 );
 
-if ($writable_files and (!in_array(basename($path), $writable_files))) {
-    $i = 0;
-    foreach ($writable_files as $afile) {
-        if ($i != 0) {
-            $files_st .= "‚Æ";
-        }
-        $files_st .= "u".$afile."v";
-        $i++;
-    }
-    p2die(basename($_SERVER['SCRIPT_NAME']) . " æ¶‚̏‘‚«ž‚ß‚éƒtƒ@ƒCƒ‹‚́A{$files_st}‚¾‚¯I");
+if (!array_key_exists($filename, $writable_files)) {
+    $files_st = implode(', ', array_keys($writable_files));
+    p2die(basename($_SERVER['SCRIPT_NAME']) . " æ¶‚̏‘‚«ž‚ß‚éƒtƒ@ƒCƒ‹‚́A{$files_st} ‚¾‚¯I");
 }
 
+$path = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . $filename;
+
 //=====================================================================
 // ‘Oˆ—
 //=====================================================================
@@ -145,12 +144,10 @@
 //=====================================================================
 // ƒvƒŠƒ“ƒgÝ’è
 //=====================================================================
-$ptitle_top = sprintf('‚ ‚ځ[‚ñ/NGƒ[ƒh•ÒW &gt; <a href="%s?path=%s">%s</a>',
-    $_SERVER['SCRIPT_NAME'], rawurlencode($path), basename($path));
+$ptitle_top = sprintf('‚ ‚ځ[‚ñ/NGƒ[ƒh•ÒW &gt; <a href="%s?file=%s">%s</a>',
+    $_SERVER['SCRIPT_NAME'], rawurlencode($filename), $writable_files[$filename]);
 $ptitle = strip_tags($ptitle_top);
 
-$csrfid = P2Util::getCsrfId(P2_SALT_EDIT_ABORN_WORD);
-
 //=====================================================================
 // ƒvƒŠƒ“ƒg
 //=====================================================================
@@ -189,7 +186,7 @@
 <p id="pan_menu"><a href="editpref.php">Ý’èŠÇ—</a> &gt; {$ptitle_top}</p>\n
 EOP;
 } else {
-    echo basename($path) . "<br>";
+    echo $filename . "<br>";
 }
 
 // PC—p•\Ž¦
@@ -215,13 +212,19 @@
     $_info_msg_ht = "";
 }
 
+if ($filename == 'p2_aborn_thread.txt') {
+    $usage_ttitle = '<li>ƒXƒŒƒ^ƒC: u‚ ‚ځ[‚ñƒXƒŒƒbƒhƒ^ƒCƒgƒ‹v‚Å‚Í•sŽg—p</li>';
+} else {
+    $usage_ttitle = '<li>ƒXƒŒƒ^ƒC: ƒXƒŒƒbƒhƒ^ƒCƒgƒ‹ (•”•ªˆê’v, í‚ɑ啶Žš¬•¶Žš‚𖳎‹)</li>';
+}
+
 $usage = <<<EOP
 <ul>
 <li>ƒ[ƒh: NG/‚ ‚ځ[‚ñƒ[ƒh (‹ó‚É‚·‚é‚Æ“o˜^‰ðœ)</li>
 <li>i: ‘啶Žš¬•¶Žš‚𖳎‹</li>
 <li>re: ³‹K•\Œ»</li>
 <li>”Â: newsplus,software “™ (Š®‘Sˆê’v, ƒJƒ“ƒ}‹æØ‚è)</li>
-<li>ƒXƒŒƒ^ƒC: ƒXƒŒƒbƒhƒ^ƒCƒgƒ‹ (•”•ªˆê’v, í‚ɑ啶Žš¬•¶Žš‚𖳎‹)</li>
+{$usage_ttitle}
 </ul>
 EOP;
 if ($_conf['ktai']) {
@@ -230,7 +233,7 @@
 echo <<<EOP
 {$usage}
 <form method="POST" action="{$_SERVER['SCRIPT_NAME']}" target="_self" accept-charset="{$_conf['accept_charset']}">
-    <input type="hidden" name="path" value="{$path_ht}">
+    <input type="hidden" name="file" value="{$filename}">
     <input type="hidden" name="csrfid" value="{$csrfid}">\n
 EOP;
 

Modified: p2ex/trunk/edit_conf_user.php
===================================================================
--- p2ex/trunk/edit_conf_user.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/edit_conf_user.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -8,10 +8,10 @@
 
 $_login->authorize(); // ƒ†[ƒU”FØ
 
-define('P2_SALT_EDIT_CONF_USER', basename(__FILE__));
+$csrfid = P2Util::getCsrfId(__FILE__);
 
 if (!empty($_POST['submit_save']) || !empty($_POST['submit_default'])) {
-    if (!isset($_POST['csrfid']) or $_POST['csrfid'] != P2Util::getCsrfId(P2_SALT_EDIT_CONF_USER)) {
+    if (!isset($_POST['csrfid']) or $_POST['csrfid'] != $csrfid) {
         p2die('•s³‚ȃ|ƒXƒg‚Å‚·');
     }
 }
@@ -111,8 +111,6 @@
 //=====================================================================
 $ptitle = 'ƒ†[ƒUÝ’è•ÒW';
 
-$csrfid = P2Util::getCsrfId(P2_SALT_EDIT_CONF_USER);
-
 $me = P2Util::getMyUrl();
 
 //=====================================================================
@@ -202,6 +200,7 @@
         array('be_2ch_mail', 'be.2ch.net‚Ì“o˜^ƒ[ƒ‹ƒAƒhƒŒƒX', P2_EDIT_CONF_USER_LONGTEXT),
         array('p2_2ch_mail', '<a href="http://p2.2ch.net/" target="_blank">p2.2ch.net</a>‚Ì“o˜^ƒ[ƒ‹ƒAƒhƒŒƒX', P2_EDIT_CONF_USER_LONGTEXT),
         array('p2_2ch_pass', 'p2.2ch.net‚̃ƒOƒCƒ“ƒpƒXƒ[ƒh', P2_EDIT_CONF_USER_LONGTEXT | P2_EDIT_CONF_USER_PASSWORD),
+        array('p2_2ch_ignore_cip', ' p2.2ch.net Cookie”FØŽž‚ÉIPƒAƒhƒŒƒX‚Ì“¯ˆê«‚ðƒ`ƒFƒbƒN'),
     );
     printEditConfGroupHtml($groupname, $conflist, $flags);
 }

Modified: p2ex/trunk/editfile.php
===================================================================
--- p2ex/trunk/editfile.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/editfile.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -7,46 +7,41 @@
 
 $_login->authorize(); // ƒ†[ƒU”FØ
 
-// ˆø”ƒGƒ‰[
-if (!isset($_REQUEST['path'])) {
-    p2die('path ‚ªŽw’肳‚ê‚Ä‚¢‚Ü‚¹‚ñ');
-}
-
 // •Ï” ==================================
-$path       = isset($_REQUEST['path'])       ? $_REQUEST['path']       : null;
+$filename   = isset($_REQUEST['file'])       ? $_REQUEST['file']       : null;
 $modori_url = isset($_REQUEST['modori_url']) ? $_REQUEST['modori_url'] : null;
 $encode     = isset($_REQUEST['encode'])     ? $_REQUEST['encode']     : null;
 
 $rows = isset($_REQUEST['rows']) ? intval($_REQUEST['rows']) : ($_conf['ktai'] ? 5 : 36);
 $cols = isset($_REQUEST['cols']) ? intval($_REQUEST['cols']) : ($_conf['ktai'] ? 0 : 128);
 
-isset($_POST['filecont']) and $filecont = $_POST['filecont'];
+$csrfid = P2Util::getCsrfId(__FILE__ . $filename);
 
 //=========================================================
 // ‘Oˆ—
 //=========================================================
+
+// •s³ƒ|ƒXƒgƒ`ƒFƒbƒN
+if (isset($_POST['filecont'])) {
+    if (!isset($_POST['csrfid']) || $_POST['csrfid'] != $csrfid) {
+        p2die('•s³‚ȃ|ƒXƒg‚Å‚·');
+    } else {
+        $filecont = $_POST['filecont'];
+    }
+}
+
 // ‘‚«ž‚ß‚éƒtƒ@ƒCƒ‹‚ðŒÀ’è‚·‚é
 $writable_files = array(
-                        //"conf.inc.php", "conf_user_style.inc.php",
-                        //"p2_aborn_name.txt", "p2_aborn_mail.txt", "p2_aborn_msg.txt", "p2_aborn_id.txt",
-                        //"p2_ng_name.txt", "p2_ng_mail.txt", "p2_ng_msg.txt", "p2_ng_id.txt",
-                        "p2_aborn_res.txt",
-                        //"conf_user_ex.php", "conf_constant.inc",
-                        //"conf_user_ex.inc.php", "conf_user_constant.inc.php"
-                    );
+    'p2_aborn_res.txt'  => '‚ ‚ځ[‚ñƒŒƒX',
+);
 
-if ($writable_files and (!in_array(basename($path), $writable_files))) {
-    $i = 0;
-    foreach ($writable_files as $afile) {
-        if ($i != 0) {
-            $files_st .= "‚Æ";
-        }
-        $files_st .= "u".$afile."v";
-        $i++;
-    }
+if (!array_key_exists($filename, $writable_files)) {
+    $files_st = implode(', ', array_keys($writable_files));
     p2die(basename($_SERVER['SCRIPT_NAME']) . " æ¶‚̏‘‚«ž‚ß‚éƒtƒ@ƒCƒ‹‚́A{$files_st}‚¾‚¯I");
 }
 
+$path = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . $filename;
+
 //=========================================================
 // ƒƒCƒ“
 //=========================================================
@@ -56,7 +51,7 @@
     }
 }
 
-editFile($path, $encode);
+editFile($path, $encode, $writable_files[$filename]);
 
 exit;
 
@@ -92,16 +87,17 @@
 /**
  * ƒtƒ@ƒCƒ‹“à—e‚ð“ǂݍž‚ñ‚ŕҏW‚·‚éŠÖ”
  */
-function editFile($path, $encode)
+function editFile($path, $encode, $title)
 {
-    global $_conf, $modori_url, $_info_msg_ht, $rows, $cols;
+    global $_conf, $modori_url, $_info_msg_ht, $rows, $cols, $csrfid;
 
     if ($path == '') {
         p2die('path ‚ªŽw’肳‚ê‚Ä‚¢‚Ü‚¹‚ñ');
     }
 
     $filename = basename($path);
-    $ptitle = "Edit: ".$filename;
+    $ptitle = 'Edit: ' . htmlspecialchars($title, ENT_QUOTES, 'Shift_JIS')
+            . ' (' . $filename . ')';
 
     //ƒtƒ@ƒCƒ‹“à—e“ǂݍž‚Ý
     FileCtl::make_datafile($path) or p2die("cannot make file. ({$path})");
@@ -136,15 +132,15 @@
 EOHEADER;
 
     echo $modori_url_ht;
-
-    echo "Edit: ".$path;
+    echo $ptitle;
     echo <<<EOFORM
 <form action="{$_SERVER['SCRIPT_NAME']}" method="post" accept-charset="{$_conf['accept_charset']}">
-    <input type="hidden" name="path" value="{$path}">
+    <input type="hidden" name="file" value="{$filename}">
     <input type="hidden" name="modori_url" value="{$modori_url}">
     <input type="hidden" name="encode" value="{$encode}">
     <input type="hidden" name="rows" value="{$rows}">
     <input type="hidden" name="cols" value="{$cols}">
+    <input type="hidden" name="csrfid" value="{$csrfid}">
     <input type="submit" name="submit" value="Save">
     {$_info_msg_ht}<br>
     <textarea style="font-size:9pt;" id="filecont" name="filecont" wrap="off"{$rows_at}{$cols_at}>{$cont_area}</textarea>

Modified: p2ex/trunk/editpref.php
===================================================================
--- p2ex/trunk/editpref.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/editpref.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -162,15 +162,16 @@
 $_info_msg_ht = '';
 
 // Ý’èƒvƒŠƒ“ƒg
-$aborn_res_txt  = $_conf['pref_dir'] . '/p2_aborn_res.txt';
-$aborn_name_txt = $_conf['pref_dir'] . '/p2_aborn_name.txt';
-$aborn_mail_txt = $_conf['pref_dir'] . '/p2_aborn_mail.txt';
-$aborn_msg_txt  = $_conf['pref_dir'] . '/p2_aborn_msg.txt';
-$aborn_id_txt   = $_conf['pref_dir'] . '/p2_aborn_id.txt';
-$ng_name_txt    = $_conf['pref_dir'] . '/p2_ng_name.txt';
-$ng_mail_txt    = $_conf['pref_dir'] . '/p2_ng_mail.txt';
-$ng_msg_txt     = $_conf['pref_dir'] . '/p2_ng_msg.txt';
-$ng_id_txt      = $_conf['pref_dir'] . '/p2_ng_id.txt';
+$aborn_thread_txt   = 'p2_aborn_thread.txt';
+$aborn_res_txt      = 'p2_aborn_res.txt';
+$aborn_name_txt     = 'p2_aborn_name.txt';
+$aborn_mail_txt     = 'p2_aborn_mail.txt';
+$aborn_msg_txt      = 'p2_aborn_msg.txt';
+$aborn_id_txt       = 'p2_aborn_id.txt';
+$ng_name_txt        = 'p2_ng_name.txt';
+$ng_mail_txt        = 'p2_ng_mail.txt';
+$ng_msg_txt         = 'p2_ng_msg.txt';
+$ng_id_txt          = 'p2_ng_id.txt';
 
 echo '<div>';
 echo <<<EOP
@@ -178,14 +179,20 @@
 EOP;
 if (!$_conf['ktai'] && $_conf['expack.skin.enabled']) {
     $skin_options = array('conf_user_style' => '•W€');
-    if (is_dir('./skin')) {
-        foreach (glob('./skin/*.php') as $skin_file) {
-            $_name = basename($skin_file, '.php');
-            if (is_file($skin_file) && preg_match('/^\\w+$/', $_name)) {
-                $skin_options[$_name] = $_name;
+    foreach (array('./skin', './user_skin') as $skin_dir) {
+        if (is_dir($skin_dir)) {
+            foreach (glob("{$skin_dir}/*.php") as $skin_file) {
+                $_name = basename($skin_file, '.php');
+                if (!array_key_exists($_name, $skin_options) &&
+                    is_file($skin_file) &&
+                    preg_match('/^[0-9A-Za-z_\\-]+$/', $_name))
+                {
+                    $skin_options[$_name] = $_name;
+                }
             }
         }
     }
+    uksort($skin_options, 'compareSkinNames');
     $skin_options_ht = '';
     foreach ($skin_options as $_name => $_title) {
         $skin_options_ht .= sprintf('<option value="%s"%s>%s</option>',
@@ -215,10 +222,10 @@
 <fieldset>
 <legend><a href="http://akid.s17.xrea.com/p2puki/pukiwiki.php?%5B%5BNG%A5%EF%A1%BC%A5%C9%A4%CE%C0%DF%C4%EA%CA%FD%CB%A1%5D%5D" target="read">NGƒ[ƒh</a>•ÒW</legend>
 EOP;
-    printEditFileForm($ng_name_txt, "–¼‘O");
-    printEditFileForm($ng_mail_txt, "ƒ[ƒ‹");
-    printEditFileForm($ng_msg_txt, "ƒƒbƒZ[ƒW");
-    printEditFileForm($ng_id_txt, "‚h‚c");
+    printEditFileForm($ng_name_txt, '–¼‘O');
+    printEditFileForm($ng_mail_txt, 'ƒ[ƒ‹');
+    printEditFileForm($ng_msg_txt, '–{•¶');
+    printEditFileForm($ng_id_txt, 'ID');
     echo <<<EOP
 </fieldset>\n\n
 EOP;
@@ -234,11 +241,12 @@
 <fieldset>
 <legend>‚ ‚ځ[‚ñƒ[ƒh•ÒW</legend>\n
 EOP;
-    printEditFileForm($aborn_res_txt, "ƒŒƒX");
-    printEditFileForm($aborn_name_txt, "–¼‘O");
-    printEditFileForm($aborn_mail_txt, "ƒ[ƒ‹");
-    printEditFileForm($aborn_msg_txt, "ƒƒbƒZ[ƒW");
-    printEditFileForm($aborn_id_txt, "‚h‚c");
+    printEditFileForm($aborn_res_txt, 'ƒŒƒX');
+    printEditFileForm($aborn_name_txt, '–¼‘O');
+    printEditFileForm($aborn_mail_txt, 'ƒ[ƒ‹');
+    printEditFileForm($aborn_msg_txt, '–{•¶');
+    printEditFileForm($aborn_id_txt, 'ID');
+    printEditFileForm($aborn_thread_txt, 'ƒXƒŒƒbƒh');
     echo <<<EOP
 </fieldset>\n
 EOP;
@@ -246,27 +254,6 @@
     echo "</td></tr>";
 
     // }}}
-    // {{{ PC - ‚»‚Ì‘¼ ‚̐ݒè
-
-    //echo "<td>\n\n";
-    /*
-    php ‚Í editfile ‚µ‚È‚¢
-
-    echo <<<EOP
-<fieldset>
-<legend>‚»‚Ì‘¼</legend>
-EOP;
-    printEditFileForm("conf/conf_user_style.inc.php", 'ƒfƒUƒCƒ“Ý’è');
-    printEditFileForm("conf/conf.inc.php", 'Šî–{Ý’è');
-    echo <<<EOP
-</fieldset>\n
-EOP;
-    */
-
-    // }}}
-
-    //echo '&nbsp;';
-
     // {{{ PC - ƒzƒXƒg‚Ì“¯Šú HTML‚̃Zƒbƒg
 
     echo <<<EOP
@@ -329,21 +316,22 @@
 <p>±ÎÞÝ/NGÜ°ÄޕҏW</p>
 <form method="GET" action="edit_aborn_word.php">
 {$_conf['k_input_ht']}
-<select name="path">
+<select name="file">
+<option value="{$aborn_thread_txt}">盈渺:准</option>
 <option value="{$aborn_name_txt}">±ÎÞÝ:–¼‘O</option>
 <option value="{$aborn_mail_txt}">±ÎÞÝ:Ò°Ù</option>
-<option value="{$aborn_msg_txt}">盈渺:勵尚灼</option>
+<option value="{$aborn_msg_txt}">±ÎÞÝ:–{•¶</option>
 <option value="{$aborn_id_txt}">盈渺:ID</option>
 <option value="{$ng_name_txt}">NG:–¼‘O</option>
 <option value="{$ng_mail_txt}">NG:Ò°Ù</option>
-<option value="{$ng_msg_txt}">NG:勵尚灼</option>
+<option value="{$ng_msg_txt}">NG:–{•¶</option>
 <option value="{$ng_id_txt}">NG:ID</option>
 </select>
 <input type="submit" value="•ÒW">
 </form>
 <form method="GET" action="editfile.php">
 {$_conf['k_input_ht']}
-<input type="hidden" name="path" value="{$aborn_res_txt}">
+<input type="hidden" name="file" value="{$aborn_res_txt}">
 <input type="submit" value="±ÎÞÝÚ½•ÒW">
 </form>
 EOP;
@@ -425,16 +413,18 @@
 /**
  * Ý’èƒtƒ@ƒCƒ‹•ÒWƒEƒCƒ“ƒhƒE‚ðŠJ‚­ƒtƒH[ƒ€HTML‚ðƒvƒŠƒ“ƒg‚·‚é
  *
- * @param   string  $path_value     •ÒW‚·‚éƒtƒ@ƒCƒ‹‚̃pƒX
+ * @param   string  $filename       •ÒW‚·‚éƒtƒ@ƒCƒ‹–¼
  * @param   string  $submit_value   submitƒ{ƒ^ƒ“‚Ì’l
  * @return  void
  */
-function printEditFileForm($path_value, $submit_value)
+function printEditFileForm($filename, $submit_value)
 {
     global $_conf;
 
-    if ((file_exists($path_value) && is_writable($path_value)) ||
-        (!file_exists($path_value) && is_writable(dirname($path_value)))
+    $path = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . $filename;
+
+    if ((file_exists($path) && is_writable($path)) ||
+        (!file_exists($path) && is_writable(dirname($path)))
     ) {
         $onsubmit = '';
         $disabled = '';
@@ -446,18 +436,21 @@
     $rows = 36; // 18
     $cols = 92; // 90
 
-    if (preg_match('/^p2_(aborn|ng)_(name|mail|id|msg)\.txt$/', basename($path_value))) {
+    if ($filename == 'p2_aborn_thread.txt' ||
+        preg_match('/^p2_(aborn|ng)_(name|mail|id|msg)\\.txt$/', $filename))
+    {
         $edit_php = 'edit_aborn_word.php';
         $target = '_self';
     } else {
         $edit_php = 'editfile.php';
         $target = 'editfile';
     }
+    $filename_ht = htmlspecialchars($filename, ENT_QUOTES);
 
     $ht = <<<EOFORM
 <form action="{$edit_php}" method="GET" target="{$target}" class="inline-form"{$onsubmit}>
     {$_conf['k_input_ht']}
-    <input type="hidden" name="path" value="{$path_value}">
+    <input type="hidden" name="file" value="{$filename_ht}">
     <input type="hidden" name="encode" value="Shift_JIS">
     <input type="hidden" name="rows" value="{$rows}">
     <input type="hidden" name="cols" value="{$cols}">
@@ -632,7 +625,28 @@
 }
 
 // }}}
+// {{{ compareSkinNames()
 
+/**
+ * ƒXƒLƒ“‚̃ŠƒXƒg‚ðƒ\[ƒg‚·‚邽‚߂̃R[ƒ‹ƒoƒbƒNŠÖ”
+ *
+ * @param string $a
+ * @param string $b
+ * @return int
+ */
+function compareSkinNames($a, $b)
+{
+    if ($a == 'conf_user_style') {
+        return -1;
+    }
+    if ($b == 'conf_user_style') {
+        return 1;
+    }
+    return strcmp($a, $b);
+}
+
+// }}}
+
 /*
  * Local Variables:
  * mode: php

Modified: p2ex/trunk/lib/NgAbornCtl.php
===================================================================
--- p2ex/trunk/lib/NgAbornCtl.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/lib/NgAbornCtl.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -13,6 +13,7 @@
     'aborn_msg'     => 0,
     'aborn_name'    => 0,
     'aborn_res'     => 0,
+    'aborn_thread'  => 0,
     'ng_chain'      => 0,
     'ng_freq'       => 0,
     'ng_id'         => 0,
@@ -30,76 +31,106 @@
 
     /**
      * ‚ ‚ځ[‚ñ&NGƒ[ƒhÝ’è‚ð•Û‘¶‚·‚é
+     *
+     * @param void
+     * @return void
      */
     static public function saveNgAborns()
     {
         global $ngaborns, $ngaborns_hits;
         global $_conf;
 
-        // HIT‚µ‚½Žž‚̂ݍXV‚·‚é
-        if ($GLOBALS['ngaborns_hits']) {
+        $lasttime = date('Y/m/d G:i');
+        if ($_conf['ngaborn_daylimit']) {
+            $daylimit = time() - 60 * 60 * 24 * $_conf['ngaborn_daylimit'];
+        } else {
+            $daylimit = 0;
+        }
+        $errors = '';
 
-            $lasttime = date('Y/m/d G:i');
-            if ($_conf['ngaborn_daylimit']) {
-                $daylimit = time() - 60 * 60 * 24 * $_conf['ngaborn_daylimit'];
-            } else {
-                $daylimit = 0;
+        foreach ($ngaborns_hits as $code => $hits) {
+            // ƒqƒbƒg‚µ‚È‚©‚Á‚½ê‡‚Å‚à1/100‚ÌŠm—¦‚Ō¢ƒf[ƒ^‚ðíœ‚·‚邽‚߂ɏˆ—‚𑱂¯‚é
+            if (!$hits && mt_rand(1, 100) < 100) {
+                continue;
             }
-            $errors = '';
 
-            foreach ($ngaborns_hits as $code => $v) {
+            if (isset($ngaborns[$code]) && !empty($ngaborns[$code]['data'])) {
 
-                if (isset($ngaborns[$code]) && !empty($ngaborns[$code]['data'])) {
+                // XVŽžŠÔ‚Ń\[ƒg‚·‚é
+                usort($ngaborns[$code]['data'], array('NgAbornCtl', 'cmpLastTime'));
 
-                    // XVŽžŠÔ‚Ń\[ƒg‚·‚é
-                    usort($ngaborns[$code]['data'], array('NgAbornCtl', 'cmpLastTime'));
+                $cont = '';
+                foreach ($ngaborns[$code]['data'] as $a_ngaborn) {
 
-                    $cont = '';
-                    foreach ($ngaborns[$code]['data'] as $a_ngaborn) {
-
-                        if (empty($a_ngaborn['lasttime']) || $a_ngaborn['lasttime'] == '--') {
-                            // ŒÃ‚¢ƒf[ƒ^‚ðíœ‚·‚é“s‡ãA‰¼‚ÉŒ»Ý‚Ì“úŽž‚ð•t—^
-                            $a_ngaborn['lasttime'] = $lasttime;
-                         } else {
-                            // •K—v‚Ȃ炱‚±‚Ō¢ƒf[ƒ^‚̓XƒLƒbƒviíœj‚·‚é
-                            if ($daylimit > 0 && strtotime($a_ngaborn['lasttime']) < $daylimit) {
-                                continue;
-                            }
+                    if (empty($a_ngaborn['lasttime']) || $a_ngaborn['lasttime'] == '--') {
+                        // ŒÃ‚¢ƒf[ƒ^‚ðíœ‚·‚é“s‡ãA‰¼‚ÉŒ»Ý‚Ì“úŽž‚ð•t—^
+                        $a_ngaborn['lasttime'] = $lasttime;
+                     } else {
+                        // •K—v‚Ȃ炱‚±‚Ō¢ƒf[ƒ^‚̓XƒLƒbƒviíœj‚·‚é
+                        if ($daylimit > 0 && strtotime($a_ngaborn['lasttime']) < $daylimit) {
+                            continue;
                         }
+                    }
 
-                        $cont .= sprintf("%s\t%s\t%d\n", $a_ngaborn['cond'], $a_ngaborn['lasttime'], $a_ngaborn['hits']);
-                    } // foreach
+                    $cont .= sprintf("%s\t%s\t%d\n", $a_ngaborn['cond'], $a_ngaborn['lasttime'], $a_ngaborn['hits']);
+                } // foreach
 
-                    /*
-                    echo "<pre>";
-                    echo $cont;
-                    echo "</pre>";
-                    */
+                /*
+                echo "<pre>";
+                echo $cont;
+                echo "</pre>";
+                */
 
-                    // ‘‚«ž‚Þ
+                // ‘‚«ž‚Þ
 
-                    $fp = @fopen($ngaborns[$code]['file'], 'wb');
-                    if (!$fp) {
-                        $errors .= "cannot write. ({$ngaborns[$code]['file']})\n";
-                    } else {
-                        flock($fp, LOCK_EX);
-                        fputs($fp, $cont);
-                        flock($fp, LOCK_UN);
-                        fclose($fp);
-                    }
+                $fp = @fopen($ngaborns[$code]['file'], 'wb');
+                if (!$fp) {
+                    $errors .= "cannot write. ({$ngaborns[$code]['file']})\n";
+                } else {
+                    flock($fp, LOCK_EX);
+                    fputs($fp, $cont);
+                    flock($fp, LOCK_UN);
+                    fclose($fp);
+                }
 
-                } // if
+            } // if
 
-            } // foreach
+        } // foreach
 
-            if ($errors != '') {
-                p2die('NG‚ ‚ځ[‚ñƒtƒ@ƒCƒ‹‚ªXV‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½B', $errors);
-            }
+        if ($errors !== '') {
+            p2die('NG‚ ‚ځ[‚ñƒtƒ@ƒCƒ‹‚ªXV‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½B', $errors);
         }
-        return true;
     }
 
     // }}}
+    // {{{ saveAbornThreads()
+
+    /**
+     * ‚ ‚ځ[‚ñƒXƒŒƒbƒhÝ’è‚ð•Û‘¶‚·‚é
+     *
+     * @param array $aborn_threads
+     * @return void
+     */
+    static public function saveAbornThreads(array $aborn_threads)
+    {
+        if (array_key_exists('ngaborns', $GLOBALS)) {
+            $orig_ngaborns = $GLOBALS['ngaborns'];
+            $restore_ngaborns = true;
+        } else {
+            $restore_ngaborns = false;
+        }
+
+        $GLOBALS['ngaborns'] = array('aborn_thread' => $aborn_threads);
+        self::saveNgAborns();
+
+        if ($restore_ngaborns) {
+            $GLOBALS['ngaborns'] = $orig_ngaborns;
+        } else {
+            unset($GLOBALS['ngaborns']);
+        }
+    }
+
+    // }}}
     // {{{ cmpLastTime()
 
     /**
@@ -121,6 +152,9 @@
 
     /**
      * ‚ ‚ځ[‚ñ&NGƒ[ƒhÝ’è‚ð“ǂݍž‚Þ
+     *
+     * @param void
+     * @return array
      */
     static public function loadNgAborns()
     {
@@ -140,12 +174,26 @@
     }
 
     // }}}
+    // {{{ loadAbornThreads()
+
+    /**
+     * ‚ ‚ځ[‚ñƒXƒŒƒbƒhÝ’è‚ð“ǂݍž‚Þ
+     *
+     * @param void
+     * @return array
+     */
+    static public function loadAbornThreads()
+    {
+        return self::_readNgAbornFromFile('p2_aborn_thread.txt');
+    }
+
+    // }}}
     // {{{ _readNgAbornFromFile()
 
     /**
      * readNgAbornFromFile
      */
-    static private function _readNgAbornFromFile($filename)
+    static protected function _readNgAbornFromFile($filename)
     {
         global $_conf;
 

Modified: p2ex/trunk/lib/P2Client.php
===================================================================
--- p2ex/trunk/lib/P2Client.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/lib/P2Client.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -36,6 +36,8 @@
      */
     const REQUEST_PARAMETER_LOGIN_ID    = 'form_login_id';
     const REQUEST_PARAMETER_LOGIN_PASS  = 'form_login_pass';
+    const REQUEST_PARAMETER_LOGIN_REGIST_COOKIE = 'regist_cookie';
+    const REQUEST_PARAMETER_LOGIN_IGNORE_COOKIE_ADDR = 'ignore_cip';
     const REQUEST_PARAMETER_HOST    = 'host';
     const REQUEST_PARAMETER_BBS     = 'bbs';
     const REQUEST_PARAMETER_KEY     = 'key';
@@ -82,6 +84,13 @@
     private $_loginPass;
 
     /**
+     * p2.2ch.net Cookie”FØŽž‚ÉIPƒAƒhƒŒƒX‚Ì“¯ˆê«‚ðƒ`ƒFƒbƒN‚µ‚È‚¢
+     *
+     * @var bool
+     */
+    private $_ignoreCookieAddr;
+
+    /**
      * Cookie‚ð•Û‘¶‚·‚éKey-Value StoreƒIƒuƒWƒFƒNƒg
      *
      * @var P2KeyValueStore_Serializing
@@ -111,9 +120,10 @@
      * @param string $loginId
      * @param string $loginPass
      * @param string $cookieSaveDir
+     * @param bool $ignoreCookieAddr
      * @throws P2Exception
      */
-    public function __construct($loginId, $loginPass, $cookieSaveDir)
+    public function __construct($loginId, $loginPass, $cookieSaveDir, $ignoreCookieAddr = false)
     {
         try {
             $cookieSavePath = $cookieSaveDir . DIRECTORY_SEPARATOR . self::COOKIE_STORE_NAME;
@@ -135,6 +145,7 @@
         $this->_loginPass = $loginPass;
         $this->_cookieStore = $cookieStore;
         $this->_cookieManager = $cookieManager;
+        $this->_ignoreCookieAddr = $ignoreCookieAddr;
 
         $defaultHeaders = array(
             'User-Agent' => self::HTTP_USER_AGENT,
@@ -197,6 +208,12 @@
         $postData = $this->getFormValues($dom, $form, $postData);
         $postData[self::REQUEST_PARAMETER_LOGIN_ID] = rawurlencode($this->_loginId);
         $postData[self::REQUEST_PARAMETER_LOGIN_PASS] = rawurlencode($this->_loginPass);
+        $postData[self::REQUEST_PARAMETER_LOGIN_REGIST_COOKIE] = '1';
+        if ($this->_ignoreCookieAddr) {
+            $postData[self::REQUEST_PARAMETER_LOGIN_IGNORE_COOKIE_ADDR] = '1';
+        } elseif (array_key_exists(self::REQUEST_PARAMETER_LOGIN_IGNORE_COOKIE_ADDR, $postData)) {
+            unset($postData[self::REQUEST_PARAMETER_LOGIN_IGNORE_COOKIE_ADDR]);
+        }
 
         $response = $this->httpPost($uri, $postData, true);
 

Modified: p2ex/trunk/lib/P2Util.php
===================================================================
--- p2ex/trunk/lib/P2Util.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/lib/P2Util.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -1124,7 +1124,7 @@
             $key .= $_SESSION['login_microtime'];
         }
 
-        return strtr(rtrim(base64_encode(sha1($key, true)), '='), '+/', '-_');
+        return self::urlSafeBase64Encode(sha1($key, true));
     }
 
     // }}}
@@ -1810,13 +1810,46 @@
         }
 
         try {
-            return new P2Client($_conf['p2_2ch_mail'], $_conf['p2_2ch_pass'], $_conf['cookie_dir']);
+            return new P2Client($_conf['p2_2ch_mail'], $_conf['p2_2ch_pass'],
+                                $_conf['cookie_dir'], (bool)$_conf['p2_2ch_ignore_cip']);
         } catch (P2Exception $e) {
             p2die($e->getMessage());
         }
     }
 
     // }}}
+    // {{{ urlSafeBase64Decode()
+
+    /**
+     * URL-safe Base64 ƒfƒR[ƒh
+     *
+     * @param string $str
+     * @return string
+     */
+    static public function urlSafeBase64Decode($str)
+    {
+        $mod = strlen($str) % 4;
+        if ($mod) {
+            $str .= str_repeat('=', 4 - $mod);
+        }
+        return base64_decode(strtr($str, '-_', '+/'), true);
+    }
+
+    // }}}
+    // {{{ urlSafeBase64Encode()
+
+    /**
+     * URL-safe Base64 ƒGƒ“ƒR[ƒh
+     *
+     * @param string $str
+     * @return string
+     */
+    static public function urlSafeBase64Encode($str)
+    {
+        return strtr(rtrim(base64_encode($str), '='), '+/', '-_');
+    }
+
+    // }}}
     // {{{ debug()
     /*
     static public function debug()

Modified: p2ex/trunk/lib/Session.php
===================================================================
--- p2ex/trunk/lib/Session.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/lib/Session.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -48,14 +48,39 @@
      *
      * ‚±‚±‚ÅPHP‚Ì•W€ƒZƒbƒVƒ‡ƒ“‚ªƒXƒ^[ƒg‚·‚é
      */
-    public function __construct($session_name = NULL, $session_id = NULL)
+    public function __construct($session_name = null, $session_id = null, $use_cookies = true)
     {
-        session_cache_limiter('none'); // ƒLƒƒƒbƒVƒ…§Œä‚È‚µ
+        // ƒLƒƒƒbƒVƒ…§Œä‚È‚µ
+        session_cache_limiter('none');
 
-        if ($session_name) { session_name($session_name); }
-        if ($session_id)   { session_id($session_id); }
+        // ƒZƒbƒVƒ‡ƒ“–¼‚¨‚æ‚уZƒbƒVƒ‡ƒ“ID‚ðÝ’è
+        if ($session_name) {
+            session_name($session_name);
+        }
+        if ($session_id) {
+            session_id($session_id);
+        }
+
+        // CookieŽg—p‚̉”ۂɉž‚¶‚ÄiniƒfƒBƒŒƒNƒeƒBƒu‚ð•ÏX
+        if ($use_cookies) {
+            ini_set('session.use_cookies', 1);
+            ini_set('session.use_only_cookies', 1);
+        } else {
+            ini_set('session.use_cookies', 0);
+            ini_set('session.use_only_cookies', 0);
+        }
+
+        // ƒZƒbƒVƒ‡ƒ“ƒf[ƒ^‚ð‰Šú‰»‚·‚é
         session_start();
 
+        // Cookie‚ªŽg—p‚Å‚«‚¸Asession.use_trans_sid‚ªOff‚̏ꍇ
+        if (!$use_cookies && !ini_get('session.use_trans_sid')) {
+            $snm = session_name();
+            $sid = session_id();
+            output_add_rewrite_var($snm, $sid);
+            $GLOBALS['_conf']['sid_at_a'] = '&amp;' . rawurlencode($snm) . '=' . rawurlencode($sid);
+        }
+
         /*
         Expires: Thu, 19 Nov 1981 08:52:00 GMT
         Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Modified: p2ex/trunk/subject.php
===================================================================
--- p2ex/trunk/subject.php	2010-01-03 15:25:24 UTC (rev 764)
+++ p2ex/trunk/subject.php	2010-01-05 12:50:04 UTC (rev 765)
@@ -9,6 +9,7 @@
 require_once './conf/conf.inc.php';
 require_once P2_LIB_DIR . '/Thread.php';
 require_once P2_LIB_DIR . '/ThreadList.php';
+require_once P2_LIB_DIR . '/NgAbornCtl.php';
 
 //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('HEAD');
 
@@ -40,6 +41,19 @@
     p2die('•K—v‚Ȉø”‚ªŽw’肳‚ê‚Ä‚¢‚Ü‚¹‚ñ');
 }
 
+if ($spmode) {
+    $aborn_threads = null;
+} else {
+    $aborn_threads = NgAbornCtl::loadAbornThreads();
+    if (!is_array($aborn_threads) ||
+        !array_key_exists('data', $aborn_threads) ||
+        !is_array($aborn_threads['data']) ||
+        count($aborn_threads['data']) == 0)
+    {
+        $aborn_threads = null;
+    }
+}
+
 // }}}
 // {{{ p2_setting, sb_keys Ý’è
 
@@ -489,15 +503,23 @@
     //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('word_filter_for_sb');
 
     // }}}
-    // {{{ ¡ƒXƒŒƒbƒh‚ ‚ځ[‚ñƒ`ƒFƒbƒN
+    // {{{ ƒXƒŒƒbƒh‚ ‚ځ[‚ñƒ`ƒFƒbƒN
 
     //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('taborn_check_continue');
-    if ($aThreadList->spmode != "taborn" && !empty($ta_keys[$aThread->key])) {
+    if ($aThreadList->spmode != 'taborn' && !empty($ta_keys[$aThread->key])) {
         unset($ta_keys[$aThread->key]);
         //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('taborn_check_continue');
-        continue; // ‚ ‚ځ[‚ñƒXƒŒ‚̓XƒLƒbƒv
+        continue; // ŒÂ•Ê‚ ‚ځ[‚ñƒXƒŒƒbƒh‚̓XƒLƒbƒv
     }
     //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('taborn_check_continue');
+    //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('ttitle_aborn_check_continue');
+    if ($aborn_threads !== null && checkThreadTitleAborn($aborn_threads, $aThread)) {
+        unset($ta_keys[$aThread->key]);
+        $GLOBALS['ngaborns_hits']['aborn_thread']++;
+        //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ttitle_aborn_check_continue');
+        continue; // ƒ^ƒCƒgƒ‹‚ª‚ ‚ځ[‚ñƒ[ƒh‚Ƀ}ƒbƒ`‚µ‚½ƒXƒŒƒbƒh‚àƒXƒLƒbƒv
+    }
+    //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ttitle_aborn_check_continue');
 
     // }}}
 
@@ -858,6 +880,11 @@
     }
 }
 
+// ƒXƒŒƒbƒhƒ^ƒCƒgƒ‹‚ ‚ځ[‚ñ‹L˜^
+if ($aborn_threads !== null) {
+    NgAbornCtl::saveAbornThreads($aborn_threads);
+}
+
 //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('FOOT');
 
 // ‚±‚±‚Ü‚Å
@@ -1074,8 +1101,81 @@
 }
 
 // }}}
+// {{{ checkThreadTitleAborn()
+
+/**
+ * ƒXƒŒƒbƒhƒ^ƒCƒgƒ‹‚ ‚ځ[‚ñ‚ÌŒŸØ‚ð‚·‚é
+ *
+ * @param array &$aborn_threads
+ * @param Thread $aThread
+ * @return bool
+ */
+function checkThreadTitleAborn(array &$aborn_threads, Thread $aThread)
+{
+    $bbs = $aThread->bbs;
+    $subject = $aThread->ttitle;
+
+    foreach ($aborn_threads['data'] as $k => $v) {
+        // ”ƒ`ƒFƒbƒN
+        if (isset($v['bbs']) && in_array($bbs, $v['bbs']) == false) {
+            continue;
+        }
+
+        // ƒ[ƒhƒ`ƒFƒbƒN
+        // ³‹K•\Œ»
+        if ($v['regex']) {
+            $re_method = $v['regex'];
+            /*if ($re_method($v['word'], $subject, $matches)) {
+                updateThreadTitleAborn($aborn_threads, $k);
+                return true;
+            }*/
+             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);
+                return true;
+            }
+        // ’Pƒ‚É•¶Žš—ñ‚ªŠÜ‚Ü‚ê‚é‚©‚Ç‚¤‚©‚ðƒ`ƒFƒbƒN
+        } else {
+            if (strpos($subject, $v['word']) !== false) {
+                updateThreadTitleAborn($aborn_threads, $k);
+                return true;
+            }
+        }
+    }
+
+    return false;
+}
+
 // }}}
+// {{{ updateThreadTitleAborn()
 
+/**
+ * ƒXƒŒƒbƒhƒ^ƒCƒgƒ‹‚ ‚ځ[‚ñÅIƒqƒbƒg“úŽž‚Ɖñ”‚ðXV
+ *
+ * @param array &$aborn_threads
+ * @param int $idx
+ * @return void
+ */
+function updateThreadTitleAborn(array &$aborn_threads, $idx)
+{
+    if (array_key_exists($idx, $aborn_threads['data'])) {
+        $aborn_threads['data'][$idx]['lasttime'] = date('Y/m/d G:i'); // HITŽžŠÔ‚ðXV
+        if (empty($aborn_threads['data'][$idx]['hits'])) {
+            $aborn_threads['data'][$idx]['hits'] = 1; // ‰HIT
+        } else {
+            $aborn_threads['data'][$idx]['hits']++; // HIT‰ñ”‚ðXV
+        }
+    }
+}
+
+// }}}
+// }}}
+
 /*
  * Local Variables:
  * mode: php



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