當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ESAPI::setValidator方法代碼示例

本文整理匯總了PHP中ESAPI::setValidator方法的典型用法代碼示例。如果您正苦於以下問題:PHP ESAPI::setValidator方法的具體用法?PHP ESAPI::setValidator怎麽用?PHP ESAPI::setValidator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ESAPI的用法示例。


在下文中一共展示了ESAPI::setValidator方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 function __construct()
 {
     //The xml file is in its insecure default location.
     //We would normally have all referenced libraries outside of the webroot.
     $this->esapi = new ESAPI('../owasp-esapi-php-read-only/test/testresources/ESAPI.xml');
     ESAPI::setEncoder(new DefaultEncoder());
     ESAPI::setValidator(new DefaultValidator());
     $this->encoder = ESAPI::getEncoder();
     $this->validator = ESAPI::getValidator();
 }
開發者ID:bradchesney79,項目名稱:PHP-OWASP-ESAPI-Canonicalization-Demo,代碼行數:10,代碼來源:user.php

示例2: ESAPI

AUTHORS SPECIFICALLY DISCLAIM ANY WARRANTIES INCLUDING, BUT NOT

LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A

PARTICULAR PURPOSE, AND NON-INFRINGEMENT.


THE SOFTWARE IS PROVIDED ON AN "AS-IS" BASIS AND AUTHORS HAVE NO

OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR

MODIFICATIONS.*/
$tainted = $_SESSION['UserData'];
$ESAPI = new ESAPI();
ESAPI::setEncoder(new DefaultEncoder());
ESAPI::setValidator(new DefaultValidator());
//verifying the data with ESAPI
if ($ESAPI->validator->isValidNumber("Course ID", $tainted, 18, 25, false)) {
    $tainted = $tainted;
} else {
    $tainted = 0;
    //default value
}
$query = "SELECT * FROM COURSE WHERE id=?";
$conn = mysql_connect('localhost', 'mysql_user', 'mysql_password');
//Connection to the database (address, user, password)
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $checked_data);
$stmt->execute();
mysql_close($conn);
開發者ID:stivalet,項目名稱:PHP-Vulnerability-test-suite,代碼行數:30,代碼來源:CWE_862_SQL__SESSION__ESAPI__prepared_query-no_right_verification.php


注:本文中的ESAPI::setValidator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。