承接 helgesverre/spamprotection 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

helgesverre/spamprotection

最新稳定版本:1.0.1

Composer 安装命令:

composer require helgesverre/spamprotection

包简介

A Spam Protection class for use in contact forms and comment fields, uses the StopForumSpam API.

README 文档

README

Latest Version on Packagist Software License Total Downloads

PHP Spam Protection Class for use in Contact forms and Comment Fields

API Keys to use with this class can be obtained here: http://www.stopforumspam.com/signup

Having an API Key is only necessary if you are going to use the submitReport() function.

Install

$ composer require helgesverre/spamprotection

Usage

Example.php

<?php use Helge\SpamProtection\SpamProtection; use Helge\SpamProtection\Types; require 'vendor/autoload.php'; $spamProtector = new SpamProtection(); /**   * All checks can be called from the check() method,   * first param is the type of check, second is the value (ip, email, username)  */ var_dump($spamProtector->check(Types::EMAIL, "helge.sverre@gmail.com")); var_dump($spamProtector->check(Types::IP, "8.8.8.8")); var_dump($spamProtector->check(Types::USERNAME, "helgesverre")); /**  * For convenience some wrapper methods are provided,   * they simply pass the data long to check()  */ var_dump($spamProtector->checkEmail("helge.sverre@gmail.com")); var_dump($spamProtector->checkIP("8.8.8.8")); var_dump($spamProtector->checkUsername("spammer"));

the check methods returns a bool, where TRUE means the IP/Email/Username has been flagged as spam.

If you want to specify a "threshold" of how many spam reports are needed before something is flagged as spam you can use the setFrequencyThreshold() method or specify a threshold in the constructor:

<?php use Helge\SpamProtection\SpamProtection; use Helge\SpamProtection\Types; require 'vendor/autoload.php'; /*  The following constants are available in the spamprotection class for convenience  const THRESHOLD_STRICT = 1;  const THRESHOLD_HIGH = 3;  const THRESHOLD_MEDIUM = 5;  const THRESHOLD_LOW = 10; */ $spamProtector = new SpamProtection(SpamProtection::THRESHOLD_STRICT); // or  $spamProtector = new SpamProtection(); $spamProtector->setFrequencyThreshold(SpamProtection::THRESHOLD_HIGH);

The library can also flag Tor Exit Nodes as spam when they are encountered.

To enable this use the setAllowTorNodes($allowTorNodes) to true or false, or specify it as the second param in the constructor:

<?php use Helge\SpamProtection\SpamProtection; use Helge\SpamProtection\Types; require 'vendor/autoload.php'; /*  The following constants are available in the spamprotection class for convenience  const TOR_ALLOW = true;  const TOR_DISALLOW = false; */ $spamProtector = new SpamProtection(SpamProtection::THRESHOLD_STRICT, SpamProtection::TOR_DISALLOW); // or  $spamProtector = new SpamProtection(); $spamProtector->setAllowTorNodes(false);

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 28.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 24
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 24
  • Watchers: 6
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固