Index: /trunk/htdocs/cacher/edit.tpl.php
===================================================================
--- /trunk/htdocs/cacher/edit.tpl.php	(revision 1053)
+++ /trunk/htdocs/cacher/edit.tpl.php	(revision 1078)
@@ -1,3 +1,3 @@
-<?php include("../common/header.tpl.php"); ?>
+<?php include "../common/header.tpl.php"; ?>
 <?php
 $h_name = htmlspecialchars($name);
@@ -16,3 +16,3 @@
 	</fieldset>
 </form>
-<?php include("../common/footer.tpl.php"); ?>
+<?php include "../common/footer.tpl.php"; ?>
Index: /trunk/htdocs/cacher/edit.php
===================================================================
--- /trunk/htdocs/cacher/edit.php	(revision 1053)
+++ /trunk/htdocs/cacher/edit.php	(revision 1078)
@@ -1,5 +1,5 @@
 <?php
 
-include("./common.php");
+include "./common.php";
 
 if (!isset($_GET['name'])) {
@@ -39,5 +39,5 @@
 $module = "cacher";
 
-include("edit.tpl.php");
+include "edit.tpl.php";
 
 ?>
Index: /trunk/htdocs/cacher/cacher.css
===================================================================
--- /trunk/htdocs/cacher/cacher.css	(revision 1069)
+++ /trunk/htdocs/cacher/cacher.css	(revision 1078)
@@ -19,5 +19,4 @@
 .hitsgraph div div.barv.active { border-color: yellow; }
 
-#help { display: block; float: right; }
 dl { overflow: hidden; }
 dt { font-weight: bold; clear: both; float: left; width: 100px; text-align: right; margin: 0; }
Index: /trunk/htdocs/cacher/help.tpl.php
===================================================================
--- /trunk/htdocs/cacher/help.tpl.php	(revision 1078)
+++ /trunk/htdocs/cacher/help.tpl.php	(revision 1078)
@@ -0,0 +1,13 @@
+<?php include "../common/header.tpl.php"; ?>
+<div class="switcher"><?php echo switcher("do", $doTypes); ?></div>
+<?php if (ini_get("xcache.test")) { ?>
+<form method="post" action="">
+	<div>
+		<input type="submit" name="coredump" value="Test coredump" class="submit" onclick="return confirm('<?php echo _('Sure?'); ?>');" />
+	</div>
+</form>
+<?php } ?>
+<div id="help">
+	<?php include get_language_file("help"); ?>
+</div>
+<?php include "../common/footer.tpl.php" ?>
Index: /trunk/htdocs/cacher/common.php
===================================================================
--- /trunk/htdocs/cacher/common.php	(revision 1054)
+++ /trunk/htdocs/cacher/common.php	(revision 1078)
@@ -3,3 +3,3 @@
 require_once "../common/common.php";
 
-include(get_language_file("cacher"));
+include get_language_file("cacher");
Index: /trunk/htdocs/cacher/summary.tpl.php
===================================================================
--- /trunk/htdocs/cacher/summary.tpl.php	(revision 1074)
+++ /trunk/htdocs/cacher/summary.tpl.php	(revision 1078)
@@ -1,18 +1,5 @@
-<?php include("../common/header.tpl.php"); ?>
-<div class="switcher"><?php echo switcher("do", $listTypes); ?></div>
-<?php
-include "./sub/summary.tpl.php";
-
-if (ini_get("xcache.test")) {
-?>
-<form method="post" action="">
-	<div>
-		<input type="submit" name="coredump" value="Test coredump" class="submit" onclick="return confirm('<?php echo _('Sure?'); ?>');" />
-	</div>
-</form>
-<?php
-}
-?>
-<?php include("./sub/moduleinfo.tpl.php"); ?>
-
-<?php include("../common/footer.tpl.php"); ?>
+<?php include "../common/header.tpl.php"; ?>
+<div class="switcher"><?php echo switcher("do", $doTypes); ?></div>
+<?php include "./sub/summary.tpl.php"; ?>
+<?php include "./sub/moduleinfo.tpl.php"; ?>
+<?php include "../common/footer.tpl.php"; ?>
Index: /trunk/htdocs/cacher/cacher-zh-traditional.lang.php
===================================================================
--- /trunk/htdocs/cacher/cacher-zh-traditional.lang.php	(revision 1074)
+++ /trunk/htdocs/cacher/cacher-zh-traditional.lang.php	(revision 1078)
@@ -41,7 +41,7 @@
 		=> '快取',
 		'php Cached'
-		=> '快取的 php 指令',
+		=> '快取的 PHP 指令',
 		'php Deleted'
-		=> '待刪 php 指令',
+		=> '待刪 PHP 指令',
 		'var Cached'
 		=> '快取的變數',
@@ -79,7 +79,7 @@
 		=> '操作按鈕|點擊按鈕清除對應共享記憶體區的資料',
 		'cache.status'
-		=> '狀態|狀態標記. 當共享內存區正在編譯 php 腳本時標記為 "編譯中". 當共享內存區暫停使用時標記為 "禁用"',
+		=> '狀態|狀態標記. 當共享內存區正在編譯 PHP 腳本時標記為 "編譯中". 當共享內存區暫停使用時標記為 "禁用"',
 		'cache.hits'
-		=> '命中|共享記憶體命中次數，命中=從該共享記憶體載入php或者變數',
+		=> '命中|共享記憶體命中次數，命中=從該共享記憶體載入 PHP 或者變數',
 		'cache.hits_avg_h'
 		=> '命中/H|每小时命中次数. 只统计最后 24 小时',
Index: /trunk/htdocs/cacher/sub/entrylist.tpl.php
===================================================================
--- /trunk/htdocs/cacher/sub/entrylist.tpl.php	(revision 1076)
+++ /trunk/htdocs/cacher/sub/entrylist.tpl.php	(revision 1078)
@@ -2,5 +2,5 @@
 <form action="" method="post">
 	<table cellspacing="0" cellpadding="4" class="cycles entries">
-		<caption><?php echo _("{$cachelist['type_name']} $listName"); ?></caption>
+		<caption><?php echo _("$typeName $listName"); ?></caption>
 <?php
 
@@ -36,10 +36,8 @@
 		, th(N_("entry.file_mtime"))
 		;
-	if ($haveinode) {
-		echo
-			th(N_("entry.file_device"))
-			, th(N_("entry.file_inode"))
-			;
-	}
+	echo
+		th(N_("entry.file_device"))
+		, th(N_("entry.file_inode"))
+		;
 }
 echo
