过滤

来源:互联网 发布:阿里云推荐码申请 编辑:程序博客网 时间:2024/04/30 17:24
 

从表单接受到$_POST[‘*’]

该信息内容可能包括  “ ‘   空格 特殊符号

 例如   “ user‘’‘’abc”

        $_POST[‘pass’] =” “” and  (select * from tbl_usr)”

防注入(攻击)

  PHP安全问题:

1、  注入

SQL

  在用户执行注册过程中口令内容部分使用了类似

(select insert update delete and or etc.)

eregi(“正则表达式”,“判断字符串”,$name);

 eregi($pattern ,)

  $pattern=(select|insert|update)

     Addslashes()

     \  :转义字符

2、  php

1、  register_glabals=off|on

        $_POST[‘name’]

        $name

3、  SQL语句尽量不要省略引号

4、  $_POST(GET COOKIE )过滤后在接受

5、  命名数据库

6、  尽量封装方法,避免暴露

7、  重定向

考虑:web项目有多少,

      过滤过程写成函数单独存成一个文件

验证码

设计表

Username  password  。。 status  md5name

Zhangsan   123456        0    

 

登录

 Name password  status=1

 

http://localhost/test.php?name=……

name=ziduan

 update    status=1

1、IIS---SMTP(发送)

2、hMailServer软件(SMTP)

Php  mail()----组件

注意:localhost  - 当作垃圾邮件  拒收

      虚拟主机---域名

3、smtp.163.com  用户名  密码

   Socket类: