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

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 1月 14日 (木) 08:31:20 JST


Revision: 778
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=778
Author:   rsk
Date:     2010-01-14 08:31:20 +0900 (Thu, 14 Jan 2010)

Log Message:
-----------
expack:
- conf.inc.phpから関数と環境チェックに使う変数をそれぞれ別ファイルに分割。
- 一部のファイルをrep2 1.8.xに合わせてリネーム。

Modified Paths:
--------------
    p2ex/trunk/conf/conf.inc.php
    p2ex/trunk/lib/Login.php
    p2ex/trunk/lib/P2Util.php
    p2ex/trunk/lib/bootstrap.php
    p2ex/trunk/lib/migrators/100113_1300.php
    p2ex/trunk/lib/migrators/yymmdd_hhmm.php

Added Paths:
-----------
    p2ex/trunk/conf/setup_info.php
    p2ex/trunk/lib/global.funcs.php
    p2ex/trunk/lib/md5_crypt.funcs.php
    p2ex/trunk/lib/setup.funcs.php

Removed Paths:
-------------
    p2ex/trunk/lib/md5_crypt.inc.php
    p2ex/trunk/lib/p2util.inc.php


-------------- next part --------------
Modified: p2ex/trunk/conf/conf.inc.php
===================================================================
--- p2ex/trunk/conf/conf.inc.php	2010-01-13 16:07:10 UTC (rev 777)
+++ p2ex/trunk/conf/conf.inc.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -49,7 +49,7 @@
 // }}}
 
 // Šî–{Ý’菈—‚ðŽÀs
-p2configure();
+p2_init();
 
 // ƒNƒŠ[ƒ“ƒAƒbƒv
 if (basename($_SERVER['SCRIPT_NAME']) != 'edit_conf_user.php') {
@@ -62,12 +62,12 @@
 $htm = array();
 $word = null;
 
-// {{{ p2configure()
+// {{{ p2_init()
 
 /**
  * ˆêŽž•Ï”‚ŃOƒ[ƒoƒ‹•Ï”‚ð‰˜õ‚µ‚È‚¢‚悤‚ɐݒ菈—‚ðŠÖ”‰»
  */
-function p2configure()
+function p2_init()
 {
     global $MYSTYLE, $STYLE, $debug;
     global $skin, $skin_en, $skin_name, $skin_uniq;
@@ -183,36 +183,23 @@
     // ŒŸõƒpƒX‚ðƒZƒbƒg
     $include_path = '';
     if (defined('P2_PEAR_HACK_DIR')) {
-        $include_path .= P2_PEAR_HACK_DIR . PATH_SEPARATOR;
+        $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;
-                }
-            }
-        }
-        if (count($paths)) {
-            $include_path .= implode(PATH_SEPARATOR, array_unique($paths)) . PATH_SEPARATOR;
-        }
     }
-    $include_path .= P2_BASE_DIR; // fallback
-    set_include_path($include_path);
-    spl_autoload_register('p2autoload');
+    set_include_path($include_path . get_include_path());
 
     // }}}
     // {{{ ŠÂ‹«ƒ`ƒFƒbƒN‚ƃfƒoƒbƒO
 
     // ƒ†[ƒeƒBƒŠƒeƒB‚ð“ǂݍž‚Þ
-    include P2_LIB_DIR . '/p2util.inc.php';
+    include P2_LIB_DIR . '/global.funcs.php';
+    include P2_LIB_DIR . '/setup.funcs.php';
+    spl_autoload_register('p2_load_class');
 
     // “®ìŠÂ‹«‚ðŠm”F (—vŒ‚ð–ž‚½‚µ‚Ä‚¢‚é‚È‚çƒRƒƒ“ƒgƒAƒEƒg‰Â)
