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. ...