Examples of PHP filtering posts and getting sensitive data

WBOY
Release: 2016-07-25 08:57:49
Original
1253 people have browsed it
  1. /**
  2. * Filter posts in batches and get sensitive data
  3. * by bbs.it-home.org
  4. */
  5. if (get_magic_quotes_gpc()) {
  6. $_GET = stripslashes_array($_GET);
  7. $_POST = stripslashes_array($_POST);
  8. }
  9. function stripslashes_array(&$array) {
  10. while(list($key,$var) = each($array)) {
  11. if ($key != 'argc' && $key != 'argv' && (strtoupper($key) != $key || ''.intval($key) == "$key")) {
  12. if (is_string($var)) {
  13. $array[$key] = stripslashes($var);
  14. }
  15. if (is_array($var)) {
  16. $array[$key] = stripslashes_array($var);
  17. }
  18. }
  19. }
  20. return $array;
  21. }
  22. //--------------------------
  23. // 替换HTML尾标签,为过滤服务
  24. //--------------------------
  25. function lib_replace_end_tag($str)
  26. {
  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); </li> <li>$str = str_replace("</SCRIPT>", "", $str);
  34. $str = str_replace("<script>", "", $str); </li> <li>$str = str_replace("</script>", "", $str);
  35. $str=str_replace("select","select",$str);
  36. $str=str_replace("join","join",$str);
  37. $str=str_replace("union","union",$str);
  38. $str=str_replace("where","where",$str);
  39. $str=str_replace("insert","insert",$str);
  40. $str=str_replace("delete","delete",$str);
  41. $str=str_replace("update","update",$str);
  42. $str=str_replace("like","like",$str);
  43. $str=str_replace("drop","drop",$str);
  44. $str=str_replace("create","create",$str);
  45. $str=str_replace("modify","modify",$str);
  46. $str=str_replace("rename","rename",$str);
  47. $str=str_replace("alter","alter",$str);
  48. $str=str_replace("cas","cast",$str);
  49. $str=str_replace("&","&",$str);
  50. $str=str_replace(">",">",$str);
  51. $str=str_replace("<","<",$str);
  52. $str=str_replace(" ",chr(32),$str);
  53. $str=str_replace(" ",chr(9),$str);
  54. $str=str_replace(" ",chr(9),$str);
  55. $str=str_replace("&",chr(34),$str);
  56. $str=str_replace("'",chr(39),$str);
  57. $str=str_replace("
    ",chr(13),$str);
  58. $str=str_replace("''","'",$str);
  59. $str=str_replace("css","'",$str);
  60. $str=str_replace("CSS","'",$str);
  61. return $str;
  62. }
复制代码


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!