搜索
首页后端开发php教程php禁用函数设置及查看方法的介绍(附示例)

本篇文章给大家带来的内容是关于php禁用函数设置及查看方法的介绍(附示例),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

这篇文章主要介绍了php禁用函数设置及查看方法,结合实例形式分析了php禁用函数的方法及使用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();
?>
<!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</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> <a href="hello.php?typ=superinfo">[高级信息]</a>
<?php
if (function_exists("phpinfo")){
  echo&#39;<a href="hello.php?typ=phpinfo">[phpinfo]</a>&#39;;}
echo&#39;<br />php探针v1.0 by MKDuse(blueidea-id)<br /><br />此程序代码,可免费使用;但不得用于商业用途;完全转载或使用此代码,请保留版权信息;<br />欢迎指正错误提建议,QQ:122712355</div>&#39;;
if (empty($_GET[&#39;typ&#39;])){
  baseinfo();}
else{
switch ($_GET[&#39;typ&#39;]){
case &#39;phpinfo&#39;:
phpinfoview();
break;
case &#39;superinfo&#39;:
superinfo();
break;
case &#39;baseinfo&#39;:
baseinfo();
break;
default:
baseinfo();}
}
function getime()
{
 $t = gettimeofday();
 return (float)($t[&#39;sec&#39;] + $t[&#39;usec&#39;]/1000000);
}
function baseinfo(){
echo &#39;<h1>基本信息</h1>&#39;;
$arr[]=array("Current PHP version:",phpversion());
$arr[]=array("Zend engine version:",zend_version());
$arr[]=array("服务器版本",$_SERVER[&#39;SERVER_SOFTWARE&#39;]);
$arr[]=array("ip地址",$_SERVER[&#39;REMOTE_HOST&#39;]);//ip
$arr[]=array("域名",$_SERVER[&#39;HTTP_HOST&#39;]);
$arr[]=array("协议端口",$_SERVER[&#39;SERVER_PROTOCOL&#39;].&#39; &#39;.$_SERVER[&#39;SERVER_PORT&#39;]);
$arr[]=array("站点根目录",$_SERVER[&#39;PATH_TRANSLATED&#39;]);
$arr[]=array("服务器时间",date(&#39;Y年m月d日,H:i:s,D&#39;));
$arr[]=array("当前用户",get_current_user());
$arr[]=array("操作系统",php_uname(&#39;s&#39;).php_uname(&#39;r&#39;).php_uname(&#39;v&#39;));
$arr[]=array("include_path",ini_get(&#39;include_path&#39;));
$arr[]=array("Server API",php_sapi_name());
$arr[]=array("error_reporting level",ini_get("display_errors"));
$arr[]=array("POST提交限制",ini_get(&#39;post_max_size&#39;));
$arr[]=array("upload_max_filesize",ini_get(&#39;upload_max_filesize&#39;));
$arr[]=array("脚本超时时间",ini_get(&#39;max_execution_time&#39;).&#39;秒&#39;);
if (ini_get("safe_mode")==0){
$arr[]=array("PHP安全模式(Safe_mode)",&#39;off&#39;);}
else{
$arr[]=array("PHP安全模式(Safe_mode)",&#39;on&#39;);}
if (function_exists(&#39;memory_get_usage&#39;)){
$arr[]=array("memory_get_usage",ini_get(&#39;memory_get_usage&#39;));}
//$arr[]=array("可用空间",intval(diskfreespace(&#39;/&#39;)/(1024 * 1024))."M");
echo&#39;<table>&#39;;
for($i=0;$i<count($arr);$i++)
{
  $overview=&#39;<tr><td class="basew">&#39;.$arr[$i][0].&#39;</td><td>&#39;.$arr[$i][1].&#39;</td></tr>&#39;;
  echo $overview;
}
echo&#39;</table>&#39;;
echo &#39;<h2>服务器性能测试</h2>&#39;;
echo&#39;<table><tr><td>服务器</td><td>整数运算<br />50万次加法(1+1)</td><td>浮点运算<br />50万次平方根(3.14开方)</td></tr>&#39;;
echo&#39;<tr><td>MKDuse的机子(P4 1.5G 256DDR winxp sp2)</td><td>465.08ms</td><td>466.66ms</td></tr>&#39;;
$time_start=getime();
for($i=0;$i<=500000;$i++);
{$count=1+1;}
$timea=round((getime()-$time_start)*1000,2);
echo &#39;<tr class="strong"><td>当前服务器</td><td>&#39;.$timea.&#39;ms</td>&#39;;
$time_start=getime();
for($i=0;$i<=500000;$i++);
{sqrt(3.14);}
$timea=round((getime()-$time_start)*1000,2);
echo &#39;<td>&#39;.$timea.&#39;ms</td></tr></table>&#39;;
?>
<script language="javascript" type="text/javascript">
function gettime()
{
 var time;
 time=new Date();
 return time.getTime();
}
start_time=gettime();
</script>
<?php
echo &#39;<h2>带宽测试</h2>&#39;;
for ($i=0;$i<100;$i++){
print "<!--1234567890#########0#########0#########0#########0#########0#########0#########0#########012345-->";}
?>
<p id="dk"></p>
<script language="javascript" type=&#39;text/javascript&#39;>
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&#39;<h2>已加载的扩展库(enable)</h2><div>&#39;;
$arr =get_loaded_extensions();
foreach($arr as $value){
  echo $value.&#39;<br />&#39;;}
echo&#39;</div><h2>禁用的函数</h2><p>&#39;;
$disfun=ini_get(&#39;disable_functions&#39;);
if (empty($disfun)){
  echo&#39;没有禁用</p>&#39;;}
else{
echo ini_get(&#39;disable_functions&#39;).&#39;</p>&#39;;}
}//关闭
function superinfo(){
echo&#39;<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>&#39;;
$arr1=ini_get_all();
for ($i=0;$i<count($arr1);$i++)
  {
$arr2=array_slice($arr1,$i,1);
print_r($arr2);
echo &#39;<br />&#39;;
}
}
function phpinfoview(){
  phpinfo();
}
?>
</div>
</body>
</html>

以上是php禁用函数设置及查看方法的介绍(附示例)的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文转载于:博客园。如有侵权,请联系admin@php.cn删除
您如何防止与会议有关的跨站点脚本(XSS)攻击?您如何防止与会议有关的跨站点脚本(XSS)攻击?Apr 23, 2025 am 12:16 AM

要保护应用免受与会话相关的XSS攻击,需采取以下措施:1.设置HttpOnly和Secure标志保护会话cookie。2.对所有用户输入进行输出编码。3.实施内容安全策略(CSP)限制脚本来源。通过这些策略,可以有效防护会话相关的XSS攻击,确保用户数据安全。

您如何优化PHP会话性能?您如何优化PHP会话性能?Apr 23, 2025 am 12:13 AM

优化PHP会话性能的方法包括:1.延迟会话启动,2.使用数据库存储会话,3.压缩会话数据,4.管理会话生命周期,5.实现会话共享。这些策略能显着提升应用在高并发环境下的效率。

什么是session.gc_maxlifetime配置设置?什么是session.gc_maxlifetime配置设置?Apr 23, 2025 am 12:10 AM

thesession.gc_maxlifetimesettinginphpdeterminesthelifespanofsessiondata,setInSeconds.1)它'sconfiguredinphp.iniorviaini_set().2)abalanceIsiseededeedeedeedeedeedeedto to to avoidperformance andununununununexpectedLogOgouts.3)

您如何在PHP中配置会话名?您如何在PHP中配置会话名?Apr 23, 2025 am 12:08 AM

在PHP中,可以使用session_name()函数配置会话名称。具体步骤如下:1.使用session_name()函数设置会话名称,例如session_name("my_session")。2.在设置会话名称后,调用session_start()启动会话。配置会话名称可以避免多应用间的会话数据冲突,并增强安全性,但需注意会话名称的唯一性、安全性、长度和设置时机。

您应该多久再生一次会话ID?您应该多久再生一次会话ID?Apr 23, 2025 am 12:03 AM

会话ID应在登录时、敏感操作前和每30分钟定期重新生成。1.登录时重新生成会话ID可防会话固定攻击。2.敏感操作前重新生成提高安全性。3.定期重新生成降低长期利用风险,但需权衡用户体验。

如何在PHP中设置会话cookie参数?如何在PHP中设置会话cookie参数?Apr 22, 2025 pm 05:33 PM

在PHP中设置会话cookie参数可以通过session_set_cookie_params()函数实现。1)使用该函数设置参数,如过期时间、路径、域名、安全标志等;2)调用session_start()使参数生效;3)根据需求动态调整参数,如用户登录状态;4)注意设置secure和httponly标志以提升安全性。

在PHP中使用会议的主要目的是什么?在PHP中使用会议的主要目的是什么?Apr 22, 2025 pm 05:25 PM

在PHP中使用会话的主要目的是维护用户在不同页面之间的状态。1)会话通过session_start()函数启动,创建唯一会话ID并存储在用户cookie中。2)会话数据保存在服务器上,允许在不同请求间传递数据,如登录状态和购物车内容。

您如何在子域中分享会议?您如何在子域中分享会议?Apr 22, 2025 pm 05:21 PM

如何在子域名间共享会话?通过设置通用域名的会话cookie实现。1.在服务器端设置会话cookie的域为.example.com。2.选择合适的会话存储方式,如内存、数据库或分布式缓存。3.通过cookie传递会话ID,服务器根据ID检索和更新会话数据。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

Dreamweaver Mac版

Dreamweaver Mac版

视觉化网页开发工具

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中