Browse Source

htdocs/cache: re-adds help

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1078 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 9 years ago
parent
commit
c780befeee
  1. 8
      htdocs/cacher/cacher-zh-simplified.lang.php
  2. 8
      htdocs/cacher/cacher-zh-traditional.lang.php
  3. 1
      htdocs/cacher/cacher.css
  4. 2
      htdocs/cacher/common.php
  5. 4
      htdocs/cacher/edit.php
  6. 4
      htdocs/cacher/edit.tpl.php
  7. 33
      htdocs/cacher/help.php
  8. 13
      htdocs/cacher/help.tpl.php
  9. 277
      htdocs/cacher/index.php
  10. 18
      htdocs/cacher/listentries.tpl.php
  11. 12
      htdocs/cacher/sub/entrylist.tpl.php
  12. 2
      htdocs/cacher/sub/summary.tpl.php
  13. 23
      htdocs/cacher/summary.tpl.php

8
htdocs/cacher/cacher-zh-simplified.lang.php

@ -40,9 +40,9 @@ $strings += array(
'Caches'
=> '缓存区',
'php Cached'
=> '缓存的 php 脚本',
=> '缓存的 PHP 脚本',
'php Deleted'
=> '待删 php 缓存',
=> '待删 PHP 缓存',
'var Cached'
=> '缓存的变量',
'var Deleted'
@ -78,9 +78,9 @@ $strings += array(
'cache.operations'
=> '操作|点击按钮清除对应共享内存区的数据',
'cache.status'
=> '状态|状态标记. 当共享内存区正在编译 php 脚本时标记为 "编译中". 当共享内存区暂停使用时标记为 "禁用"',
=> '状态|状态标记. 当共享内存区正在编译 PHP 脚本时标记为 "编译中". 当共享内存区暂停使用时标记为 "禁用"',
'cache.hits'
=> '命中|共享内存命中次数, 命中=从该共享内存载入php或者变量',
=> '命中|共享内存命中次数, 命中=从该共享内存载入 PHP 或者变量',
'cache.hits_avg_h'
=> '命中/H|每小时命中次数. 只统计最后 24 小时',
'cache.hits_graph'

8
htdocs/cacher/cacher-zh-traditional.lang.php

@ -40,9 +40,9 @@ $strings += array(
'Caches'
=> '快取',
'php Cached'
=> '快取的 php 指令',
=> '快取的 PHP 指令',
'php Deleted'
=> '待刪 php 指令',
=> '待刪 PHP 指令',
'var Cached'
=> '快取的變數',
'var Deleted'
@ -78,9 +78,9 @@ $strings += array(
'cache.operations'
=> '操作按鈕|點擊按鈕清除對應共享記憶體區的資料',
'cache.status'
=> '狀態|狀態標記. 當共享內存區正在編譯 php 腳本時標記為 "編譯中". 當共享內存區暫停使用時標記為 "禁用"',
=> '狀態|狀態標記. 當共享內存區正在編譯 PHP 腳本時標記為 "編譯中". 當共享內存區暫停使用時標記為 "禁用"',
'cache.hits'
=> '命中|共享記憶體命中次數,命中=從該共享記憶體載入php或者變數',
=> '命中|共享記憶體命中次數,命中=從該共享記憶體載入 PHP 或者變數',
'cache.hits_avg_h'
=> '命中/H|每小时命中次数. 只统计最后 24 小时',
'cache.hits_graph'

1
htdocs/cacher/cacher.css

@ -18,7 +18,6 @@ td, th { white-space: pre; }
.hitsgraph div div.barf.active { border-color: yellow; }
.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; }
dd { margin: 0; }

2
htdocs/cacher/common.php

@ -2,4 +2,4 @@
require_once "../common/common.php";
include(get_language_file("cacher"));
include get_language_file("cacher");

4
htdocs/cacher/edit.php

@ -1,6 +1,6 @@
<?php
include("./common.php");
include "./common.php";
if (!isset($_GET['name'])) {
die("missing name");
@ -38,6 +38,6 @@ else {
$module = "cacher";
include("edit.tpl.php");
include "edit.tpl.php";
?>

4
htdocs/cacher/edit.tpl.php

@ -1,4 +1,4 @@
<?php include("../common/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("../common/footer.tpl.php"); ?>
<?php include "../common/footer.tpl.php"; ?>

33
htdocs/cacher/help.php

@ -1,33 +0,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>

13
htdocs/cacher/help.tpl.php

@ -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" ?>

277
htdocs/cacher/index.php

@ -1,8 +1,8 @@
<?php
include("./common.php");
include "./common.php";
function freeblock_to_graph($freeblocks, $size)
function freeblock_to_graph($freeblocks, $size) // {{{
{
global $config;
@ -41,8 +41,8 @@ function freeblock_to_graph($freeblocks, $size)
}
return implode('', $html);
}
function calc_total(&$total, $data)
// }}}
function calc_total(&$total, $data) // {{{
{
foreach ($data as $k => $v) {
switch ($k) {
@ -70,16 +70,16 @@ function calc_total(&$total, $data)
}
}
}
function array_avg($a)
// }}}
function array_avg($a) // {{{
{
if (count($a) == 0) {
return '';
}
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);
$g = $b = 220 - (int) ($percent * 220);
@ -95,14 +95,15 @@ function bar_hits_percent($v, $percent, $active)
. '<div class="barv' . $a . '" style="background: rgb(' . "$r,$g,$b" . '); height: ' . $valueHeight . '"></div>'
. '</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) {
$max = 1;
@ -114,8 +115,8 @@ function get_cache_hits_graph($ci, $key)
}
return implode('', $html);
}
function getModuleInfo()
// }}}
function getModuleInfo() // {{{
{
ob_start();
phpinfo(INFO_MODULES);
@ -131,10 +132,110 @@ function getModuleInfo()
}
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();
phpinfo(INFO_GENERAL);
@ -157,30 +258,27 @@ if (!extension_loaded('XCache')) {
echo "You don't even have a php.ini yet?";
}
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);
$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);
}
}
}
}
$listTypes = array('' => _('Summary'), 'listphp' => _('List PHP'), 'listvar' => _('List Var Data'));
if (!isset($_GET['do'])) {
$_GET['do'] = '';
}
// {{{ process clear, enable, disable
function processAction()
{
$type = isset($_POST['type']) ? $_POST['type'] : null;
if ($type != XC_TYPE_PHP && $type != XC_TYPE_VAR) {
$type = null;
@ -197,119 +295,32 @@ function processAction()
xcache_enable_cache($type, $cacheid, false);
}
}
}
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 (isset($_POST['coredump'])) {
xcache_coredump();
}
}
// }}}
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;
}
processPOST();
$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 (!isset($_GET['do'])) {
$_GET['do'] = '';
}
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
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;
}
// }}}
?>

18
htdocs/cacher/listentries.tpl.php

@ -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"; ?>

12
htdocs/cacher/sub/entrylist.tpl.php

@ -1,7 +1,7 @@
<?php $cycleClass = new Cycle('class="col1"', 'class="col2"'); ?>
<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
echo <<<TR
@ -35,12 +35,10 @@ if ($isphp) {
, th(N_("entry.file_size"))
, 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
th(N_("entry.hash"))

2
htdocs/cacher/sub/summary.tpl.php

@ -34,7 +34,7 @@
$l_compiling = _('Compiling');
$l_normal = _('Normal');
$l_confirm = _('Sure?');
foreach ($cacheinfos as $i => $ci) {
foreach (getCacheInfos() as $i => $ci) {
$class = $cycleClass->next();
echo <<<TR
<tr {$class}>

23
htdocs/cacher/summary.tpl.php

@ -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"; ?>

Loading…
Cancel
Save