Index: /trunk/htdocs/cacher/sub/summary.tpl.php
===================================================================
--- /trunk/htdocs/cacher/sub/summary.tpl.php	(revision 1076)
+++ /trunk/htdocs/cacher/sub/summary.tpl.php	(revision 1078)
@@ -35,5 +35,5 @@
 	$l_normal = _('Normal');
 	$l_confirm = _('Sure?');
-	foreach ($cacheinfos as $i => $ci) {
+	foreach (getCacheInfos() as $i => $ci) {
 		$class = $cycleClass->next();
 		echo <<<TR
Index: /trunk/htdocs/cacher/listentries.tpl.php
===================================================================
--- /trunk/htdocs/cacher/listentries.tpl.php	(revision 1074)
+++ /trunk/htdocs/cacher/listentries.tpl.php	(revision 1078)
@@ -1,21 +1,21 @@
-<?php include("../common/header.tpl.php"); ?>
-<div class="switcher"><?php echo switcher("do", $listTypes); ?></div>
+<?php include "../common/header.tpl.php"; ?>
+<div class="switcher"><?php echo switcher("do", $doTypes); ?></div>
+<?php include "./sub/summary.tpl.php"; ?>
 <?php
-
-include "./sub/summary.tpl.php";
-$isphp = $cachelist['type'] == 'listphp';
+$entryList = getEntryList();
+$isphp = $entryList['type'] == 'listphp';
+$typeName = $entryList['type_name'];
 ob_start($config['path_nicer']);
 
 $listName = 'Cached';
-$entries = $cachelist['cache_list'];
+$entries = $entryList['cache_list'];
 include "./sub/entrylist.tpl.php";
 
 $listName = 'Deleted';
-$entries = $cachelist['deleted_list'];
+$entries = $entryList['deleted_list'];
 include "./sub/entrylist.tpl.php";
 
 ob_end_flush();
 unset($isphp);
-
 ?>
-<?php include("../common/footer.tpl.php"); ?>
+<?php include "../common/footer.tpl.php"; ?>
Index: /trunk/htdocs/cacher/cacher-zh-simplified.lang.php
===================================================================
--- /trunk/htdocs/cacher/cacher-zh-simplified.lang.php	(revision 1074)
+++ /trunk/htdocs/cacher/cacher-zh-simplified.lang.php	(revision 1078)
@@ -41,7 +41,7 @@
 		=> '缓存区',
 		'php Cached'
-		=> '缓存的 php 脚本',
+		=> '缓存的 PHP 脚本',
 		'php Deleted'
-		=> '待删 php 缓存',
+		=> '待删 PHP 缓存',
 		'var Cached'
 		=> '缓存的变量',
@@ -79,7 +79,7 @@
 		=> '操作|点击按钮清除对应共享内存区的数据',
 		'cache.status'
-		=> '状态|状态标记. 当共享内存区正在编译 php 脚本时标记为 "编译中". 当共享内存区暂停使用时标记为 "禁用"',
+		=> '状态|状态标记. 当共享内存区正在编译 PHP 脚本时标记为 "编译中". 当共享内存区暂停使用时标记为 "禁用"',
 		'cache.hits'
-		=> '命中|共享内存命中次数, 命中=从该共享内存载入php或者变量',
+		=> '命中|共享内存命中次数, 命中=从该共享内存载入 PHP 或者变量',
 		'cache.hits_avg_h'
 		=> '命中/H|每小时命中次数. 只统计最后 24 小时',
Index: /trunk/htdocs/cacher/index.php
===================================================================
--- /trunk/htdocs/cacher/index.php	(revision 1074)
+++ /trunk/htdocs/cacher/index.php	(revision 1078)
@@ -1,7 +1,7 @@
 <?php
 
-include("./common.php");
-
-function freeblock_to_graph($freeblocks, $size)
+include "./common.php";
+
+function freeblock_to_graph($freeblocks, $size) // {{{
 {
 	global $config;
@@ -42,6 +42,6 @@
 	return implode('', $html);
 }
-
-function calc_total(&$total, $data)
+// }}}
+function calc_total(&$total, $data) // {{{
 {
 	foreach ($data as $k => $v) {
@@ -71,6 +71,6 @@
 	}
 }
-
-function array_avg($a)
+// }}}
+function array_avg($a) // {{{
 {
 	if (count($a) == 0) {
@@ -79,6 +79,6 @@
 	return array_sum($a) / count($a);
 }
-
-function bar_hits_percent($v, $percent, $active)
+// }}}
+function bar_hits_percent($v, $percent, $active) // {{{
 {
 	$r = 220 + (int) ($percent * 25);
@@ -96,12 +96,13 @@
 		. '</div>';
 }
-
-function get_cache_hits_graph($ci, $key)
-{
+// }}}
+function get_cache_hits_graph($ci, $key) // {{{
+{
+	global $maxHitsByHour;
 	if ($ci['cacheid'] == -1) {
 		$max = max($ci[$key]);
 	}
 	else {
-		$max = $GLOBALS['maxhits_by_hour'][$ci['type']];
+		$max = $maxHitsByHour[$ci['type']];
 	}
 	if (!$max) {
@@ -115,6 +116,6 @@
 	return implode('', $html);
 }
-
-function getModuleInfo()
+// }}}
+function getModuleInfo() // {{{
 {
 	ob_start();
@@ -132,8 +133,108 @@
 	return implode('', $moduleInfo);
 }
+// }}}
+function getCacheInfos() // {{{
+{
+	static $cacheInfos;
+	if (isset($cacheInfos)) {
+		return $cacheInfos;
+	}
+
+	$phpCacheCount = xcache_count(XC_TYPE_PHP);
+	$varCacheCount = xcache_count(XC_TYPE_VAR);
+
+	$cacheInfos = array();
+	$total = array();
+	global $maxHitsByHour;
+	$maxHitsByHour = array(0, 0);
+	for ($i = 0; $i < $phpCacheCount; $i ++) {
+		$data = xcache_info(XC_TYPE_PHP, $i);
+		if ($_GET['do'] === 'listphp') {
+			$data += xcache_list(XC_TYPE_PHP, $i);
+		}
+		$data['type'] = XC_TYPE_PHP;
+		$data['cache_name'] = "php#$i";
+		$data['cacheid'] = $i;
+		$cacheInfos[] = $data;
+		$maxHitsByHour[XC_TYPE_PHP] = max($maxHitsByHour[XC_TYPE_PHP], max($data['hits_by_hour']));
+		if ($phpCacheCount >= 2) {
+			calc_total($total, $data);
+		}
+	}
+
+	if ($phpCacheCount >= 2) {
+		$total['type'] = XC_TYPE_PHP;
+		$total['cache_name'] = _('Total');
+		$total['cacheid'] = -1;
+		$total['gc'] = null;
+		$total['istotal'] = true;
+		unset($total['compiling']);
+		$cacheInfos[] = $total;
+	}
+
+	$total = array();
+	for ($i = 0; $i < $varCacheCount; $i ++) {
+		$data = xcache_info(XC_TYPE_VAR, $i);
+		if ($_GET['do'] === 'listvar') {
+			$data += xcache_list(XC_TYPE_VAR, $i);
+		}
+		$data['type'] = XC_TYPE_VAR;
+		$data['cache_name'] = "var#$i";
+		$data['cacheid'] = $i;
+		$cacheInfos[] = $data;
+		$maxHitsByHour[XC_TYPE_VAR] = max($maxHitsByHour[XC_TYPE_VAR], max($data['hits_by_hour']));
+		if ($varCacheCount >= 2) {
+			calc_total($total, $data);
+		}
+	}
+
+	if ($varCacheCount >= 2) {
+		$total['type'] = XC_TYPE_VAR;
+		$total['cache_name'] = _('Total');
+		$total['cacheid'] = -1;
+		$total['gc'] = null;
+		$total['istotal'] = true;
+		$cacheInfos[] = $total;
+	}
+	return $cacheInfos;
+}
+// }}}
+function getEntryList() // {{{
+{
+	static $entryList;
+	if (isset($entryList)) {
+		return $entryList;
+	}
+	$entryList = array('cache_list' => array(), 'deleted_list' => array());
+	if ($_GET['do'] == 'listphp') {
+		$entryList['type_name'] = 'php';
+		$entryList['type'] = XC_TYPE_PHP;
+	}
+	else {
+		$entryList['type_name'] = 'var';
+		$entryList['type'] = XC_TYPE_VAR;
+	}
+	foreach (getCacheInfos() as $i => $c) {
+		if (!empty($c['istotal'])) {
+			continue;
+		}
+		if ($c['type'] == $entryList['type'] && isset($c['cache_list'])) {
+			foreach ($c['cache_list'] as $e) {
+				$e['cache_name'] = $c['cache_name'];
+				$entryList['cache_list'][] = $e;
+			}
+			foreach ($c['deleted_list'] as $e) {
+				$e['cache_name'] = $c['cache_name'];
+				$entryList['deleted_list'][] = $e;
+			}
+		}
+	}
+	return $entryList;
+}
+// }}}
 
 $module = "cacher";
 if (!extension_loaded('XCache')) {
-	include("../common/header.tpl.php");
+	include "../common/header.tpl.php";
 	echo '<h1>XCache is not loaded</h1>';
 	ob_start();
@@ -158,28 +259,25 @@
 	}
 	echo "(See above)";
-	include("../common/footer.tpl.php");
+	include "../common/footer.tpl.php";
 	exit;
 }
-$pcnt = xcache_count(XC_TYPE_PHP);
-$vcnt = xcache_count(XC_TYPE_VAR);
-
-if ($_SERVER['REQUEST_METHOD'] == 'POST') {
-	$remove = @ $_POST['remove'];
-	if ($remove && is_array($remove)) {
-		foreach ($remove as $name) {
-			xcache_unset($name);
-		}
-	}
-}
-
-$listTypes = array('' => _('Summary'), 'listphp' => _('List PHP'), 'listvar' => _('List Var Data'));
-
-if (!isset($_GET['do'])) {
-	$_GET['do'] = '';
-}
-
-// {{{ process clear, enable, disable
-function processAction()
-{
+
+$doTypes = array(
+		'' => _('Summary'),
+		'listphp' => _('List PHP'),
+		'listvar' => _('List Var Data'),
+		'help' => _('Help'),
+		);
+
+function processPOST() // {{{
+{
+	if (isset($_POST['remove']) && is_array($_POST['remove'])) {
+		foreach ($_POST['remove'] as $name) {
+			if (is_string($name)) {
+				xcache_unset($name);
+			}
+		}
+	}
+
 	$type = isset($_POST['type']) ? $_POST['type'] : null;
 	if ($type != XC_TYPE_PHP && $type != XC_TYPE_VAR) {
@@ -198,118 +296,31 @@
 		}
 	}
-}
-processAction();
-if (isset($_POST['coredump'])) {
-	xcache_coredump();
-}
-// }}}
-// {{{ load info/list
-$cacheinfos = array();
-$total = array();
-$maxhits_by_hour = array(0, 0);
-for ($i = 0; $i < $pcnt; $i ++) {
-	$data = xcache_info(XC_TYPE_PHP, $i);
-	if ($_GET['do'] === 'listphp') {
-		$data += xcache_list(XC_TYPE_PHP, $i);
-	}
-	$data['type'] = XC_TYPE_PHP;
-	$data['cache_name'] = "php#$i";
-	$data['cacheid'] = $i;
-	$cacheinfos[] = $data;
-	$maxhits_by_hour[XC_TYPE_PHP] = max($maxhits_by_hour[XC_TYPE_PHP], max($data['hits_by_hour']));
-	if ($pcnt >= 2) {
-		calc_total($total, $data);
-	}
-}
-
-if ($pcnt >= 2) {
-	$total['type'] = XC_TYPE_PHP;
-	$total['cache_name'] = _('Total');
-	$total['cacheid'] = -1;
-	$total['gc'] = null;
-	$total['istotal'] = true;
-	unset($total['compiling']);
-	$cacheinfos[] = $total;
-}
-
-$total = array();
-for ($i = 0; $i < $vcnt; $i ++) {
-	$data = xcache_info(XC_TYPE_VAR, $i);
-	if ($_GET['do'] === 'listvar') {
-		$data += xcache_list(XC_TYPE_VAR, $i);
-	}
-	$data['type'] = XC_TYPE_VAR;
-	$data['cache_name'] = "var#$i";
-	$data['cacheid'] = $i;
-	$cacheinfos[] = $data;
-	$maxhits_by_hour[XC_TYPE_VAR] = max($maxhits_by_hour[XC_TYPE_VAR], max($data['hits_by_hour']));
-	if ($vcnt >= 2) {
-		calc_total($total, $data);
-	}
-}
-
-if ($vcnt >= 2) {
-	$total['type'] = XC_TYPE_VAR;
-	$total['cache_name'] = _('Total');
-	$total['cacheid'] = -1;
-	$total['gc'] = null;
-	$total['istotal'] = true;
-	$cacheinfos[] = $total;
-}
-// }}}
-// {{{ merge the list
+
+	if (isset($_POST['coredump'])) {
+		xcache_coredump();
+	}
+}
+// }}}
+
+processPOST();
+
+if (!isset($_GET['do'])) {
+	$_GET['do'] = '';
+}
+
 switch ($_GET['do']) {
 case 'listphp':
 case 'listvar':
-	$cachelist = array('cache_list' => array(), 'deleted_list' => array());
-	if ($_GET['do'] == 'listphp') {
-		$cachelist['type_name'] = 'php';
-		$cachelist['type'] = XC_TYPE_PHP;
-	}
-	else {
-		$cachelist['type_name'] = 'var';
-		$cachelist['type'] = XC_TYPE_VAR;
-	}
-	foreach ($cacheinfos as $i => $c) {
-		if (!empty($c['istotal'])) {
-			continue;
-		}
-		if ($c['type'] == $cachelist['type'] && isset($c['cache_list'])) {
-			foreach ($c['cache_list'] as $e) {
-				$e['cache_name'] = $c['cache_name'];
-				$cachelist['cache_list'][] = $e;
-			}
-			foreach ($c['deleted_list'] as $e) {
-				$e['cache_name'] = $c['cache_name'];
-				$cachelist['deleted_list'][] = $e;
-			}
-		}
-	}
-	if ($cachelist['type'] == XC_TYPE_PHP) {
-		$inodes = array();
-		$haveinode = false;
-		foreach ($cachelist['cache_list'] as $e) {
-			if (isset($e['file_inode'])) {
-				$haveinode = true;
-				break;
-			}
-		}
-		if (!$haveinode) {
-			foreach ($cachelist['deleted_list'] as $e) {
-				if (isset($e['file_inode'])) {
-					$haveinode = true;
-					break;
-				}
-			}
-		}
-	}
-	unset($data);
-	include("./listentries.tpl.php");
+	include "./listentries.tpl.php";
 	break;
 
+case 'help':
+	include "./help.tpl.php";
+	break;
+
 default:
-	include("./summary.tpl.php");
-}
-// }}}
+	include "./summary.tpl.php";
+	break;
+}
 
 ?>
Index: /unk/htdocs/cacher/help.php
===================================================================
--- /trunk/htdocs/cacher/help.php	(revision 1038)
+++ 	(revision )
@@ -1,33 +1,0 @@
-<?php
-include("./common.php");
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<?php
-echo <<<HEAD
-	<meta http-equiv="Content-Type" content="text/html; charset=$config[charset]" />
-	<meta http-equiv="Content-Language" content="$config[lang]" />
-	<script type="text/javascript" src="tablesort.js" charset="$config[charset]"></script>
-HEAD;
-?>
-
-	<link rel="stylesheet" type="text/css" href="xcache.css" />
-	<title><?php echo _('XCache Help'); ?></title>
-	<script>
-	function toggle(o)
-	{
-		o.style.display = o.style.display != 'block' ? 'block' : 'none';
-	}
-	</script>
-</head>
-
-<body>
-<h1><?php echo _('XCache Help'); ?></h1>
-<div id1="help">
-<?php include(get_language_file("help")); ?>
-</div>
-
-<?php echo _('See also'); ?>: <a href="http://xcache.lighttpd.net/wiki/PhpIni">Setting php.ini for XCache</a> @ <a href="http://xcache.lighttpd.net/">XCache wiki</a>
-</body>
-</html>
