Index: /trunk/NEWS
===================================================================
--- /trunk/NEWS	(revision 901)
+++ /trunk/NEWS	(revision 902)
@@ -2,4 +2,5 @@
 ========
  * improve stability
+ * admin/ config changed. please update accordingly
 
 2.0.0 2012-04-20
Index: /trunk/ChangeLog
===================================================================
--- /trunk/ChangeLog	(revision 901)
+++ /trunk/ChangeLog	(revision 902)
@@ -3,4 +3,5 @@
 ========
  * fixed #279: segv when cache is full (since 2.0)
+ * admin/ config changed. please update accordingly
 
 2.0.0 2012-04-20
Index: /trunk/admin/common-en.lang.php
===================================================================
--- /trunk/admin/common-en.lang.php	(revision 605)
+++ /trunk/admin/common-en.lang.php	(revision 902)
@@ -1,5 +1,5 @@
 <?php
 
-$GLOBALS['show_todo_strings'] = false;
+$GLOBALS['config']['show_todo_strings'] = false;
 
 ?>
Index: /trunk/admin/edit.php
===================================================================
--- /trunk/admin/edit.php	(revision 605)
+++ /trunk/admin/edit.php	(revision 902)
@@ -12,5 +12,5 @@
 
 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
-	if ($enable_eval) {
+	if (!empty($config['enable_eval'])) {
 		eval('$value = ' . $_POST['value']);
 	}
@@ -23,5 +23,5 @@
 }
 $value = xcache_get($name);
