本文整理汇总了PHP中ESAPI::getHTTPUtilities方法的典型用法代码示例。如果您正苦于以下问题:PHP ESAPI::getHTTPUtilities方法的具体用法?PHP ESAPI::getHTTPUtilities怎么用?PHP ESAPI::getHTTPUtilities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ESAPI
的用法示例。
在下文中一共展示了ESAPI::getHTTPUtilities方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exit
//Make sure to run this script as a "PHP Web Page"
if (php_sapi_name() === 'cli') {
exit('ERROR: This script must be run from the browser.' . PHP_EOL);
}
$ESAPI = new ESAPI(__DIR__ . "/testresources/ESAPI.xml");
ob_start();
session_start();
$view = '';
$tests = null;
if (isset($_SESSION) && isset($_SESSION['tests'])) {
$tests =& $_SESSION['tests'];
} else {
$tests = array('csi' => 'changeSessionIdentifier', 'token' => 'verifyCSRFToken', 'cookie' => 'killAllCookies (incl. killCookie)', 'log' => 'logHTTPRequest', 'logo' => 'logHTTPRequestObfuscate');
$_SESSION['tests'] =& $tests;
}
$util = ESAPI::getHTTPUtilities();
$req = new SafeRequest();
$uri = ESAPI::getEncoder()->encodeForHTML($req->getRequestURI());
if ($req->getParameter('req') == 'test1') {
try {
$util->verifyCSRFToken($req);
$view .= '<p>Your Request contained the CSRF token we have in your session. Good!</p>';
} catch (IntrusionException $e) {
$view .= '<p>Your Request did NOT contain the CSRF token we have in your session. Did you tamper??</p>';
}
$tests['token'] .= ' - DONE';
$oldSessID = session_id();
$sr = $util->changeSessionIdentifier();
if ($sr === true) {
$view .= '<p>Your session was regenerated. ID went from: ';
$view .= ESAPI::getEncoder()->encodeForHTML($oldSessID);
示例2: setUp
/**
* Constructor ensures global ESAPI is set and stores an instance of
* DefaultHTTPUtilities.
*/
protected function setUp()
{
$this->_httpUtils = ESAPI::getHTTPUtilities();
}