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

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 1月 16日 (土) 07:33:34 JST


Revision: 786
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=786
Author:   rsk
Date:     2010-01-16 07:33:34 +0900 (Sat, 16 Jan 2010)

Log Message:
-----------
expack:
- rep2 1.8.60 lib/global.funcs.php, lib/P2Util.php よりいくつかの関数を移植。
- ログインクッキーの仕様をrep2 1.8.60に合わせた。

Modified Paths:
--------------
    p2ex/trunk/conf/conf.inc.php
    p2ex/trunk/conf/setup_info.php
    p2ex/trunk/lib/HostCheck.php
    p2ex/trunk/lib/Login.php
    p2ex/trunk/lib/MD5Crypt.php
    p2ex/trunk/lib/P2Util.php
    p2ex/trunk/lib/Session.php
    p2ex/trunk/lib/global.funcs.php
    p2ex/trunk/lib/login_first.inc.php
    p2ex/trunk/lib/setup.funcs.php

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


-------------- next part --------------
Modified: p2ex/trunk/conf/conf.inc.php
===================================================================
--- p2ex/trunk/conf/conf.inc.php	2010-01-15 21:36:43 UTC (rev 785)
+++ p2ex/trunk/conf/conf.inc.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -170,25 +170,13 @@
     // PEARƒCƒ“ƒXƒg[ƒ‹ƒfƒBƒŒƒNƒgƒŠAŒŸõƒpƒX‚ɒljÁ‚³‚ê‚é
     define('P2_PEAR_DIR', P2_BASE_DIR . '/includes');
 
-    // PEAR‚ðƒnƒbƒN‚µ‚½ƒtƒ@ƒCƒ‹—pƒfƒBƒŒƒNƒgƒŠA’ʏí‚ÌPEAR‚æ‚è—Dæ“I‚ÉŒŸõƒpƒX‚ɒljÁ‚³‚ê‚é
-    // Cache/Container/db.php(PEAR::Cache)‚ªMySQL”›‚肾‚Á‚½‚̂ŁA”Ä—p“I‚É‚µ‚½‚à‚Ì‚ð’u‚¢‚Ä‚¢‚é
-    // include_path‚ð’ljÁ‚·‚é‚̂̓pƒtƒH[ƒ}ƒ“ƒX‚ɉe‹¿‚ð‹y‚Ú‚·‚½‚߁A–{“–‚É•K—v‚ȏꍇ‚Ì‚Ý’è‹`
-    if (defined('P2_USE_PEAR_HACK')) {
-        define('P2_PEAR_HACK_DIR', P2_BASE_DIR . '/lib/pear_hack');
-    }
-
     // ƒRƒ}ƒ“ƒhƒ‰ƒCƒ“ƒc[ƒ‹
     define('P2_CLI_DIR', P2_BASE_DIR . '/cli');
 
     // ŒŸõƒpƒX‚ðƒZƒbƒg
-    $include_path = '';
-    if (defined('P2_PEAR_HACK_DIR')) {
-        $include_path = P2_PEAR_HACK_DIR . PATH_SEPARATOR;
-    }
     if (is_dir(P2_PEAR_DIR)) {
-        $include_path .= P2_PEAR_DIR . PATH_SEPARATOR;
+        set_include_path(P2_PEAR_DIR . PATH_SEPARATOR . get_include_path());
     }
-    set_include_path($include_path . get_include_path());
 
     // }}}
     // {{{ ŠÂ‹«ƒ`ƒFƒbƒN‚ƃfƒoƒbƒO

Modified: p2ex/trunk/conf/setup_info.php
===================================================================
--- p2ex/trunk/conf/setup_info.php	2010-01-15 21:36:43 UTC (rev 785)
+++ p2ex/trunk/conf/setup_info.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -32,7 +32,7 @@
     'register_globals',
     'magic_quotes_gpc',
     'mbstring.encoding_translation',
-    'session.cookie_httponly',
+    'session.auto_start',
 );
 
 // ˆÚsƒXƒNƒŠƒvƒg‚ÌŽÀs‚ª•K—v‚ȕύX‚Ì‚ ‚Á‚½ƒo[ƒWƒ‡ƒ“”ԍ†‚Ì”z—ñ

Modified: p2ex/trunk/lib/HostCheck.php
===================================================================
--- p2ex/trunk/lib/HostCheck.php	2010-01-15 21:36:43 UTC (rev 785)
+++ p2ex/trunk/lib/HostCheck.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -134,10 +134,10 @@
                 ($flag == $types['private']   && self::isAddressPrivate($address))  ||
                 ($flag == $types['docomo']    && self::isAddressDocomo($address))   ||
                 ($flag == $types['au']        && self::isAddressAu($address))       ||
-                ($flag == $types['softbank']  && self::isAddressSoftbank($address)) ||
+                ($flag == $types['softbank']  && self::isAddressSoftBank($address)) ||
                 ($flag == $types['willcom']   && self::isAddressWillcom($address))  ||
                 ($flag == $types['emobile']   && self::isAddressEmobile($address))  ||
