PHP监测Memcache服务端的运行状况(3)

//
// don't cache this page
//
header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");                                    // HTTP/1.0

function duration($ts) {
    global $time;
    $years = (int)((($time - $ts)/(7*86400))/52.177457);
    $rem = (int)(($time-$ts)-($years * 52.177457 * 7 * 86400));
    $weeks = (int)(($rem)/(7*86400));
    $days = (int)(($rem)/86400) - $weeks*7;
    $hours = (int)(($rem)/3600) - $days*24 - $weeks*7*24;
    $mins = (int)(($rem)/60) - $hours*60 - $days*24*60 - $weeks*7*24*60;
    $str = '';
    if($years==1) $str .= "$years year, ";
    if($years>1) $str .= "$years years, ";
    if($weeks==1) $str .= "$weeks week, ";
    if($weeks>1) $str .= "$weeks weeks, ";
    if($days==1) $str .= "$days day,";
    if($days>1) $str .= "$days days,";
    if($hours == 1) $str .= " $hours hour and";
    if($hours>1) $str .= " $hours hours and";
    if($mins == 1) $str .= " 1 minute";
    else $str .= " $mins minutes";
    return $str;
}

// create graphics
//
function graphics_avail() {
 return extension_loaded('gd');
}

function bsize($s) {
 foreach (array('','K','M','G') as $i => $k) {
  if ($s < 1024) break;
  $s/=1024;
 }
 return sprintf("%5.1f %sBytes",$s,$k);
}

// create menu entry
function menu_entry($ob,$title) {
 global $PHP_SELF;
 if ($ob==$_GET['op']){
    return "<li><a class=https://www.linuxidc.com/Linux/2014-11/\"child_active\" href=https://www.linuxidc.com/Linux/2014-11/\"$PHP_SELF&op=$ob\">$title</a></li>";
 }
 return "<li><a class=https://www.linuxidc.com/Linux/2014-11/\"active\" href=https://www.linuxidc.com/Linux/2014-11/\"$PHP_SELF&op=$ob\">$title</a></li>";
}

function getHeader(){
    $header = <<<EOB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>MEMCACHE INFO</title>
<style type="text/css"><!--
body { background:white; font-size:100.01%; margin:0; padding:0; }
body,p,td,th,input,submit { font-size:0.8em;font-family:arial,helvetica,sans-serif; }
* html body  {font-size:0.8em}
* html p      {font-size:0.8em}
* html td    {font-size:0.8em}
* html th    {font-size:0.8em}
* html input  {font-size:0.8em}
* html submit {font-size:0.8em}
td { vertical-align:top }
a { color:black; font-weight:none; text-decoration:none; }
a:hover { text-decoration:underline; }
div.content { padding:1em 1em 1em 1em; position:absolute; width:97%; z-index:100; }

h1.memcache { background:rgb(153,153,204); margin:0; padding:0.5em 1em 0.5em 1em; }
* html h1.memcache { margin-bottom:-7px; }
h1.memcache a:hover { text-decoration:none; color:rgb(90,90,90); }
h1.memcache span.logo {
 background:rgb(119,123,180);
 color:black;
 border-right: solid black 1px;
 border-bottom: solid black 1px;
 font-style:italic;
 font-size:1em;
 padding-left:1.2em;
 padding-right:1.2em;
 text-align:right;
 display:block;
 width:130px;
 }
h1.memcache span.logo span.name { color:white; font-size:0.7em; padding:0 0.8em 0 2em; }
h1.memcache span.nameinfo { color:white; display:inline; font-size:0.4em; margin-left: 3em; }
h1.memcache div.copy { color:black; font-size:0.4em; position:absolute; right:1em; }
hr.memcache {
 background:white;
 border-bottom:solid rgb(102,102,153) 1px;
 border-style:none;
 border-top:solid rgb(102,102,153) 10px;
 height:12px;
 margin:0;
 margin-top:1px;
 padding:0;
}

ol,menu { margin:1em 0 0 0; padding:0.2em; margin-left:1em;}
ol.menu li { display:inline; margin-right:0.7em; list-style:none; font-size:85%}
ol.menu a {
 background:rgb(153,153,204);
 border:solid rgb(102,102,153) 2px;
 color:white;
 font-weight:bold;
 margin-right:0em;
 padding:0.1em 0.5em 0.1em 0.5em;
 text-decoration:none;
 margin-left: 5px;
 }
ol.menu a.child_active {
 background:rgb(153,153,204);
 border:solid rgb(102,102,153) 2px;
 color:white;
 font-weight:bold;
 margin-right:0em;
 padding:0.1em 0.5em 0.1em 0.5em;
 text-decoration:none;
 border-left: solid black 5px;
 margin-left: 0px;
 }
ol.menu span.active {
 background:rgb(153,153,204);
 border:solid rgb(102,102,153) 2px;
 color:black;
 font-weight:bold;
 margin-right:0em;
 padding:0.1em 0.5em 0.1em 0.5em;
 text-decoration:none;
 border-left: solid black 5px;
 }
ol.menu span.inactive {
 background:rgb(193,193,244);
 border:solid rgb(182,182,233) 2px;
 color:white;
 font-weight:bold;
 margin-right:0em;
 padding:0.1em 0.5em 0.1em 0.5em;
 text-decoration:none;
 margin-left: 5px;
 }
ol.menu a:hover {
 background:rgb(193,193,244);
 text-decoration:none;
 }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/8864f323703fffce391c0cd784e04a30.html