溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

php如何快速查找數(shù)據(jù)庫(kù)中惡意代碼

發(fā)布時(shí)間:2021-09-02 11:43:18 來源:億速云 閱讀:143 作者:小新 欄目:開發(fā)技術(shù)

這篇文章主要為大家展示了“php如何快速查找數(shù)據(jù)庫(kù)中惡意代碼”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“php如何快速查找數(shù)據(jù)庫(kù)中惡意代碼”這篇文章吧。

具體如下:

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

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

以上是“php如何快速查找數(shù)據(jù)庫(kù)中惡意代碼”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI