程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php 針控(查看服務器詳細信息)

php 針控(查看服務器詳細信息)

編輯:關於PHP編程

php教程 針控(查看服務器詳細信息)

 

/

*  一、本程序基於div+css教程 新型架構php探針,免費開源的自由軟件,功能強大,結構清晰,使用方便。
  1.支持windows,linux,unix,freebsd,sun solar系統
  2.支持ie6,ie7,firefox,google chrome等浏覽器。
  
  二、主要用途及適用對象:
  1.熟悉php編程的業余愛好者及專業開發人員。
  2.機房管理人員配置linux(windows)+php+mysql教程+zend系統環境,檢測系統是否配置成功。
  3.對於購買虛擬主機的用戶,用於測試服務器性能。
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
 //////////////////以下兩變量可以修改配制
 //如果這個探針你是用來驗示的,你可以在下面變量中輸入相關信息(會顯示在頁面底部
    header("content-type: text/html; charset=utf-8");
    error_reporting(e_error | e_warning | e_parse);
 ob_start();
    
    $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("yes", "<span class='resyes'>√</span>");
  define("no", "<span class='resno'>×</span>");

//=================================================================
    define("icon", "<span class='icon'>2</span>&nbsp;");
    $phps教程elf = $_server[php_self] ? $_server[php_self] : $_server[script_name];
    define("phpself", preg_replace("/(.{0,}?/+)/", "", $phpself));
    
    if ($_get['act'] == "phpinfo")
    {
        phpinfo();
        exit();
    }
    elseif($_post['act'] == "整型測試")
    {
        $valint = test_int();
    }
    elseif($_post['act'] == "浮點測試")
    {
        $valfloat = test_float();
    }
    elseif($_post['act'] == "io測試")
    {
        $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"], "uenuprobe mail server test.", "this email is sent by uenuprobe.rnrnrnrnrncopyright uenucomrnhttp://www.uenu.com"))?"完成":"失敗";
    }
    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;
  case "windows":
        //$sysreshow = (false != ($sysinfo = sys_windows()))?"show":"none";
  $sysinfo['uptime'] ="對不起windows系統不支持";
        break;
        default:
        break;
    }
    
//========================================================================

?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="common/control.css">
<script type="text/網頁特效" language="javascript" src="common/admin.otable.js"></script>
<script type="text/javascript" language="javascript" src="common/include.func.js"></script>
<title>服務器信息</title>
<style type="text/css">
.resyes {
 font-size: 12px;
 color: #090;
 font-weight:bold;
 font-family: verdana;
}
.resno {
 font-size: 12px;
 color: #f00;
 font-weight:bold;
 font-family: verdana;
}
.check00{
 color: #630; 
}
</style>
<script type="text/javascript">
window.onload=function(){
 var otable=document.getelementbyid("otable");
 for(var i=0;i<otable.rows.length;i++){
  if(i%2==0) //偶數行時
   otable.rows[i].classname="altrow";
 }
 
 var otable2=document.getelementbyid("otable2");
 for(var i=0;i<otable2.rows.length;i++){
  if(i%2==0) //偶數行時
   otable2.rows[i].classname="altrow";
 }
 
 var otable3=document.getelementbyid("otable3");
 for(var i=0;i<otable3.rows.length;i++){
  if(i%2==0) //偶數行時
   otable3.rows[i].classname="altrow";
 }
 
 var otable4=document.getelementbyid("otable4");
 for(var i=0;i<otable4.rows.length;i++){
  if(i%2==0) //偶數行時
   otable4.rows[i].classname="altrow";
 }
 
 var otable5=document.getelementbyid("otable5");
 for(var i=0;i<otable5.rows.length;i++){
  if(i%2==0) //偶數行時
   otable5.rows[i].classname="altrow";
 }
}
</script>
</head>

