Created
May 21, 2013 01:59
-
-
Save bols-blue/5617060 to your computer and use it in GitHub Desktop.
NetCommonsのRequestCheck内のリファラチェックを無効化するパッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** maple/filter/Filter_RequestCheck.class.php 2013-05-21 10:23:01.765957813 +0900 | |
--- maple/filter/old_Filter_RequestCheck.class.php 2013-05-21 09:47:56.538958483 +0900 | |
*************** | |
*** 92,99 **** | |
} | |
} else if ($this->_request->getMethod() == "POST" && isset($_FILES) && (0 < count($_FILES))) { | |
//ファイルアップロード処理の場合、リファラチェック | |
! if ($this->_refcheck()) { | |
! return; | |
} | |
} else { | |
//Default | |
--- 92,99 ---- | |
} | |
} else if ($this->_request->getMethod() == "POST" && isset($_FILES) && (0 < count($_FILES))) { | |
//ファイルアップロード処理の場合、リファラチェック | |
! if ($this->_refcheck()) { | |
! return; | |
} | |
} else { | |
//Default | |
*************** | |
*** 105,151 **** | |
if($pathList[$i] != "action" && $pathList[$i] != "view") { | |
//module名_action or module名_viewのどちらでもない場合、チェックしない | |
return; | |
! }else if ($this->_request->getMethod() == "POST" && $pathList[$i] == "action") { | |
! //登録処理の場合、リファラチェック | |
! if (isset($attributes["refcheck"]) && $attributes["refcheck"] == "none") { | |
! return; | |
! } | |
! if ($this->_refcheck()) { | |
! return; | |
} | |
! } else if($this->_request->getMethod() == "GET" && $pathList[$i] == "view"){ | |
! return; | |
! } | |
} | |
! //エラー | |
$errorList->add("RquestCheck_Error", sprintf(_REQUESTCHECK_FAILURE,CURRENT_URL)); | |
$errorList->setType(VALIDATE_ERROR_TYPE); //VALIDATE_ERRORとする | |
return; | |
! | |
} | |
! | |
/** | |
* リファラチェック | |
* @access private | |
*/ | |
function _refcheck() | |
{ | |
! if(true){ | |
! return true; | |
! }else{ | |
! $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; | |
! if ($ref != '' && strpos($ref, BASE_URL) === 0) { | |
! return true; | |
! } | |
! // httpsの場合 | |
! $ssl_base_url = preg_replace("/^http:\/\//i","https://", BASE_URL); | |
! if ($ref != '' && strpos($ref, $ssl_base_url) === 0) { | |
! return true; | |
! } | |
! return false; | |
! } | |
} | |
! | |
/** | |
* ポストフィルタ | |
* @access private | |
--- 105,147 ---- | |
if($pathList[$i] != "action" && $pathList[$i] != "view") { | |
//module名_action or module名_viewのどちらでもない場合、チェックしない | |
return; | |
! }else if ($this->_request->getMethod() == "POST" && $pathList[$i] == "action") { | |
! //登録処理の場合、リファラチェック | |
! if (isset($attributes["refcheck"]) && $attributes["refcheck"] == "none") { | |
! return; | |
! } | |
! if ($this->_refcheck()) { | |
! return; | |
} | |
! } else if($this->_request->getMethod() == "GET" && $pathList[$i] == "view"){ | |
! return; | |
! } | |
} | |
! //エラー | |
$errorList->add("RquestCheck_Error", sprintf(_REQUESTCHECK_FAILURE,CURRENT_URL)); | |
$errorList->setType(VALIDATE_ERROR_TYPE); //VALIDATE_ERRORとする | |
return; | |
! | |
} | |
! | |
/** | |
* リファラチェック | |
* @access private | |
*/ | |
function _refcheck() | |
{ | |
! $ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; | |
! if ($ref != '' && strpos($ref, BASE_URL) === 0) { | |
! return true; | |
! } | |
! // httpsの場合 | |
! $ssl_base_url = preg_replace("/^http:\/\//i","https://", BASE_URL); | |
! if ($ref != '' && strpos($ref, $ssl_base_url) === 0) { | |
! return true; | |
! } | |
! return false; | |
} | |
! | |
/** | |
* ポストフィルタ | |
* @access private |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment