diff options
author | andi <andi@splitbrain.org> | 2005-03-31 16:57:49 +0200 |
---|---|---|
committer | andi <andi@splitbrain.org> | 2005-03-31 16:57:49 +0200 |
commit | 0cecf9d507451346a32ddf45a85b425784fbb0f8 (patch) | |
tree | 076dd2d128f55022792b4bfab42c1d2d2bec4fb8 /inc/parser/spamcheck.php | |
parent | c53ea5f2d3d1019fd4e1956796bc329af499a86d (diff) | |
download | rpg-0cecf9d507451346a32ddf45a85b425784fbb0f8.tar.gz rpg-0cecf9d507451346a32ddf45a85b425784fbb0f8.tar.bz2 |
new parser added (define DOKU_USENEWPARSER to use it)
darcs-hash:20050331145749-9977f-f011ea6c65a278197e9087b685c635c60a204cd2.gz
Diffstat (limited to 'inc/parser/spamcheck.php')
-rw-r--r-- | inc/parser/spamcheck.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/inc/parser/spamcheck.php b/inc/parser/spamcheck.php new file mode 100644 index 000000000..1c2958e6f --- /dev/null +++ b/inc/parser/spamcheck.php @@ -0,0 +1,72 @@ +<?php +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); + +require_once DOKU_INC . 'inc/parser/renderer.php'; + +class Doku_Renderer_SpamCheck extends Doku_Renderer { + + // This should be populated by the code executing the instructions + var $currentCall; + + // An array of instructions that contain spam + var $spamFound = array(); + + // pcre pattern for finding spam + var $spamPattern = '#^$#'; + + function internallink($link, $title = NULL) { + $this->__checkTitle($title); + } + + function externallink($link, $title = NULL) { + $this->__checkLinkForSpam($link); + $this->__checkTitle($title); + } + + function interwikilink($link, $title = NULL) { + $this->__checkTitle($title); + } + + function filelink($link, $title = NULL) { + $this->__checkLinkForSpam($link); + $this->__checkTitle($title); + } + + function windowssharelink($link, $title = NULL) { + $this->__checkLinkForSpam($link); + $this->__checkTitle($title); + } + + function email($address, $title = NULL) { + $this->__checkLinkForSpam($address); + $this->__checkTitle($title); + } + + function internalmedialink ($src) { + $this->__checkLinkForSpam($src); + } + + function externalmedialink($src) { + $this->__checkLinkForSpam($src); + } + + function __checkTitle($title) { + if ( is_array($title) && isset($title['src'])) { + $this->__checkLinkForSpam($title['src']); + } + } + + // Pattern matching happens here + /** + * @TODO What about links like www.google.com - no http:// + */ + function __checkLinkForSpam($link) { + if( preg_match($this->spamPattern,$link) ) { + $spam = $this->currentCall; + $spam[3] = $link; + $this->spamFound[] = $spam; + } + } +} + +?> |