本文整理汇总了PHP中filter_input_array函数的典型用法代码示例。如果您正苦于以下问题:PHP filter_input_array函数的具体用法?PHP filter_input_array怎么用?PHP filter_input_array使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filter_input_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sanitizePostFields
/**
* Cleans up our $_POST superglobal values by performing some basic
* validation checks on each input, clearing the global and re-assigning
* it to the scope of our class
*/
private function sanitizePostFields()
{
if (isset($_POST)) {
# Filter all $_POST values as strings
$this->post = filter_input_array(INPUT_POST, FILTER_SANITIZE_STRING);
# Check if the query_string was set and is not empty during POST
if (isset($this->post["query_string"]) && !empty(trim($this->post["query_string"]))) {
# encode any special characters
$query_string = htmlspecialchars($this->post["query_string"]);
# remove any html tags
$query_string = strip_tags($query_string);
# replace any non-alpha characters
$query_string = preg_replace('/[^\\p{L}\\p{N}\\s]/u', '', $query_string);
# reassign our query string to our own $post now that we've
# cleaned it
$this->post["query_string"] = $query_string;
# mark this task as done
$this->status = "OK";
}
# Check if the ref value was passed from our form and is not blank
# as we'll use this later as a session identifier
if ($this->status == "OK" && isset($this->post["ref"]) && !empty(trim($this->post["ref"]))) {
# Filter the ref value as an integer for convinience
$ref = filter_input(INPUT_POST, 'ref', FILTER_SANITIZE_NUMBER_INT);
# assign our ref to our property
$this->post["ref"] = $ref;
# mark this task as done
$this->status = "OK";
}
}
}
示例2: orbis_save_keychain_details
/**
* Save keychain details
*/
function orbis_save_keychain_details($post_id, $post)
{
// Doing autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
// Verify nonce
$nonce = filter_input(INPUT_POST, 'orbis_keychain_details_meta_box_nonce', FILTER_SANITIZE_STRING);
if (!wp_verify_nonce($nonce, 'orbis_save_keychain_details')) {
return;
}
// Check permissions
if (!($post->post_type == 'orbis_keychain' && current_user_can('edit_post', $post_id))) {
return;
}
// OK
$definition = array('_orbis_keychain_url' => FILTER_VALIDATE_URL, '_orbis_keychain_email' => FILTER_VALIDATE_EMAIL, '_orbis_keychain_username' => FILTER_SANITIZE_STRING, '_orbis_keychain_password' => FILTER_UNSAFE_RAW);
$data = wp_slash(filter_input_array(INPUT_POST, $definition));
// Pasword
$password_old = get_post_meta($post_id, '_orbis_keychain_password', true);
$password_new = $data['_orbis_keychain_password'];
foreach ($data as $key => $value) {
if (empty($value)) {
delete_post_meta($post_id, $key);
} else {
update_post_meta($post_id, $key, $value);
}
}
// Action
if ($post->post_status == 'publish' && !empty($password_old) && $password_old != $password_new) {
// @see https://github.com/woothemes/woocommerce/blob/v2.1.4/includes/class-wc-order.php#L1274
do_action('orbis_keychain_password_update', $post_id, $password_old, $password_new);
}
}
示例3: saveProcess
private function saveProcess()
{
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
View::setMessageFlash("danger", "Form tidak valid");
return FALSE;
}
// form validation
if (!filter_input(INPUT_POST, "form_token") || Form::isFormTokenValid(filter_input(INPUT_POST, "form_token"))) {
View::setMessageFlash("danger", "Form tidak valid");
return FALSE;
}
// required fields
$filter = array("name" => FILTER_SANITIZE_STRING, "phone" => FILTER_SANITIZE_STRING, "address" => FILTER_SANITIZE_STRING);
$input = filter_input_array(INPUT_POST, $filter);
if (in_array('', $input) || in_array(NULL, $input)) {
View::setMessageFlash("danger", "Kolom tidak boleh kosong");
return FALSE;
}
// set member object
$staff = Authentication::getUser();
$staff->setData('name', $input['name']);
$staff->setData('phone', $input['phone']);
$staff->setData('address', $input['address']);
if (!($update = $staff->update())) {
View::setMessageFlash("danger", "Penyimpanan Gagal");
return;
}
View::setMessageFlash("success", "Penyimpanan Berhasil");
}
示例4: __construct
public function __construct()
{
parent::__construct();
//Session Enabled
$this->checkLogin();
//Session Disabled
//define input filters
$filterArgs = array('exec' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH), 'key' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH), 'description' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH));
//filter input
$_postInput = filter_input_array(INPUT_POST, $filterArgs);
//assign variables
$this->exec = $_postInput['exec'];
$this->key = $_postInput['key'];
$this->description = $_postInput['description'];
//check for eventual errors on the input passed
$this->result['errors'] = array();
if (empty($this->key)) {
$this->result['errors'][] = array('code' => -2, 'message' => "Key missing");
}
if (array_search($this->exec, self::$allowed_exec) === false) {
$this->result['errors'][] = array('code' => -5, 'message' => "No method {$this->exec} allowed.");
}
//ONLY LOGGED USERS CAN PERFORM ACTIONS ON KEYS
if (!$this->userIsLogged) {
$this->result['errors'][] = array('code' => -1, 'message' => "Login is required to perform this action");
}
}
示例5: setDados
private function setDados()
{
$dto = new RelacionamentoParametroDTO();
$_POST = filter_input_array(INPUT_POST);
$dto->setCdCatgRelac1(Input::get('relac_1') ? 4 : null)->setCdCatgVlRelac1((int) Input::get('relac_1'))->setCdCatgRelac2(Input::get('relac_2') ? 4 : null)->setCdCatgVlRelac2((int) Input::get('relac_2'))->setCdUsuarioCriacao(Session::get('user'))->setDtUsuarioCriacao('now()')->setCdUsuarioAtualiza(Session::get('user'))->setDtUsuarioAtualiza('now()');
return $dto;
}
示例6: setDados
public function setDados()
{
$dto = new MoradorEnderecoDTO();
$_POST = filter_input_array(INPUT_POST);
$dto->setNrSequencia(Input::get('id_m_end'))->setCdPessoaFisica(Input::get('cd_pessoa_fisica'))->setCdApartamento(Input::get('m_end_apartamento'))->setDtEntrada(Input::get('m_end_dt_entrada'))->setDtSaida(Input::get('m_end_dt_saida'))->setFgResidente(Input::get('residente') == '' ? null : Input::get('residente'))->setCdUsuarioCriacao(Session::get('user'))->setDtUsuarioCriacao('now()')->setCdUsuarioAtualiza(Session::get('user'))->setDtUsuarioAtualiza('now()');
return $dto;
}
示例7: __construct
public function __construct()
{
parent::__construct();
$filterArgs = array('job' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'segment' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'jpassword' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW), 'err_typing' => array('filter' => FILTER_CALLBACK, 'options' => array("setRevisionController", "sanitizeFieldValue")), 'err_translation' => array('filter' => FILTER_CALLBACK, 'options' => array("setRevisionController", "sanitizeFieldValue")), 'err_terminology' => array('filter' => FILTER_CALLBACK, 'options' => array("setRevisionController", "sanitizeFieldValue")), 'err_language' => array('filter' => FILTER_CALLBACK, 'options' => array("setRevisionController", "sanitizeFieldValue")), 'err_style' => array('filter' => FILTER_CALLBACK, 'options' => array("setRevisionController", "sanitizeFieldValue")), 'original' => array('filter' => FILTER_UNSAFE_RAW));
$postInput = filter_input_array(INPUT_POST, $filterArgs);
$this->id_job = $postInput['job'];
$this->password_job = $postInput['jpassword'];
$this->id_segment = $postInput['segment'];
$this->err_typing = $postInput['err_typing'];
$this->err_translation = $postInput['err_translation'];
$this->err_terminology = $postInput['err_terminology'];
$this->err_language = $postInput['err_language'];
$this->err_style = $postInput['err_style'];
list($this->original_translation, $none) = CatUtils::parseSegmentSplit(CatUtils::view2rawxliff($postInput['original']), ' ');
Log::doLog($_POST);
if (empty($this->id_job)) {
$this->result['errors'][] = array('code' => -1, 'message' => 'Job ID missing');
}
if (empty($this->id_segment)) {
$this->result['errors'][] = array('code' => -2, 'message' => 'Segment ID missing');
}
if (empty($this->password_job)) {
$this->result['errors'][] = array('code' => -3, 'message' => 'Job password missing');
}
}
示例8: __construct
public function __construct()
{
//SESSION ENABLED
parent::sessionStart();
parent::__construct();
$filterArgs = array('page' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'step' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'project' => array('filter' => FILTER_SANITIZE_NUMBER_INT), 'filter' => array('filter' => FILTER_VALIDATE_BOOLEAN, 'options' => array(FILTER_NULL_ON_FAILURE)), 'pn' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW), 'source' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW), 'target' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW), 'status' => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_LOW), 'onlycompleted' => array('filter' => FILTER_VALIDATE_BOOLEAN, 'options' => array(FILTER_NULL_ON_FAILURE)));
$postInput = filter_input_array(INPUT_POST, $filterArgs);
// assigning default values
if (is_null($postInput['page']) || empty($postInput['page'])) {
$postInput['page'] = 1;
}
if (is_null($postInput['step']) || empty($postInput['step'])) {
$postInput['step'] = 25;
}
if (is_null($postInput['status']) || empty($postInput['status'])) {
$postInput['status'] = Constants_JobStatus::STATUS_ACTIVE;
}
$this->lang_handler = Langs_Languages::getInstance();
$this->page = (int) $postInput['page'];
$this->step = (int) $postInput['step'];
$this->project_id = $postInput['project'];
$this->filter_enabled = (int) $postInput['filter'];
$this->search_in_pname = (string) $postInput['pn'];
$this->search_source = (string) $postInput['source'];
$this->search_target = (string) $postInput['target'];
$this->search_status = (string) $postInput['status'];
$this->search_onlycompleted = $postInput['onlycompleted'];
}
示例9: execute
public function execute()
{
$config = $this->getConfig();
$formEntradaBodega = filter_input_array(INPUT_POST)['entradaBodega'];
$entradaBodega = new entradaSalidaBodegaTable($config);
$entradaBodega->setTipoDocumentoId($formEntradaBodega['tipo_documento_id']);
$entradaBodega->setTerceroIdElabora($formEntradaBodega['tercero_id_elabora']);
$entradaBodega->setTerceroIdSolicita($formEntradaBodega['tercero_id_solicita']);
$entradaBodega->setFecha($formEntradaBodega['fecha']);
$entradaBodega->setObservacion($formEntradaBodega['observacion']);
// $detalle = new detalleEntradaSalidaBodegaTable($config);
$cod_art = filter_input_array(INPUT_POST)['cod_art'];
$tpd = filter_input_array(INPUT_POST)['tpd'];
$unm = filter_input_array(INPUT_POST)['unm'];
$cant = filter_input_array(INPUT_POST)['cant'];
$precio = filter_input_array(INPUT_POST)['precio'];
$contador = filter_input_array(INPUT_POST)['cta_campos'];
$this->objEntradaBodega = $entradaBodega->save();
$id = $entradaBodega->consById();
for ($i = 0; $i < $contador; $i++) {
$detalleEntradaBodega = new detalleEntradaSalidaBodegaTable($config);
$detalleEntradaBodega->setEntradaSalidaBodegaId($id[0]->id);
$detalleEntradaBodega->setProductoId($cod_art[$i]);
$detalleEntradaBodega->setTpd_id(1);
$detalleEntradaBodega->setUnidadMedidaId($unm[$i]);
$detalleEntradaBodega->setCantidad($cant[$i]);
$detalleEntradaBodega->setPrecio($precio[$i]);
// Se guarda el registro en la tabla detalle
$this->ObjFactura = $detalleEntradaBodega->save();
}
header('Location: ' . $config->getUrl() . 'index.php/entradaBodega/index');
}
示例10: __construct
public function __construct()
{
$vars = filter_input_array(INPUT_GET, array('ftype' => FILTER_VALIDATE_INT, 'folder_id' => FILTER_VALIDATE_INT));
$this->ftype = $vars['ftype'];
$this->folder_id = $vars['folder_id'];
$this->loadFactory();
}
示例11: login
public function login()
{
$formKey = new $this->aReg->auth();
/** @todo create standard filters for inputs */
$post = filter_input_array(INPUT_POST);
if (!isset($post['form_key']) || !$formKey->validate()) {
// Form key error
header('Location: ' . AMS_SEO_URL . 'user/signin');
} else {
if (isset($post['email'], $post['password'])) {
$lp = $this->aReg->auth->login($post['email'], $post['password'], $this->aReg->db);
/**
* @todo login default actions
* example $lp = loginprocessed return..
* if($lp){$this->otherAction()}else{ $this->prime();}
*/
if ($lp) {
//no differnce between mobile and classic views but it could be done here.
if ($_SESSION['layoutType'] !== 'classic') {
header('Location: ' . AMS_SEO_URL . 'prime');
} else {
header('Location: ' . AMS_SEO_URL . 'prime');
}
} else {
$this->prime();
}
} else {
header('Location: ' . AMS_SEO_URL . 'user/signin');
}
}
}
示例12: execute
public function execute()
{
$config = $this->getConfig();
if (filter_has_var(INPUT_POST, 'seguridad') === TRUE) {
$user = filter_input_array(INPUT_POST)['seguridad']['user'];
$password = filter_input_array(INPUT_POST)['seguridad']['pass'];
$usuario = new usuarioTable($config);
$usuario->setUsuario($user);
$usuario->setPassword($password);
if ($usuario->verificarUsuario() === TRUE) {
$datoUsuario = $usuario->getDataByUserPassword();
if ($datoUsuario !== FALSE) {
$_SESSION['user']['id'] = $datoUsuario->id;
$_SESSION['user']['nombre'] = $datoUsuario->nombre;
header("Location:" . $config->getUrl() . "index.php");
exit;
} else {
throw new Exception('Ocurrio un error usuario no existente');
}
} else {
$_SESSION['usuarioInvalido'] = 'Datos de usuario son inválidos';
header("Location:" . $config->getUrl() . "index.php/home/loginUsuario");
exit;
}
}
header("Location:" . $config->getUrl() . "index.php");
exit;
}
示例13: pegaInformacao
function pegaInformacao($tipo_request)
{
switch ($tipo_request) {
case 'POST':
$t = filter_input_array(INPUT_POST);
break;
case 'GET':
$t = filter_input_array(INPUT_GET);
break;
case 'COOKIE':
$t = filter_input_array(INPUT_COOKIE);
break;
case 'ENV':
$t = filter_input_array(INPUT_ENV);
break;
case 'SESSION':
if (isset($_SESSION)) {
$t = $_SESSION;
}
break;
}
if (isset($t) && $t != '') {
$string_com_todos = '';
foreach ($t as $chave => $valor) {
global ${$chave};
${$chave} = $valor;
$string_com_todos .= $tipo_request . ' => ' . $chave . ': ' . $valor . "\n";
/* TESTE => */
//echo $tipo_request.' => '.$chave.': '.$valor." <br>\n";
}
/* TESTE => */
//echo '<script>alert("'.$string_com_todos.'")</script>';
}
}
示例14: __construct
/**
* Class Constructor
*
* @throws LogicException
*
*/
public function __construct()
{
if (empty($this->review_order_page)) {
throw new LogicException("Property 'review_order_page' can not be EMPTY");
}
if (empty($this->tokenName)) {
throw new LogicException("Property 'tokenName' can not be EMPTY");
}
//SESSION ENABLED
$this->sessionStart();
parent::__construct(false);
$filterArgs = array($this->tokenName => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH), $this->dataKeyName => array('filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH));
$__getInput = filter_input_array(INPUT_GET, $filterArgs);
/*
*
* Do something with Token ( send it for authentication on confirm )
*
* $__getInput['tk']
*
*/
$this->tokenAuth = $__getInput[$this->tokenName];
$this->data_key_content = $__getInput[$this->dataKeyName];
Log::doLog($_GET);
Log::doLog($_SERVER['QUERY_STRING']);
}
示例15: index
public function index()
{
if (null !== filter_input_array(INPUT_POST)) {
$post = filter_input_array(INPUT_POST);
self::logAuth($post);
}
}