Home php教程 php手册 php过滤垃圾留言(评论)信息功能

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 尊渡假赌尊渡假赌尊渡假赌

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 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of the usage of return in C language Detailed explanation of the usage of return in C language Oct 07, 2023 am 10:58 AM

Detailed explanation of the usage of return in C language

What is the execution order of return and finally statements in Java? What is the execution order of return and finally statements in Java? Apr 25, 2023 pm 07:55 PM

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

Detailed explanation of JavaScript function return values ​​and return statements Detailed explanation of JavaScript function return values ​​and return statements Aug 04, 2022 am 09:46 AM

Detailed explanation of JavaScript function return values ​​and return statements

How to use return value in Python How to use return value in Python Oct 07, 2023 am 11:10 AM

How to use return value in Python

How does Vue3 use setup syntax sugar to refuse to write return How does Vue3 use setup syntax sugar to refuse to write return May 12, 2023 pm 06:34 PM

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

Use the return keyword in JavaScript Use the return keyword in JavaScript Feb 18, 2024 pm 12:45 PM

Use the return keyword in JavaScript

Match matching method in java Match matching method in java Apr 28, 2023 pm 10:31 PM

Match matching method in java

How to use return statement in JavaScript How to use return statement in JavaScript Feb 26, 2024 am 09:21 AM

How to use return statement in JavaScript

See all articles