Changeset 1078 in svn


Ignore:
Timestamp:
2012-07-29T06:45:04Z (3 years ago)
Author:
Xuefer
Message:

htdocs/cache: re-adds help

Location:
trunk/htdocs/cacher
Files:
11 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/cacher/cacher-zh-simplified.lang.php

    r1074 r1078  
    4141        => '缓存区',
    4242        'php Cached'
    43         => '缓存的 php 脚本',
     43        => '缓存的 PHP 脚本',
    4444        'php Deleted'
    45         => '待删 php 缓存',
     45        => '待删 PHP 缓存',
    4646        'var Cached'
    4747        => '缓存的变量',
     
    7979        => '操作|点击按钮清除对应共享内存区的数据',
    8080        'cache.status'
    81         => '状态|状态标记. 当共享内存区正在编译 php 脚本时标记为 "编译中". 当共享内存区暂停使用时标记为 "禁用"',
     81        => '状态|状态标记. 当共享内存区正在编译 PHP 脚本时标记为 "编译中". 当共享内存区暂停使用时标记为 "禁用"',
    8282        'cache.hits'
    83         => '命中|共享内存命中次数, 命中=从该共享内存载入php或者变量',
     83        => '命中|共享内存命中次数, 命中=从该共享内存载入 PHP 或者变量',
    8484        'cache.hits_avg_h'
    8585        => '命中/H|每小时命中次数. 只统计最后 24 小时',
  • trunk/htdocs/cacher/cacher-zh-traditional.lang.php

    r1074 r1078  
    4141        => '快取',
    4242        'php Cached'
    43         => '快取的 php 指令',
     43        => '快取的 PHP 指令',
    4444        'php Deleted'
    45         => '待刪 php 指令',
     45        => '待刪 PHP 指令',
    4646        'var Cached'
    4747        => '快取的變數',
     
    7979        => '操作按鈕|點擊按鈕清除對應共享記憶體區的資料',
    8080        'cache.status'
    81         => '狀態|狀態標記. 當共享內存區正在編譯 php 腳本時標記為 "編譯中". 當共享內存區暫停使用時標記為 "禁用"',
     81        => '狀態|狀態標記. 當共享內存區正在編譯 PHP 腳本時標記為 "編譯中". 當共享內存區暫停使用時標記為 "禁用"',
    8282        'cache.hits'
    83         => '命中|共享記憶體命中次數,命中=從該共享記憶體載入php或者變數',
     83        => '命中|共享記憶體命中次數,命中=從該共享記憶體載入 PHP 或者變數',
    8484        'cache.hits_avg_h'
    8585        => '命中/H|每小时命中次数. 只统计最后 24 小时',
  • trunk/htdocs/cacher/cacher.css

    r1069 r1078  
    1919.hitsgraph div div.barv.active { border-color: yellow; }
    2020
    21 #help { display: block; float: right; }
    2221dl { overflow: hidden; }
    2322dt { font-weight: bold; clear: both; float: left; width: 100px; text-align: right; margin: 0; }
  • trunk/htdocs/cacher/common.php

    r1054 r1078  
    33require_once "../common/common.php";
    44
    5 include(get_language_file("cacher"));
     5include get_language_file("cacher");
  • trunk/htdocs/cacher/edit.php

    r1053 r1078  
    11<?php
    22
    3 include("./common.php");
     3include "./common.php";
    44
    55if (!isset($_GET['name'])) {
     
    3939$module = "cacher";
    4040
    41 include("edit.tpl.php");
     41include "edit.tpl.php";
    4242
    4343?>
  • trunk/htdocs/cacher/edit.tpl.php

    r1053 r1078  
    1 <?php include("../common/header.tpl.php"); ?>
     1<?php include "../common/header.tpl.php"; ?>
    22<?php
    33$h_name = htmlspecialchars($name);
     
    1616    </fieldset>
    1717</form>
    18 <?php include("../common/footer.tpl.php"); ?>
     18<?php include "../common/footer.tpl.php"; ?>
  • trunk/htdocs/cacher/help.tpl.php

    r1062 r1078  
    1 <?php
    2 include("./common.php");
    3 ?>
    4 <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    5 <html xmlns="http://www.w3.org/1999/xhtml">
    6 <head>
    7 <?php
    8 echo <<<HEAD
    9     <meta http-equiv="Content-Type" content="text/html; charset=$config[charset]" />
    10     <meta http-equiv="Content-Language" content="$config[lang]" />
    11     <script type="text/javascript" src="tablesort.js" charset="$config[charset]"></script>
    12 HEAD;
    13 ?>
    14 
    15     <link rel="stylesheet" type="text/css" href="xcache.css" />
    16     <title><?php echo _('XCache Help'); ?></title>
    17     <script>
    18     function toggle(o)
    19     {
    20         o.style.display = o.style.display != 'block' ? 'block' : 'none';
    21     }
    22     </script>
    23 </head>
    24 
    25 <body>
    26 <h1><?php echo _('XCache Help'); ?></h1>
    27 <div id1="help">
    28 <?php include(get_language_file("help")); ?>
     1<?php include "../common/header.tpl.php"; ?>
     2<div class="switcher"><?php echo switcher("do", $doTypes); ?></div>
     3<?php if (ini_get("xcache.test")) { ?>
     4<form method="post" action="">
     5    <div>
     6        <input type="submit" name="coredump" value="Test coredump" class="submit" onclick="return confirm('<?php echo _('Sure?'); ?>');" />
     7    </div>
     8</form>
     9<?php } ?>
     10<div id="help">
     11    <?php include get_language_file("help"); ?>
    2912</div>
    30 
    31 <?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>
    32 </body>
    33 </html>
     13<?php include "../common/footer.tpl.php" ?>
  • trunk/htdocs/cacher/index.php

    r1074 r1078  
    11<?php
    22
    3 include("./common.php");
    4 
    5 function freeblock_to_graph($freeblocks, $size)
     3include "./common.php";
     4
     5function freeblock_to_graph($freeblocks, $size) // {{{
    66{
    77    global $config;
     
    4242    return implode('', $html);
    4343}
    44 
    45 function calc_total(&$total, $data)
     44// }}}
     45function calc_total(&$total, $data) // {{{
    4646{
    4747    foreach ($data as $k => $v) {
     
    7171    }
    7272}
    73 
    74 function array_avg($a)
     73// }}}
     74function array_avg($a) // {{{
    7575{
    7676    if (count($a) == 0) {
     
    7979    return array_sum($a) / count($a);
    8080}
    81 
    82 function bar_hits_percent($v, $percent, $active)
     81// }}}
     82function bar_hits_percent($v, $percent, $active) // {{{
    8383{
    8484    $r = 220 + (int) ($percent * 25);
     
    9696        . '</div>';
    9797}
    98 
    99 function get_cache_hits_graph($ci, $key)
    100 {
     98// }}}
     99function get_cache_hits_graph($ci, $key) // {{{
     100{
     101    global $maxHitsByHour;
    101102    if ($ci['cacheid'] == -1) {
    102103        $max = max($ci[$key]);
    103104    }
    104105    else {
    105         $max = $GLOBALS['maxhits_by_hour'][$ci['type']];
     106        $max = $maxHitsByHour[$ci['type']];
    106107    }
    107108    if (!$max) {
     
    115116    return implode('', $html);
    116117}
    117 
    118 function getModuleInfo()
     118// }}}
     119function getModuleInfo() // {{{
    119120{
    120121    ob_start();
     
    132133    return implode('', $moduleInfo);
    133134}
     135// }}}
     136function getCacheInfos() // {{{
     137{
     138    static $cacheInfos;
     139    if (isset($cacheInfos)) {
     140        return $cacheInfos;
     141    }
     142
     143    $phpCacheCount = xcache_count(XC_TYPE_PHP);
     144    $varCacheCount = xcache_count(XC_TYPE_VAR);
     145
     146    $cacheInfos = array();
     147    $total = array();
     148    global $maxHitsByHour;
     149    $maxHitsByHour = array(0, 0);
     150    for ($i = 0; $i < $phpCacheCount; $i ++) {
     151        $data = xcache_info(XC_TYPE_PHP, $i);
     152        if ($_GET['do'] === 'listphp') {
     153            $data += xcache_list(XC_TYPE_PHP, $i);
     154        }
     155        $data['type'] = XC_TYPE_PHP;
     156        $data['cache_name'] = "php#$i";
     157        $data['cacheid'] = $i;
     158        $cacheInfos[] = $data;
     159        $maxHitsByHour[XC_TYPE_PHP] = max($maxHitsByHour[XC_TYPE_PHP], max($data['hits_by_hour']));
     160        if ($phpCacheCount >= 2) {
     161            calc_total($total, $data);
     162        }
     163    }
     164
     165    if ($phpCacheCount >= 2) {
     166        $total['type'] = XC_TYPE_PHP;
     167        $total['cache_name'] = _('Total');
     168        $total['cacheid'] = -1;
     169        $total['gc'] = null;
     170        $total['istotal'] = true;
     171        unset($total['compiling']);
     172        $cacheInfos[] = $total;
     173    }
     174
     175    $total = array();
     176    for ($i = 0; $i < $varCacheCount; $i ++) {
     177        $data = xcache_info(XC_TYPE_VAR, $i);
     178        if ($_GET['do'] === 'listvar') {
     179            $data += xcache_list(XC_TYPE_VAR, $i);
     180        }
     181        $data['type'] = XC_TYPE_VAR;
     182        $data['cache_name'] = "var#$i";
     183        $data['cacheid'] = $i;
     184        $cacheInfos[] = $data;
     185        $maxHitsByHour[XC_TYPE_VAR] = max($maxHitsByHour[XC_TYPE_VAR], max($data['hits_by_hour']));
     186        if ($varCacheCount >= 2) {
     187            calc_total($total, $data);
     188        }
     189    }
     190
     191    if ($varCacheCount >= 2) {
     192        $total['type'] = XC_TYPE_VAR;
     193        $total['cache_name'] = _('Total');
     194        $total['cacheid'] = -1;
     195        $total['gc'] = null;
     196        $total['istotal'] = true;
     197        $cacheInfos[] = $total;
     198    }
     199    return $cacheInfos;
     200}
     201// }}}
     202function getEntryList() // {{{
     203{
     204    static $entryList;
     205    if (isset($entryList)) {
     206        return $entryList;
     207    }
     208    $entryList = array('cache_list' => array(), 'deleted_list' => array());
     209    if ($_GET['do'] == 'listphp') {
     210        $entryList['type_name'] = 'php';
     211        $entryList['type'] = XC_TYPE_PHP;
     212    }
     213    else {
     214        $entryList['type_name'] = 'var';
     215        $entryList['type'] = XC_TYPE_VAR;
     216    }
     217    foreach (getCacheInfos() as $i => $c) {
     218        if (!empty($c['istotal'])) {
     219            continue;
     220        }
     221        if ($c['type'] == $entryList['type'] && isset($c['cache_list'])) {
     222            foreach ($c['cache_list'] as $e) {
     223                $e['cache_name'] = $c['cache_name'];
     224                $entryList['cache_list'][] = $e;
     225            }
     226            foreach ($c['deleted_list'] as $e) {
     227                $e['cache_name'] = $c['cache_name'];
     228                $entryList['deleted_list'][] = $e;
     229            }
     230        }
     231    }
     232    return $entryList;
     233}
     234// }}}
    134235
    135236$module = "cacher";
    136237if (!extension_loaded('XCache')) {
    137     include("../common/header.tpl.php");
     238    include "../common/header.tpl.php";
    138239    echo '<h1>XCache is not loaded</h1>';
    139240    ob_start();
     
    158259    }
    159260    echo "(See above)";
    160     include("../common/footer.tpl.php");
     261    include "../common/footer.tpl.php";
    161262    exit;
    162263}
    163 $pcnt = xcache_count(XC_TYPE_PHP);
    164 $vcnt = xcache_count(XC_TYPE_VAR);
    165 
    166 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    167     $remove = @ $_POST['remove'];
    168     if ($remove && is_array($remove)) {
    169         foreach ($remove as $name) {
    170             xcache_unset($name);
    171         }
    172     }
    173 }
    174 
    175 $listTypes = array('' => _('Summary'), 'listphp' => _('List PHP'), 'listvar' => _('List Var Data'));
    176 
    177 if (!isset($_GET['do'])) {
    178     $_GET['do'] = '';
    179 }
    180 
    181 // {{{ process clear, enable, disable
    182 function processAction()
    183 {
     264
     265$doTypes = array(
     266        '' => _('Summary'),
     267        'listphp' => _('List PHP'),
     268        'listvar' => _('List Var Data'),
     269        'help' => _('Help'),
     270        );
     271
     272function processPOST() // {{{
     273{
     274    if (isset($_POST['remove']) && is_array($_POST['remove'])) {
     275        foreach ($_POST['remove'] as $name) {
     276            if (is_string($name)) {
     277                xcache_unset($name);
     278            }
     279        }
     280    }
     281
    184282    $type = isset($_POST['type']) ? $_POST['type'] : null;
    185283    if ($type != XC_TYPE_PHP && $type != XC_TYPE_VAR) {
     
    198296        }
    199297    }
    200 }
    201 processAction();
    202 if (isset($_POST['coredump'])) {
    203     xcache_coredump();
    204 }
    205 // }}}
    206 // {{{ load info/list
    207 $cacheinfos = array();
    208 $total = array();
    209 $maxhits_by_hour = array(0, 0);
    210 for ($i = 0; $i < $pcnt; $i ++) {
    211     $data = xcache_info(XC_TYPE_PHP, $i);
    212     if ($_GET['do'] === 'listphp') {
    213         $data += xcache_list(XC_TYPE_PHP, $i);
    214     }
    215     $data['type'] = XC_TYPE_PHP;
    216     $data['cache_name'] = "php#$i";
    217     $data['cacheid'] = $i;
    218     $cacheinfos[] = $data;
    219     $maxhits_by_hour[XC_TYPE_PHP] = max($maxhits_by_hour[XC_TYPE_PHP], max($data['hits_by_hour']));
    220     if ($pcnt >= 2) {
    221         calc_total($total, $data);
    222     }
    223 }
    224 
    225 if ($pcnt >= 2) {
    226     $total['type'] = XC_TYPE_PHP;
    227     $total['cache_name'] = _('Total');
    228     $total['cacheid'] = -1;
    229     $total['gc'] = null;
    230     $total['istotal'] = true;
    231     unset($total['compiling']);
    232     $cacheinfos[] = $total;
    233 }
    234 
    235 $total = array();
    236 for ($i = 0; $i < $vcnt; $i ++) {
    237     $data = xcache_info(XC_TYPE_VAR, $i);
    238     if ($_GET['do'] === 'listvar') {
    239         $data += xcache_list(XC_TYPE_VAR, $i);
    240     }
    241     $data['type'] = XC_TYPE_VAR;
    242     $data['cache_name'] = "var#$i";
    243     $data['cacheid'] = $i;
    244     $cacheinfos[] = $data;
    245     $maxhits_by_hour[XC_TYPE_VAR] = max($maxhits_by_hour[XC_TYPE_VAR], max($data['hits_by_hour']));
    246     if ($vcnt >= 2) {
    247         calc_total($total, $data);
    248     }
    249 }
    250 
    251 if ($vcnt >= 2) {
    252     $total['type'] = XC_TYPE_VAR;
    253     $total['cache_name'] = _('Total');
    254     $total['cacheid'] = -1;
    255     $total['gc'] = null;
    256     $total['istotal'] = true;
    257     $cacheinfos[] = $total;
    258 }
    259 // }}}
    260 // {{{ merge the list
     298
     299    if (isset($_POST['coredump'])) {
     300        xcache_coredump();
     301    }
     302}
     303// }}}
     304
     305processPOST();
     306
     307if (!isset($_GET['do'])) {
     308    $_GET['do'] = '';
     309}
     310
    261311switch ($_GET['do']) {
    262312case 'listphp':
    263313case 'listvar':
    264     $cachelist = array('cache_list' => array(), 'deleted_list' => array());
    265     if ($_GET['do'] == 'listphp') {
    266         $cachelist['type_name'] = 'php';
    267         $cachelist['type'] = XC_TYPE_PHP;
    268     }
    269     else {
    270         $cachelist['type_name'] = 'var';
    271         $cachelist['type'] = XC_TYPE_VAR;
    272     }
    273     foreach ($cacheinfos as $i => $c) {
    274         if (!empty($c['istotal'])) {
    275             continue;
    276         }
    277         if ($c['type'] == $cachelist['type'] && isset($c['cache_list'])) {
    278             foreach ($c['cache_list'] as $e) {
    279                 $e['cache_name'] = $c['cache_name'];
    280                 $cachelist['cache_list'][] = $e;
    281             }
    282             foreach ($c['deleted_list'] as $e) {
    283                 $e['cache_name'] = $c['cache_name'];
    284                 $cachelist['deleted_list'][] = $e;
    285             }
    286         }
    287     }
    288     if ($cachelist['type'] == XC_TYPE_PHP) {
    289         $inodes = array();
    290         $haveinode = false;
    291         foreach ($cachelist['cache_list'] as $e) {
    292             if (isset($e['file_inode'])) {
    293                 $haveinode = true;
    294                 break;
    295             }
    296         }
    297         if (!$haveinode) {
    298             foreach ($cachelist['deleted_list'] as $e) {
    299                 if (isset($e['file_inode'])) {
    300                     $haveinode = true;
    301                     break;
    302                 }
    303             }
    304         }
    305     }
    306     unset($data);
    307     include("./listentries.tpl.php");
     314    include "./listentries.tpl.php";
    308315    break;
    309316
     317case 'help':
     318    include "./help.tpl.php";
     319    break;
     320
    310321default:
    311     include("./summary.tpl.php");
    312 }
    313 // }}}
     322    include "./summary.tpl.php";
     323    break;
     324}
    314325
    315326?>
  • trunk/htdocs/cacher/listentries.tpl.php

    r1074 r1078  
    1 <?php include("../common/header.tpl.php"); ?>
    2 <div class="switcher"><?php echo switcher("do", $listTypes); ?></div>
     1<?php include "../common/header.tpl.php"; ?>
     2<div class="switcher"><?php echo switcher("do", $doTypes); ?></div>
     3<?php include "./sub/summary.tpl.php"; ?>
    34<?php
    4 
    5 include "./sub/summary.tpl.php";
    6 $isphp = $cachelist['type'] == 'listphp';
     5$entryList = getEntryList();
     6$isphp = $entryList['type'] == 'listphp';
     7$typeName = $entryList['type_name'];
    78ob_start($config['path_nicer']);
    89
    910$listName = 'Cached';
    10 $entries = $cachelist['cache_list'];
     11$entries = $entryList['cache_list'];
    1112include "./sub/entrylist.tpl.php";
    1213
    1314$listName = 'Deleted';
    14 $entries = $cachelist['deleted_list'];
     15$entries = $entryList['deleted_list'];
    1516include "./sub/entrylist.tpl.php";
    1617
    1718ob_end_flush();
    1819unset($isphp);
    19 
    2020?>
    21 <?php include("../common/footer.tpl.php"); ?>
     21<?php include "../common/footer.tpl.php"; ?>
  • trunk/htdocs/cacher/sub/entrylist.tpl.php

    r1076 r1078  
    22<form action="" method="post">
    33    <table cellspacing="0" cellpadding="4" class="cycles entries">
    4         <caption><?php echo _("{$cachelist['type_name']} $listName"); ?></caption>
     4        <caption><?php echo _("$typeName $listName"); ?></caption>
    55<?php
    66
     
    3636        , th(N_("entry.file_mtime"))
    3737        ;
    38     if ($haveinode) {
    39         echo
    40             th(N_("entry.file_device"))
    41             , th(N_("entry.file_inode"))
    42             ;
    43     }
     38    echo
     39        th(N_("entry.file_device"))
     40        , th(N_("entry.file_inode"))
     41        ;
    4442}
    4543echo
  • trunk/htdocs/cacher/sub/summary.tpl.php

    r1076 r1078  
    3535    $l_normal = _('Normal');
    3636    $l_confirm = _('Sure?');
    37     foreach ($cacheinfos as $i => $ci) {
     37    foreach (getCacheInfos() as $i => $ci) {
    3838        $class = $cycleClass->next();
    3939        echo <<<TR
  • trunk/htdocs/cacher/summary.tpl.php

    r1074 r1078  
    1 <?php include("../common/header.tpl.php"); ?>
    2 <div class="switcher"><?php echo switcher("do", $listTypes); ?></div>
    3 <?php
    4 include "./sub/summary.tpl.php";
    5 
    6 if (ini_get("xcache.test")) {
    7 ?>
    8 <form method="post" action="">
    9     <div>
    10         <input type="submit" name="coredump" value="Test coredump" class="submit" onclick="return confirm('<?php echo _('Sure?'); ?>');" />
    11     </div>
    12 </form>
    13 <?php
    14 }
    15 ?>
    16 <?php include("./sub/moduleinfo.tpl.php"); ?>
    17 
    18 <?php include("../common/footer.tpl.php"); ?>
     1<?php include "../common/header.tpl.php"; ?>
     2<div class="switcher"><?php echo switcher("do", $doTypes); ?></div>
     3<?php include "./sub/summary.tpl.php"; ?>
     4<?php include "./sub/moduleinfo.tpl.php"; ?>
     5<?php include "../common/footer.tpl.php"; ?>
Note: See TracChangeset for help on using the changeset viewer.