PHPackages                             yohns/stop-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. yohns/stop-spam

ActiveLibrary[Security](/categories/security)

yohns/stop-spam
===============

Comprehensive spam prevention and security system with rate limiting, CSRF protection, and anti-spam features

v1.1.0(2mo ago)044MITPHPPHP ^8.2

Since Jul 25Pushed 2mo agoCompare

[ Source](https://github.com/YoBuild/Stop-Spam)[ Packagist](https://packagist.org/packages/yohns/stop-spam)[ RSS](/packages/yohns-stop-spam/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

Yohns Stop Spam
===============

[](#yohns-stop-spam)

A comprehensive spam prevention and security library for PHP 8.2+ applications. This library combines rate limiting, CSRF protection, honeypot fields, timing analysis, and content spam detection into a unified security solution.

Features
--------

[](#features)

### 🛡️ Core Security Components

[](#️-core-security-components)

- **CSRF Protection**: Token-based protection against cross-site request forgery
- **Rate Limiting**: Progressive timeouts with customizable thresholds
- **Honeypot Fields**: Hidden form fields to catch automated submissions
- **Content Spam Detection**: AI-powered content analysis with keyword filtering
- **File-based Storage**: Simple JSON file storage (no database required)

### 🚀 Advanced Features

[](#-advanced-features)

- **Progressive Rate Limiting**: Automatic escalation for repeat offenders
- **Client-side Validation**: JavaScript validation with server-side verification
- **Comprehensive Logging**: Track security events and violations
- **Easy Configuration**: JSON-based configuration system
- **Automatic Cleanup**: Self-maintaining storage with configurable retention

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

[](#installation)

### Via Composer

[](#via-composer)

```
composer require yohns/stop-spam
```

### Requirements

[](#requirements)

- PHP 8.2 or higher
- JSON extension
- yohns/config ^1.2

More Information
----------------

[](#more-information)

### JavaScript Front End Docs and Code

[](#javascript-front-end-docs-and-code)

[README JavaScript Guide](README-JavaScript-GUIDE.md) - |.:.| - Code: [security-validator.js](public/assets/js/security-validator.js)

### More Reading

[](#more-reading)

---

- [Brief README](README-BRIEF.md)
- [In Dept README](README-IN-DEPT.md)

---

### Docs for each Class

[](#docs-for-each-class)

- [Yohns\\AntiSpam\\ContentAnalyzer](docs/AntiSpam/ContentAnalyzer.md)
    - ContentAnalyzer class for advanced content analysis and pattern detection.
    - Provides detailed content analysis including language detection, sentiment analysis, and advanced spam pattern recognition.
- [Yohns\\AntiSpam\\Honeypot](docs/AntiSpam/Honeypot.md)
    - Honeypot class for detecting automated bot submissions.
    - Uses hidden form fields and timing analysis to catch spam bots.
- [Yohns\\AntiSpam\\SpamDetector](docs/AntiSpam/SpamDetector.md)
    - SpamDetector class for comprehensive content spam detection
    - Analyzes content for spam patterns, keywords, and suspicious behavior. Uses machine learning-style scoring to determine spam likelihood.
- [Yohns\\Security\\ContentValidator](docs/Security/ContentValidator.md)
    - ContentValidator class for sanitizing and validating user input
    - Provides XSS protection, input sanitization, and content validation. Supports HTML filtering, email validation, URL validation, and comprehensive security threat detection with configurable rules and patterns.
- [Yohns\\Security\\CSRFToken](docs/Security/CSRFToken.md)
    - CSRFToken class for Cross-Site Request Forgery protection
    - Provides secure token generation and validation to prevent CSRF attacks. Supports multiple storage backends and provides flexible integration options.
- [Yohns\\Security\\FileStorage](docs/Security/FileStorage.md)
    - FileStorage class for managing JSON file-based data storage
    - This class provides a simple JSON file storage system to replace MySQL for security tokens, rate limits, and spam detection logs. Features automatic cleanup, file locking, and configurable permissions.
- [Yohns\\Security\\IPSecurity](docs/Security/IPSecurity.md)
    - IPSecurity class for IP-based security management
    - Handles IP whitelisting, blacklisting, geolocation, and reputation tracking. Provides comprehensive IP analysis including proxy detection, threat assessment, and automated security responses.
- [Yohns\\Security\\RateLimiter](docs/Security/RateLimiter.md)
    - RateLimiter class for preventing abuse through rate limiting
    - Implements progressive timeouts and tracks requests by IP and action type.
- [Yohns\\Security\\SecurityManager](docs/Security/SecurityManager.md)
    - SecurityManager class - Main security coordination class
    - Coordinates all security components for comprehensive protection. Provides a unified interface for CSRF protection, rate limiting, honeypot anti-spam, content validation, and security monitoring.
- [Yohns\\Security\\TokenManager](docs/Security/TokenManager.md)
    - TokenManager class for managing various types of security tokens
    - Handles API tokens, session tokens, verification tokens, and more. Provides comprehensive token lifecycle management including generation, validation, expiration, and usage tracking.

Quick Start
-----------

[](#quick-start)

### 1. Basic Setup

[](#1-basic-setup)

```
