由于本博客经常遭遇一些好奇人士做各种测试,我经常会在文章评论的数据库里面看到各种奇奇怪怪的评论,要么是各种双引号,单引号,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>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.