function inject_check($sql_str) {
return eregi('select|insert|and|or|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $sql_str);// 该函数已经被弃用 相当于preg_match()
} function verify_id($id=null) {
if(!$id) {
exit('没有提交参数!');
} elseif(inject_check($id)) {
exit('提交的参数非法!');
} elseif(!is_numeric($id)) {
exit('提交的参数非法!');
}
$id = intval($id); return $id;
} function str_check( $str ) {
if(!get_magic_quotes_gpc()) {
$str = addslashes($str); // 进行过滤
}
$str = str_replace("_", "\_", $str);
$str = str_replace("%", "\%", $str); return $str;
} function post_check($post) {
if(!get_magic_quotes_gpc()) {
$post = addslashes($post);
}
$post = str_replace("_", "\_", $post);
$post = str_replace("%", "\%", $post);
$post = nl2br($post);
$post = htmlspecialchars($post); return $post;
}

php 防止SQL注入函数的更多相关文章

  1. 过滤xss攻击和sql注入函数

    /**+----------------------------------------------------------* The goal of this function is to be a ...

  2. 自定义防SQL注入函数

    /************************************************ *SQL防注入函数 *@time 2014年6月24日18:50:59 * */ public fu ...

  3. php防止sql注入函数

    $magic_quotes_gpc = get_magic_quotes_gpc(); @extract(daddslashes($_COOKIE)); @extract(daddslashes($_ ...

  4. PHP POST, GET 参数过滤,预防sql注入函数

    1. 实际过滤函数 可适当修改其中的正则表示式 1 static public function filterWords(&$str) 2 { 3 $farr = array( 4 " ...

  5. 防sql注入函数

  6. SQL注入截取字符串函数

    在sql注入中,往往会用到截取字符串的问题,例如不回显的情况下进行的注入,也成为盲注,这种情况下往往需要一个一个字符的去猜解,过程中需要用到截取字符串.本文中主要列举三个函数和该函数注入过程中的一些用 ...

  7. SQL注入的字符串连接函数

    在select数据时,我们往往需要将数据进行连接后进行回显.很多的时候想将多个数据或者多行数据进行输出的时候,需要使用字符串连接函数.在sqli中,常见的字符串连接函数有concat(),group_ ...

  8. Sql注入截取字符串常用函数

    在sql注入中,往往会用到截取字符串的问题,例如不回显的情况下进行的注入,也成为盲注,这种情况下往往需要一个一个字符的去猜解,过程中需要用到截取字符串.本文中主要列举三个函数和该函数注入过程中的一些用 ...

  9. 【PHP代码审计】 那些年我们一起挖掘SQL注入 - 6.全局防护Bypass之一些函数的错误使用

    0x01 背景 PHP程序员在开发过程中难免会使用一些字符替换函数(str_replace).反转义函数(stripslashes),但这些函数使用位置不当就会绕过全局的防护造成SQL注入漏洞. 0x ...

随机推荐

  1. 7.4.1 Dumping Data in SQL Format with mysqldump

    7.4 Using mysqldump for Backups 使用mysqldump 用于备份: 7.4.1 Dumping Data in SQL Format with mysqldump 7. ...

  2. 【动态规划】XMU 1560 新ACM规则

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1560 题目大意: 给定n(n<=200)个任务及每个任务的耗时,问m(m< ...

  3. WCF默认实例的解读

    一:图片 IService1.cs是定义的接口,包含对Service.方法和方法用的类的声明的声明 Service1.cs是对接口的实现,包含实现的方法 代码注释: using System; usi ...

  4. 常用sql语句及案例(oracle)

    目录 1)基本 2)数学函数 3)rownum 4)分页 5)时间处理 6)字符函数 7)to_number 8)聚合函数 9)学生选课 10)图书馆借阅 基本 --新建表: ) ) not null ...

  5. Spice代码阅读一:Spice Client 与 Spice Server 通道建立过程

    文件 方法 描述 Application.cpp init_globals() 初始化Log,ssl库,canvas(或opengl canvas)和quic压缩库 Process_cmd_line( ...

  6. 设计模式学习--复合模式(Compound Pattern)

    设计模式学习--复合模式(Compound Pattern) 概述 ——————————————————————————————————————————————————— 2013年8月4日<H ...

  7. Windows 如何在cmd命令行中查看、修改、删除与添加环境变量

    转自:http://www.cnblogs.com/saptechnique/archive/2013/02/17/2914222.html 首先明确一点: 所有的在cmd命令行下对环境变量的修改只对 ...

  8. node中的Readable - flowing/non-flowing mode

    大家都知道在node中Readable Stream有两种模式: flowing mode和non-flowing mode. 对于flowing mode的Readable Stream, 我们是没 ...

  9. Java Criteria表关联查询(两个表未定义关联关系)

    Criteria criteria = this.getSession().createCriteria(Competition.class, "b"); DetachedCrit ...

  10. JAVA File转Byte[]

    /** * 获得指定文件的byte数组 */ public static byte[] getBytes(String filePath){ byte[] buffer = null; try { F ...