svnno****@sourc*****
svnno****@sourc*****
2010年 1月 17日 (日) 18:10:54 JST
Revision: 790 http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=790 Author: rsk Date: 2010-01-17 18:10:54 +0900 (Sun, 17 Jan 2010) Log Message: ----------- expack: - rev.100117.0000. (移è¡ã¹ã¯ãªããã®ãã¹ãç¨ã®ä»®ãã¼ã¸ã§ã³) - ã¾ã¨ãèªã¿ãã£ãã·ã¥ãP2KeyValueStoreã§ç®¡çããããã«ããã -- è¨å®ç®¡çã§ã¾ã¨ãèªã¿ãã£ãã·ã¥ã®ã¿ã¤ãã«ãå«ã¾ããã¹ã¬ããã åç §ã§ããããã«ãªã£ãã -- ã¾ã¨ãèªã¿ã®ãã£ãã·ã¥ãæ®ãæ°ã®å®ç¾© ($_conf['matome_cache_max']) ã conf/conf.inc.php ãã onf/conf_admin.inc.php ã«ç§»ããã - URL-safe Base64å¤æã¡ã½ãããP2Utilã¯ã©ã¹ããUrlSafeBase64ã¯ã©ã¹ã«ç§»ããã - ImageCache2ã¤ã³ã¹ãã¼ã©ã¼ãä¿®æ£ã - ãã®ä»ãå é¨çãªå¤æ´ã¨ãã°ä¿®æ£ãããã¤ãã Modified Paths: -------------- p2ex/trunk/conf/conf.inc.php p2ex/trunk/conf/conf_admin.inc.php p2ex/trunk/conf/setup_info.php p2ex/trunk/doc/ImageCache2/ic2_install.phps p2ex/trunk/editpref.php p2ex/trunk/ic2_manager.php p2ex/trunk/index.php p2ex/trunk/iv2.php p2ex/trunk/js/motolspopup.js p2ex/trunk/js/respopup.js p2ex/trunk/lib/P2DataStore/AbstractDataStore.php p2ex/trunk/lib/P2DataStore/CookieDataStore.php p2ex/trunk/lib/P2DataStore/PostDataStore.php p2ex/trunk/lib/P2KeyValueStore.php p2ex/trunk/lib/P2Util.php p2ex/trunk/lib/UA.php p2ex/trunk/lib/bootstrap.php p2ex/trunk/lib/expack/ic2/templates/ic2mng.tpl.html p2ex/trunk/lib/startup.funcs.php p2ex/trunk/read_new.php p2ex/trunk/read_new_k.php p2ex/trunk/style/editpref_css.inc p2ex/trunk/style/iv2_css.inc p2ex/trunk/style/style_css.inc Added Paths: ----------- p2ex/trunk/js/editpref.js p2ex/trunk/lib/MatomeCache.php p2ex/trunk/lib/MatomeCacheList.php p2ex/trunk/lib/P2DataStore/MatomeCacheDataStore.php p2ex/trunk/lib/P2DataStore/MatomeCacheMetaDataStore.php p2ex/trunk/lib/P2KeyValueStore/Codec/Array.php p2ex/trunk/lib/P2KeyValueStore/Codec/ArrayShiftJIS.php p2ex/trunk/lib/UrlSafeBase64.php p2ex/trunk/read_new_cache.php Removed Paths: ------------- p2ex/trunk/lib/read_new.inc.php -------------- next part -------------- Modified: p2ex/trunk/conf/conf.inc.php =================================================================== --- p2ex/trunk/conf/conf.inc.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/conf/conf.inc.php 2010-01-17 09:10:54 UTC (rev 790) @@ -7,7 +7,7 @@ // o[Wîñ $_conf = array( 'p2version' => '1.7.29+1.8.x', // rep2Ìo[W - 'p2expack' => '100113.1300', // g£pbNÌo[W + 'p2expack' => '100117.0000', // g£pbNÌo[W 'p2name' => 'expack', // rep2̼O ); @@ -225,6 +225,7 @@ $_conf['dat_dir'] = p2_realpath($_conf['dat_dir']); $_conf['idx_dir'] = p2_realpath($_conf['idx_dir']); $_conf['pref_dir'] = p2_realpath($_conf['pref_dir']); + $_conf['db_dir'] = p2_realpath($_conf['db_dir']); // ÇpÛ¶fBNg $_conf['admin_dir'] = $_conf['data_dir'] . '/admin'; @@ -282,16 +283,13 @@ $_conf[$k] = $_conf['pref_dir'] . '/' . $v; } - $_conf['matome_cache_path'] = $_conf['pref_dir'] . '/matome_cache'; - $_conf['matome_cache_ext'] = '.htm'; - $_conf['matome_cache_max'] = 3; // \õLbV Ì - $_conf['orig_favita_brd'] = $_conf['favita_brd']; $_conf['orig_favlist_idx'] = $_conf['favlist_idx']; $_conf['cookie_db_path'] = $_conf['db_dir'] . '/p2_cookies.sqlite3'; $_conf['post_db_path'] = $_conf['db_dir'] . '/p2_post_data.sqlite3'; $_conf['hostcheck_db_path'] = $_conf['db_dir'] . '/p2_hostcheck_cache.sqlite3'; + $_conf['matome_db_path'] = $_conf['db_dir'] . '/p2_matome_cache.sqlite3'; $_conf['iv2_cache_db_path'] = $_conf['db_dir'] . '/iv2_cache.sqlite3'; // â³ Modified: p2ex/trunk/conf/conf_admin.inc.php =================================================================== --- p2ex/trunk/conf/conf_admin.inc.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/conf/conf_admin.inc.php 2010-01-17 09:10:54 UTC (rev 790) @@ -98,6 +98,9 @@ // OñOCîñð\¦i·é:1, µÈ¢:0j $_conf['last_login_log_show'] = 1; // (1) +// V ÜÆßÇÝÌLbV ðc· (³ø:0, ³À:-1) +$_conf['matome_cache_max'] = 5; // (5) + // }}} // ---------------------------------------------------------------------- // {{{ p[~bV Modified: p2ex/trunk/conf/setup_info.php =================================================================== --- p2ex/trunk/conf/setup_info.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/conf/setup_info.php 2010-01-17 09:10:54 UTC (rev 790) @@ -39,6 +39,7 @@ // lÍ "yymmdd.hhmm" `®Åj[N©Â¸É\[g³êĢȯêÎÈçÈ¢ $p2_changed_versions = array( '100113.1300', + '100117.0000', ); /* Modified: p2ex/trunk/doc/ImageCache2/ic2_install.phps =================================================================== --- p2ex/trunk/doc/ImageCache2/ic2_install.phps 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/doc/ImageCache2/ic2_install.phps 2010-01-17 09:10:54 UTC (rev 790) @@ -27,10 +27,7 @@ require_once 'HTML/Template/Flexy.php'; require_once 'HTML/Template/Flexy/Element.php'; require_once 'Validate.php'; -require_once P2EX_LIB_DIR . '/ic2/findexec.inc.php'; -require_once P2EX_LIB_DIR . '/ic2/DataObject/Images.php'; -require_once P2EX_LIB_DIR . '/ic2/Thumbnailer.php'; -require_once P2EX_LIB_DIR . '/ic2/loadconfig.inc.php'; +require_once P2EX_LIB_DIR . '/ic2/bootstrap.php'; // Ýèt@CÇÝÝ $ini = ic2_loadconfig(); @@ -77,12 +74,11 @@ $table_extra_defs = ''; break; case 'sqlite': -case 'sqlite3': $serial = 'INTEGER PRIMARY KEY'; $table_extra_defs = ''; break; default: - die('MySQL, PostgreSQL, SQLite2, SQLite3ÈOÌf[^x[XÉÍεĢܹñB'); + die('MySQL, PostgreSQL, SQLite2ÈOÌf[^x[XÉÍεĢܹñB'); } // e[u¼ÍÝèÉæÁÄÍDBÌ\ñêªgíêé©àµêÈ¢ÌÅDB_xxx::quoteIdentifier()Å Modified: p2ex/trunk/editpref.php =================================================================== --- p2ex/trunk/editpref.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/editpref.php 2010-01-17 09:10:54 UTC (rev 790) @@ -30,7 +30,7 @@ if ($_conf['expack.misc.multi_favs']) { $sync_boards[] = $_conf['orig_favita_brd']; for ($i = 1; $i <= $_conf['expack.misc.favset_num']; $i++) { - $sync_boards[] = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . sprintf('p2_favita%d.brd', $i); + $sync_boards[] = sprintf('%s/p2_favita%d.brd', $_conf['pref_dir'], $i); } } else { $sync_boards[] = $_conf['favita_brd']; @@ -40,7 +40,7 @@ if ($_conf['expack.misc.multi_favs']) { $sync_indexes[] = $_conf['orig_favlist_idx']; for ($i = 1; $i <= $_conf['expack.misc.favset_num']; $i++) { - $sync_indexes[] = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . sprintf('p2_favlist%d.idx', $i); + $sync_indexes[] = sprintf('%s/p2_favlist%d.idx', $_conf['pref_dir'], $i); } } else { $sync_indexes[] = $_conf['favlist_idx']; @@ -60,8 +60,8 @@ $sync_boards[] = $_conf['orig_favita_brd']; $sync_indexes[] = $_conf['orig_favlist_idx']; for ($i = 1; $i <= $_conf['expack.misc.favset_num']; $i++) { - $sync_boards[] = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . sprintf('p2_favita%d.brd', $i); - $sync_indexes[] = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . sprintf('p2_favlist%d.idx', $i); + $sync_boards[] = sprintf('%s/p2_favita%d.brd', $_conf['pref_dir'], $i); + $sync_indexes[] = sprintf('%s/p2_favlist%d.idx', $_conf['pref_dir'], $i); } } else { $sync_boards[] = $_conf['favita_brd']; @@ -133,10 +133,13 @@ if (!$_conf['ktai']) { echo <<<EOP - <script type="text/javascript" src="js/changeskin.js?{$_conf['p2_version_id']}"></script> <link rel="stylesheet" type="text/css" href="css.php?css=style&skin={$skin_en}"> <link rel="stylesheet" type="text/css" href="css.php?css=editpref&skin={$skin_en}"> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">\n + <script type="text/javascript" src="js/basic.js?{$_conf['p2_version_id']}"></script> + <script type="text/javascript" src="js/changeskin.js?{$_conf['p2_version_id']}"></script> + <script type="text/javascript" src="js/respopup.js?{$_conf['p2_version_id']}"></script> + <script type="text/javascript" src="js/editpref.js?{$_conf['p2_version_id']}"></script>\n EOP; $body_at = ' onload="window.top.document.title=window.self.document.title;"'; } elseif (!$_conf['iphone']) { @@ -304,13 +307,12 @@ } // }}} - - echo "</table>\n"; } // gÑp\¦ if ($_conf['ktai']) { echo <<<EOP +<hr> <p>±ÎÞÝ/NGÜ°ÄÞÒW</p> <form method="GET" action="edit_aborn_word.php"> {$_conf['k_input_ht']} @@ -332,6 +334,7 @@ <input type="hidden" name="file" value="{$aborn_res_txt}"> <input type="submit" value="±ÎÞÝÚ½ÒW"> </form> +<hr> EOP; echo "<p>νÄ̯úi2chÌÂÚ]Éεܷj</p>\n"; echo getSyncFavoritesFormHt('all', '·×Ä'); @@ -363,39 +366,92 @@ // {{{ V ÜÆßÇÝÌLbV \¦ -$max = $_conf['matome_cache_max']; +$matome_cache_list = MatomeCacheList::getList(); +if ($matome_cache_list) { + $ckeyprefixlen = strlen(MatomeCacheList::getKeyPrefix()); + $i = 0; -if ($_conf['ktai']) { - $ext = '.k' . $_conf['matome_cache_ext']; -} else { - $ext = $_conf['matome_cache_ext']; -} + if ($_conf['ktai']) { + echo "<hr>\n<p>V ÜÆßÇÝLbV </p>\n"; + } else { + echo "<tr><td colspan=\"2\">\n"; + echo "<fieldset>\n<legend>V ÜÆßÇÝLbV </legend>\n"; + } -for ($i = 0; $i <= $max; $i++) { - $dnum = ($i) ? '.'.$i : ''; - $ai = '&cnum=' . $i; - $file = $_conf['matome_cache_path'] . $dnum . $ext; - //echo '<!-- '.$file.' -->'; - if (file_exists($file)) { - $filemtime = filemtime($file); - $date = date('Y/m/d G:i:s', $filemtime); - $kib = round(filesize($file) / 1024, 0); - $url = 'read_new.php?cview=1' . $ai . '&filemtime=' . $filemtime . $_conf['k_at_a']; - $links[] = '<a href="' . $url . '" target="read">' . $date . '</a> ' . $kib . 'KiB'; + echo "<ul id=\"matome_cache\">\n"; + + foreach ($matome_cache_list as $cache_key => $cache_info) { + echo '<li>'; + + $i++; + $ckey = substr($cache_key, $ckeyprefixlen); + $clink = 'read_new_cache.php?ckey=' . rawurlencode($ckey) . $_conf['k_at_a']; + if ($cache_info['title']) { + $ctitle = $cache_info['title']; + } else { + $ctitle = $ckey; + } + $cnumthreads = count($cache_info['threads']); + + if ($_conf['ktai']) { + $cdate = date('y/m/d G:i', $cache_info['time']); + echo "{$cdate}<br><a href=\"{$clink}\">{$ctitle}</a>"; + } else { + $cid = 'matome_cache_meta' . $i; + $cdate = date('Y/m/d H:i:s', $cache_info['time']); + if ($cnumthreads) { + $cpopup_at = " onmouseover=\"showCacheMetaData('{$cid}', event)\""; + $cpopup_at .= " onmouseout=\"hideCacheMetaData('{$cid}')\""; + } else { + $cpopup_at = ''; + } + echo "<span class=\"matome_cache_date\">{$cdate}</span> "; + echo "[<a href=\"{$clink}\" target=\"read\"{$cpopup_at}>{$ctitle}</a>]"; + if ($cnumthreads) { + echo "<div class=\"popup_element\" id=\"{$cid}\"{$cpopup_at}>"; + } + } + + if ($cnumthreads) { + if ($_conf['ktai']) { + $ctarget_at = ''; + } else { + $ctarget_at = ' target="read"'; + } + + echo '<ul>'; + foreach ($cache_info['threads'] as $cthread) { + $cthreadlink = $_conf['read_php'] + . '?host=' . rawurlencode($cthread['host']) + . '&bbs=' . rawurlencode($cthread['bbs']) + . '&key=' . rawurlencode($cthread['key']) + . '&ls=' . rawurlencode($cthread['ls']) + . '&offline=true' . $_conf['k_at_a']; + echo "<li><a href=\"{$cthreadlink}\"{$ctarget_at}>{$cthread['title']}</a></li>"; + } + echo '</ul>'; + + if (!$_conf['ktai']) { + echo '</div>'; + } + } + + echo "</li>\n"; } -} -if (!empty($links)) { - if ($_conf['ktai']) { - echo '<hr>'."\n"; + + echo "</ul>\n"; + if (!$_conf['ktai']) { + echo "</fieldset>\n"; + echo "</td></tr>\n"; } - echo $htm['matome'] = '<p>V ÜÆßÇÝÌOñLbV ð\¦<br>' . implode('<br>', $links) . '</p>'; } // }}} -// gÑptb^ if ($_conf['ktai']) { echo "<hr><div class=\"center\">{$_conf['k_to_index_ht']}</div>"; +} else { + echo "</table>\n"; } echo '</body></html>'; @@ -418,7 +474,7 @@ { global $_conf; - $path = $_conf['pref_dir'] . DIRECTORY_SEPARATOR . $filename; + $path = $_conf['pref_dir'] . '/' . $filename; if ((file_exists($path) && is_writable($path)) || (!file_exists($path) && is_writable(dirname($path))) Modified: p2ex/trunk/ic2_manager.php =================================================================== --- p2ex/trunk/ic2_manager.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/ic2_manager.php 2010-01-17 09:10:54 UTC (rev 790) @@ -24,6 +24,11 @@ // ÝèÇÝÝ $ini = ic2_loadconfig(); +if ($ini['Viewer']['cache'] && file_exists($_conf['iv2_cache_db_path'])) { + $viewer_cache_exists = true; +} else { + $viewer_cache_exists = false; +} // f[^x[XÉÚ± $db = DB::connect($ini['General']['dsn']); @@ -48,11 +53,14 @@ if (isset($_POST['action'])) { switch ($_POST['action']) { + // æðí·é case 'dropZero': case 'dropAborn': if ($_POST['action'] == 'dropZero') { + // N=0 Ìæðí·é $where = $db->quoteIdentifier('rank') . ' = 0'; if (isset($_POST['dropZeroLimit'])) { + // æ¾µ½úÔðÀè switch ($_POST['dropZeroSelectTime']) { case '24hours': $expires = 86400; break; case 'aday': $expires = 86400; break; @@ -69,8 +77,10 @@ time() - $expires); } } + // ubNXgÉo^·é $to_blacklist = !empty($_POST['dropZeroToBlackList']); } else { + // Ú[ñæðíµAubNXgÉo^·é $where = $db->quoteIdentifier('rank') . ' < 0'; $to_blacklist = TRUE; } @@ -89,6 +99,7 @@ $flexy->setData('toBlackList', $to_blacklist); break; + // PCpÈOÌì¬ÏÝTlCðÁ·é case 'clearThumb': $thumb_dir2 = $ini['General']['cachedir'] . '/' . $ini['Thumb2']['name']; $thumb_dir3 = $ini['General']['cachedir'] . '/' . $ini['Thumb3']['name']; @@ -104,8 +115,10 @@ } break; + // ê\¦pÌf[^LbV ðÁ·é case 'clearCache': - if (file_exists($_conf['iv2_cache_db_path'])) { + // ê\¦pf[^LbV ðNA + if ($viewer_cache_exists) { $kvs = P2KeyValueStore::getStore($_conf['iv2_cache_db_path'], P2KeyValueStore::CODEC_SERIALIZING); if ($kvs->clear() === false) { @@ -114,16 +127,19 @@ $_info_msg_ht .= '<p>ê\¦pÌf[^LbV ðÁµÜµ½B</p>'; } } + + // RpCÏÝev[gðí $result_files = P2Util::garbageCollection($flexy->options['compileDir'], -1, '', '', TRUE); $removed_files = $result_files['successed']; if (!empty($result_files['failed'])) { - $_info_msg_ht .= '<p>ȺÌt@Cªíūܹñŵ½B</p>'; + $_info_msg_ht .= '<p>ȺÌRpCÏÝev[gªíūܹñŵ½B</p>'; $_info_msg_ht .= '<ul><li>'; $_info_msg_ht .= implode('</li><li>', array_map('htmlspecialchars', $result_files['failed'])); $_info_msg_ht .= '</li></ul>'; } break; + // G[OðÁ·é case 'clearErrorLog': $result = $db->query('DELETE FROM ' . $db->quoteIdentifier($ini['General']['error_table'])); if (DB::isError($result)) { @@ -133,6 +149,7 @@ } break; + // ubNXgðÁ·é case 'clearBlackList': $result = $db->query('DELETE FROM ' . $db->quoteIdentifier($ini['General']['blacklist_table'])); if (DB::isError($result)) { @@ -142,31 +159,33 @@ } break; - case 'vacuumDB': + // f[^x[XðÅK»·é + case 'optimizeDB': // SQLite2 ÌæLbV f[^x[XðVACUUM if ($db->dsn['phptype'] == 'sqlite') { $result = $db->query('VACUUM'); if (DB::isError($result)) { $_info_msg_ht .= $result->getMessage(); } else { - $_info_msg_ht .= '<p>æf[^x[Xð®µÜµ½B</p>'; + $_info_msg_ht .= '<p>æf[^x[XðÅK»µÜµ½B</p>'; } } - // SQLite3 Ìê\¦pf[^LbV ðVACUUM - if (file_exists($_conf['iv2_cache_db_path'])) { + // SQLite3 Ìê\¦pf[^LbV ðVACUUM,REINDX + if ($viewer_cache_exists) { $kvs = P2KeyValueStore::getStore($_conf['iv2_cache_db_path'], P2KeyValueStore::CODEC_SERIALIZING); - $kvs->vacuum(); + $kvs->optimize(); unset($kvs); - $_info_msg_ht .= '<p>ê\¦pÌf[^LbV ð®µÜµ½B</p>'; + $_info_msg_ht .= '<p>ê\¦pÌf[^LbV ðÅK»µÜµ½B</p>'; } break; + // ¢è`ÌNGXg default: - $_info_msg_ht .= '<p>s³ÈNG: ' . htmlspecialchars($_POST['action'], ENT_QUOTES) . '</p>'; + $_info_msg_ht .= '<p>¢è`ÌNGXgÅ·B</p>'; + } - } if (isset($removed_files)) { $flexy->setData('removedFiles', $removed_files); } @@ -183,6 +202,11 @@ $flexy->setData('doctype', $_conf['doctype']); $flexy->setData('extra_headers', $_conf['extra_headers_ht']); $flexy->setData('extra_headers_x', $_conf['extra_headers_xht']); +if ($db->dsn['phptype'] == 'sqlite' || $viewer_cache_exists) { + $flexy->setData('enable_optimize_db', true); +} else { + $flexy->setData('enable_optimize_db', false); +} P2Util::header_nocache(); $flexy->compile('ic2mng.tpl.html'); Modified: p2ex/trunk/index.php =================================================================== --- p2ex/trunk/index.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/index.php 2010-01-17 09:10:54 UTC (rev 790) @@ -18,10 +18,21 @@ // O //============================================================= // ANZXÛpÌ.htaccessðf[^fBNgÉ쬷é -makeDenyHtaccess($_conf['pref_dir']); -makeDenyHtaccess($_conf['dat_dir']); -makeDenyHtaccess($_conf['idx_dir']); -makeDenyHtaccess($_conf['db_dir']); +$secret_dirs = array_unique(array( + $_conf['pref_dir'], + $_conf['dat_dir'], + $_conf['idx_dir'], + $_conf['db_dir'], + $_conf['admin_dir'], + $_conf['cache_dir'], + $_conf['cookie_dir'], + $_conf['compile_dir'], + $_conf['session_dir'], + $_conf['tmp_dir'], +)); +foreach ($secret_dirs as $dir) { + makeDenyHtaccess($dir); +} //============================================================= @@ -89,11 +100,10 @@ // PCp HTMLvg //====================================================== //P2Util::header_nocache(); - if ($_conf['doctype']) { - echo str_replace( - array('Transitional', 'loose.dtd'), - array('Frameset', 'frameset.dtd'), - $_conf['doctype']); + if ($_conf['doctype']) { + echo str_replace(array('Transitional', 'loose.dtd'), + array('Frameset', 'frameset.dtd'), + $_conf['doctype']); } echo <<<EOHEADER <html lang="ja"> @@ -148,6 +158,9 @@ { $hta = $dir . '/.htaccess'; if (!file_exists($hta)) { + if (!is_dir($dir)) { + FileCtl::mkdir_for($hta); + } $data = 'Order allow,deny'."\n".'Deny from all'."\n"; FileCtl::file_write_contents($hta, $data); } Modified: p2ex/trunk/iv2.php =================================================================== --- p2ex/trunk/iv2.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/iv2.php 2010-01-17 09:10:54 UTC (rev 790) @@ -174,19 +174,19 @@ } else { $cache_clear = false; } - $do_vacuum = false; + $optimize_db = false; if ($cache_clear == 'all') { $kvs->clear(); - $do_vacuum = true; + $optimize_db = true; } elseif ($cache_clear == 'gc') { $kvs->gc($cache_lifetime); - $do_vacuum = true; + $optimize_db = true; } - if ($do_vacuum) { - // LbV ðVACUUM - $kvs->vacuum(); + if ($optimize_db) { + // LbV ðVACUUM,REINDEX + $kvs->optimize(); // SQLiteÈçVACUUMðÀs if ($db_class == 'db_sqlite') { @@ -931,6 +931,16 @@ no_loop: false, no_updown: false }; +p2BindReady(function(){ + var toolbar = document.getElementById('toolbar'); + var toolbarHeight = getCurrentStyle(toolbar).height; + if (toolbarHeight == 'auto') { + toolbarHeight = toolbar.clientHeight; + } else { + toolbarHeight = parsePixels(toolbarHeight); + } + document.getElementById('header').style.height = toolbarHeight + 'px'; +}, null); // ]]> </script>\n EOJS; Added: p2ex/trunk/js/editpref.js =================================================================== --- p2ex/trunk/js/editpref.js (rev 0) +++ p2ex/trunk/js/editpref.js 2010-01-17 09:10:54 UTC (rev 790) @@ -0,0 +1,87 @@ +/** + * rep2expack - ÝèÇy[WpJavaScript + */ + +// {{{ globals + +var _EDITPREF_ACTIVEDIVID = null; + +// }}} +// {{{ showCacheMetaData() + +/** + * ÜÆßÇÝLbV Ì^f[^ð|bvAbv\¦·é + */ +function showCacheMetaData(divID, event) { + var popup = document.getElementById(divID); + if (!popup) { + reutrn; + } + + if (_EDITPREF_ACTIVEDIVID != divID) { + if (_EDITPREF_ACTIVEDIVID) { + // xȵÅ|bvAbvðB· + doHideResPopUp(_EDITPREF_ACTIVEDIVID); + } + _EDITPREF_ACTIVEDIVID = divID; + setCacheMetaDataPopUpHeight(popup); + } else if (popup.style.visibility != 'visible') { + setCacheMetaDataPopUpHeight(popup); + } + + showResPopUp(divID, event); +} + +// }}} +// {{{ hideCacheMetaData() + +/** + * ÜÆßÇÝLbV Ì^f[^ðB· + */ +function hideCacheMetaData(divID) { + hideResPopUp(divID); +} + +// }}} +// {{{ setCacheMetaDataPopUpHeight() + +/** + * |bvAbv̳𲮷é + */ +function setCacheMetaDataPopUpHeight(popup) +{ + var popupHeight, windowHeight; + + windowHeight = getWindowHeight(); + popup.style.height = 'auto'; + popup.style.overflow = 'visible'; + popupHeight = getCurrentStyle(popup).height; + if (popupHeight == 'auto') { + popupHeight = popup.clientHeight; + } else { + popupHeight = parsePixels(popupHeight); + } + + if (popupHeight > windowHeight) { + if (windowHeight > 50) { + popupHeight = windowHeight - 20; + } else { + popupHeight = windowHeight; + } + popup.style.height = popupHeight + 'px'; + popup.style.overflow = 'auto'; + } +} + +// }}} + +/* + * Local Variables: + * mode: javascript + * coding: cp932 + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode: t + * End: + */ +/* vim: set syn=javascript fenc=cp932 ai noet ts=4 sw=4 sts=4 fdm=marker: */ Modified: p2ex/trunk/js/motolspopup.js =================================================================== --- p2ex/trunk/js/motolspopup.js 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/js/motolspopup.js 2010-01-17 09:10:54 UTC (rev 790) @@ -39,7 +39,19 @@ title = ''; } - target = origin.hasAttribute('target') ? origin.getAttribute('target') : null; + if (typeof origin.hasAttribute == 'function') { + if (origin.hasAttribute('target')) { + target = origin.getAttribute('target'); + } else { + target = null; + } + } else { + target = origin.getAttribute('target'); + } + if (target && !target.length) { + target = null; + } + baseUrl = origin.getAttribute('href'); for (i = 0; i < l; i++) { anchor = div.childNodes[i]; Modified: p2ex/trunk/js/respopup.js =================================================================== --- p2ex/trunk/js/respopup.js 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/js/respopup.js 2010-01-17 09:10:54 UTC (rev 790) @@ -195,6 +195,9 @@ var y_adjust = -10; // y²Êu²® if (this.divID.indexOf('spm_') == 0) { y_adjust = -10; + } else if (this.divID.indexOf('matome_cache_meta') == 0) { + x_adjust += 10; + y_adjust += 10; } if (this.popOBJ.style.visibility != "visible") { this.popOBJ.style.zIndex = this.zNum; Added: p2ex/trunk/lib/MatomeCache.php =================================================================== --- p2ex/trunk/lib/MatomeCache.php (rev 0) +++ p2ex/trunk/lib/MatomeCache.php 2010-01-17 09:10:54 UTC (rev 790) @@ -0,0 +1,144 @@ +<?php + +// {{{ MatomeCache + +/** + * ÜÆßÇÝLbV f[^NX + */ +class MatomeCache +{ + // {{{ properties + + /** + * ÜÆßÇÝÌàe (HTML) + * + * @var string + */ + private $_content; + + /** + * ÜÆßÇÝÌ^f[^ + * + * @var array + */ + private $_metaData; + + /** + * ÜÆßÇÝLbV ðc· + * + * @var int + */ + private $_maxNumEntries; + + /** + * ÜÆßÇÝLbV ªLø©Ç¤© + * + * @var bool + */ + private $_enabled; + + // }}} + // {{{ __construct() + + /** + * RXgN^ + * + * àeðú»µAL[ðæ¾·éB + * + * @param string $title + * @param int $maxNumEntries + */ + public function __construct($title, $maxNumEntries = -1) + { + $this->_content = ''; + $this->_metaData = array( + 'time' => time(), + 'title' => $title, + 'threads' => array(), + 'size' => null, + ); + $this->_maxNumEntries = $maxNumEntries; + if ($maxNumEntries == 0) { + $this->_enabled = false; + } else { + $this->_enabled = true; + } + } + + // }}} + // {{{ __destruct() + + /** + * fXgN^ + * + * àeðÛ¶µAâLbV ðí·éB + * XbhîñªóÌêÍV XȵÆÝȵAÛ¶µÈ¢B + * + * @param void + */ + public function __destruct() + { + if ($this->_enabled && count($this->_metaData['threads'])) { + $this->_metaData['size'] = strlen($this->_content); + MatomeCacheList::add($this->_content, $this->_metaData); + if ($this->_maxNumEntries > 0) { + MatomeCacheList::trim($this->_maxNumEntries); + } + } + } + + // }}} + // {{{ concat() + + /** + * àeðÇÁ·é + * + * @param string $content + * @return void + */ + public function concat($content) + { + if ($this->_enabled) { + $this->_content .= $content; + } + } + + // }}} + // {{{ addReadThread() + + /** + * ÜÆßÇÝÉÜÜêéXbhîñðÇÁ·é + * + * @param ThreadRead $aThread + * @return void + */ + public function addReadThread(ThreadRead $aThread) + { + if ($this->_enabled) { + $this->_metaData['threads'][] = array( + 'title' => $aThread->ttitle_hd, + 'host'=> $aThread->host, + 'bbs'=> $aThread->bbs, + 'key'=> $aThread->key, + 'ls' => sprintf('%d-%dn', + $aThread->resrange['start'], + $aThread->resrange['to']), + ); + } + } + + // }}} +} + +// }}} + +/* + * 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: Added: p2ex/trunk/lib/MatomeCacheList.php =================================================================== --- p2ex/trunk/lib/MatomeCacheList.php (rev 0) +++ p2ex/trunk/lib/MatomeCacheList.php 2010-01-17 09:10:54 UTC (rev 790) @@ -0,0 +1,176 @@ +<?php + +// {{{ MatomeCacheList + +/** + * ÜÆßÇÝLbV XgNX + */ +class MatomeCacheList +{ + // {{{ add() + + /** + * Vµ¢GgðÇÁ·é + * + * @param string $content + * @param array $metaData + * @return $key + */ + static public function add($content, array $metaData) + { + $key = sprintf('%s%0.6f', self::getKeyPrefix(), microtime(true)); + MatomeCacheDataStore::set($key, $content); + MatomeCacheMetaDataStore::set($key, $metaData); + return $key; + } + + // }}} + // {{{ getKeyPrefix() + + /** + * L[Úª«ðæ¾·é + * + * @param string $type + * @param bool $forSearch + * @return array + */ + static public function getKeyPrefix($type = null) + { + global $_conf, $_login; + + if ($type === null) { + if ($_conf['iphone']) { + $type = 'iphone'; + } elseif ($_conf['ktai']) { + $type = 'ktai'; + } else { + $type = 'pc'; + } + } + + return $_login->user_u . '/' . $type . '/'; + } + + // }}} + // {{{ getList() + + /** + * ÜÆßÇÝLbV ÌXgðæ¾·é + * + * @param string $type + * @return array + */ + static public function getList($type = null) + { + $prefix = self::getKeyPrefix($type); + $orderBy = array('mtime' => 'DESC', 'key' => 'DESC'); + + return MatomeCacheMetaDataStore::getKVS()->getAll($prefix, $orderBy); + } + + // }}} + // {{{ getAllList() + + /** + * SÜÆßÇÝLbV ÌXgðæ¾·é + * + * @param string $type + * @return array + */ + static public function getAllList() + { + $types = array('pc', 'ktai', 'iphone'); + $lists = array(); + foreach ($types as $type) { + $lists[$type] = self::getList($type); + } + return $list; + } + + // }}} + // {{{ trim() + + /** + * c·ðwèµÄLbV ðí·é + * + * @param int $number + * @return int + */ + static public function trim($length, $type = null) + { + // $lengthªÌêÍíµÈ¢ + if ($length < 0) { + return false; + } + + $prefix = self::getKeyPrefix($type); + + // $lengthª[ÌêÍSí + if ($length == 0) { + return self::clear($prefix); + } + + // XVÉ\[gµÄ$length+1ÔÚÌR[hðæ¾ + $kvs = MatomeCacheDataStore::getKVS(); + $orderBy = array('mtime' => 'DESC', 'key' => 'DESC'); + $result = $kvs->getAll($prefix, $orderBy, 1, $length, true); + if (empty($result)) { + return 0; + } + + $mtime = current($result)->mtime; + $query = 'DELETE FROM $__table WHERE ' + . P2KeyValueStore::C_KEY_BEGINS + . ' AND $__mtime <= :mtime'; + + // ©Â©Á½R[hÆA»êæèXVªÃ¢f[^ðí + $stmt = $kvs->prepare($query); + $kvs->bindValueForPrefixSearch($stmt, $prefix); + $stmt->bindValue(':mtime', $mtime, PDO::PARAM_INT); + if ($stmt->execute()) { + $numRemoved = $stmt->rowCount(); + } else { + return false; + } + + // ^f[^àí + $kvs = MatomeCacheMetaDataStore::getKVS(); + $stmt = $kvs->prepare($query); + $kvs->bindValueForPrefixSearch($stmt, $prefix); + $stmt->bindValue(':mtime', $mtime, PDO::PARAM_INT); + $stmt->execute(); + + // íµ½f[^ðÔ· + return $numRemoved; + } + + // }}} + // {{{ optimize() + + /** + * ÜÆßÇÝLbV ðÅK»·é + * + * @param void + * @return void + */ + static public function optimize() + { + MatomeCacheDataStore::getKVS()->optimize(); + MatomeCacheMetaDataStore::getKVS()->optimize(); + } + + // }}} +} + +// }}} + +/* + * 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/P2DataStore/AbstractDataStore.php =================================================================== --- p2ex/trunk/lib/P2DataStore/AbstractDataStore.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/lib/P2DataStore/AbstractDataStore.php 2010-01-17 09:10:54 UTC (rev 790) @@ -27,15 +27,17 @@ * f[^ðÛ¶·éP2KeyValueStoreIuWFNgðæ¾·é * * @param string $databasePath - * @param string $type + * @param string $codec + * @param string $tableName * @return P2KeyValueStore */ static protected function _getKVS($databasePath, - $type = P2KeyValueStore::CODEC_SERIALIZING) + $codec = P2KeyValueStore::CODEC_SERIALIZING, + $tableName = null) { global $_conf; - $id = $type . ':' . $databasePath; + $id = $codec . ':' . $databasePath; if (array_key_exists($id, self::$_kvs)) { return self::$_kvs[$id]; @@ -46,7 +48,7 @@ } try { - $kvs = P2KeyValueStore::getStore($databasePath, $type); + $kvs = P2KeyValueStore::getStore($databasePath, $codec, $tableName); self::$_kvs[$id] = $kvs; } catch (Exception $e) { p2die(get_class($e) . ': ' . $e->getMessage()); @@ -83,6 +85,7 @@ static public function get($key) { return self::getKVS()->get($key); + // static::getKVS() } // }}} @@ -101,6 +104,7 @@ static public function set($key, $value) { $kvs = self::getKVS(); + // static::getKVS() if ($kvs->exists($key)) { return $kvs->update($key, $value); } else { @@ -121,6 +125,7 @@ static public function delete($key) { return self::getKVS()->delete($key); + // static::getKVS() } // }}} @@ -135,25 +140,8 @@ */ static public function clear($prefix = null) { - $kvs = self::getKVS(); - - if ($prefix === null) { - return $kvs->clear(); - } - - $pattern = str_replace(array( '%', '_', '\\'), - array('\\%', '\\_', '\\\\'), - $kvs->encodeKey($prefix)); - $query = 'DELETE FROM $__table WHERE $__key LIKE :pattern ESCAPE :escape'; - $stmt = $kvs->prepare($query); - $stmt->bindValue(':pattern', $pattern); - $stmt->bindValue(':escape', '\\'); - - if ($stmt->execute()) { - return $stmt->rowCount(); - } else { - return false; - } + return self::getKVS()->clear($prefix); + // static::getKVS(); } // }}} Modified: p2ex/trunk/lib/P2DataStore/CookieDataStore.php =================================================================== --- p2ex/trunk/lib/P2DataStore/CookieDataStore.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/lib/P2DataStore/CookieDataStore.php 2010-01-17 09:10:54 UTC (rev 790) @@ -34,6 +34,7 @@ static public function get($key) { return self::getKVS()->get($key); + // static::getKVS() } // }}} @@ -52,6 +53,7 @@ static public function set($key, $value) { $kvs = self::getKVS(); + // static::getKVS() if ($kvs->exists($key)) { return $kvs->update($key, $value); } else { @@ -72,6 +74,7 @@ static public function delete($key) { return self::getKVS()->delete($key); + // static::getKVS() } // }}} @@ -86,25 +89,8 @@ */ static public function clear($prefix = null) { - $kvs = self::getKVS(); - - if ($prefix === null) { - return $kvs->clear(); - } - - $pattern = str_replace(array( '%', '_', '\\'), - array('\\%', '\\_', '\\\\'), - $kvs->encodeKey($prefix)); - $query = 'DELETE FROM $__table WHERE $__key LIKE :pattern ESCAPE :escape'; - $stmt = $kvs->prepare($query); - $stmt->bindValue(':pattern', $pattern); - $stmt->bindValue(':escape', '\\'); - - if ($stmt->execute()) { - return $stmt->rowCount(); - } else { - return false; - } + return self::getKVS()->clear($prefix); + // static::getKVS(); } // }}} Added: p2ex/trunk/lib/P2DataStore/MatomeCacheDataStore.php =================================================================== --- p2ex/trunk/lib/P2DataStore/MatomeCacheDataStore.php (rev 0) +++ p2ex/trunk/lib/P2DataStore/MatomeCacheDataStore.php 2010-01-17 09:10:54 UTC (rev 790) @@ -0,0 +1,112 @@ +<?php +/** + * rep2expack - V ÜÆßÇÝLbV ÇNX + */ + +// {{{ MatomeCacheDataStore + +class MatomeCacheDataStore extends AbstractDataStore +{ + // {{{ getKVS() + + /** + * «Ýf[^ðÛ¶·éP2KeyValueStoreIuWFNgðæ¾·é + * + * @param void + * @return P2KeyValueStore + */ + static public function getKVS() + { + return self::_getKVS($GLOBALS['_conf']['matome_db_path'], + P2KeyValueStore::CODEC_COMPRESSING); + } + + // }}} + // {{{ AbstractDataStore.php ©çÌRsy / PHP 5.3 ÌxÃI©ðgÁÄíµ½¢ + // {{{ get() + + /** + * f[^ðæ¾·é + * + * @param string $key + * @return mixed + * @see P2KeyValueStore::get() + */ + static public function get($key) + { + return self::getKVS()->get($key); + // static::getKVS() + } + + // }}} + // {{{ set() + + /** + * f[^ðÛ¶·é + * + * @param string $key + * @param mixed $value + * @return bool + * @see P2KeyValueStore::exists(), + * P2KeyValueStore::set(), + * P2KeyValueStore::update() + */ + static public function set($key, $value) + { + $kvs = self::getKVS(); + // static::getKVS() + if ($kvs->exists($key)) { + return $kvs->update($key, $value); + } else { + return $kvs->set($key, $value); + } + } + + // }}} + // {{{ delete() + + /** + * f[^ðí·é + * + * @param string $key + * @return bool + * @see P2KeyValueStore::delete() + */ + static public function delete($key) + { + return self::getKVS()->delete($key); + // static::getKVS() + } + + // }}} + // {{{ clear() + + /** + * ·×ÄÌf[^ܽÍL[ªwè³ê½Úª«ÅnÜéf[^ðí·é + * + * @param string $prefix + * @return int + * @see P2KeyValueStore::clear() + */ + static public function clear($prefix = null) + { + return self::getKVS()->clear($prefix); + // static::getKVS(); + } + + // }}} + // }}} Rsy±±ÜÅ +} + +// }}} + +/* + * 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: Added: p2ex/trunk/lib/P2DataStore/MatomeCacheMetaDataStore.php =================================================================== --- p2ex/trunk/lib/P2DataStore/MatomeCacheMetaDataStore.php (rev 0) +++ p2ex/trunk/lib/P2DataStore/MatomeCacheMetaDataStore.php 2010-01-17 09:10:54 UTC (rev 790) @@ -0,0 +1,112 @@ +<?php +/** + * rep2expack - V ÜÆßÇÝLbV Ì^f[^ÇNX + */ + +// {{{ MatomeCacheMetaDataStore + +class MatomeCacheMetaDataStore extends AbstractDataStore +{ + // {{{ getKVS() + + /** + * «Ýf[^ðÛ¶·éP2KeyValueStoreIuWFNgðæ¾·é + * + * @param void + * @return P2KeyValueStore + */ + static public function getKVS() + { + return self::_getKVS($GLOBALS['_conf']['matome_db_path'], + P2KeyValueStore::CODEC_ARRAYSHIFTJIS); + } + + // }}} + // {{{ AbstractDataStore.php ©çÌRsy / PHP 5.3 ÌxÃI©ðgÁÄíµ½¢ + // {{{ get() + + /** + * f[^ðæ¾·é + * + * @param string $key + * @return mixed + * @see P2KeyValueStore::get() + */ + static public function get($key) + { + return self::getKVS()->get($key); + // static::getKVS() + } + + // }}} + // {{{ set() + + /** + * f[^ðÛ¶·é + * + * @param string $key + * @param mixed $value + * @return bool + * @see P2KeyValueStore::exists(), + * P2KeyValueStore::set(), + * P2KeyValueStore::update() + */ + static public function set($key, $value) + { + $kvs = self::getKVS(); + // static::getKVS() + if ($kvs->exists($key)) { + return $kvs->update($key, $value); + } else { + return $kvs->set($key, $value); + } + } + + // }}} + // {{{ delete() + + /** + * f[^ðí·é + * + * @param string $key + * @return bool + * @see P2KeyValueStore::delete() + */ + static public function delete($key) + { + return self::getKVS()->delete($key); + // static::getKVS() + } + + // }}} + // {{{ clear() + + /** + * ·×ÄÌf[^ܽÍL[ªwè³ê½Úª«ÅnÜéf[^ðí·é + * + * @param string $prefix + * @return int + * @see P2KeyValueStore::clear() + */ + static public function clear($prefix = null) + { + return self::getKVS()->clear($prefix); + // static::getKVS(); + } + + // }}} + // }}} Rsy±±ÜÅ +} + +// }}} + +/* + * 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/P2DataStore/PostDataStore.php =================================================================== --- p2ex/trunk/lib/P2DataStore/PostDataStore.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/lib/P2DataStore/PostDataStore.php 2010-01-17 09:10:54 UTC (rev 790) @@ -34,6 +34,7 @@ static public function get($key) { return self::getKVS()->get($key); + // static::getKVS() } // }}} @@ -52,6 +53,7 @@ static public function set($key, $value) { $kvs = self::getKVS(); + // static::getKVS() if ($kvs->exists($key)) { return $kvs->update($key, $value); } else { @@ -72,6 +74,7 @@ static public function delete($key) { return self::getKVS()->delete($key); + // static::getKVS() } // }}} @@ -86,25 +89,8 @@ */ static public function clear($prefix = null) { - $kvs = self::getKVS(); - - if ($prefix === null) { - return $kvs->clear(); - } - - $pattern = str_replace(array( '%', '_', '\\'), - array('\\%', '\\_', '\\\\'), - $kvs->encodeKey($prefix)); - $query = 'DELETE FROM $__table WHERE $__key LIKE :pattern ESCAPE :escape'; - $stmt = $kvs->prepare($query); - $stmt->bindValue(':pattern', $pattern); - $stmt->bindValue(':escape', '\\'); - - if ($stmt->execute()) { - return $stmt->rowCount(); - } else { - return false; - } + return self::getKVS()->clear($prefix); + // static::getKVS(); } // }}} Added: p2ex/trunk/lib/P2KeyValueStore/Codec/Array.php =================================================================== --- p2ex/trunk/lib/P2KeyValueStore/Codec/Array.php (rev 0) +++ p2ex/trunk/lib/P2KeyValueStore/Codec/Array.php 2010-01-17 09:10:54 UTC (rev 790) @@ -0,0 +1,82 @@ +<?php + +// {{{ P2KeyValueStore_Codec_Array + +/** + * zñðVACYEAVACY·éCodec + * + * VACYãÌTCYª³kðKvÆ·éÙÇå«È¢êÉg¤B + * zñÌvfɶñðÜÞêAÃÈUTF-8V[PXÅȯêÎÈçÈ¢B + */ +class P2KeyValueStore_Codec_Array implements P2KeyValueStore_Codec_Interface +{ + // {{{ encodeKey() + + /** + * L[Í»ÌÜÜ + * + * @param string $key + * @return string + */ + public function encodeKey($key) + { + return $key; + } + + // }}} + // {{{ decodeKey() + + /** + * L[Í»ÌÜÜ + * + * @param string $key + * @return string + */ + public function decodeKey($key) + { + return $key; + } + + // }}} + // {{{ encodeValue() + + /** + * lðVACY·é + * + * @param array $array + * @return string + */ + public function encodeValue($array) + { + return serialize($array); + } + + // }}} + // {{{ decodeValue() + + /** + * lðAVACY·é + * + * @param string $value + * @return array + */ + public function decodeValue($value) + { + return unserialize($value); + } + + // }}} +} + +// }}} + +/* + * 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: Added: p2ex/trunk/lib/P2KeyValueStore/Codec/ArrayShiftJIS.php =================================================================== --- p2ex/trunk/lib/P2KeyValueStore/Codec/ArrayShiftJIS.php (rev 0) +++ p2ex/trunk/lib/P2KeyValueStore/Codec/ArrayShiftJIS.php 2010-01-17 09:10:54 UTC (rev 790) @@ -0,0 +1,58 @@ +<?php + +// {{{ P2KeyValueStore_Codec_ArrayShiftJIS + +/** + * zñðVACYEAVACY·éCodec + * + * VACYãÌTCYª³kðKvÆ·éÙÇå«È¢êÉg¤B + * zñÌvfÉÜÜêé¶ñÍÃÈShift_JISV[PXÅȯêÎÈç¸A + * L[Íl©US-ASCII¶ñÅ é±ÆðúÒ·éB + */ +class P2KeyValueStore_Codec_ArrayShiftJIS extends P2KeyValueStore_Codec_Array +{ + // {{{ encodeValue() + + /** + * lðVACY·é + * + * @param array $array + * @return string + */ + public function encodeValue($array) + { + mb_convert_variables('UTF-8', 'Shift_JIS', $array); + return parent::encodeValue($array); + } + + // }}} + // {{{ decodeValue() + + /** + * lðAVACY·é + * + * @param string $value + * @return array + */ + public function decodeValue($value) + { + $array = parent::decodeValue($value); + mb_convert_variables('SJIS-win', 'UTF-8', $array); + return $array; + } + + // }}} +} + +// }}} + +/* + * 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/P2KeyValueStore.php =================================================================== --- p2ex/trunk/lib/P2KeyValueStore.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/lib/P2KeyValueStore.php 2010-01-17 09:10:54 UTC (rev 790) @@ -34,11 +34,15 @@ const Q_CLEAR = 'DELETE FROM $__table'; const Q_GC = 'DELETE FROM $__table WHERE mtime < :expires'; + const C_KEY_BEGINS = 'arkey LIKE :pattern ESCAPE :escape'; + const CODEC_DEFAULT = 'P2KeyValueStore_Codec_Default'; const CODEC_BINARY = 'P2KeyValueStore_Codec_Binary'; const CODEC_COMPRESSING = 'P2KeyValueStore_Codec_Compressing'; const CODEC_SHIFTJIS = 'P2KeyValueStore_Codec_ShiftJIS'; const CODEC_SERIALIZING = 'P2KeyValueStore_Codec_Serializing'; + const CODEC_ARRAY = 'P2KeyValueStore_Codec_Array'; + const CODEC_ARRAYSHIFTJIS = 'P2KeyValueStore_Codec_ArrayShiftJIS'; const MEMORY_DATABASE = ':memory:'; @@ -101,10 +105,13 @@ * * @param string $fileName * @param string $codec + * @param string $tableName * @return P2KeyValueStore * @throws PDOException */ - static public function getStore($fileName, $codec = self::CODEC_DEFAULT) + static public function getStore($fileName, + $codec = self::CODEC_DEFAULT, + $tableName = null) { // IuWFNgIDÆe[u¼ðè if (is_object($codec)) { @@ -112,14 +119,20 @@ } else { $className = $codec; } + $lcName = strtolower($className); if (strpos($lcName, 'p2keyvaluestore_codec_') === 0) { $codecId = substr($lcName, 22); } else { $codecId = 'user_' . $lcName; } + $kvsId = $lcName . ':' . $fileName; - $tableName = 'kvs_' . $codecId; + if ($tableName === null) { + $tableName = 'kvs_' . $codecId; + } else { + $kvsId = strtolower($tableName) . ':' . $kvsId; + } // P2KeyValueStoreÌLbV ðmF if (array_key_exists($kvsId, self::$_kvsCache)) { @@ -131,6 +144,7 @@ $pdo = self::$_pdoCache[$fileName]; } else { $pdo = new PDO('sqlite:' . $fileName); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); self::$_pdoCache[$fileName] = $pdo; } @@ -237,14 +251,41 @@ */ public function prepare($query, $forwardOnly = true) { - return $this->_prepare(str_replace(array('$__key', '$__value'), - array( 'arkey', 'value'), - $query), - true, - $forwardOnly); + $mapping = array( + '$__key' => 'arkey', + '$__value' => 'value', + '$__mtime' => 'mtime', + '$__order' => 'sort_order', + ); + + $query = str_replace(array_keys($mapping), array_values($mapping), $query); + + return $this->_prepare($query, true, $forwardOnly); } // }}} + // {{{ bindValueForPrefixSearch() + + /** + * R[hðÚª«Åõ·éÛÌlðGXP[v&oCh·é + * + * @param PDOStatement $stmt + * @param string $prefix + * @param string $escape + * @return void + */ + public function bindValueForPrefixSearch(PDOStatement $stmt, + $prefix, + $escape = '\\') + { + $pattern = str_replace(array('%', '_', $escape), + array("{$escape}%", "{$escape}_", "{$escape}{$escape}"), + $this->_codec->encodeKey($prefix)) . '%'; + $stmt->bindValue(':pattern', $pattern); + $stmt->bindValue(':escape', $escape); + } + + // }}} // {{{ buildOrderBy() /** @@ -273,15 +314,11 @@ foreach ($orderBy as $column => $direction) { $column = strtolower($column); if (array_key_exists($column, $mapping)) { - $condition = $mapping[$column] . ' '; + $condition = $mapping[$column]; if (strcasecmp($direction, 'ASC') == 0) { - $condition .= 'ASC'; + $condition .= ' ASC'; } elseif (strcasecmp($direction, 'DESC') == 0) { - $condition .= 'DESC'; - } elseif (0 < (int)$direction) { - $condition .= 'ASC'; - } else { - $condition .= 'DESC'; + $condition .= ' DESC'; } } $terms[] = $condition; @@ -371,7 +408,7 @@ return null; } else { return array( - 'key' => $this->_codec->decodeKey($row->key), + 'key' => $this->_codec->decodeKey($row->arkey), 'value' => $this->_codec->decodeValue($row->value), ); } @@ -438,33 +475,43 @@ * SÄÌR[hðAzzñƵÄÔ· * LøúÀØêÌR[hðOµ½¢êÍOÉgc()µÄ¨±Æ * + * @param string $prefix * @param array $orderBy * @param int $limit * @param int $offset * @param bool $getRaw * @return array */ - public function getAll(array $orderBy = null, - $limit = null, $offset = null, + public function getAll($prefix = null, + array $orderBy = null, + $limit = null, + $offset = null, $getRaw = false) { - $query = self::Q_GETALL - . $this->buildOrderBy($orderBy) - . $this->buildLimit($limit, $offset); + $query = self::Q_GETALL; + if ($prefix !== null) { + $query .= ' WHERE ' . self::C_KEY_BEGINS; + } + $query.= $this->buildOrderBy($orderBy); + $query.= $this->buildLimit($limit, $offset); + $stmt = $this->_prepare($query, true); + if ($prefix !== null) { + $this->bindValueForPrefixSearch($stmt, $prefix); + } $stmt->execute(); $values = array(); if ($getRaw) { $stmt->setFetchMode(PDO::FETCH_CLASS, 'P2KeyValueStore_Result'); while ($row = $stmt->fetch()) { - $values[$this->_codec->decodeKey($row->key)] = $row; + $values[$this->_codec->decodeKey($row->arkey)] = $row; } } else { $stmt->setFetchMode(PDO::FETCH_INTO, $this->_sharedResult); while ($row = $stmt->fetch()) { $value = $this->_codec->decodeValue($row->value); - $values[$this->_codec->decodeKey($row->key)] = $value; + $values[$this->_codec->decodeKey($row->arkey)] = $value; } } @@ -479,17 +526,28 @@ * åƵÄP2KeyValueStore_IteratorÅg¤ * LøúÀØêÌR[hðOµ½¢êÍOÉgc()µÄ¨±Æ * + * @param string $prefix * @param array $orderBy * @param int $limit * @param int $offset * @return array */ - public function getIds(array $orderBy = null, $limit = null, $offset = null) + public function getIds($prefix = null, + array $orderBy = null, + $limit = null, + $offset = null) { - $query = self::Q_GETIDS - . $this->buildOrderBy($orderBy) - . $this->buildLimit($limit, $offset); + $query = self::Q_GETIDS; + if ($prefix !== null) { + $query .= ' WHERE ' . self::C_KEY_BEGINS; + } + $query.= $this->buildOrderBy($orderBy); + $query.= $this->buildLimit($limit, $offset); + $stmt = $this->_prepare($query, true); + if ($prefix !== null) { + $this->bindValueForPrefixSearch($stmt, $prefix); + } $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_COLUMN, 0); @@ -502,19 +560,30 @@ * SÄÌL[ÌzñðÔ· * LøúÀØêÌR[hðOµ½¢êÍOÉgc()µÄ¨±Æ * + * @param string $prefix * @param array $orderBy * @param int $limit * @param int $offset * @return array */ - public function getKeys(array $orderBy = null, $limit = null, $offset = null) + public function getKeys($prefix = null, + array $orderBy = null, + $limit = null, + $offset = null) { - $query = self::Q_GETKEYS - . $this->buildOrderBy($orderBy) - . $this->buildLimit($limit, $offset); + $query = self::Q_GETKEYS; + if ($prefix !== null) { + $query .= ' WHERE ' . self::C_KEY_BEGINS; + } + $query.= $this->buildOrderBy($orderBy); + $query.= $this->buildLimit($limit, $offset); + $stmt = $this->_prepare($query, true); + if ($prefix !== null) { + $this->bindValueForPrefixSearch($stmt, $prefix); + } + $stmt->execute(); $stmt->setFetchMode(PDO::FETCH_COLUMN, 0); - $stmt->execute(); $keys = array(); while (($key = $stmt->fetch()) !== false) { @@ -664,14 +733,23 @@ // {{{ clear() /** - * ·×ÄÌR[hðí·é + * ·×ÄÌR[hܽÍL[ªwè³ê½Úª«ÅnÜéR[hðí·é * - * @param void + * @param string $prefix * @return int */ - public function clear() + public function clear($prefix = null) { - $stmt = $this->_prepare(self::Q_CLEAR, true); + $query = self::Q_CLEAR; + if ($prefix !== null) { + $query .= ' WHERE ' . self::C_KEY_BEGINS; + } + + $stmt = $this->_prepare($query, true); + if ($prefix !== null) { + $this->bindValueForPrefixSearch($stmt, $prefix); + } + if ($stmt->execute()) { return $stmt->rowCount(); } else { @@ -700,19 +778,20 @@ } // }}} - // {{{ vacuum() + // {{{ optimize() /** - * ì¬ÏÝvyA[hXe[ggðNAµAVACUUMðs·é + * ì¬ÏÝvyA[hXe[ggðNAµAVACUUMÆREINDEXðs·é * ¼ÌvZXª¯¶f[^x[XðJ¢Ä¢éÆ«ÉÀs·×«ÅÍÈ¢ * * @param void * @return void */ - public function vacuum() + public function optimize() { self::$_stmtCache[$this->_pdoId] = array(); $this->_pdo->exec('VACUUM'); + $this->_pdo->exec('REINDEX'); } // }}} Modified: p2ex/trunk/lib/P2Util.php =================================================================== --- p2ex/trunk/lib/P2Util.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/lib/P2Util.php 2010-01-17 09:10:54 UTC (rev 790) @@ -1142,9 +1142,7 @@ */ static public function isBrowserSafariGroup() { - return (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false || - strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false || - strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false); + return UA::isSafariGroup(); } // }}} @@ -1166,8 +1164,7 @@ */ static public function isBrowserNintendoDS() { - return (strpos($_SERVER['HTTP_USER_AGENT'], 'Nitro') !== false && - strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false); + return UA::isNintendoDS(); } // }}} @@ -1178,34 +1175,21 @@ */ static public function isBrowserPSP() { - return (strpos($_SERVER['HTTP_USER_AGENT'], 'PlayStation Portable') !== false); + return UA::isPSP(); } // }}} // {{{ isBrowserIphone() /** - * uEUªiPhone or iPod TouchÈçtrueðÔ· + * uEUªiPhone, iPod Touch or AndroidÈçtrueðÔ· */ static public function isBrowserIphone() { - return (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== false || - strpos($_SERVER['HTTP_USER_AGENT'], 'iPod') !== false); + return UA::isIPhoneGroup(); } // }}} - // }}} - // {{{ isBrowserAndroid() - - /** - * uEUªAndroidhÈçtrueðÔ· - */ - static public function isBrowserAndroid() - { - return (strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false); - } - - // }}} // {{{ isUrlWikipediaJa() /** @@ -1305,7 +1289,7 @@ $key .= $_SESSION['login_microtime']; } - return self::urlSafeBase64Encode(sha1($key, true)); + return UrlSafeBase64::encode(sha1($key, true)); } // }}} @@ -1999,38 +1983,6 @@ } // }}} - // {{{ 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), '='), '+/', '-_'); - } - - // }}} // {{{ rawurldecodeCallback() /** Modified: p2ex/trunk/lib/UA.php =================================================================== --- p2ex/trunk/lib/UA.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/lib/UA.php 2010-01-17 09:10:54 UTC (rev 790) @@ -429,7 +429,7 @@ } // Mozilla/4.0 (PSP (PlayStation Portable); 2.00) - if (preg_match('/PlayStation Portable/', $ua)) { + if (false !== strpos($ua, 'PlayStation Portable')) { return true; } return false; @@ -451,7 +451,7 @@ } // Mozilla/4.0 (compatible; MSIE 6.0; Nitro) Opera 8.5 [ja] - if (preg_match('/ Nitro/', $ua)) { + if (false !== strpos($ua, ' Nitro')) { return true; } return false; Added: p2ex/trunk/lib/UrlSafeBase64.php =================================================================== --- p2ex/trunk/lib/UrlSafeBase64.php (rev 0) +++ p2ex/trunk/lib/UrlSafeBase64.php 2010-01-17 09:10:54 UTC (rev 790) @@ -0,0 +1,55 @@ +<?php + +// {{{ UrlSafeBase64 + +/** + * GXP[v¹¸ÉURLÉßßéBase64Ï·NX + */ +class UrlSafeBase64 +{ + // {{{ decode() + + /** + * URL-safe Base64 fR[h + * + * @param string $str + * @return string + */ + static public function decode($str) + { + $mod = strlen($str) % 4; + if ($mod) { + $str .= str_repeat('=', 4 - $mod); + } + return base64_decode(strtr($str, '-_', '+/'), true); + } + + // }}} + // {{{ encode() + + /** + * URL-safe Base64 GR[h + * + * @param string $str + * @return string + */ + static public function encode($str) + { + return strtr(rtrim(base64_encode($str), '='), '+/', '-_'); + } + + // }}} +} + +// }}} + +/* + * 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/bootstrap.php =================================================================== --- p2ex/trunk/lib/bootstrap.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/lib/bootstrap.php 2010-01-17 09:10:54 UTC (rev 790) @@ -157,10 +157,11 @@ $_conf['use_cookies'] = true; -$mobile = Net_UserAgent_Mobile::singleton(); +$userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; +$mobile = Net_UserAgent_Mobile::singleton($userAgent); // iPhone, iPod Touch or Android -if (P2Util::isBrowserIphone() || P2Util::isBrowserAndroid()) { +if (UA::isIPhoneGroup($userAgent)) { $_conf['ktai'] = true; $_conf['iphone'] = true; $_conf['input_type_search'] = true; @@ -169,7 +170,7 @@ // PC } elseif ($mobile->isNonMobile()) { // Safari - if (P2Util::isBrowserSafariGroup()) { + if (UA::isSafariGroup($userAgent)) { $_conf['input_type_search'] = true; $_conf['accept_charset'] = 'UTF-8'; @@ -178,7 +179,7 @@ $_conf['ktai'] = true; // gÑQ[@ - } elseif (P2Util::isBrowserNintendoDS() || P2Util::isBrowserPSP()) { + } elseif (UA::isNintendoDS($userAgent) || UA::isPSP($userAgent)) { $_conf['ktai'] = true; } Modified: p2ex/trunk/lib/expack/ic2/templates/ic2mng.tpl.html =================================================================== --- p2ex/trunk/lib/expack/ic2/templates/ic2mng.tpl.html 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/lib/expack/ic2/templates/ic2mng.tpl.html 2010-01-17 09:10:54 UTC (rev 790) @@ -84,10 +84,9 @@ [<a href="ic2_viewtable.php?table=blacklist#footer" target="read">ubNXgð©é</a>] </div> - <div> - <input type="radio" name="action" id="action_vacuumDB" value="vacuumDB" onclick="dropZeroOptions(false)" /> - <label for="action_vacuumDB">f[^x[Xð®·é</label> - <!-- VACUUMðÀs --> + <div flexy:if="enable_optimize_db"> + <input type="radio" name="action" id="action_optimizeDB" value="optimizeDB" onclick="dropZeroOptions(false)" /> + <label for="action_optimizeDB">f[^x[XðÅK»·é</label> </div> <hr /> Deleted: p2ex/trunk/lib/read_new.inc.php =================================================================== --- p2ex/trunk/lib/read_new.inc.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/lib/read_new.inc.php 2010-01-17 09:10:54 UTC (rev 790) @@ -1,171 +0,0 @@ -<?php -/** - * rep2 - for read_new.php, read_new_k.php - */ - -// {{{ saveMatomeCache() - -/** - * V ÜÆßÇÝÌLbV ðc· - * - * register_shutdown_function() ©çÄÎêéBiÎpXÌt@C͵¦È¢Hj - */ -function saveMatomeCache() -{ - global $_conf; - - if (!empty($GLOBALS['pref_dir_realpath_failed_msg'])) { - return false; - } - - if (!empty($GLOBALS['matome_naipo'])) { - return true; - } - - if ($_conf['ktai']) { - $ext = '.k' . $_conf['matome_cache_ext']; - } else { - $ext = $_conf['matome_cache_ext']; - } - - $lock = new P2Lock($_conf['matome_cache_path'] . $ext, false); - - // [e[V - $max = $_conf['matome_cache_max']; - $i = $max; - while ($i >= 0) { - $di = ($i == 0) ? '' : '.'.$i; - $tfile = $_conf['matome_cache_path'] . $di . $ext; - $next = $i + 1; - $nfile = $_conf['matome_cache_path'] . '.' . $next . $ext; - if (file_exists($tfile)) { - if ($i == $max) { - unlink($tfile); - } else { - if (P2_OS_WINDOWS && file_exists($nfile)) { - unlink($nfile); - } - rename($tfile, $nfile); - } - } - $i--; - } - - // VKL^ - $file = $_conf['matome_cache_path'] . $ext; - //echo "<!-- {$file} -->"; - - FileCtl::make_datafile($file, $_conf['p2_perm']); - if (FileCtl::file_write_contents($file, $GLOBALS['read_new_html']) === false) { - p2die('cannot write file.'); - } - - return true; -} - -// }}} -// {{{ saveMatomeCacheFromTmpFile() - -/** - * V ÜÆßÇÝÌLbV ðc·iêt@CÉ«ñ¾àeðüßÄLbV ÉÛ¶j - */ -function saveMatomeCacheFromTmpFile() -{ - global $_conf; - - if (!empty($GLOBALS['pref_dir_realpath_failed_msg'])) { - return false; - } - - if (!empty($GLOBALS['matome_naipo'])) { - return true; - } - - if (!is_resource($GLOBALS['read_new_tmp_fh'])) { - return false; - } - - if ($_conf['ktai']) { - $ext = '.k' . $_conf['matome_cache_ext']; - } else { - $ext = $_conf['matome_cache_ext']; - } - - // [e[V - $max = $_conf['matome_cache_max']; - $i = $max; - while ($i >= 0) { - $di = ($i == 0) ? '' : '.'.$i; - $tfile = $_conf['matome_cache_path'] . $di . $ext; - $next = $i + 1; - $nfile = $_conf['matome_cache_path'] . '.' . $next . $ext; - if (file_exists($tfile)) { - if ($i == $max) { - unlink($tfile); - } else { - rename($tfile, $nfile); - } - } - $i--; - } - - // VKL^ - $file = $_conf['matome_cache_path'] . $ext; - //echo "<!-- {$file} -->"; - - FileCtl::make_datafile($file, $_conf['p2_perm']); - $fh = fopen($file, 'wb'); - if (!$fh) { - p2die('cannot write file.'); - } - @flock($fh, LOCK_EX); - fseek($GLOBALS['read_new_tmp_fh'], 0); - do { - fwrite($fh, fread($GLOBALS['read_new_tmp_fh'], 100000)); - } while (!feof($GLOBALS['read_new_tmp_fh'])); - @flock($fh, LOCK_UN); - fclose($fh); - - return true; -} - -// }}} -// {{{ getMatomeCache() - -/** - * V ÜÆßÇÝÌLbV ðæ¾ - */ -function getMatomeCache($num = '') -{ - global $_conf; - - if ($_conf['ktai']) { - $ext = '.k' . $_conf['matome_cache_ext']; - } else { - $ext = $_conf['matome_cache_ext']; - } - - $dnum = ($num) ? '.'.$num : ''; - $file = $_conf['matome_cache_path'] . $dnum . $ext; - - $cont = FileCtl::file_read_contents($file); - - if (strlen($cont) > 0) { - return $cont; - } else { - return false; - } -} - -// }}} - -/* - * 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/startup.funcs.php =================================================================== --- p2ex/trunk/lib/startup.funcs.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/lib/startup.funcs.php 2010-01-17 09:10:54 UTC (rev 790) @@ -154,27 +154,29 @@ if (preg_match('/^(?: BbsMap | BrdCtl | - BrdMenu(?:[A-Z][A-Za-z]*)? | + BrdMenu(?:Cate|Ita)? | DataPhp | FavSetManager | FileCtl | HostCheck | Login | MD5Crypt | + MatomeCache(List)? | NgAbornCtl | P2[A-Z][A-Za-z]* | PresetManager | ResHist | Session | SettingTxt | - ShowBrdMenu(?:[A-Z][A-Za-z]*)? | - ShowThread(?:[A-Z][A-Za-z]*)? | + ShowBrdMenu(?:K|Pc) | + ShowThread(?:K|Pc)? | StrCtl | StrSjis | SubjectTxt | - Thread(?:[A-Z][A-Za-z]*)? | + Thread(?:List|Read)? | UA | - Wap[A-Z][A-Za-z]* + UrlSafeBase64 | + Wap(UserAgent|Request|Response) )$/x', $name)) { if (strncmp($name, 'Wap', 3) === 0) { Modified: p2ex/trunk/read_new.php =================================================================== --- p2ex/trunk/read_new.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/read_new.php 2010-01-17 09:10:54 UTC (rev 790) @@ -5,29 +5,9 @@ */ require_once './conf/conf.inc.php'; -require_once P2_LIB_DIR . '/read_new.inc.php'; $_login->authorize(); // [UFØ -// ÜÆßæÝÌLbV ÇÝ -if (!empty($_GET['cview'])) { - $cnum = (isset($_GET['cnum'])) ? intval($_GET['cnum']) : NULL; - if ($cont = getMatomeCache($cnum)) { - echo $cont; - } else { - header('Content-Type: text/plain; charset=Shift_JIS'); - echo 'p2 error: V ÜÆßÇÝÌLbV ªÈ¢æ'; - } - exit; -} - -// ÈÝè -// 1 É·éÆLbV ðÅÈêt@CÉÛ·é -// iÇ¿çÅàÅIIÉÍt@CÉ«Üêéj -if (!defined('P2_READ_NEW_SAVE_MEMORY')) { - define('P2_READ_NEW_SAVE_MEMORY', 0); -} - //================================================================== // Ï //================================================================== @@ -64,18 +44,6 @@ // C //==================================================================== -if (P2_READ_NEW_SAVE_MEMORY) { - register_shutdown_function('saveMatomeCacheFromTmpFile'); - $read_new_tmp_fh = tmpfile(); - if (!is_resource($read_new_tmp_fh)) { - p2die('cannot make tmpfile.'); - } -} else { - register_shutdown_function('saveMatomeCache'); - $read_new_html = ''; -} -ob_start(); - $aThreadList = new ThreadList(); // ÂÆ[hÌZbg=================================== @@ -120,6 +88,8 @@ // y[Wwb_\¦ =================================== $ptitle_hd = htmlspecialchars($aThreadList->ptitle, ENT_QUOTES); $ptitle_ht = "{$ptitle_hd} Ì V ÜÆßÇÝ"; +$matomeCache = new MatomeCache($ptitle_hd, $_conf['matome_cache_max']); +ob_start(); if ($aThreadList->spmode) { $sb_ht = <<<EOP @@ -349,26 +319,19 @@ echo $_info_msg_ht; $_info_msg_ht = ''; - if (P2_READ_NEW_SAVE_MEMORY) { - fwrite($read_new_tmp_fh, ob_get_flush()); - } else { - $read_new_html .= ob_get_flush(); - } + $matomeCache->concat(ob_get_flush()); flush(); ob_start(); if (($aThread->readnum < 1) || $aThread->unum) { readNew($aThread); + $matomeCache->addReadThread($aThread); } elseif ($aThread->diedat) { echo $aThread->getdat_error_msg_ht; echo "<hr>\n"; } - if (P2_READ_NEW_SAVE_MEMORY) { - fwrite($read_new_tmp_fh, ob_get_flush()); - } else { - $read_new_html .= ob_get_flush(); - } + $matomeCache->concat(ob_get_flush()); flush(); ob_start(); @@ -673,11 +636,7 @@ echo '</body></html>'; -if (P2_READ_NEW_SAVE_MEMORY) { - fwrite($read_new_tmp_fh, ob_get_flush()); -} else { - $read_new_html .= ob_get_flush(); -} +$matomeCache->concat(ob_get_flush()); // NG Ú[ñðL^ NgAbornCtl::saveNgAborns(); Added: p2ex/trunk/read_new_cache.php =================================================================== --- p2ex/trunk/read_new_cache.php (rev 0) +++ p2ex/trunk/read_new_cache.php 2010-01-17 09:10:54 UTC (rev 790) @@ -0,0 +1,33 @@ +<?php +/** + * rep2 - V ÜÆßÇÝÌLbV ðÇÞ + */ + +require_once './conf/conf.inc.php'; + +$_login->authorize(); + +if (array_key_exists('ckey', $_GET) && is_string($_GET['ckey'])) { + $ckey = MatomeCacheList::getKeyPrefix() . $_GET['ckey']; + $cont = MatomeCacheDataStore::get($ckey); +} else { + $cont = null; +} + +if ($cont) { + echo $cont; +} else { + header('Content-Type: text/plain; charset=Shift_JIS'); + echo 'rep2 error: V ÜÆßÇÝÌLbV ªÈ¢æ'; +} + +/* + * 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/read_new_k.php =================================================================== --- p2ex/trunk/read_new_k.php 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/read_new_k.php 2010-01-17 09:10:54 UTC (rev 790) @@ -5,29 +5,9 @@ */ require_once './conf/conf.inc.php'; -require_once P2_LIB_DIR . '/read_new.inc.php'; $_login->authorize(); // [UFØ -// ÜÆßæÝÌLbV ÇÝ -if (!empty($_GET['cview'])) { - $cnum = (isset($_GET['cnum'])) ? intval($_GET['cnum']) : NULL; - if ($cont = getMatomeCache($cnum)) { - echo $cont; - } else { - header('Content-Type: text/plain; charset=Shift_JIS'); - echo 'p2 error: V ÜÆßÇÝÌLbV ªÈ¢æ'; - } - exit; -} - -// ÈÝè -// 1 É·éÆLbV ðÅÈêt@CÉÛ·é -// iÇ¿çÅàÅIIÉÍt@CÉ«Üêéj -if (!defined('P2_READ_NEW_SAVE_MEMORY')) { - define('P2_READ_NEW_SAVE_MEMORY', 0); -} - //================================================================== // Ï //================================================================== @@ -71,18 +51,6 @@ // C //==================================================================== -if (P2_READ_NEW_SAVE_MEMORY) { - register_shutdown_function('saveMatomeCacheFromTmpFile'); - $read_new_tmp_fh = tmpfile(); - if (!is_resource($read_new_tmp_fh)) { - p2die('cannot make tmpfile.'); - } -} else { - register_shutdown_function('saveMatomeCache'); - $read_new_html = ''; -} -ob_start(); - $aThreadList = new ThreadList(); // ÂÆ[hÌZbg =================================== @@ -127,6 +95,8 @@ // y[Wwb_\¦ =================================== $ptitle_hd = htmlspecialchars($aThreadList->ptitle, ENT_QUOTES); $ptitle_ht = "{$ptitle_hd} Ì V ÜÆßÇÝ"; +$matomeCache = new MatomeCache($ptitle_hd, $_conf['matome_cache_max']); +ob_start(); // &sb_view={$sb_view} if ($aThreadList->spmode) { @@ -331,28 +301,21 @@ if ($aThread->isonline) { $online_num++; } // ¶¶set echo $_info_msg_ht; - $_info_msg_ht = ""; + $_info_msg_ht = ''; - if (P2_READ_NEW_SAVE_MEMORY) { - fwrite($read_new_tmp_fh, ob_get_flush()); - } else { - $read_new_html .= ob_get_flush(); - } + $matomeCache->concat(ob_get_flush()); flush(); ob_start(); if (($aThread->readnum < 1) || $aThread->unum) { readNew($aThread); + $matomeCache->addReadThread($aThread); } elseif ($aThread->diedat) { echo $aThread->getdat_error_msg_ht; echo "<hr>\n"; } - if (P2_READ_NEW_SAVE_MEMORY) { - fwrite($read_new_tmp_fh, ob_get_flush()); - } else { - $read_new_html .= ob_get_flush(); - } + $matomeCache->concat(ob_get_flush()); flush(); ob_start(); @@ -632,11 +595,7 @@ echo '</body></html>'; -if (P2_READ_NEW_SAVE_MEMORY) { - fwrite($read_new_tmp_fh, ob_get_flush()); -} else { - $read_new_html .= ob_get_flush(); -} +$matomeCache->concat(ob_get_flush()); // NG Ú[ñðL^ NgAbornCtl::saveNgAborns(); Modified: p2ex/trunk/style/editpref_css.inc =================================================================== --- p2ex/trunk/style/editpref_css.inc 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/style/editpref_css.inc 2010-01-17 09:10:54 UTC (rev 790) @@ -29,6 +29,12 @@ margin-right: auto; } +ul#matome_cache div.popup_element ul { + margin: 0; + padding: 0; + list-style-type: none; +} + EOSTYLE; /* Modified: p2ex/trunk/style/iv2_css.inc =================================================================== --- p2ex/trunk/style/iv2_css.inc 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/style/iv2_css.inc 2010-01-17 09:10:54 UTC (rev 790) @@ -37,7 +37,7 @@ } div#header { - height: 3.75em; + height: 4em; } div#content { Modified: p2ex/trunk/style/style_css.inc =================================================================== --- p2ex/trunk/style/style_css.inc 2010-01-16 22:49:33 UTC (rev 789) +++ p2ex/trunk/style/style_css.inc 2010-01-17 09:10:54 UTC (rev 790) @@ -115,6 +115,8 @@ .popup_element { position: absolute; + top: 0; + left: 0; visibility: hidden; /* iÍBµÄ¨*/ {$respop_background} {$respop_border}