{"id":546,"date":"2024-12-10T12:05:45","date_gmt":"2024-12-10T04:05:45","guid":{"rendered":"http:\/\/192.168.5.24\/?p=546"},"modified":"2024-12-10T14:42:00","modified_gmt":"2024-12-10T06:42:00","slug":"memcached%e5%ae%89%e8%a3%85%e5%8f%8a%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/bigvip.dpdns.org\/?p=546","title":{"rendered":"memcached\u5b89\u88c5\u53ca\u4f7f\u7528"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u4ecb\u7ecd<\/h2>\n\n\n\n<p>         Memcached \u662f\u56fd\u5916\u793e\u533a\u7f51\u7ad9\u56e2\u961f\u5f00\u53d1\u7684 \u9ad8\u6027\u80fd\u7684\u5206\u5e03\u5f0f\u5185\u5b58\u7f13\u5b58\u670d\u52a1\u5668\u3002\u4e00\u822c\u7684\u4f7f\u7528\u76ee\u7684\u662f\u901a\u8fc7\u7f13\u5b58\u6570\u636e\u5e93\u67e5\u8be2\u7ed3\u679c\uff0c\u51cf\u5c11\u6570\u636e\u5e93\u8bbf\u95ee\u6b21\u6570\uff0c\u4ee5\u63d0\u9ad8\u52a8\u6001 Web \u5e94\u7528\u7684\u901f\u5ea6\u3001\u63d0\u9ad8\u8bbf\u95ee\u6548\u7387\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u5b89\u88c5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>yum -y install libevent telnet memcached <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u4f7f\u7528<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>telnet 127.0.0.1 11211<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u76d1\u63a7<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5b89\u88c5web\u670d\u52a1\u5668\u53caphp\u652f\u6301\n\nyum -y install httpd php\n\n\u628a\u76d1\u63a7\u9875\u9762\u7684php\u6587\u4ef6\u653e\u5230\u6587\u6863\u9ed8\u8ba4\u8def\u5f84\/var\/www\/html\u4e2d\n\u6253\u5f00httpd\u670d\u52a1 \n\nsystemctl start httpd<\/code><\/pre>\n\n\n\n<p>\u8ba9\u540e\u7528\u6d4f\u89c8\u5668\u6253\u5f00<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"420\" src=\"http:\/\/192.168.5.24\/wp-content\/uploads\/2024\/12\/image-3-1024x420.png\" alt=\"\" class=\"wp-image-547\" srcset=\"https:\/\/bigvip.dpdns.org\/wp-content\/uploads\/2024\/12\/image-3-1024x420.png 1024w, https:\/\/bigvip.dpdns.org\/wp-content\/uploads\/2024\/12\/image-3-300x123.png 300w, https:\/\/bigvip.dpdns.org\/wp-content\/uploads\/2024\/12\/image-3-768x315.png 768w, https:\/\/bigvip.dpdns.org\/wp-content\/uploads\/2024\/12\/image-3-816x335.png 816w, https:\/\/bigvip.dpdns.org\/wp-content\/uploads\/2024\/12\/image-3.png 1100w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u76d1\u63a7memcached\u7684php\u6587\u4ef6\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n$VERSION='$Id: memcache.php,v 1.1.2.3 2008\/08\/28 18:07:54 mikl Exp $';\n\ndefine('ADMIN_USERNAME','root'); \t\/\/ Admin Username\ndefine('ADMIN_PASSWORD','123456');  \t\/\/ Admin Password\ndefine('DATE_FORMAT','Y\/m\/d H:i:s');\ndefine('GRAPH_SIZE',200);\ndefine('MAX_ITEM_DUMP',50);\n\n$MEMCACHE_SERVERS&#91;] = '192.168.65.128:11211'; \/\/ add more as an array\n\n\n\/\/\/\/\/\/\/\/\/\/ END OF DEFAULT CONFIG AREA \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Password protect \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\nif (!isset($_SERVER&#91;'PHP_AUTH_USER']) || !isset($_SERVER&#91;'PHP_AUTH_PW']) ||\n           $_SERVER&#91;'PHP_AUTH_USER'] != ADMIN_USERNAME ||$_SERVER&#91;'PHP_AUTH_PW'] != ADMIN_PASSWORD) {\n\t\t\tHeader(\"WWW-Authenticate: Basic realm=\\\"Memcache Login\\\"\");\n\t\t\tHeader(\"HTTP\/1.0 401 Unauthorized\");\n\n\t\t\techo &lt;&lt;&lt;EOB\n\t\t\t\t&lt;html>&lt;body>\n\t\t\t\t&lt;h1>Rejected!&lt;\/h1>\n\t\t\t\t&lt;big>Wrong Username or Password!&lt;\/big>\n\t\t\t\t&lt;\/body>&lt;\/html>\nEOB;\n\t\t\texit;\n}\n\n\/\/\/\/\/\/\/\/\/\/\/MEMCACHE FUNCTIONS \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\nfunction sendMemcacheCommands($command){\n    global $MEMCACHE_SERVERS;\n\t$result = array();\n\n\tforeach($MEMCACHE_SERVERS as $server){\n\t\t$strs = explode(':',$server);\n\t\t$host = $strs&#91;0];\n\t\t$port = $strs&#91;1];\n\t\t$result&#91;$server] = sendMemcacheCommand($host,$port,$command);\n\t}\n\treturn $result;\n}\nfunction sendMemcacheCommand($server,$port,$command){\n\n\t$s = @fsockopen($server,$port);\n\tif (!$s){\n\t\tdie(\"Cant connect to:\".$server.':'.$port);\n\t}\n\n\tfwrite($s, $command.\"\\r\\n\");\n\n\t$buf='';\n\twhile ((!feof($s))) {\n\t\t$buf .= fgets($s, 256);\n\t\tif (strpos($buf,\"END\\r\\n\")!==false){ \/\/ stat says end\n\t\t    break;\n\t\t}\n\t\tif (strpos($buf,\"DELETED\\r\\n\")!==false || strpos($buf,\"NOT_FOUND\\r\\n\")!==false){ \/\/ delete says these\n\t\t    break;\n\t\t}\n\t\tif (strpos($buf,\"OK\\r\\n\")!==false){ \/\/ flush_all says ok\n\t\t    break;\n\t\t}\n\t}\n    fclose($s);\n    return parseMemcacheResults($buf);\n}\nfunction parseMemcacheResults($str){\n\n\t$res = array();\n\t$lines = explode(\"\\r\\n\",$str);\n\t$cnt = count($lines);\n\tfor($i=0; $i&lt; $cnt; $i++){\n\t    $line = $lines&#91;$i];\n\t\t$l = explode(' ',$line,3);\n\t\tif (count($l)==3){\n\t\t\t$res&#91;$l&#91;0]]&#91;$l&#91;1]]=$l&#91;2];\n\t\t\tif ($l&#91;0]=='VALUE'){ \/\/ next line is the value\n\t\t\t    $res&#91;$l&#91;0]]&#91;$l&#91;1]] = array();\n\t\t\t    list ($flag,$size)=explode(' ',$l&#91;2]);\n\t\t\t    $res&#91;$l&#91;0]]&#91;$l&#91;1]]&#91;'stat']=array('flag'=>$flag,'size'=>$size);\n\t\t\t    $res&#91;$l&#91;0]]&#91;$l&#91;1]]&#91;'value']=$lines&#91;++$i];\n\t\t\t}\n\t\t}elseif($line=='DELETED' || $line=='NOT_FOUND' || $line=='OK'){\n\t\t    return $line;\n\t\t}\n\t}\n\treturn $res;\n\n}\n\nfunction dumpCacheSlab($server,$slabId,$limit){\n    list($host,$port) = explode(':',$server);\n    $resp = sendMemcacheCommand($host,$port,'stats cachedump '.$slabId.' '.$limit);\n\n   return $resp;\n\n}\n\nfunction flushServer($server){\n    list($host,$port) = explode(':',$server);\n    $resp = sendMemcacheCommand($host,$port,'flush_all');\n    return $resp;\n}\nfunction getCacheItems(){\n $items = sendMemcacheCommands('stats items');\n $serverItems = array();\n $totalItems = array();\n foreach ($items as $server=>$itemlist){\n    $serverItems&#91;$server] = array();\n    $totalItems&#91;$server]=0;\n    if (!isset($itemlist&#91;'STAT'])){\n        continue;\n    }\n\n    $iteminfo = $itemlist&#91;'STAT'];\n\n    foreach($iteminfo as $keyinfo=>$value){\n        if (preg_match('\/items\\:(\\d+?)\\:(.+?)$\/',$keyinfo,$matches)){\n            $serverItems&#91;$server]&#91;$matches&#91;1]]&#91;$matches&#91;2]] = $value;\n            if ($matches&#91;2]=='number'){\n                $totalItems&#91;$server] +=$value;\n            }\n        }\n    }\n }\n return array('items'=>$serverItems,'counts'=>$totalItems);\n}\nfunction getMemcacheStats($total=true){\n\t$resp = sendMemcacheCommands('stats');\n\tif ($total){\n\t\t$res = array();\n\t\tforeach($resp as $server=>$r){\n\t\t\tforeach($r&#91;'STAT'] as $key=>$row){\n\t\t\t\tif (!isset($res&#91;$key])){\n\t\t\t\t\t$res&#91;$key]=null;\n\t\t\t\t}\n\t\t\t\tswitch ($key){\n\t\t\t\t\tcase 'pid':\n\t\t\t\t\t\t$res&#91;'pid']&#91;$server]=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'uptime':\n\t\t\t\t\t\t$res&#91;'uptime']&#91;$server]=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'time':\n\t\t\t\t\t\t$res&#91;'time']&#91;$server]=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'version':\n\t\t\t\t\t\t$res&#91;'version']&#91;$server]=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'pointer_size':\n\t\t\t\t\t\t$res&#91;'pointer_size']&#91;$server]=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'rusage_user':\n\t\t\t\t\t\t$res&#91;'rusage_user']&#91;$server]=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'rusage_system':\n\t\t\t\t\t\t$res&#91;'rusage_system']&#91;$server]=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'curr_items':\n\t\t\t\t\t\t$res&#91;'curr_items']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'total_items':\n\t\t\t\t\t\t$res&#91;'total_items']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'bytes':\n\t\t\t\t\t\t$res&#91;'bytes']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'curr_connections':\n\t\t\t\t\t\t$res&#91;'curr_connections']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'total_connections':\n\t\t\t\t\t\t$res&#91;'total_connections']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'connection_structures':\n\t\t\t\t\t\t$res&#91;'connection_structures']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'cmd_get':\n\t\t\t\t\t\t$res&#91;'cmd_get']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'cmd_set':\n\t\t\t\t\t\t$res&#91;'cmd_set']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'get_hits':\n\t\t\t\t\t\t$res&#91;'get_hits']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'get_misses':\n\t\t\t\t\t\t$res&#91;'get_misses']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'evictions':\n\t\t\t\t\t\t$res&#91;'evictions']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'bytes_read':\n\t\t\t\t\t\t$res&#91;'bytes_read']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'bytes_written':\n\t\t\t\t\t\t$res&#91;'bytes_written']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'limit_maxbytes':\n\t\t\t\t\t\t$res&#91;'limit_maxbytes']+=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase 'threads':\n\t\t\t\t\t\t$res&#91;'rusage_system']&#91;$server]=$row;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn $res;\n\t}\n\treturn $resp;\n}\n\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n\/\/\n\/\/ don't cache this page\n\/\/\nheader(\"Cache-Control: no-store, no-cache, must-revalidate\");  \/\/ HTTP\/1.1\nheader(\"Cache-Control: post-check=0, pre-check=0\", false);\nheader(\"Pragma: no-cache\");                                    \/\/ HTTP\/1.0\n\nfunction duration($ts) {\n    global $time;\n    $years = (int)((($time - $ts)\/(7*86400))\/52.177457);\n    $rem = (int)(($time-$ts)-($years * 52.177457 * 7 * 86400));\n    $weeks = (int)(($rem)\/(7*86400));\n    $days = (int)(($rem)\/86400) - $weeks*7;\n    $hours = (int)(($rem)\/3600) - $days*24 - $weeks*7*24;\n    $mins = (int)(($rem)\/60) - $hours*60 - $days*24*60 - $weeks*7*24*60;\n    $str = '';\n    if($years==1) $str .= \"$years year, \";\n    if($years>1) $str .= \"$years years, \";\n    if($weeks==1) $str .= \"$weeks week, \";\n    if($weeks>1) $str .= \"$weeks weeks, \";\n    if($days==1) $str .= \"$days day,\";\n    if($days>1) $str .= \"$days days,\";\n    if($hours == 1) $str .= \" $hours hour and\";\n    if($hours>1) $str .= \" $hours hours and\";\n    if($mins == 1) $str .= \" 1 minute\";\n    else $str .= \" $mins minutes\";\n    return $str;\n}\n\n\/\/ create graphics\n\/\/\nfunction graphics_avail() {\n\treturn extension_loaded('gd');\n}\n\nfunction bsize($s) {\n\tforeach (array('','K','M','G') as $i => $k) {\n\t\tif ($s &lt; 1024) break;\n\t\t$s\/=1024;\n\t}\n\treturn sprintf(\"%5.1f %sBytes\",$s,$k);\n}\n\n\/\/ create menu entry\nfunction menu_entry($ob,$title) {\n\tglobal $PHP_SELF;\n\tif ($ob==$_GET&#91;'op']){\n\t    return \"&lt;li>&lt;a class=\\\"child_active\\\" href=\\\"$PHP_SELF&amp;op=$ob\\\">$title&lt;\/a>&lt;\/li>\";\n\t}\n\treturn \"&lt;li>&lt;a class=\\\"active\\\" href=\\\"$PHP_SELF&amp;op=$ob\\\">$title&lt;\/a>&lt;\/li>\";\n}\n\nfunction getHeader(){\n    $header = &lt;&lt;&lt;EOB\n&lt;!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\">\n&lt;html>\n&lt;head>&lt;title>MEMCACHE INFO&lt;\/title>\n&lt;style type=\"text\/css\">&lt;!--\nbody { background:white; font-size:100.01%; margin:0; padding:0; }\nbody,p,td,th,input,submit { font-size:0.8em;font-family:arial,helvetica,sans-serif; }\n* html body   {font-size:0.8em}\n* html p      {font-size:0.8em}\n* html td     {font-size:0.8em}\n* html th     {font-size:0.8em}\n* html input  {font-size:0.8em}\n* html submit {font-size:0.8em}\ntd { vertical-align:top }\na { color:black; font-weight:none; text-decoration:none; }\na:hover { text-decoration:underline; }\ndiv.content { padding:1em 1em 1em 1em; position:absolute; width:97%; z-index:100; }\n\nh1.memcache { background:rgb(153,153,204); margin:0; padding:0.5em 1em 0.5em 1em; }\n* html h1.memcache { margin-bottom:-7px; }\nh1.memcache a:hover { text-decoration:none; color:rgb(90,90,90); }\nh1.memcache span.logo {\n\tbackground:rgb(119,123,180);\n\tcolor:black;\n\tborder-right: solid black 1px;\n\tborder-bottom: solid black 1px;\n\tfont-style:italic;\n\tfont-size:1em;\n\tpadding-left:1.2em;\n\tpadding-right:1.2em;\n\ttext-align:right;\n\tdisplay:block;\n\twidth:130px;\n\t}\nh1.memcache span.logo span.name { color:white; font-size:0.7em; padding:0 0.8em 0 2em; }\nh1.memcache span.nameinfo { color:white; display:inline; font-size:0.4em; margin-left: 3em; }\nh1.memcache div.copy { color:black; font-size:0.4em; position:absolute; right:1em; }\nhr.memcache {\n\tbackground:white;\n\tborder-bottom:solid rgb(102,102,153) 1px;\n\tborder-style:none;\n\tborder-top:solid rgb(102,102,153) 10px;\n\theight:12px;\n\tmargin:0;\n\tmargin-top:1px;\n\tpadding:0;\n}\n\nol,menu { margin:1em 0 0 0; padding:0.2em; margin-left:1em;}\nol.menu li { display:inline; margin-right:0.7em; list-style:none; font-size:85%}\nol.menu a {\n\tbackground:rgb(153,153,204);\n\tborder:solid rgb(102,102,153) 2px;\n\tcolor:white;\n\tfont-weight:bold;\n\tmargin-right:0em;\n\tpadding:0.1em 0.5em 0.1em 0.5em;\n\ttext-decoration:none;\n\tmargin-left: 5px;\n\t}\nol.menu a.child_active {\n\tbackground:rgb(153,153,204);\n\tborder:solid rgb(102,102,153) 2px;\n\tcolor:white;\n\tfont-weight:bold;\n\tmargin-right:0em;\n\tpadding:0.1em 0.5em 0.1em 0.5em;\n\ttext-decoration:none;\n\tborder-left: solid black 5px;\n\tmargin-left: 0px;\n\t}\nol.menu span.active {\n\tbackground:rgb(153,153,204);\n\tborder:solid rgb(102,102,153) 2px;\n\tcolor:black;\n\tfont-weight:bold;\n\tmargin-right:0em;\n\tpadding:0.1em 0.5em 0.1em 0.5em;\n\ttext-decoration:none;\n\tborder-left: solid black 5px;\n\t}\nol.menu span.inactive {\n\tbackground:rgb(193,193,244);\n\tborder:solid rgb(182,182,233) 2px;\n\tcolor:white;\n\tfont-weight:bold;\n\tmargin-right:0em;\n\tpadding:0.1em 0.5em 0.1em 0.5em;\n\ttext-decoration:none;\n\tmargin-left: 5px;\n\t}\nol.menu a:hover {\n\tbackground:rgb(193,193,244);\n\ttext-decoration:none;\n\t}\n\n\ndiv.info {\n\tbackground:rgb(204,204,204);\n\tborder:solid rgb(204,204,204) 1px;\n\tmargin-bottom:1em;\n\t}\ndiv.info h2 {\n\tbackground:rgb(204,204,204);\n\tcolor:black;\n\tfont-size:1em;\n\tmargin:0;\n\tpadding:0.1em 1em 0.1em 1em;\n\t}\ndiv.info table {\n\tborder:solid rgb(204,204,204) 1px;\n\tborder-spacing:0;\n\twidth:100%;\n\t}\ndiv.info table th {\n\tbackground:rgb(204,204,204);\n\tcolor:white;\n\tmargin:0;\n\tpadding:0.1em 1em 0.1em 1em;\n\t}\ndiv.info table th a.sortable { color:black; }\ndiv.info table tr.tr-0 { background:rgb(238,238,238); }\ndiv.info table tr.tr-1 { background:rgb(221,221,221); }\ndiv.info table td { padding:0.3em 1em 0.3em 1em; }\ndiv.info table td.td-0 { border-right:solid rgb(102,102,153) 1px; white-space:nowrap; }\ndiv.info table td.td-n { border-right:solid rgb(102,102,153) 1px; }\ndiv.info table td h3 {\n\tcolor:black;\n\tfont-size:1.1em;\n\tmargin-left:-0.3em;\n\t}\n.td-0 a , .td-n a, .tr-0 a , tr-1 a {\n    text-decoration:underline;\n}\ndiv.graph { margin-bottom:1em }\ndiv.graph h2 { background:rgb(204,204,204);; color:black; font-size:1em; margin:0; padding:0.1em 1em 0.1em 1em; }\ndiv.graph table { border:solid rgb(204,204,204) 1px; color:black; font-weight:normal; width:100%; }\ndiv.graph table td.td-0 { background:rgb(238,238,238); }\ndiv.graph table td.td-1 { background:rgb(221,221,221); }\ndiv.graph table td { padding:0.2em 1em 0.4em 1em; }\n\ndiv.div1,div.div2 { margin-bottom:1em; width:35em; }\ndiv.div3 { position:absolute; left:40em; top:1em; width:580px; }\n\/\/div.div3 { position:absolute; left:37em; top:1em; right:1em; }\n\ndiv.sorting { margin:1.5em 0em 1.5em 2em }\n.center { text-align:center }\n.aright { position:absolute;right:1em }\n.right { text-align:right }\n.ok { color:rgb(0,200,0); font-weight:bold}\n.failed { color:rgb(200,0,0); font-weight:bold}\n\nspan.box {\n\tborder: black solid 1px;\n\tborder-right:solid black 2px;\n\tborder-bottom:solid black 2px;\n\tpadding:0 0.5em 0 0.5em;\n\tmargin-right:1em;\n}\nspan.green { background:#60F060; padding:0 0.5em 0 0.5em}\nspan.red { background:#D06030; padding:0 0.5em 0 0.5em }\n\ndiv.authneeded {\n\tbackground:rgb(238,238,238);\n\tborder:solid rgb(204,204,204) 1px;\n\tcolor:rgb(200,0,0);\n\tfont-size:1.2em;\n\tfont-weight:bold;\n\tpadding:2em;\n\ttext-align:center;\n\t}\n\ninput {\n\tbackground:rgb(153,153,204);\n\tborder:solid rgb(102,102,153) 2px;\n\tcolor:white;\n\tfont-weight:bold;\n\tmargin-right:1em;\n\tpadding:0.1em 0.5em 0.1em 0.5em;\n\t}\n\/\/-->\n&lt;\/style>\n&lt;\/head>\n&lt;body>\n&lt;div class=\"head\">\n\t&lt;h1 class=\"memcache\">\n\t\t&lt;span class=\"logo\">&lt;a href=\"http:\/\/pecl.php.net\/package\/memcache\">memcache&lt;\/a>&lt;\/span>\n\t\t&lt;span class=\"nameinfo\">memcache.php by &lt;a href=\"http:\/\/livebookmark.net\">Harun Yayli&lt;\/a>&lt;\/span>\n\t&lt;\/h1>\n\t&lt;hr class=\"memcache\">\n&lt;\/div>\n&lt;div class=content>\nEOB;\n\n    return $header;\n}\nfunction getFooter(){\n    global $VERSION;\n    $footer = '&lt;\/div>&lt;!-- Based on apc.php '.$VERSION.'-->&lt;\/body>\n&lt;\/html>\n';\n\n    return $footer;\n\n}\nfunction getMenu(){\n    global $PHP_SELF;\necho \"&lt;ol class=menu>\";\nif ($_GET&#91;'op']!=4){\necho &lt;&lt;&lt;EOB\n    &lt;li>&lt;a href=\"$PHP_SELF&amp;op={$_GET&#91;'op']}\">Refresh Data&lt;\/a>&lt;\/li>\nEOB;\n}\nelse {\necho &lt;&lt;&lt;EOB\n    &lt;li>&lt;a href=\"$PHP_SELF&amp;op=2}\">Back&lt;\/a>&lt;\/li>\nEOB;\n}\necho\n\tmenu_entry(1,'View Host Stats'),\n\tmenu_entry(2,'Variables');\n\necho &lt;&lt;&lt;EOB\n\t&lt;\/ol>\n\t&lt;br\/>\nEOB;\n}\n\n\/\/ TODO, AUTH\n\n$_GET&#91;'op'] = !isset($_GET&#91;'op'])? '1':$_GET&#91;'op'];\n$PHP_SELF= isset($_SERVER&#91;'PHP_SELF']) ? htmlentities(strip_tags($_SERVER&#91;'PHP_SELF'],'')) : '';\n\n$PHP_SELF=$PHP_SELF.'?';\n$time = time();\n\/\/ sanitize _GET\n\nforeach($_GET as $key=>$g){\n    $_GET&#91;$key]=htmlentities($g);\n}\n\n\n\/\/ singleout\n\/\/ when singleout is set, it only gives details for that server.\nif (isset($_GET&#91;'singleout']) &amp;&amp; $_GET&#91;'singleout']>=0 &amp;&amp; $_GET&#91;'singleout'] &lt;count($MEMCACHE_SERVERS)){\n    $MEMCACHE_SERVERS = array($MEMCACHE_SERVERS&#91;$_GET&#91;'singleout']]);\n}\n\n\/\/ display images\nif (isset($_GET&#91;'IMG'])){\n    $memcacheStats = getMemcacheStats();\n    $memcacheStatsSingle = getMemcacheStats(false);\n\n    if (!graphics_avail()) {\n\t\texit(0);\n\t}\n\n\tfunction fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') {\n\t\tglobal $col_black;\n\t\t$x1=$x+$w-1;\n\t\t$y1=$y+$h-1;\n\n\t\timagerectangle($im, $x, $y1, $x1+1, $y+1, $col_black);\n\t\tif($y1>$y) imagefilledrectangle($im, $x, $y, $x1, $y1, $color2);\n\t\telse imagefilledrectangle($im, $x, $y1, $x1, $y, $color2);\n\t\timagerectangle($im, $x, $y1, $x1, $y, $color1);\n\t\tif ($text) {\n\t\t\tif ($placeindex>0) {\n\n\t\t\t\tif ($placeindex&lt;16)\n\t\t\t\t{\n\t\t\t\t\t$px=5;\n\t\t\t\t\t$py=$placeindex*12+6;\n\t\t\t\t\timagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $color2);\n\t\t\t\t\timageline($im,$x,$y+$h\/2,$px+90,$py,$color2);\n\t\t\t\t\timagestring($im,2,$px,$py-6,$text,$color1);\n\n\t\t\t\t} else {\n\t\t\t\t\tif ($placeindex&lt;31) {\n\t\t\t\t\t\t$px=$x+40*2;\n\t\t\t\t\t\t$py=($placeindex-15)*12+6;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$px=$x+40*2+100*intval(($placeindex-15)\/15);\n\t\t\t\t\t\t$py=($placeindex%15)*12+6;\n\t\t\t\t\t}\n\t\t\t\t\timagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2);\n\t\t\t\t\timageline($im,$x+$w,$y+$h\/2,$px,$py,$color2);\n\t\t\t\t\timagestring($im,2,$px+2,$py-6,$text,$color1);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\timagestring($im,4,$x+5,$y1-16,$text,$color1);\n\t\t\t}\n\t\t}\n\t}\n\n\n    function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$color2,$text='',$placeindex=0) {\n\t\t$r=$diameter\/2;\n\t\t$w=deg2rad((360+$start+($end-$start)\/2)%360);\n\n\n\t\tif (function_exists(\"imagefilledarc\")) {\n\t\t\t\/\/ exists only if GD 2.0.1 is avaliable\n\t\t\timagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);\n\t\t\timagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE);\n\t\t\timagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL|IMG_ARC_EDGED);\n\t\t} else {\n\t\t\timagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);\n\t\t\timageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);\n\t\t\timageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start+1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);\n\t\t\timageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end-1))   * $r, $centerY + sin(deg2rad($end))   * $r, $color2);\n\t\t\timageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end))   * $r, $centerY + sin(deg2rad($end))   * $r, $color2);\n\t\t\timagefill($im,$centerX + $r*cos($w)\/2, $centerY + $r*sin($w)\/2, $color2);\n\t\t}\n\t\tif ($text) {\n\t\t\tif ($placeindex>0) {\n\t\t\t\timageline($im,$centerX + $r*cos($w)\/2, $centerY + $r*sin($w)\/2,$diameter, $placeindex*12,$color1);\n\t\t\t\timagestring($im,4,$diameter, $placeindex*12,$text,$color1);\n\n\t\t\t} else {\n\t\t\t\timagestring($im,4,$centerX + $r*cos($w)\/2, $centerY + $r*sin($w)\/2,$text,$color1);\n\t\t\t}\n\t\t}\n\t}\n\t$size = GRAPH_SIZE; \/\/ image size\n\t$image = imagecreate($size+50, $size+10);\n\n\t$col_white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);\n\t$col_red   = imagecolorallocate($image, 0xD0, 0x60,  0x30);\n\t$col_green = imagecolorallocate($image, 0x60, 0xF0, 0x60);\n\t$col_black = imagecolorallocate($image,   0,   0,   0);\n\n\timagecolortransparent($image,$col_white);\n\n    switch ($_GET&#91;'IMG']){\n        case 1: \/\/ pie chart\n            $tsize=$memcacheStats&#91;'limit_maxbytes'];\n    \t\t$avail=$tsize-$memcacheStats&#91;'bytes'];\n    \t\t$x=$y=$size\/2;\n    \t\t$angle_from = 0;\n    \t\t$fuzz = 0.000001;\n\n            foreach($memcacheStatsSingle as $serv=>$mcs) {\n    \t\t\t$free = $mcs&#91;'STAT']&#91;'limit_maxbytes']-$mcs&#91;'STAT']&#91;'bytes'];\n    \t\t\t$used = $mcs&#91;'STAT']&#91;'bytes'];\n\n\n                if ($free>0){\n    \t\t\t\/\/ draw free\n    \t\t\t    $angle_to = ($free*360)\/$tsize;\n                    $perc =sprintf(\"%.2f%%\", ($free *100) \/ $tsize) ;\n\n        \t\t\tfill_arc($image,$x,$y,$size,$angle_from,$angle_from + $angle_to ,$col_black,$col_green,$perc);\n        \t\t\t$angle_from = $angle_from + $angle_to ;\n                }\n    \t\t\tif ($used>0){\n    \t\t\t\/\/ draw used\n        \t\t\t$angle_to = ($used*360)\/$tsize;\n        \t\t\t$perc =sprintf(\"%.2f%%\", ($used *100) \/ $tsize) ;\n        \t\t\tfill_arc($image,$x,$y,$size,$angle_from,$angle_from + $angle_to ,$col_black,$col_red, '('.$perc.')' );\n                    $angle_from = $angle_from+ $angle_to ;\n    \t\t\t}\n    \t\t\t}\n\n        break;\n\n        case 2: \/\/ hit miss\n\n            $hits = ($memcacheStats&#91;'get_hits']==0) ? 1:$memcacheStats&#91;'get_hits'];\n            $misses = ($memcacheStats&#91;'get_misses']==0) ? 1:$memcacheStats&#91;'get_misses'];\n            $total = $hits + $misses ;\n\n\t       \tfill_box($image, 30,$size,50,-$hits*($size-21)\/$total,$col_black,$col_green,sprintf(\"%.1f%%\",$hits*100\/$total));\n\t\t    fill_box($image,130,$size,50,-max(4,($total-$hits)*($size-21)\/$total),$col_black,$col_red,sprintf(\"%.1f%%\",$misses*100\/$total));\n\t\tbreak;\n\n    }\n    header(\"Content-type: image\/png\");\n\timagepng($image);\n\texit;\n}\n\necho getHeader();\necho getMenu();\n\nswitch ($_GET&#91;'op']) {\n\n    case 1: \/\/ host stats\n    \t$phpversion = phpversion();\n        $memcacheStats = getMemcacheStats();\n        $memcacheStatsSingle = getMemcacheStats(false);\n\n        $mem_size = $memcacheStats&#91;'limit_maxbytes'];\n    \t$mem_used = $memcacheStats&#91;'bytes'];\n\t    $mem_avail= $mem_size-$mem_used;\n\t    $startTime = time()-array_sum($memcacheStats&#91;'uptime']);\n\n        $curr_items = $memcacheStats&#91;'curr_items'];\n        $total_items = $memcacheStats&#91;'total_items'];\n        $hits = ($memcacheStats&#91;'get_hits']==0) ? 1:$memcacheStats&#91;'get_hits'];\n        $misses = ($memcacheStats&#91;'get_misses']==0) ? 1:$memcacheStats&#91;'get_misses'];\n        $sets = $memcacheStats&#91;'cmd_set'];\n\n       \t$req_rate = sprintf(\"%.2f\",($hits+$misses)\/($time-$startTime));\n\t    $hit_rate = sprintf(\"%.2f\",($hits)\/($time-$startTime));\n\t    $miss_rate = sprintf(\"%.2f\",($misses)\/($time-$startTime));\n\t    $set_rate = sprintf(\"%.2f\",($sets)\/($time-$startTime));\n\n\t    echo &lt;&lt;&lt; EOB\n\t\t&lt;div class=\"info div1\">&lt;h2>General Cache Information&lt;\/h2>\n\t\t&lt;table cellspacing=0>&lt;tbody>\n\t\t&lt;tr class=tr-1>&lt;td class=td-0>PHP Version&lt;\/td>&lt;td>$phpversion&lt;\/td>&lt;\/tr>\nEOB;\n\t\techo \"&lt;tr class=tr-0>&lt;td class=td-0>Memcached Host\". ((count($MEMCACHE_SERVERS)>1) ? 's':'').\"&lt;\/td>&lt;td>\";\n\t\t$i=0;\n\t\tif (!isset($_GET&#91;'singleout']) &amp;&amp; count($MEMCACHE_SERVERS)>1){\n    \t\tforeach($MEMCACHE_SERVERS as $server){\n    \t\t      echo ($i+1).'. &lt;a href=\"'.$PHP_SELF.'&amp;singleout='.$i++.'\">'.$server.'&lt;\/a>&lt;br\/>';\n    \t\t}\n\t\t}\n\t\telse{\n\t\t    echo '1.'.$MEMCACHE_SERVERS&#91;0];\n\t\t}\n\t\tif (isset($_GET&#91;'singleout'])){\n\t\t      echo '&lt;a href=\"'.$PHP_SELF.'\">(all servers)&lt;\/a>&lt;br\/>';\n\t\t}\n\t\techo \"&lt;\/td>&lt;\/tr>\\n\";\n\t\techo \"&lt;tr class=tr-1>&lt;td class=td-0>Total Memcache Cache&lt;\/td>&lt;td>\".bsize($memcacheStats&#91;'limit_maxbytes']).\"&lt;\/td>&lt;\/tr>\\n\";\n\n\techo &lt;&lt;&lt;EOB\n\t\t&lt;\/tbody>&lt;\/table>\n\t\t&lt;\/div>\n\n\t\t&lt;div class=\"info div1\">&lt;h2>Memcache Server Information&lt;\/h2>\nEOB;\n        foreach($MEMCACHE_SERVERS as $server){\n            echo '&lt;table cellspacing=0>&lt;tbody>';\n            echo '&lt;tr class=tr-1>&lt;td class=td-1>'.$server.'&lt;\/td>&lt;td>&lt;a href=\"'.$PHP_SELF.'&amp;server='.array_search($server,$MEMCACHE_SERVERS).'&amp;op=6\">&#91;&lt;b>Flush this server&lt;\/b>]&lt;\/a>&lt;\/td>&lt;\/tr>';\n    \t\techo '&lt;tr class=tr-0>&lt;td class=td-0>Start Time&lt;\/td>&lt;td>',date(DATE_FORMAT,$memcacheStatsSingle&#91;$server]&#91;'STAT']&#91;'time']-$memcacheStatsSingle&#91;$server]&#91;'STAT']&#91;'uptime']),'&lt;\/td>&lt;\/tr>';\n    \t\techo '&lt;tr class=tr-1>&lt;td class=td-0>Uptime&lt;\/td>&lt;td>',duration($memcacheStatsSingle&#91;$server]&#91;'STAT']&#91;'time']-$memcacheStatsSingle&#91;$server]&#91;'STAT']&#91;'uptime']),'&lt;\/td>&lt;\/tr>';\n    \t\techo '&lt;tr class=tr-0>&lt;td class=td-0>Memcached Server Version&lt;\/td>&lt;td>'.$memcacheStatsSingle&#91;$server]&#91;'STAT']&#91;'version'].'&lt;\/td>&lt;\/tr>';\n    \t\techo '&lt;tr class=tr-1>&lt;td class=td-0>Used Cache Size&lt;\/td>&lt;td>',bsize($memcacheStatsSingle&#91;$server]&#91;'STAT']&#91;'bytes']),'&lt;\/td>&lt;\/tr>';\n    \t\techo '&lt;tr class=tr-0>&lt;td class=td-0>Total Cache Size&lt;\/td>&lt;td>',bsize($memcacheStatsSingle&#91;$server]&#91;'STAT']&#91;'limit_maxbytes']),'&lt;\/td>&lt;\/tr>';\n    \t\techo '&lt;\/tbody>&lt;\/table>';\n\t   }\n    echo &lt;&lt;&lt;EOB\n\n\t\t&lt;\/div>\n\t\t&lt;div class=\"graph div3\">&lt;h2>Host Status Diagrams&lt;\/h2>\n\t\t&lt;table cellspacing=0>&lt;tbody>\nEOB;\n\n\t$size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);\n\techo &lt;&lt;&lt;EOB\n\t\t&lt;tr>\n\t\t&lt;td class=td-0>Cache Usage&lt;\/td>\n\t\t&lt;td class=td-1>Hits &amp;amp; Misses&lt;\/td>\n\t\t&lt;\/tr>\nEOB;\n\n\techo\n\t\tgraphics_avail() ?\n\t\t\t  '&lt;tr>'.\n\t\t\t  \"&lt;td class=td-0>&lt;img alt=\\\"\\\" $size src=\\\"$PHP_SELF&amp;IMG=1&amp;\".(isset($_GET&#91;'singleout'])? 'singleout='.$_GET&#91;'singleout'].'&amp;':'').\"$time\\\">&lt;\/td>\".\n\t\t\t  \"&lt;td class=td-1>&lt;img alt=\\\"\\\" $size src=\\\"$PHP_SELF&amp;IMG=2&amp;\".(isset($_GET&#91;'singleout'])? 'singleout='.$_GET&#91;'singleout'].'&amp;':'').\"$time\\\">&lt;\/td>&lt;\/tr>\\n\"\n\t\t\t: \"\",\n\t\t'&lt;tr>',\n\t\t'&lt;td class=td-0>&lt;span class=\"green box\">&amp;nbsp;&lt;\/span>Free: ',bsize($mem_avail).sprintf(\" (%.1f%%)\",$mem_avail*100\/$mem_size),\"&lt;\/td>\\n\",\n\t\t'&lt;td class=td-1>&lt;span class=\"green box\">&amp;nbsp;&lt;\/span>Hits: ',$hits.sprintf(\" (%.1f%%)\",$hits*100\/($hits+$misses)),\"&lt;\/td>\\n\",\n\t\t'&lt;\/tr>',\n\t\t'&lt;tr>',\n\t\t'&lt;td class=td-0>&lt;span class=\"red box\">&amp;nbsp;&lt;\/span>Used: ',bsize($mem_used ).sprintf(\" (%.1f%%)\",$mem_used *100\/$mem_size),\"&lt;\/td>\\n\",\n\t\t'&lt;td class=td-1>&lt;span class=\"red box\">&amp;nbsp;&lt;\/span>Misses: ',$misses.sprintf(\" (%.1f%%)\",$misses*100\/($hits+$misses)),\"&lt;\/td>\\n\";\n\t\techo &lt;&lt;&lt; EOB\n\t&lt;\/tr>\n\t&lt;\/tbody>&lt;\/table>\n&lt;br\/>\n\t&lt;div class=\"info\">&lt;h2>Cache Information&lt;\/h2>\n\t\t&lt;table cellspacing=0>&lt;tbody>\n\t\t&lt;tr class=tr-0>&lt;td class=td-0>Current Items(total)&lt;\/td>&lt;td>$curr_items ($total_items)&lt;\/td>&lt;\/tr>\n\t\t&lt;tr class=tr-1>&lt;td class=td-0>Hits&lt;\/td>&lt;td>{$hits}&lt;\/td>&lt;\/tr>\n\t\t&lt;tr class=tr-0>&lt;td class=td-0>Misses&lt;\/td>&lt;td>{$misses}&lt;\/td>&lt;\/tr>\n\t\t&lt;tr class=tr-1>&lt;td class=td-0>Request Rate (hits, misses)&lt;\/td>&lt;td>$req_rate cache requests\/second&lt;\/td>&lt;\/tr>\n\t\t&lt;tr class=tr-0>&lt;td class=td-0>Hit Rate&lt;\/td>&lt;td>$hit_rate cache requests\/second&lt;\/td>&lt;\/tr>\n\t\t&lt;tr class=tr-1>&lt;td class=td-0>Miss Rate&lt;\/td>&lt;td>$miss_rate cache requests\/second&lt;\/td>&lt;\/tr>\n\t\t&lt;tr class=tr-0>&lt;td class=td-0>Set Rate&lt;\/td>&lt;td>$set_rate cache requests\/second&lt;\/td>&lt;\/tr>\n\t\t&lt;\/tbody>&lt;\/table>\n\t\t&lt;\/div>\n\nEOB;\n\n    break;\n\n    case 2: \/\/ variables\n\n\t\t$m=0;\n\t\t$cacheItems= getCacheItems();\n\t\t$items = $cacheItems&#91;'items'];\n\t\t$totals = $cacheItems&#91;'counts'];\n\t\t$maxDump = MAX_ITEM_DUMP;\n\t\tforeach($items as $server => $entries) {\n\n    \techo &lt;&lt;&lt; EOB\n\n\t\t\t&lt;div class=\"info\">&lt;table cellspacing=0>&lt;tbody>\n\t\t\t&lt;tr>&lt;th colspan=\"2\">$server&lt;\/th>&lt;\/tr>\n\t\t\t&lt;tr>&lt;th>Slab Id&lt;\/th>&lt;th>Info&lt;\/th>&lt;\/tr>\nEOB;\n\n\t\t\tforeach($entries as $slabId => $slab) {\n\t\t\t    $dumpUrl = $PHP_SELF.'&amp;op=2&amp;server='.(array_search($server,$MEMCACHE_SERVERS)).'&amp;dumpslab='.$slabId;\n\t\t\t\techo\n\t\t\t\t\t\"&lt;tr class=tr-$m>\",\n\t\t\t\t\t\"&lt;td class=td-0>&lt;center>\",'&lt;a href=\"',$dumpUrl,'\">',$slabId,'&lt;\/a>',\"&lt;\/center>&lt;\/td>\",\n\t\t\t\t\t\"&lt;td class=td-last>&lt;b>Item count:&lt;\/b> \",$slab&#91;'number'],'&lt;br\/>&lt;b>Age:&lt;\/b>',duration($time-$slab&#91;'age']),'&lt;br\/> &lt;b>Evicted:&lt;\/b>',((isset($slab&#91;'evicted']) &amp;&amp; $slab&#91;'evicted']==1)? 'Yes':'No');\n\t\t\t\t\tif ((isset($_GET&#91;'dumpslab']) &amp;&amp; $_GET&#91;'dumpslab']==$slabId) &amp;&amp;  (isset($_GET&#91;'server']) &amp;&amp; $_GET&#91;'server']==array_search($server,$MEMCACHE_SERVERS))){\n\t\t\t\t\t    echo \"&lt;br\/>&lt;b>Items: item&lt;\/b>&lt;br\/>\";\n\t\t\t\t\t    $items = dumpCacheSlab($server,$slabId,$slab&#91;'number']);\n                        \/\/ maybe someone likes to do a pagination here :)\n\t\t\t\t\t    $i=1;\n                        foreach($items&#91;'ITEM'] as $itemKey=>$itemInfo){\n                            $itemInfo = trim($itemInfo,'&#91; ]');\n\n\n                            echo '&lt;a href=\"',$PHP_SELF,'&amp;op=4&amp;server=',(array_search($server,$MEMCACHE_SERVERS)),'&amp;key=',base64_encode($itemKey).'\">',$itemKey,'&lt;\/a>';\n                            if ($i++ % 10 == 0) {\n                                echo '&lt;br\/>';\n                            }\n                            elseif ($i!=$slab&#91;'number']+1){\n                                echo ',';\n                            }\n                        }\n\t\t\t\t\t}\n\n\t\t\t\t\techo \"&lt;\/td>&lt;\/tr>\";\n\t\t\t\t$m=1-$m;\n\t\t\t}\n\t\techo &lt;&lt;&lt;EOB\n\t\t\t&lt;\/tbody>&lt;\/table>\n\t\t\t&lt;\/div>&lt;hr\/>\nEOB;\n}\n\t\tbreak;\n\n    break;\n\n    case 4: \/\/item dump\n        if (!isset($_GET&#91;'key']) || !isset($_GET&#91;'server'])){\n            echo \"No key set!\";\n            break;\n        }\n        \/\/ I'm not doing anything to check the validity of the key string.\n        \/\/ probably an exploit can be written to delete all the files in key=base64_encode(\"\\n\\r delete all\").\n        \/\/ somebody has to do a fix to this.\n        $theKey = htmlentities(base64_decode($_GET&#91;'key']));\n\n        $theserver = $MEMCACHE_SERVERS&#91;(int)$_GET&#91;'server']];\n        list($h,$p) = explode(':',$theserver);\n        $r = sendMemcacheCommand($h,$p,'get '.$theKey);\n        echo &lt;&lt;&lt;EOB\n        &lt;div class=\"info\">&lt;table cellspacing=0>&lt;tbody>\n\t\t\t&lt;tr>&lt;th>Server&lt;th>Key&lt;\/th>&lt;th>Value&lt;\/th>&lt;th>Delete&lt;\/th>&lt;\/tr>\nEOB;\n        echo \"&lt;tr>&lt;td class=td-0>\",$theserver,\"&lt;\/td>&lt;td class=td-0>\",$theKey,\n             \" &lt;br\/>flag:\",$r&#91;'VALUE']&#91;$theKey]&#91;'stat']&#91;'flag'],\n             \" &lt;br\/>Size:\",bsize($r&#91;'VALUE']&#91;$theKey]&#91;'stat']&#91;'size']),\n             \"&lt;\/td>&lt;td>\",chunk_split($r&#91;'VALUE']&#91;$theKey]&#91;'value'],40),\"&lt;\/td>\",\n             '&lt;td>&lt;a href=\"',$PHP_SELF,'&amp;op=5&amp;server=',(int)$_GET&#91;'server'],'&amp;key=',base64_encode($theKey),\"\\\">Delete&lt;\/a>&lt;\/td>\",\"&lt;\/tr>\";\n        echo &lt;&lt;&lt;EOB\n\t\t\t&lt;\/tbody>&lt;\/table>\n\t\t\t&lt;\/div>&lt;hr\/>\nEOB;\n    break;\n    case 5: \/\/ item delete\n    \tif (!isset($_GET&#91;'key']) || !isset($_GET&#91;'server'])){\n\t\t\techo \"No key set!\";\n\t\t\tbreak;\n        }\n        $theKey = htmlentities(base64_decode($_GET&#91;'key']));\n\t\t$theserver = $MEMCACHE_SERVERS&#91;(int)$_GET&#91;'server']];\n\t\tlist($h,$p) = explode(':',$theserver);\n        $r = sendMemcacheCommand($h,$p,'delete '.$theKey);\n        echo 'Deleting '.$theKey.':'.$r;\n\tbreak;\n\n   case 6: \/\/ flush server\n        $theserver = $MEMCACHE_SERVERS&#91;(int)$_GET&#91;'server']];\n        $r = flushServer($theserver);\n        echo 'Flush  '.$theserver.\":\".$r;\n   break;\n}\necho getFooter();\n\n?><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u4ecb\u7ecd Memcached \u662f\u56fd\u5916\u793e\u533a\u7f51\u7ad9\u56e2\u961f\u5f00\u53d1\u7684 \u9ad8\u6027\u80fd\u7684\u5206\u5e03\u5f0f\u5185\u5b58\u7f13\u5b58\u670d\u52a1\u5668\u3002\u4e00\u822c\u7684\u4f7f\u7528\u76ee\u7684\u662f\u901a\u8fc7\u7f13\u5b58 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[20,36,35],"tags":[26,42],"class_list":["post-546","post","type-post","status-publish","format-aside","hentry","category-linux","category-36","category-35","tag-php","tag-web","post_format-post-format-aside"],"_links":{"self":[{"href":"https:\/\/bigvip.dpdns.org\/index.php?rest_route=\/wp\/v2\/posts\/546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bigvip.dpdns.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bigvip.dpdns.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bigvip.dpdns.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bigvip.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=546"}],"version-history":[{"count":3,"href":"https:\/\/bigvip.dpdns.org\/index.php?rest_route=\/wp\/v2\/posts\/546\/revisions"}],"predecessor-version":[{"id":552,"href":"https:\/\/bigvip.dpdns.org\/index.php?rest_route=\/wp\/v2\/posts\/546\/revisions\/552"}],"wp:attachment":[{"href":"https:\/\/bigvip.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bigvip.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bigvip.dpdns.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}