Home > php教程 > php手册 > body text

php过滤垃圾留言(评论)信息功能

WBOY
Release: 2016-06-21 08:49:07
Original
1089 people have browsed it

由于本博客经常遭遇一些好奇人士做各种测试,我经常会在文章评论的数据库里面看到各种奇奇怪怪的评论,要么是各种双引号,单引号,sql语句关键词等各种尝试,要么就是一些毫无意义的评论,所以对于文章评论这块不得不做了各种限制,垃圾评论信息过滤是最近才加上去的,参照了网上的一些案例,下面在此记录分享一下。

function isValidData($s){
	if(preg_match("/([\x{4e00}-\x{9fa5}].+)\\1{4,}/u",$s)){
		return false;//同字重复5次以上
	}elseif(preg_match("/^[0-9a-zA-Z]*$/",$s)){
		return false;//全数字,全英文或全数字英文混合的
	}elseif(strlen($s)

以上垃圾信息过滤功能还是非常简单粗糙的,不过是应急之需,待有空了参照一下wordpress这种开源程序的垃圾信息过滤功能再继续补充。如果你有更好的方法或者想法请在下方留言帮以完善,作者将不胜感激。



Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!