当前位置: 首页>>代码示例>>PHP>>正文


PHP ESAPI::getHTTPUtilities方法代码示例

本文整理汇总了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);
开发者ID:najamelan,项目名称:PHP-ESAPI,代码行数:31,代码来源:ExtraTestsForHTTP.php

示例2: setUp

 /**
  * Constructor ensures global ESAPI is set and stores an instance of
  * DefaultHTTPUtilities.
  */
 protected function setUp()
 {
     $this->_httpUtils = ESAPI::getHTTPUtilities();
 }
开发者ID:najamelan,项目名称:PHP-ESAPI,代码行数:8,代码来源:HTTPUtilitiesTest.php


注:本文中的ESAPI::getHTTPUtilities方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。