Changeset 1074 in svn for trunk/htdocs/cacher/index.php


Ignore:
Timestamp:
2012-07-29T05:06:57Z (3 years ago)
Author:
Xuefer
Message:

htdocs: split template

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/cacher/index.php

    r1069 r1074  
    114114    }
    115115    return implode('', $html);
     116}
     117
     118function getModuleInfo()
     119{
     120    ob_start();
     121    phpinfo(INFO_MODULES);
     122    $moduleInfo = ob_get_clean();
     123    if (!preg_match_all('!(XCache[^<>]*)</a></h2>(.*?)<h2>!is', $moduleInfo, $m)) {
     124        return;
     125    }
     126
     127    $moduleInfo = array();
     128    foreach ($m[1] as $i => $dummy) {
     129        $moduleInfo[] = '<h3>' . trim($m[1][$i]) . '</h3>';
     130        $moduleInfo[] = str_replace('<br />', '', trim($m[2][$i]));
     131    }
     132    return implode('', $moduleInfo);
    116133}
    117134
     
    156173}
    157174
    158 $moduleinfo = null;
    159 $type_none = -1;
    160 if (!isset($_GET['type'])) {
    161     $_GET['type'] = $type_none;
    162 }
    163 $_GET['type'] = $type = (int) $_GET['type'];
     175$listTypes = array('' => _('Summary'), 'listphp' => _('List PHP'), 'listvar' => _('List Var Data'));
     176
     177if (!isset($_GET['do'])) {
     178    $_GET['do'] = '';
     179}
    164180
    165181// {{{ process clear, enable, disable
     
    194210for ($i = 0; $i < $pcnt; $i ++) {
    195211    $data = xcache_info(XC_TYPE_PHP, $i);
    196     if ($type === XC_TYPE_PHP) {
     212    if ($_GET['do'] === 'listphp') {
    197213        $data += xcache_list(XC_TYPE_PHP, $i);
    198214    }
     
    220236for ($i = 0; $i < $vcnt; $i ++) {
    221237    $data = xcache_info(XC_TYPE_VAR, $i);
    222     if ($type === XC_TYPE_VAR) {
     238    if ($_GET['do'] === 'listvar') {
    223239        $data += xcache_list(XC_TYPE_VAR, $i);
    224240    }
     
    243259// }}}
    244260// {{{ merge the list
    245 switch ($type) {
    246 case XC_TYPE_PHP:
    247 case XC_TYPE_VAR:
    248     $cachelist = array('type' => $type, 'cache_list' => array(), 'deleted_list' => array());
    249     if ($type == XC_TYPE_VAR) {
     261switch ($_GET['do']) {
     262case 'listphp':
     263case '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 {
    250270        $cachelist['type_name'] = 'var';
    251     }
    252     else {
    253         $cachelist['type_name'] = 'php';
     271        $cachelist['type'] = XC_TYPE_VAR;
    254272    }
    255273    foreach ($cacheinfos as $i => $c) {
     
    257275            continue;
    258276        }
    259         if ($c['type'] == $type && isset($c['cache_list'])) {
     277        if ($c['type'] == $cachelist['type'] && isset($c['cache_list'])) {
    260278            foreach ($c['cache_list'] as $e) {
    261279                $e['cache_name'] = $c['cache_name'];
     
    268286        }
    269287    }
    270     if ($type == XC_TYPE_PHP) {
     288    if ($cachelist['type'] == XC_TYPE_PHP) {
    271289        $inodes = array();
    272290        $haveinode = false;
     
    287305    }
    288306    unset($data);
     307    include("./listentries.tpl.php");
    289308    break;
    290309
    291310default:
    292     $_GET['type'] = $type_none;
    293     $cachelist = array();
    294     ob_start();
    295     phpinfo(INFO_MODULES);
    296     $moduleinfo = ob_get_clean();
    297     if (preg_match_all('!(XCache[^<>]*)</a></h2>(.*?)<h2>!is', $moduleinfo, $m)) {
    298         $moduleinfo = array();
    299         foreach ($m[1] as $i => $dummy) {
    300             $moduleinfo[] = '<h3>' . trim($m[1][$i]) . '</h3>';
    301             $moduleinfo[] = str_replace('<br />', '', trim($m[2][$i]));
    302         }
    303         $moduleinfo = implode('', $moduleinfo);
    304     }
    305     else {
    306         $moduleinfo = null;
    307     }
    308     break;
     311    include("./summary.tpl.php");
    309312}
    310313// }}}
    311314
    312 $type_php = XC_TYPE_PHP;
    313 $type_var = XC_TYPE_VAR;
    314 $listTypes = array($type_none => _('Statistics'), $type_php => _('List PHP'), $type_var => _('List Var Data'));
    315 
    316 include("cacher.tpl.php");
    317 
    318315?>
Note: See TracChangeset for help on using the changeset viewer.