mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 00:45:34 +00:00
- allow to check forms with GET Request
This commit is contained in:
parent
2a11ab47bc
commit
07b7578190
|
@ -313,15 +313,26 @@ function createHiddenFieldWithKey($formid='') { /* {{{ */
|
|||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Check if the form key in the POST variable 'formtoken' has the value
|
||||
* of key returned by createFormKey()
|
||||
* Check if the form key in the POST or GET request variable 'formtoken'
|
||||
* has the value of key returned by createFormKey(). Request to modify
|
||||
* data in the DMS should always use POST because it is harder to run
|
||||
* CSRF attacks using POST than GET.
|
||||
*
|
||||
* @param string $formid individual form identifier
|
||||
* @param string $method defines if the form data is pass via GET or
|
||||
* POST (default)
|
||||
* @return boolean true if key matches otherwise false
|
||||
*/
|
||||
function checkFormKey($formid='') { /* {{{ */
|
||||
if(isset($_POST['formtoken']) && $_POST['formtoken'] == createFormKey($formid))
|
||||
return true;
|
||||
function checkFormKey($formid='', $method='POST') { /* {{{ */
|
||||
switch($method) {
|
||||
case 'GET':
|
||||
if(isset($_GET['formtoken']) && $_GET['formtoken'] == createFormKey($formid))
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
if(isset($_POST['formtoken']) && $_POST['formtoken'] == createFormKey($formid))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* }}} */
|
||||
|
|
Loading…
Reference in New Issue
Block a user