<body class="contentbody">
<div class="maindiv">
<span class="ctitle">服務器信息</span>
<ul class="cmenu">
 <li><a href="server_info.php?action=">服務器特征</a></li>
 <li><a href="server_info.php?action=phpinfo">php基本特征</a></li>
 <li><a href="server_info.php?action=otherinfo">php組件支持狀況</a></li>
 <li><a href="server_info.php?action=dbinfo">數據庫支持狀況</a></li>
 <li><a href="server_info.php?action=testinfo">性能檢測</a></li>
    <li><a href="server_moreinfo.php">服務器詳細信息</a></li>
</ul>

<div class="concontent">
<?php
switch($_get['action']){
 case '':
?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="ctable" id="otable" align="center">
<tr>
 <th colspan="2" align="center">服務器特征</th>
</tr>
<tr>
 <td width="150">服務器時間</td>
    <td><?php echo gmdate("y年m月d日 h:i:s",time());?>&nbsp;(格林威治標准時間)&nbsp;&nbsp;<?php echo gmdate("y年n月j日 h:i:s",time()+8*3600)?>&nbsp;(北京時間)</td>
</tr>
<tr>
    <td>服務器域名</td>
    <td><?php echo("<a href="http://$_server[server_name]"  title=訪問此域名 target=_blank>$_server[server_name]</a>"); ?></td>
</tr>
<tr>
 <td>服務器ip地址</td>
    <td><?php $host_ip=gethostbyname($_server["server_name"]); echo($host_ip);?></td>
</tr>
<tr>
 <td>服務器操作系統</td>
    <td><?php $os = explode(" ", php_uname()); echo $os[0]; echo "&nbsp;&nbsp;";
 if ($os[0] =="windows") {echo "主機名稱:".$os[2];} else {echo "內核版本:".$os[2];}?></td>
</tr>
<tr>
 <td>服務器運行時間</td>
    <td><?php if ($sysinfo['uptime']!=""){ echo $sysinfo['uptime'];} else  echo "對不起windows系統不支持"; ?></td>
</tr>
<tr>
 <td>服務器操作系統文字編碼</td>
    <td><?php echo($_server["http_accept_language"]); ?></td>
</tr>
<tr>
 <td>服務器解譯引擎</td>
    <td><?php echo($_server["server_software"]); ?></td>
</tr>
<tr>
 <td>web服務端口</td>
    <td><?php echo($_server["server_port"]); ?></td>
</tr>
<tr>
 <td>服務器管理員</td>
    <td><a href="mailto:<?php echo $_server['server_admin'];?>"><?php echo $_server['server_admin'];?></a></td>
</tr>
<tr>
 <td>本文件路徑</td>
    <td><?php echo($_server["script_filename"]);?></td>
</tr>
<tr>
 <td>服務端剩余空間</td>
    <td><?php echo intval(diskfreespace(".") / (1024 * 1024)).'mb';?></td>
</tr>
<tr>
 <td>系統當前用戶名</td>
    <td><?php echo @get_current_user();?></td>
</tr>
</table>
<br />
<!-- 僅在windows 環境中輸出-->
<?php if(("show" !==$sysreshow) & ("0"!= $_env["number_of_processors"])& (""!= $_env["number_of_processors"])){?>
<div class="info3">服務器處理器</div><div class="info4">cpu個數:<?php echo $_env["number_of_processors"]?> <?php echo "&nbsp;&nbsp;".$_env["processor_identifier"]; echo "&nbsp;&nbsp;運行級別:".$_env["processor_level"]; echo "&nbsp;&nbsp;版本:".$_env["processor_revision"];?></div>
<?php }?>
<!-- 僅在windows 環境中輸出結束-->
<!-- linux or unix 參數輸出-->
<?php if(("show"==$sysreshow)&("0" != $sysinfo['cpu']['num'])&("" != $sysinfo['cpu']['num'])){?>
<div class="info3">服務器處理器</div><div class="info4">cpu個數:<?php echo $sysinfo['cpu']['num']?> &nbsp;&nbsp;<?php echo $sysinfo['cpu']['detail']?></div>
<?php }?>
<?php if("show"==$sysreshow){?>
<div class="info3">內存使用狀況</div><div class="info4">
<?php echo $sysinfo['memtotal']?>m, 已使用
<?php echo $sysinfo['memused']?>m, 空閒
<?php echo $sysinfo['memfree']?>m, 使用率
<?php echo $sysinfo['mempercent']?>%</div>
<div class="info3">swap區</div><div class="info4">
共<?php echo $sysinfo['swaptotal']?>m, 已使用
<?php echo $sysinfo['swapused']?>m, 空閒
<?php echo $sysinfo['swapfree']?>m, 使用率
<?php echo $sysinfo['swappercent']?>%</div>
<div class="info3">系統平均負載</div><div class="info4"><?php echo $sysinfo['loadavg']?></div>
<?php }?>
<!-- linux or unix 參數輸出結束-->
<?php
  break;
 case 'phpinfo':
?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="ctable" id="otable" align="center">
<tr>
 <th colspan="4" align="center">php基本特征</th>
</tr>
<tr>
 <td width="30%">php版本</td>
    <td width="20%"><?php echo php_version;?></td>
 <td width="30%">php運行方式</td>
    <td><?php /**strtoupper(php_sapi_name());**/ echo ucwords(php_sapi_name());?></td>
</tr>
<tr>
 <td>支持zend編譯運行&nbsp;&nbsp;(<?php if($zend="yes") {echo "版本:";echo zend_version();}?>)</td>
    <td><?php echo $zend=(get_cfg_var("zend_optimizer.optimization_level")||get_cfg_var("zend_extension_manager.optimizer_ts")||get_cfg_var("zend_extension_ts")) ?yes:no?></td>
 <td>運行於安全模式</td>
    <td><?php if(get_cfg_var("safemode")){echo("是");}else echo("否"); ?></td>
</tr>
<tr>
 <td>自動定義全局變量&nbsp;register_globals</td>
    <td><?php echo @get_cfg_var("register_globals")?'on' : 'off';?></td>
 <td>允許使用url打開文件allow_url_fopen</td>
    <td><?php echo get_cfg_var("allow_url_fopen")=="1"?yes:no?></td>
</tr>
<tr>
 <td>允許動態加載鏈接庫enable_dl</td>
    <td><?php echo get_cfg_var("enable_dl")=="1"?yes:no?></td>
 <td>顯示錯誤信息&nbsp;display_errors</td>
    <td><?php echo get_cfg_var("display_errors")=="1"?yes:no?></td>
</tr>
<tr>
 <td>短標記&lt;? ?&gt;支持</td>
    <td><?php echo @get_cfg_var("short_open_tag")?yes:no;?></td>
 <td>標記&lt;% %&gt;支持</td>
    <td><?php echo @get_cfg_var("asp教程_tags")?yes:no;?></td>
</tr>
<tr>
 <td>cookie支持</td>
    <td><?php echo isset($http_cookie_vars)?yes:no;?></td>
 <td>session支持</td>
    <td><?php echo function_exists(session_start)?yes:no;?></td>
</tr>
<tr>
 <td>浮點運算有效數字顯示位數</td>
    <td><?php echo @get_cfg_var("precision");?></td>
 <td>強制y2k兼容</td>
    <td><?php echo @get_cfg_var("y2k_compliance")?yes:no;?></td>
</tr>
<tr>
 <td>被禁用的函數disable_functions</td>
    <td><?php $disused = @get_cfg_var("disable_functions")?"1":"0";
if($disused =="1")
{echo '<a href="#" title="
'.@get_cfg_var("disable_functions").'
">'."more".'</a>';}
else {echo "none";}?></td>
 <td>程序最長運行時間max_execution_time</td>
    <td><?php echo(get_cfg_var("max_execution_time")."秒");?></td>
</tr>
<tr>
 <td>程序最多允許使用內存量 memory_limit</td>
    <td><?php echo @get_cfg_var("memory_limit");?></td>
 <td>post最大字節數&nbsp;post_max_size</td>
    <td><?php echo @get_cfg_var("post_max_size");?></td>
</tr>
<tr>
 <td>允許最大上傳文件&nbsp;upload_max_filesize</td>
    <td><?php echo @get_cfg_var("file_uploads")?@get_cfg_var("upload_max_filesize") : $error;?></td>
 <td>php信息 phpinfo</td>
    <td><?php echo (false!==eregi("phpinfo",$disfuns))?no:"<a href='$phpself?act=phpinfo' target='_blank' class='static'>phpinfo</a>"?></td>
</tr>
<tr>
 <td>html錯誤顯示</td>
    <td><?php echo @get_cfg_var("html_errors")?yes:no;?></td>
 <td>調試器地址/端口</td>
    <td><?php echo $debugerhost=@get_cfg_var("debugger.host")?yes:no;if ($debugerhost =="yes") {echo @get_cfg_var("debugger.port")?yes:no;}?></td>
</tr>
<tr>
 <td>smtp支持</td>
    <td><?php echo @get_cfg_var("smtp")?yes:no;?></td>
 <td>smtp地址</td>
    <td><?php echo @get_cfg_var("smtp");?></td>
</tr>
</table>
<?php
  break;
 case 'otherinfo': 
?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="ctable" id="otable" align="center">
<tr>
 <th colspan="4" align="center">php組件支持狀況</th>
</tr>
<tr>
 <td width="30%">拼寫檢查 aspell library</td>
    <td width="20%"><?php echo function_exists(aspell_new)?yes:no;?></td>
    <td width="30%">高精度數學運算 bcmath</td>
    <td><?php echo function_exists(bcadd)?yes:no;?></td>
</tr>
<tr>
 <td>歷法運算 calendar</td>
    <td><?php echo function_exists(jdtofrench)?yes:no;?></td>
 <td>圖形處理 gd library</td>
    <td><?php echo function_exists(imageline)?yes:no;?></td>
</tr>
<tr>
 <td>類/對象支持</td>
    <td><?php echo function_exists(class_exists)?yes:no;?></td>
 <td>字串類型檢測支持</td>
    <td><?php echo function_exists(ctype_upper)?yes:no;?></td>
</tr>
<tr>
 <td>iconv編碼支持</td>
    <td><?php echo function_exists(iconv)?yes:no;?></td>
 <td>mcrypt加密處理支持</td>
    <td><?php echo function_exists(mcrypt_cbc)?yes:no;?></td>
</tr>
<tr>
 <td>哈稀計算 mhash</td>
    <td><?php echo function_exists(mhash)?yes:no;?></td>
 <td>openssl支持</td>
    <td><?php echo function_exists(openssl_open)?yes:no;?></td>
</tr>
<tr>
 <td>prel相容語法 pcre</td>
    <td><?php echo function_exists(preg_match)?yes:no;?></td>
 <td>正則擴展(兼容perl)支持</td>
    <td><?php echo function_exists(preg_match)?yes:no;?></td>
</tr>
<tr>
 <td>socket支持</td>
    <td><?php echo function_exists(fsockopen)?yes:no;?></td>
 <td>流媒體支持</td>
    <td><?php echo function_exists(stream_context_create)?yes:no;?></td>
</tr>
<tr>
 <td>tokenizer支持</td>
    <td><?php echo function_exists(token_name)?yes:no;?></td>
 <td>url支持</td>
    <td><?php echo function_exists(parse_url)?yes:no;?></td>
</tr>
<tr>
 <td>wddx支持(web distributed data exchange)</td>
    <td><?php echo function_exists(wddx_add_vars)?yes:no;?></td>
 <td>壓縮文件支持(zlib)</td>
    <td><?php echo function_exists(gzclose)?yes:no;?></td>
</tr>
<tr>
 <td>xml解析</td>
    <td><?php echo function_exists(xml_set_object)?yes:no;?></td>
 <td>ftp</td>
    <td><?php echo function_exists(ftp_login)?yes:no;?></td>
</tr>
<tr>
 <td>目錄存取協議(ldap)支持</td>
    <td><?php echo function_exists(ldap_close)?yes:no;?></td>
 <td>yellow page系統支持</td>
    <td><?php echo function_exists(yp_match)?yes:no;?></td>
</tr>
<tr>
 <td>php和java綜合支持</td>
    <td><?php echo function_exists(java_last_exception_get)?yes:no;?></td>
 <td>imap電子郵件系統支持</td>
    <td><?php echo function_exists(imap_close)?yes:no;?></td>
</tr>
<tr>
 <td>snmp網絡管理協議支持</td>
    <td><?php echo function_exists(snmpget)?yes:no;?></td>
 <td>vmailmgr郵件處理支持</td>
    <td><?php echo function_exists(vm_adduser)?yes:no;?></td>
</tr>
<tr>
 <td>pdf文檔支持</td>
    <td><?php echo function_exists(pdf_close)?yes:no;?></td>
 <td>fdf表單資料格式支持</td>
    <td><?php echo function_exists(fdf_close)?yes:no;?></td>
</tr>
</table>
<?php
  break;
 case 'dbinfo': 
?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="ctable" id="otable" align="center">
<tr>
 <th colspan="4" align="center">數據庫支持狀況</th>
</tr>
<tr>
 <td width="30%">mysql數據庫支持</td>
    <td width="20%"><?php echo function_exists(mysql_close)?yes:no;?></td>
 <td width="30%">mysql數據庫持續連接</td>
    <td><?php echo @get_cfg_var("mysql.allow_persistent")?yes:no;?></td>
</tr>
<tr>
 <td>mysql最大連接數</td>
    <td><?php echo @get_cfg_var("mysql.max_links")==-1 ? "不限" : @get_cfg_var("mysql.max_links");?></td>
 <td>odbc數據庫連接</td>
    <td><?php echo function_exists(odbc_close)?yes:no;?></td>
</tr>
<tr>
 <td>sql server數據庫支持</td>
    <td><?php echo function_exists(mssql_close)?yes:no;?></td>
 <td>msql數據庫支持</td>
    <td><?php echo function_exists(msql_close)?yes:no;?></td>
</tr>
<tr>
 <td>postgre sql數據庫支持</td>
    <td><?php echo function_exists(pg_close)?yes:no;?></td>
 <td>oracle數據庫支持</td>
    <td><?php echo function_exists(ora_close)?yes:no;?></td>
</tr>
<tr>
 <td>oracle 8 數據庫支持</td>
    <td><?php echo function_exists(ocilogoff)?yes:no;?></td>
 <td>dbase數據庫支持</td>
    <td><?php echo function_exists(dbase_close)?yes:no;?></td>
</tr>
<tr>
 <td>sybase數據庫支持</td>
    <td><?php echo function_exists(sybase_close)?yes:no;?></td>
 <td>dba數據庫支持</td>
    <td><?php echo function_exists(dba_close)?yes:no;?></td>
</tr>
<tr>
 <td>dbm數據庫支持</td>
    <td><?php echo function_exists(dbmclose)?yes:no;?></td>
 <td>dbx數據庫支持</td>
    <td><?php echo function_exists(dbx_close)?yes:no;?></td>
</tr>
<tr>
 <td>db++數據庫支持</td>
    <td><?php echo function_exists(dbplus_close)?yes:no;?></td>
 <td>frontbase數據庫支持</td>
    <td><?php echo function_exists(fbsql_close)?yes:no;?></td>
</tr>
<tr>
 <td>filepro數據庫支持</td>
    <td><?php echo function_exists(filepro)?yes:no;?></td>
 <td>informix數據庫支持</td>
    <td><?php echo function_exists(ifx_close)?yes:no;?></td>
</tr>
<tr>
 <td>lotus notes數據庫支持</td>
    <td><?php echo function_exists(notes_version)?yes:no;?></td>
 <td>interbase數據庫支持</td>
    <td><?php echo function_exists(ibase_close)?yes:no;?></td>
</tr>
<tr>
 <td>ingres數據庫支持</td>
    <td><?php echo function_exists(ingres_close)?yes:no;?></td>
 <td>hyperwave數據庫支持</td>
    <td><?php echo function_exists(hw_close)?yes:no;?></td>
</tr>
<tr>
 <td>ovrimos sql數據庫連接支持</td>
    <td><?php echo function_exists(ovrimos_close)?yes:no;?></td>
 <td>sesam數據庫連接支持</td>
    <td><?php echo function_exists(sesam_disconnect)?yes:no;?></td>
</tr>
<tr>
 <td>sqlite數據庫連接支持</td>
    <td><?php echo function_exists(sqlite_close)?yes:no;?></td>
 <td>adabas d數據庫連接支持</td>
    <td><?php echo function_exists(ada_close)?yes:no;?></td>
</tr>
</table>
<?php
  break;
 case 'testinfo': 
?>
<form action="<?php echo phpself."?action=testinfo&icon=$icon&#testinfo1"?>" method="post">
<!--服務器性能檢測-->
<div id="testinfo1">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="ctable" id="otable" align="center">
<tr><th colspan="4">服務器性能檢測</th></tr>
<tr align="center">
 <td width="25%">參照對象</td>
 <td width="25%">整數運算能力檢測(1+1運算300萬次)</td>
 <td width="25%">浮點運算能力檢測(開平方300萬次)</td>
 <td width="25%">數據i/o能力檢測(讀取10k文件1萬次)</td>
</tr>
<tr align="center">
 <td>紅色主機單線型(雙核)</td>
 <td>0.33 秒</td>
 <td>0.95 秒</td>
 <td>0.03 秒</td>
</tr>
<tr align="center">
 <td>紅色主機雙線型(四核)</td>
 <td>0.25 秒</td>
 <td>0.79 秒</td>
 <td>0.03 秒</td>
</tr>
<tr align="center">
 <td>xeon(tm) 2.80*2+4g+centos 5.2</td>
 <td>0.068秒</td>
 <td>0.086秒</td>
 <td>小於0.100秒</td>
</tr>
<tr align="center">
 <td>xeon(tm) 2.80ghz+2g+freebsd 4.0</td>
 <td>0.501秒</td>
 <td>0.694秒</td>
 <td>小於0.100秒</td>
</tr>
<tr align="center" height="50">
 <td>本台服務器</td>
 <td><span style="color:#390"><?php echo $valint;?></span> <input type="submit" value="整型測試" name="act" class="button" /></td>
 <td><span style="color:#06c"><?php echo $valfloat;?></span> <input type="submit" value="浮點測試" name="act" class="button" /></td>
 <td><span style="color:#f60"><?php echo $valio;?></span> <input type="submit" value="io測試" name="act" class="button" /></td>
</tr>
</table>
</div>
<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;?>" />
</form>
<?php
$ismysql = (false !== function_exists("mysql_query"))?"":" disabled";
$ismail = (false !== function_exists("mail"))?"":" disabled";
?>
<br />
<form action="<?php echo phpself."?action=testinfo&icon=$icon&#testinfo2"?>" method="post">
<div id="testinfo2">
<!--mysql數據庫連接檢測--><br /><br />
<table cellpadding="0" cellspacing="0" border="0" width="80%" class="ctable" id="otable2" align="center">
<tr><th colspan="2">mysql數據庫連接檢測</th></tr>
<tr>
 <td width="30%" align="right">mysql服務器:</td>
 <td><input name="mysqlhost" type="text" id="mysqlhost" value="localhost" size="80" class="text2" /></td>
</tr>
<tr>
 <td align="right">mysql用戶名:</td>
 <td><input name="mysqluser" type="text" id="mysqluser" value="root" size="80" class="text2" /></td>
</tr>
<tr>
 <td align="right">mysql用戶密碼:</td>
 <td><input type="text" name="mysqlpassword" <?php echo $ismysql?> size="80" class="text2" /></td>
</tr>
<tr>
 <td align="right">mysql數據庫名稱:</td>
 <td><input type="text" name="mysqldb" size="80" class="text2" /></td>
</tr>
<tr>
 <td align="right" height="30"><input type="submit" class="button" value="connect" <?php echo $ismysql?>  name="act" /></td>
    <td><div class="check00"><?php if("show"==$mysqlreshow){echo $mysqlre;}?> </div></td>
</tr>
</table>
</div>
</form>
<br /><br />
<form action="<?php echo phpself."?action=testinfo&icon=$icon&#testinfo5"?>" method="post">
<div id="testinfo5">
<!--郵件發送檢測-->
<table cellpadding="0" cellspacing="0" border="0" width="80%" class="ctable" id="otable3" align="center">
<tr><th colspan="2">php配置參數狀況</th></tr>
<tr>
    <td width="30%" align="right">請輸入您要檢測的參數名稱:</td>
    <td><input type="text" name="opname" size="80" class="text2" /></td>
</tr>
<tr>
    <td align="right" height="30"><input type="submit" class="button" value="configuration_check" name="act" /></td>
    <td><div class="check00"><?php if("show"==$opreshow){echo $opre;}?></div></td>
</tr>
</table>
</div>
</form>
<br /><br />
<form action="<?php echo phpself."?action=testinfo&icon=$icon&#testinfo3"?>" method="post">
<div id="testinfo3">
<!--函數檢測-->
<table cellpadding="0" cellspacing="0" border="0" width="80%" class="ctable" id="otable4" align="center">
<tr><th colspan="2">函數檢測</th></tr>
<tr>
 <td width="30%" align="right">請輸入您要檢測的函數名稱:</td>
 <td><input type="text" name="funname" size="80" class="text2" /></td>
</tr>
<tr>
 <td align="right" height="30"><input type="submit" class="button" value="function_check" name="act" /></td>
    <td><div class="check00"><?php if("show"==$funreshow){echo $funre;}?> </div></td>
</tr>
</table>
</div>
</form>
<br /><br />
<form action="<?php echo phpself."?action=testinfo&icon=$icon&#testinfo4"?>" method="post">
<div id="testinfo4">
<!--郵件發送檢測-->
<table cellpadding="0" cellspacing="0" border="0" width="80%" class="ctable" id="otable5" align="center">
<tr><th colspan="2">mail郵件發送測試</th></tr>
<tr>
    <td width="30%" align="right">請輸入您要檢測的郵件地址:</td>
    <td><input type="text" name="mailreceiver" size="80" <?php echo $ismail?> class="text2" /></td>
</tr>
<tr>
    <td align="right" height="30"><input type="submit" class="button" value="sendmail" <?php echo $ismail?>  name="act" /></td>
    <td><div class="check00"><?php if("show"==$mailreshow){echo $mailre;}?></div></td>
</tr>
</table>
</div>
</form>

<?php
  break;
}?>
</div>

</div>
</body>
</html>
<?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, 6)."秒";
        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, 6)."秒";
        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, 6)."秒";
        return($time);
    }
