It should be a simple matter to deny edits that contain certain text.
This edit.php snippet appears to do just that:
if ( "save" == $formtype ) { # Check for spam if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) { $this->spamPage( $matches[0] ); return; } But I can't find where to set $wgSpamRegex (not in localSettings.php) , nor am I able to even add or replace its value directly in the code. I've tried inserting these two assignments
$wgSpamRegex = '1px;'; $wgSpamRegex .= '1px;';
directly before the "if" statement, and the edits still take place.
If I add a "PRINT $wgSpamRegex;" command to debug, it either shows the variable to be empty or doesn't display the debug text at all, depending on where in the code I put it.
Using version 1.3.x on a hosted site.
Surely, there is an easy solution....?
James Birkholz http://www.birchy.com/GenWiki
=James Birkholz= wrote:
It should be a simple matter to deny edits that contain certain text.
This edit.php snippet appears to do just that:
if ( "save" == $formtype ) { # Check for spam if ( $wgSpamRegex && preg_match( $wgSpamRegex,
$this->textbox1, $matches ) ) { $this->spamPage( $matches[0] ); return; } But I can't find where to set $wgSpamRegex (not in localSettings.php) ,
All configuration variables are to be set in LocalSettings.php; that is indeed the correct place to set it.
nor am I able to even add or replace its value directly in the code. I've tried inserting these two assignments
$wgSpamRegex = '1px;'; $wgSpamRegex .= '1px;';
If you have PHP set to display or log warnings you may see a warning printed on save; this is because you need to include a delimiter around the expression.
For more background, see the documentation:
http://www.php.net/manual/en/ref.pcre.php
-- brion vibber (brion @ pobox.com)
I added this line to localSettings.php:
$wgSpamRegex = "/1px;/";
(There was no existing code for $wgSpamRegex)
I had left my direct assignment in the edit.php code, so it changed the value to the old non-deliminated string, but when I found that and removed it, all works. Yay!
Then I tried to change the System Message to not reveal what piece of text triggered the spam filter. Now, it just says:
The page you wanted to save was blocked by the spam filter. If you are not a spammer, please [[User:WikiSysop|report this to the admin]].
But the spam text is still displayed. So then I found:
function spamPage( $match ) { global $wgOut; $wgOut->setPageTitle( wfMsg( "spamprotectiontitle" ) ); $wgOut->setRobotpolicy( "noindex,nofollow" ); $wgOut->setArticleRelated( false );
// $wgOut->addWikiText( wfMsg( "spamprotectiontext" ) . "\n\n" . $match ); $wgOut->addWikiText( wfMsg( "spamprotectiontext" ) );
So I removed the $match from the last line and all works.
Thanks!
mediawiki-l@lists.wikimedia.org