php快速查找數(shù)據(jù)庫中惡意代碼的方法
來源:易賢網(wǎng) 閱讀:1302 次 日期:2015-04-03 10:15:41
溫馨提示:易賢網(wǎng)小編為您整理了“php快速查找數(shù)據(jù)庫中惡意代碼的方法”,方便廣大網(wǎng)友查閱!

本文實例講述了php快速查找數(shù)據(jù)庫中惡意代碼的方法。分享給大家供大家參考。具體如下:

  數(shù)據(jù)庫被輸入惡意代碼,為了保證你的數(shù)據(jù)庫的安全,你必須得小心去清理。有了下面一個超級方便的功能,即可快速清除數(shù)據(jù)庫惡意代碼。

function cleanInput($input) {

$search = array(

, // Strip out javascript

, // 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);

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機網(wǎng)站地址:php快速查找數(shù)據(jù)庫中惡意代碼的方法
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權(quán)所有:易賢網(wǎng)