#secure - s├ęcuriser une chaine ou un tableau contre le XSS #http://www.warriordudimanche.net function secure($var,$level=0){ // $level=0 > returns text only (no html or script), 1 > text + html (no script), 2 > all content secured with entities if (is_array($var)){foreach ($var as $index=>$v){$var[$index]=secure($v,$level);}} else if (is_string($var)){ if ($level==0){$var=strip_tags($var);} else if ($level==1){$var=preg_replace('#on[a-z]+ ?= ?["\'].*?["\'](?=[ />])|</?script>|javascript:#i','',$var);} else {$var=htmlspecialchars($var);} } return $var; }