肥宅自学平台_人人成为技术开发者

肥宅人只等待您,联系我们吧,曾经的巅峰是否能回来?我们正在用心服务!

PHP怎么过滤post get参数实现安全

 更新时间:2024-04-20 15:35:12   作者:肥宅-季波   我要评论(0)  

         用于过滤post与get传递过来的敏感数据
  1. <?
  2. /**
  3. * 批量过滤post,get敏感数据
  4. * by www.fzzixue.com
  5. */
  6. if (get_magic_quotes_gpc()) {
  7.     $_GET = stripslashes_array($_GET);
  8.     $_POST = stripslashes_array($_POST);
  9. }
  10. function stripslashes_array(&$array) {
  11.     while (list($key, $var) = each($array)) {
  12.         if ($key != 'argc' && $key != 'argv' && (strtoupper($key) != $key || '' . intval($key) == "$key")) {
  13.             if (is_string($var)) {
  14.                 $array[$key] = stripslashes($var);
  15.             }
  16.             if (is_array($var)) {
  17.                 $array[$key] = stripslashes_array($var);
  18.             }
  19.         }
  20.     }
  21.     return $array;
  22. }
  23. //--------------------------
  24. // 替换HTML尾标签,为过滤服务
  25. //--------------------------
  26. function lib_replace_end_tag($str) {
  27.     if (empty($str)) return false;
  28.     $str = htmlspecialchars($str);
  29.     $str = str_replace('/', "", $str);
  30.     $str = str_replace("\", "", $str);
  31.     $str = str_replace(">", "", $str);
  32.     $str = str_replace("<", "", $str);
  33.     $str = str_replace("<SCRIPT>", "", $str);
  34.     $str = str_replace("</SCRIPT>", "", $str);
  35.     $str = str_replace("<script>", "", $str);
  36.     $str = str_replace("</script>", "", $str);
  37.     $str = str_replace("select", "select", $str);
  38.     $str = str_replace("join", "join", $str);
  39.     $str = str_replace("union", "union", $str);
  40.     $str = str_replace("where", "where", $str);
  41.     $str = str_replace("insert", "insert", $str);
  42.     $str = str_replace("delete", "delete", $str);
  43.     $str = str_replace("update", "update", $str);
  44.     $str = str_replace("like", "like", $str);
  45.     $str = str_replace("drop", "drop", $str);
  46.     $str = str_replace("create", "create", $str);
  47.     $str = str_replace("modify", "modify", $str);
  48.     $str = str_replace("rename", "rename", $str);
  49.     $str = str_replace("alter", "alter", $str);
  50.     $str = str_replace("cas", "cast", $str);
  51.     $str = str_replace("&", "&", $str);
  52.     $str = str_replace(">", ">", $str);
  53.     $str = str_replace("<", "<", $str);
  54.     $str = str_replace(" ", chr(32), $str);
  55.     $str = str_replace(" ", chr(9), $str);
  56.     $str = str_replace("    ", chr(9), $str);
  57.     $str = str_replace("&", chr(34), $str);
  58.     $str = str_replace("'", chr(39), $str);
  59.     $str = str_replace("<br />", chr(13), $str);
  60.     $str = str_replace("''", "'", $str);
  61.     $str = str_replace("css", "'", $str);
  62.     $str = str_replace("CSS", "'", $str);
  63.     return $str;
  64. }
"小礼物走一走,来肥宅自学平台支持我"
评论区

评论

共条评论
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~
客服中心在线客服
全心全意为平台用户服务
Copyright © 2017-2023 自学平台网站地图:去查看>
  • 肥宅人自己的自学平台
  • 人人都能成为平台讲师
  • 贡献你的力量壮大肥宅自学平台
  • 将自己的能力变现
  • 实现人生的第二职业
网址收藏平台安卓APP
微信公众号微信公众号

本站部分图片或者资源来自程序自动采集或卖家(商家)发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!

肥宅自学教程网是一个主打IT视频教程、自媒体运行、摄影剪辑等内容的资源学习交流平台。