Changeset 1053 in svn for trunk/htdocs/cacher/cacher.php


Ignore:
Timestamp:
2012-07-27T09:17:42+02:00 (3 years ago)
Author:
Xuefer
Message:

refactor: move htdocs, bin, lib for easier installation

File:
1 moved

Legend:

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

    r1052 r1053  
    22
    33include("./common.php");
    4 
    5 class Cycle
    6 {
    7     var $values;
    8     var $i;
    9     var $count;
    10 
    11     function Cycle($v)
    12     {
    13         $this->values = func_get_args();
    14         $this->i = -1;
    15         $this->count = count($this->values);
    16     }
    17 
    18     function next()
    19     {
    20         $this->i = ($this->i + 1) % $this->count;
    21         return $this->values[$this->i];
    22     }
    23 
    24     function cur()
    25     {
    26         return $this->values[$this->i];
    27     }
    28 
    29     function reset()
    30     {
    31         $this->i = -1;
    32     }
    33 }
    34 
    35 function number_formats($a, $keys)
    36 {
    37     foreach ($keys as $k) {
    38         $a[$k] = number_format($a[$k]);
    39     }
    40     return $a;
    41 }
    42 
    43 function size($size)
    44 {
    45     $size = (int) $size;
    46     if ($size < 1024)
    47         return number_format($size, 2) . ' b';
    48 
    49     if ($size < 1048576)
    50         return number_format($size / 1024, 2) . ' K';
    51 
    52     return number_format($size / 1048576, 2) . ' M';
    53 }
    54 
    55 function age($time)
    56 {
    57     if (!$time) return '';
    58     $delta = REQUEST_TIME - $time;
    59 
    60     if ($delta < 0) {
    61         $delta = -$delta;
    62     }
    63    
    64     static $seconds = array(1, 60, 3600, 86400, 604800, 2678400, 31536000);
    65     static $name = array('s', 'm', 'h', 'd', 'w', 'M', 'Y');
    66 
    67     for ($i = 6; $i >= 0; $i --) {
    68         if ($delta >= $seconds[$i]) {
    69             $ret = (int) ($delta / $seconds[$i]);
    70             return $ret . ' ' . $name[$i];
    71         }
    72     }
    73 
    74     return '0 s';
    75 }
    764
    775function freeblock_to_graph($freeblocks, $size)
     
    183111}
    184112
    185 function switcher($name, $options)
    186 {
    187     $n = isset($_GET[$name]) ? $_GET[$name] : null;
    188     $html = array();
    189     foreach ($options as $k => $v) {
    190         $html[] = sprintf('<a href="?%s=%s"%s>%s</a>', $name, $k, $k == $n ? ' class="active"' : '', $v);
    191     }
    192     return implode('', $html);
    193 }
    194 
    195 function th($name, $attrs = null)
    196 {
    197     $translated = __($name);
    198     if ($translated == $name) {
    199         $translated = "$name|$name";
    200     }
    201     list($text, $title) = explode('|', $translated, 2);
    202     return sprintf('%s<th%s id="%s" title="%s"><a href="javascript:" onclick="resort(this); return false">%s</a></th>%s'
    203             , "\t"
    204             , $attrs ? " $attrs" : ""
    205             , $name, htmlspecialchars(trim($title)), trim($text)
    206             , "\n");
    207 }
    208 
    209 $php_version = phpversion();
    210 $xcache_version = XCACHE_VERSION;
    211 $xcache_modules = XCACHE_MODULES;
    212 
     113$module = "cacher";
    213114if (!extension_loaded('XCache')) {
    214     include("header.tpl.php");
     115    include("../common/header.tpl.php");
    215116    echo '<h1>XCache is not loaded</h1>';
    216117    ob_start();
     
    235136    }
    236137    echo "(See above)";
    237     include("footer.tpl.php");
     138    include("../common/footer.tpl.php");
    238139    exit;
    239140}
     
    401302$type_php = XC_TYPE_PHP;
    402303$type_var = XC_TYPE_VAR;
    403 $types = array($type_none => _('Statistics'), $type_php => _('List PHP'), $type_var => _('List Var Data'));
    404 
    405 include("xcache.tpl.php");
     304$listTypes = array($type_none => _('Statistics'), $type_php => _('List PHP'), $type_var => _('List Var Data'));
     305
     306include("cacher.tpl.php");
    406307
    407308?>
Note: See TracChangeset for help on using the changeset viewer.