svnno****@sourc*****
svnno****@sourc*****
2009年 12月 14日 (月) 19:52:23 JST
Revision: 737 http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=737 Author: akid Date: 2009-12-14 19:52:23 +0900 (Mon, 14 Dec 2009) Log Message: ----------- ãã¼ã¿æä½é¢é£ã®ã¡ã½ãããæ´æ°ï¼P2Util::idxDirOfHostBbs()ã®é©ç¨çï¼ Modified Paths: -------------- p2/trunk/edit_indexmenuk.php p2/trunk/index.php p2/trunk/iphone/read_header_k.inc.php p2/trunk/lib/Login.php p2/trunk/lib/NgAbornCtl.php p2/trunk/lib/P2Util.php p2/trunk/lib/Session.php p2/trunk/lib/SettingTxt.php p2/trunk/lib/SubjectTxt.php p2/trunk/lib/Thread.php p2/trunk/lib/ThreadList.php p2/trunk/lib/ThreadRead.php p2/trunk/lib/dele.funcs.php p2/trunk/lib/downloadDatMachiBbs.func.php p2/trunk/lib/downloadDatShitaraba.func.php p2/trunk/lib/settaborn.func.php p2/trunk/post.php p2/trunk/post_form_i.php p2/trunk/read.php p2/trunk/subject.php p2/trunk/subject_i.php p2/trunk/subject_new.php -------------- next part -------------- Modified: p2/trunk/edit_indexmenuk.php =================================================================== --- p2/trunk/edit_indexmenuk.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/edit_indexmenuk.php 2009-12-14 10:52:23 UTC (rev 737) @@ -54,7 +54,7 @@ } echo <<<EOP - <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> + <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> </head> <body{$body_at}>\n EOP; @@ -75,13 +75,13 @@ <?php foreach ($menuKLinkHtmls as $code => $html) { echo <<<EOP - <tr> - <td>$html</td> - <td>[ <a class="te" href="{$_SERVER['SCRIPT_NAME']}?code={$code}&set=top{$_conf['k_at_a']}" title="êÔãÉÚ®">£</a></td> - <td><a class="te" href="{$_SERVER['SCRIPT_NAME']}?code={$code}&set=up{$_conf['k_at_a']}" title="êÂãÉÚ®">ª</a></td> - <td><a class="te" href="{$_SERVER['SCRIPT_NAME']}?code={$code}&set=down{$_conf['k_at_a']}" title="êºÉÚ®">«</a></td> - <td><a class="te" href="{$_SERVER['SCRIPT_NAME']}?code={$code}&set=bottom{$_conf['k_at_a']}" title="êÔºÉÚ®">¥</a> ]</td> - </tr> + <tr> + <td>$html</td> + <td>[ <a class="te" href="{$_SERVER['SCRIPT_NAME']}?code={$code}&set=top{$_conf['k_at_a']}" title="êÔãÉÚ®">£</a></td> + <td><a class="te" href="{$_SERVER['SCRIPT_NAME']}?code={$code}&set=up{$_conf['k_at_a']}" title="êÂãÉÚ®">ª</a></td> + <td><a class="te" href="{$_SERVER['SCRIPT_NAME']}?code={$code}&set=down{$_conf['k_at_a']}" title="êºÉÚ®">«</a></td> + <td><a class="te" href="{$_SERVER['SCRIPT_NAME']}?code={$code}&set=bottom{$_conf['k_at_a']}" title="êÔºÉÚ®">¥</a> ]</td> + </tr> EOP; } ?></table> @@ -215,3 +215,14 @@ $newArray = array_unique($newArray); return $newArray; } + +/* + * 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: p2/trunk/index.php =================================================================== --- p2/trunk/index.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/index.php 2009-12-14 10:52:23 UTC (rev 737) @@ -6,7 +6,7 @@ $_login->authorize(); // [UFØ -// ANZXÛpÌ.htaccessðf[^fBNgÉ쬷é +// ANZXÛpÌ.htaccessðf[^fBNgÉ©®ì¬·é _makeDenyHtaccess($_conf['pref_dir']); _makeDenyHtaccess($_conf['dat_dir']); _makeDenyHtaccess($_conf['idx_dir']); Modified: p2/trunk/iphone/read_header_k.inc.php =================================================================== --- p2/trunk/iphone/read_header_k.inc.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/iphone/read_header_k.inc.php 2009-12-14 10:52:23 UTC (rev 737) @@ -50,14 +50,14 @@ $rnum_range = $_conf['k_rnum_range']; $latest_show_res_num = $_conf['k_rnum_range']; // ÅVXX -$read_navi_previous = ""; -$read_navi_previous_btm = ""; -$read_navi_next = ""; -$read_navi_next_btm = ""; -$read_footer_navi_new_ht = ""; -$read_footer_navi_new_btm_ht = ""; -$read_navi_latest = ""; -$read_navi_latest_btm = ""; +$read_navi_previous = ''; +$read_navi_previous_btm = ''; +$read_navi_next = ''; +$read_navi_next_btm = ''; +$read_footer_navi_new_ht = ''; +$read_footer_navi_new_btm_ht = ''; +$read_navi_latest = ''; +$read_navi_latest_btm = ''; $read_navi_filter = ''; $read_navi_filter_btm = ''; @@ -230,12 +230,18 @@ // {{{ õ -$read_navi_filter = <<<EOP -<a href="read_filter_i.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$_conf['k_at_a']}">{$find_st}</a> -EOP; -$read_navi_filter_btm = <<<EOP -<a href="read_filter_i.php?host={$aThread->host}{$bbs_q}{$key_q}{$ttitle_en_q}{$_conf['k_at_a']}">{$find_st}</a> -EOP; +$read_navi_filter = $read_navi_filter_btm = P2View::tagA( + P2Util::buildQueryUri('read_filter_i.php', + array( + 'host' => $aThread->host, + 'bbs' => $aThread->bbs, + 'key' => $aThread->key, + 'ttitle_en' => $ttitle_en, + UA::getQueryKey() => UA::getQueryValue() + ) + ), + hs($find_st) +); // }}} @@ -296,7 +302,7 @@ <script type="text/javascript" src="iphone/js/respopup.iPhone.js?v=20090429"></script> <script type="text/javascript" src="iphone/js/setfavjs.js?v=20090428"></script> <script type="text/javascript" src="js/post_form.js?v=20090724"></script> - <script type="text/javascript"> + <script type="text/javascript"> <!-- // iPhoneÌURLÒWªð\¦µÈ¢æ¤XN[·é window.onload = function() { @@ -350,7 +356,7 @@ } $fade = empty($_GET['fade']) ? 'false' : 'true'; -$existWord = (strlen($GLOBALS['word']) > 0) ? 'true' : 'false'; +$existWord = strlen($GLOBALS['word']) ? 'true' : 'false'; echo <<<EOP <script type="text/javascript"> @@ -439,15 +445,19 @@ ); if (isset($GLOBALS['word']) && strlen($GLOBALS['word'])) { - echo "õÊ: "; - echo "{$filter_fields[$res_filter['field']]}"; - echo ""{$word_hs}"ð"; - echo ($res_filter['match'] == 'on') ? 'ÜÞ' : 'ÜÜÈ¢'; + echo hs(sprintf( + 'õÊ: %s"%s"ð%s', + $filter_fields[$res_filter['field']], + $GLOBALS['word'], + ($res_filter['match'] == 'on') ? 'ÜÞ' : 'ÜÜÈ¢' + )); } echo P2View::getHrHtmlK(); +// ±Ìt@CàÅÌͱ±ÜÅ + //======================================================================================= // Öi±Ìt@CàÅÌÝpj //======================================================================================= @@ -474,7 +484,7 @@ if (!empty($_REQUEST[$k])) { $form .= sprintf( '<input type="hidden" name="%s" value="%s">', - htmlspecialchars($k), htmlspecialchars($_REQUEST[$k], ENT_QUOTES) + htmlspecialchars($k, ENT_QUOTES), htmlspecialchars($_REQUEST[$k], ENT_QUOTES) ); } else { return ''; @@ -598,9 +608,9 @@ ); return $toolbar_right_ht = <<<EOTOOLBAR - <li class="whiteButton">$info_atag</li> - <li class="whiteButton">$dele_atag</li> - <li class="whiteButton"><a href="{$motothre_url}">{$moto_thre_st}</a></li> + <li class="whiteButton">$info_atag</li> + <li class="whiteButton">$dele_atag</li> + <li class="whiteButton"><a href="{$motothre_url}">{$moto_thre_st}</a></li> EOTOOLBAR; } @@ -609,13 +619,8 @@ */ function _getGetDatErrorMsgHtml($aThread) { - $diedat_msg_ht = ''; - if ($aThread->getdat_error_msg_ht) { - $diedat_msg_ht = $aThread->getdat_error_msg_ht; - } else { - $diedat_msg_ht = "<p><b>p2 info - ÂT[o©çÅVÌXbhîñðæ¾Å«Ü¹ñŵ½B</b></p>"; - } - return $diedat_msg_ht; + $diedat_msg_ini_ht = '<p><b>p2 info - ÂT[o©çÅVÌXbhîñðæ¾Å«Ü¹ñŵ½B</b></p>'; + return strlen($aThread->getdat_error_msg_ht) ? $aThread->getdat_error_msg_ht : $diedat_msg_ini_ht; } Modified: p2/trunk/lib/Login.php =================================================================== --- p2/trunk/lib/Login.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/Login.php 2009-12-14 10:52:23 UTC (rev 737) @@ -762,12 +762,8 @@ */ function clearCookieAuth() { - $r = setcookie('cid', '', time() - 3600); - - setcookie('p2_user', '', time() - 3600); // p~vf 2005/6/13 - setcookie('p2_pass', '', time() - 3600); // p~vf 2005/6/13 - setcookie('p2_pass_x', '', time() - 3600); // p~vf 2005/6/13 - + $r = P2Util::unsetCookie('cid'); + $_COOKIE = array(); return $r; @@ -787,21 +783,16 @@ if (!is_null($ignore_cip)) { if ($ignore_cip) { - setcookie('ignore_cip', '1', $time); + P2Util::setCookie('ignore_cip', '1', $time); $_COOKIE['ignore_cip'] = '1'; } else { - setcookie('ignore_cip', '', time() - 3600); + P2Util::unsetCookie('ignore_cip'); unset($_COOKIE['ignore_cip']); } } if ($cid = $this->makeCid($user_u, $pass_x)) { - // httponlyÌÎÍPHP5.2.0©ç - if (version_compare(phpversion(), '5.2.0', '<')) { - return setcookie('cid', $cid, $time, $path = '', $domain = '', $secure = 0); - } else { - return setcookie('cid', $cid, $time, $path = '', $domain = '', $secure = 0, $this->isAcceptableCookieHttpOnly()); - } + return P2Util::setCookie('cid', $cid, $time); } return false; } Modified: p2/trunk/lib/NgAbornCtl.php =================================================================== --- p2/trunk/lib/NgAbornCtl.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/NgAbornCtl.php 2009-12-14 10:52:23 UTC (rev 737) @@ -281,17 +281,7 @@ function countNgAbornsHits($ngcode) { if (!isset($GLOBALS['ngaborns_hits'])) { - $GLOBALS['ngaborns_hits'] = array( - 'aborn_res' => 0, - 'aborn_name' => 0, - 'aborn_mail' => 0, - 'aborn_msg' => 0, - 'aborn_id' => 0, - 'ng_name' => 0, - 'ng_mail' => 0, - 'ng_msg' => 0, - 'ng_id' => 0 - ); + NgAbornCtl::initNgAbornsHits(); } if ($ngcode != 'ng_msg') { @@ -302,6 +292,25 @@ } /** + * @access private + * @return void + */ + function initNgAbornsHits() + { + $GLOBALS['ngaborns_hits'] = array( + 'aborn_res' => 0, + 'aborn_name' => 0, + 'aborn_mail' => 0, + 'aborn_msg' => 0, + 'aborn_id' => 0, + 'ng_name' => 0, + 'ng_mail' => 0, + 'ng_msg' => 0, + 'ng_id' => 0 + ); + } + + /** * Ú[ñ&NG[hÝèðÛ¶·é * * @static Modified: p2/trunk/lib/P2Util.php =================================================================== --- p2/trunk/lib/P2Util.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/P2Util.php 2009-12-14 10:52:23 UTC (rev 737) @@ -11,6 +11,149 @@ class P2Util { /** + * |[gÔðíÁ½zXg¼ðæ¾·é + * + * @return string|null + */ + function getMyHost() + { + if (!isset($_SERVER['HTTP_HOST'])) { + return null; + } + return preg_replace('/:\d+$/', '', $_SERVER['HTTP_HOST']); + } + + /** + * @access public + * @return string + */ + function getCookieDomain() + { + return ''; + } + + /** + * @access private + * @return string + */ + function encodeCookieName($key) + { + // zñwèpÉA[]¾¯»ÌÜÜcµÄAURLGR[hð©¯é + return $key_urlen = preg_replace_callback( + '/[^\\[\\]]+/', + create_function('$m', 'return rawurlencode($m[0]);'), + $key + ); + } + + /** + * setcookie() ÅÍAauÅKvÈmax ageªÝè³êÈ¢ÌÅA±¿çðp·é + * + * @access public + * @return boolean + */ + function setCookie($key, $value = '', $expires = null, $path = '', $domain = null, $secure = false, $httponly = true) + { + if (is_null($domain)) { + $domain = P2Util::getCookieDomain(); + } + is_null($expires) and $expires = time() + 60 * 60 * 24 * 365; + + + if (headers_sent()) { + return false; + } + + + // Mac IEÍA®ìsÇðN±·çµ¢ÁÛ¢ÌÅAhttponlyÌÎÛ©çO·Bi»à»àÎàµÄ¢È¢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: '. P2Util::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; + } + + /** + * NbL[ðÁ·éBÏ $_COOKIE àB + * + * @access public + * @param string $key key, k1[k2] + * @return boolean + */ + function unsetCookie($key, $path = '', $domain = null) + { + if (is_null($domain)) { + $domain = P2Util::getCookieDomain(); + } + + + // zñðsetcookie()·éÍAL[¶ñðPHPÌzñÌêÌæ¤ÉA'' â "" ÅNH[gµÈ¢B + // »êçÍL[¶ñƵÄF¯³êĵܤB['hoge']ÅÍÈA[hoge]Æwè·éB + // setcookie()ÅAêL[Í[]ÅÍÜÈ¢æ¤É·éBi³øÈÆÈéBj k1[k2] Æ¢¤\LÅwè·éB + // setcookie()ÅÍzñðÜÆßÄí·é±ÆÍÅ«È¢B + // k1 ÌwèÅ k1[k2] ÍÁ¦È¢ÌÅA±Ì\bhÅεĢéB + + // $keyªzñƵÄwè³êÄ¢½Èç + $ckey = null; // $_COOKIEpÌL[ + if (preg_match('/\]$/', $key)) { + // ÅÌL[ð[]ÅÍÞ + $ckey = preg_replace('/^([^\[]+)/', '[$1]', $key); + // []ÌL[ð''ÅÍÞ + $ckey = preg_replace('/\[([^\[\]]+)\]/', "['$1']", $ckey); + //var_dump($ckey); + } + + // ÎÛCookielªzñÅ êÎÄAðs¤ + $cArray = null; + if ($ckey) { + eval("isset(\$_COOKIE{$ckey}) && is_array(\$_COOKIE{$ckey}) and \$cArray = \$_COOKIE{$ckey};"); + } else { + isset($_COOKIE[$key]) && is_array($_COOKIE[$key]) and $cArray = $_COOKIE[$key]; + } + if (is_array($cArray)) { + foreach ($cArray as $k => $v) { + $keyr = "{$key}[{$k}]"; + if (!P2Util::unsetCookie($keyr, $path, $domain)) { + return false; + } + } + } + + if (is_array($cArray) or setcookie("$key", '', time() - 3600, $path, $domain)) { + if ($ckey) { + eval("unset(\$_COOKIE{$ckey});"); + } else { + unset($_COOKIE[$key]); + } + return true; + } + return false; + } + + /** * eÊÌPÊðoCg\¦©çKXÏ·µÄ\¦·é * * @param integer $size bytes @@ -136,7 +279,7 @@ */ function getThreadAbornFile($host, $bbs) { - return $taborn_file = P2Util::idxDirOfHost($host) . '/' . rawurlencode($bbs) . '/p2_threads_aborn.idx'; + return $taborn_file = P2Util::idxDirOfHostBbs($host, $bbs) . 'p2_threads_aborn.idx'; } /** @@ -215,7 +358,7 @@ */ function getSamba24CacheFile($host, $bbs) { - return P2Util::datDirOfHost($host) . '/' . rawurlencode($bbs) . '/samba24.txt'; + return P2Util::datDirOfHostBbs($host, $bbs) . 'samba24.txt'; } /** @@ -322,10 +465,9 @@ if (array_key_exists($key, $cache_)) { return $cache_[$ckey]; } + + $key_idx = P2Util::idxDirOfHostBbs($host, $bbs) . $key . '.idx'; - $idx_host_dir = P2Util::idxDirOfHost($host); - $key_idx = $idx_host_dir . '/' . $bbs . '/' . $key . '.idx'; - // key.idx©ç¼OÆ[ðÇÝ $FROM = null; $mail = null; @@ -590,8 +732,7 @@ return $ita_names[$id]; } - $idx_host_dir = P2Util::idxDirOfHost($host); - $p2_setting_txt = $idx_host_dir . "/" . $bbs . "/p2_setting.txt"; + $p2_setting_txt = P2Util::idxDirOfHostBbs($host, $bbs) . 'p2_setting.txt'; if (file_exists($p2_setting_txt)) { @@ -633,6 +774,12 @@ */ function datDirOfHost($host, $dir_sep = false) { + // O̽ßÉøÌ^ð`FbN + if (!is_bool($dir_sep)) { + $emsg = sprintf('Error: %s - invalid $dir_sep', __FUNCTION__); + trigger_error($emsg, E_USER_WARNING); + die($emsg); + } return P2Util::_p2DirOfHost($GLOBALS['_conf']['dat_dir'], $host, $dir_sep); } @@ -644,6 +791,12 @@ */ function idxDirOfHost($host, $dir_sep = false) { + // O̽ßÉøÌ^ð`FbN + if (!is_bool($dir_sep)) { + $emsg = sprintf('Error: %s - invalid $dir_sep', __FUNCTION__); + trigger_error($emsg, E_USER_WARNING); + die($emsg); + } return P2Util::_p2DirOfHost($GLOBALS['_conf']['idx_dir'], $host, $dir_sep); } @@ -734,17 +887,17 @@ * @param string $bbs * @param bool $dir_sep * @return string - * @see P2Util::_p2DirOfHost() */ function datDirOfHostBbs($host, $bbs, $dir_sep = true) { - $dir = P2Util::_p2DirOfHost($GLOBALS['_conf']['dat_dir'], $host) . $bbs; + $dir = P2Util::datDirOfHost($host, true) . $bbs; if ($dir_sep) { $dir .= DIRECTORY_SEPARATOR; } return $dir; } + // }}} // {{{ idxDirOfHostBbs() /** @@ -760,7 +913,7 @@ */ function idxDirOfHostBbs($host, $bbs, $dir_sep = true) { - $dir = P2Util::_p2DirOfHost($GLOBALS['_conf']['idx_dir'], $host) . $bbs; + $dir = P2Util::idxDirOfHost($host, true) . $bbs; if ($dir_sep) { $dir .= DIRECTORY_SEPARATOR; } @@ -817,7 +970,7 @@ } else { $filename = 'failed.data.php'; } - return $failed_post_file = P2Util::idxDirOfHost($host) . '/' . $bbs . '/' . $filename; + return $failed_post_file = P2Util::idxDirOfHostBbs($host, $bbs) . $filename; } /** Modified: p2/trunk/lib/Session.php =================================================================== --- p2/trunk/lib/Session.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/Session.php 2009-12-14 10:52:23 UTC (rev 737) @@ -351,8 +351,9 @@ // ZbVðØf·éÉÍZbVNbL[àí·éB $session_name = session_name(); if (isset($_COOKIE[$session_name])) { + //setcookie($session_name, '', time() - 42000); + P2Util::unsetCookie($session_name); unset($_COOKIE[$session_name]); - setcookie($session_name, '', time() - 42000); } // ÅIIÉAZbVðjó·é Modified: p2/trunk/lib/SettingTxt.php =================================================================== --- p2/trunk/lib/SettingTxt.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/SettingTxt.php 2009-12-14 10:52:23 UTC (rev 737) @@ -40,9 +40,9 @@ $this->host = $host; $this->bbs = $bbs; - $dat_bbs_dir = P2Util::datDirOfHost($this->host) . '/' . $this->bbs; - $this->setting_txt = $dat_bbs_dir . '/SETTING.TXT'; - $this->setting_srd = $dat_bbs_dir . '/p2_kb_setting.srd'; + $dat_bbs_dir_s = P2Util::datDirOfHostBbs($this->host, $this->bbs); + $this->setting_txt = $dat_bbs_dir_s . 'SETTING.TXT'; + $this->setting_srd = $dat_bbs_dir_s . 'p2_kb_setting.srd'; $this->url = 'http://' . $this->host . '/' . $this->bbs . '/SETTING.TXT'; Modified: p2/trunk/lib/SubjectTxt.php =================================================================== --- p2/trunk/lib/SubjectTxt.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/SubjectTxt.php 2009-12-14 10:52:23 UTC (rev 737) @@ -49,7 +49,7 @@ */ function setSubjectFile($host, $bbs) { - $this->subject_file = P2Util::datDirOfHost($host) . '/' . rawurlencode($bbs) . '/subject.txt'; + $this->subject_file = P2Util::datDirOfHostBbs($host, $bbs) . 'subject.txt'; } /** Modified: p2/trunk/lib/Thread.php =================================================================== --- p2/trunk/lib/Thread.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/Thread.php 2009-12-14 10:52:23 UTC (rev 737) @@ -202,15 +202,12 @@ die('Error: ' . __FUNCTION__); } - $this->host = $host; - $this->bbs = $bbs; - $this->key = $key; - - $dat_host_dir = P2Util::datDirOfHost($this->host); - $idx_host_dir = P2Util::idxDirOfHost($this->host); + $this->host = $host; + $this->bbs = $bbs; + $this->key = $key; - $this->keydat = $dat_host_dir . '/' . $this->bbs . '/' . $this->key . '.dat'; - $this->keyidx = $idx_host_dir . '/' . $this->bbs . '/' . $this->key . '.idx'; + $this->keydat = P2Util::datDirOfHostBbs($this->host, $this->bbs) . $this->key . '.dat'; + $this->keyidx = P2Util::getKeyIdxFilePath($this->host, $this->bbs, $this->key); $GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('setThreadPathInfo()'); } Modified: p2/trunk/lib/ThreadList.php =================================================================== --- p2/trunk/lib/ThreadList.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/ThreadList.php 2009-12-14 10:52:23 UTC (rev 737) @@ -164,11 +164,8 @@ } elseif ($this->spmode == 'soko') { - $dat_host_dir = P2Util::datDirOfHost($this->host); - $idx_host_dir = P2Util::idxDirOfHost($this->host); - - $dat_bbs_dir = $dat_host_dir . DIRECTORY_SEPARATOR . $this->bbs; - $idx_bbs_dir = $idx_host_dir . DIRECTORY_SEPARATOR . $this->bbs; + $dat_bbs_dir = P2Util::datDirOfHostBbs($this->host, $this->bbs, false); + $idx_bbs_dir = P2Util::idxDirOfHostBbs($this->host, $this->bbs, false); $dat_pattern = '/([0-9]+)\.dat$/'; $idx_pattern = '/([0-9]+)\.idx$/'; Modified: p2/trunk/lib/ThreadRead.php =================================================================== --- p2/trunk/lib/ThreadRead.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/ThreadRead.php 2009-12-14 10:52:23 UTC (rev 737) @@ -210,13 +210,13 @@ return false; } - $from_bytes = intval($from_bytes); + $range_bytes = intval($from_bytes); - if ($from_bytes == 0) { + if ($range_bytes == 0) { $zero_read = true; } else { $zero_read = false; - $from_bytes = $from_bytes - 1; + $range_bytes = $from_bytes - 1; } //$url = 'http://' . $this->host . '/' . $this->bbs . '/dat/' . $this->key . '.dat'; @@ -247,7 +247,7 @@ $request .= "Accept-Language: ja, en\r\n"; $request .= "User-Agent: " . P2Util::getP2UA($withMonazilla = true) . "\r\n"; if (!$zero_read) { - $request .= "Range: bytes={$from_bytes}-\r\n"; + $request .= "Range: bytes={$range_bytes}-\r\n"; } $request .= "Referer: http://{$purl['host']}/{$this->bbs}/\r\n"; if ($this->modified) { @@ -354,17 +354,16 @@ } // Not Modified - } elseif ($code == "304") { + } elseif ($code == '304') { fclose($fp); $this->isonline = true; - return "304 Not Modified"; + return '304 Not Modified'; // Requested Range Not Satisfiable - } elseif ($code == "416") { + } elseif ($code == '416') { //echo " Ú[ño"; fclose($fp); - unset($this->onbytes); - unset($this->modified); + $this->clearOnbytesModified(); return $this->downloadDat2ch(0); // Ú[ñðoµ½ÌÅSæè¼µB // \úµÈ¢HTTPR[hBXbhªÈ¢Æ»f @@ -396,8 +395,7 @@ if (!$zero_read) { if (substr($body, 0, 1) != "\n") { //echo " Ú[ño"; - unset($this->onbytes); - unset($this->modified); + $this->clearOnbytesModified(); return $this->downloadDat2ch(0); // Ú[ñðoµ½ÌÅSæè¼µB } $body = substr($body, 1); @@ -405,10 +403,20 @@ FileCtl::make_datafile($this->keydat, $_conf['dat_perm']); - $rsc = $zero_read ? LOCK_EX : FILE_APPEND | LOCK_EX; - - if (false === file_put_contents($this->keydat, $body, $rsc)) { - trigger_error("file_put_contents(" . $this->keydat . ")", E_USER_WARNING); + $done = false; + if ($fp = fopen($this->keydat, 'rb+')) { + flock($fp, LOCK_EX); + if (0 === fseek($fp, $from_bytes)) { + if (false !== fwrite($fp, $body)) { + ftruncate($fp, $from_bytes + strlen($body)); + $done = true; + } + } + flock($fp, LOCK_UN); + fclose($fp); + } + if (!$done) { + trigger_error('cannot write file (' . $this->keydat . ')', E_USER_WARNING); die('Error: cannot write file. downloadDat2ch()'); return false; } @@ -420,8 +428,7 @@ $this->getDatBytesFromLocalDat(); // $aThread->length ðset if ($this->onbytes != $this->length) { $onbytes = $this->onbytes; - unset($this->onbytes); - unset($this->modified); + $this->clearOnbytesModified(); P2Util::pushInfoHtml("p2 info: $onbytes/$this->length t@CTCYªÏÈÌÅAdatðÄ澵ܵ½<br>"); $debug && $GLOBALS['profiler']->leaveSection('dat_size_check'); return $this->downloadDat2ch(0); // datTCYÍs³BSæè¼µB @@ -447,6 +454,16 @@ } /** + * @access private + * @return void + */ + function clearOnbytesModified() + { + unset($this->onbytes); + unset($this->modified); + } + + /** * 2ch DATð_E[hÅ«È©Á½Æ«ÉÄÑo³êé * * @access private Modified: p2/trunk/lib/dele.funcs.php =================================================================== --- p2/trunk/lib/dele.funcs.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/dele.funcs.php 2009-12-14 10:52:23 UTC (rev 737) @@ -61,12 +61,9 @@ { global $_conf; - $dat_host_dir = P2Util::datDirOfHost($host); - $idx_host_dir = P2Util::idxDirOfHost($host); - - $anidx = $idx_host_dir . '/' . $bbs . '/' . $key . '.idx'; - $adat = $dat_host_dir . '/' . $bbs . '/' . $key . '.dat'; - + $anidx = P2Util::idxDirOfHostBbs($host, $bbs) . $key . '.idx'; + $adat = P2Util::datDirOfHostBbs($host, $bbs) . $key . '.dat'; + // FileÌí // idxiÂlpÝèj if (file_exists($anidx)) { Modified: p2/trunk/lib/downloadDatMachiBbs.func.php =================================================================== --- p2/trunk/lib/downloadDatMachiBbs.func.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/downloadDatMachiBbs.func.php 2009-12-14 10:52:23 UTC (rev 737) @@ -68,8 +68,6 @@ $latest_num = 0; if ($mdatlines = _machiHtmltoDatLines($mlines, $latest_num)) { - $rsc = $file_append ? (FILE_APPEND | LOCK_EX) : LOCK_EX; - $cont = ''; for ($i = $START; $i <= $latest_num; $i++) { if (isset($mdatlines[$i])) { @@ -78,8 +76,18 @@ $cont .= " Ú[ñ<> Ú[ñ<> Ú[ñ<> Ú[ñ<>\n"; } } - if (false === file_put_contents($ThreadRead->keydat, $cont, $rsc)) { - trigger_error("file_put_contents(" . $ThreadRead->keydat . ")", E_USER_WARNING); + + $done = false; + if ($fp = fopen($ThreadRead->keydat, 'ab+')) { + flock($fp, LOCK_EX); + if (false !== fwrite($fp, $cont)) { + $done = true; + } + flock($fp, LOCK_UN); + fclose($fp); + } + if (!$done) { + trigger_error('cannot write file (' . $ThreadRead->keydat . ')', E_USER_WARNING); die('Error: cannot write file.'); } } Modified: p2/trunk/lib/downloadDatShitaraba.func.php =================================================================== --- p2/trunk/lib/downloadDatShitaraba.func.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/downloadDatShitaraba.func.php 2009-12-14 10:52:23 UTC (rev 737) @@ -82,8 +82,6 @@ $latest_num = 0; if ($mdatlines = _shitarabaDatTo2chDatLines($mlines, $latest_num)) { - $rsc = $file_append ? (FILE_APPEND | LOCK_EX) : LOCK_EX; - $cont = ''; for ($i = $START; $i <= $latest_num; $i++) { if ($mdatlines[$i]) { @@ -92,10 +90,19 @@ $cont .= " Ú[ñ<> Ú[ñ<> Ú[ñ<> Ú[ñ<>\n"; } } - if (false === file_put_contents($ThreadRead->keydat, $cont, $rsc)) { - trigger_error("file_put_contents(" . $ThreadRead->keydat . ")", E_USER_WARNING); + + $done = false; + if ($fp = fopen($ThreadRead->keydat, 'ab+')) { + flock($fp, LOCK_EX); + if (false !== fwrite($fp, $cont)) { + $done = true; + } + flock($fp, LOCK_UN); + fclose($fp); + } + if (!$done) { + trigger_error('cannot write file (' . $ThreadRead->keydat . ')', E_USER_WARNING); die('Error: cannot write file.'); - return false; } } Modified: p2/trunk/lib/settaborn.func.php =================================================================== --- p2/trunk/lib/settaborn.func.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/lib/settaborn.func.php 2009-12-14 10:52:23 UTC (rev 737) @@ -15,8 +15,7 @@ // {{{ key.idx ÇÝÞ - $idx_host_dir = P2Util::idxDirOfHost($host); - $idxfile = "{$idx_host_dir}/{$bbs}/{$key}.idx"; + $idxfile = P2Util::getKeyIdxFilePath($host, $bbs, $key); $data[0] = null; Modified: p2/trunk/post.php =================================================================== --- p2/trunk/post.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/post.php 2009-12-14 10:52:23 UTC (rev 737) @@ -55,7 +55,7 @@ $_conf['last_post_time_file'] = $_conf['pref_dir'] . '/last_post_time.txt'; if (P2Util::isHost2chs($host)) { $server_id = preg_replace('{\.2ch\.net$}', '', $host); - $_conf['last_post_time_file'] = P2Util::idxDirOfHost($host) . '/' . rawurlencode($server_id) . '_' . 'last_post_time.txt'; + $_conf['last_post_time_file'] = P2Util::idxDirOfHost($host, true) . rawurlencode($server_id) . '_' . 'last_post_time.txt'; } if (!isset($ttitle)) { @@ -298,8 +298,7 @@ return; } - $idx_host_dir = P2Util::idxDirOfHost($host); - $keyidx = $idx_host_dir . '/' . $bbs . '/' . $key . '.idx'; + $keyidx = P2Util::getKeyIdxFilePath($host, $bbs, $key); $akeyline = array(); if (file_exists($keyidx) and $keylines = file($keyidx)) { @@ -392,8 +391,6 @@ // f[^PHP`®ip2_res_hist.dat.php, ^uæØèjÌ«ÝððAdat`®ip2_res_hist.dat, <>æØèjÉÏ··é P2Util::transResHistLogPhpToDat(); - $date_and_id = date("y/m/d H:i"); - FileCtl::make_datafile($_conf['p2_res_hist_dat'], $_conf['res_write_perm']); $resnum = ''; @@ -405,19 +402,30 @@ } } - $newdata = $from . '<>' . $mail . "<>$date_and_id<>$message<>$ttitle<>$host<>$bbs<>$key<>$resnum"; + $newdata_ar = array( + $from, $mail, date("y/m/d H:i"), $message, $ttitle, $host, $bbs, $key, $resnum + ); + $newdata = implode('<>', $newdata_ar) . "\n"; // ܸ^uðSÄOµÄi2chÌ«ÝÅÍ^uÍí³êé 2004/12/13j $newdata = str_replace("\t", '', $newdata); // <>ð^uÉÏ·µÄ //$newdata = str_replace('<>', "\t", $newdata); - - $cont = $newdata . "\n"; - - if (false === file_put_contents($_conf['p2_res_hist_dat'], $cont, FILE_APPEND | LOCK_EX)) { + + $done = false; + if ($fp = fopen($_conf['p2_res_hist_dat'], 'ab+')) { + flock($fp, LOCK_EX); + if (false !== fwrite($fp, $newdata)) { + $done = true; + } + flock($fp, LOCK_UN); + fclose($fp); + } + if (!$done) { trigger_error('p2 error: «ÝOÌ۶ɸsµÜµ½', E_USER_WARNING); return false; } + return true; } Modified: p2/trunk/post_form_i.php =================================================================== --- p2/trunk/post_form_i.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/post_form_i.php 2009-12-14 10:52:23 UTC (rev 737) @@ -38,8 +38,7 @@ p2die('s³ÈøÅ·'); } -$idx_host_dir = P2Util::idxDirOfHost($host); -$key_idx = $idx_host_dir . '/' . $bbs . '/' . $key . '.idx'; +$keyidx = P2Util::getKeyIdxFilePath($host, $bbs, $key); // tH[ÌIvVÇÝÝ require_once P2_LIB_DIR . '/post_options_loader.inc.php'; Modified: p2/trunk/read.php =================================================================== --- p2/trunk/read.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/read.php 2009-12-14 10:52:23 UTC (rev 737) @@ -26,6 +26,7 @@ if ($_conf['ktai'] && isset($_GET['ktool_name']) && isset($_GET['ktool_value'])) { switch ($_GET['ktool_name']) { + // GO case 'goto': if (preg_match('/(-|,)/', $_GET['ktool_value'])) { $_REQUEST['ls'] = $_GET['ls'] = $_GET['ktool_value']; @@ -35,15 +36,18 @@ } break; + // >攴 case 'res_quote': $_GET['resnum'] = (int)$_GET['ktool_value']; $_GET['inyou'] = 1; require './post_form.php'; exit; + // >ハ case 'copy_quote': $_GET['inyou'] = 1; + // ハ case 'copy': $GLOBALS['_read_copy_resnum'] = (int)$_GET['ktool_value']; require './read_copy_k.php'; Modified: p2/trunk/subject.php =================================================================== --- p2/trunk/subject.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/subject.php 2009-12-14 10:52:23 UTC (rev 737) @@ -55,8 +55,7 @@ $sb_keys_txt = null; } else { - $idx_host_dir = P2Util::idxDirOfHost($host); - $idx_bbs_dir_s = $idx_host_dir . '/' . $bbs . '/'; + $idx_bbs_dir_s = P2Util::idxDirOfHostBbs($host, $bbs); $p2_setting_txt = $idx_bbs_dir_s . 'p2_setting.txt'; $sb_keys_b_txt = $idx_bbs_dir_s . 'p2_sb_keys_b.txt'; Modified: p2/trunk/subject_i.php =================================================================== --- p2/trunk/subject_i.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/subject_i.php 2009-12-14 10:52:23 UTC (rev 737) @@ -56,8 +56,7 @@ $sb_keys_txt = null; } else { - $idx_host_dir = P2Util::idxDirOfHost($host); - $idx_bbs_dir_s = $idx_host_dir . '/' . $bbs . '/'; + $idx_bbs_dir_s = P2Util::idxDirOfHostBbs($host, $bbs); $p2_setting_txt = $idx_bbs_dir_s . 'p2_setting.txt'; $sb_keys_b_txt = $idx_bbs_dir_s . 'p2_sb_keys_b.txt'; Modified: p2/trunk/subject_new.php =================================================================== --- p2/trunk/subject_new.php 2009-12-02 10:13:26 UTC (rev 736) +++ p2/trunk/subject_new.php 2009-12-14 10:52:23 UTC (rev 737) @@ -36,12 +36,11 @@ if ($spmode) { $p2_setting_txt = $_conf['pref_dir'] . "/p2_setting_" . $spmode . ".txt"; } else { - $idx_host_dir = P2Util::idxDirOfHost($host); - $idx_bbs_dir_s = $idx_host_dir . '/' . $bbs . '/'; + $idx_bbs_dir_s = P2Util::idxDirOfHostBbs($host, $bbs); $p2_setting_txt = $idx_bbs_dir_s . "p2_setting.txt"; - $sb_keys_b_txt = $idx_bbs_dir_s . "p2_sb_keys_b.txt"; - $sb_keys_txt = $idx_bbs_dir_s . "p2_sb_keys.txt"; + $sb_keys_b_txt = $idx_bbs_dir_s . "p2_sb_keys_b.txt"; + $sb_keys_txt = $idx_bbs_dir_s . "p2_sb_keys.txt"; if (!empty($_REQUEST['norefresh']) || !empty($_REQUEST['word'])) { if ($prepre_sb_cont = @file_get_contents($sb_keys_b_txt)) {