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

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2010年 5月 25日 (火) 15:42:11 JST


Revision: 863
          http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=863
Author:   rsk
Date:     2010-05-25 15:42:11 +0900 (Tue, 25 May 2010)

Log Message:
-----------
expack:
- rev.100525.1530.
- 公式p2の新サーバーに対応。
-- サーバーの既定値は w1.p2.2ch.net なので、p2 ID が766000以降の人は
   設定管理 > ユーザ設定編集 > rep2基本設定 > be/p2 > p2_2ch_host を
   w2.p2.2ch.net にしてください。

Modified Paths:
--------------
    p2ex/trunk/conf/conf.inc.php
    p2ex/trunk/conf/conf_user_def.inc.php
    p2ex/trunk/edit_conf_user.php
    p2ex/trunk/lib/P2Client.php
    p2ex/trunk/lib/P2Util.php
    p2ex/trunk/lib/ShowThread.php
    p2ex/trunk/lib/UA.php
    p2ex/trunk/read_copy_k.php


-------------- next part --------------
Modified: p2ex/trunk/conf/conf.inc.php
===================================================================
--- p2ex/trunk/conf/conf.inc.php	2010-04-26 06:22:35 UTC (rev 862)
+++ p2ex/trunk/conf/conf.inc.php	2010-05-25 06:42:11 UTC (rev 863)
@@ -7,7 +7,7 @@
 // ƒo[ƒWƒ‡ƒ“î•ñ
 $_conf = array(
     'p2version' => '1.7.29+1.8.x',  // rep2‚̃o[ƒWƒ‡ƒ“
-    'p2expack'  => '100227.0215',   // Šg’£ƒpƒbƒN‚̃o[ƒWƒ‡ƒ“
+    'p2expack'  => '100525.1530',   // Šg’£ƒpƒbƒN‚̃o[ƒWƒ‡ƒ“
     'p2name'    => 'expack',        // rep2‚Ì–¼‘O
 );
 

Modified: p2ex/trunk/conf/conf_user_def.inc.php
===================================================================
--- p2ex/trunk/conf/conf_user_def.inc.php	2010-04-26 06:22:35 UTC (rev 862)
+++ p2ex/trunk/conf/conf_user_def.inc.php	2010-05-25 06:42:11 UTC (rev 863)
@@ -16,6 +16,10 @@
 // }}}
 // {{{ p2.2ch.netƒAƒJƒEƒ“ƒg
 
+// p2.2ch.net‚̃T[ƒo[
+$conf_user_def['p2_2ch_host'] = "w1.p2.2ch.net"; // ("w1.p2.2ch.net")
+$conf_user_rules['p2_2ch_host'] = array('/^(?:w\\d+\\.)?p2\\.2ch\\.net$/');
+
 // p2.2ch.net‚Ì“o˜^ƒ[ƒ‹ƒAƒhƒŒƒX
 $conf_user_def['p2_2ch_mail'] = ""; // ("")
 

Modified: p2ex/trunk/edit_conf_user.php
===================================================================
--- p2ex/trunk/edit_conf_user.php	2010-04-26 06:22:35 UTC (rev 862)
+++ p2ex/trunk/edit_conf_user.php	2010-05-25 06:42:11 UTC (rev 863)
@@ -229,8 +229,9 @@
     $conflist = array(
         array('be_2ch_code', '<a href="http://be.2ch.net/" target="_blank">be.2ch.net</a>‚Ì”FØƒR[ƒh(ƒpƒXƒ[ƒh‚Å‚Í‚È‚¢)', P2_EDIT_CONF_USER_LONGTEXT),
         array('be_2ch_mail', 'be.2ch.net‚Ì“o˜^ƒ[ƒ‹ƒAƒhƒŒƒX', P2_EDIT_CONF_USER_LONGTEXT),
-        array('p2_2ch_mail', '<a href="http://p2.2ch.net/" target="_blank">p2.2ch.net</a>‚Ì“o˜^ƒ[ƒ‹ƒAƒhƒŒƒX', P2_EDIT_CONF_USER_LONGTEXT),
-        array('p2_2ch_pass', 'p2.2ch.net‚̃ƒOƒCƒ“ƒpƒXƒ[ƒh', P2_EDIT_CONF_USER_LONGTEXT | P2_EDIT_CONF_USER_PASSWORD),
+        array('p2_2ch_host', 'ŒöŽ®p2 (<a href="http://p2.2ch.net/" target="_blank">p2.2ch.net</a>) ‚ÅŠ„‚è“–‚Ä‚ç‚ê‚Ä‚¢‚éƒT[ƒo[', P2_EDIT_CONF_USER_LONGTEXT),
+        array('p2_2ch_mail', 'ŒöŽ®p2‚Ì“o˜^ƒ[ƒ‹ƒAƒhƒŒƒX', P2_EDIT_CONF_USER_LONGTEXT),
+        array('p2_2ch_pass', 'ŒöŽ®p2‚̃ƒOƒCƒ“ƒpƒXƒ[ƒh', P2_EDIT_CONF_USER_LONGTEXT | P2_EDIT_CONF_USER_PASSWORD),
         array('p2_2ch_ignore_cip', ' p2.2ch.net Cookie”FØŽž‚ÉIPƒAƒhƒŒƒX‚Ì“¯ˆê«‚ðƒ`ƒFƒbƒN'),
     );
     printEditConfGroupHtml($groupname, $conflist, $flags);
