php防止xss攻击简易函数_PHP_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > PHP > php防止xss攻击简易函数

php防止xss攻击简易函数

 2018/4/11 17:30:40  rabbit7777  程序员俱乐部  我要评论(0)
  • 摘要:functionxss_clean($var){$ra=array('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/','/script/i','/javascript/i','/vbscript/i','/onload/i','/onunload/i','/onchange/i','/onsubmit/i','/onreset/i','/onselect/i','/onblur/i','/onfocus/i','/onabort/i','/onkeydown/i'
  • 标签:PHP 函数 攻击
class="php">function xss_clean ($var)
{
    $ra=array('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/','/script/i','/javascript/i','/vbscript/i','/onload/i','/onunload/i','/onchange/i','/onsubmit/i','/onreset/i','/onselect/i','/onblur/i','/onfocus/i','/onabort/i','/onkeydown/i','/onkeypress/i','/onkeyup/i','/onclick/i','/ondblclick/i','/onmousedown/i','/onmousemove/i','/onmouseout/i','/onmouseover/i','/onmouseup/i','/onunload/i');
    $var = preg_replace($ra,'',$var);
   
    return htmlspecialchars($var,ENT_QUOTES);
}

?

上一篇: 对HashMap的思考及手写实现荐 下一篇: 没有下一篇了!
发表评论
用户名: 匿名