Because this blog often encounters some curious people to do various tests, I often see all sorts of weird comments in the comments database, either a variety of double quotes, single quotes, SQL statement keywords, or some meaningless comments, so there are a number of limitations to the article comment. Spam review information filtering is only recently added, referring to some of the online cases, the following share in this record.
function Isvaliddata ($s) {
if (Preg_match ("/([\x{4e00}-\x{9fa5}].+) \\1{4,}/u", $s)) {return
false;// Repeat the same word more than 5 times
}elseif (Preg_match ("/^[0-9a-za-z]*$/", $s)) {return
false;//full number, full English or all digital English mixed
}elseif (strlen ($s) <10) {return
false;//input characters long pass short
} return
true;
}
The above spam filtering function is very simple and rough, but the need for emergency, to be free to refer to wordpress this open-source program spam filtering function to continue to add. If you have a better way or idea, please leave a message below to improve, the author will be greatly appreciated.