Please review:
http://banbuilder.com/
To install BanBuilder, simply include it in your project's composer.json.
"snipe/banbuilder": "dev-master",
And then run composer update. There are no additional dependencies required for this package to work.
Usage:
use Snipe\BanBuilder\CensorWords;
$censor = new CensorWords;
$string = $censor->censorString($yourstring);
This returns $string as an array, where you can access $string['clean'] for the cleaned version of the $yourstring, or $string['orig'], which will give you the original $yourstring.
Is this relatively easy enough to incorporate into flarum without needing an extension?
Where would I include use Snipe\BanBuilder\CensorWords;
CommentPost.php?
Then what would be the string to use?
Besides censoring foul language, it could also be used to filter out goo.gl shortened urls and other site links.
There is also this project:
https://github.com/sworup/ProfanityFilter