调用方法:
$url='https://www.5t6t.com/?name=xiaoma';echo clearxss($url);
function clearxss($getstr,$repstr=''){if (strlen($getstr) == 0 || is_null($getstr)){return $getstr;}$pattern = array('/\bstyle\b/i','/\bexpression\b/i','/\bon\w{4,30}\s*=/i','/[\']/','/\bcookie\b/i','/\bdocument\b/i','/\blocalStorage\b/i','/\balert\b/i','/\bconfirm\b/i','/\bopen\b/i','/\bclose\b/i','/\blocation\b/i','/\beval\b/i','/\bfunction\b/i','/\bwrite\b/i');$rep = array_fill(0,count($pattern),'');$getstr = preg_replace($pattern, $rep, $getstr);$getstr = strip_tags($getstr);return $getstr;}
评论