-    p2checkenv(__LINE__);
+    p2_check_environment(__LINE__);
 
     if ($debug) {
         if (!class_exists('Benchmark_Profiler', false)) {
@@ -226,8 +213,7 @@
     // }}}
     // {{{ •¶ŽšƒR[ƒh‚ÌŽw’è
 
-    //mb_detect_order("CP932,CP51932,ASCII");
-    mb_internal_encoding('CP932');
+    mb_internal_encoding('SJIS-win');
     mb_http_output('pass');
     mb_substitute_character(63); // •¶ŽšƒR[ƒh•ÏŠ·‚ÉŽ¸”s‚µ‚½•¶Žš‚ª "?" ‚É‚È‚é
     //mb_substitute_character(0x3013); // ¬
@@ -235,7 +221,7 @@
 
     if (function_exists('mb_ereg_replace')) {
         define('P2_MBREGEX_AVAILABLE', 1);
-        mb_regex_encoding('CP932');
+        mb_regex_encoding('SJIS-win');
     } else {
         define('P2_MBREGEX_AVAILABLE', 0);
     }
@@ -279,7 +265,7 @@
     $_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_utf8'] = mb_convert_encoding('ž', 'UTF-8', 'SJIS-win');
     $_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'])
 
@@ -337,214 +323,7 @@
 }
 
 // }}}
-// {{{ p2checkenv()
 
-/**
- * “®ìŠÂ‹«‚ðŠm”F‚·‚é
- *
- * @return bool
- */
-function p2checkenv($check_recommended)
-{
-    global $_info_msg_ht;
-
-    $php_version = phpversion();
-    $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, '<')) {
-        p2die("PHP {$required_version} –¢–ž‚Å‚ÍŽg‚¦‚Ü‚¹‚ñB");
-    }
-
-    // •K{Šg’£ƒ‚ƒWƒ…[ƒ‹
-    foreach ($required_extensions as $ext) {
-        if (!extension_loaded($ext)) {
-            p2die("{$ext} Šg’£ƒ‚ƒWƒ…[ƒ‹‚ªƒ[ƒh‚³‚ê‚Ä‚¢‚Ü‚¹‚ñB");
-        }
-    }
-
-    // —LŒø‚¾‚Æ“®ì‚µ‚È‚¢php.iniƒfƒBƒŒƒNƒeƒBƒu
-    $directives = array(
-        'safe_mode',
-        'register_globals',
-        'magic_quotes_gpc',
-        'mbstring.encoding_translation',
-        'session.cookie_httponly',
-    );
-    foreach ($directives as $directive) {
-        if (ini_get($directive)) {
-            p2die("{$directive} ‚ª On ‚Å‚·B",
-                  "php.ini ‚Å {$directive} ‚ð Off ‚É‚µ‚Ä‚­‚¾‚³‚¢B");
-        }
-    }
-
-    // eAccelerator
-    if (extension_loaded('eaccelerator') &&
-        version_compare(EACCELERATOR_VERSION, '0.9.5.2', '<'))
-    {
-        $err = 'eAccelerator‚ðXV‚µ‚Ä‚­‚¾‚³‚¢B';
-        $ev = EACCELERATOR_VERSION;
-        $msg = <<<EOP
-<p>PHP 5.2‚Å—áŠO‚ð•ß‘¨‚Å‚«‚È‚¢–â‘è‚Ì‚ ‚éeAccelerator ({$ev})‚ªƒCƒ“ƒXƒg[ƒ‹‚³‚ê‚Ä‚¢‚Ü‚·B<br>
-eAccelerator‚𖳌ø‚É‚·‚é‚©A‚±‚Ì–â‘肪C³‚³‚ꂽeAccelerator 0.9.5.2ˆÈ~‚ðŽg—p‚µ‚Ä‚­‚¾‚³‚¢B<br>
-<a href="http://eaccelerator.net/">http://eaccelerator.net/</a></p>
-EOP;
-        p2die($err, $msg, true);
-    }
-
-    // „§ƒo[ƒWƒ‡ƒ“
-    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</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 true;
-}
-
-// }}}
-// {{{ p2checkmigration()
-
-/**
- * ƒ}ƒCƒOƒŒ[ƒVƒ‡ƒ“‚Ì•K—v‚ª‚ ‚é‚©‚Ç‚¤‚©‚ðƒ`ƒFƒbƒN
- *
- * @param   string  $config_version
- * @return  array
- */
-function p2checkmigration($config_version)
-{
-    // "yymmdd.hhmm" Œ`Ž®‚̃}ƒCƒOƒŒ[ƒVƒ‡ƒ“‚ª•K—v‚ȕύX‚Ì‚ ‚Á‚½ƒo[ƒWƒ‡ƒ“”ԍ†‚Ì”z—ñ
-    // ’l‚̓†ƒj[ƒN‚©‚¸‡‚Ƀ\[ƒg‚³‚ê‚Ä‚¢‚È‚¯‚ê‚΂Ȃç‚È‚¢
-    $versions = array(
-        '100113.1300',
-    );
-
-    $migrators = array();
-    $found = false;
-
-    foreach ($versions as $version) {
-        if ($found || version_compare($config_version, $version, '<')) {
-            $found = true;
-            $migrator_name = str_replace('.', '_', $version);
-            $migrator_func = 'p2_migrate_' . $migrator_name;
-            $migrator_file = '/migrators/' . $migrator_name . '.php';
-            $migrators[$migrator_func] = $migrator_file;
-        }
-    }
-
-    if ($found) {
-        return $migrators;
-    } else {
-        return null;
-    }
-}
-
-// }}}
-// {{{ p2migrate()
-
-/**
- * ƒ}ƒCƒOƒŒ[ƒVƒ‡ƒ“‚ðŽÀs
- *
- * @param array $user_conf ŒÃ‚¢ƒ†[ƒU[Ý’è
- * @param array $migrators ƒ}ƒCƒOƒŒ[ƒVƒ‡ƒ“ŠÖ”‚̃ŠƒXƒg
- * @return array V‚µ‚¢ƒ†[ƒU[Ý’è
- */
-function p2migrate(array $user_conf, array $migrators)
-{
-    global $_conf;
-
-    foreach ($migrators as $migrator_func => $migrator_file) {
-        include P2_LIB_DIR . $migrator_file;
-        $user_conf = $migrator_func($_conf, $user_conf);
-    }
-
-    return $user_conf;
-}
-
-// }}}
-// {{{ p2autoload()
-
-/**
- * ƒNƒ‰ƒXƒ[ƒ_[
- *
- * @string $name
- * @return void
- */
-function p2autoload($name)
-{
-    if (preg_match('/^(?:
-            BbsMap |
-            BrdCtl |
-            BrdMenu\\w* |
-            DataPhp |
-            FavSetManager |
-            FileCtl |
-            HostCheck |
-            Login |
-            NgAbornCtl |
-            P2\\w+ |
-            PresetManager |
-            ResHist |
-            Session |
-            SettingTxt |
-            ShowBrdMenu\\w* |
-            ShowThread\\w* |
-            StrCtl |
-            StrSjis |
-            SubjectTxt |
-            Thread\\w* |
-            Wap\\w+
-        )$/x', $name))
-    {
-        if ($name == 'P2Lock') {
-            include P2_LIB_DIR . '/FileCtl.php';
-        } elseif ($name == 'ResArticle') {
-            include P2_LIB_DIR . '/ResHist.php';
-        } elseif (strncmp($name, 'Wap', 3) === 0) {
-            include P2_LIB_DIR . '/Wap.php';
-        } elseif (strncmp($name, 'P2Http', 6) === 0) {
-            include P2_LIB_DIR . '/P2HttpExt.php';
-        } elseif (strncmp($name, 'BrdMenu', 7) === 0) {
-            include P2_LIB_DIR . '/BrdMenu.php';
-        } else {
-            include P2_LIB_DIR . '/' . $name . '.php';
-        }
-    } elseif (preg_match('/^\\w+DataStore$/', $name)) {
-        include P2_LIB_DIR . '/P2DataStore/' . $name . '.php';
-    }
-}
-
-// }}}
-
 /*
  * Local Variables:
  * mode: php

Added: p2ex/trunk/conf/setup_info.php
===================================================================
--- p2ex/trunk/conf/setup_info.php	                        (rev 0)
+++ p2ex/trunk/conf/setup_info.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -0,0 +1,53 @@
+<?php
+/**
+ * rep2expack - ŠÂ‹«ƒ`ƒFƒbƒN‚ÅŽg—p‚·‚é•Ï”
+ */
+
+// •K{ƒo[ƒWƒ‡ƒ“
+$p2_required_version_5_2 = '5.2.8';
+$p2_required_version_5_3 = '5.3.0';
+
+// „§ƒo[ƒWƒ‡ƒ“
+$p2_recommended_version_5_2 = '5.2.12';
+$p2_recommended_version_5_3 = '5.3.1';
+
+// •K{Šg’£ƒ‚ƒWƒ…[ƒ‹
+$p2_required_extensions = array(
+    'dom',
+    'json',
+    'libxml',
+    'mbstring',
+    'pcre',
+    'pdo',
+    'pdo_sqlite',
+    'session',
+    'spl',
+    //'xsl',
+    'zlib',
+);
+
+// —LŒø‚¾‚Æ“®ì‚µ‚È‚¢php.iniƒfƒBƒŒƒNƒeƒBƒu
+$p2_incompatible_ini_directives = array(
+    'safe_mode',
+    'register_globals',
+    'magic_quotes_gpc',
+    'mbstring.encoding_translation',
+    'session.cookie_httponly',
+);
+
+// ˆÚsƒXƒNƒŠƒvƒg‚ÌŽÀs‚ª•K—v‚ȕύX‚Ì‚ ‚Á‚½ƒo[ƒWƒ‡ƒ“”ԍ†‚Ì”z—ñ
+// ’l‚Í "yymmdd.hhmm" Œ`Ž®‚цƒj[ƒN‚©‚¸‡‚Ƀ\[ƒg‚³‚ê‚Ä‚¢‚È‚¯‚ê‚΂Ȃç‚È‚¢
+$p2_changed_versions = array(
+    '100113.1300',
+);
+
+/*
+ * 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/Login.php
===================================================================
--- p2ex/trunk/lib/Login.php	2010-01-13 16:07:10 UTC (rev 777)
+++ p2ex/trunk/lib/Login.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -732,7 +732,9 @@
             return false;
         }
 
-        require_once P2_LIB_DIR . '/md5_crypt.inc.php';
+        if (!function_exists('md5_encrypt')) {
+            include P2_LIB_DIR . '/md5_crypt.funcs.php';
+        }
 
         $key = $this->getMd5CryptKey();
 
@@ -756,7 +758,9 @@
     {
         global $_conf;
 
-        require_once P2_LIB_DIR . '/md5_crypt.inc.php';
+        if (!function_exists('md5_decrypt')) {
+            include P2_LIB_DIR . '/md5_crypt.funcs.php';
+        }
 
         $key = $this->getMd5CryptKey();
 

Modified: p2ex/trunk/lib/P2Util.php
===================================================================
--- p2ex/trunk/lib/P2Util.php	2010-01-13 16:07:10 UTC (rev 777)
+++ p2ex/trunk/lib/P2Util.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -1060,7 +1060,9 @@
     {
         global $_conf;
 
-        require_once P2_LIB_DIR . '/md5_crypt.inc.php';
+        if (!function_exists('md5_encrypt')) {
+            include P2_LIB_DIR . '/md5_crypt.funcs.php';
+        }
 
         $md5_crypt_key = self::getAngoKey();
         $crypted_login2chPW = md5_encrypt($login2chPW, $md5_crypt_key, 32);
@@ -1094,7 +1096,9 @@
     {
         global $_conf;
 
-        require_once P2_LIB_DIR . '/md5_crypt.inc.php';
+        if (!function_exists('md5_decrypt')) {
+            include P2_LIB_DIR . '/md5_crypt.funcs.php';
+        }
 
         if (!file_exists($_conf['idpw2ch_php'])) {
             return false;

Modified: p2ex/trunk/lib/bootstrap.php
===================================================================
--- p2ex/trunk/lib/bootstrap.php	2010-01-13 16:07:10 UTC (rev 777)
+++ p2ex/trunk/lib/bootstrap.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -1,7 +1,7 @@
 <?php
 /**
  * rep2expack - ‰Šú‰»ƒXƒNƒŠƒvƒg
- * conf/conf.inc.php ‚Ì p2configure() ‚©‚ç“ǂݍž‚Ü‚ê‚éB
+ * conf/conf.inc.php ‚Ì p2_init() ‚©‚ç“ǂݍž‚Ü‚ê‚éB
  */
 
 require_once 'Net/UserAgent/Mobile.php';
@@ -41,8 +41,8 @@
 
     if ($config_version !== $_conf['p2expack']) {
         // Ý’è‚̍XV
-        if ($migrators = p2checkmigration($config_version)) {
-            $conf_user = p2migrate($conf_user, $migrators);
+        if ($migrators = p2_check_migration($config_version)) {
+            $conf_user = p2_invoke_migrators($migrators, $conf_user);
         }
 
         // ƒfƒtƒHƒ‹ƒgÝ’è‚ð“ǂݍž‚݁Aƒ†[ƒU[Ý’è‚Æ‚Æ‚à‚Ƀ}[ƒW

Copied: p2ex/trunk/lib/global.funcs.php (from rev 777, p2ex/trunk/lib/p2util.inc.php)
===================================================================
--- p2ex/trunk/lib/global.funcs.php	                        (rev 0)
+++ p2ex/trunk/lib/global.funcs.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -0,0 +1,621 @@
+<?php
+/**
+ * rep2expack - ƒ†[ƒeƒBƒŠƒeƒBŠÖ”ŒQ
+ */
+
+// {{{ CONSTANTS
+
+/**
+ * ®”‚̍őå’l‚ƍŏ¬’l
+ */
+define('P2_INT_MAX', PHP_INT_MAX);
+define('P2_INT_MIN', - PHP_INT_MAX - 1);
+
+/**
+ * Š¿Žš‚Ƀ}ƒbƒ`‚·‚鐳‹K•\Œ»
+ */
+//define('P2_REGEX_KANJI', mb_convert_encoding('/[ˆê-êž]/u', 'UTF-8', 'SJIS-win'));
+define('P2_REGEX_KANJI', '/[\\x{4e00}-\\x{9fa0}]/u');
+
+/**
+ *‚·‚²‚­“K“–‚È•ª‚©‚¿‘‚«—p³‹K•\Œ»
+ */
+/*
+define('P2_REGEX_WAKATI', mb_convert_encoding('/(' . implode('|', array(
+    //'[ˆê-êž]+[‚Ÿ-‚ñ]*',
+    //'[ˆê-êž]+',
+    '[ˆê“ñŽOŽlŒÜ˜ZŽµ”ª‹ã\]+',
+    '[’š-êž]+',
+    '[‚Ÿ-‚ñ][‚Ÿ-‚ñ[`JK]*',
+    '[ƒ@-ƒ–][ƒ@-ƒ–[`JK]*',
+    //'[a-z][a-z_\\-]*',
+    //'[0-9][0-9.]*',
+    '[0-9a-z][0-9a-z_\\-]*',
+)) . ')/u', 'UTF-8', 'SJIS-win'));
+*/
+define('P2_REGEX_WAKATI', '/(
+#[\\x{4e00}-\\x{9fa0}]+[\\x{3041}-\\x{3093}]*|
+#[\\x{4e00}-\\x{9fa0}]+|
+[\\x{4e00}\\x{4e8c}\\x{4e09}\\x{56db}\\x{4e94}\\x{516d}\\x{4e03}\\x{516b}\\x{4e5d}\\x{5341}]+|
+[\\x{4e01}-\\x{9fa0}]+|
+[\\x{3041}-\\x{3093}][\\x{3041}-\\x{3093}\\x{30fc}\\x{301c}\\x{309b}\\x{309c}]*|
+[\\x{30a1}-\\x{30f6}][\\x{30a1}-\\x{30f6}\\x{30fc}\\x{301c}\\x{309b}\\x{309c}]*|
+#[a-z][a-z_\\-]*|
+#[0-9][0-9.]*|
+[0-9a-z][0-9a-z_\\-]*)/ux');
+
+/**
+ * UTF-8,NFD‚̂Ђ炪‚ȁEƒJƒ^ƒJƒi‚Ì‘÷‰¹E”¼‘÷‰¹‚Ƀ}ƒbƒ`‚·‚鐳‹K•\Œ»
+ */
+/*
+define('P2_REGEX_NFD_KANA',
+    str_replace(
+        array('%u3099%', '%u309A%'),
+        array(pack('C*', 0xE3, 0x82, 0x99), pack('C*', 0xE3, 0x82, 0x9A)),
+        mb_convert_encoding(
+            '/([‚¤‚©-‚±‚³-‚»‚½-‚Æ‚Í-‚ÙƒEƒJ-ƒRƒT-ƒ\ƒ^-ƒgƒn-ƒzTR])%u3099%|([‚Í-‚Ùƒn-ƒz])%u309A%/u',
+            'UTF-8',
+            'SJIS-win'
+        )
+    )
+);
+*/
+define('P2_REGEX_NFD_KANA', '/([\\x{3046}\\x{304b}-\\x{3053}\\x{3055}-\\x{305d}\\x{305f}-\\x{3068}\\x{306f}-\\x{307b}\\x{30a6}\\x{30ab}-\\x{30b3}\\x{30b5}-\\x{30bd}\\x{30bf}-\\x{30c8}\\x{30cf}-\\x{30db}\\x{309d}\\x{30fd}])\\x{3099}|([\\x{306f}-\\x{307b}\\x{30cf}-\\x{30db}])\\x{309a}/u');
+
+// }}}
+// {{{ p2h()
+
+/**
+* htmlspecialchars($value, ENT_QUOTES) ‚̃Vƒ‡[ƒgƒJƒbƒg
+*
+* @param    string $str
+* @param    string $charset
+* @param    bool   $double_encode
+* @return   string
+*/
+function p2h($str, $charset = 'Shift_JIS', $double_encode = true)
+{
+    return htmlspecialchars($str, ENT_QUOTES, $charset, $double_encode);
+}
+
+// }}}
+// {{{ p2die()
+
+/**
+ * ƒƒbƒZ[ƒW‚ð•\Ž¦‚µ‚ďI—¹
+ * ƒwƒbƒ_‚ªo—Í‚³‚ê‚Ä‚¢‚éê‡A<body>‚܂ł͏o—͍ςƌ©‚È‚·
+ *
+ * I—¹ƒXƒe[ƒ^ƒXƒR[ƒh2‚ÍP2CommandRunner‚ɃGƒ‰[ƒƒbƒZ[ƒW‚ª
+ * HTML‚Å‚ ‚邱‚Æ‚ð’Ê’m‚·‚邽‚ß
+ *
+ * @param   string $err ƒGƒ‰[ŠT—v
+ * @param   string $msg Ú×‚Èà–¾
+ * @param   bool   $raw Ú×‚Èà–¾‚ðƒGƒXƒP[ƒv‚·‚é‚©”Û‚©
+ * @return  void
+ */
+function p2die($err = null, $msg = null, $raw = false)
+{
+    if (!defined('P2_CLI_RUN') && !headers_sent()) {
+        header('Expires: ' . http_date(0)); // “ú•t‚ª‰ß‹Ž
+        header('Last-Modified: ' . http_date()); // í‚ɏC³‚³‚ê‚Ä‚¢‚é
+        header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
+        header('Cache-Control: post-check=0, pre-check=0', false);
+        header('Pragma: no-cache'); // HTTP/1.0
+        echo <<<EOH
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
+{$GLOBALS['_conf']['extra_headers_ht']}
+<title>rep2 error</title>
+</head>
+<body>
+EOH;
+    }
+
+    echo '<h3>rep2 error</h3>';
+
+    if ($err !== null) {
+        echo '<p><strong>', htmlspecialchars($err, ENT_QUOTES), '</strong></p>';
+    }
+
+    if ($msg !== null) {
+        if ($raw) {
+            echo $msg;
+        } else {
+            echo '<p>', nl2br(htmlspecialchars($msg, ENT_QUOTES)), '</p>';
+        }
+    }
+
+    if (true) {
+        echo '<pre><em>backtrace:</em>';
+
+        $p2_file_prefix = P2_BASE_DIR . DIRECTORY_SEPARATOR;
+        $p2_base_dir_len = strlen(P2_BASE_DIR);
+        $backtrace = debug_backtrace();
+        $c = count($backtrace);
+
+        foreach ($backtrace as $bt) {
+            echo "\n";
+
+            if (strpos($bt['file'], $p2_file_prefix) === 0) {
+                $filename = '.' . substr($bt['file'], $p2_base_dir_len);
+            } else {
+                $filename = '(external)' . DIRECTORY_SEPARATOR . basename($bt['file']);
+            }
+            printf('  % 2d. %s (line %d)', $c--, $filename, $bt['line']);
+
+            if (array_key_exists('function', $bt) && $bt['function'] !== '' && $bt['function'] !== 'p2die') {
+                if (array_key_exists('class', $bt) && $bt['class'] !== '') {
+                    printf(': %s%s%s()',
+                           $bt['class'],
+                           str_replace('>', '&gt;', $bt['type']),
+                           $bt['function']
+                           );
+                } else {
+                    printf(': %s()', $bt['function']);
+                }
+            }
+        }
+
+        echo '</pre>';
+    }
+
+    if (!defined('P2_CLI_RUN')) {
+        echo '</body></html>';
+    }
+    exit(2);
+}
+
+// }}}
+// {{{ http_date()
+
+if (!function_exists('http_date')) {
+    /**
+     * pecl_http‚Ìhttp_date()‚ÌPure PHP”Å
+     *
+     * @param   int $timestamp
+     * @return  string
+     */
+    function http_date($timestamp = null)
+    {
+        if ($timestamp === null) {
+            //return str_replace('+0000', 'GMT', gmdate(DATE_RFC1123));
+            return gmdate('D, d M Y H:i:s \\G\\M\\T');
+        }
+        //return str_replace('+0000', 'GMT', gmdate(DATE_RFC1123, $timestamp));
+        return gmdate('D, d M Y H:i:s \\G\\M\\T', $timestamp);
+    }
+}
+
+// }}}
+// {{{ ctype
+
+/**
+ * ctypeŠg’£ƒ‚ƒWƒ…[ƒ‹ŠÖ”‚ÌPure PHP”Å (cntrl,graph,print,punct,space‚ÍŠ„ˆ¤)
+ */
+if (!extension_loaded('ctype')) {
+    function ctype_alnum($str) { return (bool)preg_match('/^[0-9A-Za-z]+$/', $str); }
+    function ctype_alpha($str) { return (bool)preg_match('/^[A-Za-z]+$/', $str); }
+    function ctype_digit($str) { return (bool)preg_match('/^[0-9]+$/', $str); }
+    function ctype_lower($str) { return (bool)preg_match('/^[a-z]+$/', $str); }
+    function ctype_upper($str) { return (bool)preg_match('/^[A-Z]+$/', $str); }
+    function ctype_xdigit($str) { return (bool)preg_match('/^[0-9A-Fa-f]+$/', $str); }
+}
+
+// }}}
+// {{{ p2_scan_nullbyte()
+
+/**
+ * ƒŠƒNƒGƒXƒgƒpƒ‰ƒ[ƒ^‚©‚çNULLƒoƒCƒg‚ðŒŸo‚µ‚½‚çI—¹‚·‚é
+ * array_walk_recursive() —pƒR[ƒ‹ƒoƒbƒNŠÖ”
+ *
+ * @param   mixed   $value 
+ * @param   mixed   $key
+ * @return  void
+ */
+function p2_scan_nullbyte($value, $key)
+{
+    if (is_string($value) && strpos($value, P2_NULLBYTE) !== false) {
+        p2die('ƒŠƒNƒGƒXƒgƒpƒ‰ƒ[ƒ^‚ÉNULLƒoƒCƒg‚ªŠÜ‚Ü‚ê‚Ä‚¢‚Ü‚·B');
+    }
+}
+
+// }}}
+// {{{ p2_scan_script_injection()
+
+/**
+ * ¶‚Ì‚Ü‚ÜHTML‚É–„‚ߍž‚Ü‚ê‚é host, bbs, key, ls ‚É
+ * HTML‚Ì“ÁŽê•¶Žš‚ªŠÜ‚Ü‚ê‚Ä‚¢‚½‚çI—¹‚·‚é
+ *
+ * @param   array   $request
+ * @return  void
+ */
+function p2_scan_script_injection($request)
+{
+    foreach (array('host', 'bbs', 'key', 'ls') as $key) {
+        if (array_key_exists($key, $request)) {
+            $value = $request[$key];
+            if (htmlspecialchars($value, ENT_QUOTES) != $value) {
+                p2die('ƒŠƒNƒGƒXƒgƒpƒ‰ƒ[ƒ^‚É•s³‚È•¶Žš‚ª‚ ‚è‚Ü‚·B');
+            }
+        }
+    }
+}
+
+// }}}
+// {{{ p2_print_memory_usage()
+
+/**
+ * ƒƒ‚ƒŠ‚ÌŽg—p—Ê‚ð•\Ž¦‚·‚é
+ *
+ * @return  void
+ */
+function p2_print_memory_usage()
+{
+    if (function_exists('memory_get_usage')) {
+        $usage = memory_get_usage();
+    } elseif (function_exists('xdebug_memory_usage')) {
+        $usage = xdebug_memory_usage();
+    } else {
+        $usage = -1;
+    }
+    $kb = $usage / 1024;
+    $kb = number_format($kb, 2, '.', '');
+
+    echo 'Memory Usage: ' . $kb . 'KiB';
+}
+
+// }}}
+// {{{ p2_realpath()
+
+/**
+ * ŽÀÝ‚µ‚È‚¢(‚©‚à‚µ‚ê‚È‚¢)ƒtƒ@ƒCƒ‹‚̐â‘΃pƒX‚ðŽæ“¾‚·‚é
+ *
+ * @param   string $path
+ * @return  string
+ */
+function p2_realpath($path)
+{
+    if (file_exists($path)) {
+        return realpath($path);
+    }
+    if (!class_exists('File_Util', false)) {
+        require 'File/Util.php';
+    }
+    return File_Util::realPath($path);
+}
+
+// }}}
+// {{{ p2_si2int()
+
+/**
+ * SIÚ“ªŽ«‚‚«‚̐”’l‚𐮐”‚É•ÏŠ·‚·‚é
+ *
+ * @param   numeric $num
+ * @param   string  $kmg
+ * @return  int
+ * @throws  OverflowException, UnderflowException
+ */
+function p2_si2int($num, $kmg)
+{
+    $real = p2_si2real($num, $kmg);
+    if ($real > PHP_INT_MAX) {
+        throw new OverflowException(sprintf('Integer overflow (%0.0f)', $real));
+        //return PHP_INT_MAX;
+    }
+    if ($real < P2_INT_MIN) {
+        throw new UnderflowException(sprintf('Integer underflow (%0.0f)', $real));
+        //return P2_INT_MIN;
+    }
+    return (int)$real;
+}
+
+// }}}
+// {{{ p2_si2real()
+
+/**
+ * SIÚ“ªŽ«‚‚«‚̐”’l‚ðŽÀ”‚É•ÏŠ·‚·‚é
+ * Œµ–§‚É‚Í1000”{‚·‚é‚Ì‚ª³‚µ‚¢‚ªA‚ ‚¦‚Ä1024”{‚·‚é
+ *
+ * @param   numeric $num
+ * @param   string  $kmg
+ * @return  float
+ */
+function p2_si2real($num, $kmg)
+{
+    $num = (float)$num;
+    switch ($kmg[0]) {
+        case 'G': case 'g': $num *= 1024;
+        case 'M': case 'm': $num *= 1024;
+        case 'M': case 'k': $num *= 1024;
+    }
+    return $num;
+}
+
+// }}}
+// {{{ p2_mb_basename()
+
+/**
+ * ƒ}ƒ‹ƒ`ƒoƒCƒg‘Ήž‚Ìbasename()
+ *
+ * @param   string $path
+ * @param   string $encoding
+ * @return  string
+ */
+function p2_mb_basename($path, $encoding = 'SJIS-win')
+{
+    if (DIRECTORY_SEPARATOR != '/') {
+        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
+    }
+    if (!mb_substr_count($path, '/', $encoding)) {
+        return $path;
+    }
+    $len = mb_strlen($path, $encoding);
+    $pos = mb_strrpos($path, '/', $encoding);
+    return mb_substr($path, $pos + 1, $len - $pos, $encoding);
+}
+
+// }}}
+// {{{ p2_mb_ereg_count()
+
+/**
+ * ƒ}ƒ‹ƒ`ƒoƒCƒg³‹K•\Œ»‚Ƀ}ƒbƒ`‚µ‚½‰ñ”‚ð•Ô‚·
+ *
+ * @param   string $pattern
+ * @param   string $string
+ * @param   string $option
+ * @return  int
+ */
+function p2_mb_ereg_count($pattern, $string, $option = null)
+{
+    if ($option === null) {
+        if (!mb_ereg_search_init($string, $pattern)) {
+            return false;
+        }
+    } else {
+        if (!mb_ereg_search_init($string, $pattern, $option)) {
+            return false;
+        }
+    }
+
+    $i = 0;
+
+    while (mb_ereg_search()) {
+        $i++;
+    }
+
+    return $i;
+}
+
+// }}}
+// {{{ p2_set_filtering_word()
+
+/**
+ * ƒtƒBƒ‹ƒ^ƒ}ƒbƒ`ƒ“ƒO—p‚̃Oƒ[ƒoƒ‹•Ï”‚ðÝ’è‚·‚é
+ *
+ * @param   string $word
+ * @param   string $method
+ * @return  string
+ */
+function p2_set_filtering_word($word, $method = 'regex')
+{
+    $word_fm = StrCtl::wordForMatch($word, $method);
+
+    if (strlen($word_fm) == 0) {
+        $word_fm = null;
+        $GLOBALS['word_fm'] = null;
+        $GLOBALS['words_fm'] = array();
+    } elseif ($method == 'just' || $method == 'regex') {
+        $GLOBALS['word_fm'] = $word_fm;
+        $GLOBALS['words_fm'] = array($word_fm);
+    } elseif (P2_MBREGEX_AVAILABLE == 1) {
+        $GLOBALS['word_fm'] = mb_ereg_replace('\\s+', '|', $word_fm);
+        $GLOBALS['words_fm'] = mb_split('\\s+', $word_fm);
+    } else {
+        $GLOBALS['word_fm'] = preg_replace('/\\s+/', '|', $word_fm);
+        $GLOBALS['words_fm'] = preg_split('/\\s+/', $word_fm);
+    }
+
+    return $word_fm;
+}
+
+// }}}
+// {{{ p2_normalize()
+
+if (extension_loaded('intl')) {
+    /**
+     * NormalizerƒNƒ‰ƒX‚ðŽg‚Á‚½³‹K‰»ŠÖ”
+     *
+     * @param   string $str
+     * @return  string
+     */
+    function p2_normalize($str)
+    {
+        return strtolower(Normalizer::normalize(mb_convert_encoding(
+                $str, 'UTF-8', 'SJIS-win'), Normalizer::NFKC));
+    }
+} else {
+    /**
+     * ‚·‚²‚­“K“–‚Ȑ³‹K‰»ŠÖ”
+     *
+     * @param   string $str
+     * @return  string
+     */
+    function p2_normalize($str)
+    {
+        return mb_strtolower(mb_convert_kana(mb_convert_encoding(
+                $str, 'UTF-8', 'SJIS-win'), 'KVas', 'UTF-8'), 'UTF-8');
+    }
+}
+
+// }}}
+// {{{ p2_wakati()
+
+/**
+ * ‚·‚²‚­“K“–‚È•ª‚©‚¿‘‚«ŠÖ”
+ *
+ * @param   string $str
+ * @return  array
+ */
+function p2_wakati($str)
+{
+    $str = preg_replace(P2_REGEX_WAKATI, '$0 ', p2_normalize($str));
+    return preg_split('/\\s+/u', $str, -1, PREG_SPLIT_NO_EMPTY);
+}
+
+// }}}
+// {{{ p2_get_highlighting_regex
+
+/**
+ * p2_wakati()‚ÌŒ‹‰Ê“™AƒL[ƒ[ƒh‚Ì”z—ñ‚©‚çƒnƒCƒ‰ƒCƒg—p‚̐³‹K•\Œ»‚𐶐¬‚·‚é
+ *
+ * @param   array $words
+ * @return  string
+ */
+function p2_get_highlighting_regex(array $words)
+{
+    $featured_words = array_filter($words, '_p2_get_highlighting_regex_filter');
+    if (count($featured_words) == 0) {
+        $featured_words = $words;
+    }
+    //rsort($featured_words, SORT_STRING);
+
+    $pattern = mb_convert_encoding(implode(' ', $featured_words), 'SJIS-win', 'UTF-8');
+    return str_replace(' ', '|', StrCtl::wordForMatch($pattern, 'or'));
+
+}
+
+// }}}
+// {{{ _p2_get_highlighting_regex_filter
+
+/**
+ * p2_get_highlighting_regex()‚©‚çŒÄ‚яo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”
+ *
+ * @param   string $str
+ * @return  bool
+ */
+function _p2_get_highlighting_regex_filter($str)
+{
+    if (preg_match(P2_REGEX_KANJI, $str)) {
+        return true;
+    } elseif (mb_strlen($str, 'UTF-8') > 1 && preg_match(P2_REGEX_WAKATI, $str)) {
+        return true;
+    } else {
+        return false;
+    }
+}
+
+// }}}
+// {{{ p2_combine_nfd_kana()
+
+/**
+ * Safari ‚©‚çƒAƒbƒvƒ[ƒh‚³‚ꂽƒtƒ@ƒCƒ‹–¼‚Ì•¶Žš‰»‚¯‚ð•â³‚·‚éŠÖ”
+ * ´‰¹+‘÷“_E´‰¹+”¼‘÷“_‚ðˆê•¶Žš‚É‚Ü‚Æ‚ß‚é (NFD ‚Ő³‹K‰»‚³‚ꂽ ‚©‚È ‚ð NFC ‚É‚·‚é)
+ * “üo—Í‚Ì•¶ŽšƒR[ƒh‚ÍUTF-8
+ *
+ * @param   string $str
+ * @return  string
+ */
+function p2_combine_nfd_kana($str)
+{
+    if (extension_loaded('intl')) {
+        return Normalizer::normalize($str, Normalizer::NFC);
+    }
+    return preg_replace_callback(P2_REGEX_NFD_KANA, '_p2_combine_nfd_kana', $str);
+}
+
+// }}}
+// {{{ _p2_combine_nfd_kana()
+
+/**
+ * p2_combine_nfd_kana()‚©‚çŒÄ‚яo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”
+ *
+ * @param   array $m
+ * @return  string
+ */
+function _p2_combine_nfd_kana($m)
+{
+    if ($m[1]) {
+        $C = unpack('C*', $m[1]);
+        $C[3] += 1;
+    } elseif ($m[2]) {
+        $C = unpack('C*', $m[2]);
+        $C[3] += 2;
+    } else {
+        return $m[0]; // ‚ ‚肦‚È‚¢
+    }
+
+    return pack('C*', $C[1], $C[2], $C[3]);
+}
+
+// }}}
+// {{{ p2_correct_css_fonts()
+
+/**
+ * ƒXƒ^ƒCƒ‹ƒV[ƒg‚̃tƒHƒ“ƒgŽw’è‚𒲐®‚·‚é
+ *
+ * @param string|array $fonts
+ * @return string
+ */
+function p2_correct_css_fontfamily($fonts)
+{
+    if (is_string($fonts)) {
+        $fonts = preg_split('/(["\'])?\\s*,\\s*(?(1)\\1)/', trim($fonts, " \t\"'"));
+    } elseif (!is_array($fonts)) {
+        return '';
+    }
+    $fonts = '"' . implode('","', $fonts) . '"';
+    $fonts = preg_replace('/"(serif|sans-serif|cursive|fantasy|monospace)"/', '\\1', $fonts);
+    return trim($fonts, '"');
+}
+
+// }}}
+// {{{ p2_correct_css_color()
+
+/**
+ * ƒXƒ^ƒCƒ‹ƒV[ƒg‚̐FŽw’è‚𒲐®‚·‚é
+ *
+ * @param   string $color
+ * @return  string
+ */
+function p2_correct_css_color($color)
+{
+    return preg_replace('/^#([0-9A-F])([0-9A-F])([0-9A-F])$/i', '#$1$1$2$2$3$3', $color);
+}
+
+// }}}
+// {{{ p2_escape_css_url()
+
+/**
+ * ƒXƒ^ƒCƒ‹ƒV[ƒg‚ÌURL‚ðƒGƒXƒP[ƒv‚·‚é
+ *
+ * CSS‚Å“Á‚ɈӖ¡‚Ì‚ ‚éƒg[ƒNƒ“‚Å‚ ‚é‹ó”’•¶ŽšAƒVƒ“ƒOƒ‹ƒNƒH[ƒgA
+ * ƒ_ƒuƒ‹ƒNƒH[ƒgAŠ‡ŒÊAƒoƒbƒNƒXƒ‰ƒbƒVƒ…‚ðURLƒGƒ“ƒR[ƒh‚·‚é
+ *
+ * @param   string $url
+ * @return  string
+ */
+function p2_escape_css_url($url)
+{
+    if (strpos($url, chr(0)) !== false) {
+        return '';
+    }
+    return str_replace(array( "\t",  "\n",  "\r",   ' ',   '"',   "'",   '(',   ')',  '\\'),
+                       array('%09', '%0A', '%0D', '%20', '%22', '%27', '%28', '%29', '%5C'),
+                       $url);
+}
+
+// }}}
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Copied: p2ex/trunk/lib/md5_crypt.funcs.php (from rev 777, p2ex/trunk/lib/md5_crypt.inc.php)
===================================================================
--- p2ex/trunk/lib/md5_crypt.funcs.php	                        (rev 0)
+++ p2ex/trunk/lib/md5_crypt.funcs.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -0,0 +1,89 @@
+<?php
+/**
+ * ‚±‚̃tƒ@ƒCƒ‹‚̊֐”‚́APHPƒ}ƒjƒ…ƒAƒ‹ƒy[ƒW‚æ‚è‚Ì”qŽØ‚Å‚·BŠ´ŽÓB
+ * @link http://jp.php.net/manual/ja/function.md5.php
+ *
+ * Alexander Valyalkin
+ * 01-Jul-2004 05:41
+ * Below is MD5-based block cypher (MDC-like), which works in 128bit CFB mode.
+ * It is very useful to encrypt secret data before transfer it over the network.
+ * $iv_len - initialization vector's length.
+ * 0 <= $iv_len <= 512
+ */
+
+// {{{ get_rnd_iv()
+
+function get_rnd_iv($iv_len)
+{
+   $iv = '';
+   while ($iv_len-- > 0) {
+       $iv .= chr(mt_rand() & 0xff);
+   }
+   return $iv;
+}
+
+// }}}
+// {{{ md5_decrypt()
+
+function md5_encrypt($plain_text, $password, $iv_len = 16)
+{
+   $plain_text .= "\x13";
+   $n = strlen($plain_text);
+   if ($n % 16) $plain_text .= str_repeat(chr(0), 16 - ($n % 16));
+   $i = 0;
+   $enc_text = get_rnd_iv($iv_len);
+   $iv = substr($password ^ $enc_text, 0, 512);
+   while ($i < $n) {
+       $block = substr($plain_text, $i, 16) ^ pack('H*', md5($iv));
+       $enc_text .= $block;
+       $iv = substr($block . $iv, 0, 512) ^ $password;
+       $i += 16;
+   }
+   return base64_encode($enc_text);
+}
+
+// }}}
+// {{{ md5_decrypt()
+
+function md5_decrypt($enc_text, $password, $iv_len = 16)
+{
+   $enc_text = base64_decode($enc_text);
+   $n = strlen($enc_text);
+   $i = $iv_len;
+   $plain_text = '';
+   $iv = substr($password ^ substr($enc_text, 0, $iv_len), 0, 512);
+   while ($i < $n) {
+       $block = substr($enc_text, $i, 16);
+       $plain_text .= $block ^ pack('H*', md5($iv));
+       $iv = substr($block . $iv, 0, 512) ^ $password;
+       $i += 16;
+   }
+   return preg_replace('/\\x13\\x00*$/', '', $plain_text);
+}
+
+// }}}
+
+/******************************************/
+/*
+$plain_text = 'very secret string';
+$password = 'very secret password';
+echo "plain text is: [${plain_text}]<br />\n";
+echo "password is: [${password}]<br />\n";
+
+$enc_text = md5_encrypt($plain_text, $password);
+echo "encrypted text is: [${enc_text}]<br />\n";
+
+$plain_text2 = md5_decrypt($enc_text, $password);
+echo "decrypted text is: [${plain_text2}]<br />\n";
+*/
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Deleted: p2ex/trunk/lib/md5_crypt.inc.php
===================================================================
--- p2ex/trunk/lib/md5_crypt.inc.php	2010-01-13 16:07:10 UTC (rev 777)
+++ p2ex/trunk/lib/md5_crypt.inc.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -1,89 +0,0 @@
-<?php
-/**
- * ‚±‚̃tƒ@ƒCƒ‹‚̊֐”‚́APHPƒ}ƒjƒ…ƒAƒ‹ƒy[ƒW‚æ‚è‚Ì”qŽØ‚Å‚·BŠ´ŽÓB
- * @link http://jp.php.net/manual/ja/function.md5.php
- *
- * Alexander Valyalkin
- * 01-Jul-2004 05:41
- * Below is MD5-based block cypher (MDC-like), which works in 128bit CFB mode.
- * It is very useful to encrypt secret data before transfer it over the network.
- * $iv_len - initialization vector's length.
- * 0 <= $iv_len <= 512
- */
-
-// {{{ get_rnd_iv()
-
-function get_rnd_iv($iv_len)
-{
-   $iv = '';
-   while ($iv_len-- > 0) {
-       $iv .= chr(mt_rand() & 0xff);
-   }
-   return $iv;
-}
-
-// }}}
-// {{{ md5_decrypt()
-
-function md5_encrypt($plain_text, $password, $iv_len = 16)
-{
-   $plain_text .= "\x13";
-   $n = strlen($plain_text);
-   if ($n % 16) $plain_text .= str_repeat(chr(0), 16 - ($n % 16));
-   $i = 0;
-   $enc_text = get_rnd_iv($iv_len);
-   $iv = substr($password ^ $enc_text, 0, 512);
-   while ($i < $n) {
-       $block = substr($plain_text, $i, 16) ^ pack('H*', md5($iv));
-       $enc_text .= $block;
-       $iv = substr($block . $iv, 0, 512) ^ $password;
-       $i += 16;
-   }
-   return base64_encode($enc_text);
-}
-
-// }}}
-// {{{ md5_decrypt()
-
-function md5_decrypt($enc_text, $password, $iv_len = 16)
-{
-   $enc_text = base64_decode($enc_text);
-   $n = strlen($enc_text);
-   $i = $iv_len;
-   $plain_text = '';
-   $iv = substr($password ^ substr($enc_text, 0, $iv_len), 0, 512);
-   while ($i < $n) {
-       $block = substr($enc_text, $i, 16);
-       $plain_text .= $block ^ pack('H*', md5($iv));
-       $iv = substr($block . $iv, 0, 512) ^ $password;
-       $i += 16;
-   }
-   return preg_replace('/\\x13\\x00*$/', '', $plain_text);
-}
-
-// }}}
-
-/******************************************/
-/*
-$plain_text = 'very secret string';
-$password = 'very secret password';
-echo "plain text is: [${plain_text}]<br />\n";
-echo "password is: [${password}]<br />\n";
-
-$enc_text = md5_encrypt($plain_text, $password);
-echo "encrypted text is: [${enc_text}]<br />\n";
-
-$plain_text2 = md5_decrypt($enc_text, $password);
-echo "decrypted text is: [${plain_text2}]<br />\n";
-*/
-
-/*
- * 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/migrators/100113_1300.php
===================================================================
--- p2ex/trunk/lib/migrators/100113_1300.php	2010-01-13 16:07:10 UTC (rev 777)
+++ p2ex/trunk/lib/migrators/100113_1300.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -8,21 +8,21 @@
 /**
  * rev.100113.1300
  *
- * @param array $core_conf rep2ƒRƒA‚̐ݒè
- * @param array $user_conf ŒÃ‚¢ƒ†[ƒU[Ý’è
+ * @param array $core_config rep2ƒRƒA‚̐ݒè
+ * @param array $user_config ŒÃ‚¢ƒ†[ƒU[Ý’è
  * @return array V‚µ‚¢ƒ†[ƒU[Ý’è
  */
-function p2_migrate_100113_1300(array $core_conf, array $user_conf)
+function p2_migrate_100113_1300(array $core_config, array $user_config)
 {
-    $data_dir   = $core_conf['data_dir'];
-    $db_dir     = $core_conf['db_dir'];
-    $cache_dir  = $core_conf['cache_dir'];
-    $cookie_dir = $core_conf['cookie_dir'];
+    $data_dir   = $core_config['data_dir'];
+    $db_dir     = $core_config['db_dir'];
+    $cache_dir  = $core_config['cache_dir'];
+    $cookie_dir = $core_config['cookie_dir'];
 
     // {{{ ƒzƒXƒgƒ`ƒFƒbƒN‚Ìgethostbyaddr()ƒLƒƒƒbƒVƒ…
 
     $old_hostcheck_db = $cache_dir . '/hostcheck_gethostby.sq3';
-    $new_hostcheck_db = $core_conf['hostcheck_db_path'];
+    $new_hostcheck_db = $core_config['hostcheck_db_path'];
 
     _100113_1300_rename_db($old_hostcheck_db, $new_hostcheck_db);
     _100113_1300_rename_table($new_hostcheck_db, 'kvs_p2keyvaluestore', 'kvs_default');
@@ -43,7 +43,7 @@
     // {{{ “Še—pCookieƒXƒgƒŒ[ƒW
 
     $old_cookie_db = $cookie_dir . '/p2_cookies.sqlite3';
-    $new_cookie_db = $core_conf['cookie_db_path'];
+    $new_cookie_db = $core_config['cookie_db_path'];
 
     _100113_1300_rename_db($old_cookie_db, $new_cookie_db);
     _100113_1300_rename_table($new_cookie_db, 'kvs_p2keyvaluestore_serializing', 'kvs_serializing');
@@ -52,14 +52,14 @@
     // {{{ ‘‚«ž‚݃f[ƒ^‚̃oƒbƒNƒAƒbƒvƒXƒgƒŒ[ƒW
 
     $old_post_db = $cookie_dir . '/p2_post_data.sqlite3';
-    $new_post_db = $core_conf['post_db_path'];
+    $new_post_db = $core_config['post_db_path'];
 
     _100113_1300_rename_db($old_post_db, $new_post_db);
     _100113_1300_rename_table($new_post_db, 'kvs_p2keyvaluestore_serializing', 'kvs_serializing');
 
     // }}}
 
-    return $user_conf;
+    return $user_config;
 }
 
 // }}}

Modified: p2ex/trunk/lib/migrators/yymmdd_hhmm.php
===================================================================
--- p2ex/trunk/lib/migrators/yymmdd_hhmm.php	2010-01-13 16:07:10 UTC (rev 777)
+++ p2ex/trunk/lib/migrators/yymmdd_hhmm.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -8,13 +8,13 @@
 /**
  * yymmdd_hhmm ‚ðŽÀÛ‚̃o[ƒWƒ‡ƒ“”ԍ†‚É’uŠ·‚µ‚Ċ֐”‚Ì’†g‚ð‹Lq‚·‚é
  *
- * @param array $core_conf rep2ƒRƒA‚̐ݒè
- * @param array $user_conf ŒÃ‚¢ƒ†[ƒU[Ý’è
+ * @param array $core_config rep2ƒRƒA‚̐ݒè
+ * @param array $user_config ŒÃ‚¢ƒ†[ƒU[Ý’è
  * @return array V‚µ‚¢ƒ†[ƒU[Ý’è
  */
-function p2_migrate_yymmdd_hhmm(array $core_conf, array $user_conf)
+function p2_migrate_yymmdd_hhmm(array $core_config, array $user_config)
 {
-    return $user_conf;
+    return $user_config;
 }
 
 // }}}

Deleted: p2ex/trunk/lib/p2util.inc.php
===================================================================
--- p2ex/trunk/lib/p2util.inc.php	2010-01-13 16:07:10 UTC (rev 777)
+++ p2ex/trunk/lib/p2util.inc.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -1,621 +0,0 @@
-<?php
-/**
- * rep2expack - ƒ†[ƒeƒBƒŠƒeƒBŠÖ”ŒQ
- */
-
-// {{{ CONSTANTS
-
-/**
- * ®”‚̍őå’l‚ƍŏ¬’l
- */
-define('P2_INT_MAX', PHP_INT_MAX);
-define('P2_INT_MIN', - PHP_INT_MAX - 1);
-
-/**
- * Š¿Žš‚Ƀ}ƒbƒ`‚·‚鐳‹K•\Œ»
- */
-//define('P2_REGEX_KANJI', mb_convert_encoding('/[ˆê-êž]/u', 'UTF-8', 'SJIS-win'));
-define('P2_REGEX_KANJI', '/[\\x{4e00}-\\x{9fa0}]/u');
-
-/**
- *‚·‚²‚­“K“–‚È•ª‚©‚¿‘‚«—p³‹K•\Œ»
- */
-/*
-define('P2_REGEX_WAKATI', mb_convert_encoding('/(' . implode('|', array(
-    //'[ˆê-êž]+[‚Ÿ-‚ñ]*',
-    //'[ˆê-êž]+',
-    '[ˆê“ñŽOŽlŒÜ˜ZŽµ”ª‹ã\]+',
-    '[’š-êž]+',
-    '[‚Ÿ-‚ñ][‚Ÿ-‚ñ[`JK]*',
-    '[ƒ@-ƒ–][ƒ@-ƒ–[`JK]*',
-    //'[a-z][a-z_\\-]*',
-    //'[0-9][0-9.]*',
-    '[0-9a-z][0-9a-z_\\-]*',
-)) . ')/u', 'UTF-8', 'SJIS-win'));
-*/
-define('P2_REGEX_WAKATI', '/(
-#[\\x{4e00}-\\x{9fa0}]+[\\x{3041}-\\x{3093}]*|
-#[\\x{4e00}-\\x{9fa0}]+|
-[\\x{4e00}\\x{4e8c}\\x{4e09}\\x{56db}\\x{4e94}\\x{516d}\\x{4e03}\\x{516b}\\x{4e5d}\\x{5341}]+|
-[\\x{4e01}-\\x{9fa0}]+|
-[\\x{3041}-\\x{3093}][\\x{3041}-\\x{3093}\\x{30fc}\\x{301c}\\x{309b}\\x{309c}]*|
-[\\x{30a1}-\\x{30f6}][\\x{30a1}-\\x{30f6}\\x{30fc}\\x{301c}\\x{309b}\\x{309c}]*|
-#[a-z][a-z_\\-]*|
-#[0-9][0-9.]*|
-[0-9a-z][0-9a-z_\\-]*)/ux');
-
-/**
- * UTF-8,NFD‚̂Ђ炪‚ȁEƒJƒ^ƒJƒi‚Ì‘÷‰¹E”¼‘÷‰¹‚Ƀ}ƒbƒ`‚·‚鐳‹K•\Œ»
- */
-/*
-define('P2_REGEX_NFD_KANA',
-    str_replace(
-        array('%u3099%', '%u309A%'),
-        array(pack('C*', 0xE3, 0x82, 0x99), pack('C*', 0xE3, 0x82, 0x9A)),
-        mb_convert_encoding(
-            '/([‚¤‚©-‚±‚³-‚»‚½-‚Æ‚Í-‚ÙƒEƒJ-ƒRƒT-ƒ\ƒ^-ƒgƒn-ƒzTR])%u3099%|([‚Í-‚Ùƒn-ƒz])%u309A%/u',
-            'UTF-8',
-            'SJIS-win'
-        )
-    )
-);
-*/
-define('P2_REGEX_NFD_KANA', '/([\\x{3046}\\x{304b}-\\x{3053}\\x{3055}-\\x{305d}\\x{305f}-\\x{3068}\\x{306f}-\\x{307b}\\x{30a6}\\x{30ab}-\\x{30b3}\\x{30b5}-\\x{30bd}\\x{30bf}-\\x{30c8}\\x{30cf}-\\x{30db}\\x{309d}\\x{30fd}])\\x{3099}|([\\x{306f}-\\x{307b}\\x{30cf}-\\x{30db}])\\x{309a}/u');
-
-// }}}
-// {{{ p2h()
-
-/**
-* htmlspecialchars($value, ENT_QUOTES) ‚̃Vƒ‡[ƒgƒJƒbƒg
-*
-* @param    string $str
-* @param    string $charset
-* @param    bool   $double_encode
-* @return   string
-*/
-function p2h($str, $charset = 'Shift_JIS', $double_encode = true)
-{
-    return htmlspecialchars($str, ENT_QUOTES, $charset, $double_encode);
-}
-
-// }}}
-// {{{ p2die()
-
-/**
- * ƒƒbƒZ[ƒW‚ð•\Ž¦‚µ‚ďI—¹
- * ƒwƒbƒ_‚ªo—Í‚³‚ê‚Ä‚¢‚éê‡A<body>‚܂ł͏o—͍ςƌ©‚È‚·
- *
- * I—¹ƒXƒe[ƒ^ƒXƒR[ƒh2‚ÍP2CommandRunner‚ɃGƒ‰[ƒƒbƒZ[ƒW‚ª
- * HTML‚Å‚ ‚邱‚Æ‚ð’Ê’m‚·‚邽‚ß
- *
- * @param   string $err ƒGƒ‰[ŠT—v
- * @param   string $msg Ú×‚Èà–¾
- * @param   bool   $raw Ú×‚Èà–¾‚ðƒGƒXƒP[ƒv‚·‚é‚©”Û‚©
- * @return  void
- */
-function p2die($err = null, $msg = null, $raw = false)
-{
-    if (!defined('P2_CLI_RUN') && !headers_sent()) {
-        header('Expires: ' . http_date(0)); // “ú•t‚ª‰ß‹Ž
-        header('Last-Modified: ' . http_date()); // í‚ɏC³‚³‚ê‚Ä‚¢‚é
-        header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
-        header('Cache-Control: post-check=0, pre-check=0', false);
-        header('Pragma: no-cache'); // HTTP/1.0
-        echo <<<EOH
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
-<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
-{$GLOBALS['_conf']['extra_headers_ht']}
-<title>rep2 error</title>
-</head>
-<body>
-EOH;
-    }
-
-    echo '<h3>rep2 error</h3>';
-
-    if ($err !== null) {
-        echo '<p><strong>', htmlspecialchars($err, ENT_QUOTES), '</strong></p>';
-    }
-
-    if ($msg !== null) {
-        if ($raw) {
-            echo $msg;
-        } else {
-            echo '<p>', nl2br(htmlspecialchars($msg, ENT_QUOTES)), '</p>';
-        }
-    }
-
-    if (true) {
-        echo '<pre><em>backtrace:</em>';
-
-        $p2_file_prefix = P2_BASE_DIR . DIRECTORY_SEPARATOR;
-        $p2_base_dir_len = strlen(P2_BASE_DIR);
-        $backtrace = debug_backtrace();
-        $c = count($backtrace);
-
-        foreach ($backtrace as $bt) {
-            echo "\n";
-
-            if (strpos($bt['file'], $p2_file_prefix) === 0) {
-                $filename = '.' . substr($bt['file'], $p2_base_dir_len);
-            } else {
-                $filename = '(external)' . DIRECTORY_SEPARATOR . basename($bt['file']);
-            }
-            printf('  % 2d. %s (line %d)', $c--, $filename, $bt['line']);
-
-            if (array_key_exists('function', $bt) && $bt['function'] !== '' && $bt['function'] !== 'p2die') {
-                if (array_key_exists('class', $bt) && $bt['class'] !== '') {
-                    printf(': %s%s%s()',
-                           $bt['class'],
-                           str_replace('>', '&gt;', $bt['type']),
-                           $bt['function']
-                           );
-                } else {
-                    printf(': %s()', $bt['function']);
-                }
-            }
-        }
-
-        echo '</pre>';
-    }
-
-    if (!defined('P2_CLI_RUN')) {
-        echo '</body></html>';
-    }
-    exit(2);
-}
-
-// }}}
-// {{{ http_date()
-
-if (!function_exists('http_date')) {
-    /**
-     * pecl_http‚Ìhttp_date()‚ÌPure PHP”Å
-     *
-     * @param   int $timestamp
-     * @return  string
-     */
-    function http_date($timestamp = null)
-    {
-        if ($timestamp === null) {
-            //return str_replace('+0000', 'GMT', gmdate(DATE_RFC1123));
-            return gmdate('D, d M Y H:i:s \\G\\M\\T');
-        }
-        //return str_replace('+0000', 'GMT', gmdate(DATE_RFC1123, $timestamp));
-        return gmdate('D, d M Y H:i:s \\G\\M\\T', $timestamp);
-    }
-}
-
-// }}}
-// {{{ ctype
-
-/**
- * ctypeŠg’£ƒ‚ƒWƒ…[ƒ‹ŠÖ”‚ÌPure PHP”Å (cntrl,graph,print,punct,space‚ÍŠ„ˆ¤)
- */
-if (!extension_loaded('ctype')) {
-    function ctype_alnum($str) { return (bool)preg_match('/^[0-9A-Za-z]+$/', $str); }
-    function ctype_alpha($str) { return (bool)preg_match('/^[A-Za-z]+$/', $str); }
-    function ctype_digit($str) { return (bool)preg_match('/^[0-9]+$/', $str); }
-    function ctype_lower($str) { return (bool)preg_match('/^[a-z]+$/', $str); }
-    function ctype_upper($str) { return (bool)preg_match('/^[A-Z]+$/', $str); }
-    function ctype_xdigit($str) { return (bool)preg_match('/^[0-9A-Fa-f]+$/', $str); }
-}
-
-// }}}
-// {{{ p2_scan_nullbyte()
-
-/**
- * ƒŠƒNƒGƒXƒgƒpƒ‰ƒ[ƒ^‚©‚çNULLƒoƒCƒg‚ðŒŸo‚µ‚½‚çI—¹‚·‚é
- * array_walk_recursive() —pƒR[ƒ‹ƒoƒbƒNŠÖ”
- *
- * @param   mixed   $value 
- * @param   mixed   $key
- * @return  void
- */
-function p2_scan_nullbyte($value, $key)
-{
-    if (is_string($value) && strpos($value, P2_NULLBYTE) !== false) {
-        p2die('ƒŠƒNƒGƒXƒgƒpƒ‰ƒ[ƒ^‚ÉNULLƒoƒCƒg‚ªŠÜ‚Ü‚ê‚Ä‚¢‚Ü‚·B');
-    }
-}
-
-// }}}
-// {{{ p2_scan_script_injection()
-
-/**
- * ¶‚Ì‚Ü‚ÜHTML‚É–„‚ߍž‚Ü‚ê‚é host, bbs, key, ls ‚É
- * HTML‚Ì“ÁŽê•¶Žš‚ªŠÜ‚Ü‚ê‚Ä‚¢‚½‚çI—¹‚·‚é
- *
- * @param   array   $request
- * @return  void
- */
-function p2_scan_script_injection($request)
-{
-    foreach (array('host', 'bbs', 'key', 'ls') as $key) {
-        if (array_key_exists($key, $request)) {
-            $value = $request[$key];
-            if (htmlspecialchars($value, ENT_QUOTES) != $value) {
-                p2die('ƒŠƒNƒGƒXƒgƒpƒ‰ƒ[ƒ^‚É•s³‚È•¶Žš‚ª‚ ‚è‚Ü‚·B');
-            }
-        }
-    }
-}
-
-// }}}
-// {{{ p2_print_memory_usage()
-
-/**
- * ƒƒ‚ƒŠ‚ÌŽg—p—Ê‚ð•\Ž¦‚·‚é
- *
- * @return  void
- */
-function p2_print_memory_usage()
-{
-    if (function_exists('memory_get_usage')) {
-        $usage = memory_get_usage();
-    } elseif (function_exists('xdebug_memory_usage')) {
-        $usage = xdebug_memory_usage();
-    } else {
-        $usage = -1;
-    }
-    $kb = $usage / 1024;
-    $kb = number_format($kb, 2, '.', '');
-
-    echo 'Memory Usage: ' . $kb . 'KiB';
-}
-
-// }}}
-// {{{ p2_realpath()
-
-/**
- * ŽÀÝ‚µ‚È‚¢(‚©‚à‚µ‚ê‚È‚¢)ƒtƒ@ƒCƒ‹‚̐â‘΃pƒX‚ðŽæ“¾‚·‚é
- *
- * @param   string $path
- * @return  string
- */
-function p2_realpath($path)
-{
-    if (file_exists($path)) {
-        return realpath($path);
-    }
-    if (!class_exists('File_Util', false)) {
-        require 'File/Util.php';
-    }
-    return File_Util::realPath($path);
-}
-
-// }}}
-// {{{ p2_si2int()
-
-/**
- * SIÚ“ªŽ«‚‚«‚̐”’l‚𐮐”‚É•ÏŠ·‚·‚é
- *
- * @param   numeric $num
- * @param   string  $kmg
- * @return  int
- * @throws  OverflowException, UnderflowException
- */
-function p2_si2int($num, $kmg)
-{
-    $real = p2_si2real($num, $kmg);
-    if ($real > PHP_INT_MAX) {
-        throw new OverflowException(sprintf('Integer overflow (%0.0f)', $real));
-        //return PHP_INT_MAX;
-    }
-    if ($real < P2_INT_MIN) {
-        throw new UnderflowException(sprintf('Integer underflow (%0.0f)', $real));
-        //return P2_INT_MIN;
-    }
-    return (int)$real;
-}
-
-// }}}
-// {{{ p2_si2real()
-
-/**
- * SIÚ“ªŽ«‚‚«‚̐”’l‚ðŽÀ”‚É•ÏŠ·‚·‚é
- * Œµ–§‚É‚Í1000”{‚·‚é‚Ì‚ª³‚µ‚¢‚ªA‚ ‚¦‚Ä1024”{‚·‚é
- *
- * @param   numeric $num
- * @param   string  $kmg
- * @return  float
- */
-function p2_si2real($num, $kmg)
-{
-    $num = (float)$num;
-    switch ($kmg[0]) {
-        case 'G': case 'g': $num *= 1024;
-        case 'M': case 'm': $num *= 1024;
-        case 'M': case 'k': $num *= 1024;
-    }
-    return $num;
-}
-
-// }}}
-// {{{ p2_mb_basename()
-
-/**
- * ƒ}ƒ‹ƒ`ƒoƒCƒg‘Ήž‚Ìbasename()
- *
- * @param   string $path
- * @param   string $encoding
- * @return  string
- */
-function p2_mb_basename($path, $encoding = 'SJIS-win')
-{
-    if (DIRECTORY_SEPARATOR != '/') {
-        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
-    }
-    if (!mb_substr_count($path, '/', $encoding)) {
-        return $path;
-    }
-    $len = mb_strlen($path, $encoding);
-    $pos = mb_strrpos($path, '/', $encoding);
-    return mb_substr($path, $pos + 1, $len - $pos, $encoding);
-}
-
-// }}}
-// {{{ p2_mb_ereg_count()
-
-/**
- * ƒ}ƒ‹ƒ`ƒoƒCƒg³‹K•\Œ»‚Ƀ}ƒbƒ`‚µ‚½‰ñ”‚ð•Ô‚·
- *
- * @param   string $pattern
- * @param   string $string
- * @param   string $option
- * @return  int
- */
-function p2_mb_ereg_count($pattern, $string, $option = null)
-{
-    if ($option === null) {
-        if (!mb_ereg_search_init($string, $pattern)) {
-            return false;
-        }
-    } else {
-        if (!mb_ereg_search_init($string, $pattern, $option)) {
-            return false;
-        }
-    }
-
-    $i = 0;
-
-    while (mb_ereg_search()) {
-        $i++;
-    }
-
-    return $i;
-}
-
-// }}}
-// {{{ p2_set_filtering_word()
-
-/**
- * ƒtƒBƒ‹ƒ^ƒ}ƒbƒ`ƒ“ƒO—p‚̃Oƒ[ƒoƒ‹•Ï”‚ðÝ’è‚·‚é
- *
- * @param   string $word
- * @param   string $method
- * @return  string
- */
-function p2_set_filtering_word($word, $method = 'regex')
-{
-    $word_fm = StrCtl::wordForMatch($word, $method);
-
-    if (strlen($word_fm) == 0) {
-        $word_fm = null;
-        $GLOBALS['word_fm'] = null;
-        $GLOBALS['words_fm'] = array();
-    } elseif ($method == 'just' || $method == 'regex') {
-        $GLOBALS['word_fm'] = $word_fm;
-        $GLOBALS['words_fm'] = array($word_fm);
-    } elseif (P2_MBREGEX_AVAILABLE == 1) {
-        $GLOBALS['word_fm'] = mb_ereg_replace('\\s+', '|', $word_fm);
-        $GLOBALS['words_fm'] = mb_split('\\s+', $word_fm);
-    } else {
-        $GLOBALS['word_fm'] = preg_replace('/\\s+/', '|', $word_fm);
-        $GLOBALS['words_fm'] = preg_split('/\\s+/', $word_fm);
-    }
-
-    return $word_fm;
-}
-
-// }}}
-// {{{ p2_normalize()
-
-if (extension_loaded('intl')) {
-    /**
-     * NormalizerƒNƒ‰ƒX‚ðŽg‚Á‚½³‹K‰»ŠÖ”
-     *
-     * @param   string $str
-     * @return  string
-     */
-    function p2_normalize($str)
-    {
-        return strtolower(Normalizer::normalize(mb_convert_encoding(
-                $str, 'UTF-8', 'SJIS-win'), Normalizer::NFKC));
-    }
-} else {
-    /**
-     * ‚·‚²‚­“K“–‚Ȑ³‹K‰»ŠÖ”
-     *
-     * @param   string $str
-     * @return  string
-     */
-    function p2_normalize($str)
-    {
-        return mb_strtolower(mb_convert_kana(mb_convert_encoding(
-                $str, 'UTF-8', 'SJIS-win'), 'KVas', 'UTF-8'), 'UTF-8');
-    }
-}
-
-// }}}
-// {{{ p2_wakati()
-
-/**
- * ‚·‚²‚­“K“–‚È•ª‚©‚¿‘‚«ŠÖ”
- *
- * @param   string $str
- * @return  array
- */
-function p2_wakati($str)
-{
-    $str = preg_replace(P2_REGEX_WAKATI, '$0 ', p2_normalize($str));
-    return preg_split('/\\s+/u', $str, -1, PREG_SPLIT_NO_EMPTY);
-}
-
-// }}}
-// {{{ p2_get_highlighting_regex
-
-/**
- * p2_wakati()‚ÌŒ‹‰Ê“™AƒL[ƒ[ƒh‚Ì”z—ñ‚©‚çƒnƒCƒ‰ƒCƒg—p‚̐³‹K•\Œ»‚𐶐¬‚·‚é
- *
- * @param   array $words
- * @return  string
- */
-function p2_get_highlighting_regex(array $words)
-{
-    $featured_words = array_filter($words, '_p2_get_highlighting_regex_filter');
-    if (count($featured_words) == 0) {
-        $featured_words = $words;
-    }
-    //rsort($featured_words, SORT_STRING);
-
-    $pattern = mb_convert_encoding(implode(' ', $featured_words), 'SJIS-win', 'UTF-8');
-    return str_replace(' ', '|', StrCtl::wordForMatch($pattern, 'or'));
-
-}
-
-// }}}
-// {{{ _p2_get_highlighting_regex_filter
-
-/**
- * p2_get_highlighting_regex()‚©‚çŒÄ‚яo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”
- *
- * @param   string $str
- * @return  bool
- */
-function _p2_get_highlighting_regex_filter($str)
-{
-    if (preg_match(P2_REGEX_KANJI, $str)) {
-        return true;
-    } elseif (mb_strlen($str, 'UTF-8') > 1 && preg_match(P2_REGEX_WAKATI, $str)) {
-        return true;
-    } else {
-        return false;
-    }
-}
-
-// }}}
-// {{{ p2_combine_nfd_kana()
-
-/**
- * Safari ‚©‚çƒAƒbƒvƒ[ƒh‚³‚ꂽƒtƒ@ƒCƒ‹–¼‚Ì•¶Žš‰»‚¯‚ð•â³‚·‚éŠÖ”
- * ´‰¹+‘÷“_E´‰¹+”¼‘÷“_‚ðˆê•¶Žš‚É‚Ü‚Æ‚ß‚é (NFD ‚Ő³‹K‰»‚³‚ꂽ ‚©‚È ‚ð NFC ‚É‚·‚é)
- * “üo—Í‚Ì•¶ŽšƒR[ƒh‚ÍUTF-8
- *
- * @param   string $str
- * @return  string
- */
-function p2_combine_nfd_kana($str)
-{
-    if (extension_loaded('intl')) {
-        return Normalizer::normalize($str, Normalizer::NFC);
-    }
-    return preg_replace_callback(P2_REGEX_NFD_KANA, '_p2_combine_nfd_kana', $str);
-}
-
-// }}}
-// {{{ _p2_combine_nfd_kana()
-
-/**
- * p2_combine_nfd_kana()‚©‚çŒÄ‚яo‚³‚ê‚éƒR[ƒ‹ƒoƒbƒNŠÖ”
- *
- * @param   array $m
- * @return  string
- */
-function _p2_combine_nfd_kana($m)
-{
-    if ($m[1]) {
-        $C = unpack('C*', $m[1]);
-        $C[3] += 1;
-    } elseif ($m[2]) {
-        $C = unpack('C*', $m[2]);
-        $C[3] += 2;
-    } else {
-        return $m[0]; // ‚ ‚肦‚È‚¢
-    }
-
-    return pack('C*', $C[1], $C[2], $C[3]);
-}
-
-// }}}
-// {{{ p2_correct_css_fonts()
-
-/**
- * ƒXƒ^ƒCƒ‹ƒV[ƒg‚̃tƒHƒ“ƒgŽw’è‚𒲐®‚·‚é
- *
- * @param string|array $fonts
- * @return string
- */
-function p2_correct_css_fontfamily($fonts)
-{
-    if (is_string($fonts)) {
-        $fonts = preg_split('/(["\'])?\\s*,\\s*(?(1)\\1)/', trim($fonts, " \t\"'"));
-    } elseif (!is_array($fonts)) {
-        return '';
-    }
-    $fonts = '"' . implode('","', $fonts) . '"';
-    $fonts = preg_replace('/"(serif|sans-serif|cursive|fantasy|monospace)"/', '\\1', $fonts);
-    return trim($fonts, '"');
-}
-
-// }}}
-// {{{ p2_correct_css_color()
-
-/**
- * ƒXƒ^ƒCƒ‹ƒV[ƒg‚̐FŽw’è‚𒲐®‚·‚é
- *
- * @param   string $color
- * @return  string
- */
-function p2_correct_css_color($color)
-{
-    return preg_replace('/^#([0-9A-F])([0-9A-F])([0-9A-F])$/i', '#$1$1$2$2$3$3', $color);
-}
-
-// }}}
-// {{{ p2_escape_css_url()
-
-/**
- * ƒXƒ^ƒCƒ‹ƒV[ƒg‚ÌURL‚ðƒGƒXƒP[ƒv‚·‚é
- *
- * CSS‚Å“Á‚ɈӖ¡‚Ì‚ ‚éƒg[ƒNƒ“‚Å‚ ‚é‹ó”’•¶ŽšAƒVƒ“ƒOƒ‹ƒNƒH[ƒgA
- * ƒ_ƒuƒ‹ƒNƒH[ƒgAŠ‡ŒÊAƒoƒbƒNƒXƒ‰ƒbƒVƒ…‚ðURLƒGƒ“ƒR[ƒh‚·‚é
- *
- * @param   string $url
- * @return  string
- */
-function p2_escape_css_url($url)
-{
-    if (strpos($url, chr(0)) !== false) {
-        return '';
-    }
-    return str_replace(array( "\t",  "\n",  "\r",   ' ',   '"',   "'",   '(',   ')',  '\\'),
-                       array('%09', '%0A', '%0D', '%20', '%22', '%27', '%28', '%29', '%5C'),
-                       $url);
-}
-
-// }}}
-
-/*
- * Local Variables:
- * mode: php
- * coding: cp932
- * tab-width: 4
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
-// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:

Added: p2ex/trunk/lib/setup.funcs.php
===================================================================
--- p2ex/trunk/lib/setup.funcs.php	                        (rev 0)
+++ p2ex/trunk/lib/setup.funcs.php	2010-01-13 23:31:20 UTC (rev 778)
@@ -0,0 +1,204 @@
+<?php
+/**
+ * rep2expack - ƒZƒbƒgƒAƒbƒv—pŠÖ”ŒQ
+ */
+
+// {{{ p2_check_environment()
+
+/**
+ * “®ìŠÂ‹«‚ðŠm”F‚·‚é
+ *
+ * @return bool
+ */
+function p2_check_environment($check_recommended)
+{
+    global $_info_msg_ht;
+
+    include P2_CONF_DIR . '/setup_info.php';
+
+    $php_version = phpversion();
+
+    if (version_compare($php_version, '5.3.0-dev', '>=')) {
+        $required_version = $p2_required_version_5_3;
+        $recommended_version = $p2_recommended_version_5_3;
+    } else {
+        $required_version = $p2_required_version_5_2;
+        $recommended_version = $p2_recommended_version_5_2;
+    }
+
+    // PHP‚̃o[ƒWƒ‡ƒ“
+    if (version_compare($php_version, $required_version, '<')) {
+        p2die("PHP {$required_version} –¢–ž‚Å‚ÍŽg‚¦‚Ü‚¹‚ñB");
+    }
+
+    // •K{Šg’£ƒ‚ƒWƒ…[ƒ‹
+    foreach ($p2_required_extensions as $ext) {
+        if (!extension_loaded($ext)) {
+            p2die("{$ext} Šg’£ƒ‚ƒWƒ…[ƒ‹‚ªƒ[ƒh‚³‚ê‚Ä‚¢‚Ü‚¹‚ñB");
+        }
+    }
+
+    // —LŒø‚¾‚Æ“®ì‚µ‚È‚¢php.iniƒfƒBƒŒƒNƒeƒBƒu
+    foreach ($p2_incompatible_ini_directives as $directive) {
+        if (ini_get($directive)) {
+            p2die("{$directive} ‚ª On ‚Å‚·B",
+                  "php.ini ‚Å {$directive} ‚ð Off ‚É‚µ‚Ä‚­‚¾‚³‚¢B");
+        }
+    }
+
+    // eAccelerator
+    if (extension_loaded('eaccelerator') &&
+        version_compare(EACCELERATOR_VERSION, '0.9.5.2', '<'))
+    {
+        $err = 'eAccelerator‚ðXV‚µ‚Ä‚­‚¾‚³‚¢B';
+        $ev = EACCELERATOR_VERSION;
+        $msg = <<<EOP
+<p>PHP 5.2‚Å—áŠO‚ð•ß‘¨‚Å‚«‚È‚¢–â‘è‚Ì‚ ‚éeAccelerator ({$ev})‚ªƒCƒ“ƒXƒg[ƒ‹‚³‚ê‚Ä‚¢‚Ü‚·B<br>
+eAccelerator‚𖳌ø‚É‚·‚é‚©A‚±‚Ì–â‘肪C³‚³‚ꂽeAccelerator 0.9.5.2ˆÈ~‚ðŽg—p‚µ‚Ä‚­‚¾‚³‚¢B<br>
+<a href="http://eaccelerator.net/">http://eaccelerator.net/</a></p>
+EOP;
+        p2die($err, $msg, true);
+    }
+
+    // „§ƒo[ƒWƒ‡ƒ“
+    if ($check_recommended) {
+        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</p>
+<p style="font-size:smaller">‚±‚̃ƒbƒZ[ƒW‚ð•\Ž¦‚µ‚È‚¢‚悤‚É‚·‚é‚É‚Í
+<em>{\$rep2_directory}</em>/conf/conf.inc.php ‚Ì {$check_recommended} s–ځA<br>
+<samp>p2_check_environment(<strong>__LINE__</strong>);</samp> ‚ð
+<samp>p2_check_environment(<strong>false</strong>);</samp> ‚ɏ‘‚«Š·‚¦‚Ä‚­‚¾‚³‚¢B</p>
+EOP;
+            }
+            return false;
+        }
+    }
+
+    return true;
+}
+
+// }}}
+// {{{ p2_check_migration()
+
+/**
+ * ƒ}ƒCƒOƒŒ[ƒVƒ‡ƒ“‚Ì•K—v‚ª‚ ‚é‚©‚Ç‚¤‚©‚ðƒ`ƒFƒbƒN
+ *
+ * @param   string  $config_version
+ * @return  array
+ */
+function p2_check_migration($config_version)
+{
+    include P2_CONF_DIR . '/setup_info.php';
+
+    $migrators = array();
+    $found = false;
+
+    foreach ($p2_changed_versions as $version) {
+        if ($found || version_compare($config_version, $version, '<')) {
+            $found = true;
+            $migrator_name = str_replace('.', '_', $version);
+            $migrator_func = 'p2_migrate_' . $migrator_name;
+            $migrator_file = '/migrators/' . $migrator_name . '.php';
+            $migrators[$migrator_func] = $migrator_file;
+        }
+    }
+
+    if ($found) {
+        return $migrators;
+    } else {
+        return null;
+    }
+}
+
+// }}}
+// {{{ p2_invoke_migrators()
+
+/**
+ * ƒ}ƒCƒOƒŒ[ƒVƒ‡ƒ“‚ðŽÀs
+ *
+ * @param array $migrators ƒ}ƒCƒOƒŒ[ƒVƒ‡ƒ“ŠÖ”‚̃ŠƒXƒg
+ * @param array $user_config ŒÃ‚¢ƒ†[ƒU[Ý’è
+ * @return array V‚µ‚¢ƒ†[ƒU[Ý’è
+ */
+function p2_invoke_migrators(array $migrators, array $user_config)
+{
+    global $_conf;
+
+    foreach ($migrators as $migrator_func => $migrator_file) {
+        include P2_LIB_DIR . $migrator_file;
+        $user_config = $migrator_func($_conf, $user_config);
+    }
+
+    return $user_config;
+}
+
+// }}}
+// {{{ p2_load_class()
+
+/**
+ * ƒNƒ‰ƒXƒ[ƒ_[
+ *
+ * @string $name
+ * @return void
+ */
+function p2_load_class($name)
+{
+    if (preg_match('/^(?:
+            BbsMap |
+            BrdCtl |
+            BrdMenu\\w* |
+            DataPhp |
+            FavSetManager |
+            FileCtl |
+            HostCheck |
+            Login |
+            NgAbornCtl |
+            P2\\w+ |
+            PresetManager |
+            ResHist |
+            Session |
+            SettingTxt |
+            ShowBrdMenu\\w* |
+            ShowThread\\w* |
+            StrCtl |
+            StrSjis |
+            SubjectTxt |
+            Thread\\w* |
+            Wap\\w+
+        )$/x', $name))
+    {
+        if ($name == 'P2Lock') {
+            include P2_LIB_DIR . '/FileCtl.php';
+        } elseif ($name == 'ResArticle') {
+            include P2_LIB_DIR . '/ResHist.php';
+        } elseif (strncmp($name, 'Wap', 3) === 0) {
+            include P2_LIB_DIR . '/Wap.php';
+        } elseif (strncmp($name, 'P2Http', 6) === 0) {
+            include P2_LIB_DIR . '/P2HttpExt.php';
+        } elseif (strncmp($name, 'BrdMenu', 7) === 0) {
+            include P2_LIB_DIR . '/BrdMenu.php';
+        } else {
+            include P2_LIB_DIR . '/' . $name . '.php';
+        }
+    } elseif (preg_match('/^\\w+DataStore$/', $name)) {
+        include P2_LIB_DIR . '/P2DataStore/' . $name . '.php';
+    }
+}
+
+// }}}
+
+/*
+ * 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:



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