最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 安全过滤代码
时间:2022-07-02 09:16:17 编辑:袖梨 来源:一聚教程网
/**
* @name date safe class 0.1
* @author kevin xu
* @copyright kenvin E-mail:[email protected] MSN:[email protected]
*/
interface dateSafe{
function gincn();
}
class safe extends doSafe implements dateSafe
{
public $safe;
function __construct($safe)
{
parent::__construct($safe); //调用父类构造函数,网友javachen找出来的错误
$this->safe = $safe;
}
function gincn()
{
$this->safe = parent::xss($this->safe);
$this->safe = parent::sql($this->safe);
return $this->safe;
}
}
class doSafe
{
protected $str;
function __construct($str)
{
$this->str = $str;
}
function xss()
{
$this->str = trim($this->str); //清理空格字符
$this->str = nl2br($this->str); //将换行符转化为
$this->str = strip_tags($this->str); //过滤文本中的HTML标签
$this->str = htmlspecialchars($this->str); //将文本中的内容转换为HTML实体
$this->str = addslashes($this->str); //加入字符转义
return $this->str;
}
function sql()
{
$this->str = mysql_escape_string($this->str);
return $this->str;
}
}
?>
相关文章
- 光遇暮土神龛位置汇总完整版 05-16
- DNF手游试炼之塔15层较好的打法 05-16
- DNF手游纯净的黄金增幅书获取方法有哪些 05-16
- 逆水寒手游逍遥游心哪几种 05-16
- 中国比特币排行榜前十名 比特币排行榜前十名地址 05-16
- 崩坏3沧海市西城区宝箱全收集路线 05-16