ibm-free-cloud's People
Forkers
ygseaibm-free-cloud's Issues
index.php
<script language="javascript" type="text/javascript">
var acd1;
acd1 = new Date();
acd1ok=acd1.getTime();
</script>
<?php
for($i=1;$i<=100000;$i++)
{
echo "<!--567890#########0#########0#########0#########0#########0#########0#########0#########012345-->";
}
?>
<script language="javascript" type="text/javascript">
var acd2;
acd2 = new Date();
acd2ok=acd2.getTime();
window.location = '?speed=' +(acd2ok-acd1ok)+'#w_networkspeed';
</script>
"; Echo "这里显示系统被禁用的函数\n"; print_r($arr); echo ""; exit(); } //MySQL检测 if ($_POST['act'] == 'MySQL检测') { $host = isset($_POST['host']) ? trim($_POST['host']) : ''; $port = isset($_POST['port']) ? (int) $_POST['port'] : ''; $login = isset($_POST['login']) ? trim($_POST['login']) : ''; $password = isset($_POST['password']) ? trim($_POST['password']) : ''; $host = preg_match('~[^a-z0-9\-\.]+~i', $host) ? '' : $host; $port = intval($port) ? intval($port) : ''; $login = preg_match('~[^a-z0-9\_\-]+~i', $login) ? '' : htmlspecialchars($login); $password = is_string($password) ? htmlspecialchars($password) : ''; } elseif ($_POST['act'] == '函数检测') { $funRe = "函数".$_POST['funName']."支持状况检测结果:".isfun1($_POST['funName']); } elseif ($_POST['act'] == '邮件检测') { $mailRe = "邮件发送检测结果:发送"; if($_SERVER['SERVER_PORT']==80){$mailContent = "http://".$_SERVER['SERVER_NAME'].($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);} else{$mailContent = "http://".$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);} $mailRe .= (false !== @mail($_POST["mailAdd"], $mailContent, "This is a test mail!")) ? "完成":"失败"; } //网络速度测试 if(isset($_POST['speed'])) { $speed=round(100/($_POST['speed']/1000),2); } elseif($_GET['speed']=="0") { $speed=6666.67; } elseif(isset($_GET['speed']) and $_GET['speed']>0) { $speed=round(100/($_GET['speed']/1000),2); //下载速度:$speed kb/s } else { $speed=" 未探测 "; } // 检测函数支持 function isfun($funName = '') { if (!$funName || trim($funName) == '' || preg_match('~[^a-z0-9\_]+~i', $funName, $tmp)) return '错误'; return (false !== function_exists($funName)) ? '√' : '×'; } function isfun1($funName = '') { if (!$funName || trim($funName) == '' || preg_match('~[^a-z0-9\_]+~i', $funName, $tmp)) return '错误'; return (false !== function_exists($funName)) ? '√' : '×'; } //整数运算能力测试 function test_int() { $timeStart = gettimeofday(); for($i = 0; $i < 3000000; $i++) { $t = 1+1; } $timeEnd = gettimeofday(); $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"]; $time = round($time, 3)."秒"; return $time; } //浮点运算能力测试 function test_float() { //得到圆周率值 $t = pi(); $timeStart = gettimeofday(); for($i = 0; $i < 3000000; $i++) { //开平方 sqrt($t); } $timeEnd = gettimeofday(); $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"]; $time = round($time, 3)."秒"; return $time; } //IO能力测试 function test_io() { $fp = @fopen(PHPSELF, "r"); $timeStart = gettimeofday(); for($i = 0; $i < 10000; $i++) { @fread($fp, 10240); @Rewind($fp); } $timeEnd = gettimeofday(); @fclose($fp); $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"]; $time = round($time, 3)."秒"; return($time); } function GetCoreInformation() {$data = file('/proc/stat');$cores = array();foreach( $data as $line ) {if( preg_match('/^cpu[0-9]/', $line) ){$info = explode(' ', $line);$cores[]=array('user'=>$info[1],'nice'=>$info[2],'sys' => $info[3],'idle'=>$info[4],'iowait'=>$info[5],'irq' => $info[6],'softirq' => $info[7]);}}return $cores;} function GetCpuPercentages($stat1, $stat2) {if(count($stat1)!==count($stat2)){return;}$cpus=array();for( $i = 0, $l = count($stat1); $i < $l; $i++) { $dif = array(); $dif['user'] = $stat2[$i]['user'] - $stat1[$i]['user'];$dif['nice'] = $stat2[$i]['nice'] - $stat1[$i]['nice']; $dif['sys'] = $stat2[$i]['sys'] - $stat1[$i]['sys'];$dif['idle'] = $stat2[$i]['idle'] - $stat1[$i]['idle'];$dif['iowait'] = $stat2[$i]['iowait'] - $stat1[$i]['iowait'];$dif['irq'] = $stat2[$i]['irq'] - $stat1[$i]['irq'];$dif['softirq'] = $stat2[$i]['softirq'] - $stat1[$i]['softirq'];$total = array_sum($dif);$cpu = array();foreach($dif as $x=>$y) $cpu[$x] = round($y / $total * 100, 2);$cpus['cpu' . $i] = $cpu;}return $cpus;} $stat1 = GetCoreInformation();sleep(1);$stat2 = GetCoreInformation();$data = GetCpuPercentages($stat1, $stat2); $cpu_show = $data['cpu0']['user']."%us, ".$data['cpu0']['sys']."%sy, ".$data['cpu0']['nice']."%ni, ".$data['cpu0']['idle']."%id, ".$data['cpu0']['iowait']."%wa, ".$data['cpu0']['irq']."%irq, ".$data['cpu0']['softirq']."%softirq"; function makeImageUrl($title, $data) {$api='http://api.yahei.net/tz/cpu_show.php?id=';$url.=$data['user'].',';$url.=$data['nice'].',';$url.=$data['sys'].',';$url.=$data['idle'].',';$url.=$data['iowait'];$url.='&chdl=User|Nice|Sys|Idle|Iowait&chdlp=b&chl=';$url.=$data['user'].'%25|';$url.=$data['nice'].'%25|';$url.=$data['sys'].'%25|';$url.=$data['idle'].'%25|';$url.=$data['iowait'].'%25';$url.='&chtt=Core+'.$title;return $api.base64_encode($url);} if($_GET['act'] == "cpu_percentage"){echo "图片加载慢,请耐心等待!
";foreach( $data as $k => $v ) {echo '';}echo "";exit();} // 根据不同系统取得CPU相关信息 switch(PHP_OS) { case "Linux": $sysReShow = (false !== ($sysInfo = sys_linux()))?"show":"none"; break; case "FreeBSD": $sysReShow = (false !== ($sysInfo = sys_freebsd()))?"show":"none"; break; /* case "WINNT": $sysReShow = (false !== ($sysInfo = sys_windows()))?"show":"none"; break; */ default: break; } //linux系统探测 function sys_linux() { // CPU if (false === ($str = @file("/proc/cpuinfo"))) return false; $str = implode("", $str); @preg_match_all("/model\s+name\s{0,}\:+\s{0,}([\w\s\)\(\@.-]+)([\r\n]+)/s", $str, $model); @preg_match_all("/cpu\s+MHz\s{0,}\:+\s{0,}([\d\.]+)[\r\n]+/", $str, $mhz); @preg_match_all("/cache\s+size\s{0,}\:+\s{0,}([\d\.]+\s{0,}[A-Z]+[\r\n]+)/", $str, $cache); @preg_match_all("/bogomips\s{0,}\:+\s{0,}([\d\.]+)[\r\n]+/", $str, $bogomips); if (false !== is_array($model[1])) { $res['cpu']['num'] = sizeof($model[1]); /* for($i = 0; $i < $res['cpu']['num']; $i++) { $res['cpu']['model'][] = $model[1][$i].' ('.$mhz[1][$i].')'; $res['cpu']['mhz'][] = $mhz[1][$i]; $res['cpu']['cache'][] = $cache[1][$i]; $res['cpu']['bogomips'][] = $bogomips[1][$i]; }*/ if($res['cpu']['num']==1) $x1 = ''; else $x1 = ' ×'.$res['cpu']['num']; $mhz[1][0] = ' | 频率:'.$mhz[1][0]; $cache[1][0] = ' | 二级缓存:'.$cache[1][0]; $bogomips[1][0] = ' | Bogomips:'.$bogomips[1][0]; $res['cpu']['model'][] = $model[1][0].$mhz[1][0].$cache[1][0].$bogomips[1][0].$x1; if (false !== is_array($res['cpu']['model'])) $res['cpu']['model'] = implode("
", $res['cpu']['model']); if (false !== is_array($res['cpu']['mhz'])) $res['cpu']['mhz'] = implode("
", $res['cpu']['mhz']); if (false !== is_array($res['cpu']['cache'])) $res['cpu']['cache'] = implode("
", $res['cpu']['cache']); if (false !== is_array($res['cpu']['bogomips'])) $res['cpu']['bogomips'] = implode("
", $res['cpu']['bogomips']); } // NETWORK // UPTIME if (false === ($str = @file("/proc/uptime"))) return false; $str = explode(" ", implode("", $str)); $str = trim($str[0]); $min = $str / 60; $hours = $min / 60; $days = floor($hours / 24); $hours = floor($hours - ($days * 24)); $min = floor($min - ($days * 60 * 24) - ($hours * 60)); if ($days !== 0) $res['uptime'] = $days."天"; if ($hours !== 0) $res['uptime'] .= $hours."小时"; $res['uptime'] .= $min."分钟"; // MEMORY if (false === ($str = @file("/proc/meminfo"))) return false; $str = implode("", $str); preg_match_all("/MemTotal\s{0,}\:+\s{0,}([\d\.]+).+?MemFree\s{0,}\:+\s{0,}([\d\.]+).+?Cached\s{0,}\:+\s{0,}([\d\.]+).+?SwapTotal\s{0,}\:+\s{0,}([\d\.]+).+?SwapFree\s{0,}\:+\s{0,}([\d\.]+)/s", $str, $buf); preg_match_all("/Buffers\s{0,}\:+\s{0,}([\d\.]+)/s", $str, $buffers); $res['memTotal'] = round($buf[1][0]/1024, 2); $res['memFree'] = round($buf[2][0]/1024, 2); $res['memBuffers'] = round($buffers[1][0]/1024, 2); $res['memCached'] = round($buf[3][0]/1024, 2); $res['memUsed'] = $res['memTotal']-$res['memFree']; $res['memPercent'] = (floatval($res['memTotal'])!=0)?round($res['memUsed']/$res['memTotal']*100,2):0; $res['memRealUsed'] = $res['memTotal'] - $res['memFree'] - $res['memCached'] - $res['memBuffers']; //真实内存使用 $res['memRealFree'] = $res['memTotal'] - $res['memRealUsed']; //真实空闲 $res['memRealPercent'] = (floatval($res['memTotal'])!=0)?round($res['memRealUsed']/$res['memTotal']*100,2):0; //真实内存使用率 $res['memCachedPercent'] = (floatval($res['memCached'])!=0)?round($res['memCached']/$res['memTotal']*100,2):0; //Cached内存使用率 $res['swapTotal'] = round($buf[4][0]/1024, 2); $res['swapFree'] = round($buf[5][0]/1024, 2); $res['swapUsed'] = round($res['swapTotal']-$res['swapFree'], 2); $res['swapPercent'] = (floatval($res['swapTotal'])!=0)?round($res['swapUsed']/$res['swapTotal']*100,2):0; // LOAD AVG if (false === ($str = @file("/proc/loadavg"))) return false; $str = explode(" ", implode("", $str)); $str = array_chunk($str, 4); $res['loadAvg'] = implode(" ", $str[0]); return $res; } //FreeBSD系统探测 function sys_freebsd() { //CPU if (false === ($res['cpu']['num'] = get_key("hw.ncpu"))) return false; $res['cpu']['model'] = get_key("hw.model"); //LOAD AVG if (false === ($res['loadAvg'] = get_key("vm.loadavg"))) return false; //UPTIME if (false === ($buf = get_key("kern.boottime"))) return false; $buf = explode(' ', $buf); $sys_ticks = time() - intval($buf[3]); $min = $sys_ticks / 60; $hours = $min / 60; $days = floor($hours / 24); $hours = floor($hours - ($days * 24)); $min = floor($min - ($days * 60 * 24) - ($hours * 60)); if ($days !== 0) $res['uptime'] = $days."天"; if ($hours !== 0) $res['uptime'] .= $hours."小时"; $res['uptime'] .= $min."分钟"; //MEMORY if (false === ($buf = get_key("hw.physmem"))) return false; $res['memTotal'] = round($buf/1024/1024, 2); $str = get_key("vm.vmtotal"); preg_match_all("/\nVirtual Memory[\:\s]*\(Total[\:\s]*([\d]+)K[\,\s]*Active[\:\s]*([\d]+)K\)\n/i", $str, $buff, PREG_SET_ORDER); preg_match_all("/\nReal Memory[\:\s]*\(Total[\:\s]*([\d]+)K[\,\s]*Active[\:\s]*([\d]+)K\)\n/i", $str, $buf, PREG_SET_ORDER); $res['memRealUsed'] = round($buf[0][2]/1024, 2); $res['memCached'] = round($buff[0][2]/1024, 2); $res['memUsed'] = round($buf[0][1]/1024, 2) + $res['memCached']; $res['memFree'] = $res['memTotal'] - $res['memUsed']; $res['memPercent'] = (floatval($res['memTotal'])!=0)?round($res['memUsed']/$res['memTotal']*100,2):0; $res['memRealPercent'] = (floatval($res['memTotal'])!=0)?round($res['memRealUsed']/$res['memTotal']*100,2):0; return $res; } //取得参数值 FreeBSD function get_key($keyName) { return do_command('sysctl', "-n $keyName"); } //确定执行文件位置 FreeBSD function find_command($commandName) { $path = array('/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin'); foreach($path as $p) { if (@is_executable("$p/$commandName")) return "$p/$commandName"; } return false; } //执行系统命令 FreeBSD function do_command($commandName, $args) { $buffer = ""; if (false === ($command = find_command($commandName))) return false; if ($fp = @Popen("$command $args", 'r')) { while (!@Feof($fp)) { $buffer .= @fgets($fp, 4096); } return trim($buffer); } return false; } //windows系统探测 function sys_windows() { if (PHP_VERSION >= 5) { $objLocator = new COM("WbemScripting.SWbemLocator"); $wmi = $objLocator->ConnectServer(); $prop = $wmi->get("Win32_PnPEntity"); } else { return false; } //CPU $cpuinfo = GetWMI($wmi,"Win32_Processor", array("Name","L2CacheSize","NumberOfCores")); $res['cpu']['num'] = $cpuinfo[0]['NumberOfCores']; if (null == $res['cpu']['num']) { $res['cpu']['num'] = 1; }/* for ($i=0;$i<$res['cpu']['num'];$i++) { $res['cpu']['model'] .= $cpuinfo[0]['Name']."
"; $res['cpu']['cache'] .= $cpuinfo[0]['L2CacheSize']."
"; }*/ $cpuinfo[0]['L2CacheSize'] = ' ('.$cpuinfo[0]['L2CacheSize'].')'; if($res['cpu']['num']==1) $x1 = ''; else $x1 = ' ×'.$res['cpu']['num']; $res['cpu']['model'] = $cpuinfo[0]['Name'].$cpuinfo[0]['L2CacheSize'].$x1; // SYSINFO $sysinfo = GetWMI($wmi,"Win32_OperatingSystem", array('LastBootUpTime','TotalVisibleMemorySize','FreePhysicalMemory','Caption','CSDVersion','SerialNumber','InstallDate')); $sysinfo[0]['Caption']=iconv('GBK', 'UTF-8',$sysinfo[0]['Caption']); $sysinfo[0]['CSDVersion']=iconv('GBK', 'UTF-8',$sysinfo[0]['CSDVersion']); $res['win_n'] = $sysinfo[0]['Caption']." ".$sysinfo[0]['CSDVersion']." 序列号:{$sysinfo[0]['SerialNumber']} 于".date('Y年m月d日H:i:s',strtotime(substr($sysinfo[0]['InstallDate'],0,14)))."安装"; //UPTIME $res['uptime'] = $sysinfo[0]['LastBootUpTime']; $sys_ticks = 3600*8 + time() - strtotime(substr($res['uptime'],0,14)); $min = $sys_ticks / 60; $hours = $min / 60; $days = floor($hours / 24); $hours = floor($hours - ($days * 24)); $min = floor($min - ($days * 60 * 24) - ($hours * 60)); if ($days !== 0) $res['uptime'] = $days."天"; if ($hours !== 0) $res['uptime'] .= $hours."小时"; $res['uptime'] .= $min."分钟"; //MEMORY $res['memTotal'] = round($sysinfo[0]['TotalVisibleMemorySize']/1024,2); $res['memFree'] = round($sysinfo[0]['FreePhysicalMemory']/1024,2); $res['memUsed'] = $res['memTotal']-$res['memFree']; //上面两行已经除以1024,这行不用再除了 $res['memPercent'] = round($res['memUsed'] / $res['memTotal']*100,2); $swapinfo = GetWMI($wmi,"Win32_PageFileUsage", array('AllocatedBaseSize','CurrentUsage')); // LoadPercentage $loadinfo = GetWMI($wmi,"Win32_Processor", array("LoadPercentage")); $res['loadAvg'] = $loadinfo[0]['LoadPercentage']; return $res; } function GetWMI($wmi,$strClass, $strValue = array()) { $arrData = array(); $objWEBM = $wmi->Get($strClass); $arrProp = $objWEBM->Properties_; $arrWEBMCol = $objWEBM->Instances_(); foreach($arrWEBMCol as $objItem) { @reset($arrProp); $arrInstance = array(); foreach($arrProp as $propItem) { eval("\$value = \$objItem->" . $propItem->Name . ";"); if (empty($strValue)) { $arrInstance[$propItem->Name] = trim($value); } else { if (in_array($propItem->Name, $strValue)) { $arrInstance[$propItem->Name] = trim($value); } } } $arrData[] = $arrInstance; } return $arrData; } //比例条 function bar($percent) { ?>
<div class="bar"><div class="barli" style="width:<?php echo $percent?>%"> </div></div>
<table>
<tr>
<th class="w_logo">红杏出墙</th>
</tr>
</table>
<td width="13%" >服务器当前时间</td>
<td width="37%" ><span id="stime"><?php echo $stime;?></span></td>
<td width="13%" >服务器已运行时间</td>
<td width="37%" colspan="3"><span id="uptime"><?php echo $uptime;?></span></td>
<td width="13%">CPU型号 [<?php echo $sysInfo['cpu']['num'];?>核]</td>
<td width="87%" colspan="5"><?php echo $sysInfo['cpu']['model'];?></td>
<td>内存使用状况</td>
<td colspan="5">
物理内存:共
<font color='#CC0000'><?php echo $memTotal;?> </font>
, 已用
<font color='#CC0000'><span id="UsedMemory"><?php echo $mu;?></span></font>
, 空闲
<font color='#CC0000'><span id="FreeMemory"><?php echo $mf;?></span></font>
, 使用率
<span id="memPercent"><?php echo $memPercent;?></span>
<div class="bar"><div id="barmemPercent" class="barli_green" style="width:<?php echo $memPercent?>%" > </div> </div>
Cache化内存为 <span id="CachedMemory"><?php echo $mc;?></span>
, 使用率
<span id="memCachedPercent"><?php echo $memCachedPercent;?></span>
% | Buffers缓冲为 <span id="Buffers"><?php echo $mb;?></span>
<div class="bar"><div id="barmemCachedPercent" class="barli_blue" style="width:<?php echo $memCachedPercent?>%" > </div></div>
真实内存使用
<span id="memRealUsed"><?php echo $memRealUsed;?></span>
, 真实内存空闲
<span id="memRealFree"><?php echo $memRealFree;?></span>
, 使用率
<span id="memRealPercent"><?php echo $memRealPercent;?></span>
%
<div class="bar_1"><div id="barmemRealPercent" class="barli_1" style="width:<?php echo $memRealPercent?>%" > </div></div>
SWAP区:共
<?php echo $st;?>
, 已使用
<span id="swapUsed"><?php echo $su;?></span>
, 空闲
<span id="swapFree"><?php echo $sf;?></span>
, 使用率
<span id="swapPercent"><?php echo $swapPercent;?></span>
%
<div class="bar"><div id="barswapPercent" class="barli_red" style="width:<?php echo $swapPercent?>%" > </div> </div>
</td>
</tr>
<tr>
<td>系统平均负载</td>
<td colspan="5" class="w_number"><span id="loadAvg"><?php echo $load;?></span></td>
</tr>
服务器实时数据 | |||||
---|---|---|---|---|---|
硬盘使用状况 |
总空间 G,
已用 G,
空闲 G,
使用率 %
|
||||
<tr><th colspan="5">网络使用状况</th></tr>
<tr>
<td width="13%"><?php echo $info[1][0]?> : </td>
<td width="29%">入网: <font color='#CC0000'><span id="NetInput<?php echo $i?>"><?php echo $NetInput[$i]?></span></font></td>
<td width="14%">实时: <font color='#CC0000'><span id="NetInputSpeed<?php echo $i?>">0B/s</span></font></td>
<td width="29%">出网: <font color='#CC0000'><span id="NetOut<?php echo $i?>"><?php echo $NetOut[$i]?></span></font></td>
<td width="14%">实时: <font color='#CC0000'><span id="NetOutSpeed<?php echo $i?>">0B/s</span></font></td>
</tr>
<table>
<tr>
<td class="w_foot"><A HREF="https://www.dujin.org/" target="_blank"><?php echo $title.$version;?></A></td>
<td class="w_foot"><?php $run_time = sprintf('%0.4f', microtime_float() - $time_start);?>Processed in <?php echo $run_time?> seconds. <?php echo memory_usage();?> memory usage.</td>
<td class="w_foot"><a href="#w_top">返回顶部</a></td>
</tr>
</table>
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.