php过滤垃圾留言(评论)信息功能
Jun 21, 2016 am 08:49 AM
elseif
false
match
return
由于本博客经常遭遇一些好奇人士做各种测试,我经常会在文章评论的数据库里面看到各种奇奇怪怪的评论,要么是各种双引号,单引号,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) <p><font face="Courier New">以上垃圾信息过滤功能还是非常简单粗糙的,不过是应急之需,待有空了参照一下wordpress这种开源程序的垃圾信息过滤功能再继续补充。如果你有更好的方法或者想法请在下方留言帮以完善,作者将不胜感激。</font></p> <p style="width:100%;text-align:center;margin:10px 0"> <br> <br> </p><p style="width:100%;text-align:center;margin:10px 0"> </p><p class="clear"></p>
Copy after login
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

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
3 weeks ago
By DDD

Hot tools Tags

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
3 weeks ago
By DDD

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of the usage of return in C language

What is the execution order of return and finally statements in Java?

Detailed explanation of JavaScript function return values and return statements

How does Vue3 use setup syntax sugar to refuse to write return

How to use return statement in JavaScript
