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


PHP InputFilter::safeSQL方法代碼示例

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


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

示例1: testSafeSQL

 /**
  *  Test saveSQL()
  *  @todo Figure out problem w/ mysql_real_escape_string()
  *  @todo Figure out how to test with magic quotes either on or off
  */
 public function testSafeSQL()
 {
     $rs = mysql_connect();
     if ($rs == false) {
         PHPUnit2_Framework_Assert::fail("InputFilterTest:" . " unable to open a connction to MySQL");
     }
     //  Trivial case, nothing to clean
     $this->assertEquals(InputFilter::safeSQL('foo', $rs), 'foo');
     $this->assertEquals(InputFilter::safeSQL(array('foo', 'bar'), $rs), array('foo', 'bar'));
     if (get_magic_quotes_gpc()) {
         // verify stripping of magic quotes
         //  FIXME: figure out how to test this case
         $this->assertEquals(InputFilter::safeSQL('a\\\'b\\"c\\\\d\\\\x00e\\\\nf\\\\rg\\\\x1a', $rs), 'a\\\'b\\"c\\\\d\\\\x00e\\\\nf\\\\rg\\\\x1a');
     } else {
         // verify magic quotes aren't there
         $pattern = "a'b\"c\\de\nf\rgh";
         $non_zero_pattern = "a'b\"c\\de\nf\rgh";
         $quoted_pattern = "a\\'b\\\"c\\\\de\\\nf\\\rg\\h";
         $quoted_non_zero_pattern = "a\\'b\\\"c\\\\de\\\nf\\\rg\\h";
         //            echo "\nIf this fails it means mysql_real_escape_string() is broken: ";
         //            $this->assertEquals(mysql_real_escape_string($non_zero_pattern),
         //                                $quoted_non_zero_pattern);
         //            echo "\nIf this fails it means mysql_real_escape_string() is broken: ";
         //            $this->assertEquals(mysql_real_escape_string($pattern),
         //                                $quoted_pattern);
         //            $this->assertEquals(
         //                   InputFilter::safeSQL($pattern,$rs),$quoted_pattern);
     }
     // Remove the following line when you complete this test.
     throw new PHPUnit2_Framework_IncompleteTestError();
 }
開發者ID:phpontrax,項目名稱:trax,代碼行數:36,代碼來源:InputFilterTest.php

示例2: ValidateSQL

 public function ValidateSQL($sql, $db)
 {
     $data = new InputFilter();
     $data->sql = $data->safeSQL($sql, $db);
     return $data->sql;
 }
開發者ID:brahimmachkouri,項目名稱:phpDHCPAdmin,代碼行數:6,代碼來源:class.validation.php

示例3: die

 }
 require_once DIR_WS_INCLUDES . 'database_tables.php';
 require_once DIR_FS_INC . 'xtc_db_connect.inc.php';
 require_once DIR_FS_INC . 'xtc_db_close.inc.php';
 require_once DIR_FS_INC . 'xtc_db_error.inc.php';
 require_once DIR_FS_INC . 'xtc_db_query.inc.php';
 require_once DIR_FS_INC . 'xtc_not_null.inc.php';
 require_once DIR_FS_INC . 'xtc_db_fetch_array.inc.php';
 require_once DIR_FS_INC . 'xtc_db_input.inc.php';
 require_once DIR_FS_INC . 'xtc_validate_password.inc.php';
 require_once DIR_WS_CLASSES . 'class.inputfilter.php';
 xtc_db_connect() or die('Unable to connect to database server!');
 //$_POST security
 $InputFilter = new InputFilter();
 $_POST = $InputFilter->process($_POST);
 $_POST = $InputFilter->safeSQL($_POST);
 $check_customer_query = xtc_db_query('
                                    SELECT customers_id,
                                           customers_password,
                                           customers_email_address
                                      FROM ' . TABLE_CUSTOMERS . '
                                     WHERE customers_email_address = "' . xtc_db_input($_POST['email_address']) . '"
                                       AND customers_status = 0');
 $check_customer = xtc_db_fetch_array($check_customer_query);
 if (!xtc_validate_password(xtc_db_input($_POST['password']), $check_customer['customers_password'], $check_customer['customers_email_address'])) {
     die('Zugriff verweigert. E-Mail und/oder Passwort falsch!');
 } else {
     if (isset($_POST['repair']) && xtc_not_null($_POST['repair'])) {
         //repair options
         switch ($_POST['repair']) {
             // turn off SEO friendy URLs
開發者ID:shophelfer,項目名稱:shophelfer.com-shop,代碼行數:31,代碼來源:login_admin.php

示例4: InputFilter

}
// if gzip_compression is enabled and gzip_off is not set, start to buffer the output
if ((!isset($gzip_off) || !$gzip_off) && GZIP_COMPRESSION == 'true' && ($ext_zlib_loaded = extension_loaded('zlib')) && PHP_VERSION >= '4') {
    if (($ini_zlib_output_compression = (int) ini_get('zlib.output_compression')) < 1) {
        ob_start('ob_gzhandler');
    } else {
        ini_set('zlib.output_compression_level', GZIP_LEVEL);
    }
}
// security inputfilter for GET/POST/COOKIE
require DIR_WS_CLASSES . 'class.inputfilter.php';
$InputFilter = new InputFilter();
$_GET = $InputFilter->process($_GET);
$_POST = $InputFilter->process($_POST);
$_REQUEST = $InputFilter->process($_REQUEST);
$_GET = $InputFilter->safeSQL($_GET, $link);
$_POST = $InputFilter->safeSQL($_POST, $link);
$_REQUEST = $InputFilter->safeSQL($_REQUEST, $link);
// set the top level domains
$http_domain = xtc_get_top_level_domain(HTTP_SERVER);
$https_domain = xtc_get_top_level_domain(HTTPS_SERVER);
$current_domain = $request_type == 'NONSSL' ? $http_domain : $https_domain;
// include shopping cart class
require DIR_WS_CLASSES . 'shopping_cart.php';
// include navigation history class
require DIR_WS_CLASSES . 'navigation_history.php';
// some code to solve compatibility issues
require DIR_WS_FUNCTIONS . 'compatibility.php';
// define how the session functions will be used
require DIR_WS_FUNCTIONS . 'sessions.php';
// set the session name and save path
開發者ID:shophelfer,項目名稱:shophelfer.com-shop,代碼行數:31,代碼來源:application_top.php


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