Download the PHP package heyitsmi/content-guard without Composer
On this page you can find all versions of the php package heyitsmi/content-guard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download heyitsmi/content-guard
More information about heyitsmi/content-guard
Files in heyitsmi/content-guard
Package content-guard
Short Description A content sanitization library to filter negative content and online gambling spam.
License MIT
Informations about the package content-guard
ContentGuard
ContentGuard is a robust PHP content sanitization library specifically designed for the Indonesian web ecosystem. It helps developers filter out online gambling spam (judi online), profanity, and hate speech with advanced detection capabilities.
Unlike simple string replacement tools, ContentGuard uses an intelligent Regex Engine to detect "Leet Speak" (visual masking) commonly used by spammers (e.g., detecting s10t g4c0r as slot gacor).
Features
- ✅ Smart Detection: Catch masked words like
g4c0r,s.l.o.t,judi, etc. - ✅ Pre-built Dictionary: Comes with a comprehensive database of Indonesian gambling terms and profanity.
- ✅ Laravel Ready: Includes Service Provider and Facade for seamless integration.
- ✅ Customizable: Add your own blocklist and configure strictness.
- ✅ Zero Dependencies: Lightweight and fast.
Installation
You can install the package via composer:
Configuration (Laravel)
If you are using Laravel, you can publish the configuration file to customize the behavior (e.g., changing the mask character or adding custom keywords).
Run the following command:
This will create a config/content-guard.php file in your application.
Usage
1. Using Laravel Facade (Recommended for Laravel)
You can use the ContentGuard facade anywhere in your controllers, jobs, or blade directives.
2. Standalone PHP Usage
If you are not using Laravel, you can instantiate the class directly.
3. Client-side Masking (Blur or Hidden)
ContentGuard can wrap detected words in HTML tags, allowing you to use CSS and JavaScript for a premium "click-to-reveal" experience.
Publication (Laravel)
Publish the assets (CSS and JS):
Assets Inclusion
In your layout file (e.g., app.blade.php), inclusion the assets using the blade directive:
Usage
Use the wrap() method instead of sanitize() to get HTML-tagged content:
The wrap() method will generate:
<span class="cg-word cg-blur" data-cg-word="slot">slot</span>
Users can click on the blurred/masked word to reveal the original content.
How It Works
ContentGuard converts standard keywords into flexible Regex patterns based on a Substitution Map.
-
Input:
slot -
Regex Generated:
/\b(s|5|\$|z)[\W_]*(l|1|!|\|)[\W_]*(o|0|@|ø)[\W_]*(t|7|\+)\b/i - Matches:
slot,s1ot,s.l.o.t,s-l-o-t,sl0t, etc.
Testing
To run the unit tests included in this package:
Contributing
Contributions are welcome! If you find new slang words or spam patterns popular in Indonesia, please submit a Pull Request to update the src/Dictionary files.
License
The MIT License (MIT). Please see License File for more information.