php禁用函數設定及查看方法詳解_php技巧

來源:互聯網
上載者:User

本文執行個體講述了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

在主機上面如何查看禁用的函數列表,我從網上找了一個非常不錯的探針

<?phpheader("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><?phpif (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'].' '.$_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><?phpecho '<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><?phpecho'<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數組(Array)操作技巧大全》、《php字串(string)用法總結》、《PHP資料結構與演算法教程》、《php程式設計演算法總結》及《php常見資料庫操作技巧匯總》

希望本文所述對大家PHP程式設計有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.