Jump to content

Extension:WikiBanHammer

From mediawiki.org
MediaWiki extensions manual
WikiBanHammer
Release status: unmaintained
Implementation User identity , User activity
Description Automatically trap and block bots that don't obey robots.txt rules
Author(s) Morgan Shatee Byers (jehovahsaystalk)
Latest version 1.1
MediaWiki 1.29
PHP PHP7
License GNU General Public License 2.0 or later
Download
README.md
Example Website example
wfLoadExtension( 'WikiBanHammer' );

WikiBanHammer Automatically trap and block bots that don't obey robots.txt rules

Installation

[edit]
  • Download and place the file(s) in a directory called WikiBanHammer in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'WikiBanHammer' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Trouble shooting

[edit]

Protect Your MediaWiki with a Blackhole for Bad Bots
I decided to create an MediaWiki Extension from a PHP script

that i found on a website at https://perishablepress.com/blackhole-bad-bots/

If you are better at building this extension please create a branch.
I will slowly add the files and instruction on how i installed this
PHP on to my MediaWiki website.
If you would like to see how WikiBanHammer blocks spam bots
visit my MediaWiki website www.jehovahsays.net
explore random pages & then visit www.jehovahsays.net/blackhole/
And you will see that if you were a bot that you would be banned from all my MediaWiki pages
globally.

Warning!

WikiBanHammer can ban you from your own MediaWiki website.
In order to unban yourself you will need to open the
file named blackhole.dat and remove your ip address and save.

How to install & configure MediaWiki Extension:WikiBanHammer

Step 1.
Download the .zip
unzip WikiBanHammer.zip
rename the unzipped folder named WikiBanHammer-master to WikiBanHammer.
copy and paste WikiBanHammer into your MediaWiki extensions folder.
You can also use command line
Change Directory to your extensions folder
git clone https://github.com/jehovahsays/WikiBanHammer.git

Step 2.
Use Notepad++ to edit these next few files.
open the folder named blackhole.
open the file named blackhole.php
edit line 39 if you need to allow
legit bots to index your website.
after you finish doing that scroll down
to line 66 and edit the contact url or email
just in case a human got banned.
save the file blackhole.php
when your done.

Next open the file named index.php
edit lines 37 & 38 to your
email if you need to receive alerts
everytime a bot is banned.

Next scroll down to
line 203 change the title of the web page
banned users will see and line 216 & line 238
to change the contact information just case
again a human quote on quote happen to get banned.
save the file index.php
when your done.

Step 3.
copy the file robots.txt and the
folder named blackhole into your root folder
for example after you copy and paste
you website url should look like this
www.example.com/robots.txt
www.example.com/blackhole/

blackhole.dat must be server-writable log file (serves as the blacklist)

Step 4.
Open you mediawiki installation folder
open the folder named includes
open the file named Webstart.php
scroll down to line 35
and add this code

include(realpath(getenv('DOCUMENT_ROOT')) .'/blackhole/blackhole.php');

save the file when your done.

Step 5.
Add the code below to your Localsettings.php

wfLoadExtension( 'WikiBanHammer' );

Step 6.
finally the last step
open your mediawiki folder
open the folder named skins
open the folder named Vector
open the file named VectorTemplate.php
scroll down to line line 97
add this html code to all your pages

<a rel="nofollow" style="display:none;" href="/blackhole/">
Usually only robot could see this text.
But , if you can see this text.
Do NOT follow this link or you will be banned from the site!</a>

Testing the WikiBanHammer
Test WikiBanHammer by visiting blackhole
open your browser
and visit www.yourdomain.com/blackhole/
you should see a you are banned page
navigate to your mediawiki pages and
you should see your banned on every page.

to unban yourself open the folder named blackhole
open the file named blackhole.dat look for your ip
delete your ip and save the file and you are unbanned.

To make WikiBanHammer stonger redirect all of your error pages
to the folder /blackhole/

I will make a video for those who need visual verification & confirmation.

that i found on a website at
https://perishablepress.com/blackhole-bad-bots/

If you are better at building this extension please create a branch.
I will slowly add the files and instruction on how i installed this
PHP on to my Mediawiki website.