]> git.mjollnir.org Git - moodle.git/commitdiff
A very simple filter to censor "bad" words.
authormoodler <moodler>
Thu, 16 Oct 2003 09:33:27 +0000 (09:33 +0000)
committermoodler <moodler>
Thu, 16 Oct 2003 09:33:27 +0000 (09:33 +0000)
Also provides an example of how to write filters.

filter/censor/censor.php [new file with mode: 0644]

diff --git a/filter/censor/censor.php b/filter/censor/censor.php
new file mode 100644 (file)
index 0000000..0b79ef7
--- /dev/null
@@ -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);
+}
+
+
+?>