<?php
/*
+--------------------------------------------------------------------------
| B-Check v0.05.4
| ========================================
| 南方第三制作
| http://www.rubyfans.com
| ========================================
| 探针官方: 无
| 最后更新: 2010.9.6 11:30
| QQ:307292967
+---------------------------------------------------------------------------
|
| 在编写过程中,学习借鉴了很多其他优秀的探针
| 并根据自身的理解做了很多修改和优化,就当前而言,这是探测信息最全面的PHP探针了!
| 整个执行框架,我是想到哪就写到哪,并没有进行合理的规划,我想,在以后我有时间的时候会近一步更新
|
+--------------------------------------------------------------------------
*/
//抑制所有的错误信息
ini_set('display_errors', 'off');
//计算页面运行时间函数
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$pagestartime=getmicrotime();
//显示常量
define("on", "<font color=\"green\"><b>Yes</b></font>");
define("off", "<font color=\"red\"><b>No</b></font>");
define("version", "v0.05.4");//版本号
define("overtime","2010.9.6 11:30");//完成时间
//显示开关
$mysqlReShow = "none";
//使用通知,针对前几个版本中,使用通知处理不合理,导致通知邮件源源不断塞进我的邮箱。
if($_COOKIE["had_send"] != "yes") {
$messagex="来自:http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."\n\n版本:".version;
$tox="307292967@qq.com";
$subjectx="B-check User - ".version;
mail($tox, $subjectx, $messagex);
setcookie("had_send", "yes");
}
//性能信息结果刷新
$ts_int = (false == empty($_POST['tsint']))?$_POST['tsint']:test_int();
$ts_float = (false == empty($_POST['tsfloat']))?$_POST['tsfloat']:test_float();
$ts_io = (false == empty($_POST['tsio']))?$_POST['tsio']:test_io();
if(isset($_POST['speed']))
{
$speed=round(100/($_POST['speed']/1000),2);
}
elseif($_GET['speed']=="0")
{
$speed=6666.67;
}
elseif(isset($_GET['speed']) and $_GET['speed']>0)
{
$speed=round(100/($_GET['speed']/1000),2);
}
else
{
$speed="<font color=red> 未探测 </font>";
}
//phpinfo()信息列举
switch ($_GET['action']){
case "phpinfo_GENERAL":
phpinfo(INFO_GENERAL+INFO_ENVIRONMENT+INFO_VARIABLES);
exit;
case "phpinfo_CONFIGURATION":
phpinfo(INFO_CONFIGURATION);
exit;
case "phpinfo_MODULES":
phpinfo(INFO_MODULES);
exit;
case "phpinfo":
phpinfo();
exit;
default:
break;
}
//表单处理
if(isset($_POST['Buginfo']) and $_POST['act']=="提交"){//Bug提交!
$message=$message."\n\n 来自:".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
$to="307292967@qq.com";
$subject="浩哥你多大了?";
$jg=@mail($to, $subject, $message);
$jgprint= (true==$jg)?"<font color=\"green\">上报成功!谢谢你!</font>":"<font color=\"red\">上报失败!写信给我吧:307292967@qq.com</font>";
}
elseif($_POST['action']=="整数运算")
{
$ts_int=test_int();
}
elseif($_POST['action']=="浮点运算")
{
$ts_float=test_float();
}
elseif($_POST['action']=="IO测试")
{
$ts_io=test_io();
}
elseif($_POST['action']=="开始测试")//网速测试,等你来完善。
{
?>
<script language="javascript" type="text/javascript">
var acd1;
acd1 = new Date();
acd1ok=acd1.getTime();
</script>
<?php
for($i=1;$i<=1000;$i++){
echo "<!--567890#########0#########0#########0#########0#########0#########0#########0#########012345-->";
}
?>
<script language="javascript" type="text/javascript">
var acd2;
acd2 = new Date();
acd2ok=acd2.getTime();
window.location = '?speed=' +(acd2ok-acd1ok)+'#bottom';
</script>
<?php
}
elseif($_POST['action'] == "连接Mysql")
{
$mysqlReShow = "show";
$mysqlRe = "MYSQL连接测试结果:";
$mysqlRe .= (false !==mysql_connect($_POST['mysqlhost'], $_POST['mysqluser'], $_POST['mysqlpsd']))?"<font color=\"#009900\">MYSQL服务器连接正常</font>,":"<font color=\"red\">MYSQL服务器连接失败!</font>, ";
$mysqlRe .= "数据库 <b>".$_POST['mysqldb']."</b> ";
$mysqlRe .= (false != @mysql_select_db($_POST['mysqldb']))?"<font color=\"#009900\">连接正常</font>":"<font color=\"red\">连接失败!</font>";
if(false !==mysql_connect($_POST['mysqlhost'], $_POST['mysqluser'], $_POST['mysqlpsd']))
{
$mysql_version=mysql_get_server_info();
}
else
{
$mysql_version="<font color=red>获取失败!</font>";
}
$mysqlRe .= ",Mysql服务器版本:";
$mysqlRe .= $mysql_version;
}
elseif($_POST['action'] == "发送")
{
$mailRe = (false !== @mail($_POST["mailReceiver"], "探针邮件测试", "成功发送!"))?"<font color=\"#090\">发送完成</font>":"<font color=red>发送失败!</font>";
}
elseif($_POST['action']=="检测")
{
$funre=$_POST['funame']." 的支持情况:".getfunexists($_POST['funame']);
}
elseif($_POST['action']=="检测1")
{
$pmre=$_POST['pm']." 的支持情况:".getvar($_POST['pm']);
}
//获取Zend Optimizer版本,方法参考了废墟のPHP探针
function checkoptimizer()
{
$url= "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."?action=phpinfo";
$htmlct=file_get_contents($url);
eregi("Optimizer v(.*), Copyright", $htmlct, $regs);
$optimizerversion=$regs[1];
$optimizerversion=(''!=$optimizerversion)?$optimizerversion:"<font color=red>获取失败!</font>";
return $optimizerversion;
}
//获取php.ini配置参数,参考iProber
function getvar($varname)
{
switch($var=get_cfg_var($varname)?get_cfg_var($varname):ini_get($varname))
{
case 0:
return off;
break;
case 1:
return on;
break;
default:
return $var;
break;
}
}
//判断函数定义情况
function getfunexists($funame)
{
return (false !== function_exists($funame))?on:off;
}
//整数运算测试
function test_int()
{
$startime=getmicrotime();
for($i = 0; $i < 3000000; $i++);
{
$t = 1+1;
}
$endtime=getmicrotime();
$time=round($endtime-$startime,4);
return $time;
}
//浮点数运算测试
function test_float()
{
$startime=getmicrotime();
for($i = 0; $i < 3000000; $i++);
{
sqrt($t);
}
$endtime=getmicrotime();
$time=round($endtime-$startime,4);
return $time;
}
//IO能力测试
function test_io()
{
$fp = fopen($_SERVER['PHP_SELF'], "r");
$startime=getmicrotime();
for($i = 0; $i < 300000; $i++);
{
fread($fp, 10240);
rewind($fp);
}
$endtime=getmicrotime();
$time=round($endtime-$startime,4);
return $time;
}
//获取磁盘信息、disk_x_space("y")的参数不能用变量,@在这里不起作用
$diskct=0;
$disk=array();
/*if(@disk_total_space("A:")!=NULL) *为防止影响服务器,不检查软驱 - 阿江说的
{
$diskct=1;
$disk["A"]=round((@disk_free_space("A:")/(1024*1024*1024)),2)."G / ".round((@disk_total_space("A:")/(1024*1024*1024)),2).'G';
}*/
$diskz=0; //磁盘总容量
$diskk=0; //磁盘剩余容量
if(@disk_total_space("B:")!=NULL)
{
$diskct++;
$disk["B"][0]=round(@disk_free_space("B:")/(1024*1024*1024),2).'G';
$disk["B"][1]=round(@disk_total_space("B:")/(1024*1024*1024),2).'G';
$disk["B"][2]=round(((@disk_free_space("B:")/(1024*1024*1024))/(@disk_total_space("B:")/(1024*1024*1024)))*100,2).'%';
$diskk+=round((@disk_free_space("B:")/(1024*1024*1024)),2);
$diskz+=round((@disk_total_space("B:")/(1024*1024*1024)),2);
}
if(@disk_total_space("C:")!=NULL)
{
$diskct++;
$disk["C"][0]=round((@disk_free_space("C:")/(1024*1024*1024)),2).'G';
$disk["C"][1]=round((@disk_total_space("C:")/(1024*1024*1024)),2).'G';
$disk["C"][2]=round(((@disk_free_space("C:")/(1024*1024*1024))/(@disk_total_s