教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php探针 phpinfo()函数禁用时使用

php探针 phpinfo()函数禁用时使用

发布时间:2018-01-24   编辑:jiaochengji.com
分享一个php探针代码,当phpinfo函数被禁用时,可以使用此php探针代码检测服务器信息,有需要的朋友参考下。

例子,php探针代码。

在php开发过程中,经常需要检测下php服务器环境,那么本文这个php探针代码就可以派上用场。
 

复制代码 代码示例:

<?php
header("content-type: text/html; charset=utf-8");
header("cache-control: no-cache, must-revalidate"); 
header("pragma: no-cache");
error_reporting(0);
ob_end_flush();

?>
<!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="pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="cache-control" content="private" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />//加了这句,看看能不能解决linux下显示乱码的问题?
<title>php 探针 v1.0 - www.jbxue.com</title>
<style type="text/css">
<!--
body{text-align:center;margin-top:20px;background-color:#a9b674;}

#overview{width:700px;margin:0 auto;text-align:left;}
a{text-decoration:underline;color:#992700;}
.strong{color:#992700;}
.basew{width:300px;}
-->
</style>
</head>

<body>
<div id="overview">
<div id="copyright">版权信息
<a href="hello.php?typ=baseinfo">[基本信息]</a>&nbsp;<a href="hello.php?typ=superinfo">[高级信息]</a>
<?php
if (function_exists("phpinfo")){
    echo'<a href="hello.php?typ=phpinfo">[phpinfo]</a>';}

echo'<br />php探针v1.0 by mkduse(blueidea-id)<br /><br />此程序代码,可免费使用;但不得用于商业用途;完全转载或使用此代码,请保留版权信息;<br />欢迎指正错误提建议,qq:122712355</div>';

if (empty($_get['typ'])){
    baseinfo();}
else{
switch ($_get['typ']){
case 'phpinfo':
phpinfoview();
break;
case 'superinfo':
superinfo();
break;
case 'baseinfo':
baseinfo();
break;
default:
baseinfo();}
}

function getime()
{
  $t = gettimeofday();
  return (float)($t['sec'] + $t['usec']/1000000);
}

function baseinfo(){
echo '<h1>基本信息</h1>';
$arr[]=array("current php version:",phpversion());
$arr[]=array("zend engine version:",zend_version());
$arr[]=array("服务器版本",$_server['server_software']);
$arr[]=array("ip地址",$_server['remote_host']);//ip
$arr[]=array("域名",$_server['http_host']);
$arr[]=array("协议端口",$_server['server_protocol'].'&nbsp;&nbsp;'.$_server['server_port']);
$arr[]=array("站点根目录",$_server['path_translated']);
$arr[]=array("服务器时间",date('y年m月d日,h:i:s,d'));
$arr[]=array("当前用户",get_current_user());
$arr[]=array("操作系统",php_uname('s').php_uname('r').php_uname('v'));
$arr[]=array("include_path",ini_get('include_path'));
$arr[]=array("server api",php_sapi_name());

$arr[]=array("error_reporting level",ini_get("display_errors"));
$arr[]=array("post提交限制",ini_get('post_max_size'));
$arr[]=array("upload_max_filesize",ini_get('upload_max_filesize'));
$arr[]=array("脚本超时时间",ini_get('max_execution_time').'秒');

if (ini_get("safe_mode")==0){
$arr[]=array("php安全模式(safe_mode)",'off');}
else{
$arr[]=array("php安全模式(safe_mode)",'on');}

if (function_exists('memory_get_usage')){
$arr[]=array("memory_get_usage",ini_get('memory_get_usage'));}

//$arr[]=array("可用空间",intval(diskfreespace('/')/(1024 * 1024))."m");
echo'<table>';
for($i=0;$i<count($arr);$i++)
{
    $overview='<tr><td class="basew">'.$arr[$i][0].'</td><td>'.$arr[$i][1].'</td></tr>';
    echo $overview;
}
echo'</table>';
echo '<h2>服务器性能测试</h2>';
echo'<table><tr><td>服务器</td><td>整数运算<br />50万次加法(1+1)</td><td>浮点运算<br />50万次平方根(3.14开方)</td></tr>';
echo'<tr><td>mkduse的机子(p4 1.5g 256ddr winxp sp2)</td><td>465.08ms</td><td>466.66ms</td></tr>';
$time_start=getime();
for($i=0;$i<=500000;$i++);
{$count=1+1;}
$timea=round((getime()-$time_start)*1000,2);
echo '<tr class="strong"><td>当前服务器</td><td>'.$timea.'ms</td>';

$time_start=getime();
for($i=0;$i<=500000;$i++);
{sqrt(3.14);}
$timea=round((getime()-$time_start)*1000,2);
echo '<td>'.$timea.'ms</td></tr></table>';


?>
<script language="javascript" type="text/javascript">
function gettime()

  var time; 
  time=new date();
  return time.gettime(); 
}
start_time=gettime();
</script>
<?php
echo '<h2>带宽测试</h2>';
for ($i=0;$i<100;$i++){
print "<!--1234567890#########0#########0#########0#########0#########0#########0#########0#########012345-->";}

?>
<p id="dk"></p>
<script language="javascript" type='text/javascript'>
var timea;
var netspeed;
timea=gettime()-start_time;
netspeed=math.round(10/timea*1000);
document.getelementbyidx("dk").innerhtml="向客户端发送10kb数据,耗时"+timea+"ms<br />您与此服务器的连接速度为"+netspeed+"kb/s";
</script>

<?php
echo'<h2>已加载的扩展库(enable)</h2><div>';
$arr =get_loaded_extensions();
foreach($arr as $value){
    echo $value.'<br />';}

echo'</div><h2>禁用的函数</h2><p>';
$disfun=ini_get('disable_functions');
if (empty($disfun)){
    echo'没有禁用</p>';}
else{
echo ini_get('disable_functions').'</p>';}

}//关闭

function superinfo(){
echo'<h1>高级信息</h1><p>php_ini_user 1 配置选项可用在用户的 php 脚本或windows 注册表中<br> php_ini_perdir 2 配置选项可在 php.ini, .htaccess 或 httpd.conf 中设置 <br>php_ini_system 4 配置选项可在 php.ini or httpd.conf 中设置 <br>php_ini_all 7 配置选项可在各处设置</p>';

$arr1=ini_get_all();
for ($i=0;$i<count($arr1);$i++)
    {
$arr2=array_slice($arr1,$i,1);
print_r($arr2);
echo '<br />';
}
}

function phpinfoview(){
    phpinfo();
}
?>
</div>
</body>
</html>

php服务器探针显示php服务器信息
PHP探针获取客户端信息
带查看密码的php探针代码
php探针不显示cpu、内存、硬盘信息原因分析

您可能感兴趣的文章:
php探针 phpinfo()函数禁用时使用
php探针不显示cpu、内存、硬盘信息原因分析
Linux服务器查看PHP是否支持mail()函数方法
Linux服务器查看 PHP 是否支持mail()函数方法
php服务器探针显示php服务器信息
PHP出现Warning: scandir()问题的解决方法
什么是php探针
PHP Warning: phpinfo() has been disabled函数禁用
phpinfo()获取php服务器配置信息
phpinfo是什么意思

关键词: phpinfo  php探针   
[关闭]
~ ~