/*-------------------------------------------------------------------------------------------------------------
    比例條
--------------------------------------------------------------------------------------------------------------*/
    function bar($percent)
    {
    echo '<br/><ul class="bar">
 <li style="width:';
 echo $percent."%">";
    echo '&nbsp;</li>
    </ul>';
}
/*-------------------------------------------------------------------------------------------------------------
    根據不同系統取得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("/models+names{0,}:+s{0,}([ws)(.]+)[rn]+/", $str, $model);
        //@preg_match_all("/cpus+mhzs{0,}:+s{0,}([d.]+)[rn]+/", $str, $mhz);
        @preg_match_all("/caches+sizes{0,}:+s{0,}([d.]+s{0,}[a-z]+[rn]+)/", $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("/memtotals{0,}:+s{0,}([d.]+).+?memfrees{0,}:+s{0,}([d.]+).+?swaptotals{0,}:+s{0,}([d.]+).+?swapfrees{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'] = (floatval($res['memtotal'])!=0)?round($res['memused']/$res['memtotal']*100,2):0;
        
        $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'] = (floatval($res['memtotal'])!=0)?round($res['memused']/$res['memtotal']*100,2):0;
          
        $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;
    }

/*-------------------------------------------------------------------------------------------------------------
    系統參數探測 windows
--------------------------------------------------------------------------------------------------------------*/
    function sys_windows()
 {
 //$phpos=php_os;
 $sysinfo['uptime'] ="對不起windows系統不支持";
 
 }
?>


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved