保护免受XSS攻击脚本

<? function antihack(&$var){ if(is_array($var)) array_walk($var, 'antihack');功能antihack(&$ ​​VAR){如果(IS_ARRAY(是$ var))的。array_walk($变种,'antihack'); else $var = htmlspecialchars(stripslashes(mysql_real_escape_string($var)), ENT_QUOTES, 'UTF-8');否则是$ var =用htmlspecialchars(函数stripslashes(mysql_real_escape_string($ VAR)),ENT_QUOTES,'utf-8'); } foreach(array('_SERVER', '_GET', '_POST', '_COOKIE', '_REQUEST') as $v){ if(!empty(${$v})) array_walk(${$v}, 'antihack'); }的foreach(数组('_SERVER','_GET','_POST','_COOKIE','_REQUEST')为$ V){如果(!空($ {$ V}))的。array_walk($ {$ V}, 'antihack'); } ?> }?> 出处.俄国一论坛

相关推荐

发表评论

路人甲

网友评论(0)