-if ($enable_eval) {
+if (!empty($enable['enable_eval'])) {
 	$value = var_export($value, true);
 	$editable = true;
Index: /trunk/admin/header.tpl.php
===================================================================
--- /trunk/admin/header.tpl.php	(revision 605)
+++ /trunk/admin/header.tpl.php	(revision 902)
@@ -4,7 +4,7 @@
 <?php
 echo <<<HEAD
-	<meta http-equiv="Content-Type" content="text/html; charset=$charset" />
-	<meta http-equiv="Content-Language" content="$lang" />
-	<script type="text/javascript" src="tablesort.js" charset="$charset"></script>
+	<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;
 ?>
Index: /trunk/admin/common.php
===================================================================
--- /trunk/admin/common.php	(revision 783)
+++ /trunk/admin/common.php	(revision 902)
@@ -41,8 +41,8 @@
 function get_language_file($name)
 {
-	global $charset, $lang;
-	$s = strtolower($charset);
-	if (isset($lang)) {
-		$l = strtolower($lang);
+	global $config;
+	$s = strtolower($config['charset']);
+	if (!empty($config['lang'])) {
+		$l = strtolower($config['lang']);
 		$file = get_language_file_ex($name, $l, $s);
 		if (!isset($file)) {
@@ -56,5 +56,5 @@
 			$file = get_language_file_ex($name, $l, $s);
 			if (isset($file)) {
-				$lang = $l;
+				$config['lang'] = $l;
 				break;
 			}
@@ -63,5 +63,5 @@
 				$file = get_language_file_ex($name, $ll, $s);
 				if (isset($file)) {
-					$lang = $l;
+					$config['lang'] = $l;
 					break;
 				}
@@ -77,5 +77,5 @@
 		return $GLOBALS['strings'][$str];
 	}
-	if (!empty($GLOBALS['show_todo_strings'])) {
+	if (!empty($GLOBALS['config']['show_todo_strings'])) {
 		return '<span style="color:red">' . htmlspecialchars($str) . '</span>';
 	}
@@ -96,4 +96,18 @@
 }
 
+function ob_filter_path_nicer_default($list_html)
+{
+	$sep = DIRECTORY_SEPARATOR;
+	$docRoot = $_SERVER['DOCUMENT_ROOT'];
+	$list_html = str_replace($docRoot,  "{DOCROOT}" . (substr($docRoot, -1) == $sep ? $sep : ""), $list_html);
+	$xcachedir = realpath(dirname(__FILE__) . "$sep..$sep");
+	$list_html = str_replace($xcachedir . $sep, "{XCache}$sep", $list_html);
+	if ($sep == '/') {
+		$list_html = str_replace("/home/", "{H}/", $list_html);
+	}
+	return $list_html;
+}
+
+
 error_reporting(E_ALL);
 ini_set('display_errors', 'On');
@@ -105,8 +119,10 @@
 	$_POST = stripaddslashes_array($_POST, $mqs);
 	$_REQUEST = stripaddslashes_array($_REQUEST, $mqs);
+	unset($mqs);
 }
 ini_set('magic_quotes_runtime', '0');
 
-$charset = "UTF-8";
+$config = array();
+include("./config.default.php");
 if (file_exists("./config.php")) {
 	include("./config.php");
@@ -114,11 +130,7 @@
 
 include(get_language_file("common"));
-if (!isset($lang)) {
-	$lang = 'en-us';
+if (empty($config['lang'])) {
+	$config['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: /trunk/admin/config.default.php
===================================================================
--- /trunk/admin/config.default.php	(revision 902)
+++ /trunk/admin/config.default.php	(revision 902)
@@ -0,0 +1,71 @@
+<?php
+
+// this is default config, DO NOT modify this file
+// copy this file and write your own config and name it as config.php
+
+// detected by browser
+// $config['lang'] = 'en-us';
+
+$config['charset'] = "UTF-8";
+
+// translators only
+$config['show_todo_strings'] = false;
+
+// width of graph for free or usage blocks
+$config['percent_graph_width'] = 120;
+$config['percent_graph_type'] = 'used'; // either 'used' or 'free'
+
+// only enable if you have password protection for admin page
+// enabling this option will cause user to eval() whatever code they want
+$config['enable_eval'] = false;
+
+// this ob filter is applied for the cache list, not the whole page
+$config['path_nicer'] = 'ob_filter_path_nicer_default';
+
+/*
+function custom_ob_filter_path_nicer($list_html)
+{
+	$list_html = ob_filter_path_nicer_default($list_html); // this function is from common.php
+	return $list_html;
+}
+$config['path_nicer'] = 'custom_ob_filter_path_nicer';
+*/
+
+// you can simply let xcache to do the http auth
+// but if you have your home made login/permission system, you can implement the following
+// {{{ home made login example
+// this is an example only, it's won't work for you without your implemention.
+/*
+function check_admin_and_by_pass_xcache_http_auth()
+{
+	require("/path/to/user-login-and-permission-lib.php");
+	session_start();
+
+	if (!user_logined()) {
+		if (!ask_the_user_to_login()) {
+			exit;
+		}
+	}
+
+	user_load_permissions();
+	if (!user_is_admin()) {
+		die("Permission denied");
+	}
+
+	// user is trusted after permission checks above.
+	// tell XCache about it (the only way to by pass XCache http auth)
+	$_SERVER["PHP_AUTH_USER"] = "moo";
+	$_SERVER["PHP_AUTH_PW"] = "your-xcache-password";
+	return true;
+}
+
+check_admin_and_by_pass_xcache_http_auth();
+*/
+// }}}
+
+/* by pass XCache http auth
+$_SERVER["PHP_AUTH_USER"] = "moo";
+$_SERVER["PHP_AUTH_PW"] = "your-xcache-password";
+*/
+
+?>
Index: /trunk/admin/help.php
===================================================================
--- /trunk/admin/help.php	(revision 605)
+++ /trunk/admin/help.php	(revision 902)
@@ -7,7 +7,7 @@
 <?php
 echo <<<HEAD
-	<meta http-equiv="Content-Type" content="text/html; charset=$charset" />
-	<meta http-equiv="Content-Language" content="$lang" />
-	<script type="text/javascript" src="tablesort.js" charset="$charset"></script>
+	<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;
 ?>
Index: /trunk/admin/xcache.tpl.php
===================================================================
--- /trunk/admin/xcache.tpl.php	(revision 868)
+++ /trunk/admin/xcache.tpl.php	(revision 902)
@@ -33,5 +33,5 @@
 		<th><?php echo _T('Size'); ?></th>
 		<th><?php echo _T('Avail'); ?></th>
-		<th><?php echo _T(isset($free_graph_width) ? '% Free' : '% Used'); ?></th>
+		<th><?php echo _T($config['percent_graph_type'] == 'free' ? '% Free' : '% Used'); ?></th>
 		<th><?php echo _T('Clear'); ?></th>
 		<th><?php echo _T('Compiling'); ?></th>
@@ -58,5 +58,5 @@
 		$pvalue = (int) ($ci['avail'] / $ci['size'] * 100);
 		$pempty = 100 - $pvalue;
-		if (!isset($free_graph_width)) {
+		if ($config['percent_graph_type'] == 'used') {
 			// swap
 			$tmp = $pvalue;
@@ -65,5 +65,5 @@
 		}
 
-		$w = $graph_width;
+		$w = $config['percent_graph_width'];
 		if (empty($ci['istotal'])) {
 			$graph = freeblock_to_graph($ci['free_blocks'], $ci['size']);
@@ -135,7 +135,7 @@
 	<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="legendtitle"><?php echo _T($config['percent_graph_type'] == 'free' ? '% 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="legendtitle"><?php echo _T($config['percent_graph_type'] == 'free' ? '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>
@@ -145,7 +145,5 @@
 if ($cachelist) {
 	$isphp = $cachelist['type'] == $type_php;
-	if (function_exists("ob_filter_path_nicer")) {
-		ob_start("ob_filter_path_nicer");
-	}
+	ob_start($config['path_nicer']);
 	foreach (array('Cached' => $cachelist['cache_list'], 'Deleted' => $cachelist['deleted_list']) as $listname => $entries) {
 		$a->reset();
@@ -261,7 +259,5 @@
 <?php
 	}
-	if (function_exists("ob_filter_path_nicer")) {
-		ob_end_flush();
-	}
+	ob_end_flush();
 }
 if ($moduleinfo) {
Index: /trunk/admin/xcache.php
===================================================================
--- /trunk/admin/xcache.php	(revision 868)
+++ /trunk/admin/xcache.php	(revision 902)
@@ -77,15 +77,15 @@
 function freeblock_to_graph($freeblocks, $size)
 {
-	global $graph_width, $usage_graph_width, $free_graph_width;
+	global $config;
 
 	// cached in static variable
 	static $graph_initial;
 	if (!isset($graph_initial)) {
-		$graph_initial = array_fill(0, $graph_width, 0);
+		$graph_initial = array_fill(0, $config['percent_graph_width'], 0);
 	}
 	$graph = $graph_initial;
 	foreach ($freeblocks as $b) {
-		$begin = $b['offset'] / $size * $graph_width;
-		$end = ($b['offset'] + $b['size']) / $size * $graph_width;
+		$begin = $b['offset'] / $size * $config['percent_graph_width'];
+		$end = ($b['offset'] + $b['size']) / $size * $config['percent_graph_width'];
 
 		if ((int) $begin == (int) $end) {
@@ -104,5 +104,5 @@
 	$c = 255;
 	foreach ($graph as $k => $v) {
-		if (!isset($free_graph_width)) {
+		if ($config['percent_graph_type'] != 'free') {
 			$v = 1 - $v;
 		}
Index: /unk/admin/config.php.example
===================================================================
--- /trunk/admin/config.php.example	(revision 647)
+++ 	(revision )
@@ -1,69 +1,0 @@
-<?php
-
-// this is an example only
-// write your own config and name it as config.php
-
-// detected by browser
-// $lang = 'en-us';
-
-$charset = "UTF-8";
-
-// developers only
-$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;
-
-// only enable if you have password protection for admin page
-// enabling this option will cause user to eval() whatever code they want
-$enable_eval = false;
-
-// 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
-function ob_filter_path_nicer($o)
-{
-	$sep = DIRECTORY_SEPARATOR;
-	$d = $_SERVER['DOCUMENT_ROOT'];
-	$o = str_replace($d,  "{DOCROOT}" . (substr($d, -1) == $sep ? $sep : ""), $o);
-	$xcachedir = realpath(dirname(__FILE__) . "$sep..$sep");
-	$o = str_replace($xcachedir . $sep, "{XCache}$sep", $o);
-	if ($sep == '/') {
-		$o = str_replace("/home/", "{H}/", $o);
-	}
-	return $o;
-}
-
-// you can simply let xcache to do the http auth
-// but if you have your home made login/permission system, you can implement the following
-// {{{ home made login example
-// this is an example only, it's won't work for you without your implemention.
-function check_admin_and_by_pass_xcache_http_auth()
-{
-	require("/path/to/user-login-and-permission-lib.php");
-	session_start();
-
-	if (!user_logined()) {
-		if (!ask_the_user_to_login()) {
-			exit;
-		}
-	}
-
-	user_load_permissions();
-	if (!user_is_admin()) {
-		die("Permission denied");
-	}
-
-	// user is trusted after permission checks above.
-	// tell XCache about it (the only way to by pass XCache http auth)
-	$_SERVER["PHP_AUTH_USER"] = "moo";
-	$_SERVER["PHP_AUTH_PW"] = "your-xcache-password";
-	return true;
-}
-
-// uncomment:
-// check_admin_and_by_pass_xcache_http_auth();
-// }}}
-
-?>
