* 一、本程序基于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", "yes "); //define("no", "no "); define("yes", "√ "); define("no", "× ");
//================================================================= define("icon", "2 "); $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 .= "数据库教程 ".$_post['mysqldb']." "; $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 = "函数 ".$_post['funname']." 支持状况检测结果:".isfun($_post['funname']); } elseif($_post['act'] == "configuration_check") { $opreshow = "show"; $opre = "配置参数 ".$_post['opname']." 检测结果:".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; } //========================================================================
?>
服务器信息
服务器信息
switch($_get['action']){
case '':
?>
服务器特征
服务器时间
(格林威治标准时间) (北京时间)
服务器域名
$_server[server_name]"); ?>
服务器ip地址
服务器操作系统
if ($os[0] =="windows") {echo "主机名称:".$os[2];} else {echo "内核版本:".$os[2];}?>
服务器运行时间
服务器操作系统文字编码
服务器解译引擎
web服务端口
服务器管理员
本文件路径
服务端剩余空间
系统当前用户名
服务器处理器
cpu个数:
服务器处理器
cpu个数:
内存使用状况
m, 已使用 m, 空闲 m, 使用率 %
swap区
共m, 已使用 m, 空闲 m, 使用率 %
系统平均负载
break;
case 'phpinfo':
?>
php基本特征
php版本
php运行方式
支持zend编译运行 ()
运行于安全模式
自动定义全局变量 register_globals
允许使用url打开文件allow_url_fopen
允许动态加载链接库enable_dl
显示错误信息 display_errors
短标记 ?>支持
标记<% %>支持
cookie支持
session支持
浮点运算有效数字显示位数
强制y2k兼容
被禁用的函数disable_functions
if($disused =="1") {echo ' ">'."more".'';} else {echo "none";}?>
程序最长运行时间max_execution_time
程序最多允许使用内存量 memory_limit
post最大字节数 post_max_size
允许最大上传文件 upload_max_filesize
php信息 phpinfo
phpinfo"?>
html错误显示
调试器地址/端口
smtp支持
smtp地址
break;
case 'otherinfo':
?>
php组件支持状况
拼写检查 aspell library
高精度数学运算 bcmath
历法运算 calendar
图形处理 gd library
类/对象支持
字串类型检测支持
iconv编码支持
mcrypt加密处理支持
哈稀计算 mhash
openssl支持
prel相容语法 pcre
正则扩展(兼容perl)支持
socket支持
流媒体支持
tokenizer支持
url支持
wddx支持(web distributed data exchange)
压缩文件支持(zlib)
xml解析
ftp
目录存取协议(ldap)支持
yellow page系统支持
php和java综合支持
imap电子邮件系统支持
snmp网络管理协议支持
vmailmgr邮件处理支持
pdf文档支持
fdf表单资料格式支持
break;
case 'dbinfo':
?>
数据库支持状况
mysql数据库支持
mysql数据库持续连接
mysql最大连接数
odbc数据库连接
sql server数据库支持
msql数据库支持
postgre sql数据库支持
oracle数据库支持
oracle 8 数据库支持
dbase数据库支持
sybase数据库支持
dba数据库支持
dbm数据库支持
dbx数据库支持
db++数据库支持
frontbase数据库支持
filepro数据库支持
informix数据库支持
lotus notes数据库支持
interbase数据库支持
ingres数据库支持
hyperwave数据库支持
ovrimos sql数据库连接支持
sesam数据库连接支持
sqlite数据库连接支持
adabas d数据库连接支持
break;
case 'testinfo':
?>
$ismysql = (false !== function_exists("mysql_query"))?"":" disabled";
$ismail = (false !== function_exists("mail"))?"":" disabled";
?>
break; }?>
/*============================================================= 函数库 =============================================================*/
/*------------------------------------------------------------------------------------------------------------- 检测函数支持 --------------------------------------------------------------------------------------------------------------*/ 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 { $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 { 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 { @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 '
'; } /*------------------------------------------------------------------------------------------------------------- 根据不同系统取得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']['detail'][] = "类型:".$model[1][$i]." 缓存:".$cache[1][$i]; } if (false !== is_array($res['cpu']['detail'])) $res['cpu']['detail'] = implode(" ", $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系统不支持"; } ?>