当前位置:首页 > PHP教程 > php函数 > 列表

php禁用函数设置及查看方法的介绍(附示例)

发布:smiling 来源: PHP粉丝网  添加日期:2019-12-31 14:04:50 浏览: 评论:0 

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

这篇文章主要介绍了php禁用函数设置及查看方法,结合实例形式分析了php禁用函数的方法及使用php探针查看禁用函数信息的相关实现技巧,需要的朋友可以参考下

本文实例讲述了php禁用函数设置及查看方法。分享给大家供大家参考,具体如下:

打开PHP.INI,找到这行:

disable_functions =

在后面那里加上要禁用的函数,如禁用多个函数,要用半角逗号 , 分开

给个例子:

  1. disable_functions = passthru,exec,system,popen,chroot,scandir,chgrp,chown,escapesh 
  2.  
  3. 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

在主机上面如何查看禁用的函数列表,我从网上找了一个非常不错的探针:

  1. <?php 
  2.  
  3. header("content-Type: text/html; charset=utf-8"); 
  4.  
  5. header("Cache-Control: no-cache, must-revalidate"); 
  6.  
  7. header("Pragma: no-cache"); 
  8.  
  9. error_reporting(0); 
  10.  
  11. ob_end_flush(); 
  12.  
  13. ?> 
  14.  
  15. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  16.  
  17. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  18.  
  19. <html xmlns="http://www.w3.org/1999/xhtml"> 
  20.  
  21. <head> 
  22.  
  23. <meta http-equiv="Pragma" content="No-cache" /> 
  24.  
  25. <meta http-equiv="Expires" content="0" /> 
  26.  
  27. <meta http-equiv="cache-control" content="private" /> 
  28.  
  29. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />//加了这句,看看能不能解决linux下显示乱码的问题? 
  30.  
  31. <title>PHP 探针 v1.0</title> 
  32.  
  33. <style type="text/css"> 
  34.  
  35. <!-- 
  36.  
  37. body{text-align:center;margin-top:20px;background-color:#a9b674;} 
  38.  
  39. #overview{width:700px;margin:0 auto;text-align:left;} 
  40.  
  41. a{text-decoration:underline;color:#992700;} 
  42.  
  43. .strong{color:#992700;} 
  44.  
  45. .basew{width:300px;} 
  46.  
  47. --> 
  48.  
  49. </style> 
  50.  
  51. </head> 
  52.  
  53. <body> 
  54.  
  55. <div id="overview"> 
  56.  
  57. <div id="copyright">版权信息 
  58.  
  59. <a href="hello.php?typ=baseinfo">[基本信息]</a> <a href="hello.php?typ=superinfo">[高级信息]</a> 
  60.  
  61. <?php 
  62.  
  63. if (function_exists("phpinfo")){ 
  64.  
  65.   echo'<a href="hello.php?typ=phpinfo">[phpinfo]</a>';} 
  66.  
  67. echo'<br />php探针v1.0 by MKDuse(blueidea-id)<br /><br />此程序代码,可免费使用;但不得用于商业用途;完全转载或使用此代码,请保留版权信息;<br />欢迎指正错误提建议,QQ:122712355</div>'; 
  68.  
  69. if (emptyempty($_GET['typ'])){ 
  70.  
  71.   baseinfo();} 
  72.  
  73. else{ 
  74.  
  75. switch ($_GET['typ']){ 
  76.  
  77. case 'phpinfo': 
  78.  
  79. phpinfoview(); 
  80.  
  81. break; 
  82.  
  83. case 'superinfo': 
  84.  
  85. superinfo(); 
  86.  
  87. break; 
  88.  
  89. case 'baseinfo': 
  90.  
  91. baseinfo(); 
  92.  
  93. break; 
  94.  
  95. default: 
  96.  
  97. baseinfo();} 
  98.  
  99. } 
  100.  
  101. function getime() 
  102.  
  103. { 
  104.  
  105.  $t = gettimeofday(); 
  106.  
  107.  return (float)($t['sec'] + $t['usec']/1000000); 
  108.  
  109. } 
  110.  
  111. function baseinfo(){ 
  112.  
  113. echo '<h1>基本信息</h1>'; 
  114.  
  115. $arr[]=array("Current PHP version:",phpversion()); 
  116.  
  117. $arr[]=array("Zend engine version:",zend_version()); 
  118.  
  119. $arr[]=array("服务器版本",$_SERVER['SERVER_SOFTWARE']); 
  120.  
  121. $arr[]=array("ip地址",$_SERVER['REMOTE_HOST']);//ip 
  122.  
  123. $arr[]=array("域名",$_SERVER['HTTP_HOST']); 
  124.  
  125. $arr[]=array("协议端口",$_SERVER['SERVER_PROTOCOL'].' '.$_SERVER['SERVER_PORT']); 
  126.  
  127. $arr[]=array("站点根目录",$_SERVER['PATH_TRANSLATED']); 
  128.  
  129. $arr[]=array("服务器时间",date('Y年m月d日,H:i:s,D')); 
  130.  
  131. $arr[]=array("当前用户",get_current_user()); 
  132.  
  133. $arr[]=array("操作系统",php_uname('s').php_uname('r').php_uname('v')); 
  134.  
  135. $arr[]=array("include_path",ini_get('include_path')); 
  136.  
  137. $arr[]=array("Server API",php_sapi_name()); 
  138.  
  139. $arr[]=array("error_reporting level",ini_get("display_errors")); 
  140.  
  141. $arr[]=array("POST提交限制",ini_get('post_max_size')); 
  142.  
  143. $arr[]=array("upload_max_filesize",ini_get('upload_max_filesize')); 
  144.  
  145. $arr[]=array("脚本超时时间",ini_get('max_execution_time').'秒'); 
  146.  
  147. if (ini_get("safe_mode")==0){ 
  148.  
  149. $arr[]=array("PHP安全模式(Safe_mode)",'off');} 
  150.  
  151. else{ 
  152.  
  153. $arr[]=array("PHP安全模式(Safe_mode)",'on');} 
  154.  
  155. if (function_exists('memory_get_usage')){ 
  156.  
  157. $arr[]=array("memory_get_usage",ini_get('memory_get_usage'));} 
  158.  
  159. //$arr[]=array("可用空间",intval(diskfreespace('/')/(1024 * 1024))."M"); 
  160.  
  161. echo'<table>'; 
  162.  
  163. for($i=0;$i<count($arr);$i++) 
  164.  
  165. { 
  166.  
  167.   $overview='<tr><td class="basew">'.$arr[$i][0].'</td><td>'.$arr[$i][1].'</td></tr>'; 
  168.  
  169.   echo $overview; 
  170.  
  171. } 
  172.  
  173. echo'</table>'; 
  174.  
  175. echo '<h2>服务器性能测试</h2>'; 
  176.  
  177. echo'<table><tr><td>服务器</td><td>整数运算<br />50万次加法(1+1)</td><td>浮点运算<br />50万次平方根(3.14开方)</td></tr>'; 
  178.  
  179. echo'<tr><td>MKDuse的机子(P4 1.5G 256DDR winxp sp2)</td><td>465.08ms</td><td>466.66ms</td></tr>'; 
  180.  
  181. $time_start=getime(); 
  182.  
  183. for($i=0;$i<=500000;$i++); 
  184.  
  185. {$count=1+1;} 
  186.  
  187. $timea=round((getime()-$time_start)*1000,2); 
  188.  
  189. echo '<tr class="strong"><td>当前服务器</td><td>'.$timea.'ms</td>'; 
  190.  
  191. $time_start=getime(); 
  192.  
  193. for($i=0;$i<=500000;$i++); 
  194.  
  195. {sqrt(3.14);} 
  196.  
  197. $timea=round((getime()-$time_start)*1000,2); 
  198.  
  199. echo '<td>'.$timea.'ms</td></tr></table>'; 
  200.  
  201. ?> 
  202.  
  203. <script language="javascript" type="text/javascript"> 
  204.  
  205. function gettime() 
  206.  
  207. { 
  208.  
  209.  var time; 
  210.  
  211.  time=new Date(); 
  212.  
  213.  return time.getTime(); 
  214.  
  215. } 
  216.  
  217. start_time=gettime(); 
  218.  
  219. </script> 
  220.  
  221. <?php 
  222.  
  223. echo '<h2>带宽测试</h2>'; 
  224.  
  225. for ($i=0;$i<100;$i++){ 
  226.  
  227. print "<!--1234567890#########0#########0#########0#########0#########0#########0#########0#########012345-->";} 
  228.  
  229. ?> 
  230.  
  231. <p id="dk"></p> 
  232.  
  233. <script language="javascript" type='text/javascript'> 
  234.  
  235. var timea; 
  236.  
  237. var netspeed; 
  238.  
  239. timea=gettime()-start_time; 
  240.  
  241. netspeed=Math.round(10/timea*1000); 
  242.  
  243. document.getElementByIdx("dk").innerHTML="向客户端发送10KB数据,耗时"+timea+"ms<br />您与此服务器的连接速度为"+netspeed+"kb/s"; 
  244.  
  245. </script> 
  246.  
  247. <?php 
  248.  
  249. echo'<h2>已加载的扩展库(enable)</h2><div>'; 
  250.  
  251. $arr =get_loaded_extensions(); 
  252.  
  253. foreach($arr as $value){ 
  254.  
  255.   echo $value.'<br />';} 
  256.  
  257. echo'</div><h2>禁用的函数</h2><p>'; 
  258.  
  259. $disfun=ini_get('disable_functions'); 
  260.  
  261. if (emptyempty($disfun)){ 
  262.  
  263.   echo'没有禁用</p>';} 
  264.  
  265. else{ 
  266.  
  267. echo ini_get('disable_functions').'</p>';} 
  268.  
  269. }//关闭 
  270.  
  271. function superinfo(){ 
  272.  
  273. 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>'; 
  274.  
  275. $arr1=ini_get_all(); 
  276.  
  277. for ($i=0;$i<count($arr1);$i++) 
  278.  
  279.   { 
  280.  
  281. $arr2=array_slice($arr1,$i,1); 
  282.  
  283. print_r($arr2); 
  284.  
  285. echo '<br />'; 
  286.  
  287. } 
  288.  
  289. } 
  290.  
  291. function phpinfoview(){ 
  292.  
  293.   phpinfo(); 
  294.  
  295. } 
  296.  
  297. ?> 
  298.  
  299. </div> 
  300.  
  301. </body> 
  302.  
  303. </html> 

以上就是php禁用函数设置及查看方法的介绍(附示例)的详细内容。

Tags: php禁用函数

分享到: