문제

I'm currently being 'spammed' with zalgo text on my webpage and i need a function to check if it contains zalgo.

I found this code:

if ( preg_match ( '/[^\x20-\x7E]/', $text ) || preg_match ( '/[^\x20-\x7E]/', $text ) ) {
die('ZALGO not allowed');}

but it also blocks some legit posts. Is there a better way?

Thanks

도움이 되었습니까?

해결책

Zalgo typically falls in the CC and CD unicode ranges. Try matching against /[\xCC\xCD]/. You should generally have a reCAPTCHA anyway to mitigate spam. If it's not 4channers one day then it might be viagra bots the next day.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top