设为首页 收藏本站
查看: 689|回复: 0

[经验分享] 禁用php函数的设置

[复制链接]

尚未签到

发表于 2015-8-26 12:08:08 | 显示全部楼层 |阅读模式
打开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(&quot;content-Type: text/html; charset=utf-8&quot;);
header(&quot;Cache-Control: no-cache, must-revalidate&quot;);  
header(&quot;Pragma: no-cache&quot;);
error_reporting(0);
ob_end_flush();
?>
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>
<html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;>
<head>
<meta http-equiv=&quot;Pragma&quot; content=&quot;No-cache&quot; />
<meta http-equiv=&quot;Expires&quot; content=&quot;0&quot; />
<meta http-equiv=&quot;cache-control&quot; content=&quot;private&quot; />
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; />//加了这句,看看能不能解决linux下显示乱码的问题?
<title>PHP 探针 v1.0</title>
<style type=&quot;text/css&quot;>
<!--
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=&quot;overview&quot;>
<div id=&quot;copyright&quot;>版权信息
<a href=&quot;hello.php?typ=baseinfo&quot;>[基本信息]</a> <a href=&quot;hello.php?typ=superinfo&quot;>[高级信息]</a>
<?php
if (function_exists(&quot;phpinfo&quot;)){
echo'<a href=&quot;hello.php?typ=phpinfo&quot;>[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(&quot;Current PHP version:&quot;,phpversion());
$arr[]=array(&quot;Zend engine version:&quot;,zend_version());
$arr[]=array(&quot;服务器版本&quot;,$_SERVER['SERVER_SOFTWARE']);
$arr[]=array(&quot;ip地址&quot;,$_SERVER['REMOTE_HOST']);//ip
$arr[]=array(&quot;域名&quot;,$_SERVER['HTTP_HOST']);
$arr[]=array(&quot;协议端口&quot;,$_SERVER['SERVER_PROTOCOL'].'  '.$_SERVER['SERVER_PORT']);
$arr[]=array(&quot;站点根目录&quot;,$_SERVER['PATH_TRANSLATED']);
$arr[]=array(&quot;服务器时间&quot;,date('Y年m月d日,H:i:s,D'));
$arr[]=array(&quot;当前用户&quot;,get_current_user());
$arr[]=array(&quot;操作系统&quot;,php_uname('s').php_uname('r').php_uname('v'));
$arr[]=array(&quot;include_path&quot;,ini_get('include_path'));
$arr[]=array(&quot;Server API&quot;,php_sapi_name());
$arr[]=array(&quot;error_reporting level&quot;,ini_get(&quot;display_errors&quot;));
$arr[]=array(&quot;POST提交限制&quot;,ini_get('post_max_size'));
$arr[]=array(&quot;upload_max_filesize&quot;,ini_get('upload_max_filesize'));
$arr[]=array(&quot;脚本超时时间&quot;,ini_get('max_execution_time').'秒');
if (ini_get(&quot;safe_mode&quot;)==0){
$arr[]=array(&quot;PHP安全模式(Safe_mode)&quot;,'off');}
else{
$arr[]=array(&quot;PHP安全模式(Safe_mode)&quot;,'on');}
if (function_exists('memory_get_usage')){
$arr[]=array(&quot;memory_get_usage&quot;,ini_get('memory_get_usage'));}
//$arr[]=array(&quot;可用空间&quot;,intval(diskfreespace('/')/(1024 * 1024)).&quot;M&quot;);
echo'<table>';
for($i=0;$i<count($arr);$i++)
{
$overview='<tr><td class=&quot;basew&quot;>'.$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=&quot;strong&quot;><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=&quot;javascript&quot; type=&quot;text/javascript&quot;>
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 &quot;<!--1234567890#########0#########0#########0#########0#########0#########0#########0#########012345-->&quot;;}
?>
<p id=&quot;dk&quot;></p>
<script language=&quot;javascript&quot; type='text/javascript'>
var timea;
var netspeed;
timea=gettime()-start_time;
netspeed=Math.round(10/timea*1000);
document.getElementByIdx(&quot;dk&quot;).innerHTML=&quot;向客户端发送10KB数据,耗时&quot;+timea+&quot;ms<br />您与此服务器的连接速度为&quot;+netspeed+&quot;kb/s&quot;;
</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>



  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-104446-1-1.html 上篇帖子: Fastcgi介绍和php中fastcgi的应用 下篇帖子: 设置局域网PHP环境IP访问
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表