• 技术文章 >后端开发 >php教程

    php快速查找数据库中恶意代码的方法,快速查找恶意代码_PHP教程

    2016-07-13 09:58:31原创492

    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程序设计有所帮助。

    www.bkjia.comtruehttp://www.bkjia.com/PHPjc/977793.htmlTechArticlephp快速查找数据库中恶意代码的方法,快速查找恶意代码 本文实例讲述了php快速查找数据库中恶意代码的方法。分享给大家供大家参考。具...

    php入门到就业线上直播课:查看学习

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

    前端(VUE)零基础到就业课程:点击学习

    清晰的学习路线+老师随时辅导答疑

    自己动手写 PHP MVC 框架:点击学习

    快速了解MVC架构、了解框架底层运行原理

    专题推荐:php 数据库 恶意代码
    上一篇:php输出全球各个时区列表的方法_PHP教程 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • ❤️‍🔥共22门课程,总价3725元,会员免费学• ❤️‍🔥接口自动化测试不想写代码?• 你知道如何用PHP实现多进程吗• PHP与MySQL连接的方法总结• 求解:phpcms模板怎样转码?该怎么解决• php 之 cookie 跟 session 简单解读(笔记)• php怎的快捷知道某个函数在哪个文件用过
    1/1

    PHP中文网