Index: /branches/1.3/Decompiler.class.php
===================================================================
--- /branches/1.3/Decompiler.class.php	(revision 622)
+++ /branches/1.3/Decompiler.class.php	(revision 623)
@@ -29,6 +29,6 @@
 	if (is_array($src)) {
 		die_error('array str');
-		$src = new Decompiler_Array($src);
-		return $src->__toString($indent);
+		$src = new Decompiler_Array($src, false, $indent);
+		return $src->__toString();
 	}
 
@@ -165,7 +165,7 @@
 	}
 
-	function __toString($indent)
-	{
-		return $this->obj->__toString($indent);
+	function __toString()
+	{
+		return $this->obj->__toString();
 	}
 }
@@ -258,15 +258,17 @@
 {
 	var $needExport = false;
-
-	function Decompiler_Array($value = array(), $needexport = false)
+	var $indent = '';
+
+	function Decompiler_Array($value = array(), $needexport = false, $indent = '')
 	{
 		$this->value = $value;
 		$this->needExport = $needexport;
-	}
-
-	function __toString($indent)
+		$this->indent = $indent;
+	}
+
+	function __toString()
 	{
 		$exp = "array(";
-		$indent .= INDENT;
+		$indent = $this->indent . INDENT;
 		$assoclen = 0;
 		$multiline = 0;
@@ -335,5 +337,5 @@
 	var $iskey;
 
-	function __toString($indent)
+	function __toString()
 	{
 		return 'foreach (' . '';
Index: /branches/1.3/admin/common-zh-simplified-utf-8.lang.php
===================================================================
--- /branches/1.3/admin/common-zh-simplified-utf-8.lang.php	(revision 622)
+++ /branches/1.3/admin/common-zh-simplified-utf-8.lang.php	(revision 623)
@@ -24,8 +24,16 @@
 		'Compiling'
 		=> '编译中',
-		'%'
-		=> '%',
+		'% Free'
+		=> '% 剩余',
+		'% Used'
+		=> '% 已用',
 		'Hits'
 		=> '命中',
+		'Hits 24H'
+		=> '24H 分布',
+		'Hits/H'
+		=> '命中/H',
+		'Hits/S'
+		=> '命中/S',
 		'Misses'
 		=> '错过',
@@ -69,4 +77,12 @@
 		'GC'
 		=> 'GC',
+		'Legends:'
+		=> '图例:',
+		'Used Blocks'
+		=> '已用块',
+		'Free Blocks'
+		=> '未用块',
+		'Total'
+		=> '总共',
 		'Cache'
 		=> '缓冲区',
Index: /branches/1.3/admin/common-zh-traditional-utf-8.lang.php
===================================================================
--- /branches/1.3/admin/common-zh-traditional-utf-8.lang.php	(revision 622)
+++ /branches/1.3/admin/common-zh-traditional-utf-8.lang.php	(revision 623)
@@ -24,8 +24,16 @@
 		'Compiling'
 		=> '編譯中',
-		'%'
-		=> '%',
+		'% Free'
+		=> '% 剩余',
+		'% Used'
+		=> '% 已用',
 		'Hits'
 		=> '命中',
+		'Hits 24H'
+		=> '24H 分布',
+		'Hits/H'
+		=> '命中/H',
+		'Hits/S'
+		=> '命中/S',
 		'Misses'
 		=> '錯過',
@@ -69,4 +77,12 @@
 		'GC'
 		=> 'GC',
+		'Legends:'
+		=> '图例:',
+		'Used Blocks'
+		=> '已用块',
+		'Free Blocks'
+		=> '未用块',
+		'Total'
+		=> '总共',
 		'Cache'
 		=> '快取',
Index: /branches/1.3/admin/common.php
===================================================================
--- /branches/1.3/admin/common.php	(revision 622)
+++ /branches/1.3/admin/common.php	(revision 623)
@@ -109,4 +109,8 @@
 	$lang = 'en-us';
 }
+if (!isset($usage_graph_width) && !isset($free_graph_width)) {
+	$usage_graph_width = 120;
+}
+$graph_width = isset($free_graph_width) ? $free_graph_width : $usage_graph_width;
 
 ?>
Index: /branches/1.3/admin/config.php.example
===================================================================
--- /branches/1.3/admin/config.php.example	(revision 622)
+++ /branches/1.3/admin/config.php.example	(revision 623)
@@ -12,4 +12,9 @@
 $show_todo_strings = false;
 
+// width of graph for free or usage blocks
+$usage_graph_width = 120;
+// do not define both with
+// $free_graph_width = 120;
+
 // this function is detected by xcache.tpl.php, and enabled if function_exists
 // this ob filter is applied for the cache list, not the whole page
@@ -17,5 +22,5 @@
 {
 	$sep = DIRECTORY_SEPARATOR;
-	$o = str_replace($_SERVER['DOCUMENT_ROOT'],  "{DOCROOT}$sep", $o);
+	$o = str_replace($_SERVER['DOCUMENT_ROOT'],  "{DOCROOT}" . (substr($d, -1) == $sep ? $sep : ""), $o);
 	$xcachedir = realpath(dirname(__FILE__) . "$sep..$sep");
 	$o = str_replace($xcachedir . $sep, "{XCache}$sep", $o);
Index: /branches/1.3/admin/header.tpl.php
===================================================================
--- /branches/1.3/admin/header.tpl.php	(revision 622)
+++ /branches/1.3/admin/header.tpl.php	(revision 623)
@@ -1,3 +1,3 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!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>
Index: /branches/1.3/admin/help-en.lang.php
===================================================================
--- /branches/1.3/admin/help-en.lang.php	(revision 622)
+++ /branches/1.3/admin/help-en.lang.php	(revision 623)
@@ -4,8 +4,11 @@
 <dt><?php echo _T('Size'); ?>: </dt><dd>Cache Size, Size of the cache (or cache chunk), in bytes</dd>
 <dt><?php echo _T('Avail'); ?>: </dt><dd>Available Memory, free memory in bytes of this cache</dd>
-<dt><?php echo _T('%'); ?>: </dt><dd>Percent, A bar shows how much memory available in percent</dd>
+<dt><?php echo _T('% Used'); ?>: </dt><dd>Percent, A bar shows how much memory available in percent, and memory blocks status</dd>
 <dt><?php echo _T('Clear'); ?>: </dt><dd>Clear Button, Press the button to clean this cache</dd>
 <dt><?php echo _T('Compiling'); ?>: </dt><dd>Compiling flag, "yes" if the cache is busy compiling php script</dd>
 <dt><?php echo _T('Hits'); ?>: </dt><dd>Cache Hits, hit=a var/php is loaded from this cache</dd>
+<dt><?php echo _T('Hits/H'); ?>: </dt><dd>Average Hits per Hour. Only last 24 hours is logged</dd>
+<dt><?php echo _T('Hits 24H'); ?>: </dt><dd>Hits 24 Hours. Hits graph of last 24 hours</dd>
+<dt><?php echo _T('Hits/S'); ?>: </dt><dd>Average Hits per Second. Only last 5 seconds is logged</dd>
 <dt><?php echo _T('Misses'); ?>: </dt><dd>Cache Misses, miss=a var/php is requested but not in the cache</dd>
 <dt><?php echo _T('Clogs'); ?>: </dt><dd>Compiling Clogs, clog=compiling is needed but avoided to wait(be blocked) when the cache is busy compiling already</dd>
Index: /branches/1.3/admin/help-zh-simplified-utf-8.lang.php
===================================================================
--- /branches/1.3/admin/help-zh-simplified-utf-8.lang.php	(revision 622)
+++ /branches/1.3/admin/help-zh-simplified-utf-8.lang.php	(revision 623)
@@ -4,8 +4,11 @@
 <dt><?php echo _T('Size'); ?>: </dt><dd>共享内存区大小, 单位: 字节</dd>
 <dt><?php echo _T('Avail'); ?>: </dt><dd>可用内存, 对应共享内存区的剩余内存字节数</dd>
-<dt><?php echo _T('%'); ?>: </dt><dd>百分比, 条状显示可用内存的比例</dd>
+<dt><?php echo _T('% Used'); ?>: </dt><dd>百分比, 条状显示可用内存的比例, 以及显示分配块状态</dd>
 <dt><?php echo _T('Clear'); ?>: </dt><dd>清除按钮, 点击按钮清除对应共享内存区的数据</dd>
 <dt><?php echo _T('Compiling'); ?>: </dt><dd>编译标记, 当共享内存区正在编译 php 脚本时标记为 "yes"</dd>
 <dt><?php echo _T('Hits'); ?>: </dt><dd>共享内存命中次数, 命中=从该共享内存载入php或者变量</dd>
+<dt><?php echo _T('Hits/H'); ?>: </dt><dd>每小时命中次数. 只统计最后 24 小时</dd>
+<dt><?php echo _T('Hits 24H'); ?>: </dt><dd>24 小时命中分布图. 图表现是最后 24 小时的命中次数</dd>
+<dt><?php echo _T('Hits/S'); ?>: </dt><dd>每秒命中次数. 只统计最后 5 秒</dd>
 <dt><?php echo _T('Misses'); ?>: </dt><dd>共享内存错过次数, 错过=请求的php或者变量并不在该共享内存内</dd>
 <dt><?php echo _T('Clogs'); ?>: </dt><dd>编译阻塞跳过, 阻塞=当需该共享内存区负责编译时, 其他进程/现成无法访问此共享内存. 跳过=XCache 自动判断阻塞的共享内存区自动跳过阻塞等待, 直接使用非共享内存方式继续处理请求</dd>
Index: /branches/1.3/admin/help-zh-traditional-utf-8.lang.php
===================================================================
--- /branches/1.3/admin/help-zh-traditional-utf-8.lang.php	(revision 622)
+++ /branches/1.3/admin/help-zh-traditional-utf-8.lang.php	(revision 623)
@@ -4,5 +4,5 @@
 <dt><?php echo _T('Size'); ?>: </dt><dd>共享記憶體區大小，單位：位元</dd>
 <dt><?php echo _T('Avail'); ?>: </dt><dd>可用記憶體，對應共享記憶體區的剩餘記憶體位元數</dd>
-<dt><?php echo _T('%'); ?>: </dt><dd>百分比，條狀顯示可用記憶體的比例</dd>
+<dt><?php echo _T('% Used'); ?>: </dt><dd>百分比，條狀顯示可用記憶體的比例</dd>
 <dt><?php echo _T('Clear'); ?>: </dt><dd>清除按鈕，點擊按鈕清除對應共享記憶體區的資料</dd>
 <dt><?php echo _T('Compiling'); ?>: </dt><dd>編譯標記，當共享記憶體區正在編譯 php 指令時標記為 "yes"</dd>
Index: /branches/1.3/admin/xcache.css
===================================================================
--- /branches/1.3/admin/xcache.css	(revision 622)
+++ /branches/1.3/admin/xcache.css	(revision 623)
@@ -1,5 +1,7 @@
 input, table { font-family: sans-serif; }
 input { font-size: 12px; }
-table { border-collapse: collapse; font-size: 11px; }
+table { border-collapse: collapse; font-size: 11px; margin: 0; margin-bottom: 10px; }
+table caption, h2 { font-size: 16px; font-weight: bold; text-align: left; padding-top: 20px; margin-bottom: 2px; }
+table { white-space: pre; }
 table.cycles { border: 1px solid black; margin-top: 5px; margin-bottom: 5px; }
 table.cycles .col1 { background-color: #f5f5f5; }
@@ -17,11 +19,24 @@
 .button { }
 span.sortarrow { color: white; text-decoration: none; }
-.freeblocks { float: left; margin-right: 4px;}
-.freeblocks td { text-align: right; }
 form {margin: 0; padding: 0}
-.percent { border: 1px solid black; width: 80%; height: 20px; }
-.percent div { font-size: 1px; line-height: 1px; width: 100%;}
-.percent .pavail { background: blue; }
-.switcher, h1, h2 { text-align: center; display: block; }
+
+.percent { height: 3px; margin-bottom: 1px; border: 1px solid gray; }
+.percent div { float: left; height: 100%; }
+.pvalue { background: limegreen; }
+
+.blocksgraph { height: 16px; }
+.blocksgraph div { float: left; height: 3px; width: 4px; border: solid gray; border-width: 0 0px 1px 0; }
+.blocksgraph { border: 1px solid gray; border-bottom: 0px; }
+
+.hitsgraph { height: 20px; margin: auto; }
+.hitsgraph div { float: left; width: 2px; height: 100%; }
+.hitsgraph div:hover { background: gray; }
+.hitsgraph div div { float: none; width: 100%; }
+.hitsgraph div div.barf { border: 0px solid gray; border-width: 1px 0 0 0; }
+.hitsgraph div div.barv { border: 0px solid gray; border-width: 0 0 1px 0; }
+.hitsgraph div div.barf.active { border-color: yellow; }
+.hitsgraph div div.barv.active { border-color: yellow; }
+
+.switcher, h1 { text-align: center; display: block; }
 .switcher * { color: blue; }
 .switcher a.active { font-weight: bold; font-size: 130%; color: black; }
@@ -31,2 +46,5 @@
 dt { font-weight: bold; clear: both; float: left; width: 100px; text-align: right; margin: 0; }
 dd { margin: 0; }
+.blockarea { overflow: hidden; _width: 1px; }
+div.legend { float: left; border: 1px solid gray; font: 12px/12px monospace; }
+div.legendtitle { float: left; padding: 2px; padding-right: 10px; font: 12px/12px monospace; }
Index: /branches/1.3/admin/xcache.php
===================================================================
--- /branches/1.3/admin/xcache.php	(revision 622)
+++ /branches/1.3/admin/xcache.php	(revision 623)
@@ -73,4 +73,112 @@
 
 	return '0 s';
+}
+
+function freeblock_to_graph($freeblocks, $size)
+{
+	global $graph_width, $usage_graph_width, $free_graph_width;
+
+	// cached in static variable
+	static $graph_initial;
+	if (!isset($graph_initial)) {
+		$graph_initial = array_fill(0, $graph_width, 0);
+	}
+	$graph = $graph_initial;
+	foreach ($freeblocks as $b) {
+		$begin = $b['offset'] / $size * $graph_width;
+		$end = ($b['offset'] + $b['size']) / $size * $graph_width;
+
+		if ((int) $begin == (int) $end) {
+			$v = $end - $begin;
+			$graph[(int) $v] += $v - (int) $v;
+		}
+		else {
+			$graph[(int) $begin] += 1 - ($begin - (int) $begin);
+			$graph[(int) $end] += $end - (int) $end;
+			for ($i = (int) $begin + 1, $e = (int) $end; $i < $e; $i ++) {
+				$graph[$i] += 1;
+			}
+		}
+	}
+	$html = array();
+	$c = 255;
+	foreach ($graph as $k => $v) {
+		if (!isset($free_graph_width)) {
+			$v = 1 - $v;
+		}
+		$v = (int) ($v * $c);
+		$r = $g = $c - $v;
+		$b = $c;
+		$html[] = '<div style="background: rgb(' . "$r,$g,$b" . ')"></div>';
+	}
+	return implode('', $html);
+}
+
+function calc_total(&$total, $data)
+{
+	foreach ($data as $k => $v) {
+		switch ($k) {
+		case 'type':
+		case 'cache_name':
+		case 'cacheid':
+		case 'free_blocks':
+			continue 2;
+		}
+		if (!isset($total[$k])) {
+			$total[$k] = $v;
+		}
+		else {
+			switch ($k) {
+			case 'his_by_hour':
+			case 'his_by_second':
+				foreach ($data[$k] as $kk => $vv) {
+					$total[$k][$kk] += $vv;
+				}
+				break;
+
+			default:
+				$total[$k] += $v;
+			}
+		}
+	}
+}
+
+function array_avg($a)
+{
+	if (count($a) == 0) {
+		return '';
+	}
+	return array_sum($a) / count($a);
+}
+
+function bar_hits_percent($v, $percent, $active)
+{
+	$r = 220 + (int) ($percent * 25);
+	$g = $b = 220 - (int) ($percent * 220);
+	$percent = (int) ($percent * 100);
+	$a = $active ? ' active' : '';
+	return '<div title="' . $v . '">'
+		. '<div class="barf' . $a . '" style="height: ' . (100 - $percent) . '%"></div>'
+		. '<div class="barv' . $a . '" style="background: rgb(' . "$r,$g,$b" . '); height: ' . $percent . '%"></div>'
+		. '</div>';
+}
+
+function hits_to_graph($hits)
+{
+	$max = 0;
+	foreach ($hits as $v) {
+		if ($max < $v) {
+			$max = $v;
+		}
+	}
+	if (!$max) {
+		return '';
+	}
+	$t = (time() / (60 * 60)) % 24;
+	$html = array();
+	foreach ($hits as $i => $v) {
+		$html[] = bar_hits_percent($v, $v / $max, $i == $t);
+	}
+	return implode('', $html);
 }
 
@@ -130,5 +238,13 @@
 		$cacheid = (int) (isset($_POST['cacheid']) ? $_POST['cacheid'] : 0);
 		if (isset($_POST['clearcache'])) {
-			xcache_clear_cache($type, $cacheid);
+			$count = xcache_count($type);
+			if ($cacheid == $count) {
+				for ($cacheid = 0; $cacheid < $count; $cacheid ++) {
+					xcache_clear_cache($type, $cacheid);
+				}
+			}
+			else {
+				xcache_clear_cache($type, $cacheid);
+			}
 		}
 	}
@@ -138,4 +254,5 @@
 // {{{ load info/list
 $cacheinfos = array();
+$total = array();
 for ($i = 0; $i < $pcnt; $i ++) {
 	$data = xcache_info(XC_TYPE_PHP, $i);
@@ -147,5 +264,19 @@
 	$data['cacheid'] = $i;
 	$cacheinfos[] = $data;
-}
+	if ($pcnt >= 2) {
+		calc_total($total, $data);
+	}
+}
+
+if ($pcnt >= 2) {
+	$total['type'] = XC_TYPE_PHP;
+	$total['cache_name'] = _T('Total');
+	$total['cacheid'] = $pcnt;
+	$total['gc'] = null;
+	$total['istotal'] = true;
+	$cacheinfos[] = $total;
+}
+
+$total = array();
 for ($i = 0; $i < $vcnt; $i ++) {
 	$data = xcache_info(XC_TYPE_VAR, $i);
@@ -157,4 +288,16 @@
 	$data['cacheid'] = $i;
 	$cacheinfos[] = $data;
+	if ($pcnt >= 2) {
+		calc_total($total, $data);
+	}
+}
+
+if ($vcnt >= 2) {
+	$total['type'] = XC_TYPE_VAR;
+	$total['cache_name'] = _T('Total');
+	$total['cacheid'] = $vcnt;
+	$total['gc'] = null;
+	$total['istotal'] = true;
+	$cacheinfos[] = $total;
 }
 // }}}
