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£pbNÌo[W + 'p2expack' => '100525.1530', // g£pbNÌ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.netAJEg +// 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^[AhX $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(pX[hÅÍÈ¢)', P2_EDIT_CONF_USER_LONGTEXT), array('be_2ch_mail', 'be.2ch.netÌo^[AhX', P2_EDIT_CONF_USER_LONGTEXT), - array('p2_2ch_mail', '<a href="http://p2.2ch.net/" target="_blank">p2.2ch.net</a>Ìo^[AhX', P2_EDIT_CONF_USER_LONGTEXT), - array('p2_2ch_pass', 'p2.2ch.netÌOCpX[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^[AhX', P2_EDIT_CONF_USER_LONGTEXT), + array('p2_2ch_pass', 'ö®p2ÌOCpX[h', P2_EDIT_CONF_USER_LONGTEXT | P2_EDIT_CONF_USER_PASSWORD), array('p2_2ch_ignore_cip', ' p2.2ch.net CookieFØÉIPAhX̯ê«ð`FbN'), ); 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ÆeGg|Cg + * eGg|Cg̼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/^| OCID ([AhX) * * @var string @@ -116,14 +122,24 @@ /** * RXgN^ * + * @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ÀsB - $uri = self::P2_ROOT_URI . self::SCRIPT_NAME_POST; + $uri = $this->_rootUri . self::SCRIPT_NAME_POST; $response = $this->httpPost($uri, $postData, true); // CookiemFÌêÍÄPOSTB 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- Xbhð\¦·é NX */ +$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> '; } //=================================================