本文整理汇总了PHP中Filters::anti_sql_injection方法的典型用法代码示例。如果您正苦于以下问题:PHP Filters::anti_sql_injection方法的具体用法?PHP Filters::anti_sql_injection怎么用?PHP Filters::anti_sql_injection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filters
的用法示例。
在下文中一共展示了Filters::anti_sql_injection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AdminModel
<?php
require 'app/inc/autoload.php';
if (isset($_POST) && !empty($_POST)) {
$user = Filters::anti_sql_injection($_POST['user']);
$password = md5($_POST['password']);
$admin_model = new AdminModel();
$admin_model->setCond('user = "' . $user . '"');
$admin_model->setCond('password = "' . $password . '"');
$load = $admin_model->load();
if (!empty($load)) {
$_SESSION['id_admin'] = $load[0]['id'];
$_SESSION['user_admin'] = $load[0]['user'];
$_SESSION['password_admin'] = $load[0]['password'];
}
}
// Check login
if (isset($_SESSION['user_admin']) && isset($_SESSION['password_admin'])) {
header('location: index.php');
exit;
}
Template::getHeader();
?>
<div id="content">
<form method="post" name="login" action="login.php">
<div class="block_field">
<label for="user">User<label>
<input type="text" name="user" id="user" size="30" />
</div>
<div class="block_field">
<label for="password">Password<label>
示例2: getData
/**
* Get data para insercao
*/
public function getData()
{
// Deletando fields vazios
if (count($this->remove_empty)) {
foreach ($this->remove_empty as $field) {
if (array_key_exists($field, $this->data) && $this->data[$field] == '') {
$key = array_search($field, $this->fields);
unset($this->fields[$key]);
}
}
}
// Aplicando formatação aos valores
$values = array();
foreach ($this->fields as $field) {
if (array_key_exists($field, $this->data)) {
$treated_value = Filters::anti_sql_injection($this->data[$field]);
$treated_value = $this->strip_tags ? Filters::strip_tags($treated_value) : $treated_value;
if (array_key_exists($field, $this->_filters)) {
$filter = $this->_filters[$field];
$all_filters = get_class_methods('Filters');
if (function_exists($filter)) {
$treated_value = $filter($treated_value);
} else {
if (in_array($filter, get_class_methods($this))) {
$treated_value = $this->{$filter}($treated_value);
} else {
if (in_array($filter, $all_filters)) {
$treated_value = Filters::$filter($treated_value);
}
}
}
}
$values[$field] = '"' . $treated_value . '"';
} else {
$values[$field] = '""';
}
}
return $values;
}