<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://www.cookipedia.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=How_to_stop_Spam_on_a_MediaWiki</id>
	<title>How to stop Spam on a MediaWiki - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.cookipedia.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=How_to_stop_Spam_on_a_MediaWiki"/>
	<link rel="alternate" type="text/html" href="https://www.cookipedia.co.uk/wiki/index.php?title=How_to_stop_Spam_on_a_MediaWiki&amp;action=history"/>
	<updated>2026-04-03T21:35:50Z</updated>
	<subtitle>Revision history for this page on [[Cookipedia]]</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://www.cookipedia.co.uk/wiki/index.php?title=How_to_stop_Spam_on_a_MediaWiki&amp;diff=258312&amp;oldid=prev</id>
		<title>Chef at 04:52, 1 October 2020</title>
		<link rel="alternate" type="text/html" href="https://www.cookipedia.co.uk/wiki/index.php?title=How_to_stop_Spam_on_a_MediaWiki&amp;diff=258312&amp;oldid=prev"/>
		<updated>2020-10-01T04:52:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;!-- seo --&amp;gt;&lt;br /&gt;
{{#seo:&lt;br /&gt;
|title=How to stop Spam on a MediaWiki&lt;br /&gt;
|titlemode=replace&lt;br /&gt;
|keywords=#howtostopspamonamediawiki #stonebakedspampizza #cookipedia #help #trustedusers &lt;br /&gt;
|hashtagrev=12032020&lt;br /&gt;
|description=Cookipedia has been running for about three and a half years and over that period of time we have had problems with spammers&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;!-- /seo --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Spam pizza recipe.jpg|thumb|300px|right|[[Stone baked Spam pizza]]]]&lt;br /&gt;
[[Cookipedia]] has been running for about three and a half years and over that period of time we have had problems with spammers.&lt;br /&gt;
&lt;br /&gt;
Since we have now managed to stop spam completely, I thought it might be useful to let others know how we managed this.&lt;br /&gt;
&lt;br /&gt;
The steps we took may not be suitable for every Wiki but they work well for us. However, you&amp;#039;ll probably be able to take some tips and ideas away with you.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Most of these tasks require systems skills and privileged server access.  Contact your ISP for assistance if you are not comfortable with any of these tasks.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
==How we stopped the spam==&lt;br /&gt;
====Enforce registration for editing====&lt;br /&gt;
This does prevent free and easy editing, however, we were regularly attacked until we enforced registration.&lt;br /&gt;
&lt;br /&gt;
* Add the following to LocalSettings.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   #Restrict anonymous editing&lt;br /&gt;
   $wgGroupPermissions[&amp;#039;*&amp;#039;][&amp;#039;edit&amp;#039;] = false;&lt;br /&gt;
&lt;br /&gt;
   #Anonymous users cannot create new pages&lt;br /&gt;
   $wgGroupPermissions[&amp;#039;*&amp;#039;][&amp;#039;createpage&amp;#039;] = false;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Enforce email confirmation before editing is allowed====&lt;br /&gt;
A user has to reply to a system generated email before they are allowed to edit an article. This means they have provide (and potentially use-up) a valid email address. It also means that they have to waste a little more of their time in the process.&lt;br /&gt;
* Add the following to LocalSettings.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   # force email when registering&lt;br /&gt;
   # email must be confirmed before edits allowed&lt;br /&gt;
   $wgEmailConfirmToEdit = true;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Prevent inclusion of external links to new or untrusted users====&lt;br /&gt;
This made the biggest difference of all.  No spammer wants to add anything to your wiki unless they can place a link to their website.&lt;br /&gt;
&lt;br /&gt;
New users will be unable to add an external link to any page &amp;#039;&amp;#039;or&amp;#039;&amp;#039; make an edit to a page that has an existing external link until an Admin had added them to the [[TrustedUsers]] page.  Once in this file they are allowed to add and edit links.&lt;br /&gt;
&lt;br /&gt;
* Install MediaWiki:Extension: [https://www.mediawiki.org/wiki/Extension:NotEvil Extension:NotEvil]&lt;br /&gt;
&lt;br /&gt;
I also made a small change to the [https://php.net/manual/en/function.preg-match.php Regex] so it included a block on more than just https:&lt;br /&gt;
&lt;br /&gt;
Around line 71 of mediawiki-spamcallback.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   if(preg_match(&amp;#039;/https|www\.|\.co\.uk|\.com|\.net/&amp;#039;,$diff)){&lt;br /&gt;
      $reason = &amp;#039;direct links are forbidden&amp;#039;;&lt;br /&gt;
      $block = true;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Install a [https://en.wikipedia.org/wiki/CAPTCHA CAPTCHA system]====&lt;br /&gt;
Not sure if this has made much difference as there have been a few attackers that appear to have found a way around this. However it is trivial to setup and it&amp;#039;s one more hoop they have to jump through.&lt;br /&gt;
* Install MediaWiki:Extension: [https://www.mediawiki.org/wiki/Extension:ReCAPTCHA ReCAPTCHA]&lt;br /&gt;
* Add the following to LocalSettings.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# reCaptcha&lt;br /&gt;
require_once( &amp;quot;$IP/extensions/recaptcha/ReCaptcha.php&amp;quot; );&lt;br /&gt;
// Sign up for these at https://www.google.com/recaptcha/admin/create&lt;br /&gt;
$recaptcha_public_key = &amp;#039;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&amp;#039;;&lt;br /&gt;
$recaptcha_private_key = &amp;#039;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&amp;#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
====Bulk removal of pages by user or IP====&lt;br /&gt;
* Install: https://www.mediawiki.org/wiki/Extension:Nuke&lt;br /&gt;
===Permanently blocking the spammers===&lt;br /&gt;
Once The above changes were implemented, apart from the day I ballsed-up the regex, we have not had any spam whatsoever.&lt;br /&gt;
&lt;br /&gt;
When we identify a user that has attempted to spam our Wiki, we block them forever.&lt;br /&gt;
* [[Special:BlockUser]]&lt;br /&gt;
&lt;br /&gt;
We also block any users that fit the profile of a spammer.  See the [[Special:BlockList|block list]] for the &amp;#039;&amp;#039;Walks like a duck&amp;#039;&amp;#039; entries.  They are fairly obvious. We still have a &amp;#039;&amp;#039;Contact the Editor&amp;#039;&amp;#039; method, should we inadvertently block a good-guy.&lt;br /&gt;
&lt;br /&gt;
====Discover the IP address of the spammers====&lt;br /&gt;
[https://www.mediawiki.org/wiki/Extension:CheckUser CheckUser] will allow an Admin to discover the IP address of a User.&lt;br /&gt;
&lt;br /&gt;
* Install MediaWiki:Extension: [https://www.mediawiki.org/wiki/Extension:CheckUser CheckUser]&lt;br /&gt;
* Add the following to localSettings.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   # enable extension:CheckUser&lt;br /&gt;
   include_once(&amp;quot;$IP/extensions/CheckUser/CheckUser.php&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This enables an administrator to discover the [https://en.wikipedia.org/wiki/IP_address IP address] of the user who attempted to spam your Wiki.  &lt;br /&gt;
&lt;br /&gt;
====Once you&amp;#039;ve spotted a bad guy, keep &amp;#039;em out forever====&lt;br /&gt;
[[File:40px-Dialog-warning.svg.png|40px]] Blocking a user by IP address means they will never be able to view your site at all from that address.  That may be too strict for you.  &amp;#039;&amp;#039;&amp;#039;There are many pitfalls in blocking visitors by IP address.&amp;#039;&amp;#039;&amp;#039;  If you are not careful you can block many thousands of users, prevent search engines from spidering your site, even restrict access from entire countries. &amp;#039;&amp;#039;Do not attempt this unless you know what you are doing!&amp;#039;&amp;#039; You have been warned!&lt;br /&gt;
&lt;br /&gt;
* Using the [https://httpd.apache.org/docs/2.2/howto/access.html deny from pragma], add the IP addresses of spammers to your vhost.conf file&lt;br /&gt;
* Check your Apache error_log on a daily basis to keep an eye on who you have been blocking. Blocked users will have an entry similar to this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Sat Feb 18 17:50:17 2012] [error] [client 64.120.31.41] client denied by server configuration: /home/httpd/vhosts/cookipedia.co.uk/httpdocs/wiki/index.php, referer: None&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* This is our current IP block list: [[File:vhost.conf.txt]]&lt;br /&gt;
====Good luck!====&lt;br /&gt;
I hope you have found even just some of this this useful. --[[User:Chef|Chef]] 05:38, 19 February 2012 (GMT)&lt;br /&gt;
==See also==&lt;br /&gt;
* MediaWiki Extensions: https://www.mediawiki.org/wiki/Category:Extensions &lt;br /&gt;
** Not Evil: https://www.mediawiki.org/wiki/Extension:NotEvil&lt;br /&gt;
** ReCAPTCHA: https://www.mediawiki.org/wiki/Extension:ReCAPTCHA&lt;br /&gt;
** CheckUser: https://www.mediawiki.org/wiki/Extension:CheckUser&lt;br /&gt;
** Mass deletion: https://www.mediawiki.org/wiki/Extension:Nuke&lt;br /&gt;
* What is CAPTCHA: https://en.wikipedia.org/wiki/CAPTCHA&lt;br /&gt;
* PHP regular expressions: https://php.net/manual/en/function.preg-match.php&lt;br /&gt;
* IP Addresses: https://en.wikipedia.org/wiki/IP_address&lt;br /&gt;
** Apache Access control docs: https://httpd.apache.org/docs/2.2/howto/access.html&lt;br /&gt;
** Block Website Harvesters (huge lists): https://www.wizcrafts.net/exploited-servers-blocklist.html&lt;br /&gt;
* MediaWiki Anti-spam features: https://www.mediawiki.org/wiki/Anti-spam_features&lt;br /&gt;
** Combat Spam: https://www.mediawiki.org/wiki/Manual:Combating_spam&lt;br /&gt;
** Combat Vandalism: https://www.mediawiki.org/wiki/Manual:Combating_vandalism &lt;br /&gt;
&lt;br /&gt;
{{CategoryLineIngredients}}&lt;br /&gt;
[[Category:Useful information]]&lt;br /&gt;
[[Category:Help]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- footer hashtags --&amp;gt;&amp;lt;code &amp;#039;hashtagrev:12032020&amp;#039;&amp;gt;[[Special:Search/howtostopspamonamediawiki|#howtostopspamonamediawiki]] [[Special:Search/stonebakedspampizza|#stonebakedspampizza]] [[Special:Search/cookipedia|#cookipedia]] [[Special:Search/help|#help]] [[Special:Search/trustedusers|#trustedusers]] &lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;!-- /footer hashtags --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Chef</name></author>
	</entry>
</feed>