-                ($flag == $types['iphone']    && self::isAddressIphone($address))   ||
+                ($flag == $types['iphone']    && self::isAddressIPhone($address))   ||
                 ($flag == $types['custom'] && (!empty($custom) || !empty($custom_re)) &&
                     self::isAddressInBand($address, $custom, $custom_re,
                             'custom', filemtime(P2_CONF_DIR . '/conf_hostcheck.php')
@@ -549,12 +549,12 @@
     }
 
     // }}}
-    // {{{ isAddressSoftbank()
+    // {{{ isAddressSoftBank()
 
     /**
      * SoftBank?
      */
-    static public function isAddressSoftbank($address = null)
+    static public function isAddressSoftBank($address = null)
     {
         include P2_CONF_DIR . '/ip_softbank.php';
 
@@ -621,12 +621,12 @@
     }
 
     // }}}
-    // {{{ isAddressIphone()
+    // {{{ isAddressIPhone()
 
     /**
      * iPhone 3G (SoftBank)?
      */
-    static public function isAddressIphone($address = null)
+    static public function isAddressIPhone($address = null)
     {
         include P2_CONF_DIR . '/ip_iphone.php';
 
@@ -645,6 +645,134 @@
     }
 
     // }}}
+    // {{{ isAddressJigWeb()
+
+    /**
+     * IP‚Í jig web?
+     *
+     * @param   string  $addr
+     * @return  boolean
+     */
+    function isAddressJigWeb($addr = null)
+    {
+        if (is_null($addr)) {
+            $addr = $_SERVER['REMOTE_ADDR'];
+        }
+        // bw5022.jig.jp
+        $reghost = '/^bw\d+\.jig\.jp$/';
+
+        $bands = array(
+            '202.181.98.241',   // 2007/08/06
+            //'210.143.108.0/24', // 2005/6/23
+        );
+        return self::isAddressInBand($addr, $bands, $reghost, 'jigweb');
+    }
+
+    // }}}
+    // {{{ isAddressJig()
+
+    /**
+     * IP‚Í jigƒAƒvƒŠ?
+     *
+     * @link    http://br.jig.jp/pc/ip_br.html
+     * @static
+     * @access  public
+     * @return  boolean
+     */
+    function isAddressJig($addr = null)
+    {
+        if (is_null($addr)) {
+            $addr = $_SERVER['REMOTE_ADDR'];
+        }
+
+        // br***.jig.jp
+        $reghost = '/^br\d+\.jig\.jp$/';
+
+        // @updated 2009/06/04
+        $bands = array(
+            '59.106.14.175/32',
+            '59.106.14.176/32',
+            '59.106.23.169/32',
+            '59.106.23.170/31',
+            '59.106.23.172/31',
+            '59.106.23.174/32',
+            '112.78.114.171/32',
+            '112.78.114.172/30',
+            '112.78.114.176/29',
+            '112.78.114.184/30',
+            '112.78.114.188/31',
+            '112.78.114.191/32',
+            '112.78.114.192/29',
+            '112.78.114.200/30',
+            '112.78.114.204/31',
+            '112.78.114.206/32',
+            '112.78.114.208/32',
+            '202.181.96.94/32',
+            '202.181.98.153/32',
+            '202.181.98.156/32',
+            '202.181.98.160/32',
+            '202.181.98.179/32',
+            '202.181.98.182/32',
+            '202.181.98.185/32',
+            '202.181.98.196/32',
+            '202.181.98.218/32',
+            '202.181.98.221/32',
+            '202.181.98.223/32',
+            '202.181.98.247/32',
+            '210.188.205.81/32',
+            '210.188.205.83/32',
+            '210.188.205.97/32',
+            '210.188.205.166/31',
+            '210.188.205.168/31',
+            '210.188.205.170/32',
+            '210.188.220.169/32',
+            '210.188.220.170/31',
+            '210.188.220.172/30',
+            '219.94.133.167/32',
+            '219.94.133.192/32',
+            '219.94.133.243/32',
+            '219.94.144.5/32',
+            '219.94.144.6/31',
+            '219.94.144.23/32',
+            '219.94.144.24/32',
+            '219.94.147.35/32',
+            '219.94.147.36/30',
+            '219.94.147.42/31',
+            '219.94.147.44/32',
+            '219.94.166.8/30',
+            '219.94.166.173/32',
+            '219.94.197.196/30',
+            '219.94.197.200/30',
+            '219.94.197.204/31'
+        );
+        return self::isAddressInBand($addr, $bands, $reghost, 'jig');
+    }
+
+    // }}}
+    // {{{ isAddressIbis()
+
+    /**
+     * IP‚Í ibis?
+     *
+     * @static
+     * @access  public
+     * @return  boolean
+     */
+    static public function isAddressIbis($addr = null)
+    {
+        if (is_null($addr)) {
+            $addr = $_SERVER['REMOTE_ADDR'];
+        }
+
+        // http://qb5.2ch.net/test/read.cgi/operate/1183341095/504
+        $bands = array(
+            '219.117.203.9', // ƒVƒXƒeƒ€ˆÚs‚ªŠ®—¹‚·‚ê‚Η˜—p‚µ‚È‚­‚È‚é‚炵‚¢
+            '59.106.52.16/29'
+        );
+        return self::isAddressInBand($addr, $bands);
+    }
+
+    // }}}
 }
 
 // }}}

Modified: p2ex/trunk/lib/Login.php
===================================================================
--- p2ex/trunk/lib/Login.php	2010-01-15 21:36:43 UTC (rev 785)
+++ p2ex/trunk/lib/Login.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -665,17 +665,28 @@
 
     /**
      * cookie”FØ‚ð“o˜^/‰ðœ‚·‚é
+     *
+     * @param void
+     * @return boolean
      */
     public function registCookie()
     {
+        $r = true;
+
         if (!empty($_REQUEST['ctl_regist_cookie'])) {
             if ($_REQUEST['regist_cookie'] == '1') {
-                $this->setCookieCid($this->user_u, $this->pass_x);
+                $ignore_cip = false;
+                if (!empty($_POST['ignore_cip'])) {
+                    $ignore_cip = true;
+                }
+                $r = $this->setCookieCid($this->user_u, $this->pass_x, $ignore_cip);
             } else {
                 // ƒNƒbƒL[‚ðƒNƒŠƒA
-                $this->clearCookieAuth();
+                $r = $this->clearCookieAuth();
             }
         }
+
+        return $r;
     }
 
     // }}}
@@ -703,19 +714,32 @@
     /**
      * CID‚ðcookie‚ɃZƒbƒg‚·‚é
      *
+     * @param string $user_u
+     * @param string $pass_x
+     * @param boolean|null $ignore_cip
      * @return boolean
      */
-    public function setCookieCid($user_u, $pass_x)
+    protected function setCookieCid($user_u, $pass_x, $ignore_cip = null)
     {
         global $_conf;
 
+        $time = time() + 60*60*24 * $_conf['cid_expire_day'];
+
+        if (!is_null($ignore_cip)) {
+            if ($ignore_cip) {
+                P2Util::setCookie('ignore_cip', '1', $time);
+                $_COOKIE['ignore_cip'] = '1';
+            } else {
+                P2Util::unsetCookie('ignore_cip');
+                // ”O‚Ì‚½‚߃hƒƒCƒ“Žw’è‚È‚µ‚à
+                setcookie('ignore_cip', '', time() - 3600);
+            }
+        }
+
         if ($cid = $this->makeCid($user_u, $pass_x)) {
-            $time = time() + 60*60*24 * $_conf['cid_expire_day'];
-            setcookie('cid', $cid, $time);
-            return true;
-        } else {
-            return false;
+            return P2Util::setCookie('cid', $cid, $time);
         }
+        return false;
     }
 
     // }}}
@@ -732,14 +756,10 @@
             return false;
         }
 
-        $key = $this->getMd5CryptKey();
-
-        $idtime = $user_u. ':'. time(). ':';
-        $pw_enc = md5($idtime . $pass_x);
-        $str = $idtime . $pw_enc;
-        $cid = MD5Crypt::encrypt($str, $key, 32);
-
-        return $cid;
+        $user_time  = $user_u . ':' . time() . ':';
+        $md5_utpx = md5($user_time . $pass_x);
+        $cid_src  = $user_time . $md5_utpx;
+        return $cid = MD5Crypt::encrypt($cid_src, self::getMd5CryptPassForCid());
     }
 
     // }}}
@@ -754,17 +774,19 @@
     {
         global $_conf;
 
-        $key = $this->getMd5CryptKey();
+        $dec = MD5Crypt::decrypt($cid, self::getMd5CryptPassForCid());
 
-        $dec = MD5Crypt::decrypt($cid, $key, 32);
-        list($user, $time, $pw_enc) = explode(':', $dec, 3);
+        $user = $time = $md5_utpx = null;
+        list($user, $time, $md5_utpx) = explode(':', $dec, 3);
+        if (!strlen($user) || !$time || !$md5_utpx) {
+            return false;
+        }
 
         // —LŒøŠúŒÀ “ú”
-        if (time() > $time + (86400 * $_conf['cid_expire_day'])) {
+        if (time() > $time + (60*60*24 * $_conf['cid_expire_day'])) {
             return false; // ŠúŒÀØ‚ê
-        } else {
-            return array($user, $time, $pw_enc);
         }
+        return array($user, $time, $md5_utpx);
     }
 
     // }}}
@@ -816,17 +838,45 @@
     }
 
     // }}}
