function summaryAsHTML($rev) { if (!($summary = $this->summary($rev))) { return ''; } return HTML::strong(array('class' => 'wiki-summary'), "(", TransformLinks($summary, $rev->get('markup'), $rev->getPageName()), ")"); }
/** * Handle AntiSpam here. How? http://wikiblacklist.blogspot.com/ * Need to check dynamically some blacklist wikipage settings * (plugin WikiAccessRestrictions) and some static blacklist. * DONE: * Always: More then 20 new external links * ENABLE_SPAMASSASSIN: content patterns by babycart (only php >= 4.3 for now) * ENABLE_SPAMBLOCKLIST: content domain blacklist */ function isSpam() { $current =& $this->current; $request =& $this->request; $oldtext = $current->getPackedContent(); $newtext =& $this->_content; // FIXME: in longer texts the NUM_SPAM_LINKS number should be increased. // better use a certain text : link ratio. // 1. Not more then 20 new external links if (defined("NUM_SPAM_LINKS")) { if ($this->numLinks($newtext) - $this->numLinks($oldtext) >= NUM_SPAM_LINKS) { // Allow strictly authenticated users? // TODO: mail the admin? $this->tokens['PAGE_LOCKED_MESSAGE'] = HTML($this->getSpamMessage(), HTML::p(HTML::strong(_("Too many external links.")))); return true; } } // 2. external babycart (SpamAssassin) check // This will probably prevent from discussing sex or viagra related topics. So beware. if (ENABLE_SPAMASSASSIN) { include_once "lib/spam_babycart.php"; if ($babycart = check_babycart($newtext, $request->get("REMOTE_ADDR"), $this->user->getId())) { // TODO: mail the admin if (is_array($babycart)) { $this->tokens['PAGE_LOCKED_MESSAGE'] = HTML($this->getSpamMessage(), HTML::p(HTML::em(_("SpamAssassin reports: "), join("\n", $babycart)))); } return true; } } // 3. extract (new) links and check surbl for blocked domains if (ENABLE_SPAMBLOCKLIST and $this->numLinks($newtext)) { include_once "lib/SpamBlocklist.php"; include_once "lib/InlineParser.php"; $parsed = TransformLinks($newtext); foreach ($parsed->_content as $link) { if (isa($link, 'Cached_ExternalLink')) { $uri = $link->_getURL($this->page->getName()); if ($res = IsBlackListed($uri)) { // TODO: mail the admin $this->tokens['PAGE_LOCKED_MESSAGE'] = HTML($this->getSpamMessage(), HTML::p(HTML::strong(_("External links contain blocked domains:")), HTML::ul(HTML::li(sprintf(_("%s is listed at %s"), $res[2], $res[0]))))); return true; } } } } return false; }