PHP過濾post、get敏感性資料的例子

來源:互聯網
上載者:User
  1. /**
  2. * 批量過濾post,get敏感性資料
  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("", "", $str);
  34. $str = str_replace("", "", $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. }
複製代碼
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.