-    // {{{ getMd5CryptKey()
+    // {{{ getMd5CryptPassForCid()
 
     /**
-     * MD5Crypt::encrypt, MD5Crypt::decrypt ‚Ì‚½‚߂ɃNƒŠƒvƒgƒL[‚𓾂é
+     * MD5Crypt::encrypt, MD5Crypt::decrypt ‚Ì‚½‚ß‚Ì password(salt) ‚𓾂é
+     * iƒNƒbƒL[‚Ìcid‚̐¶¬‚É—˜—p‚µ‚Ä‚¢‚éj
      *
-     * @return string
+     * @param   void
+     * @access  private
+     * @return  string
      */
-    public function getMd5CryptKey()
+    static private function getMd5CryptPassForCid()
     {
-        //return $_SERVER['SERVER_NAME'] . $_SERVER['HTTP_USER_AGENT'] . $_SERVER['SERVER_SOFTWARE'];
-        return $_SERVER['SERVER_NAME'] . $_SERVER['SERVER_SOFTWARE'];
+        //return md5($_SERVER['SERVER_NAME'] . $_SERVER['HTTP_USER_AGENT'] . $_SERVER['SERVER_SOFTWARE']);
+
+        //$seed = $_SERVER['SERVER_NAME'] . $_SERVER['SERVER_SOFTWARE'];
+        $seed = $_SERVER['SERVER_SOFTWARE'];
+
+        // ƒ[ƒJƒ‹ƒ`ƒFƒbƒN‚ð‚µ‚ÄAHostCheck::isAddressDocomo() ‚ȂǂŃzƒXƒg–¼‚ðˆø‚­‹@‰ï‚ðŒ¸‚ç‚·
+        $notK = (bool)(HostCheck::isAddressLocal() || HostCheck::isAddressPrivate());
+
+        // Œg‘Ñ”»’肳‚ꂽê‡‚́A IPƒ`ƒFƒbƒN‚È‚µ
+        if (
+            !$notK and
+            //!$_conf['cid_seed_ip'] or
+            UA::isK(geti($_SERVER['HTTP_USER_AGENT']))
+            || HostCheck::isAddressDocomo() || HostCheck::isAddressAu() || HostCheck::isAddressSoftBank()
+            || HostCheck::isAddressWillcom()
+            || HostCheck::isAddressJigWeb() || HostCheck::isAddressJig()
+            || HostCheck::isAddressIbis()
+        ) {
+            ;
+        } elseif (!empty($_COOKIE['ignore_cip'])) {
+            ;
+        } else {
+            $now_ips = explode('.', $_SERVER['REMOTE_ADDR']);
+            $seed .= $now_ips[0];
+        }
+
+        return md5($seed, true);
     }
 
     // }}}

Modified: p2ex/trunk/lib/MD5Crypt.php
===================================================================
--- p2ex/trunk/lib/MD5Crypt.php	2010-01-15 21:36:43 UTC (rev 785)
+++ p2ex/trunk/lib/MD5Crypt.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -32,6 +32,8 @@
 
     static public function encrypt($plain_text, $password, $iv_len = 16)
     {
+        $password = self::adjustPassword($password, $iv_len); // added by aki
+
         $plain_text .= "\x13";
         $n = strlen($plain_text);
         if ($n % 16) {
@@ -54,6 +56,8 @@
 
     static public function decrypt($enc_text, $password, $iv_len = 16)
     {
+        $password = self::adjustPassword($password, $iv_len); // added by aki
+
         $enc_text = base64_decode($enc_text);
         $n = strlen($enc_text);
         $i = $iv_len;
@@ -69,8 +73,27 @@
     }
 
     // }}}
+    // {{{ adjustPassword()
 
+    /**
+     * $passwordisaltj‚Ì’·‚³‚ª $iv_len ‚ð’´‚¦‚Ä‚¢‚½‚ç md5() ‚µ‚½ŒãAƒJƒbƒg‚µ‚ÄŽû‚ß‚é
+     *
+     * @author  aki
+     * @since   2007/07/02
+     * @access  private
+     * @return  string
+     */
+    static private function adjustPassword($password, $iv_len)
+    {
+        if (strlen($password) > $iv_len) {
+            $password = substr(md5($password), 0, $iv_len);
+        }
+        return $password;
+    }
+
+    // }}}
 }
+
 // }}}
 
 /******************************************/

Modified: p2ex/trunk/lib/P2Util.php
===================================================================
--- p2ex/trunk/lib/P2Util.php	2010-01-15 21:36:43 UTC (rev 785)
+++ p2ex/trunk/lib/P2Util.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -61,6 +61,172 @@
     static private $_postDataStore = null;
 
     // }}}
+    // {{{ getMyHost()
+
+    /**
+     * ƒ|[ƒg”ԍ†‚ðí‚Á‚½ƒzƒXƒg–¼‚ðŽæ“¾‚·‚é
+     *
+     * @param   void
+     * @return  string|null
+     */
+    static public function getMyHost()
+    {
+        if (!isset($_SERVER['HTTP_HOST'])) {
+            return null;
+        }
+        return preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST']);
+    }
+
+    // }}}
+    // {{{ getCookieDomain()
+
+    /**
+     * @param   void
+     * @return  string
+     */
+    static public function getCookieDomain()
+    {
+        return '';
+    }
+
+    // }}}
+    // {{{ encodeCookieName()
+
+    /**
+     * @param   string $key
+     * @return  string
+     */
+    static private function encodeCookieName($key)
+    {
+        // ”z—ñŽw’è—p‚ɁA[]‚¾‚¯‚»‚Ì‚Ü‚ÜŽc‚µ‚āAURLƒGƒ“ƒR[ƒh‚ð‚©‚¯‚é
+        return $key_urlen = preg_replace_callback(
+            '/[^\\[\\]]+/',
+            array(__CLASS__, 'rawurldecodeCallback'),
+            $key
+        );
+    }
+
+    // }}}
+    // {{{ setCookie()
+
+    /**
+     * setcookie() ‚ł́Aau‚Å•K—v‚Èmax age‚ªÝ’肳‚ê‚È‚¢‚̂ŁA‚±‚¿‚ç‚ð—˜—p‚·‚é
+     *
+     * @access  public
+     * @param   string  $key
+     * @param   string  $value
+     * @param   int     $expires
+     * @param   string  $path
+     * @param   string  $domain
+     * @param   boolean $secure
+     * @param   boolean $httponly
+     * @return  boolean
+     */
+    static public function setCookie($key, $value = '', $expires = null, $path = '', $domain = null, $secure = false, $httponly = true)
+    {
+        if (is_null($domain)) {
+            $domain = self::getCookieDomain();
+        }
+        is_null($expires) and $expires = time() + 60 * 60 * 24 * 365;
+
+        if (headers_sent()) {
+            return false;
+        }
+
+        // Mac IE‚́A“®ì•s—Ç‚ð‹N‚±‚·‚炵‚¢‚Á‚Û‚¢‚̂ŁAhttponly‚̑Ώۂ©‚çŠO‚·Bi‚»‚à‚»‚à‘Ήž‚à‚µ‚Ä‚¢‚È‚¢j
+        // MAC IE5.1  Mozilla/4.0 (compatible; MSIE 5.16; Mac_PowerPC)
+        if (preg_match('/MSIE \d\\.\d+; Mac/', geti($_SERVER['HTTP_USER_AGENT']))) {
+            $httponly = false;
+        }
+
+        // setcookie($key, $value, $expires, $path, $domain, $secure = false, $httponly = true);
+        /*
+        if (is_array($name)) {
+            list($k, $v) = each($name);
+            $name = $k . '[' . $v . ']';
+        }
+        */
+        if ($expires) {
+            $maxage = $expires - time();
+        }
+
+        header(
+            'Set-Cookie: '. self::encodeCookieName($key) . '=' . rawurlencode($value)
+                 . (empty($domain) ? '' : '; Domain=' . $domain)
+                 . (empty($expires) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s', $expires) . ' GMT')
+                 . (empty($maxage) ? '' : '; Max-Age=' . $maxage)
+                 . (empty($path) ? '' : '; Path=' . $path)
+                 . (!$secure ? '' : '; Secure')
+                 . (!$httponly ? '' : '; HttpOnly'),
+             $replace = false
+        );
+
+        return true;
+    }
+
+    // }}}
+    // {{{ unsetCookie()
+
+    /**
+     * ƒNƒbƒL[‚ðÁ‹Ž‚·‚éB•Ï” $_COOKIE ‚àB
+     *
+     * @param   string  $key  key, k1[k2]
+     * @param   string  $path
+     * @param   string  $domain
+     * @return  boolean
+     */
+    static public function unsetCookie($key, $path = '', $domain = null)
+    {
+        if (is_null($domain)) {
+            $domain = self::getCookieDomain();
+        }
+
+        // ”z—ñ‚ðsetcookie()‚·‚鎞‚́AƒL[•¶Žš—ñ‚ðPHP‚Ì”z—ñ‚̏ꍇ‚̂悤‚ɁA'' ‚â "" ‚ŃNƒH[ƒg‚µ‚È‚¢B
+        // ‚»‚ê‚ç‚̓L[•¶Žš—ñ‚Æ‚µ‚Ä”FŽ¯‚³‚ê‚Ä‚µ‚Ü‚¤B['hoge']‚Å‚Í‚È‚­A[hoge]‚ÆŽw’è‚·‚éB
+        // setcookie()‚ŁAˆêŽžƒL[‚Í[]‚ň͂܂Ȃ¢‚悤‚É‚·‚éBi–³Œø‚ȏˆ—‚Æ‚È‚éBj k1[k2] ‚Æ‚¢‚¤•\‹L‚ÅŽw’è‚·‚éB
+        // setcookie()‚Å‚Í”z—ñ‚ð‚܂Ƃ߂č폜‚·‚邱‚Æ‚Í‚Å‚«‚È‚¢B
+        // k1 ‚ÌŽw’è‚Å k1[k2] ‚͏Á‚¦‚È‚¢‚̂ŁA‚±‚̃ƒ\ƒbƒh‚őΉž‚µ‚Ä‚¢‚éB
+
+        // $key‚ª”z—ñ‚Æ‚µ‚ÄŽw’肳‚ê‚Ä‚¢‚½‚È‚ç
+        $cakey = null; // $_COOKIE—p‚̃L[
+        if (preg_match('/\]$/', $key)) {
+            // Å‰‚̃L[‚ð[]‚ň͂Þ
+            $cakey = preg_replace('/^([^\[]+)/', '[$1]', $key);
+            // []‚̃L[‚ð''‚ň͂Þ
+            $cakey = preg_replace('/\[([^\[\]]+)\]/', "['$1']", $cakey);
+            //var_dump($cakey);
+        }
+
+        // ‘ΏÛCookie’l‚ª”z—ñ‚Å‚ ‚ê‚΍ċAˆ—‚ðs‚¤
+        $cArray = null;
+        if ($cakey) {
+            eval("isset(\$_COOKIE{$cakey}) && is_array(\$_COOKIE{$cakey}) and \$cArray = \$_COOKIE{$cakey};");
+        } else {
+            if (isset($_COOKIE[$key]) && is_array($_COOKIE[$key])) {
+                $cArray = $_COOKIE[$key];
+            }
+        }
+        if (is_array($cArray)) {
+            foreach ($cArray as $k => $v) {
+                $keyr = "{$key}[{$k}]";
+                if (!self::unsetCookie($keyr, $path, $domain)) {
+                    return false;
+                }
+            }
+        }
+
+        if (is_array($cArray) or setcookie("$key", '', time() - 3600, $path, $domain)) {
+            if ($cakey) {
+                eval("unset(\$_COOKIE{$cakey});");
+            } else {
+                unset($_COOKIE[$key]);
+            }
+            return true;
+        }
+        return false;
+    }
+
+    // }}}
     // {{{ fileDownload()
 
     /**
@@ -106,7 +272,7 @@
             if ($wap_res->isRedirect() && array_key_exists('Location', $wap_res->headers)) {
                 $location = $wap_res->headers['Location'];
                 $location_ht = htmlspecialchars($location, ENT_QUOTES);
-                $location_t = P2Util::throughIme($location);
+                $location_t = self::throughIme($location);
                 $_info_msg_ht .= "Location: <a href=\"{$location_t}\"{$_conf['ext_win_target_at']}>{$location_ht}</a><br>";
             }
             $_info_msg_ht .= "p2 info: <a href=\"{$url_t}\"{$_conf['ext_win_target_at']}>{$wap_req->url}</a> ‚ɐڑ±‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½B</div>";
@@ -1865,6 +2031,21 @@
     }
 
     // }}}
+    // {{{ rawurldecodeCallback()
+
+    /**
+     * preg_replace_callback()‚̃R[ƒ‹ƒoƒbƒNŠÖ”‚Æ‚µ‚Ä
+     * ƒ}ƒbƒ`‰ÓŠ‘S‘Ì‚Érawurldecode()‚ð‚©‚¯‚é
+     *
+     * @param   array   $m
+     * @return  string
+     */
+    static public function rawurldecodeCallback(array $m)
+    {
+        return rawurlencode($m[0]);
+    }
+
+    // }}}
     // {{{ debug()
     /*
     static public function debug()

Modified: p2ex/trunk/lib/Session.php
===================================================================
--- p2ex/trunk/lib/Session.php	2010-01-15 21:36:43 UTC (rev 785)
+++ p2ex/trunk/lib/Session.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -50,6 +50,8 @@
      */
     public function __construct($session_name = null, $session_id = null, $use_cookies = true)
     {
+        $this->setCookieHttpOnly();
+
         // ƒLƒƒƒbƒVƒ…§Œä‚È‚µ
         session_cache_limiter('none');
 
@@ -308,10 +310,11 @@
         $_SESSION = array();
 
         // ƒZƒbƒVƒ‡ƒ“‚ðØ’f‚·‚é‚ɂ̓ZƒbƒVƒ‡ƒ“ƒNƒbƒL[‚àíœ‚·‚éB
-        // Note: ƒZƒbƒVƒ‡ƒ“î•ñ‚¾‚¯‚Å‚È‚­ƒZƒbƒVƒ‡ƒ“‚ð”j‰ó‚·‚éB
-        if (isset($_COOKIE[session_name()])) {
-           unset($_COOKIE[session_name()]);
-           setcookie(session_name(), '', time() - 42000);
+        $session_name = session_name();
+        if (isset($_COOKIE[$session_name])) {
+           //setcookie($session_name, '', time() - 42000);
+           P2Util::unsetCookie($session_name);
+           unset($_COOKIE[$session_name]);
         }
 
         // ÅI“I‚ɁAƒZƒbƒVƒ‡ƒ“‚ð”j‰ó‚·‚é
@@ -329,6 +332,29 @@
     }
 
     // }}}
+    // {{{ setCookieHttpOnly()
+
+    /**
+     * ƒZƒbƒVƒ‡ƒ“‚Ìsetcookie‚ÉHttpOnly‚ðŽw’è‚·‚é
+     * http://msdn2.microsoft.com/ja-jp/library/system.web.httpcookie.httponly(VS.80).aspx
+     *
+     * @param   void
+     * @return  void
+     */
+    private function setCookieHttpOnly()
+    {
+        $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
+
+        // Mac IE‚́A“®ì•s—Ç‚ð‹N‚±‚·‚炵‚¢‚Á‚Û‚¢‚̂őΏۂ©‚çŠO‚·Bi‚»‚à‚»‚à‘Ήž‚à‚µ‚Ä‚¢‚È‚¢j
+        // Mozilla/4.0 (compatible; MSIE 5.16; Mac_PowerPC)
+        if (preg_match('/MSIE \d\\.\d+; Mac/', $ua)) {
+            return;
+        }
+
+        ini_set('session.cookie_httponly', true);
+    }
+
+    // }}}
 }
 
 // }}}

Added: p2ex/trunk/lib/UA.php
===================================================================
--- p2ex/trunk/lib/UA.php	                        (rev 0)
+++ p2ex/trunk/lib/UA.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -0,0 +1,524 @@
+<?php
+// —Ⴆ‚΁AƒNƒGƒŠ[‚ª b=k ‚È‚ç isK() ‚ªtrue‚Æ‚È‚é‚̂ŁAŒg‘ÑŒü‚¯•\Ž¦‚É‚µ‚½‚è‚·‚é
+
+// {{{ ‚±‚̃Nƒ‰ƒX‚Å‚Ì‚Ý—˜—p‚·‚éƒOƒ[ƒoƒ‹•Ï”i_UA_*j
+// over PHP5‚ÉŒÀ’è‚Å‚«‚é‚È‚çƒvƒ‰ƒCƒx[ƒg‚ȃNƒ‰ƒX•Ï”‚É‚µ‚½‚¢‚Æ‚±‚ë‚Ì‚à‚Ì
+
+// @see getQueryKey()
+$GLOBALS['_UA_query_key'] = 'b';
+
+// @see setPCQuery() // b=pc
+$GLOBALS['_UA_PC_query'] = 'pc';
+
+// @see setMobileQuery() // b=k
+$GLOBALS['_UA_mobile_query'] = 'k';
+
+// @see setIPhoneGroupQuery() // b=i
+$GLOBALS['_UA_iphonegroup_query'] = 'i';
+
+$GLOBALS['_UA_force_mode'] = null;
+
+// }}}
+// {{{ UA
+
+// [todo] enableJS() ‚â enableAjax() ‚à—~‚µ‚¢‚©‚à
+
+/**
+ * staticƒƒ\ƒbƒh‚Å—˜—p‚·‚é
+ */
+class UA
+{
+    // {{{ setForceMode()
+
+    /**
+     * ‹­§“I‚Ƀ‚[ƒhipc, kj‚ðŽw’è‚·‚é
+     * iƒNƒGƒŠ[‚ðƒZƒbƒg‚·‚é‚킯‚Å‚Í‚È‚¢j
+     */
+    static public function setForceMode($v)
+    {
+        $GLOBALS['_UA_force_mode'] = $v;
+    }
+
+    // }}}
+    // {{{ isPC()
+
+    /**
+     * UA‚ªPCi”ñƒ‚ƒoƒCƒ‹j‚È‚çtrue‚ð•Ô‚·
+     * iPhone‚àŠÜ‚ñ‚Å‚¢‚邪A‚¢‚¸‚êŠÜ‚Ü‚È‚­‚È‚é‰Â”\«‚ª‚ ‚邱‚Æ‚É’ˆÓB
+     * Œ»ÝAiPhone‚ÍsetForceMode()‚ÅisMobileByQuery()ˆµ‚¢‚µ‚Ä‚¢‚éBiŒø—ÍŽã‚߂Łj
+     *
+     * @return  boolean
+     */
+    static public function isPC($ua = null)
+    {
+        return !self::isMobile($ua);
+    }
+
+    // }}}
+    // {{{ isK()
+
+    /**
+     * isMobile() ‚̃GƒCƒŠƒAƒX‚É‚È‚Á‚Ä‚¢‚é
+     *
+     * [plan] Œg‘ÑisK()‚ƁAƒ‚ƒoƒCƒ‹isMobile()‚́A•Ê‚Ì‚à‚Ì‚Æ‚µ‚Ä‹æ•Ê‚µ‚½•û‚ª‚¢‚¢‚©‚ȁBiisMobile()‚ÍisK()‚ðŠÜ‚Þ‚à‚Ì‚Æ‚µ‚āj
+     * Œg‘сF‰æ–Ê‚ª¬‚³‚¢Bƒy[ƒW‚Ì•\Ž¦—e—ʂɐ§ŒÀ‚ª‚ ‚éB”Žš‚̃AƒNƒZƒXƒL[‚ðŽg‚¤B
+     * ƒ‚ƒoƒCƒ‹FŒg‘Ñ‚Æ“¯‚¶‚­‰æ–Ê‚ª¬‚³‚ß‚¾‚ªAƒtƒ‹ƒuƒ‰ƒEƒU‚ŁAJavaScript‚ªŽg‚¦‚éB
+     */
+    static public function isK($ua = null)
+    {
+        return self::isMobile($ua);
+    }
+
+    // }}}
+    // {{{ isMobile()
+
+    /**
+     * UA‚ªŒg‘Ñ•\Ž¦‘ΏۂȂçtrue‚ð•Ô‚·
+     * isK()‚ƈӖ¡‚ð‹æ•Ê‚·‚é—\’肪‚ ‚é‚̂ŁA‚»‚ê‚Ü‚Å‚ÌŠÔ‚ÍŽg‚í‚È‚¢‚Å‚¨‚­iŒ»Žž“_AŽg‚Á‚Ä‚¢‚È‚¢j
+     * iisMobileByQuery()‚È‚Ç‚ÍŽg‚í‚ê‚Ä‚¢‚邪j
+     * isM()‚É‚µ‚½‚¢‹C‚àB
+     *
+     * @params  string  $ua  UA‚ðŽw’è‚·‚é‚È‚ç
+     * @return  boolean
+     */
+    static public function isMobile($ua = null)
+    {
+        static $cache_ = null;
+
+        // ‹­§Žw’肪‚ ‚ê‚Î
+        if (isset($GLOBALS['_UA_force_mode'])) {
+            // ‚±‚±‚̓LƒƒƒbƒVƒ…‚µ‚È‚¢
+            return ($GLOBALS['_UA_force_mode'] == $GLOBALS['_UA_mobile_query']);
+        }
+
+        // ˆø”‚ÌUA‚ª–³Žw’è‚È‚çAƒNƒGƒŠ[Žw’è‚ðŽQÆ
+        if (is_null($ua)) {
+            if (self::getQueryValue()) {
+                return self::isMobileByQuery();
+            }
+        }
+
+        // ˆø”‚ÌUA‚ª–³Žw’è‚È‚çAƒLƒƒƒbƒVƒ…—LŒø
+        if (is_null($ua) and !is_null($cache_)) {
+            return $cache_;
+        }
+
+        $isMobile = false;
+        if ($nuam = &self::getNet_UserAgent_Mobile($ua)) {
+            if (!$nuam->isNonMobile()) {
+                $isMobile = true;
+            }
+        }
+
+        /*
+        // NetFrontŒniŠÜ‚ÞPSPj‚àƒ‚ƒoƒCƒ‹‚É
+        if (!$isMobile) {
+            $isMobile = self::isNetFront($ua);
+        }
+
+        // Nintendo DS‚àƒ‚ƒoƒCƒ‹‚É
+        if (!$isMobile) {
+            $isMobile = self::isNintendoDS($ua);
+        }
+        */
+
+        // ˆø”‚ÌUA‚ª–³Žw’è‚È‚çAƒLƒƒƒbƒVƒ…•Û‘¶
+        if (is_null($ua)) {
+            $cache_ = $isMobile;
+        }
+
+        return $isMobile;
+    }
+
+    // }}}
+    // {{{ isIPhoneGroup()
+
+    /**
+     * UA‚ªiPhone, iPod touch‚È‚çtrue‚ð•Ô‚·B
+     *
+     * @param   string   $aua  UA‚ðŽw’è‚·‚é‚È‚ç
+     * @return  boolean
+     */
+    static public function isIPhoneGroup($aua = null)
+    {
+        static $cache_ = null;
+
+        // ‹­§Žw’肪‚ ‚ê‚΃`ƒFƒbƒN
+        if (isset($GLOBALS['_UA_force_mode'])) {
+            // ˆÚs‚Ì•Ö‹XãAŒø—Í‚ðŽã‚ß‚Ä‚¢‚é
+            // return ($GLOBALS['_UA_force_mode'] == $GLOBALS['_UA_iphonegroup_query']);
+            if ($GLOBALS['_UA_force_mode'] == $GLOBALS['_UA_iphonegroup_query']) {
+                return true;
+            }
+        }
+
+        $ua = $aua;
+
+        // UA‚̈ø”‚ª–³Žw’è‚È‚çA
+        if (is_null($aua)) {
+            // ƒNƒGƒŠ[Žw’è‚ðŽQÆ
+            if (self::getQueryValue()) {
+                //// Œã•ûŒÝŠ·ãAb=k‚Å‚àiPhone‚Æ‚Ý‚È‚·‚±‚Æ‚ð‹–‚·B
+                //if (!self::isMobileByQuery()) {
+                    return self::isIPhoneGroupByQuery();
+                //}
+            }
+
+            // iƒLƒƒƒbƒVƒ…‚·‚é‚Ù‚Ç‚Å‚Í‚È‚¢‚©‚àj
+            // ˆø”‚ÌUA‚ª–³Žw’è‚È‚çAƒLƒƒƒbƒVƒ…—LŒø
+            if (!is_null($cache_)) {
+                return $cache_;
+            }
+
+            // ƒNƒ‰ƒCƒAƒ“ƒg‚ÌUA‚Å”»•Ê
+            if (isset($_SERVER['HTTP_USER_AGENT'])) {
+                $ua = $_SERVER['HTTP_USER_AGENT'];
+            }
+        }
+
+        $isiPhoneGroup = false;
+
+        // iPhone
+        // Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3
+
+        // iPod touch
+        // Mozilla/5.0 (iPod; U; CPU like Mac OS X; ja-jp) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A110a Safari/419.3
+        if (preg_match('/(iPhone|iPod)/', $ua) || self::isAndroidWebKit($ua)) {
+            $isiPhoneGroup = true;
+        }
+
+        // UA‚̈ø”‚ª–³Žw’è‚È‚çAƒLƒƒƒbƒVƒ…•Û‘¶
+        if (is_null($aua)) {
+            $cache_ = $isiPhoneGroup;
+        }
+        return $isiPhoneGroup;
+    }
+
+    // }}}
+    // {{{ isPCByQuery()
+
+    /**
+     * ƒNƒGƒŠ[‚ªPC‚ðŽw’肵‚Ä‚¢‚é‚È‚çtrue‚ð•Ô‚·
+     *
+     * @return  boolean
+     */
+    static private function isPCByQuery()
+    {
+        $qv = self::getQueryValue();
+        if (isset($qv) && $qv == self::getPCQuery()) {
+            return true;
+        }
+        return false;
+    }
+
+    // }}}
+    // {{{ isMobileByQuery()
+
+    /**
+     * ƒNƒGƒŠ[‚ªŒg‘Ñ‚ðŽw’肵‚Ä‚¢‚é‚È‚çtrue‚ð•Ô‚·
+     *
+     * @return  boolean
+     */
+    static private function isMobileByQuery()
+    {
+        $qv = self::getQueryValue();
+        if (isset($qv) && $qv == self::getMobileQuery()) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * ƒNƒGƒŠ[‚ªIPhoneGroup‚ðŽw’肵‚Ä‚¢‚é‚È‚çtrue‚ð•Ô‚·
+     *
+     * @return  boolean
+     */
+    static private function isIPhoneGroupByQuery()
+    {
+        $qv = self::getQueryValue();
+        if (isset($qv) && $qv == self::getIPhoneGroupQuery()) {
+            return true;
+        }
+        return false;
+    }
+
+    // }}}
+    // {{{ getQueryValue()
+
+    /**
+     * •\Ž¦ƒ‚[ƒhŽw’è—p‚̃NƒGƒŠ[’l‚ðŽæ“¾‚·‚é
+     *
+     * @return  string|null
+     */
+    static public function getQueryValue($key = null)
+    {
+        if (is_null($key)) {
+            if (!$key = self::getQueryKey()) {
+                return null;
+            }
+        }
+
+        $r = null;
+        if (isset($_REQUEST[$key])) {
+            if (preg_match('/^\\w+$/', $_REQUEST[$key])) {
+                $r = $_REQUEST[$key];
+            }
+        }
+        return $r;
+    }
+
+    // }}}
+    // {{{ getQueryKey()
+
+    /**
+     * @return  string
+     */
+    static public function getQueryKey()
+    {
+        return $GLOBALS['_UA_query_key'];
+    }
+
+    // }}}
+    // {{{ setPCQuery()
+
+    /**
+     * @param   string  $pc  default is 'pc'
+     * @return  void
+     */
+    static public function setPCQuery($pc)
+    {
+        $GLOBALS['_UA_PC_query'] = $pc;
+    }
+
+    // }}}
+    // {{{ getPCQuery()
+
+    /**
+     * @return  string
+     */
+    static public function getPCQuery()
+    {
+        return $GLOBALS['_UA_PC_query'];
+    }
+
+    // }}}
+    // {{{ setMobileQuery()
+
+    /**
+     * @param   string  $k  default is 'k'
+     * @return  void
+     */
+    static public function setMobileQuery($k)
+    {
+        $GLOBALS['_UA_mobile_query'] = $k;
+    }
+
+    // }}}
+    // {{{ getMobileQuery()
+
+    /**
+     * @return  string
+     */
+    static public function getMobileQuery()
+    {
+        return $GLOBALS['_UA_mobile_query'];
+    }
+
+    // }}}
+    // {{{ setIPhoneGroupQuery()
+
+    /**
+     * @param   string  $i  default is 'i'
+     * @return  void
+     */
+    static public function setIPhoneGroupQuery($i)
+    {
+        $GLOBALS['_UA_iphonegroup_query'] = $i;
+    }
+
+    // }}}
+    // {{{ getIPhoneGroupQuery()
+
+    /**
+     * @return  string
+     */
+    static public function getIPhoneGroupQuery()
+    {
+        return $GLOBALS['_UA_iphonegroup_query'];
+    }
+
+    // }}}
+    // {{{ getNet_UserAgent_Mobile()
+
+    /**
+     * Net_UserAgent_Mobile::singleton() ‚ÌŒ‹‰Ê‚ðŽæ“¾‚·‚éB
+     * REAR Error ‚Í false ‚É•ÏŠ·‚³‚ê‚éB
+     *
+     * @param   string  $ua
+     * @return  Net_UserAgent_Mobile|false
+     */
+    static public function getNet_UserAgent_Mobile($ua = null)
+    {
+        static $cache_ = null;
+
+        if (is_null($ua) and !is_null($cache_)) {
+            return $cache_;
+        }
+
+        if (!class_exists('Net_UserAgent_Mobile', false)) {
+            require 'Net/UserAgent/Mobile.php';
+        }
+
+        if (!is_null($ua)) {
+            $nuam = Net_UserAgent_Mobile::factory($ua);
+        } else {
+            $nuam = Net_UserAgent_Mobile::singleton();
+        }
+
+        if (PEAR::isError($nuam)) {
+            trigger_error($nuam->toString, E_USER_WARNING);
+            $return = false;
+
+        } elseif (!$nuam) {
+            $return = false; // null
+
+        } else {
+            $return = $nuam;
+        }
+
+        if (is_null($ua)) {
+            $cache_ = $return;
+        }
+
+        return $return;
+    }
+
+    // }}}
+    // {{{ isNetFront()
+
+    /**
+     * UA‚ªNetFrontiŒg‘сAPDAAPSPj‚È‚çtrue‚ð•Ô‚·
+     *
+     * @param   string   $ua  UA‚ðŽw’è‚·‚é‚È‚ç
+     * @return  boolean
+     */
+    static public function isNetFront($ua = null)
+    {
+        if (is_null($ua) and isset($_SERVER['HTTP_USER_AGENT'])) {
+            $ua = $_SERVER['HTTP_USER_AGENT'];
+        }
+
+        if (preg_match('/(NetFront|AVEFront\/|AVE-Front\/)/', $ua)) {
+            return true;
+        }
+        if (self::isPSP()) {
+            return true;
+        }
+        return false;
+    }
+
+    // }}}
+    // {{{ isPSP()
+
+    /**
+     * UA‚ªPSP‚È‚çtrue‚ð•Ô‚·BNetFrontŒn‚炵‚¢B
+     *
+     * @param   string   $ua  UA‚ðŽw’è‚·‚é‚È‚ç
+     * @return  boolean
+     */
+    static public function isPSP($ua = null)
+    {
+        if (is_null($ua) and isset($_SERVER['HTTP_USER_AGENT'])) {
+            $ua = $_SERVER['HTTP_USER_AGENT'];
+        }
+
+        // Mozilla/4.0 (PSP (PlayStation Portable); 2.00)
+        if (preg_match('/PlayStation Portable/', $ua)) {
+            return true;
+        }
+        return false;
+    }
+
+    // }}}
+    // {{{ isNintendoDS()
+
+    /**
+     * UA‚ªNintendo DS‚È‚çtrue‚ð•Ô‚·B
+     *
+     * @param   string   $ua  UA‚ðŽw’è‚·‚é‚È‚ç
+     * @return  boolean
+     */
+    static public function isNintendoDS($ua = null)
+    {
+        if (is_null($ua) and isset($_SERVER['HTTP_USER_AGENT'])) {
+            $ua = $_SERVER['HTTP_USER_AGENT'];
+        }
+
+        // Mozilla/4.0 (compatible; MSIE 6.0; Nitro) Opera 8.5 [ja]
+        if (preg_match('/ Nitro/', $ua)) {
+            return true;
+        }
+        return false;
+    }
+
+    // }}}
+    // {{{ isAndroidWebKit()
+
+    /**
+     * UA‚ªAndroidi‚ÅWebkitj‚È‚çtrue‚ð•Ô‚·B
+     *
+     * @param   string   $ua  UA‚ðŽw’è‚·‚é‚È‚ç
+     * @return  boolean
+     */
+    static public function isAndroidWebKit($ua = null)
+    {
+        if (is_null($ua) and isset($_SERVER['HTTP_USER_AGENT'])) {
+            $ua = $_SERVER['HTTP_USER_AGENT'];
+        }
+        if (!$ua) {
+            return false;
+        }
+        // ƒVƒ~ƒ…ƒŒ[ƒ^
+        // Mozilla/5.0 (Linux; U; Android 1.0; en-us; generic) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2
+        // T-mobile G1
+        // Mozilla/5.0 (Linux; U; Android 1.0; en-us; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2
+        // generic‚Ædream‚ªˆÙ‚È‚é
+        if (false !== strpos('Android', $ua) && false !== strpos('WebKit', $ua)) {
+            return true;
+        }
+        return false;
+    }
+
+    // }}}
+    // {{{ isSafariGroup()
+
+    /**
+     * UA‚ªSafariŒn‚È‚ç true ‚ð•Ô‚·
+     *
+     * @param   string   $ua  UA‚ðŽw’è‚·‚é‚È‚ç
+     * @return  boolean
+     */
+    static public function isSafariGroup($ua = null)
+    {
+        if (is_null($ua) and isset($_SERVER['HTTP_USER_AGENT'])) {
+            $ua = $_SERVER['HTTP_USER_AGENT'];
+        }
+
+        return (boolean)preg_match('/Safari|AppleWebKit|Konqueror/', $ua);
+    }
+
+    // }}}
+}
+
+// }}}
+
+/*
+ * 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/global.funcs.php
===================================================================
--- p2ex/trunk/lib/global.funcs.php	2010-01-15 21:36:43 UTC (rev 785)
+++ p2ex/trunk/lib/global.funcs.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -3,6 +3,86 @@
  * rep2expack - ƒ†[ƒeƒBƒŠƒeƒBŠÖ”ŒQ
  */
 
+// {{{ rep2 1.8.x lib/global.funcs.php ‚æ‚è
+
+/**
+ * htmlspecialchars() ‚Ì•Ê–¼‚Ý‚½‚¢‚È‚à‚Ì
+ *
+ * @param   string  $alt  ’l‚ª‹ó‚Ì‚Æ‚«‚Ì‘ã‘Ö•¶Žš—ñ
+ * @return  string|null
+ */
+function hs($str, $alt = '', $quoteStyle = ENT_QUOTES)
+{
+    return (isset($str) && strlen($str) > 0) ? htmlspecialchars($str, $quoteStyle) : $alt;
+}
+
+/**
+ * notice ‚Ì—}§‚à‚µ‚Ä‚­‚ê‚é hs()
+ * ŽQÆ‚Å’l‚ðŽó‚¯Žæ‚é‚̂̓Cƒ}ƒCƒ`‚¾‚ªA‚»‚¤‚µ‚È‚¯‚ê‚Înotice‚Ì—}§‚ª‚Å‚«‚È‚¢
+ *
+ * @param   &string  $str  •¶Žš—ñ•Ï”‚ÌŽQÆ
+ * @return  string|null
+ */
+function hsi(&$str, $alt = '', $quoteStyle = ENT_QUOTES)
+{
+    return (isset($str) && strlen($str) > 0) ? htmlspecialchars($str, $quoteStyle) : $alt;
+}
+
+/**
+ * echo hs()
+ *
+ * @return  void
+ */
+function eh($str, $alt = '', $quoteStyle = ENT_QUOTES)
+{
+    echo hs($str, $alt, $quoteStyle);
+}
+
+/**
+ * echo hs() inotice‚ð—}§‚·‚éj
+ *
+ * @param   &string  $str  •¶Žš—ñ•Ï”‚ÌŽQÆ
+ * @return  void
+ */
+function ehi(&$str, $alt = '', $quoteStyle = ENT_QUOTES)
+{
+    echo hs($str, $alt, $quoteStyle);
+}
+
+/**
+ * ‘¶Ý‚µ‚È‚¢•Ï”‚Ì notice ‚ðo‚·‚±‚Æ‚È‚­A•Ï”‚Ì’l‚ðŽæ“¾‚·‚é
+ *
+ * ‚±‚̊֐”‚Å”z—ñ‚Ì’†g‚ðŽæ“¾‚µ‚悤‚Æ‚·‚é‚ƁA”z—ñ‚»‚Ì‚à‚Ì‚ðì¬‚µ‚Ä‚µ‚Ü‚¤‚±‚Æ‚ª‚ ‚é‚Ì‚É’ˆÓB
+ * ‚‚܂è $hoge ‚ª‘¶Ý‚µ‚È‚¢Žž‚ɁAgeti($hoge['huga']) ‚Æ‚·‚é‚ƁA $hoge ‚Í array('huga' => null) ‚Æ‚È‚Á‚Ä‚µ‚Ü‚¤B
+ *
+ * @return  mixed
+ */
+function geti(&$var, $alt = null)
+{
+    return isset($var) ? $var : $alt;
+}
+
+/**
+ * ‰üs‚ð•t‚¯‚Ä•¶Žš—ñ‚ðo—Í‚·‚éBcli(\n)‚Æweb(<br>)‚ŏo—Í‚ª•Ï‰»‚·‚éB
+ * ˆø”‚Ì•¶Žš—ñ‚Í•¡”Žæ‚邱‚Æ‚ª‰Â”\Bˆø”‚ª‚È‚¯‚ê‚Ήüs‚¾‚¯‚ðo—Í‚·‚éB
+ *
+ * @return  void
+ */
+function echoln()
+{
+    $n = (php_sapi_name() == 'cli') ? "\n" : '<br>';
+    
+    if ($args = func_get_args()) {
+        foreach ($args as $v) {
+            echo $v . $n;
+        }
+    } else {
+        echo $n;
+    }
+}
+
+// }}}
+
 // {{{ CONSTANTS
 
 /**

Modified: p2ex/trunk/lib/login_first.inc.php
===================================================================
--- p2ex/trunk/lib/login_first.inc.php	2010-01-15 21:36:43 UTC (rev 785)
+++ p2ex/trunk/lib/login_first.inc.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -149,8 +149,19 @@
                 $regist_cookie_checked = '';
             }
         }
-        $auth_sub_input_ht = '<input type="hidden" name="ctl_regist_cookie" value="1">'."\n".
-            '<input type="checkbox" id="regist_cookie" name="regist_cookie" value="1"'.$regist_cookie_checked.'><label for="regist_cookie">cookie‚É•Û‘¶‚·‚éi„§j</label><br>';
+        $ignore_cip_checked = '';
+        if (isset($_POST['submit_newuser']) || isset($_POST['submit_userlogin'])) {
+            if (geti($_POST['ignore_cip']) == '1') {
+                $ignore_cip_checked = ' checked';
+            }
+        } else {
+            if (geti($_COOKIE['ignore_cip']) == '1') {
+                $ignore_cip_checked = ' checked';
+            }
+        }
+        $auth_sub_input_ht = '<input type="hidden" name="ctl_regist_cookie" value="1">'
+          . sprintf('<input type="checkbox" id="regist_cookie" name="regist_cookie" value="1"%s><label for="regist_cookie">ƒƒOƒCƒ“î•ñ‚ðCookie‚É•Û‘¶‚·‚éi„§j</label><br>', $regist_cookie_checked)
+          . sprintf('<input type="checkbox" id="ignore_cip" name="ignore_cip" value="1"%s><label for="ignore_cip">Cookie”FØŽž‚ÉIP‚Ì“¯ˆê«‚ðƒ`ƒFƒbƒN‚µ‚È‚¢</label><br>', $ignore_cip_checked);
     }
 
     // }}}

Modified: p2ex/trunk/lib/setup.funcs.php
===================================================================
--- p2ex/trunk/lib/setup.funcs.php	2010-01-15 21:36:43 UTC (rev 785)
+++ p2ex/trunk/lib/setup.funcs.php	2010-01-15 22:33:34 UTC (rev 786)
@@ -173,6 +173,7 @@
             StrSjis |
             SubjectTxt |
             Thread(?:[A-Z][A-Za-z]*)? |
+            UA |
             Wap[A-Z][A-Za-z]*
         )$/x', $name))
     {



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