From: moodler <moodler>
Date: Thu, 16 Oct 2003 09:33:27 +0000 (+0000)
Subject: A very simple filter to censor "bad" words.
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3e6525ba88656b2db96617f565861e3d9bfc6fb9;p=moodle.git

A very simple filter to censor "bad" words.

Also provides an example of how to write filters.
---

diff --git a/filter/censor/censor.php b/filter/censor/censor.php
new file mode 100644
index 0000000000..0b79ef7c97
--- /dev/null
+++ b/filter/censor/censor.php
@@ -0,0 +1,37 @@
+<?php // $id$
+//////////////////////////////////////////////////////////////
+//  Censorship filtering
+// 
+//  This very simple example of a Text Filter will parse
+//  printed text, replacing words with other words
+//
+//  To activate this filter, add a line like this to your
+//  config.php:
+//
+//  $CFG->textfilter1 = 'filter/censor/censor.php';
+//
+//////////////////////////////////////////////////////////////
+
+/// These lines are important - the variable must match the name 
+/// of the actual function below
+
+    $textfilter_function = 'censor_filter';
+
+    if (function_exists($textfilter_function)) {
+        return;
+    }
+
+
+/// This is the filtering function itself.  It accepts the 
+/// courseid and the text to be filtered (in HTML form).
+
+function censor_filter($courseid, $text) {
+
+    static $search  = array('fuck', 'cunt', 'shit', 'wank', 'cock');
+    static $replace = array('f***', 'c***', 's***', 'w***', 'c***');
+
+    return str_ireplace($search, $replace, $text);
+}
+
+
+?>