網頁

2013年4月2日 星期二

wampserver php.ini

php.ini的變數設定詳解

錯誤記錄( error log)


php 內建就有記錄程式錯誤的功能,方便工程師 debug。
  • error_reporting = E_ALL : 指定哪些錯誤類型須要php記錄
    • E_ALL : 是指全部的 error 訊息都要記錄
    • E_ERROR: 嚴重錯誤,會使得程式當掉的才記錄下來
    • E_WARNING : warning 記錄下來
    • E_PARSE : 編譯錯誤記錄下來
    • E_NOTICE : 提醒工程師,可能會出錯的訊息
    • error_reporting = E_ERROR & E_WARNING :只記錄這兩種錯誤
    • error_reporting = E_ALL & ~E_NOTICE :除了 Notice以外的錯誤都記錄下來
  • display_errors = On
    • [On] : 在網頁顯示錯誤訊息,
如果打開這個功能,當程式發生錯誤時,user會立即在網頁上看到錯誤訊息,除了會讓user以為看到亂碼之外,還有安全性上的風險。
  • [Off] : 不在網頁上顯示錯誤訊息,
  • display_startup_errors
    • [On] : php 起始錯誤會記錄下來,如module載入失敗等等訊息。
    • [Off] : 建議關閉,預設也是關閉的
  • log_errors = On
    • [On] : 將錯誤訊息記錄在檔案裡。
    • [Off] : 關閉記錄錯誤訊息在檔案的功能。
  • log_errors_max_len = 1024 : log檔案的最大size
  • error_log = "/logs/error_log" :指定log的檔案名稱
  • ignore_repeated_errors : 同一個檔案,同一行,忽略重覆的錯誤訊息。
  • ignore_repeated_source : 當同一個錯誤,是執行在不同的檔案時産生,忽略此錯誤訊息。
  • report_memleaks = On : 記錄 memory leak (E_WARNING)
  • track_errors :將誤錯訊息存在變數 $php_errormsg


设置php.ini
1、PHP程序不能自动设置编码问题及解决方法
default_charset = "utf-8"

2、部署到WampServer页面出现( ! ) SCREAM: Error suppression ignored for错误及解决方法


PHP Notice: undefined index 完美解决方法

   $val = !empty($_GET[$str]) ? $_GET[$str] : null;


更改如下属性为:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE 
#error_reporting = E_ALL 

display_startup_errors = Off

ignore_repeated_errors = Off

ignore_repeated_source = Off

track_errors = Off

html_errors = Off

重启WampServer服务,就OK了




( ! ) Fatal error: Call to undefined function ldap_connect()

E:\wamp\bin\php\php5.4.12/php.ini

 ;extension=php_ldap.dll  #962 註解打開



如何修復網站與作業系統常見之漏洞與弱點


避免了 SQL Injection 之攻擊。


/etc/php.ini 有個參數:
  
; http://php.net/magic-quotes-gpc
magic_quotes_gpc = On

當啟用 magic_quotes_gpc 參數後,對於GET/POST 中使用者輸入之特殊字元,如單引號(')雙引號( " )、反斜線( \ ), 前面會自動再加上反斜線( \ ),此時即視同為字元。當 magic_quotes_gpc 功能開啟後,SQL 執行之語法已改變為:
SELECT * FROM admin where login='davis' and passwd='\' or \'a\'=\'a'














Session Cookie without HttpOnly flag set


Description
This session cookie doesn''t have the HTTPOnly flag set. When a cookie is set with the HTTPOnly flag, it instructs the browser that the cookie can only be accessed by the server and not by client-side scripts. This is an important security protection for session cookies.
Impact
None
Recommendation
If possible, you should set the HTTPOnly flag for this cookie.


Session Cookie without HttpOnly flag set
  
; Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript.
; http://php.net/session.cookie-httponly
session.cookie_httponly = true
Session Cookie without Secure flag set
  
; http://php.net/session.cookie-secure
session.cookie_secure = true

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。