1
0
Fork 0

refactor: move htdocs, bin, lib for easier installation

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1053 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
This commit is contained in:
Xuefer 2012-07-27 07:17:42 +00:00
parent 07c4675cb0
commit d7303c3387
32 changed files with 452 additions and 680 deletions

View File

@ -197,10 +197,10 @@ val*)
tracer=(valgrind --gen-suppressions=all)
;;
dc)
exec ./php-cli -c devel.ini ./mod_disassembler/bin/phpdc.phpr "${args[@]}" | tee decompiled.php
exec ./php-cli -c devel.ini ./bin/phpdc.phpr "${args[@]}" | tee decompiled.php
;;
dop)
exec ./php-cli -c devel.ini ./mod_disassembler/bin/phpdop.phpr "${args[@]}"
exec ./php-cli -c devel.ini ./bin/phpdop.phpr "${args[@]}"
;;
retest)
exec make xcachetest "$@" TESTS="`grep '^/.*\.phpt$' php_test_results_*.txt | uniq | xargs`"

View File

@ -1,16 +1,4 @@
input, table { font-family: sans-serif; }
input { font-size: 12px; }
table { border-collapse: collapse; font-size: 11px; margin: 0; }
table caption, h2, h3 { font-size: 16px; font-weight: bold; text-align: left; padding-top: 20px; margin-bottom: 2px; }
h3 { font-size: 14px; padding-top: 2px; margin-bottom: 0px; }
td, th { white-space: pre; }
table.cycles { border: 1px solid black; margin-top: 5px; margin-bottom: 5px; }
table.cycles .col1 { background-color: #f5f5f5; }
table.cycles .col2 { background-color: #e0e0e0; }
table.cycles th, table.cycles td { border: 1px solid black; font-family: monospace; }
table.cycles th { background-color: #9999cc; color: black; font-weight: bold; height: 20px; line-height: 20px; font-family: serif; }
th a { color: black; font-weight: bold; display: block; width: 100%; height: 100%; }
th { font-size: 12px; }
.phpinfo table { border: 1px solid black; margin-bottom: 1px; }
.phpinfo table th, .phpinfo table td { border: 1px solid black; }
.phpinfo table th { font-weight: bold; }
@ -38,15 +26,7 @@ form {margin: 0; padding: 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 a { color: blue; padding: 1px 8px 1px 8px; border: 1px solid white; border-bottom-color: black; text-decoration: none; }
.switcher a:hover.active
, .switcher a:active.active
, .switcher a.active { color: black; background: #99C; border-color: #99C; border-left-color: black; border-right-color: black; }
.switcher a:hover { background: #f0f0f0; }
.switcher a:active { background: #e0e0e0; }
#help { display: block; float: right; }
.footnote { text-align: right; font-size: 12px; }
dl { overflow: hidden; }
dt { font-weight: bold; clear: both; float: left; width: 100px; text-align: right; margin: 0; }
dd { margin: 0; }

View File

@ -2,78 +2,6 @@
include("./common.php");
class Cycle
{
var $values;
var $i;
var $count;
function Cycle($v)
{
$this->values = func_get_args();
$this->i = -1;
$this->count = count($this->values);
}
function next()
{
$this->i = ($this->i + 1) % $this->count;
return $this->values[$this->i];
}
function cur()
{
return $this->values[$this->i];
}
function reset()
{
$this->i = -1;
}
}
function number_formats($a, $keys)
{
foreach ($keys as $k) {
$a[$k] = number_format($a[$k]);
}
return $a;
}
function size($size)
{
$size = (int) $size;
if ($size < 1024)
return number_format($size, 2) . ' b';
if ($size < 1048576)
return number_format($size / 1024, 2) . ' K';
return number_format($size / 1048576, 2) . ' M';
}
function age($time)
{
if (!$time) return '';
$delta = REQUEST_TIME - $time;
if ($delta < 0) {
$delta = -$delta;
}
static $seconds = array(1, 60, 3600, 86400, 604800, 2678400, 31536000);
static $name = array('s', 'm', 'h', 'd', 'w', 'M', 'Y');
for ($i = 6; $i >= 0; $i --) {
if ($delta >= $seconds[$i]) {
$ret = (int) ($delta / $seconds[$i]);
return $ret . ' ' . $name[$i];
}
}
return '0 s';
}
function freeblock_to_graph($freeblocks, $size)
{
global $config;
@ -182,36 +110,9 @@ function hits_to_graph($hits)
return implode('', $html);
}
function switcher($name, $options)
{
$n = isset($_GET[$name]) ? $_GET[$name] : null;
$html = array();
foreach ($options as $k => $v) {
$html[] = sprintf('<a href="?%s=%s"%s>%s</a>', $name, $k, $k == $n ? ' class="active"' : '', $v);
}
return implode('', $html);
}
function th($name, $attrs = null)
{
$translated = __($name);
if ($translated == $name) {
$translated = "$name|$name";
}
list($text, $title) = explode('|', $translated, 2);
return sprintf('%s<th%s id="%s" title="%s"><a href="javascript:" onclick="resort(this); return false">%s</a></th>%s'
, "\t"
, $attrs ? " $attrs" : ""
, $name, htmlspecialchars(trim($title)), trim($text)
, "\n");
}
$php_version = phpversion();
$xcache_version = XCACHE_VERSION;
$xcache_modules = XCACHE_MODULES;
$module = "cacher";
if (!extension_loaded('XCache')) {
include("header.tpl.php");
include("../common/header.tpl.php");
echo '<h1>XCache is not loaded</h1>';
ob_start();
phpinfo(INFO_GENERAL);
@ -234,7 +135,7 @@ if (!extension_loaded('XCache')) {
echo "You don't even have a php.ini yet?";
}
echo "(See above)";
include("footer.tpl.php");
include("../common/footer.tpl.php");
exit;
}
$pcnt = xcache_count(XC_TYPE_PHP);
@ -400,8 +301,8 @@ default:
$type_php = XC_TYPE_PHP;
$type_var = XC_TYPE_VAR;
$types = array($type_none => _('Statistics'), $type_php => _('List PHP'), $type_var => _('List Var Data'));
$listTypes = array($type_none => _('Statistics'), $type_php => _('List PHP'), $type_var => _('List Var Data'));
include("xcache.tpl.php");
include("cacher.tpl.php");
?>

View File

@ -1,8 +1,8 @@
<?php include("header.tpl.php"); ?>
<?php include("../common/header.tpl.php"); ?>
<div class="switcher"><?php echo switcher("type", $listTypes); ?></div>
<div id="help">
<a href="help.php"><?php echo _("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"');
@ -214,11 +214,11 @@ if ($cachelist) {
$name = htmlspecialchars($entry['name']);
$hits = number_format($entry['hits']);
$size = size($entry['size']);
$class_cnt = number_format($entry['class_cnt']);
$function_cnt = number_format($entry['function_cnt']);
if ($isphp) {
$phprefcount = number_format($entry['phprefcount']);
$file_size = size($entry['file_size']);
$class_cnt = number_format($entry['class_cnt']);
$function_cnt = number_format($entry['function_cnt']);
$phprefcount = number_format($entry['phprefcount']);
$file_size = size($entry['file_size']);
}
if ($isphp) {
@ -230,19 +230,21 @@ if ($cachelist) {
$dtime = age($entry['dtime']);
}
if (!$isphp) {
if ($isphp) {
$namelink = $name;
echo <<<ENTRY
<td><input type="checkbox" name="remove[]" value="{$name}"/></td>
<td>{$entry['cache_name']} {$i}</td>
ENTRY;
}
else {
echo <<<ENTRY
<td><label><input type="checkbox" name="remove[]" value="{$name}"/>{$entry['cache_name']} {$i}</label></td>
ENTRY;
$uname = urlencode($entry['name']);
$namelink = "<a href=\"edit.php?name=$uname\">$name</a>";
}
else {
$namelink = $name;
}
echo <<<ENTRY
<td>{$entry['cache_name']} {$i}</td>
<td>{$namelink}</td>
<td align="right" int="{$entry['hits']}">{$entry['hits']}</td>
<td align="right" int="{$entry['size']}">{$size}</td>
@ -298,4 +300,4 @@ if ($moduleinfo) {
HTML;
}
?>
<?php include("footer.tpl.php"); ?>
<?php include("../common/footer.tpl.php"); ?>

View File

@ -1,152 +0,0 @@
<?php
function xcache_validateFileName($name)
{
return preg_match('!^[a-zA-Z0-9._-]+$!', $name);
}
function get_language_file_ex($name, $l, $s)
{
static $lmap = array(
'zh' => 'zh-simplified',
'zh-hk' => 'zh-traditional',
'zh-tw' => 'zh-traditional',
);
static $smap = array(
'gbk' => 'gb2312',
'gb18030' => 'gb2312',
);
if (isset($lmap[$l])) {
$l = $lmap[$l];
}
$file = "$name-$l-$s.lang.php";
if (xcache_validateFileName($file) && file_exists($file)) {
return $file;
}
if (isset($smap[$s])) {
$s = $smap[$s];
$file = "$name-$l-$s.lang.php";
if (xcache_validateFileName($file) && file_exists($file)) {
return $file;
}
}
$file = "$name-$l.lang.php";
if (xcache_validateFileName($file) && file_exists($file)) {
return $file;
}
return null;
}
function get_language_file($name)
{
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)) {
$l = strtok($l, ':-');
$file = get_language_file_ex($name, $l, $s);
}
}
else if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
foreach (explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $l) {
$l = strtok($l, ':;');
$file = get_language_file_ex($name, $l, $s);
if (isset($file)) {
$config['lang'] = $l;
break;
}
if (strpos($l, '-') !== false) {
$ll = strtok($l, ':-');
$file = get_language_file_ex($name, $ll, $s);
if (isset($file)) {
$config['lang'] = $l;
break;
}
}
}
}
return isset($file) ? $file : "$name-en.lang.php";
}
function _($str)
{
if (isset($GLOBALS['strings'][$str])) {
return $GLOBALS['strings'][$str];
}
if (!empty($GLOBALS['config']['show_todo_strings'])) {
return '<span style="color:red">' . htmlspecialchars($str) . '</span>|';
}
return $str;
}
function __($str)
{
return _($str);
}
function N_($str)
{
return $str;
}
function stripaddslashes_array($value, $mqs = false)
{
if (is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = stripaddslashes_array($v, $mqs);
}
}
else if(is_string($value)) {
$value = $mqs ? str_replace('\'\'', '\'', $value) : stripslashes($value);
}
return $value;
}
function ob_filter_path_nicer_default($list_html)
{
$sep = DIRECTORY_SEPARATOR;
$docRoot = $_SERVER['DOCUMENT_ROOT'];
if ($sep != '/') {
$docRoot = str_replace('/', $sep, $docRoot);
}
$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');
define('REQUEST_TIME', time());
if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) {
$mqs = (bool) ini_get('magic_quotes_sybase');
$_GET = stripaddslashes_array($_GET, $mqs);
$_POST = stripaddslashes_array($_POST, $mqs);
$_REQUEST = stripaddslashes_array($_REQUEST, $mqs);
unset($mqs);
}
ini_set('magic_quotes_runtime', '0');
$config = array();
include("./config.default.php");
if (file_exists("./config.php")) {
include("./config.php");
}
include(get_language_file("common"));
if (empty($config['lang'])) {
$config['lang'] = 'en-us';
}
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
?>

View File

@ -1,16 +1,9 @@
<?php
// this is default config
// DO NOT rename/delete/modify this file
// see config.example.php
// [default config]
// DO NOT rename/delete/modify this file which will be overwritten when upgrade
// See config.example.php instead
// 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;
@ -20,7 +13,3 @@ $config['percent_graph_type'] = 'used'; // either 'used' or 'free'
// 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';
?>

View File

@ -1,17 +1,14 @@
<?php
// this is example config
// DO NOT rename/delete/modify this file
// if you want to customize config, copy this file and name it as config.php
// upgrading your config.php when config.example.php were upgraded
// leave this setting unset to auto detect using browser request header
// $config['lang'] = 'en-us';
$config['charset'] = "UTF-8";
// enable this for translators only
$config['show_todo_strings'] = false;
// DO NOT rename/delete/modify example file which will be overwritten when upgrade
// How To Custom Config:
// 1. copy config.example.php config.php; edit config.php
// 2. upgrading your config.php when config.example.php were upgraded
// XCache will load
// 1. ../config.default.php
// 2. ./config.default.php
// 3. ../config.php
// 4. ./config.php
// width of graph for free or usage blocks
$config['percent_graph_width'] = 120;
@ -21,54 +18,3 @@ $config['percent_graph_type'] = 'used'; // either 'used' or 'free'
// 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
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';
// XCache builtin http auth is enforce for security reason
// if http auth is disabled, any vhost user that can upload *.php, will see all variable data cached in XCache
// but if you have your own login/permission system, you can use the following example
// {{{ 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()) {
user_load_permissions();
if (user_is_admin()) {
// user is trusted after permission checks above.
// tell XCache about it (the only secure way to by pass XCache http auth)
$_SERVER["PHP_AUTH_USER"] = "moo";
$_SERVER["PHP_AUTH_PW"] = "your-xcache-password-before-md5";
}
else {
die("Permission denied");
}
}
else {
if (!ask_the_user_to_login()) {
exit;
}
}
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-before-md5";
*/
?>

View File

@ -36,9 +36,7 @@ else {
}
}
$php_version = phpversion();
$xcache_version = XCACHE_VERSION;
$xcache_modules = XCACHE_MODULES;
$module = "cacher";
include("edit.tpl.php");

View File

@ -1,4 +1,4 @@
<?php include("header.tpl.php"); ?>
<?php include("../common/header.tpl.php"); ?>
<?php
$h_name = htmlspecialchars($name);
$h_value = htmlspecialchars($value);
@ -15,4 +15,4 @@ $h_value = htmlspecialchars($value);
?>
</fieldset>
</form>
<?php include("footer.tpl.php"); ?>
<?php include("../common/footer.tpl.php"); ?>

View File

@ -1,9 +0,0 @@
<div class="footnote">
<?php echo <<<EOS
PHP {$php_version} Powered By: XCache {$xcache_version}, {$xcache_modules}
EOS;
?>
</div>
</body>
</html>

View File

@ -1,17 +0,0 @@
<!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 sprintf(_("XCache %s Administration"), $xcache_version); ?></title>
</head>
<body>
<h1><?php echo sprintf(_("XCache %s Administration"), $xcache_version); ?></h1>

View File

@ -1,3 +1,3 @@
<?php
include("xcache.php");
include("cacher.php");

View File

@ -0,0 +1,4 @@
<?php
$strings = array();

250
htdocs/common/common.php Normal file
View File

@ -0,0 +1,250 @@
<?php
class Cycle
{
var $values;
var $i;
var $count;
function Cycle($v)
{
$this->values = func_get_args();
$this->i = -1;
$this->count = count($this->values);
}
function next()
{
$this->i = ($this->i + 1) % $this->count;
return $this->values[$this->i];
}
function cur()
{
return $this->values[$this->i];
}
function reset()
{
$this->i = -1;
}
}
function switcher($name, $options)
{
$n = isset($_GET[$name]) ? $_GET[$name] : null;
$html = array();
foreach ($options as $k => $v) {
$html[] = sprintf('<a href="?%s=%s"%s>%s</a>', $name, $k, $k == $n ? ' class="active"' : '', $v);
}
return implode('', $html);
}
function moduleswitcher()
{
global $module, $modules;
$html = array();
foreach ($modules as $k => $v) {
$html[] = sprintf('<a href="../%s/"%s>%s</a>', $k, $k == $module ? ' class="active"' : '', $v);
}
return implode('', $html);
}
function th($name, $attrs = null)
{
$translated = __($name);
if ($translated == $name) {
$translated = "$name|$name";
}
list($text, $title) = explode('|', $translated, 2);
return sprintf('%s<th%s id="%s" title="%s"><a href="javascript:" onclick="resort(this); return false">%s</a></th>%s'
, "\t"
, $attrs ? " $attrs" : ""
, $name, htmlspecialchars(trim($title)), trim($text)
, "\n");
}
function xcache_validateFileName($name)
{
return preg_match('!^[a-zA-Z0-9._-]+$!', $name);
}
function get_language_file_ex($name, $lang)
{
static $langMap = array(
'zh' => 'zh-simplified',
'zh-hk' => 'zh-traditional',
'zh-tw' => 'zh-traditional',
);
if (isset($langMap[$lang])) {
$lang = $langMap[$lang];
}
$file = "$name-$lang.lang.php";
if (xcache_validateFileName($file) && file_exists($file)) {
return $file;
}
return null;
}
function get_language_file($name)
{
global $config;
if (!empty($config['lang'])) {
$lang = strtolower($config['lang']);
$file = get_language_file_ex($name, $lang);
if (!isset($file)) {
$lang = strtok($lang, ':-');
$file = get_language_file_ex($name, $lang);
}
}
else if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
foreach (explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $lang) {
$lang = strtok($lang, ':;');
$file = get_language_file_ex($name, $lang);
if (isset($file)) {
$config['lang'] = $lang;
break;
}
if (strpos($lang, '-') !== false) {
$file = get_language_file_ex($name, strtok($lang, ':-'));
if (isset($file)) {
$config['lang'] = $lang;
break;
}
}
}
}
return isset($file) ? $file : "$name-en.lang.php";
}
function _($str)
{
if (isset($GLOBALS['strings'][$str])) {
return $GLOBALS['strings'][$str];
}
if (!empty($GLOBALS['config']['show_todo_strings'])) {
return '<span style="color:red">' . htmlspecialchars($str) . '</span>|';
}
return $str;
}
function __($str)
{
return _($str);
}
function N_($str)
{
return $str;
}
function number_formats($a, $keys)
{
foreach ($keys as $k) {
$a[$k] = number_format($a[$k]);
}
return $a;
}
function size($size)
{
$size = (int) $size;
if ($size < 1024)
return number_format($size, 2) . ' b';
if ($size < 1048576)
return number_format($size / 1024, 2) . ' K';
return number_format($size / 1048576, 2) . ' M';
}
function age($time)
{
if (!$time) return '';
$delta = REQUEST_TIME - $time;
if ($delta < 0) {
$delta = -$delta;
}
static $seconds = array(1, 60, 3600, 86400, 604800, 2678400, 31536000);
static $name = array('s', 'm', 'h', 'd', 'w', 'M', 'Y');
for ($i = 6; $i >= 0; $i --) {
if ($delta >= $seconds[$i]) {
$ret = (int) ($delta / $seconds[$i]);
return $ret . ' ' . $name[$i];
}
}
return '0 s';
}
function stripaddslashes_array($value, $mqs = false)
{
if (is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = stripaddslashes_array($v, $mqs);
}
}
else if(is_string($value)) {
$value = $mqs ? str_replace('\'\'', '\'', $value) : stripslashes($value);
}
return $value;
}
function ob_filter_path_nicer_default($list_html)
{
$sep = DIRECTORY_SEPARATOR;
$docRoot = $_SERVER['DOCUMENT_ROOT'];
if ($sep != '/') {
$docRoot = str_replace('/', $sep, $docRoot);
}
$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');
define('REQUEST_TIME', time());
if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) {
$mqs = (bool) ini_get('magic_quotes_sybase');
$_GET = stripaddslashes_array($_GET, $mqs);
$_POST = stripaddslashes_array($_POST, $mqs);
$_REQUEST = stripaddslashes_array($_REQUEST, $mqs);
unset($mqs);
}
ini_set('magic_quotes_runtime', '0');
$config = array();
if (file_exists("./config.default.php")) {
include("./config.default.php");
}
include("../config.default.php");
if (file_exists("../config.php")) {
include("../config.php");
}
if (file_exists("./config.php")) {
include("./config.php");
}
include(get_language_file("common"));
$modules = array();
if (file_exists("../cacher/index.php")) {
$modules["cacher"] = _("Cacher");
}
if (file_exists("../coverager/index.php")) {
$modules["coverager"] = _("Coverager");
}
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
?>

View File

@ -0,0 +1,13 @@
<div class="footnote">
PHP <?php
echo phpversion();
?> Powered By: XCache <?php
echo defined('XCACHE_VERSION') ? XCACHE_VERSION : '';
?>, <?php
echo defined('XCACHE_MODULES') ? XCACHE_MODULES : '';
?>
</div>
</body>
</html>

View File

@ -0,0 +1,15 @@
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $GLOBALS['config']['charset']; ?>" />
<meta http-equiv="Content-Language" content="<?php echo $GLOBALS['config']['charset']; ?>" />
<script type="text/javascript" src="tablesort.js"></script>
<link rel="stylesheet" type="text/css" href="../common/common.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['module']; ?>.css" />
<title><?php echo $title = sprintf("XCache %s", $xcache_version = defined('XCACHE_VERSION') ? XCACHE_VERSION : '') . " - " . ucfirst($GLOBALS['module']); ?></title>
</head>
<body>
<h1><?php echo $title; ?></h1>
<div class="switcher"><?php echo moduleswitcher(); ?></div>

17
htdocs/config.default.php Normal file
View File

@ -0,0 +1,17 @@
<?php
// [default config]
// DO NOT rename/delete/modify this file which will be overwritten when upgrade
// See config.example.php instead
// detected by browser
// $config['lang'] = 'en-us';
$config['charset'] = "UTF-8";
// translators only
$config['show_todo_strings'] = false;
// this ob filter function is applied for the list with paths, not the whole page
$config['path_nicer'] = 'ob_filter_path_nicer_default';

65
htdocs/config.example.php Normal file
View File

@ -0,0 +1,65 @@
<?php
// DO NOT rename/delete/modify example file which will be overwritten when upgrade
// How To Custom Config:
// 1. copy config.example.php config.php; edit config.php
// 2. upgrading your config.php when config.example.php were upgraded
// leave this setting unset to auto detect using browser request header
// $config['lang'] = 'en-us';
$config['charset'] = "UTF-8";
// enable this for translators only
$config['show_todo_strings'] = false;
// this ob filter is applied for the cache list, not the whole page
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';
// "XCache Cacher" http auth for is enforced for security reason
// if http auth is disabled, any vhost user who can upload *.php will see all variable data cached in XCache
/*// but if you have your own login/permission system, you can integerate it using the following example
// {{{ 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()) {
user_load_permissions();
if (user_is_admin()) {
// user is trusted after permission checks above.
// tell XCache about it (the only secure way to by pass XCache http auth)
$_SERVER["PHP_AUTH_USER"] = "moo";
$_SERVER["PHP_AUTH_PW"] = "your-xcache-password-before-md5";
}
else {
die("Permission denied");
}
}
else {
if (!ask_the_user_to_login()) {
exit;
}
}
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-before-md5";
*/

View File

@ -1,25 +0,0 @@
<?php
$strings = array(
'root'
=> '开始',
'Directory'
=> '目录',
'File'
=> '文件',
'Percent'
=> '覆盖率',
'Hits'
=> '命中',
'Lines'
=> '行数',
'TODO'
=> '闲置文件',
'XCache PHP Code Coverage Viewer'
=> 'XCache PHP 代码覆盖查看器',
'module'
=> '模块',
''
=> '',
);

View File

@ -1,112 +1,7 @@
<?php
function get_language_file_ex($name, $l, $s)
{
static $lmap = array(
'zh' => 'zh-simplified',
'zh-hk' => 'zh-traditional',
'zh-tw' => 'zh-traditional',
);
static $smap = array(
'gbk' => 'gb2312',
'gb18030' => 'gb2312',
);
require_once "../common/common.php";
if (isset($lmap[$l])) {
$l = $lmap[$l];
}
if (file_exists($file = "$name-$l-$s.lang.php")) {
return $file;
}
if (isset($smap[$s])) {
$s = $smap[$s];
if (file_exists($file = "$name-$l-$s.lang.php")) {
return $file;
}
}
if (file_exists($file = "$name-$l.lang.php")) {
return $file;
}
return null;
}
include(get_language_file("coverager"));
$module = "coverager";
function get_language_file($name)
{
global $charset, $lang;
$s = strtolower($charset);
if (isset($lang)) {
$l = strtolower($lang);
$file = get_language_file_ex($name, $l, $s);
if (!isset($file)) {
$l = strtok($l, '-');
$file = get_language_file_ex($name, $l, $s);
}
}
else if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
foreach (explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $l) {
$l = strtok($l, ';');
$file = get_language_file_ex($name, $l, $s);
if (isset($file)) {
$lang = $l;
break;
}
if (strpos($l, '-') !== false) {
$ll = strtok($l, '-');
$file = get_language_file_ex($name, $ll, $s);
if (isset($file)) {
$lang = $l;
break;
}
}
}
}
return isset($file) ? $file : "$name-en.lang.php";
}
function _T($str)
{
if (isset($GLOBALS['strings'][$str])) {
return $GLOBALS['strings'][$str];
}
if (!empty($GLOBALS['show_todo_strings'])) {
return '<span style="color:red">' . htmlspecialchars($str) . '</span>';
}
return $str;
}
function stripaddslashes_array($value, $mqs = false)
{
if (is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = stripaddslashes_array($v, $mqs);
}
}
else if(is_string($value)) {
$value = $mqs ? str_replace('\'\'', '\'', $value) : stripslashes($value);
}
return $value;
}
error_reporting(E_ALL);
ini_set('display_errors', 'On');
define('REQUEST_TIME', time());
if (get_magic_quotes_gpc()) {
$mqs = (bool) ini_get('magic_quotes_sybase');
$_GET = stripaddslashes_array($_GET, $mqs);
$_POST = stripaddslashes_array($_POST, $mqs);
$_REQUEST = stripaddslashes_array($_REQUEST, $mqs);
}
ini_set('magic_quotes_runtime', '0');
$charset = "UTF-8";
if (file_exists("./config.php")) {
include("./config.php");
}
include(get_language_file("common"));
if (!isset($lang)) {
$lang = 'en-us';
}
?>

