summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klier <chi@chimeric.de>2008-10-12 19:48:49 +0200
committerMichael Klier <chi@chimeric.de>2008-10-12 19:48:49 +0200
commite403cc58e0f623c70da4018a6eb869464dc97996 (patch)
treeaf18ed4af50d92871d1b9323d85787aaaf768400
parente3e6ab3c9a02ebb58211cd1b0ebc26437d0c1827 (diff)
downloadrpg-e403cc58e0f623c70da4018a6eb869464dc97996.tar.gz
rpg-e403cc58e0f623c70da4018a6eb869464dc97996.tar.bz2
FS#1024 new Event COMMON_WORDBLOCK_BLOCKED
This event allows action plugins to take action if a wordblock occurs. Event data: data[matches] - array of wordblock matches data[userinfo] - detailed userinfo [ip] - ip address [user] - username (if logged in) [name] - real name (if logged in) [mail] - mail address (if logged in) darcs-hash:20081012174849-23886-0ac42addc14ee3e36e961272de229a6002d052e9.gz
-rw-r--r--inc/common.php28
1 files changed, 26 insertions, 2 deletions
diff --git a/inc/common.php b/inc/common.php
index a8a6dd5ff..1532c523a 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -510,11 +510,26 @@ function script($script='doku.php'){
* Checks the wikitext against a list of blocked expressions
* returns true if the text contains any bad words
*
+ * Triggers COMMON_WORDBLOCK_BLOCKED
+ *
+ * Action Plugins can use this event to inspect the blocked data
+ * and gain information about the user who was blocked.
+ *
+ * Event data:
+ * data['matches'] - array of matches
+ * data['userinfo'] - information about the blocked user
+ * [ip] - ip address
+ * [user] - username (if logged in)
+ * [mail] - mail address (if logged in)
+ * [name] - real name (if logged in)
+ *
* @author Andreas Gohr <andi@splitbrain.org>
+ * Michael Klier <chi@chimeric.de>
*/
function checkwordblock(){
global $TEXT;
global $conf;
+ global $INFO;
if(!$conf['usewordblock']) return false;
@@ -542,8 +557,17 @@ function checkwordblock(){
if(empty($block)) continue;
$re[] = $block;
}
- if(count($re) && preg_match('#('.join('|',$re).')#si',$text)) {
- return true;
+ if(count($re) && preg_match('#('.join('|',$re).')#si',$text,$matches)) {
+ //prepare event data
+ $data['matches'] = $matches;
+ $data['userinfo']['ip'] = $_SERVER['REMOTE_ADDR'];
+ if($_SERVER['REMOTE_USER']) {
+ $data['userinfo']['user'] = $_SERVER['REMOTE_USER'];
+ $data['userinfo']['name'] = $INFO['userinfo']['name'];
+ $data['userinfo']['mail'] = $INFO['userinfo']['mail'];
+ }
+ $callback = create_function('', 'return true;');
+ return trigger_event('COMMON_WORDBLOCK_BLOCKED', $data, $callback, true);
}
}
return false;