Code Monkey home page Code Monkey logo

php-spam-filter's Introduction

Here is a quick example of the use:

require_once 'php-spam-filter/spamfilter.php';
$text = "Do you want to purchase some [url=shadywebsite.ca]Canadian viagra[/url] from me?";

// Search in a specific blacklist (absolute paths can be used instead)
$filter = new SpamFilter(['blacklist-trading.txt']);
$result = $filter->check_text($text);
if ($result)
{
    echo "You like talking about economics and trading, right? Go away!";
}


// Search in all available blacklists
$filter = new SpamFilter();

$result = $filter->check_text($text);
if ($result)
{
    // Result contains the matched word (not the matched regular expression)
    // In our example, $result will contain the value "viagra".
    echo "There is a special place in hell reserved for people who talk about '$result' on my blog!";
}
else
{
	echo "Your comment is clean from all known spam!";
}

There is an additional function named spam_check_url(), but is currently just an alias for spam_check_text() until I have it wired up as I want it.

An example use of this library can be seen in IQAndreas/jekyll-static-comments.

The blacklists are stored as a submodule just to ease in updating the lists via automated scripts. For details on the formatting to use in the blacklists, see blacklists/README.md.

License

Pre-emptively released under GPLv3, but I may change this in the future to suit the needs of others.

I hate writing documentation.

php-spam-filter's People

Contributors

iqandreas avatar

Watchers

James Cloos avatar Praveen Maurya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.