PHP过滤POST,GET敏感数据
2012-11-19 11:28
549 查看
web开发安全一直是很重要的位置,所以在开发web应用时,尽量剔除采用过滤技术来保证数据的安全性。 尤其是在POST,GET提交的时候,经常会采用过滤敏感数据。下面是本人在网上搜索到的关于如何PHP过 滤POST,GET敏感数据的方法。 //php 批量过滤post,get敏感数据 if (get_magic_quotes_gpc()) { $_GET = stripslashes_array($_GET); $_POST = stripslashes_array($_POST); } function stripslashes_array(&$array) { while(list($key,$var) = each($array)) { if ($key != 'argc' && $key != 'argv' && (strtoupper($key) != $key || ''.intval($key) == "$key")) { if (is_string($var)) { $array[$key] = stripslashes($var); } if (is_array($var)) { $array[$key] = stripslashes_array($var); } } } return $array; } // 替换HTML尾标签,为过滤服务 //-------------------------- function lib_replace_end_tag($str) { if (empty($str)) return false; $str = htmlspecialchars($str); $str = str_replace( '/', "", $str); $str = str_replace("\\", "", $str); $str = str_replace(">", "", $str); $str = str_replace("<", "", $str); $str = str_replace("<SCRIPT>", "", $str); $str = str_replace("</SCRIPT>", "", $str); $str = str_replace("<script>", "", $str); $str = str_replace("</script>", "", $str); $str=str_replace("select","select",$str); $str=str_replace("join","join",$str); $str=str_replace("union","union",$str); $str=str_replace("where","where",$str); $str=str_replace("insert","insert",$str); $str=str_replace("delete","delete",$str); $str=str_replace("update","update",$str); $str=str_replace("like","like",$str); $str=str_replace("drop","drop",$str); $str=str_replace("create","create",$str); $str=str_replace("modify","modify",$str); $str=str_replace("rename","rename",$str); $str=str_replace("alter","alter",$str); $str=str_replace("cas","cast",$str); $str=str_replace("&","&",$str); $str=str_replace(">",">",$str); $str=str_replace("<","<",$str); $str=str_replace(" ",chr(32),$str); $str=str_replace(" ",chr(9),$str); $str=str_replace(" ",chr(9),$str); $str=str_replace("&",chr(34),$str); $str=str_replace("'",chr(39),$str); $str=str_replace("<br />",chr(13),$str); $str=str_replace("''","'",$str); $str=str_replace("css","'",$str); $str=str_replace("CSS","'",$str); return $str; }
相关文章推荐
- php过滤所有恶意字符(批量过滤post,get敏感数据)
- php过滤所有恶意字符(批量过滤post,get敏感数据)经典
- PHP过滤POST,GET敏感数据
- php过滤所有恶意字符(批量过滤post,get敏感数据)
- php 批量过滤post,get敏感数据
- PHP过滤post,get敏感数据
- javaWed项目中用过滤器实现转码功能,敏感词汇过滤更能,处理Get和Post接收数据中的中文乱码问题以及敏感词汇的处理
- php的curl函数模拟post、get数据提交,速度非常慢的处理办法
- PHP利用Curl、socket、file_get_contents POST数据
- php 获取提交的数据 $_REQUEST = $_GET + $_POST + $_COOKIE
- php中$_GET与$_POST过滤sql注入的方法
- PHP中使用file_get_contents post数据代码例子
- php中用于接受表单数据的$_request与$_post、$_get
- php模拟GET与POST向微信接口提交及获取数据的方法
- php中使用Curl、socket、file_get_contents三种方法POST提交数据
- PHP利用Curl、socket、file_get_contents POST数据
- php中$_GET与$_POST过滤sql注入的方法
- php中用socket模拟http中post或者get提交数据的示例代码
- PHP之文件操作,http请求数据格式,模拟get和post,CURL模拟请求的使用
- PHP 使用curl库来发送GET,POST请求,处理json格式数据