PHP Quick Find malicious code in the database method, quickly find malicious code _php Tutorial

Source: Internet
Author: User

PHP Quick Find malicious code in the database method, quickly find malicious code


The examples in this article describe how PHP quickly finds malicious code in a database. Share to everyone for your reference. Specific as follows:

The database is entered into malicious code, in order to keep your database secure, you have to be careful to clean up. With the following super-convenient feature, you can quickly clear the database of malicious code.

function CleanInput ($input) {$search = array (  ' @]*?>.*? @si ',//Strip out JavaScript  ' @<[\/\!] *? [^<>]*?> @si ',//Strip out HTML tags  ' @]*?>.*? @siU ',//Strip style tags properly  ' @@ '//Strip multi- Line comments);  $output = Preg_replace ($search, ", $input);  return $output; }function sanitize ($input) {  if (Is_array ($input)) {    foreach ($input as $var = $val) {      $output [$var] = Sanitize ($val);    }  }  else {    if (GET_MAGIC_QUOTES_GPC ()) {      $input = stripslashes ($input);    }    $input = CleanInput ($input);    $output = mysql_real_escape_string ($input);  }  return $output;} Usage: $bad _string = "hi! It ' s a good day! "; $good _string = sanitize ($bad _string);//$good _string returns "hi! It\ ' s a good day! " Also use for getting post/get Variables$_post = sanitize ($_post); $_get = sanitize ($_get);

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/977793.html www.bkjia.com true http://www.bkjia.com/PHPjc/977793.html techarticle PHP Quick Way to find malicious code in the database, quickly find malicious code This article describes how PHP quickly finds malicious code in a database. Share to everyone for your reference. ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.