php快速尋找資料庫中惡意代碼的方法,快速尋找惡意代碼_PHP教程

來源:互聯網
上載者:User

php快速尋找資料庫中惡意代碼的方法,快速尋找惡意代碼


本文執行個體講述了php快速尋找資料庫中惡意代碼的方法。分享給大家供大家參考。具體如下:

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

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程式設計有所協助。

http://www.bkjia.com/PHPjc/977793.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/977793.htmlTechArticlephp快速尋找資料庫中惡意代碼的方法,快速尋找惡意代碼 本文執行個體講述了php快速尋找資料庫中惡意代碼的方法。分享給大家供大家參考。具...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.