@@ -776,13 +777,39 @@
 {
     global $conf_user_rules, $conf_user_def;
 
-    if (is_array($conf_user_rules)) {
-        foreach ($conf_user_rules as $k => $v) {
-            if (isset($_POST['conf_edit'][$k])) {
-                $def = isset($conf_user_def[$k]) ? $conf_user_def[$k] : null;
-                foreach ($v as $func) {
-                    $_POST['conf_edit'][$k] = call_user_func($func, $_POST['conf_edit'][$k], $def);
+    if (!array_key_exists('conf_edit', $_POST) || !is_array($_POST['conf_edit'])) {
+        return;
+    }
+
+    foreach ($conf_user_rules as $key => $rules ) {
+        if (array_key_exists($key, $_POST['conf_edit'])) {
+            $default = array_key_exists($key, $conf_user_def) ? $conf_user_def[$key] : null;
+            $value = $_POST['conf_edit'][$key];
+
+            if ($value !== $default) {
+                foreach ($rules as $rule) {
+                    if (is_string($rule)) {
+                        if (strncmp($rule, '/', 1) === 0) {
+                            if (!preg_match($rule, $value)) {
+                                $value = $default;
+                            }
+                        } elseif (strncmp($rule, '!/', 2) === 0) {
+                            if (preg_match(substr($rule, 1), $value)) {
+                                $value = $default;
+                            }
+                        } else {
+                            $value = call_user_func($rule, $value, $default);
+                        }
+                    } else {
+                        $value = call_user_func($rule, $value, $default);
+                    }
+
+                    if ($value === $default) {
+                        break;
+                    }
                 }
+
+                $_POST['conf_edit'][$key] = $value;
             }
         }
     }

Modified: p2ex/trunk/lib/P2Client.php
===================================================================
--- p2ex/trunk/lib/P2Client.php	2010-04-26 06:22:35 UTC (rev 862)
+++ p2ex/trunk/lib/P2Client.php	2010-05-25 06:42:11 UTC (rev 863)
@@ -16,9 +16,8 @@
     const COOKIE_STORE_NAME = 'p2_2ch_net_cookies.sqlite3';
 
     /**
-     * ŒöŽ®p2‚ÌURI‚ÆŠeƒGƒ“ƒgƒŠƒ|ƒCƒ“ƒg
+     * ŠeƒGƒ“ƒgƒŠƒ|ƒCƒ“ƒg‚Ì–¼‘O
      */
-    const P2_ROOT_URI = 'http://p2.2ch.net/p2/';
     const SCRIPT_NAME_READ = 'read.php';
     const SCRIPT_NAME_POST = 'post.php';
     const SCRIPT_NAME_INFO = 'info.php';
@@ -69,6 +68,13 @@
     // {{{ properties
 
     /**
+     * ŒöŽ®p2‚̃‹[ƒgURI
+     *
+     * @var string
+     */
+    private $_rootUri;
+
+    /**
      * p2.2ch.net/ƒ‚ƒŠƒ^ƒ| ƒƒOƒCƒ“ID (ƒ[ƒ‹ƒAƒhƒŒƒX)
      *
      * @var string
@@ -116,14 +122,24 @@
     /**
      * ƒRƒ“ƒXƒgƒ‰ƒNƒ^
      *
+     * @param string $rootUri
      * @param string $loginId
      * @param string $loginPass
      * @param string $cookieSaveDir
      * @param bool $ignoreCookieAddr
      * @throws P2Exception
      */
-    public function __construct($loginId, $loginPass, $cookieSaveDir, $ignoreCookieAddr = false)
+    public function __construct($rootUri,
+                                $loginId,
+                                $loginPass,
+                                $cookieSaveDir,
+                                $ignoreCookieAddr = false)
     {
+        if (!preg_match('!^https?://.+/$!', $rootUri)) {
+            throw new Exception('Invalid root URI was given.');
+        }
+        $this->_rootUri = $rootUri;
+
         try {
             $cookieSavePath = $cookieSaveDir . DIRECTORY_SEPARATOR . self::COOKIE_STORE_NAME;
             $cookieStore = P2KeyValueStore::getStore($cookieSavePath,
@@ -185,7 +201,7 @@
                           &$response = null)
     {
         if ($uri === null) {
-            $uri = self::P2_ROOT_URI;
+            $uri = $this->_rootUri;
         }
 
         if ($dom === null) {
@@ -237,7 +253,7 @@
     public function readThread($host, $bbs, $key, $ls = '1', &$response = null)
     {
         $getData = $this->setupGetData($host, $bbs, $key, $ls);
-        $uri = self::P2_ROOT_URI . self::SCRIPT_NAME_READ;
+        $uri = $this->_rootUri . self::SCRIPT_NAME_READ;
         $response = $this->httpGet($uri, $getData, true);
         $dom = new P2DOM($response['body']);
 
@@ -291,14 +307,14 @@
         $result = $dom->query($expression);
         if (($result instanceof DOMNodeList) && $result->length > 0) {
             $anchor = $result->item(0);
-            $uri = self::P2_ROOT_URI
+            $uri = $this->_rootUri
                  . strstr($anchor->getAttribute('href'), self::SCRIPT_NAME_READ);
             $response = $this->httpGet($uri);
         }
 
         // dat‚ðŽæ“¾‚·‚éB
         $getData = $this->setupGetData($host, $bbs, $key);
-        $uri = self::P2_ROOT_URI . self::SCRIPT_NAME_DAT;
+        $uri = $this->_rootUri . self::SCRIPT_NAME_DAT;
         $response = $this->httpGet($uri, $getData, true);
 
         if (strpos($response['body'], self::NEEDLE_DAT_NO_DAT) !== false) {
@@ -354,7 +370,7 @@
         }
 
         // POSTŽÀsB
-        $uri = self::P2_ROOT_URI . self::SCRIPT_NAME_POST;
+        $uri = $this->_rootUri . self::SCRIPT_NAME_POST;
         $response = $this->httpPost($uri, $postData, true);
 
         // CookieŠm”F‚̏ꍇ‚͍ÄPOSTB

Modified: p2ex/trunk/lib/P2Util.php
===================================================================
--- p2ex/trunk/lib/P2Util.php	2010-04-26 06:22:35 UTC (rev 862)
+++ p2ex/trunk/lib/P2Util.php	2010-05-25 06:42:11 UTC (rev 863)
@@ -1996,8 +1996,11 @@
         }
 
         try {
-            return new P2Client($_conf['p2_2ch_mail'], $_conf['p2_2ch_pass'],
-                                $_conf['db_dir'], (bool)$_conf['p2_2ch_ignore_cip']);
+            return new P2Client("http://{$_conf['p2_2ch_host']}/p2/",
+                                $_conf['p2_2ch_mail'],
+                                $_conf['p2_2ch_pass'],
+                                $_conf['db_dir'],
+                                (bool)$_conf['p2_2ch_ignore_cip']);
         } catch (P2Exception $e) {
             p2die($e->getMessage());
         }

Modified: p2ex/trunk/lib/ShowThread.php
===================================================================
--- p2ex/trunk/lib/ShowThread.php	2010-04-26 06:22:35 UTC (rev 862)
+++ p2ex/trunk/lib/ShowThread.php	2010-05-25 06:42:11 UTC (rev 863)
@@ -3,6 +3,8 @@
  * rep2- ƒXƒŒƒbƒh‚ð•\Ž¦‚·‚é ƒNƒ‰ƒX
  */
 
+$GLOBALS['last_hit_resnum'] = null;
+
 // {{{ ShowThread
 
 abstract class ShowThread

Modified: p2ex/trunk/lib/UA.php
===================================================================
--- p2ex/trunk/lib/UA.php	2010-04-26 06:22:35 UTC (rev 862)
+++ p2ex/trunk/lib/UA.php	2010-05-25 06:42:11 UTC (rev 863)
@@ -183,7 +183,7 @@
 
         // 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)) {
+        if (preg_match('/iP(?:hone|[ao]d)/', $ua) || self::isAndroidWebKit($ua)) {
             $isiPhoneGroup = true;
         }
 
@@ -479,7 +479,7 @@
         // 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)) {
+        if (false !== strpos($ua, 'Android') && false !== strpos($ua, 'WebKit')) {
             return true;
         }
         return false;

Modified: p2ex/trunk/read_copy_k.php
===================================================================
--- p2ex/trunk/read_copy_k.php	2010-04-26 06:22:35 UTC (rev 862)
+++ p2ex/trunk/read_copy_k.php	2010-05-25 06:42:11 UTC (rev 863)
@@ -28,7 +28,7 @@
 $quote = !empty($_GET['inyou']);
 
 if (isset($_SERVER['HTTP_REFERER'])) {
-    $back_link = '<a href="' . htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES) . '" title="–ß‚é">' . –ß‚é . '</a> ';
+    $back_link = '<a href="' . htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES) . '" title="–ß‚é">–ß‚é</a> ';
 }
 
 //=================================================



P2-php-svn メーリングリストの案内
Zurück zum Archiv-Index