php 安全过滤代码

WBOY
リリース: 2016-06-13 10:11:16
オリジナル
1027 人が閲覧しました


/**
* @name date safe class 0.1
* @author kevin xu
* @copyright kenvin E-mail:gincn@cn.cashboxparty.com MSN:gincn@live.cn
*/
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
;
 }
}

?>

関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のおすすめ
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!