svnno****@sourc*****
svnno****@sourc*****
2010年 1月 5日 (火) 21:50:04 JST
Revision: 765 http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=765 Author: rsk Date: 2010-01-05 21:50:04 +0900 (Tue, 05 Jan 2010) Log Message: ----------- expack: - rev.100105.2130. - ã¹ã¬ããã¿ã¤ãã«ãã¼ã¼ãæ©è½ãå®è£ ã - å ¬å¼p2ã®Cookieèªè¨¼æã«IPã¢ãã¬ã¹ã®åä¸æ§ããã§ãã¯ããã ã©ãããé¸æããè¨å®é ç®ã追å ã - ã¯ã©ã¤ã¢ã³ããCookieããµãã¼ããããå¦ãã§èªåçã« php.ini ãã£ã¬ã¯ãã£ã session.use_cookies 㨠session.use_only_cookies ãåãæ¿ããããã«ããã - rep2ã«ã¼ããã£ã¬ã¯ããªã« user_skin ãã£ã¬ã¯ããªãããå ´åã ãããããã¹ãã³ãèªã¿è¾¼ãããã«ããã -- user_skin ãã£ã¬ã¯ããªã¯ skin ãã£ã¬ã¯ããªãããåªå ãããã -- ã¹ãã³ãã¡ã¤ã«åã¯æ£è¦è¡¨ç¾ ^[0-9A-Za-z_\-]\.php$ ã« ãããããªããã°ãªããªãã - PHPã®ãã¼ã¸ã§ã³è¦åã¡ãã»ã¼ã¸ãtitle.phpã«ã ã表示ããããã«ããã - ãã®ä»ãå é¨çã«å°ãå¤æ´ã Modified Paths: -------------- p2ex/trunk/conf/conf.inc.php p2ex/trunk/conf/conf_user_def.inc.php p2ex/trunk/edit_aborn_word.php p2ex/trunk/edit_conf_user.php p2ex/trunk/editfile.php p2ex/trunk/editpref.php p2ex/trunk/lib/NgAbornCtl.php p2ex/trunk/lib/P2Client.php p2ex/trunk/lib/P2Util.php p2ex/trunk/lib/Session.php p2ex/trunk/subject.php -------------- next part -------------- Modified: p2ex/trunk/conf/conf.inc.php =================================================================== --- p2ex/trunk/conf/conf.inc.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/conf/conf.inc.php 2010-01-05 12:50:04 UTC (rev 765) @@ -7,7 +7,7 @@ // o[Wîñ $_conf = array( 'p2version' => '1.7.29+1.8.x', // rep2Ìo[W - 'p2expack' => '100103.1800', // g£pbNÌo[W + 'p2expack' => '100105.2130', // g£pbNÌo[W 'p2name' => 'expack', // rep2̼O ); @@ -168,6 +168,7 @@ // XL define('P2_SKIN_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'skin'); +define('P2_USER_SKIN_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'user_skin'); // PEARCXg[fBNgAõpXÉÇÁ³êé define('P2_PEAR_DIR', P2_BASE_DIR . DIRECTORY_SEPARATOR . 'includes'); @@ -623,21 +624,60 @@ // }}} // {{{ fUCÝè Ç -$skin_name = 'conf_user_style'; +$skin_name = $default_skin_name = 'conf_user_style'; $skin = $P2_CONF_DIR_S . 'conf_user_style.inc.php'; if (!$_conf['ktai'] && $_conf['expack.skin.enabled']) { + // Û¶³êÄ¢éXL¼ + $saved_skin_name = null; if (file_exists($_conf['expack.skin.setting_path'])) { - $skin_name = rtrim(file_get_contents($_conf['expack.skin.setting_path'])); - $skin = P2_SKIN_DIR . DIRECTORY_SEPARATOR . $skin_name . '.php'; + $saved_skin_name = rtrim(file_get_contents($_conf['expack.skin.setting_path'])); + if (!preg_match('/^[0-9A-Za-z_\\-]+$/', $saved_skin_name)) { + $saved_skin_name = null; + } } else { FileCtl::make_datafile($_conf['expack.skin.setting_path'], $_conf['expack.skin.setting_perm']); } - if (isset($_REQUEST['skin']) && preg_match('/^\\w+$/', $_REQUEST['skin']) && $skin_name != $_REQUEST['skin']) { - $skin_name = $_REQUEST['skin']; - $skin = P2_SKIN_DIR . DIRECTORY_SEPARATOR . $skin_name . '.php'; - FileCtl::file_write_contents($_conf['expack.skin.setting_path'], $skin_name); + + // NGXgÅwè³ê½XL¼ + $new_skin_name = null; + if (array_key_exists('skin', $_REQUEST) && is_string($_REQUEST['skin'])) { + $new_skin_name = $_REQUEST['skin']; + if (!preg_match('/^[0-9A-Za-z_\\-]+$/', $new_skin_name)) { + $new_skin_name = null; + } elseif ($new_skin_name != $saved_skin_name) { + FileCtl::file_write_contents($_conf['expack.skin.setting_path'], $new_skin_name); + } } + + // NGXgÅwè³ê½êXL¼ + $tmp_skin_name = null; + if (array_key_exists('tmp_skin', $_REQUEST) && is_string($_REQUEST['tmp_skin'])) { + $tmp_skin_name = $_REQUEST['tmp_skin']; + if (!preg_match('/^[0-9A-Za-z_\\-]+$/', $tmp_skin_name)) { + $tmp_skin_name = null; + } + } + + // XLõ + foreach (array($tmp_skin_name, $new_skin_name, $saved_skin_name, $default_skin_name) as $skin_name) { + if ($skin_name !== null) { + if ($skin_name == $default_skin_name) { + break; + } + $user_skin_path = P2_USER_SKIN_DIR . DIRECTORY_SEPARATOR . $skin_name . '.php'; + if (file_exists($user_skin_path)) { + $skin = $user_skin_path; + break; + } + $bundled_skin_path = P2_SKIN_DIR . DIRECTORY_SEPARATOR . $skin_name . '.php'; + if (file_exists($bundled_skin_path)) { + $skin = $bundled_skin_path; + break; + } + } + } } + if (!file_exists($skin)) { $skin_name = 'conf_user_style'; $skin = $P2_CONF_DIR_S . 'conf_user_style.inc.php'; @@ -927,18 +967,8 @@ // }}} -$_p2session = new Session(); +$_p2session = new Session(null, null, $support_cookies); -if (!$support_cookies) { - if (ini_get('session.use_only_cookies')) { - p2die('Session unavailable', 'php.ini Å session.use_only_cookies ª On ÉÈÁĢܷB'); - } - if (!ini_get('session.use_trans_sid')) { - output_add_rewrite_var(session_name(), session_id()); - $_conf['sid_at_a'] = '&' . rawurldecode(session_name()) . '=' . rawurldecode(session_id()); - } -} - // }}} // {{{ ¨CÉZbg @@ -1007,7 +1037,8 @@ $php_version = phpversion(); $required_version = '5.2.8'; - $recommended_version = '5.2.10'; + $recommended_version52 = '5.2.12'; + $recommended_version53 = '5.3.1'; // PHPÌo[W if (version_compare($php_version, $required_version, '<')) { @@ -1048,15 +1079,24 @@ } // §o[W - if ($check_recommended && version_compare($php_version, $recommended_version, '<')) { - $conf_php = htmlspecialchars(__FILE__, ENT_QUOTES); - $_info_msg_ht .= <<<EOP + if ($check_recommended) { + if (version_compare($php_version, '5.3.0-dev', '>=')) { + $recommended_version = $recommended_version53; + } else { + $recommended_version = $recommended_version52; + } + if (version_compare($php_version, $recommended_version, '<')) { + // title.php ÌÝbZ[Wð\¦ + if (basename($_SERVER['PHP_SELF'], '.php') == 'title') { + $_info_msg_ht .= <<<EOP <p><strong>§o[WæèâPHPÅ®ìµÄ¢Ü·B</strong><em>(PHP {$php_version})</em><br> -PHP {$recommended_version} È~ÉAbvf[g·é±Æ𨷷ߵܷB<br> -<small>i±ÌbZ[Wð\¦µÈ¢æ¤É·éÉÍ {$conf_php} Ì {$check_recommended} sÚÌ -"p2checkenv(__LINE__);" ð quot;p2checkenv(false);" É«·¦Ä¾³¢j</small></p> +PHP {$recommended_version} È~ÉAbvf[g·é±Æ𨷷ߵܷB</p> +<p style="font-size:smaller">±ÌbZ[Wð\¦µÈ¢æ¤É·éÉÍ <em>{\$rep2_directory}</em>/conf/conf.inc.php Ì {$check_recommended} sÚA<br> +<samp>p2checkenv(__LINE__);</samp> ð <samp>p2checkenv(false);</samp> É«·¦Ä¾³¢B</p> EOP; - return false; + } + return false; + } } return true; Modified: p2ex/trunk/conf/conf_user_def.inc.php =================================================================== --- p2ex/trunk/conf/conf_user_def.inc.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/conf/conf_user_def.inc.php 2010-01-05 12:50:04 UTC (rev 765) @@ -22,6 +22,10 @@ // p2.2ch.netÌOCpX[h $conf_user_def['p2_2ch_pass'] = ""; // ("") +// p2.2ch.net CookieFØÉIPAhX̯ê«ð`FbN +$conf_user_def['p2_2ch_ignore_cip'] = 0; // (0) +$conf_user_rad['p2_2ch_ignore_cip'] = array('0' => '`FbN·é', '1' => '`FbNµÈ¢'); + // }}} // {{{ PATH Modified: p2ex/trunk/edit_aborn_word.php =================================================================== --- p2ex/trunk/edit_aborn_word.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/edit_aborn_word.php 2010-01-05 12:50:04 UTC (rev 765) @@ -7,35 +7,34 @@ $_login->authorize(); // [UFØ -define('P2_SALT_EDIT_ABORN_WORD', basename(__FILE__)); +$filename = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; -$path = isset($_REQUEST['path']) ? $_REQUEST['path'] : ''; -$path_ht = htmlspecialchars($path, ENT_QUOTES); - +$csrfid = P2Util::getCsrfId(__FILE__ . $filename); if (!empty($_POST['submit_save']) || !empty($_POST['submit_default'])) { - if (!isset($_POST['csrfid']) or $_POST['csrfid'] != P2Util::getCsrfId(P2_SALT_EDIT_ABORN_WORD)) { + if (!isset($_POST['csrfid']) or $_POST['csrfid'] != $csrfid) { p2die('s³È|XgÅ·'); } } $writable_files = array( - "p2_aborn_name.txt", "p2_aborn_mail.txt", "p2_aborn_msg.txt", "p2_aborn_id.txt", - "p2_ng_name.txt", "p2_ng_mail.txt", "p2_ng_msg.txt", "p2_ng_id.txt", - //"p2_aborn_res.txt", + 'p2_aborn_thread.txt' => ' Ú[ñXbh^Cg', + 'p2_aborn_name.txt' => ' Ú[ñl[', + 'p2_aborn_mail.txt' => ' Ú[ñ[', + 'p2_aborn_msg.txt' => ' Ú[ñbZ[W', + 'p2_aborn_id.txt' => ' Ú[ñID', + 'p2_ng_name.txt' => 'NGl[', + 'p2_ng_mail.txt' => 'NG[', + 'p2_ng_msg.txt' => 'NGbZ[W', + 'p2_ng_id.txt' => 'NGID', ); -if ($writable_files and (!in_array(basename($path), $writable_files))) { - $i = 0; - foreach ($writable_files as $afile) { - if ($i != 0) { - $files_st .= "Æ"; - } - $files_st .= "u".$afile."v"; - $i++; - } - p2die(basename($_SERVER['SCRIPT_NAME']) . " æ¶Ì«ßét@CÍA{$files_st}¾¯I"); +if (!array_key_exists($filename, $writable_files)) { + $files_st = implode(', ', array_keys($writable_files)); + p2die(basename($_SERVER['SCRIPT_NAME']) . " æ¶Ì«ßét@CÍA{$files_st} ¾¯I"); } +$path = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . $filename; + //===================================================================== // O //===================================================================== @@ -145,12 +144,10 @@ //===================================================================== // vgÝè //===================================================================== -$ptitle_top = sprintf(' Ú[ñ/NG[hÒW > <a href="%s?path=%s">%s</a>', - $_SERVER['SCRIPT_NAME'], rawurlencode($path), basename($path)); +$ptitle_top = sprintf(' Ú[ñ/NG[hÒW > <a href="%s?file=%s">%s</a>', + $_SERVER['SCRIPT_NAME'], rawurlencode($filename), $writable_files[$filename]); $ptitle = strip_tags($ptitle_top); -$csrfid = P2Util::getCsrfId(P2_SALT_EDIT_ABORN_WORD); - //===================================================================== // vg //===================================================================== @@ -189,7 +186,7 @@ <p id="pan_menu"><a href="editpref.php">ÝèÇ</a> > {$ptitle_top}</p>\n EOP; } else { - echo basename($path) . "<br>"; + echo $filename . "<br>"; } // PCp\¦ @@ -215,13 +212,19 @@ $_info_msg_ht = ""; } +if ($filename == 'p2_aborn_thread.txt') { + $usage_ttitle = '<li>X^C: u Ú[ñXbh^CgvÅÍsgp</li>'; +} else { + $usage_ttitle = '<li>X^C: Xbh^Cg (ªêv, íÉ嶬¶ð³)</li>'; +} + $usage = <<<EOP <ul> <li>[h: NG/ Ú[ñ[h (óÉ·éÆo^ð)</li> <li>i: 嶬¶ð³</li> <li>re: ³K\»</li> <li>Â: newsplus,software (®Sêv, J}æØè)</li> -<li>X^C: Xbh^Cg (ªêv, íÉ嶬¶ð³)</li> +{$usage_ttitle} </ul> EOP; if ($_conf['ktai']) { @@ -230,7 +233,7 @@ echo <<<EOP {$usage} <form method="POST" action="{$_SERVER['SCRIPT_NAME']}" target="_self" accept-charset="{$_conf['accept_charset']}"> - <input type="hidden" name="path" value="{$path_ht}"> + <input type="hidden" name="file" value="{$filename}"> <input type="hidden" name="csrfid" value="{$csrfid}">\n EOP; Modified: p2ex/trunk/edit_conf_user.php =================================================================== --- p2ex/trunk/edit_conf_user.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/edit_conf_user.php 2010-01-05 12:50:04 UTC (rev 765) @@ -8,10 +8,10 @@ $_login->authorize(); // [UFØ -define('P2_SALT_EDIT_CONF_USER', basename(__FILE__)); +$csrfid = P2Util::getCsrfId(__FILE__); if (!empty($_POST['submit_save']) || !empty($_POST['submit_default'])) { - if (!isset($_POST['csrfid']) or $_POST['csrfid'] != P2Util::getCsrfId(P2_SALT_EDIT_CONF_USER)) { + if (!isset($_POST['csrfid']) or $_POST['csrfid'] != $csrfid) { p2die('s³È|XgÅ·'); } } @@ -111,8 +111,6 @@ //===================================================================== $ptitle = '[UÝèÒW'; -$csrfid = P2Util::getCsrfId(P2_SALT_EDIT_CONF_USER); - $me = P2Util::getMyUrl(); //===================================================================== @@ -202,6 +200,7 @@ 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_ignore_cip', ' p2.2ch.net CookieFØÉIPAhX̯ê«ð`FbN'), ); printEditConfGroupHtml($groupname, $conflist, $flags); } Modified: p2ex/trunk/editfile.php =================================================================== --- p2ex/trunk/editfile.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/editfile.php 2010-01-05 12:50:04 UTC (rev 765) @@ -7,46 +7,41 @@ $_login->authorize(); // [UFØ -// øG[ -if (!isset($_REQUEST['path'])) { - p2die('path ªwè³êĢܹñ'); -} - // Ï ================================== -$path = isset($_REQUEST['path']) ? $_REQUEST['path'] : null; +$filename = isset($_REQUEST['file']) ? $_REQUEST['file'] : null; $modori_url = isset($_REQUEST['modori_url']) ? $_REQUEST['modori_url'] : null; $encode = isset($_REQUEST['encode']) ? $_REQUEST['encode'] : null; $rows = isset($_REQUEST['rows']) ? intval($_REQUEST['rows']) : ($_conf['ktai'] ? 5 : 36); $cols = isset($_REQUEST['cols']) ? intval($_REQUEST['cols']) : ($_conf['ktai'] ? 0 : 128); -isset($_POST['filecont']) and $filecont = $_POST['filecont']; +$csrfid = P2Util::getCsrfId(__FILE__ . $filename); //========================================================= // O //========================================================= + +// s³|Xg`FbN +if (isset($_POST['filecont'])) { + if (!isset($_POST['csrfid']) || $_POST['csrfid'] != $csrfid) { + p2die('s³È|XgÅ·'); + } else { + $filecont = $_POST['filecont']; + } +} + // «ßét@CðÀè·é $writable_files = array( - //"conf.inc.php", "conf_user_style.inc.php", - //"p2_aborn_name.txt", "p2_aborn_mail.txt", "p2_aborn_msg.txt", "p2_aborn_id.txt", - //"p2_ng_name.txt", "p2_ng_mail.txt", "p2_ng_msg.txt", "p2_ng_id.txt", - "p2_aborn_res.txt", - //"conf_user_ex.php", "conf_constant.inc", - //"conf_user_ex.inc.php", "conf_user_constant.inc.php" - ); + 'p2_aborn_res.txt' => ' Ú[ñX', +); -if ($writable_files and (!in_array(basename($path), $writable_files))) { - $i = 0; - foreach ($writable_files as $afile) { - if ($i != 0) { - $files_st .= "Æ"; - } - $files_st .= "u".$afile."v"; - $i++; - } +if (!array_key_exists($filename, $writable_files)) { + $files_st = implode(', ', array_keys($writable_files)); p2die(basename($_SERVER['SCRIPT_NAME']) . " æ¶Ì«ßét@CÍA{$files_st}¾¯I"); } +$path = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . $filename; + //========================================================= // C //========================================================= @@ -56,7 +51,7 @@ } } -editFile($path, $encode); +editFile($path, $encode, $writable_files[$filename]); exit; @@ -92,16 +87,17 @@ /** * t@CàeðÇÝñÅÒW·éÖ */ -function editFile($path, $encode) +function editFile($path, $encode, $title) { - global $_conf, $modori_url, $_info_msg_ht, $rows, $cols; + global $_conf, $modori_url, $_info_msg_ht, $rows, $cols, $csrfid; if ($path == '') { p2die('path ªwè³êĢܹñ'); } $filename = basename($path); - $ptitle = "Edit: ".$filename; + $ptitle = 'Edit: ' . htmlspecialchars($title, ENT_QUOTES, 'Shift_JIS') + . ' (' . $filename . ')'; //t@CàeÇÝÝ FileCtl::make_datafile($path) or p2die("cannot make file. ({$path})"); @@ -136,15 +132,15 @@ EOHEADER; echo $modori_url_ht; - - echo "Edit: ".$path; + echo $ptitle; echo <<<EOFORM <form action="{$_SERVER['SCRIPT_NAME']}" method="post" accept-charset="{$_conf['accept_charset']}"> - <input type="hidden" name="path" value="{$path}"> + <input type="hidden" name="file" value="{$filename}"> <input type="hidden" name="modori_url" value="{$modori_url}"> <input type="hidden" name="encode" value="{$encode}"> <input type="hidden" name="rows" value="{$rows}"> <input type="hidden" name="cols" value="{$cols}"> + <input type="hidden" name="csrfid" value="{$csrfid}"> <input type="submit" name="submit" value="Save"> {$_info_msg_ht}<br> <textarea style="font-size:9pt;" id="filecont" name="filecont" wrap="off"{$rows_at}{$cols_at}>{$cont_area}</textarea> Modified: p2ex/trunk/editpref.php =================================================================== --- p2ex/trunk/editpref.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/editpref.php 2010-01-05 12:50:04 UTC (rev 765) @@ -162,15 +162,16 @@ $_info_msg_ht = ''; // Ýèvg -$aborn_res_txt = $_conf['pref_dir'] . '/p2_aborn_res.txt'; -$aborn_name_txt = $_conf['pref_dir'] . '/p2_aborn_name.txt'; -$aborn_mail_txt = $_conf['pref_dir'] . '/p2_aborn_mail.txt'; -$aborn_msg_txt = $_conf['pref_dir'] . '/p2_aborn_msg.txt'; -$aborn_id_txt = $_conf['pref_dir'] . '/p2_aborn_id.txt'; -$ng_name_txt = $_conf['pref_dir'] . '/p2_ng_name.txt'; -$ng_mail_txt = $_conf['pref_dir'] . '/p2_ng_mail.txt'; -$ng_msg_txt = $_conf['pref_dir'] . '/p2_ng_msg.txt'; -$ng_id_txt = $_conf['pref_dir'] . '/p2_ng_id.txt'; +$aborn_thread_txt = 'p2_aborn_thread.txt'; +$aborn_res_txt = 'p2_aborn_res.txt'; +$aborn_name_txt = 'p2_aborn_name.txt'; +$aborn_mail_txt = 'p2_aborn_mail.txt'; +$aborn_msg_txt = 'p2_aborn_msg.txt'; +$aborn_id_txt = 'p2_aborn_id.txt'; +$ng_name_txt = 'p2_ng_name.txt'; +$ng_mail_txt = 'p2_ng_mail.txt'; +$ng_msg_txt = 'p2_ng_msg.txt'; +$ng_id_txt = 'p2_ng_id.txt'; echo '<div>'; echo <<<EOP @@ -178,14 +179,20 @@ EOP; if (!$_conf['ktai'] && $_conf['expack.skin.enabled']) { $skin_options = array('conf_user_style' => 'W'); - if (is_dir('./skin')) { - foreach (glob('./skin/*.php') as $skin_file) { - $_name = basename($skin_file, '.php'); - if (is_file($skin_file) && preg_match('/^\\w+$/', $_name)) { - $skin_options[$_name] = $_name; + foreach (array('./skin', './user_skin') as $skin_dir) { + if (is_dir($skin_dir)) { + foreach (glob("{$skin_dir}/*.php") as $skin_file) { + $_name = basename($skin_file, '.php'); + if (!array_key_exists($_name, $skin_options) && + is_file($skin_file) && + preg_match('/^[0-9A-Za-z_\\-]+$/', $_name)) + { + $skin_options[$_name] = $_name; + } } } } + uksort($skin_options, 'compareSkinNames'); $skin_options_ht = ''; foreach ($skin_options as $_name => $_title) { $skin_options_ht .= sprintf('<option value="%s"%s>%s</option>', @@ -215,10 +222,10 @@ <fieldset> <legend><a href="http://akid.s17.xrea.com/p2puki/pukiwiki.php?%5B%5BNG%A5%EF%A1%BC%A5%C9%A4%CE%C0%DF%C4%EA%CA%FD%CB%A1%5D%5D" target="read">NG[h</a>ÒW</legend> EOP; - printEditFileForm($ng_name_txt, "¼O"); - printEditFileForm($ng_mail_txt, "["); - printEditFileForm($ng_msg_txt, "bZ[W"); - printEditFileForm($ng_id_txt, "hc"); + printEditFileForm($ng_name_txt, '¼O'); + printEditFileForm($ng_mail_txt, '['); + printEditFileForm($ng_msg_txt, '{¶'); + printEditFileForm($ng_id_txt, 'ID'); echo <<<EOP </fieldset>\n\n EOP; @@ -234,11 +241,12 @@ <fieldset> <legend> Ú[ñ[hÒW</legend>\n EOP; - printEditFileForm($aborn_res_txt, "X"); - printEditFileForm($aborn_name_txt, "¼O"); - printEditFileForm($aborn_mail_txt, "["); - printEditFileForm($aborn_msg_txt, "bZ[W"); - printEditFileForm($aborn_id_txt, "hc"); + printEditFileForm($aborn_res_txt, 'X'); + printEditFileForm($aborn_name_txt, '¼O'); + printEditFileForm($aborn_mail_txt, '['); + printEditFileForm($aborn_msg_txt, '{¶'); + printEditFileForm($aborn_id_txt, 'ID'); + printEditFileForm($aborn_thread_txt, 'Xbh'); echo <<<EOP </fieldset>\n EOP; @@ -246,27 +254,6 @@ echo "</td></tr>"; // }}} - // {{{ PC - »Ì¼ ÌÝè - - //echo "<td>\n\n"; - /* - php Í editfile µÈ¢ - - echo <<<EOP -<fieldset> -<legend>»Ì¼</legend> -EOP; - printEditFileForm("conf/conf_user_style.inc.php", 'fUCÝè'); - printEditFileForm("conf/conf.inc.php", 'î{Ýè'); - echo <<<EOP -</fieldset>\n -EOP; - */ - - // }}} - - //echo ' '; - // {{{ PC - zXg̯ú HTMLÌZbg echo <<<EOP @@ -329,21 +316,22 @@ <p>±ÎÞÝ/NGÜ°ÄÞÒW</p> <form method="GET" action="edit_aborn_word.php"> {$_conf['k_input_ht']} -<select name="path"> +<select name="file"> +<option value="{$aborn_thread_txt}">盈渺:准</option> <option value="{$aborn_name_txt}">±ÎÞÝ:¼O</option> <option value="{$aborn_mail_txt}">±ÎÞÝ:Ò°Ù</option> -<option value="{$aborn_msg_txt}">盈渺:勵尚灼</option> +<option value="{$aborn_msg_txt}">±ÎÞÝ:{¶</option> <option value="{$aborn_id_txt}">盈渺:ID</option> <option value="{$ng_name_txt}">NG:¼O</option> <option value="{$ng_mail_txt}">NG:Ò°Ù</option> -<option value="{$ng_msg_txt}">NG:勵尚灼</option> +<option value="{$ng_msg_txt}">NG:{¶</option> <option value="{$ng_id_txt}">NG:ID</option> </select> <input type="submit" value="ÒW"> </form> <form method="GET" action="editfile.php"> {$_conf['k_input_ht']} -<input type="hidden" name="path" value="{$aborn_res_txt}"> +<input type="hidden" name="file" value="{$aborn_res_txt}"> <input type="submit" value="±ÎÞÝÚ½ÒW"> </form> EOP; @@ -425,16 +413,18 @@ /** * Ýèt@CÒWEChEðJtH[HTMLðvg·é * - * @param string $path_value ÒW·ét@CÌpX + * @param string $filename ÒW·ét@C¼ * @param string $submit_value submit{^Ìl * @return void */ -function printEditFileForm($path_value, $submit_value) +function printEditFileForm($filename, $submit_value) { global $_conf; - if ((file_exists($path_value) && is_writable($path_value)) || - (!file_exists($path_value) && is_writable(dirname($path_value))) + $path = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . $filename; + + if ((file_exists($path) && is_writable($path)) || + (!file_exists($path) && is_writable(dirname($path))) ) { $onsubmit = ''; $disabled = ''; @@ -446,18 +436,21 @@ $rows = 36; // 18 $cols = 92; // 90 - if (preg_match('/^p2_(aborn|ng)_(name|mail|id|msg)\.txt$/', basename($path_value))) { + if ($filename == 'p2_aborn_thread.txt' || + preg_match('/^p2_(aborn|ng)_(name|mail|id|msg)\\.txt$/', $filename)) + { $edit_php = 'edit_aborn_word.php'; $target = '_self'; } else { $edit_php = 'editfile.php'; $target = 'editfile'; } + $filename_ht = htmlspecialchars($filename, ENT_QUOTES); $ht = <<<EOFORM <form action="{$edit_php}" method="GET" target="{$target}" class="inline-form"{$onsubmit}> {$_conf['k_input_ht']} - <input type="hidden" name="path" value="{$path_value}"> + <input type="hidden" name="file" value="{$filename_ht}"> <input type="hidden" name="encode" value="Shift_JIS"> <input type="hidden" name="rows" value="{$rows}"> <input type="hidden" name="cols" value="{$cols}"> @@ -632,7 +625,28 @@ } // }}} +// {{{ compareSkinNames() +/** + * XLÌXgð\[g·é½ßÌR[obNÖ + * + * @param string $a + * @param string $b + * @return int + */ +function compareSkinNames($a, $b) +{ + if ($a == 'conf_user_style') { + return -1; + } + if ($b == 'conf_user_style') { + return 1; + } + return strcmp($a, $b); +} + +// }}} + /* * Local Variables: * mode: php Modified: p2ex/trunk/lib/NgAbornCtl.php =================================================================== --- p2ex/trunk/lib/NgAbornCtl.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/lib/NgAbornCtl.php 2010-01-05 12:50:04 UTC (rev 765) @@ -13,6 +13,7 @@ 'aborn_msg' => 0, 'aborn_name' => 0, 'aborn_res' => 0, + 'aborn_thread' => 0, 'ng_chain' => 0, 'ng_freq' => 0, 'ng_id' => 0, @@ -30,76 +31,106 @@ /** * Ú[ñ&NG[hÝèðÛ¶·é + * + * @param void + * @return void */ static public function saveNgAborns() { global $ngaborns, $ngaborns_hits; global $_conf; - // HITµ½ÌÝXV·é - if ($GLOBALS['ngaborns_hits']) { + $lasttime = date('Y/m/d G:i'); + if ($_conf['ngaborn_daylimit']) { + $daylimit = time() - 60 * 60 * 24 * $_conf['ngaborn_daylimit']; + } else { + $daylimit = 0; + } + $errors = ''; - $lasttime = date('Y/m/d G:i'); - if ($_conf['ngaborn_daylimit']) { - $daylimit = time() - 60 * 60 * 24 * $_conf['ngaborn_daylimit']; - } else { - $daylimit = 0; + foreach ($ngaborns_hits as $code => $hits) { + // qbgµÈ©Á½êÅà1/100Ìm¦Åâf[^ðí·é½ßÉð±¯é + if (!$hits && mt_rand(1, 100) < 100) { + continue; } - $errors = ''; - foreach ($ngaborns_hits as $code => $v) { + if (isset($ngaborns[$code]) && !empty($ngaborns[$code]['data'])) { - if (isset($ngaborns[$code]) && !empty($ngaborns[$code]['data'])) { + // XVÔÅ\[g·é + usort($ngaborns[$code]['data'], array('NgAbornCtl', 'cmpLastTime')); - // XVÔÅ\[g·é - usort($ngaborns[$code]['data'], array('NgAbornCtl', 'cmpLastTime')); + $cont = ''; + foreach ($ngaborns[$code]['data'] as $a_ngaborn) { - $cont = ''; - foreach ($ngaborns[$code]['data'] as $a_ngaborn) { - - if (empty($a_ngaborn['lasttime']) || $a_ngaborn['lasttime'] == '--') { - // âf[^ðí·ésãA¼É»ÝÌúðt^ - $a_ngaborn['lasttime'] = $lasttime; - } else { - // KvÈç±±Åâf[^ÍXLbviíj·é - if ($daylimit > 0 && strtotime($a_ngaborn['lasttime']) < $daylimit) { - continue; - } + if (empty($a_ngaborn['lasttime']) || $a_ngaborn['lasttime'] == '--') { + // âf[^ðí·ésãA¼É»ÝÌúðt^ + $a_ngaborn['lasttime'] = $lasttime; + } else { + // KvÈç±±Åâf[^ÍXLbviíj·é + if ($daylimit > 0 && strtotime($a_ngaborn['lasttime']) < $daylimit) { + continue; } + } - $cont .= sprintf("%s\t%s\t%d\n", $a_ngaborn['cond'], $a_ngaborn['lasttime'], $a_ngaborn['hits']); - } // foreach + $cont .= sprintf("%s\t%s\t%d\n", $a_ngaborn['cond'], $a_ngaborn['lasttime'], $a_ngaborn['hits']); + } // foreach - /* - echo "<pre>"; - echo $cont; - echo "</pre>"; - */ + /* + echo "<pre>"; + echo $cont; + echo "</pre>"; + */ - // «Þ + // «Þ - $fp = @fopen($ngaborns[$code]['file'], 'wb'); - if (!$fp) { - $errors .= "cannot write. ({$ngaborns[$code]['file']})\n"; - } else { - flock($fp, LOCK_EX); - fputs($fp, $cont); - flock($fp, LOCK_UN); - fclose($fp); - } + $fp = @fopen($ngaborns[$code]['file'], 'wb'); + if (!$fp) { + $errors .= "cannot write. ({$ngaborns[$code]['file']})\n"; + } else { + flock($fp, LOCK_EX); + fputs($fp, $cont); + flock($fp, LOCK_UN); + fclose($fp); + } - } // if + } // if - } // foreach + } // foreach - if ($errors != '') { - p2die('NG Ú[ñt@CªXVūܹñŵ½B', $errors); - } + if ($errors !== '') { + p2die('NG Ú[ñt@CªXVūܹñŵ½B', $errors); } - return true; } // }}} + // {{{ saveAbornThreads() + + /** + * Ú[ñXbhÝèðÛ¶·é + * + * @param array $aborn_threads + * @return void + */ + static public function saveAbornThreads(array $aborn_threads) + { + if (array_key_exists('ngaborns', $GLOBALS)) { + $orig_ngaborns = $GLOBALS['ngaborns']; + $restore_ngaborns = true; + } else { + $restore_ngaborns = false; + } + + $GLOBALS['ngaborns'] = array('aborn_thread' => $aborn_threads); + self::saveNgAborns(); + + if ($restore_ngaborns) { + $GLOBALS['ngaborns'] = $orig_ngaborns; + } else { + unset($GLOBALS['ngaborns']); + } + } + + // }}} // {{{ cmpLastTime() /** @@ -121,6 +152,9 @@ /** * Ú[ñ&NG[hÝèðÇÝÞ + * + * @param void + * @return array */ static public function loadNgAborns() { @@ -140,12 +174,26 @@ } // }}} + // {{{ loadAbornThreads() + + /** + * Ú[ñXbhÝèðÇÝÞ + * + * @param void + * @return array + */ + static public function loadAbornThreads() + { + return self::_readNgAbornFromFile('p2_aborn_thread.txt'); + } + + // }}} // {{{ _readNgAbornFromFile() /** * readNgAbornFromFile */ - static private function _readNgAbornFromFile($filename) + static protected function _readNgAbornFromFile($filename) { global $_conf; Modified: p2ex/trunk/lib/P2Client.php =================================================================== --- p2ex/trunk/lib/P2Client.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/lib/P2Client.php 2010-01-05 12:50:04 UTC (rev 765) @@ -36,6 +36,8 @@ */ const REQUEST_PARAMETER_LOGIN_ID = 'form_login_id'; const REQUEST_PARAMETER_LOGIN_PASS = 'form_login_pass'; + const REQUEST_PARAMETER_LOGIN_REGIST_COOKIE = 'regist_cookie'; + const REQUEST_PARAMETER_LOGIN_IGNORE_COOKIE_ADDR = 'ignore_cip'; const REQUEST_PARAMETER_HOST = 'host'; const REQUEST_PARAMETER_BBS = 'bbs'; const REQUEST_PARAMETER_KEY = 'key'; @@ -82,6 +84,13 @@ private $_loginPass; /** + * p2.2ch.net CookieFØÉIPAhX̯ê«ð`FbNµÈ¢ + * + * @var bool + */ + private $_ignoreCookieAddr; + + /** * CookieðÛ¶·éKey-Value StoreIuWFNg * * @var P2KeyValueStore_Serializing @@ -111,9 +120,10 @@ * @param string $loginId * @param string $loginPass * @param string $cookieSaveDir + * @param bool $ignoreCookieAddr * @throws P2Exception */ - public function __construct($loginId, $loginPass, $cookieSaveDir) + public function __construct($loginId, $loginPass, $cookieSaveDir, $ignoreCookieAddr = false) { try { $cookieSavePath = $cookieSaveDir . DIRECTORY_SEPARATOR . self::COOKIE_STORE_NAME; @@ -135,6 +145,7 @@ $this->_loginPass = $loginPass; $this->_cookieStore = $cookieStore; $this->_cookieManager = $cookieManager; + $this->_ignoreCookieAddr = $ignoreCookieAddr; $defaultHeaders = array( 'User-Agent' => self::HTTP_USER_AGENT, @@ -197,6 +208,12 @@ $postData = $this->getFormValues($dom, $form, $postData); $postData[self::REQUEST_PARAMETER_LOGIN_ID] = rawurlencode($this->_loginId); $postData[self::REQUEST_PARAMETER_LOGIN_PASS] = rawurlencode($this->_loginPass); + $postData[self::REQUEST_PARAMETER_LOGIN_REGIST_COOKIE] = '1'; + if ($this->_ignoreCookieAddr) { + $postData[self::REQUEST_PARAMETER_LOGIN_IGNORE_COOKIE_ADDR] = '1'; + } elseif (array_key_exists(self::REQUEST_PARAMETER_LOGIN_IGNORE_COOKIE_ADDR, $postData)) { + unset($postData[self::REQUEST_PARAMETER_LOGIN_IGNORE_COOKIE_ADDR]); + } $response = $this->httpPost($uri, $postData, true); Modified: p2ex/trunk/lib/P2Util.php =================================================================== --- p2ex/trunk/lib/P2Util.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/lib/P2Util.php 2010-01-05 12:50:04 UTC (rev 765) @@ -1124,7 +1124,7 @@ $key .= $_SESSION['login_microtime']; } - return strtr(rtrim(base64_encode(sha1($key, true)), '='), '+/', '-_'); + return self::urlSafeBase64Encode(sha1($key, true)); } // }}} @@ -1810,13 +1810,46 @@ } try { - return new P2Client($_conf['p2_2ch_mail'], $_conf['p2_2ch_pass'], $_conf['cookie_dir']); + return new P2Client($_conf['p2_2ch_mail'], $_conf['p2_2ch_pass'], + $_conf['cookie_dir'], (bool)$_conf['p2_2ch_ignore_cip']); } catch (P2Exception $e) { p2die($e->getMessage()); } } // }}} + // {{{ urlSafeBase64Decode() + + /** + * URL-safe Base64 fR[h + * + * @param string $str + * @return string + */ + static public function urlSafeBase64Decode($str) + { + $mod = strlen($str) % 4; + if ($mod) { + $str .= str_repeat('=', 4 - $mod); + } + return base64_decode(strtr($str, '-_', '+/'), true); + } + + // }}} + // {{{ urlSafeBase64Encode() + + /** + * URL-safe Base64 GR[h + * + * @param string $str + * @return string + */ + static public function urlSafeBase64Encode($str) + { + return strtr(rtrim(base64_encode($str), '='), '+/', '-_'); + } + + // }}} // {{{ debug() /* static public function debug() Modified: p2ex/trunk/lib/Session.php =================================================================== --- p2ex/trunk/lib/Session.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/lib/Session.php 2010-01-05 12:50:04 UTC (rev 765) @@ -48,14 +48,39 @@ * * ±±ÅPHPÌWZbVªX^[g·é */ - public function __construct($session_name = NULL, $session_id = NULL) + public function __construct($session_name = null, $session_id = null, $use_cookies = true) { - session_cache_limiter('none'); // LbV §äȵ + // LbV §äȵ + session_cache_limiter('none'); - if ($session_name) { session_name($session_name); } - if ($session_id) { session_id($session_id); } + // ZbV¼¨æÑZbVIDðÝè + if ($session_name) { + session_name($session_name); + } + if ($session_id) { + session_id($session_id); + } + + // CookiegpÌÂÛɶÄinifBNeBuðÏX + if ($use_cookies) { + ini_set('session.use_cookies', 1); + ini_set('session.use_only_cookies', 1); + } else { + ini_set('session.use_cookies', 0); + ini_set('session.use_only_cookies', 0); + } + + // ZbVf[^ðú»·é session_start(); + // CookieªgpÅ«¸Asession.use_trans_sidªOffÌê + if (!$use_cookies && !ini_get('session.use_trans_sid')) { + $snm = session_name(); + $sid = session_id(); + output_add_rewrite_var($snm, $sid); + $GLOBALS['_conf']['sid_at_a'] = '&' . rawurlencode($snm) . '=' . rawurlencode($sid); + } + /* Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Modified: p2ex/trunk/subject.php =================================================================== --- p2ex/trunk/subject.php 2010-01-03 15:25:24 UTC (rev 764) +++ p2ex/trunk/subject.php 2010-01-05 12:50:04 UTC (rev 765) @@ -9,6 +9,7 @@ require_once './conf/conf.inc.php'; require_once P2_LIB_DIR . '/Thread.php'; require_once P2_LIB_DIR . '/ThreadList.php'; +require_once P2_LIB_DIR . '/NgAbornCtl.php'; //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('HEAD'); @@ -40,6 +41,19 @@ p2die('KvÈøªwè³êĢܹñ'); } +if ($spmode) { + $aborn_threads = null; +} else { + $aborn_threads = NgAbornCtl::loadAbornThreads(); + if (!is_array($aborn_threads) || + !array_key_exists('data', $aborn_threads) || + !is_array($aborn_threads['data']) || + count($aborn_threads['data']) == 0) + { + $aborn_threads = null; + } +} + // }}} // {{{ p2_setting, sb_keys Ýè @@ -489,15 +503,23 @@ //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('word_filter_for_sb'); // }}} - // {{{ ¡Xbh Ú[ñ`FbN + // {{{ Xbh Ú[ñ`FbN //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('taborn_check_continue'); - if ($aThreadList->spmode != "taborn" && !empty($ta_keys[$aThread->key])) { + if ($aThreadList->spmode != 'taborn' && !empty($ta_keys[$aThread->key])) { unset($ta_keys[$aThread->key]); //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('taborn_check_continue'); - continue; // Ú[ñXÍXLbv + continue; // ÂÊ Ú[ñXbhÍXLbv } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('taborn_check_continue'); + //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('ttitle_aborn_check_continue'); + if ($aborn_threads !== null && checkThreadTitleAborn($aborn_threads, $aThread)) { + unset($ta_keys[$aThread->key]); + $GLOBALS['ngaborns_hits']['aborn_thread']++; + //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ttitle_aborn_check_continue'); + continue; // ^Cgª Ú[ñ[hÉ}b`µ½XbhàXLbv + } + //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ttitle_aborn_check_continue'); // }}} @@ -858,6 +880,11 @@ } } +// Xbh^Cg Ú[ñL^ +if ($aborn_threads !== null) { + NgAbornCtl::saveAbornThreads($aborn_threads); +} + //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('FOOT'); // ±±ÜÅ @@ -1074,8 +1101,81 @@ } // }}} +// {{{ checkThreadTitleAborn() + +/** + * Xbh^Cg Ú[ñÌØð·é + * + * @param array &$aborn_threads + * @param Thread $aThread + * @return bool + */ +function checkThreadTitleAborn(array &$aborn_threads, Thread $aThread) +{ + $bbs = $aThread->bbs; + $subject = $aThread->ttitle; + + foreach ($aborn_threads['data'] as $k => $v) { + // Â`FbN + if (isset($v['bbs']) && in_array($bbs, $v['bbs']) == false) { + continue; + } + + // [h`FbN + // ³K\» + if ($v['regex']) { + $re_method = $v['regex']; + /*if ($re_method($v['word'], $subject, $matches)) { + updateThreadTitleAborn($aborn_threads, $k); + return true; + }*/ + if ($re_method($v['word'], $subject)) { + updateThreadTitleAborn($aborn_threads, $k); + return true; + } + // 嶬¶ð³ + } elseif ($v['ignorecase']) { + if (stripos($subject, $v['word']) !== false) { + updateThreadTitleAborn($aborn_threads, $k); + return true; + } + // PɶñªÜÜêé©Ç¤©ð`FbN + } else { + if (strpos($subject, $v['word']) !== false) { + updateThreadTitleAborn($aborn_threads, $k); + return true; + } + } + } + + return false; +} + // }}} +// {{{ updateThreadTitleAborn() +/** + * Xbh^Cg Ú[ñÅIqbgúÆñðXV + * + * @param array &$aborn_threads + * @param int $idx + * @return void + */ +function updateThreadTitleAborn(array &$aborn_threads, $idx) +{ + if (array_key_exists($idx, $aborn_threads['data'])) { + $aborn_threads['data'][$idx]['lasttime'] = date('Y/m/d G:i'); // HITÔðXV + if (empty($aborn_threads['data'][$idx]['hits'])) { + $aborn_threads['data'][$idx]['hits'] = 1; // HIT + } else { + $aborn_threads['data'][$idx]['hits']++; // HITñðXV + } + } +} + +// }}} +// }}} + /* * Local Variables: * mode: php