本文整理匯總了PHP中Csrf::cleanRequestURI方法的典型用法代碼示例。如果您正苦於以下問題:PHP Csrf::cleanRequestURI方法的具體用法?PHP Csrf::cleanRequestURI怎麽用?PHP Csrf::cleanRequestURI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Csrf
的用法示例。
在下文中一共展示了Csrf::cleanRequestURI方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: cleanRequestURI
if ($objFWUser->objUser->login($backend)) {
return true;
}
}
return false;
}
/**
* Remove the CSRF protection parameter from the query string and referrer
*/
public static function cleanRequestURI()
{
// This will remove the parameter from the first position in the query string
// and leave an URI like "index.php&name=value", which is invalid
//$csrfUrlModifierPattern = '#(?:\&(?:amp\;)?|\?)?'.self::$formkey.'\=[a-zA-Z0-9_]+#';
// Better cut the parameter plus trailing ampersand, if any.
$csrfUrlModifierPattern = '/' . self::$formkey . '\\=[a-zA-Z0-9_]+\\&?/';
// This will leave the URI valid, even if it's the last parameter;
// a trailing question mark or ampersand does no harm.
!empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] = preg_replace($csrfUrlModifierPattern, '', $_SERVER['QUERY_STRING']) : false;
!empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] = preg_replace($csrfUrlModifierPattern, '', $_SERVER['REQUEST_URI']) : false;
!empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] = preg_replace($csrfUrlModifierPattern, '', $_SERVER['HTTP_REFERER']) : false;
!empty($_SERVER['argv']) ? $_SERVER['argv'] = preg_grep($csrfUrlModifierPattern, $_SERVER['argv'], PREG_GREP_INVERT) : false;
}
public static function setFrontendMode()
{
self::$frontend_mode = true;
@ini_set('url_rewriter.tags', 'area=href,frame=src,iframe=src,input=src,form=,fieldset=');
}
}
Csrf::cleanRequestURI();