参数过滤
2015-07-15 16:26
337 查看
/** * 参数过滤 * @param string/array $str * @return string/array */ function get_field($str){ if(empty($str)){return;} $string = preg_replace('/select | insert | update | and | in | on | left | joins | delete | \% | \= | \/\* | \* | \.\.\/ | \.\/ | union | from | where | group | into | load_file | outfile /','',$str); $new_str = htmlspecialchars($string, ENT_COMPAT); $return = strip_tags(str_replace(PHP_EOL.PHP_EOL, PHP_EOL,$new_str)); return $return; } $str = 'select * from table where id = 1 or name " '; echo red_field($str); 输出:*tableid1 or name "
相关文章推荐
- centos7下redis的安装
- 黑马程序员————第四天
- 多台center服务器相互免密码登陆
- PAT 1063. Set Similarity (25)
- 谈闭包的时候,要不要谈钩子?
- struts1源码分析(二)初始化主线
- Python学习笔记4_字符串
- 【转载】12306铁道部订票网站性能分析
- 遍历二叉树
- linux系统数据落盘之细节
- Apache 配置域名入口路径
- java虚拟机内存分配
- Visual studio 2013 err:visual studio no editoroptiondefinition export found for the given option ...
- 黑马程序员————第三天
- struts1源码分析(一)整体概览和核心组件
- Linux-2.6.20的cs8900驱动分析(一)
- C++前缀自增/后缀自增及重载
- autotools-practice
- IOS把图片缓存到本地的几种方法
- Android开发:Eclipse中SqliteManager插件使用