PHP filter Spam message (comments) Information function

Source: Internet
Author: User
Tags filter comments return

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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.