php探针

<?php
  /* Functions in this file */
  /**************************/

  // bar($percent)
  // find_command($commandName)
  // getcon($varName)
  // get_key($keyName)
  // isfun($funName)
  // sys_freebsd()
  // sys_linux()
  // test_float()
  // test_int()
  // test_io()
    // do_command($commandName, $args)
    // sec_title($secName, $secId)

  error_reporting(E_ERROR | E_WARNING | E_PARSE);
 
  $valInt = (false == empty($_POST['pInt']))?$_POST['pInt']:
  "未测试";
  $valFloat = (false == empty($_POST['pFloat']))?$_POST['pFloat']:
  "未测试";
  $valIo = (false == empty($_POST['pIo']))?$_POST['pIo']:
  "未测试";
  $mysqlReShow = "none";
  $mailReShow = "none";
  $funReShow = "none";
  $opReShow = "none";
  $sysReShow = "none";
 
  define("YES", "<span class='resYes'>YES</span>");
  define("NO", "<span class='resNo'>NO</span>");
  define("ICON", "<span class='icon'>2</span> ");
  $phpSelf = $_SERVER[PHP_SELF] ? $_SERVER[PHP_SELF] : $_SERVER[SCRIPT_NAME];
  define("PHPSELF", preg_replace("/(.{0,}?//+)/", "", $phpSelf));
 
  if ($HTTP_GET_VARS['act'] == "phpinfo")
    {
    phpinfo();
    exit();
  }
  elseif($_POST['act'] == "TEST_1")
  {
    $valInt = test_int();
  }
  elseif($_POST['act'] == "TEST_2")
  {
    $valFloat = test_float();
  }
  elseif($_POST['act'] == "TEST_3")
  {
    $valIo = test_io();
  }
  elseif($_POST['act'] == "CONNECT")
  {
    $mysqlReShow = "show";
    $mysqlRe = "MYSQL连接测试结果:";
    $mysqlRe .= (false !== @mysql_connect($_POST['mysqlHost'], $_POST['mysqlUser'], $_POST['mysqlPassword']))?"MYSQL服务器连接正常, ":
    "MYSQL服务器连接失败, ";
    $mysqlRe .= "数据库 <b>".$_POST['mysqlDb']."</b> ";
    $mysqlRe .= (false != @mysql_select_db($_POST['mysqlDb']))?"连接正常":
    "连接失败";
  }
  elseif($_POST['act'] == "SENDMAIL")
  {
    $mailReShow = "show";
    $mailRe = "MAIL邮件发送测试结果:发送";
    $mailRe .= (false !== @mail($_POST["mailReceiver"], "MAIL SERVER TEST", "This email is sent by iProber./r/n/r/ndEpoch Studio/r/nhttp://depoch.net"))?"完成": "失败";
  }
  elseif($_POST['act'] == "FUNCTION_CHECK")
  {
    $funReShow = "show";
    $funRe = "函数 <b>".$_POST['funName']."</b> 支持状况检测结果:".isfun($_POST['funName']);
  }
  elseif($_POST['act'] == "CONFIGURATION_CHECK")
  {
    $opReShow = "show";
    $opRe = "配置参数 <b>".$_POST['opName']."</b> 检测结果:".getcon($_POST['opName']);
  }
 
 
  // 系统参数
 
 
  switch (PHP_OS)
  {
    case "Linux":
    $sysReShow = (false !== ($sysInfo = sys_linux()))?"show":
    "none";
    break;
    case "FreeBSD":
    $sysReShow = (false !== ($sysInfo = sys_freebsd()))?"show":
    "none";
    break;
    default:
    break;
  }
 
  /*========================================================================*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/url]">
<html xmlns="[url]http://www.w3.org/1999/xhtml[/url]">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" >
<title>iProber v0.021 - PHP探针</title>
<meta name="author" content="凡人论坛" >
<meta name="description" content="凡人论坛 php探针" >
<meta name="keywords" content="凡人论坛,网上商城,iProber,探针,php,mysql,工作室," >
<style type="text/css">
<!--
body { background-color:#595959; margin:0px; text-align:center; }
div,input,li,a { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #666666; }
input { background-color: #f3f3f3; border: 1px solid #999999; }
ul,form { margin:0px; padding:0px; }
li { list-style-type:none; }
a:link,a:visited,a:active { color:#666666; text-decoration:none; }
a:hover { color: #33cc00; }
a.arrow:link,a.arrow:visited,a.arrow:active { font-family:Webdings, sans-serif; font-size:10px; }
a.arrow:hover { color:#99ff00; }
a.static:link,a.static:visited,a.static:active,a.static:hover { color:#33cc00;text-decoration:none; }
.button { font-size:10px; }
.sectIcon { color:#FF7200; font-family:Webdings, sans-serif; font-size: 12px; margin-right:5px; }
.resYes { font-size: 9px; font-weight: bold; color: #33CC00; }
.resNo { font-size: 9px; font-weight: bold; color: #FF0000; }
hr.bar { color: #FFCC00; height: 8px; }

#container { width:700px; background-color:#dddddd; }
#top1 { border-bottom:1px solid #666666; height:10px; line-height:10px; width:100%; }
#top2 { border-top:1px solid #ffffff; height:80px; line-height:80px; background-color:#538296; border-bottom: 1px solid #376677;}
    #top2 a:link,#top2 a:visited,#top2 a:active,#top2 a:hover { color: #9BC6FF;}
    #top2 li.left { width:40%; float:left; color:#ffffff; }
    .logoI { font-family: Webdings, sans-serif; font-size: 50px; color: #FFCC00; }
    .logoProber { font-size: 35px; color: #99ff00; font-weight:bolder; }
    #top2 li.right { width:55%; float:left; height:25px; line-height:25px; text-align:right; padding:15px 0px; }
#top3 { border-top:1px solid #FFFFFF; border-bottom:1px solid #9E9E9E; background-color:#c6c6c6; height:25px; line-height:25px; }
    #top3 li { width:16.6%; float:left; }
#mainArea { border-top:1px solid #ffffff; border-bottom:1px solid #9e9e9e; text-align: left; padding:0px 15px; }
    #mainArea div.titleContainer { margin:15px 0px; border:none; }
    #mainArea div.title { border-top:1px solid #B1B1B1; border-left: 1px solid #B1B1B1; border-right: 1px solid #FFFFFF; border-bottom:1px solid #FFFFFF; float:left; width:98%; }
    #mainArea div.arrow { float:left; height:12px; line-height:12px; width:1%; border:none; }
    #mainArea li.title { border-bottom:1px solid #B1B1B1; border-right:1px solid #B1B1B1; border-left:1px solid #FFFFFF; border-top:1px solid #FFFFFF; height:22px; line-height:22px; padding:0px 5px; font-weight:bolder; }
    #mainArea div { border-bottom:1px dashed #efefef; height:24px; line-height:24px; }
    #mainArea li.c1 { width:35%; float:left; }
    #mainArea li.c2 { width:10%; float:left; }
    #mainArea li.c3 { width:50%; float:left; }
    #mainArea li.c4 { width:60%; float:left; }
    #mainArea li.c5 {width:16%; float:left; }
    #mainArea li.c6 { width:33%; float:left; }
    #mainArea div.bar { width:410px; text-align:left; border:none; }
    #mainArea div.bar li { float:left; }
#footerArrow { text-align:right; border:none; }
#footer { border-top:1px solid #ffffff; line-height:15px; height:15px; padding:5px 15px; }
    #footer #left { float:left; }
    #footer #left li { font-size:8px; color:#ffffff; font-weight:bold; }
    #footer div.c1 { margin-right:8px; background-color:#B6B9AC; height:12px; line-height:12px; float:left; border:1px solid #B6B9AC; }
    #footer li.left { width:36px; text-align:center; background-color:#FFA061; border:1px solid #ffffff; float:left; }
    #footer li.right { width:44px; text-align:center; border-top:1px solid #ffffff; border-right:1px solid #ffffff; border-bottom:1px solid #ffffff; float:left; }
    #footer #left a:link,#footer #left a:visited,#footer #left a:active,#footer #left a:hover { font-size: 8px; color:#ffffff; font-weight:bold; }
    #footer #right { float:right; font-size:10px; }
    #footer #right a:link,#footer #right a:visited,#footer #right a:active,#footer #right a:hover { font-size:10px; color:#CC3300; font-weight:bolder; }
-->
</style>
</head>

<body>
<div id="container">
<form method="post" action="<?php echo PHPSELF."#bottom"?>" id="main_form">
<input type="hidden" name="pInt" value="<?php echo $valInt?>" >
<input type="hidden" name="pFloat" value="<?php echo $valFloat?>" >
<input type="hidden" name="pIo" value="<?php echo $valIo?>" >
<div id="top1"><a name="top" ></div>
<div id="top2">
    <ul>
    <li class="left">
        <span class="logoI">i</span>
        <span class="logoProber">Prober</span>v0.021
    </li>
    <li class="right">
        <a href="http://www.sp521.net/" target="_blank">点击下载 iProber 探针, 或查看最新版本 ■</a><br >
        <a href="http://www.sp521.net/bbs/sendemail.php?username=星雨之恋">报告BUGS, 或反馈意见给 凡人论坛 ■</a>
    </li>
    </ul>
</div>
<div id="top3">
    <ul>
    <li><a href="#sec1">[服务器特征]</a></li>
    <li><a href="#sec2">[PHP基本特征]</a></li>
    <li><a href="#sec3">[组件支持状况]</a></li>
    <li><a href="#sec4">[服务器性能检测]</a></li>
    <li><a href="#sec5">[自定义检测]</a></li>
    <li><a href="<?php echo PHPSELF?>">[刷新]</a>   <a href="#bottom" class="arrow">66</a></li>
    </ul>
</div>
<div id="mainArea">
<!-- =============================================================
服务器特性
============================================================== -->
<?sec_title("服务器特征","sec1");?>
    <?if("show"==$sysReShow){?>
    <div><ul>
    <li class="c1">服务器处理器 CPU</li>
    <li class="c4">CPU个数:<?php echo $sysInfo['cpu']['num']?><br ><?php echo $sysInfo['cpu']['detail']?></li>
    </ul></div><?}?>
    <div><ul>
    <li class="c1">服务器时间</li>
    <li class="c4"> <?php echo date("Y年n月j日 H:i:s")?> 北京时间:<?php echo gmdate("Y年n月j日 H:i:s",time()+8*3600)?></li>
    </ul></div>
    <?if("show"==$sysReShow){?>
    <div><ul>
    <li class="c1">服务器运行时间</li>
    <li class="c4"> <?php echo $sysInfo['uptime']?></li>
    </ul></div><?}?>
    <div><ul>
    <li class="c1">服务器域名/IP地址</li>
    <li class="c4"> <?php echo $_SERVER['SERVER_NAME']?> ( <?php echo @gethostbyname($_SERVER['SERVER_NAME'])?> )</li>
    </ul></div>
    <div><ul>
    <li class="c1">服务器操作系统<?$os = explode(" ", php_uname());?></li>
    <li class="c4"> <?php echo $os[0];?> 内核版本:<?php echo $os[2]?></li>
    </ul></div>
    <div><ul>
    <li class="c1">主机名称</li>
    <li class="c4"> <?php echo $os[1];?></li>
    </ul></div>
    <div><ul>
    <li class="c1">服务器解译引擎</li>
    <li class="c4"> <?php echo $_SERVER['SERVER_SOFTWARE']?></li>
    </ul></div>
    <div><ul>
    <li class="c1">Web服务端口</li>
    <li class="c4"> <?php echo $_SERVER['SERVER_PORT']?></li>
    </ul></div>
    <div><ul>
    <li class="c1">服务器管理员</li>
    <li class="c4"> <a href="mailto:<?php echo $_SERVER['SERVER_ADMIN']?>"><?php echo $_SERVER['SERVER_ADMIN']?></a></li>
    </ul></div>
    <div><ul>
    <li class="c1">本文件路径</li>
    <li class="c4"> <?php echo $_SERVER['PATH_TRANSLATED']?></li>
    </ul></div>
    <div><ul>
    <li class="c1">目前还有空余空间 diskfreespace</li>
    <li class="c4"> <?php echo round((@disk_free_space(".")/(1024*1024)),2)?>M</li>
    </ul></div>
    <?if("show"==$sysReShow){?>
    <div><ul>
    <li class="c1">内存使用状况</li>
    <li class="c4">
    物理内存:共<?php echo $sysInfo['memTotal']?>M, 已使用<?php echo $sysInfo['memUsed']?>M, 空闲<?php echo $sysInfo['memFree']?>M
    <?php echo bar($sysInfo['memPercent'])?>
    SWAP区:共<?php echo $sysInfo['swapTotal']?>M, 已使用<?php echo $sysInfo['swapUsed']?>M, 空闲<?php echo $sysInfo['swapFree']?>M
    <?php echo bar($sysInfo['swapPercent'])?>
    </li>
    </ul></div>
    <div><ul>
    <li class="c1">系统平均负载</li>
    <li class="c4"> <?php echo $sysInfo['loadAvg']?></li>
    </ul></div><?}?>

<!-- =============================================================
PHP基本特性
============================================================== -->
<?sec_title("PHP基本特征","sec2");?>
    <div><ul>
    <li class="c3">PHP运行方式</li>
    <li><?php echo strtoupper(php_sapi_name())?></li>
    </ul></div>
    <div><ul>
    <li class="c3">PHP版本</li>
    <li><?php echo PHP_VERSION?></li>
    </ul></div>
    <div><ul>
    <li class="c3">运行于安全模式</li>
    <li><?php echo getcon("safe_mode")?></li>
    </ul></div>
    <div><ul>
    <li class="c3">允许使用URL打开文件 allow_url_fopen</li>
    <li><?php echo getcon("allow_url_fopen")?></li>
    </ul></div>
    <div><ul>
    <li class="c3">允许动态加载链接库 enable_dl</li>
    <li><?php echo getcon("enable_dl")?></li>
    </ul></div>
    <div><ul>
    <li class="c3">显示错误信息 display_errors</li>
    <li><?php echo getcon("display_errors")?></li>
    </ul></div>
    <div><ul>
    <li class="c3">自动定义全局变量 register_globals</li>
    <li><?php echo getcon("register_global")?></li>
    </ul></div>
    <div><ul>
    <li class="c3">程序最多允许使用内存量 memory_limit</li>
    <li><?php echo getcon("memory_limit")?></li>
    </ul></div>
    <div><ul>
    <li class="c3">POST最大字节数 post_max_size</li>
    <li><?php echo getcon("post_max_size")?></li>
    </ul></div>
    <div><ul>
    <li class="c3">允许最大上传文件 upload_max_filesize</li>
    <li><?php echo getcon("upload_max_filesize")?></li>
    </ul></div>
    <div><ul>
    <li class="c3">程序最长运行时间 max_execution_time</li>
    <li><?php echo getcon("max_execution_time")?>秒</li>
    </ul></div>
    <div><ul>
    <li class="c3">magic_quotes_gpc</li>
    <li><?php echo (1===get_magic_quotes_gpc())?YES:NO?></li>
    </ul></div>
    <div><ul>
    <li class="c3">magic_quotes_runtime</li>
    <li><?php echo (1===get_magic_quotes_runtime())?YES:NO?></li>
    </ul></div>
    <div><ul>
    <li class="c3">被禁用的函数 disable_functions</li>
    <li class="c3"><?php echo (""==($disFuns=get_cfg_var("disable_functions")))?"无 ":str_replace(",","<br >",$disFuns)?></li>
    </ul></div>
    <div><ul>
    <li class="c3">PHP信息 PHPINFO</li>
    <li><?php echo (false!==eregi("phpinfo",$disFuns))?NO:"<a href='$phpSelf?act=phpinfo' target='_blank' class='static'>PHPINFO</a>"?></li>
    </ul></div>

<!-- =============================================================
PHP组件支持
============================================================== -->
<?sec_title("组件支持状况","sec3");?>
    <div><ul>
    <li class="c1">拼写检查 ASpell Library</li>
    <li class="c2"><?php echo isfun("aspell_check_raw")?></li>
    <li class="c1">高精度数学运算 BCMath</li>
    <li class="c2"><?php echo isfun("bcadd")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">历法运算 Calendar</li>
    <li class="c2"><?php echo isfun("cal_days_in_month")?></li>
    <li class="c1">DBA数据库</li>
    <li class="c2"><?php echo isfun("dba_close")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">dBase数据库</li>
    <li class="c2"><?php echo isfun("dbase_close")?></li>
    <li class="c1">DBM数据库</li>
    <li class="c2"><?php echo isfun("dbmclose")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">FDF表单资料格式 Forms Data Format</li>
    <li class="c2"><?php echo isfun("fdf_get_ap")?></li>
    <li class="c1">FilePro数据库</li>
    <li class="c2"><?php echo isfun("filepro_fieldcount")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">Hyperwave数据库</li>
    <li class="c2"><?php echo isfun("hw_close")?></li>
    <li class="c1">图形处理 GD Library</li>
    <li class="c2"><?php echo isfun("gd_info")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">IMAP电子邮件系统</li>
    <li class="c2"><?php echo isfun("imap_close")?></li>
    <li class="c1">Informix数据库</li>
    <li class="c2"><?php echo isfun("ifx_close")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">LDAP目录协议</li>
    <li class="c2"><?php echo isfun("ldap_close")?></li>
    <li class="c1">MCrypt加密处理</li>
    <li class="c2"><?php echo isfun("mcrypt_cbc")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">哈稀计算 MHash</li>
    <li class="c2"><?php echo isfun("mhash_count")?></li>
    <li class="c1">mSQL数据库</li>
    <li class="c2"><?php echo isfun("msql_close")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">SQL Server数据库</li>
    <li class="c2"><?php echo isfun("mssql_close")?></li>
    <li class="c1">MySQL数据库</li>
    <li class="c2"><?php echo isfun("mysql_close")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">SyBase数据库</li>
    <li class="c2"><?php echo isfun("sybase_close")?></li>
    <li class="c1">Yellow Page系统</li>
    <li class="c2"><?php echo isfun("yp_match")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">Oracle数据库</li>
    <li class="c2"><?php echo isfun("ora_close")?></li>
    <li class="c1">Oracle 8 数据库</li>
    <li class="c2"><?php echo isfun("OCILogOff")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">PREL相容语法 PCRE</li>
    <li class="c2"><?php echo isfun("preg_match")?></li>
    <li class="c1">PDF文档支持</li>
    <li class="c2"><?php echo isfun("pdf_close")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">Postgre SQL数据库</li>
    <li class="c2"><?php echo isfun("pg_close")?></li>
    <li class="c1">SNMP网络管理协议</li>
    <li class="c2"><?php echo isfun("snmpget")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">VMailMgr邮件处理</li>
    <li class="c2"><?php echo isfun("vm_adduser")?></li>
    <li class="c1">WDDX支持</li>
    <li class="c2"><?php echo isfun("wddx_add_vars")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">压缩文件支持(Zlib)</li>
    <li class="c2"><?php echo isfun("gzclose")?></li>
    <li class="c1">XML解析</li>
    <li class="c2"><?php echo isfun("xml_set_object")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">FTP</li>
    <li class="c2"><?php echo isfun("ftp_login")?></li>
    <li class="c1">ODBC数据库连接</li>
    <li class="c2"><?php echo isfun("odbc_close")?></li>
    </ul></div>
    <div><ul>
    <li class="c1">Session支持</li>
    <li class="c2"><?php echo isfun("session_start")?></li>
    <li class="c1">Socket支持</li>
    <li class="c2"><?php echo isfun("fsockopen")?></li>
    </ul></div>

<!-- =============================================================
服务器性能检测
============================================================== -->
<?sec_title("服务器性能检测","sec4");?>
    <div><b>整数运算能力测试(1+1运算300万次)</b></div>
    <div><ul>
    <li class="c4">Tahiti 的电脑(P4 1.7G 256M WinXP)</li>
    <li>1.421秒</li>
    </ul></div>
    <div><ul>
    <li class="c4">PIPNI免费空间(2004/06/28 02:08)</li>
    <li>2.545秒</li>
    </ul></div>
    <div><ul>
    <li class="c4">神话科技风CGI型(2004/06/28 02:03)</li>
    <li>0.797秒</li>
    </ul></div>
    <div><ul>
    <li class="c4">您正在使用的这台服务器 <input type="submit" value="TEST_1" class="button" name="act" ></li>
    <li><?php echo $valInt?></li>
    </ul></div>

    <div><b>浮点运算能力测试(开平方300万次)</b></div>
    <div><ul>
    <li class="c4">Tahiti 的电脑(P4 1.7G 256M WinXP)</li>
    <li>1.358秒</li>
    </ul></div>
    <div><ul>
    <li class="c4">PIPNI免费空间(2004/06/28 02:08)</li>
    <li>2.648秒</li>
    </ul></div>
    <div><ul>
    <li class="c4">神话科技风CGI型(2004/06/28 02:03)</li>
    <li>0.729秒</li>
    </ul></div>
    <div><ul>
    <li class="c4">您正在使用的这台服务器 <input type="submit" value="TEST_2" class="button" name="act" ></li>
    <li><?php echo $valFloat?></li>
    </ul></div>

    <div><b>数据I/O能力测试(读取10K文件10000次)</b></div>
    <div><ul>
    <li class="c4">Tahiti 的电脑(P4 1.7G 256M WinXP)</li>
    <li>0.177秒</li>
    </ul></div>
    <div><ul>
    <li class="c4">PIPNI免费空间(2004/06/28 02:08)</li>
    <li>0.171秒</li>
    </ul></div>
    <div><ul>
    <li class="c4">神话科技风CGI型(2004/06/28 02:03)</li>
    <li>0.156秒</li>
    </ul></div>
    <div><ul>
    <li class="c4">您正在使用的这台服务器 <input type="submit" value="TEST_3" class="button" name="act" ></li>
    <li><?php echo $valIo?></li>
    </ul></div>

<!-- =============================================================
自定义检测
============================================================== -->
<?php
  $isMysql = (false !== function_exists("mysql_query"))?"":" disabled";
  $isMail = (false !== function_exists("mail"))?"":" disabled";
    sec_title("自定义检测","sec5");
?>
    <div><b>MYSQL连接测试</b></div>
    <div><ul>
    <li class="c5">MYSQL服务器</li>
    <li class="c6"><input type="text" name="mysqlHost" value="localhost" <?php echo $isMysql ?>></li>
    <li class="c5">MYSQL用户名</li>
    <li class="c6"><input type="text" name="mysqlUser" <?php echo $isMysql?> ></li>
    </ul></div>
    <div><ul>
    <li class="c5">MYSQL用户密码</li>
    <li class="c6"><input type="text" name="mysqlPassword" <?php echo $isMysql?> ></li>
    <li class="c5">MYSQL数据库名称</li>
    <li class="c6"><input type="text" name="mysqlDb" > <input type="submit" class="button" value="CONNECT" <?php echo $isMysql?> name="act" ></li>
    </ul></div>
    <?if("show"==$mysqlReShow){?>
    <div><?php echo $mysqlRe?></div><?}?>

    <div><b>MAIL邮件发送测试</b></div>
    <div><ul>
    <li class="c5">收信地址</li>
    <li><input type="text" name="mailReceiver" size="50" <?php echo $isMail?> > <input type="submit" class="button" value="SENDMAIL" <?php echo $isMail?> name="act" > </li>
    </ul></div>
    <?if("show"==$mailReShow){?>
    <div><?php echo $mailRe?></div><?}?>

    <div><b>函数支持状况</b></div>
    <div><ul>
    <li class="c5">函数名称</li>
    <li><input type="text" name="funName" size="50" > <input type="submit" class="button" value="FUNCTION_CHECK" name="act" > </li>
    </ul></div>
    <?if("show"==$funReShow){?>
    <div><?php echo $funRe?></div><?}?>

    <div><b>PHP配置参数状况</b></div>
    <div><ul>
    <li class="c5">参数名称</li>
    <li><input type="text" name="opName" size="40" > <input type="submit" class="button" value="CONFIGURATION_CHECK" name="act" ></li>
    </ul></div>
    <?if("show"==$opReShow){?>
    <div><?php echo $opRe?></div><?}?>

<!-- =============================================================
页脚
============================================================== -->
<div id="footerArrow"><a name="bottom" ><a href="#top" class="arrow">55</a></div>
</div>
<div id="footer">
    <div id="left">
        <div class="c1">
        <ul>
        <li class="left">VALID</li>
        <li class="right"><a href="[url]http://validator.w3.org/check?uri=referer[/url]">XHTML</a></li>
        </ul>
        </div>
        <div class="c1">
        <ul>
        <li class="left">VALID</li>
        <li class="right"><a href="[url]http://jigsaw.w3.org/css-validator/validator?uri=http://<?php echo $_SERVER[url]['SERVER_NAME'].($_SERVER[PHP_SELF] ? $_SERVER[PHP_SELF] : $_SERVER[SCRIPT_NAME]);?>">CSS</a></li>
        </ul>
        </div>
    </div>
    <div id="right">
        powered by: <a href="[url]http://depoch.net[/url]" target="_blank">dEpoch Studio</a>
    </div>
</div>
</form></div>
</body></html>

<?php
  /*=============================================================
  函数库
  =============================================================*/
  /*=============================================================
  栏目表头
  =============================================================*/
  function sec_title($sectName, $secId)
  {
  ?>
  <div class="titleContainer">
    <div class="title"><ul><li class="title"><span class="sectIcon">8</span><?php echo $sectName?><a name="<?php echo $secId?>" ></li></ul></div>
    <div class="arrow"><ul><li><a href="#top" class="arrow">5</a></li><li><a href="#bottom" class="arrow">6</a></li></ul></div>
    </div>
  <?php
  }
  /*=============================================================
  检测函数支持
  =============================================================*/
  function isfun($funName)
  {
    return (false !== function_exists($funName))?YES:NO;
  }
  /*=============================================================
  检测PHP设置参数
  =============================================================*/
  function getcon($varName)
  {
    switch($res = get_cfg_var($varName))
    {
        case 0:
        return NO;
        break;
        case 1:
        return YES;
        break;
        default:
        return $res;
        break;
    }
    
  }
  /*=============================================================
  整数运算能力测试
  =============================================================*/
  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 bar($percent)
  {
    $w = floor(3.5 * $percent);
  ?>
      <div class="bar"><ul><li><hr class="bar" width="<?php echo $w?>" ></li><li><?php echo $percent?>%</li></ul></div>
  <?php
  }
  /*=============================================================
  系统参数探测 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]+/", $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);
    if (false !== is_array($model[1]))
        {
        $res['cpu']['num'] = sizeof($model[1]);
        for($i = 0; $i < $res['cpu']['num']; $i++)
        {
          $res['cpu']['detail'][] = "类型:".$model[1][$i]." 缓存:".$cache[1][$i];
        }
        if (false !== is_array($res['cpu']['detail'])) $res['cpu']['detail'] = implode("<br >", $res['cpu']['detail']);
        }
    
    
    // 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/.]+).+?SwapTotal/s{0,}/:+/s{0,}([/d/.]+).+?SwapFree/s{0,}/:+/s{0,}([/d/.]+)/s", $str, $buf);
    
    $res['memTotal'] = round($buf[1][0]/1024, 2);
    $res['memFree'] = round($buf[2][0]/1024, 2);
    $res['memUsed'] = ($res['memTotal']-$res['memFree']);
    $res['memPercent'] = round(($res['memUsed']/$res['memTotal']) * 100, 2);
    
    $res['swapTotal'] = round($buf[3][0]/1024, 2);
    $res['swapFree'] = round($buf[4][0]/1024, 2);
    $res['swapUsed'] = ($res['swapTotal']-$res['swapFree']);
    $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, 3);
    $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']['detail'] = get_key("hw.model");
    
    //LOAD AVG
    if (false === ($res['loadAvg'] = get_key("vm.loadavg"))) return false;
    $res['loadAvg'] = str_replace("{", "", $res['loadAvg']);
    $res['loadAvg'] = str_replace("}", "", $res['loadAvg']);
    
    //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);
    $buf = explode("/n", do_command("vmstat", ""));
    $buf = explode(" ", trim($buf[2]));
    
    $res['memFree'] = round($buf[5]/1024, 2);
    $res['memUsed'] = ($res['memTotal']-$res['memFree']);
    $res['memPercent'] = round(($res['memUsed']/$res['memTotal']) * 100, 2);
    
    $buf = explode("/n", do_command("swapinfo", "-k"));
    $buf = $buf[1];
    preg_match_all("/([0-9]+)/s+([0-9]+)/s+([0-9]+)/", $buf, $bufArr);
    $res['swapTotal'] = round($bufArr[1][0]/1024, 2);
    $res['swapUsed'] = round($bufArr[2][0]/1024, 2);
    $res['swapFree'] = round($bufArr[3][0]/1024, 2);
    $res['swapPercent'] = (floatval($res['swapTotal'])!=0)?round(($res['swapUsed']/$res['swapTotal']) * 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;
  }
?>
///
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值