@@ -171,4 +314,7 @@
 	}
 	foreach ($cacheinfos as $i => $c) {
+		if (!empty($c['istotal'])) {
+			continue;
+		}
 		if ($c['type'] == $type && isset($c['cache_list'])) {
 			foreach ($c['cache_list'] as $e) {
Index: /branches/1.3/admin/xcache.tpl.php
===================================================================
--- /branches/1.3/admin/xcache.tpl.php	(revision 622)
+++ /branches/1.3/admin/xcache.tpl.php	(revision 623)
@@ -1,18 +1,23 @@
 <?php include("header.tpl.php"); ?>
-<a href="help.php" target="_blank" id="help"><?php echo _T("Help") ?> &raquo;</a>
-<span class="switcher"><?php echo switcher("type", $types); ?></span>
+<div id="help">
+	<a href="help.php"><?php echo _T("Help") ?> &raquo;</a>
+</div>
+<div class="switcher"><?php echo switcher("type", $types); ?></div>
 <?php
 $a = new Cycle('class="col1"', 'class="col2"');
 $b = new Cycle('class="col1"', 'class="col2"');
 ?>
-<?php echo _T('Caches'); ?>:
 <table cellspacing="0" cellpadding="4" class="cycles">
-	<col />
-	<col align="right" />
-	<col align="right" />
-	<col align="right" />
-	<col />
-	<col />
-	<col align="right" />
+	<caption><?php echo _T('Caches'); ?></caption>
+	<col />
+	<col align="right" />
+	<col align="right" />
+	<col align="right" />
+	<col />
+	<col />
+	<col align="right" />
+	<col align="right" />
+	<col align="right" />
+	<col />
 	<col align="right" />
 	<col align="right" />
@@ -28,8 +33,11 @@
 		<th><?php echo _T('Size'); ?></th>
 		<th><?php echo _T('Avail'); ?></th>
-		<th><?php echo _T('%'); ?></th>
+		<th><?php echo _T(isset($free_graph_width) ? '% Free' : '% Used'); ?></th>
 		<th><?php echo _T('Clear'); ?></th>
 		<th><?php echo _T('Compiling'); ?></th>
 		<th><?php echo _T('Hits'); ?></th>
+		<th><?php echo _T('Hits/H'); ?></th>
+		<th><?php echo _T('Hits 24H'); ?></th>
+		<th><?php echo _T('Hits/S'); ?></th>
 		<th><?php echo _T('Misses'); ?></th>
 		<th><?php echo _T('Clogs'); ?></th>
@@ -48,6 +56,21 @@
 		echo "
 		<tr ", $a->next(), ">";
-		$pavail = (int) ($ci['avail'] / $ci['size'] * 100);
-		$pused = 100 - $pavail;
+		$pvalue = (int) ($ci['avail'] / $ci['size'] * 100);
+		$pempty = 100 - $pvalue;
+		if (!isset($free_graph_width)) {
+			// swap
+			$tmp = $pvalue;
+			$pvalue = $pempty;
+			$pempty = $tmp;
+		}
+
+		$w = $graph_width;
+		if (empty($ci['istotal'])) {
+			$graph = freeblock_to_graph($ci['free_blocks'], $ci['size']);
+			$blocksgraph = "<div class=\"blocksgraph\" style=\"width: {$w}px\">{$graph}</div>";
+		}
+		else {
+			$blocksgraph = '';
+		}
 
 		$ci_slots = size($ci['slots']);
@@ -55,6 +78,18 @@
 		$ci_avail = size($ci['avail']);
 		$ci = number_formats($ci, $numkeys);
-		$ci['compiling']    = $ci['type'] == $type_php ? ($ci['compiling'] ? 'yes' : 'no') : '-';
-		$ci['can_readonly'] = $ci['can_readonly'] ? 'yes' : 'no';
+
+		$hits_avg_h     = number_format(array_avg($ci['hits_by_hour']), 2);
+		$hits_avg_s     = number_format(array_avg($ci['hits_by_second']), 2);
+		$hits_graph_h   = hits_to_graph($ci['hits_by_hour']);
+		$hits_graph_h_w = count($ci['hits_by_hour']) * 2;
+
+		if (!empty($ci['istotal'])) {
+			$ci['compiling']    = '-';
+			$ci['can_readonly'] = '-';
+		}
+		else {
+			$ci['compiling']    = $ci['type'] == $type_php ? ($ci['compiling'] ? 'yes' : 'no') : '-';
+			$ci['can_readonly'] = $ci['can_readonly'] ? 'yes' : 'no';
+		}
 		echo <<<EOS
 		<th>{$ci['cache_name']}</th>
@@ -62,16 +97,24 @@
 		<td title="{$ci['size']}">{$ci_size}</td>
 		<td title="{$ci['avail']}">{$ci_avail}</td>
-		<td title="{$pavail} %"><div class="percent"><div style="height: {$pused}%" class="pused">&nbsp;</div><div style="height: {$pavail}%" class="pavail">&nbsp;</div></div></td>
-		<td>
-			<form method="post">
-				<div>
-					<input type="hidden" name="type" value="{$ci['type']}">
-					<input type="hidden" name="cacheid" value="{$ci['cacheid']}">
-					<input type="submit" name="clearcache" value="{$l_clear}" class="submit" onclick="return confirm('{$l_clear_confirm}');" />
-				</div>
-			</form>
-		</td>
+		<td title="{$pvalue} %"
+			><div class="percent" style="width: {$w}px"
+				><div style="width: {$pvalue}%" class="pvalue"></div
+				><div style="width: {$pempty}%" class="pempty"></div
+			></div
+		>{$blocksgraph}</td>
+		<td
+			><form method="post" action=""
+				><div
+					><input type="hidden" name="type" value="{$ci['type']}"
+					/><input type="hidden" name="cacheid" value="{$ci['cacheid']}"
+					/><input type="submit" name="clearcache" value="{$l_clear}" class="submit" onclick="return confirm('{$l_clear_confirm}');"
+				/></div
+			></form
+		></td>
 		<td>{$ci['compiling']}</td>
 		<td>{$ci['hits']}</td>
+		<td>{$hits_avg_h}</td>
+		<td><div class="hitsgraph" style="width: {$hits_graph_h_w}px">{$hits_graph_h}</div></td>
+		<td>{$hits_avg_s}</td>
 		<td>{$ci['misses']}</td>
 		<td>{$ci['clogs']}</td>
@@ -89,31 +132,13 @@
 	<?php } ?>
 </table>
-<div>
-	<?php echo _T('Free Blocks'); ?>:
+<div class="blockarea legends">
+	<div class="legendtitle"><?php echo _T('Legends:'); ?></div>
+	<div class="legend pvalue">&nbsp;&nbsp;</div>
+	<div class="legendtitle"><?php echo _T(isset($free_graph_width) ? '% Free' : '% Used'); ?></div>
+	<div class="legend" style="background: rgb(0,0,255)">&nbsp;&nbsp;</div>
+	<div class="legendtitle"><?php echo _T(isset($free_graph_width) ? 'Free Blocks' : 'Used Blocks'); ?></div>
+	<div class="legend" style="background: rgb(255,0,0)">&nbsp;&nbsp;</div>
+	<div class="legendtitle"><?php echo _T('Hits'); ?></div>
 </div>
-<?php
-foreach ($cacheinfos as $i => $ci) {
-	$b->reset();
-?>
-<table cellspacing="0" cellpadding="4" class="cycles freeblocks">
-	<tr>
-		<th><?php echo $ci['cache_name']; ?> <?php echo _T("size"); ?><br><?php echo _T("offset"); ?></th>
-	<?php
-	foreach ($ci['free_blocks'] as $block) {
-		$size   = size($block['size']);
-		$offset = size($block['offset']);
-
-		$c = $b->next();
-		echo "
-		<td $c><nobr>$size<br>$offset</nobr></td>";
-	}
-	?>
-
-	</tr>
-</table>
-<?php
-}
-?>
-<div style="clear: both">&nbsp;</div>
 <?php
 
@@ -125,10 +150,9 @@
 	foreach (array('Cached' => $cachelist['cache_list'], 'Deleted' => $cachelist['deleted_list']) as $listname => $entries) {
 		$a->reset();
-		echo "
-		<caption>", _T("{$cachelist['type_name']} $listname"), "</caption>";
 		?>
 
 	<form action="" method="post">
-	<table cellspacing="0" cellpadding="4" class="cycles entrys" width="100%">
+	<table cellspacing="0" cellpadding="4" class="cycles entries" width="100%">
+		<caption><?php echo _T("{$cachelist['type_name']} $listname"); ?></caption>
 		<col />
 		<col />
Index: /branches/1.3/coverager.c
===================================================================
--- /branches/1.3/coverager.c	(revision 622)
+++ /branches/1.3/coverager.c	(revision 623)
@@ -470,4 +470,5 @@
 
 	if (cfg_get_string("xcache.coveragedump_directory", &xc_coveragedump_dir) == SUCCESS && xc_coveragedump_dir) {
+		xc_coveragedump_dir = pestrdup(xc_coveragedump_dir, 1);
 		int len = strlen(xc_coveragedump_dir);
 		if (len) {
@@ -477,4 +478,5 @@
 		}
 		if (!strlen(xc_coveragedump_dir)) {
+			pefree(xc_coveragedump_dir, 1);
 			xc_coveragedump_dir = NULL;
 		}
@@ -490,4 +492,5 @@
 	}
 	if (xc_coveragedump_dir) {
+		pefree(xc_coveragedump_dir, 1);
 		xc_coveragedump_dir = NULL;
 	}
Index: /branches/1.3/coverager/config.php.example
===================================================================
--- /branches/1.3/coverager/config.php.example	(revision 622)
+++ /branches/1.3/coverager/config.php.example	(revision 623)
@@ -22,5 +22,5 @@
 {
 	$sep = DIRECTORY_SEPARATOR;
-	$o = str_replace($_SERVER['DOCUMENT_ROOT'],  "{DOCROOT}$sep", $o);
+	$o = str_replace($_SERVER['DOCUMENT_ROOT'],  "{DOCROOT}" . (substr($d, -1) == $sep ? $sep : ""), $o);
 	$xcachedir = realpath(dirname(__FILE__) . "$sep..$sep");
 	$o = str_replace($xcachedir . $sep, "{XCache}$sep", $o);
Index: /branches/1.3/coverager/coverager.css
===================================================================
--- /branches/1.3/coverager/coverager.css	(revision 622)
+++ /branches/1.3/coverager/coverager.css	(revision 623)
@@ -3,4 +3,6 @@
 th { font-size: 12px; }
 table { border-collapse: collapse; }
+table.center { margin-left: auto; margin-right: auto; }
+table\-center { text-align: center; }
 table.cycles { border: 1px solid black; margin-top: 5px; margin-bottom: 5px; }
 table.cycles .col1 { background-color: #f5f5f5; }
@@ -55,9 +57,13 @@
 .lineCov   { background-color: #F0F0F0; }
 .lineNoCov { background-color: #ffe0e0; }
+div.code {
+	border: 1px solid gray;
+	font-size: 12px;
+}
 pre.code {
 	font-family: monospace;
 	font-size: 12px;
 	white-space: pre;
-	border: 1px solid gray;
+	padding: 0; margin: 0;
 }
 
Index: /branches/1.3/coverager/coverager.php
===================================================================
--- /branches/1.3/coverager/coverager.php	(revision 622)
+++ /branches/1.3/coverager/coverager.php	(revision 623)
@@ -114,6 +114,6 @@
 				$lines = explode('<br />', $lines);
 				$last = array_pop($lines);
+				$lines[count($lines) - 1] .= $last;
 				$filecov = sprint_cov($fileinfo['cov'], $lines, false);
-				$filecov .= $last;
 				unset($source);
 			}
@@ -325,5 +325,5 @@
 		}
 		if (isset($cov[$offs])) {
-			$lines[$l] = sprintf("<li class=\"line%sCov\"> %s\t%s\n</li>"
+			$lines[$l] = sprintf("<li class=\"line%sCov\"><pre class=\"code\"> %s\t%s\n</pre></li>"
 					, $cov[$offs] ? '' : 'No'
 					, $cov[$offs]
@@ -331,5 +331,5 @@
 		}
 		else {
-			$lines[$l] = "<li>\t$line\n</li>";
+			$lines[$l] = "<li><pre class=\"code\">\t$line\n</pre></li>";
 		}
 	}
Index: /branches/1.3/coverager/coverager.tpl.php
===================================================================
--- /branches/1.3/coverager/coverager.tpl.php	(revision 622)
+++ /branches/1.3/coverager/coverager.tpl.php	(revision 623)
@@ -1,3 +1,3 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!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>
@@ -56,5 +56,6 @@
 	$l_tds = _T("TODO");
 	return <<<EOS
-	<table align="center" cellpadding="2" cellspacing="0" border="0" class="cycles">
+<div class="table-center">
+	<table cellpadding="2" cellspacing="0" border="0" class="cycles center">
 	<tr>
 		<th>{$l_dir}</th><th>{$l_per}</th><th>{$l_hit}</th><th>{$l_lns}</th><th>{$l_tds}</th>
@@ -105,4 +106,5 @@
 	return <<<EOS
 	</table>
+</div>
 EOS;
 }
@@ -117,6 +119,6 @@
 	$l_lns = _T("Lines");
 	return <<<EOS
-	<br>
-	<table align="center" cellpadding="2" cellspacing="0" border="0" class="cycles">
+<div class="center-table">
+	<table cellpadding="2" cellspacing="0" border="0" class="cycles center">
 	<tr>
 		<th>{$l_fil}</th><th>{$l_per}</th><th>{$l_hit}</th><th>{$l_lns}</th>
@@ -162,4 +164,5 @@
 	return <<<EOS
     </table>
+</div>
 EOS;
 }
@@ -172,5 +175,7 @@
 	$path_html = htmlspecialchars($path);
 	echo <<<EOS
-	<a href="?">$l_root</a> $path<br />
+	<div>
+		<a href="?">$l_root</a> $path<br />
+	</div>
 EOS;
 	echo dir_head($dirinfo);
@@ -199,5 +204,7 @@
 	$dir_html = htmlspecialchars($dir);
 	echo <<<EOS
-	<a href="?">$l_root</a> <a href="?path={$dir_url}">{$dir_html}</a>/<strong>{$filename}</strong><br />
+	<div>
+		<a href="?">$l_root</a> <a href="?path={$dir_url}">{$dir_html}</a>/<strong>{$filename}</strong><br />
+	</div>
 EOS;
 
@@ -209,5 +216,7 @@
 		$tplfile_html = htmlspecialchars($tplfile);
 		echo <<<EOS
-		<a href="#tpl">{$tplfile_html}</a><br />
+		<div>
+			<a href="#tpl">{$tplfile_html}</a><br />
+		</div>
 EOS;
 	}
@@ -216,10 +225,14 @@
 	}
 	echo <<<EOS
-	<pre class="code"><ol>{$filecov}</ol></pre>
+	<div class="code">
+		<ol>{$filecov}</ol>
+	</div>
 EOS;
 	if ($tplfile) {
 		echo <<<EOS
 	<a name="tpl">{$tplfile}</a>
-	<pre class="code"><ol>{$tplcov}</ol></pre>
+	<div class="code">
+		<ol>{$tplcov}</ol>
+	</div>
 EOS;
 	}
Index: /branches/1.3/mkopcode_spec.awk
===================================================================
--- /branches/1.3/mkopcode_spec.awk	(revision 622)
+++ /branches/1.3/mkopcode_spec.awk	(revision 623)
@@ -15,5 +15,9 @@
 			exit
 		}
-		printf "\tOPSPEC(%10s, %10s, %10s, %10s)\n", array[1], array[2], array[3], array[4]
+		comment = "";
+		if (match($0, /\/\* (\d+) \*\//, comments)) {
+			comment = comments[1];
+		}
+		printf "\tOPSPEC(%10s, %10s, %10s, %10s)%s\n", array[1], array[2], array[3], array[4], comment;
 		next
 	}
Index: /branches/1.3/phpdc.phpr
===================================================================
--- /branches/1.3/phpdc.phpr	(revision 622)
+++ /branches/1.3/phpdc.phpr	(revision 623)
@@ -13,5 +13,5 @@
 }
 