View File

@ -0,0 +1,19 @@
<?php
// DO NOT rename/delete/modify example file which will be overwritten when upgrade
// How To Custom Config:
// 1. copy config.example.php config.php; edit config.php
// 2. upgrading your config.php when config.example.php were upgraded
// XCache will load
// 1. ../config.default.php
// 2. ./config.default.php
// 3. ../config.php
// 4. ./config.php
// $config['include_paths = array("/www/my-php-project/");
// $config['exclude_paths = array("/www/my-php-project/tmp/");
$config['syntax_higlight'] = true;
$config['use_cache'] = false;
//// $config['datadir'] is default to ini_get("xcache.coveragedump_directory")
// $config['datadir'] = '';

View File

@ -1,59 +0,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;
// $include_paths = array("/www/my-php-project/");
// $exclude_paths = array("/www/my-php-project/tmp/");
$syntaxhiglight = true;
$usecache = false;
//// $datadir is default to ini_get("xcache.coveragedump_directory")
// $datadir = '';
function ob_filter_path_nicer($o)
{
$sep = DIRECTORY_SEPARATOR;
$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);
if ($sep == '/') {
$o = str_replace("/home/", "{H}/", $o);
}
return $o;
}
// implement your auth here if needed
// {{{ home made login example
// this is an example only, it's won't work for you without your implemention.
function check_admin_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");
}
return true;
}
// uncomment:
// check_admin_auth()
// }}}
?>

View File

@ -1,6 +1,6 @@
<?php
$strings = array(
$strings += array(
'root'
=> '开始',
'Directory'

View File

@ -1,15 +1,5 @@
h1 { text-align: center; display: block; }
input, table { font-family: sans-serif; font-size: 11px; }
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; }
table.cycles .col2 { background-color: #e0e0e0; }
table.cycles th, table.cycles td { border: 1px solid black; font-family: monospace; }
table.cycles th { background-color: #9999cc; color: black; font-weight: bold; height: 20px; line-height: 20px; font-family: serif; }
th a { color: black; font-weight: bold; display: block; width: 100%; height: 100%; }
.coverFile {
text-align: left;
@ -67,5 +57,4 @@ pre.code {
padding: 0; margin: 0;
}
.footnote { text-align: right; font-size: 12px; }
.error { color: red; }

View File

@ -2,40 +2,10 @@
include("./common.php");
class Cycle
{
var $values;
var $i;
var $count;
function Cycle($v)
{
$this->values = func_get_args();
$this->i = -1;
$this->count = count($this->values);
}
function next()
{
$this->i = ($this->i + 1) % $this->count;
return $this->values[$this->i];
}
function cur()
{
return $this->values[$this->i];
}
function reset()
{
$this->i = -1;
}
}
class XcacheCoverageViewer
{
var $syntaxhiglight = true;
var $usecache = false;
var $syntax_higlight = true;
var $use_cache = false;
var $include_paths = array();
var $exclude_paths = array();
var $charset = 'UTF-8';
@ -49,10 +19,10 @@ class XcacheCoverageViewer
{
$this->datadir = ini_get('xcache.coveragedump_directory');
// copy config
foreach (array('charset', 'include_paths', 'exclude_paths', 'syntaxhiglight', 'usecache', 'datadir', 'lang') as $k) {
if (isset($GLOBALS[$k])) {
$this->{$k} = $GLOBALS[$k];
global $config;
foreach (array('charset', 'include_paths', 'exclude_paths', 'syntax_higlight', 'use_cache', 'datadir', 'lang') as $k) {
if (isset($config[$k])) {
$this->{$k} = $config[$k];
}
}
@ -78,7 +48,7 @@ class XcacheCoverageViewer
$action = 'dir';
$prefix_len = strlen($path) + 1;
$dirinfo = $this->loadDir($this->outpath);
if (!$this->usecache) {
if (!$this->use_cache) {
ksort($dirinfo['subdirs']);
ksort($dirinfo['files']);
}
@ -103,7 +73,7 @@ class XcacheCoverageViewer
$lines[$l] .= $chunks[$c];
}
}
if ($this->syntaxhiglight) {
if ($this->syntax_higlight) {
$source = implode('', $lines);
ob_start();
highlight_string($source);
@ -129,20 +99,20 @@ class XcacheCoverageViewer
}
else if (!$this->datadir) {
$action = 'error';
$error = 'require `ini:xcache.coveragedump_directory` or `config:$datadir` to be set';
$error = 'require `xcache.coveragedump_directory` in ini or `$datadir` in config to be set';
}
else {
$action = 'error';
$error = "no data";
}
$xcache_version = defined('XCACHE_VERSION') ? XCACHE_VERSION : '';
global $config;
include("coverager.tpl.php");
}
function loadDir($outdir, $addtodo = null)
{
if ($this->usecache) {
if ($this->use_cache) {
$cachefile = $outdir . "/.pcovcache";
if (file_exists($cachefile)) {
return unserialize(file_get_contents($cachefile));
@ -209,7 +179,7 @@ class XcacheCoverageViewer
}
}
if ($this->usecache) {
if ($this->use_cache) {
ksort($subdirs);
ksort($files);
}
@ -222,7 +192,7 @@ class XcacheCoverageViewer
'subdirs' => $subdirs,
);
if ($this->usecache) {
if ($this->use_cache) {
$fp = fopen($cachefile, "wb");
fwrite($fp, serialize($info));
fclose($fp);
@ -232,7 +202,7 @@ class XcacheCoverageViewer
function loadFile($file)
{
if ($this->usecache) {
if ($this->use_cache) {
$cachefile = $file . "cache";
if (file_exists($cachefile)) {
return unserialize(file_get_contents($cachefile));
@ -242,7 +212,7 @@ class XcacheCoverageViewer
$info = $this->loadCov($file); //, $lines);
unset($info['cov']);
if ($this->usecache) {
if ($this->use_cache) {
$fp = fopen($cachefile, "wb");
fwrite($fp, serialize($info));
fclose($fp);

View File

@ -1,19 +1,4 @@
<!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=$this->charset" />
<meta http-equiv="Content-Language" content="{$this->lang}" />
<script type="text/javascript" src="tablesort.js" charset="$this->charset"></script>
HEAD;
?>
<link rel="stylesheet" type="text/css" href="coverager.css" />
<title><?php echo _T("XCache PHP Code Coverage Viewer"); ?></title>
</head>
<body>
<h1><?php echo _T("XCache PHP Code Coverage Viewer"); ?></h1>
<?php include "../common/header.tpl.php"; ?>
<?php
function calc_percent($info, &$percent, &$class)
@ -49,11 +34,11 @@ function dir_head()
{
global $cycle;