php禁用函数设置及查看方法详解
本文实例讲述了php禁用函数设置及查看方法。分享给大家供大家参考,具体如下:
打开PHP.INI,找到这行:
disable_functions=
在后面那里加上要禁用的函数,如禁用多个函数,要用半角逗号,分开
给个例子:
disable_functions=passthru,exec,system,popen,chroot,scandir,chgrp,chown,escapesh ellcmd,escapeshellarg,shell_exec,proc_open,proc_get_status
建议在主机上禁用的函数:
disable_functions=system,exec,shell_exec,passthru,proc_open,proc_close,proc_get_status,checkdnsrr,getmxrr,getservbyname,getservbyport,syslog,popen,show_source,highlight_file,dl,socket_listen,socket_create,socket_bind,socket_accept,socket_connect,stream_socket_server,stream_socket_accept,stream_socket_client,ftp_connect,ftp_login,ftp_pasv,ftp_get,sys_getloadavg,disk_total_space,disk_free_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
在主机上面如何查看禁用的函数列表,我从网上找了一个非常不错的探针
<?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();
?>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Pragma"content="No-cache"/>
<metahttp-equiv="Expires"content="0"/>
<metahttp-equiv="cache-control"content="private"/>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>//加了这句,看看能不能解决linux下显示乱码的问题?
<title>PHP探针v1.0</title>
<styletype="text/css">
<!--
body{text-align:center;margin-top:20px;background-color:#a9b674;}
#overview{width:700px;margin:0auto;text-align:left;}
a{text-decoration:underline;color:#992700;}
.strong{color:#992700;}
.basew{width:300px;}
-->
</style>
</head>
<body>
<divid="overview">
<divid="copyright">版权信息
<ahref="hello.php?typ=baseinfo">[基本信息]</a><ahref="hello.php?typ=superinfo">[高级信息]</a>
<?php
if(function_exists("phpinfo")){
echo'<ahref="hello.php?typ=phpinfo">[phpinfo]</a>';}
echo'<br/>php探针v1.0byMKDuse(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();}
}
functiongetime()
{
$t=gettimeofday();
return(float)($t['sec']+$t['usec']/1000000);
}
functionbaseinfo(){
echo'<h1>基本信息</h1>';
$arr[]=array("CurrentPHPversion:",phpversion());
$arr[]=array("Zendengineversion:",zend_version());
$arr[]=array("服务器版本",$_SERVER['SERVER_SOFTWARE']);
$arr[]=array("ip地址",$_SERVER['REMOTE_HOST']);//ip
$arr[]=array("域名",$_SERVER['HTTP_HOST']);
$arr[]=array("协议端口",$_SERVER['SERVER_PROTOCOL'].''.$_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("ServerAPI",php_sapi_name());
$arr[]=array("error_reportinglevel",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><tdclass="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的机子(P41.5G256DDRwinxpsp2)</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'<trclass="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>';
?>
<scriptlanguage="javascript"type="text/javascript">
functiongettime()
{
vartime;
time=newDate();
returntime.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-->";}
?>
<pid="dk"></p>
<scriptlanguage="javascript"type='text/javascript'>
vartimea;
varnetspeed;
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($arras$value){
echo$value.'<br/>';}
echo'</div><h2>禁用的函数</h2><p>';
$disfun=ini_get('disable_functions');
if(empty($disfun)){
echo'没有禁用</p>';}
else{
echoini_get('disable_functions').'</p>';}
}//关闭
functionsuperinfo(){
echo'<h1>高级信息</h1><p>PHP_INI_USER1配置选项可用在用户的PHP脚本或Windows注册表中<br>PHP_INI_PERDIR2配置选项可在php.ini,.htaccess或httpd.conf中设置<br>PHP_INI_SYSTEM4配置选项可在php.iniorhttpd.conf中设置<br>PHP_INI_ALL7配置选项可在各处设置</p>';
$arr1=ini_get_all();
for($i=0;$i<count($arr1);$i++)
{
$arr2=array_slice($arr1,$i,1);
print_r($arr2);
echo'<br/>';
}
}
functionphpinfoview(){
phpinfo();
}
?>
</div>
</body>
</html>
更多关于PHP相关内容感兴趣的读者可查看本站专题:《php程序设计安全教程》、《php面向对象程序设计入门教程》、《PHP数学运算技巧总结》、《PHP数组(Array)操作技巧大全》、《php字符串(string)用法总结》、《PHP数据结构与算法教程》、《php程序设计算法总结》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。