Kohana之Security使用

日记来的,方便用到快速查找,其实手册已经说的很明白了

token验证,用于表单,或许有用

<?php
$token = Security::token();
if (Security::check($token)){
	echo "ok";
}

编码PHP代码

<?php
$str="<?php echo'hi'; ?>";
echo Security::encode_php_tags($str);

防止xss攻击

<?php
$str="<html><script>alert('dd');</script><h1>ddd</h1></html>";
echo Security::xss_clean($str);

这个东西挺好用的,呵呵

posted @ 2010-08-19 11:14  liushan  阅读(161)  评论(0)    收藏  举报