diff --git a/modules/banned-regexps.pl b/modules/banned-regexps.pl index 725497f3..21e20b0e 100644 --- a/modules/banned-regexps.pl +++ b/modules/banned-regexps.pl @@ -67,14 +67,17 @@ sub RegexpNewBannedContent { my ($regexp, $comment, $re) = ($1, $4, undef); eval { $re = qr/$regexp/i; }; if (defined($re) && $str =~ $re) { - $rule = Tss('Rule "%1" matched on this page.', QuoteHtml($regexp)) . ' ' + my $explanation = ($1 + ? Tss('Regular expression "%1" matched "%2" on this page.', QuoteHtml($regexp), $1) + : Ts('Regular expression "%s" matched on this page.', QuoteHtml($regexp))); + $rule = $explanation . ' ' . ($comment ? Ts('Reason: %s.', $comment) : T('Reason unknown.')) . ' ' - . Ts('See %s for more information.', GetPageLink($BannedRegexps)); + . Ts('See %s for more information.', GetPageLink($BannedRegexps)); last; } } } - LogBannedContent($rule) if $rule and $BannedFile; + LogWrite($rule) if $rule and $BannedFile; return $rule if $rule; return 0; } diff --git a/modules/logbannedcontent.pl b/modules/logbannedcontent.pl index 2a973ed2..ab5cf00f 100755 --- a/modules/logbannedcontent.pl +++ b/modules/logbannedcontent.pl @@ -20,25 +20,31 @@ use vars qw($BannedFile); $BannedFile = "$DataDir/spammer.log" unless defined $BannedFile; -*OldBannedContent = *BannedContent; -*BannedContent = *LogBannedContent; -$BannedContent = $OldBannedContent; # copy variable +*LogOldBannedContent = *BannedContent; +*BannedContent = *LogNewBannedContent; +$BannedContent = $LogOldBannedContent; # copy variable -sub LogBannedContent { +sub LogNewBannedContent { my $str = shift; - my $rule = OldBannedContent($str); - if ($rule) { - my $visitor = $ENV{'REMOTE_ADDR'}; - ($sec, $min, $hr, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); - $year=$year+1900; - $mon += 1; - # Fix for 0's - $mon = sprintf("%02d", $mon); - $mday = sprintf("%02d", $mday); - $sec = sprintf("%02d", $sec); - $min = sprintf("%02d", $min); - $hr = sprintf("%02d", $hr); - AppendStringToFile($BannedFile, "$year/$mon/$mday\t$hr:$min:$sec\t$visitor: $OpenPageName - $rule\n"); - } + my $rule = LogOldBannedContent($str); + LogWrite($rule) if $rule; return $rule; } + +*LogOldUserIsBanned = *UserIsBanned; +*UserIsBanned = *LogNewUserIsBanned; + +sub LogNewUserIsBanned { + my $str = shift; + my $rule = LogOldUserIsBanned($str); + LogWrite(Ts('Host or IP matched %s', $rule)) if $rule; + return $rule; +} + +sub LogWrite { + my $rule = shift; + my $id = $OpenPageName || GetId(); + AppendStringToFile($BannedFile, + join("\t", TimeToW3($Now), $ENV{'REMOTE_ADDR'}, $id, $rule) + . "\n"); +} diff --git a/modules/toc-js.pl b/modules/toc-js.pl new file mode 100644 index 00000000..a5022734 --- /dev/null +++ b/modules/toc-js.pl @@ -0,0 +1,98 @@ +# Copyright (C) 2013 Alex Schroeder +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program. If not, see . + +package OddMuse; + +$ModulesDescription .= '

toc-js.pl, see Javascript Table of Contents Extension

'; + +use vars qw($TocOutlineLibrary); + +$TocOutlineLibrary = 'http://h5o.googlecode.com/files/outliner.0.5.0.62.js'; + +# Add the dojo script to edit pages. +push (@MyInitVariables, \&TocScript); + +sub TocScript { + # cookie is not initialized yet so we cannot use GetParam + # Cross browser compatibility: http://www.tek-tips.com/faqs.cfm?fid=4862 + # HTML5 Outlines: http://blog.tremily.us/posts/HTML5_outlines/ + # Required library: http://code.google.com/p/h5o/ + if (GetParam('action', 'browse') eq 'browse') { + $HtmlHeaders .= qq{ + + +}; + } +}