-$dc = &new Decompiler();
+$dc = new Decompiler();
 if (isset($argv[1])) {
 	$dc->decompileFile($argv[1]);
Index: /branches/1.3/processor/hashtable.m4
===================================================================
--- /branches/1.3/processor/hashtable.m4	(revision 622)
+++ /branches/1.3/processor/hashtable.m4	(revision 623)
@@ -123,5 +123,5 @@
 				fprintf(stderr, "$2:\"");
 				xc_dprint_str_len(BUCKET_KEY_S(b), BUCKET_KEY_SIZE(b));
-				fprintf(stderr, "\" %d:h=%lu", BUCKET_KEY_SIZE(b), b->h);
+				fprintf(stderr, "\" %d:h=%lu ", BUCKET_KEY_SIZE(b), b->h);
 			')
 			if (sizeof(void *) == sizeof($2)) {
Index: /branches/1.3/processor/processor.m4
===================================================================
--- /branches/1.3/processor/processor.m4	(revision 622)
+++ /branches/1.3/processor/processor.m4	(revision 623)
@@ -211,5 +211,5 @@
 				dnl fprintf(stderr, "copy from %p to %p\n", src[0], dst[0]);
 			')
-			IFDPRINT(`INDENT()`'fprintf(stderr, "[%p]", src[0]);')
+			IFDPRINT(`INDENT()`'fprintf(stderr, "[%p] ", src[0]);')
 			STRUCT_P_EX(zval, dst[0], src[0], `[0]', `', ` ')
 			FIXPOINTER_EX(zval, dst[0])
@@ -475,4 +475,7 @@
 	IFCOPY(`
 		switch (src->opcode) {
+#ifdef ZEND_GOTO
+			case ZEND_GOTO:
+#endif
 			case ZEND_JMP:
 				dst->op1.u.jmp_addr = processor->active_opcodes_dst + (src->op1.u.jmp_addr - processor->active_opcodes_src);
Index: /branches/1.3/processor/struct.m4
===================================================================
--- /branches/1.3/processor/struct.m4	(revision 622)
+++ /branches/1.3/processor/struct.m4	(revision 623)
@@ -60,5 +60,5 @@
 
 		IFDPRINT(`
-			fprintf(stderr, "%s", " {\n");
+			fprintf(stderr, "%s", "{\n");
 			indent ++;
 		')
@@ -146,5 +146,5 @@
 	DBG(`$0($*)')
 	if (src->$2) {
-		IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2");')
+		IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2 ");')
 		STRUCT_P_EX(`$1', `dst->$2', `src->$2', `$2', `$3')
 	}
@@ -160,5 +160,5 @@
 	DBG(`$0($*)')
 	assert(sizeof($1) == sizeof(src->$2));
-	IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2");')
+	IFDPRINT(`INDENT()`'fprintf(stderr, "$1:$2 ");')
 	STRUCT_P_EX(`$1', `dst->$2', `src->$2', `$2', `$3', `&')
 	DONE(`$2')
Index: /branches/1.3/run-xcachetest
===================================================================
--- /branches/1.3/run-xcachetest	(revision 622)
+++ /branches/1.3/run-xcachetest	(revision 623)
@@ -19,5 +19,5 @@
 if test -z "$TEST_PHP_USER" ; then
 	TEST_PHP_USER="$PHP_SRC/tests"
-	for i in Zend ZendEngine2 ext/standard/tests ext/reflection/tests ; do
+	for i in Zend ZendEngine2 ext/standard/tests ext/reflection/tests ext/spl/tests; do
 		if test -d "$PHP_SRC/$i" ; then
 			TEST_PHP_USER="$TEST_PHP_USER,$PHP_SRC/$i"
Index: /branches/1.3/utils.c
===================================================================
--- /branches/1.3/utils.c	(revision 622)
+++ /branches/1.3/utils.c	(revision 623)
@@ -144,4 +144,7 @@
 #ifdef ZEND_ENGINE_2_1
 		switch (opline->opcode) {
+#ifdef ZEND_GOTO
+			case ZEND_GOTO:
+#endif
 			case ZEND_JMP:
 				opline->op1.u.opline_num = opline->op1.u.jmp_addr - op_array->opcodes;
@@ -194,4 +197,7 @@
 #ifdef ZEND_ENGINE_2_1
 		switch (opline->opcode) {
+#ifdef ZEND_GOTO
+			case ZEND_GOTO:
+#endif
 			case ZEND_JMP:
 				assert(opline->op1.u.opline_num < op_array->last);
@@ -294,4 +300,7 @@
 	while (opline < end) {
 		switch (opline->opcode) {
+#ifdef ZEND_GOTO
+			case ZEND_GOTO:
+#endif
 			case ZEND_JMP:
 				next = begin + opline->op1.u.opline_num;
Index: /branches/1.3/utils.h
===================================================================
--- /branches/1.3/utils.h	(revision 622)
+++ /branches/1.3/utils.h	(revision 623)
@@ -80,5 +80,4 @@
 typedef struct {
 	int alloc;
-	int orig_user_error_handler_error_reporting;
 	char *filename;
 
@@ -98,4 +97,8 @@
 	Bucket    *tmp_internal_function_tail;
 	Bucket    *tmp_internal_class_tail;
+
+#ifdef E_STRICT
+	int orig_user_error_handler_error_reporting;
+#endif
 } xc_sandbox_t;
 
Index: /branches/1.3/xcache-test.ini
===================================================================
--- /branches/1.3/xcache-test.ini	(revision 622)
+++ /branches/1.3/xcache-test.ini	(revision 623)
@@ -1,3 +1,2 @@
-auto_globals_jit = Off
 memory_limit = 256M
 
Index: /branches/1.3/xcache.c
===================================================================
--- /branches/1.3/xcache.c	(revision 622)
+++ /branches/1.3/xcache.c	(revision 623)
@@ -87,4 +87,9 @@
 
 static zend_bool xc_initized = 0;
+static time_t xc_init_time = 0;
+static long unsigned xc_init_instance_id = 0;
+#ifdef ZTS
+static long unsigned xc_init_instance_subid = 0;
+#endif
 static zend_compile_file_t *origin_compile_file = NULL;
 static zend_compile_file_t *old_compile_file = NULL;
@@ -247,4 +252,53 @@
 /* }}} */
 #endif
+static inline zend_uint advance_wrapped(zend_uint val, zend_uint count) /* {{{ */
+{
+	if (val + 1 >= count) {
+		return 0;
+	}
+	return val + 1;
+}
+/* }}} */
+static void xc_counters_inc(time_t *curtime, zend_uint *curslot, time_t period, zend_ulong *counters, zend_uint count TSRMLS_DC) /* {{{ */
+{
+	time_t n = XG(request_time) / period;
+	if (*curtime != n) {
+		zend_uint target_slot = n % count;
+		if (n - *curtime > period) {
+			memset(counters, 0, sizeof(counters[0]) * count);
+		}
+		else {
+			zend_uint slot;
+			for (slot = advance_wrapped(*curslot, count);
+					slot != target_slot;
+					slot = advance_wrapped(slot, count)) {
+				counters[slot] = 0;
+			}
+			counters[target_slot] = 0;
+		}
+		*curtime = n;
+		*curslot = target_slot;
+	}
+	counters[*curslot] ++;
+}
+/* }}} */
+static void xc_cache_hit_dmz(xc_cache_t *cache TSRMLS_DC) /* {{{ */
+{
+	cache->hits ++;
+
+	xc_counters_inc(&cache->hits_by_hour_cur_time
+			, &cache->hits_by_hour_cur_slot, 60 * 60
+			, cache->hits_by_hour
+			, sizeof(cache->hits_by_hour) / sizeof(cache->hits_by_hour[0])
+			TSRMLS_CC);
+
+	xc_counters_inc(&cache->hits_by_second_cur_time
+			, &cache->hits_by_second_cur_slot
+			, 1
+			, cache->hits_by_second
+			, sizeof(cache->hits_by_second) / sizeof(cache->hits_by_second[0])
+			TSRMLS_CC);
+}
+/* }}} */
 
 /* helper function that loop through each entry */
@@ -311,5 +365,5 @@
 	int i, c;
 
-	if (!xc_php_ttl || !xc_php_gc_interval) {
+	if (!xc_php_ttl || !xc_php_gc_interval || !xc_php_caches) {
 		return;
 	}
@@ -324,5 +378,5 @@
 	int i, c;
 
-	if (!xc_var_gc_interval) {
+	if (!xc_var_gc_interval || !xc_var_caches) {
 		return;
 	}
@@ -372,10 +426,14 @@
 	int i, c;
 
-	for (i = 0, c = xc_php_hcache.size; i < c; i ++) {
-		xc_gc_deletes_one(xc_php_caches[i] TSRMLS_CC);
-	}
-
-	for (i = 0, c = xc_var_hcache.size; i < c; i ++) {
-		xc_gc_deletes_one(xc_var_caches[i] TSRMLS_CC);
+	if (xc_php_caches) {
+		for (i = 0, c = xc_php_hcache.size; i < c; i ++) {
+			xc_gc_deletes_one(xc_php_caches[i] TSRMLS_CC);
+		}
+	}
+
+	if (xc_var_caches) {
+		for (i = 0, c = xc_var_hcache.size; i < c; i ++) {
+			xc_gc_deletes_one(xc_var_caches[i] TSRMLS_CC);
+		}
 	}
 }
@@ -385,5 +443,6 @@
 static void xc_fillinfo_dmz(int cachetype, xc_cache_t *cache, zval *return_value TSRMLS_DC) /* {{{ */
 {
-	zval *blocks;
+	zval *blocks, *hits;
+	int i;
 	const xc_block_t *b;
 #ifndef NDEBUG
@@ -417,4 +476,17 @@
 		add_assoc_null_ex(return_value, ZEND_STRS("gc"));
 	}
+	MAKE_STD_ZVAL(hits);
+	array_init(hits);
+	for (i = 0; i < sizeof(cache->hits_by_hour) / sizeof(cache->hits_by_hour[0]); i ++) {
+		add_next_index_long(hits, (long) cache->hits_by_hour[i]);
+	}
+	add_assoc_zval_ex(return_value, ZEND_STRS("hits_by_hour"), hits);
+
+	MAKE_STD_ZVAL(hits);
+	array_init(hits);
+	for (i = 0; i < sizeof(cache->hits_by_second) / sizeof(cache->hits_by_second[0]); i ++) {
+		add_next_index_long(hits, (long) cache->hits_by_second[i]);
+	}
+	add_assoc_zval_ex(return_value, ZEND_STRS("hits_by_second"), hits);
 
 	MAKE_STD_ZVAL(blocks);
@@ -640,6 +712,11 @@
 static void xc_entry_unholds(TSRMLS_D) /* {{{ */
 {
-	xc_entry_unholds_real(XG(php_holds), xc_php_caches, xc_php_hcache.size TSRMLS_CC);
-	xc_entry_unholds_real(XG(var_holds), xc_var_caches, xc_var_hcache.size TSRMLS_CC);
+	if (xc_php_caches) {
+		xc_entry_unholds_real(XG(php_holds), xc_php_caches, xc_php_hcache.size TSRMLS_CC);
+	}
+
+	if (xc_var_caches) {
+		xc_entry_unholds_real(XG(var_holds), xc_var_caches, xc_var_hcache.size TSRMLS_CC);
+	}
 }
 /* }}} */
@@ -914,5 +991,5 @@
 			TRACE("found %s, catch it", stored_xce->name.str.val);
 			xc_entry_hold_php_dmz(stored_xce TSRMLS_CC);
-			cache->hits ++;
+			xc_cache_hit_dmz(cache);
 			break;
 		}
@@ -1222,17 +1299,20 @@
 	xc_shm_t *shm;
 	int i;
-	if (!xc_initized) {
-		return 0;
-	}
-	for (i = 0; i < xc_php_hcache.size; i ++) {
-		shm = xc_php_caches[i]->shm;
-		if (shm->handlers->is_readwrite(shm, p)) {
-			return 1;
-		}
-	}
-	for (i = 0; i < xc_var_hcache.size; i ++) {
-		shm = xc_var_caches[i]->shm;
-		if (shm->handlers->is_readwrite(shm, p)) {
-			return 1;
+
+	if (xc_php_caches) {
+		for (i = 0; i < xc_php_hcache.size; i ++) {
+			shm = xc_php_caches[i]->shm;
+			if (shm->handlers->is_readwrite(shm, p)) {
+				return 1;
+			}
+		}
+	}
+
+	if (xc_var_caches) {
+		for (i = 0; i < xc_var_hcache.size; i ++) {
+			shm = xc_var_caches[i]->shm;
+			if (shm->handlers->is_readwrite(shm, p)) {
+				return 1;
+			}
 		}
 	}
@@ -1244,17 +1324,20 @@
 	xc_shm_t *shm;
 	int i;
-	if (!xc_initized) {
-		return 0;
-	}
-	for (i = 0; i < xc_php_hcache.size; i ++) {
-		shm = xc_php_caches[i]->shm;
-		if (shm->handlers->is_readonly(shm, p)) {
-			return 1;
-		}
-	}
-	for (i = 0; i < xc_var_hcache.size; i ++) {
-		shm = xc_var_caches[i]->shm;
-		if (shm->handlers->is_readonly(shm, p)) {
-			return 1;
+
+	if (xc_php_caches) {
+		for (i = 0; i < xc_php_hcache.size; i ++) {
+			shm = xc_php_caches[i]->shm;
+			if (shm->handlers->is_readonly(shm, p)) {
+				return 1;
+			}
+		}
+	}
+
+	if (xc_var_caches) {
+		for (i = 0; i < xc_var_hcache.size; i ++) {
+			shm = xc_var_caches[i]->shm;
+			if (shm->handlers->is_readonly(shm, p)) {
+				return 1;
+			}
 		}
 	}
@@ -1515,5 +1598,5 @@
 		XG(internal_table_copied) = 1;
 	}
-	if (xc_php_hcache.size && !XG(php_holds)) {
+	if (xc_php_caches && !XG(php_holds)) {
 		XG(php_holds) = calloc(xc_php_hcache.size, sizeof(xc_stack_t));
 		for (i = 0; i < xc_php_hcache.size; i ++) {
@@ -1522,5 +1605,5 @@
 	}
 
-	if (xc_initized && xc_var_hcache.size && !XG(var_holds)) {
+	if (xc_var_caches && !XG(var_holds)) {
 		XG(var_holds) = calloc(xc_var_hcache.size, sizeof(xc_stack_t));
 		for (i = 0; i < xc_var_hcache.size; i ++) {
@@ -1675,8 +1758,8 @@
 	}
 
-#define STR "WWW-authenticate: Basic Realm=\"XCache Administration\""
+#define STR "HTTP/1.0 401 Unauthorized"
 	sapi_add_header_ex(STR, sizeof(STR) - 1, 1, 1 TSRMLS_CC);
 #undef STR
-#define STR "HTTP/1.0 401 Unauthorized"
+#define STR "WWW-authenticate: Basic Realm=\"XCache Administration\""
 	sapi_add_header_ex(STR, sizeof(STR) - 1, 1, 1 TSRMLS_CC);
 #undef STR
@@ -1884,5 +1967,5 @@
 	} LEAVE_LOCK(xce.cache);
 	if (found) {
-		xce.cache->hits ++;
+		xc_cache_hit_dmz(xce.cache TSRMLS_CC);
 	}
 	else {
@@ -1965,5 +2048,5 @@
 	} LEAVE_LOCK(xce.cache);
 	if (found) {
-		xce.cache->hits ++;
+		xc_cache_hit_dmz(xce.cache TSRMLS_CC);
 	}
 	else {
@@ -2098,4 +2181,18 @@
 }
 /* }}} */
+#ifdef HAVE_XCACHE_DPRINT
+/* {{{ proto bool  xcache_dprint(mixed value)
+   Prints variable (or value) internal struct (debug only) */
+PHP_FUNCTION(xcache_dprint)
+{
+	zval *value;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
+		return;
+	}
+	xc_dprint_zval(value, 0 TSRMLS_CC);
+}
+/* }}} */
+#endif
 /* {{{ proto string xcache_asm(string filename)
  */
@@ -2323,4 +2420,7 @@
 	PHP_FE(xcache_isset,             NULL)
 	PHP_FE(xcache_unset,             NULL)
+#ifdef HAVE_XCACHE_DPRINT
+	PHP_FE(xcache_dprint,            NULL)
+#endif
 	{NULL, NULL,                     NULL}
 };
@@ -2460,4 +2560,14 @@
 	php_info_print_table_row(2, "Modules Built", XCACHE_MODULES);
 	php_info_print_table_row(2, "Readonly Protection", xc_readonly_protection ? "enabled" : "N/A");
+	ptr = php_format_date("Y-m-d H:i:s", sizeof("Y-m-d H:i:s") - 1, xc_init_time, 1 TSRMLS_CC);
+	php_info_print_table_row(2, "Cache Init Time", ptr);
+	efree(ptr);
+
+#ifdef ZTS
+	snprintf(buf, sizeof(buf), "%lu.%lu", xc_init_instance_id, xc_init_instance_subid);
+#else
+	snprintf(buf, sizeof(buf), "%lu", xc_init_instance_id);
+#endif
+	php_info_print_table_row(2, "Cache Instance Id", buf);
 
 	if (xc_php_size) {
@@ -2694,4 +2804,9 @@
 		}
 		xc_initized = 1;
+		xc_init_time = time(NULL);
+		xc_init_instance_id = getpid();
+#ifdef ZTS
+		xc_init_instance_subid = tsrm_thread_id();
+#endif
 	}
 
Index: /branches/1.3/xcache.h
===================================================================
--- /branches/1.3/xcache.h	(revision 622)
+++ /branches/1.3/xcache.h	(revision 623)
@@ -220,4 +220,11 @@
 	time_t     last_gc_deletes;
 	time_t     last_gc_expires;
+
+	time_t     hits_by_hour_cur_time;
+	zend_uint  hits_by_hour_cur_slot;
+	zend_ulong hits_by_hour[24];
+	time_t     hits_by_second_cur_time;
+	zend_uint  hits_by_second_cur_slot;
+	zend_ulong hits_by_second[5];
 } xc_cache_t;
 /* }}} */
Index: /branches/1.3/xcache.ini
===================================================================
--- /branches/1.3/xcache.ini	(revision 622)
+++ /branches/1.3/xcache.ini	(revision 623)
@@ -23,5 +23,5 @@
 ; to disable: xcache.size=0
 ; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows
-xcache.size  =                0M
+xcache.size  =               60M
 ; set to cpu count (cat /proc/cpuinfo |grep -c processor)
 xcache.count =                 1
@@ -34,5 +34,5 @@
 
 ; same as aboves but for variable cache
-xcache.var_size  =            0M
+xcache.var_size  =            4M
 xcache.var_count =             1
 xcache.var_slots =            8K
