1. Go to this page and download the library: Download gorankrgovic/spam-marker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gorankrgovic / spam-marker example snippets
use SpamMarker\SpamMarker;
// 1.
// Use some filters
use SpamMarker\Filter\BlackListed;
// 2.
// Initalize the blackisted filter
$blackListed = new BlackListed();
// Add some spammy keywords
$blackListed->add('hacker');
$blackListed->add('attacker');
// 3.
// Initialize the spam marker
$spamMarker = new SpamMarker();
// 4.
// Register the filters
$spamMarker->registerFilter($blackListed);
// 5.
// Check your string against filters
$spamMarkerResult = $spamMarker->check("
Hello, this is some text containing hacker and attacker
and should fail as it has a word that is black-listed
");
// var_dump ( $spamMarkerResult );
// It gives you two objects - is_spam (bool) and messages array
if ( $spamMarkerResult->passed() )
{
// Do some stuff, because the spam marker is passed
echo 'Your string doesn\'t contain the spam';
}
else
{
echo 'String containts the spam!';
}
// If you only want to see if it's failed then just...
if ( $spamMarkerResult->failed() ) {
// Do stuff
}
$loadedFilter->setOption('message', 'My own returning error message');
$config = array(
'message' => 'My own custom error message'
);
$blackListed = new BlackListed($config);