search
HomePHP LibrariesOther librariesPHP security, anti-injection class
PHP security, anti-injection class
<?php
class Params
{
  public $get = array();
  public $post = array();
  function __construct()
  {
    if (!empty($_GET)) {
      foreach ($_GET as $key => $val) {
        if (is_numeric($val)) {
          $this->get[$key] = $this->getInt($val);
        } else {
          $this->get[$key] = $this->getStr($val);
        }
      }
    }
    if (!empty($_POST)) {
      foreach ($_POST as $key => $val) {
        if (is_numeric($val)) {
          $this->post[$key] = $this->getInt($val);
        } else {
          $this->post[$key] = $this->getStr($val);
        }
      }
    }
  }

This is a PHP security library that uses prepared statements and parameterized queries. SQL statements with any parameters will be sent to the database server and parsed! It is impossible for an attacker to maliciously inject SQL!

Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

PHP anti-injection configuration and php anti-injection code_PHP tutorialPHP anti-injection configuration and php anti-injection code_PHP tutorial

13Jul2016

PHP anti-injection configuration and PHP anti-injection code. There are two types of anti-injection in php. One is sql anti-injection. The other is a process like many cms. All the variables are submitted. The other is to configure php.ini directly. I will tell you respectively below.

PHP anti-sql injection class (php pdo prevents sql injection class)PHP anti-sql injection class (php pdo prevents sql injection class)

25Jul2016

PHP anti-sql injection class (php pdo prevents sql injection class)

PHP anti-injection security code_PHP tutorialPHP anti-injection security code_PHP tutorial

21Jul2016

PHP anti-injection security code. Brief description: /**************************** Description: Determine whether the passed variables contain illegal characters such as $_POST, $_GET Function: Anti-injection ******************************/ Copy the code code as follows

PHP anti-injection security implementation program code_PHP tutorialPHP anti-injection security implementation program code_PHP tutorial

13Jul2016

PHP anti-injection security implementation code. I have talked about a lot of SQL injection prevention codes before, but we still have to start with our server script. Let’s talk about some common methods of preventing injection in PHP. You can refer to it.

PHP Security - Session InjectionPHP Security - Session Injection

20Feb2017

Session Injection A similar problem to session exposure is session injection. This type of attack is based on your WEB server not only having read permissions to the session storage directory, but also having write permissions. Therefore, it is possible to write a paragraph that allows other users to add...

See all articles