好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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.对于购买虚拟主机的用户,用于测试服务器性能.

以下两变量可以修改配制,如果这个探针你是用来验示的,你可以在下面变量中输入相关信息,会显示在页面底部.

php 针探代码如下:

header( "content-type: text/html; charset=utf-8" );       error_reporting (e_error | e_warning | e_parse);   ob_start();              $valint  = (false ==  empty empty ( $_post [ 'pint' ]))? $_post [ 'pint' ]: "未测试" ;       $valfloat  = (false ==  empty empty ( $_post [ 'pfloat' ]))? $_post [ 'pfloat' ]: "未测试" ;       $valio  = (false ==  empty 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. copyright uenucom http://HdhCmsTestuenu测试数据" ))? "完成" : "失败" ;      }       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://HdhCmsTestw3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd" >  <html xmlns= "http://HdhCmsTestw3.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)(.]+)[ ]+/" ,  $str ,  $model );           //@preg_match_all("/cpus+mhzs{0,}:+s{0,}([d.]+)[ ]+/", $str, $mhz);           @preg_match_all( "/caches+sizes{0,}:+s{0,}([d.]+s{0,}[a-z]+[ ]+)/" ,  $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 ( " " , 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 ( " " , 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;      }  //开源代码phpfensi测试数据   /*-------------------------------------------------------------------------------------------------------------       系统参数探测 windows   --------------------------------------------------------------------------------------------------------------*/        function  sys_windows()   {    //$phpos=php_os;     $sysinfo [ 'uptime' ] = "对不起windows系统不支持" ;      }  ?>

查看更多关于php 针探,查看服务器详细信息 - 综合实例的详细内容...

  阅读:49次