PHPackages                             fof/anti-spam - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. fof/anti-spam

ActiveFlarum-extension[Security](/categories/security)

fof/anti-spam
=============

Effective tools to manage spammers on your community.

1.1.4(7mo ago)426.0k—1.6%1[5 issues](https://github.com/FriendsOfFlarum/anti-spam/issues)[1 PRs](https://github.com/FriendsOfFlarum/anti-spam/pulls)MITPHPCI passing

Since Nov 17Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/FriendsOfFlarum/anti-spam)[ Packagist](https://packagist.org/packages/fof/anti-spam)[ Docs](https://friendsofflarum.org)[ Fund](https://opencollective.com/fof/donate)[ RSS](/packages/fof-anti-spam/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (14)Used By (0)

FoF Anti Spam
=============

[](#fof-anti-spam)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667) [![Latest Stable Version](https://camo.githubusercontent.com/7e39993c8e43808aff54e88bdadf0811dc5740f55e762cb90361f69c6a821b0d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f662f616e74692d7370616d2e737667)](https://packagist.org/packages/fof/anti-spam) [![Total Downloads](https://camo.githubusercontent.com/36b9a28dc0cbde0c78fd159ea5dcb1f3d557b3f65a42b746b21b0737ac0b99f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666f662f616e74692d7370616d2e737667)](https://packagist.org/packages/fof/anti-spam)

A [Flarum](http://flarum.org) extension. Effective tools to manage spammers on your community

Features
--------

[](#features)

### Content Filtering (New!)

[](#content-filtering-new)

Automatically detect and prevent spam content from new users before it becomes visible:

- **Automatic Detection**: Monitors posts and discussions from recently registered users for common spam indicators

    - Phone numbers in international format
    - Email addresses
    - Suspicious URLs not on your allowlist
    - Custom blocked words and phrases
    - Advanced regex pattern matching
- **Smart User Targeting**: Only monitors users within their first few posts or hours after registration
- **Flexible Actions**:

    - Automatically flag suspicious content for moderator review (requires `flarum/flags`)
    - Send suspicious content to approval queue (requires `flarum/approval`)
    - Configurable spam score thresholds (0-100)
- **Custom Flag Type**: Uses a dedicated `spam` flag type with prominent score display to distinguish automatic detections from user reports
- **Configurable via Admin UI or Code**: Full configuration through admin panel, or use `extend.php` for advanced customization

### User Management

[](#user-management)

- Set default actions to be processed when a user is marked as a "spammer"
- Select either "delete" or "suspend" for users
- Select "delete", "hide" or "move to tag" for spam discussions
- Select either "delete" or "hide" for spam replies

### StopForumSpam Integration

[](#stopforumspam-integration)

- Option to submit spammer details to the [StopForumSpam database](https://www.stopforumspam.com/)
- Check new registrations against the [StopForumSpam database](https://www.stopforumspam.com/) to block spammers before they can register on your forum
- Supports OAuth registrations (`fof/oauth`, `fof/passport`)
- Configurable confidence and frequency thresholds
- Regional endpoint selection for compliance

Configuration
-------------

[](#configuration)

### Basic Setup (Admin UI)

[](#basic-setup-admin-ui)

All settings can be configured through the admin panel:

1. Navigate to Extensions → FoF Anti Spam → Settings
2. Enable content filtering
3. Configure user targeting (post count, account age)
4. Enable detectors (phones, emails, URLs)
5. Set spam score thresholds
6. Configure automatic actions (flag/unapprove)
7. Add allowed domains and blocked words

### Advanced Configuration (extend.php)

[](#advanced-configuration-extendphp)

For programmatic configuration or version-controlled settings, you can configure the extension in your forum's `extend.php`:

```
use FoF\AntiSpam\Extend\ContentFilter;
use FoF\AntiSpam\ContentFilter\Detectors\PhoneDetector;

return [
    // ... your other extenders ...

    // Configure content filtering
    (new ContentFilter())
        // Enable/disable content filtering
        ->enabled(true)

        // User targeting: monitor users within first N posts
        ->monitorUsersUpToPostCount(5)

        // User targeting: monitor users within first N hours
        ->monitorUsersUpToHoursOld(24)

        // Domain allowlist
        ->allowDomain('youtube.com')
        ->allowDomain('github.com')
        ->allowDomains(['stackoverflow.com', 'wikipedia.org'])

        // Custom domain validation
        ->allowDomainCallback(function ($uri, $user) {
            return str_ends_with($uri->getHost(), '.mycompany.com');
        })

        // Block specific patterns (regex)
        ->blockPattern('/\b(viagra|cialis)\b/i', 'Pharmaceutical spam')
        ->blockPattern('/\bcrypto\s*currency\b/i', 'Cryptocurrency spam')

        // Enable/disable detectors
        ->blockPhoneNumbers(true)
        ->blockEmailAddresses(true)
        ->blockUrls(true)

        // Spam score thresholds (0-100)
        // Each detector awards 50 points per match
        // Default: 50 for both (single detection triggers actions)
        ->spamScoreThreshold(50)  // Auto-unapprove threshold
        ->flagScoreThreshold(50)   // Auto-flag threshold

        // Enable automatic actions
        ->enableAutoUnapprove(true)  // Requires flarum/approval
        ->enableAutoFlag(true)        // Requires flarum/flags

        // System user for automatic flags
        ->assignFlagsToModerator(1)  // User ID (defaults to 1)

        // Disable specific detectors if needed
        ->disableDetector(PhoneDetector::class),
];
```

Configuration set via `extend.php` will override admin UI settings and be displayed as read-only in the admin panel.

How Content Filtering Works
---------------------------

[](#how-content-filtering-works)

### Spam Score System

[](#spam-score-system)

The content filtering system uses a point-based spam scoring mechanism:

- Each detector awards **50 points** per match (capped at 80-100 points per detector)
- Multiple detections stack up to create a cumulative score
- Default thresholds are set to **50 points** (meaning a single detection triggers actions)

**Example**: A post containing both a phone number and an email address would score 100 points, triggering both flagging and unapproval (if enabled).

### Custom Flag Type

[](#custom-flag-type)

This extension uses a custom `spam` flag type for automatic detections:

- **Spam score** is stored in the flag's `reason` field
- **Detection details** are stored in the `reason_detail` field
- **Display format**: "Automatic Spam Detection - score {score}"
- Provides clear visual distinction from user-reported flags

### Detection Methods

[](#detection-methods)

**Phone Number Detector**

- Matches international phone numbers with + or 00 prefix
- Requires at least 9 digits
- Examples: `+1234567890`, `00 123 456 7890`

**Email Detector**

- Matches standard email addresses
- Example: `spam@example.com`

**URL Detector**

- Matches HTTP/HTTPS URLs
- Checks against allowlist (your forum domain is auto-allowlisted)
- Example: `http://suspicious-site.com`

**Pattern Detector (Blocked Words)**

- Case-insensitive matching
- Whole word boundary matching (e.g., "viagra" matches "viagra" but not "niagara")
- Supports multi-word phrases (e.g., "crypto pump")
- Advanced: Custom regex patterns via `extend.php`

Requirements
------------

[](#requirements)

- Flarum 2.0+
- PHP 8.2+

More integrations
-----------------

[](#more-integrations)

Future integrations with extensions such as:

- `fof/user-bio`
- `fof/upload`

and more, are planned soon.

Installation
------------

[](#installation)

Install with composer:

```
composer require fof/anti-spam:"*"
```

Updating
--------

[](#updating)

```
composer update fof/anti-spam
php flarum migrate
php flarum cache:clear
```

Links
-----

[](#links)

- [Packagist](https://packagist.org/packages/fof/anti-spam)
- [GitHub](https://github.com/FriendsOfFlarum/anti-spam)
- [Discuss](https://discuss.flarum.org/d/33698)

An extension by [FriendsOfFlarum](https://github.com/FriendsOfFlarum).

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance55

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~68 days

Recently: every ~30 days

Total

13

Last Release

92d ago

Major Versions

0.1.0-beta.3 → 1.0.02023-11-23

1.1.4 → 2.0.0-beta.12025-12-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16573496?v=4)[IanM](/maintainers/imorland)[@imorland](https://github.com/imorland)

![](https://avatars.githubusercontent.com/u/1630413?v=4)[Gregor Hammerschmidt](/maintainers/GreXXL)[@GreXXL](https://github.com/GreXXL)

![](https://www.gravatar.com/avatar/0538135c1debcef5602dce7ece027909cc832b7a6284ab9189a19aa8de98d60d?d=identicon)[clarkwinkelmann](/maintainers/clarkwinkelmann)

![](https://www.gravatar.com/avatar/1298cdc0b2402a1aa34fb75a254947d655e090d62bd0531311331d369cac934e?d=identicon)[datitisev](/maintainers/datitisev)

---

Top Contributors

[![imorland](https://avatars.githubusercontent.com/u/16573496?v=4)](https://github.com/imorland "imorland (29 commits)")[![flarum-bot](https://avatars.githubusercontent.com/u/39334649?v=4)](https://github.com/flarum-bot "flarum-bot (13 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (4 commits)")[![DavideIadeluca](https://avatars.githubusercontent.com/u/146922689?v=4)](https://github.com/DavideIadeluca "DavideIadeluca (1 commits)")[![Justman100](https://avatars.githubusercontent.com/u/149507651?v=4)](https://github.com/Justman100 "Justman100 (1 commits)")

---

Tags

flarum

### Embed Badge

![Health badge](/badges/fof-anti-spam/health.svg)

```
[![Health](https://phpackages.com/badges/fof-anti-spam/health.svg)](https://phpackages.com/packages/fof-anti-spam)
```

###  Alternatives

[fof/upload

The file upload extension for the Flarum forum with insane intelligence.

188171.7k15](/packages/fof-upload)[fof/byobu

Well integrated, advanced private discussions.

61105.8k9](/packages/fof-byobu)[fof/recaptcha

Increase your forum's security with Google reCAPTCHA

1235.4k](/packages/fof-recaptcha)[fof/user-bio

Add a user bio to user profiles

2196.5k9](/packages/fof-user-bio)[flarum/gdpr

Features for GDPR, PII management

1425.2k15](/packages/flarum-gdpr)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
