Extension:RudeProxyBlock
From MediaWiki.org
|
RudeProxyBlock Release status: stable |
|
|---|---|
| Implementation | User rights |
| Description | This extension disallows all access made by an IP listed as an Open Proxy. |
| Author(s) | Daniel Friesen (DantmanTalk) |
| Last Version | 0.1 |
| License | No license specified |
| Download | see below |
Contents |
[edit] What can this extension do?
I built this extension on a request from Jack Phoenix when he wanted to be able to block all the open proxies that Wikipedia had blocked. I used a bot to grab all the pages in that category and turned it into a list. But unfortunately the block function in userlib.py was always returning a BlockError, so to allow Jack to block the users I instead built this quick extension which disallows access to all users listed in MediaWiki:Openproxylist.
[edit] Usage
To use the extension create a list of proxies at MediaWiki:Openproxylist on your wiki (One proxy per line, no extra text on those lines). Any IP listed there will not be allowed to edit or view pages and will be redirected to Special:RudeProxyBlock and will have a message displayed to them (When viewed from a normal IP the page is just a link back to the Main Page). You can customize the title using MediaWiki:Rudeproxyblock and the message using MediaWiki:Rudeproxyblockmsg.
[edit] Installation
Copy the code below into extensions/RudeProxyBlock.php and add the change to LocalSettings.php.
[edit] Changes to LocalSettings.php
require_once("$IP/extensions/RudeProxyBlock.php");
[edit] extensions/RudeProxyBlock.php
<?php /** * The RudeProxyBlock Extension's task's are: * - Auto Blocking and Restriction of users using an OpenProxy listed in MediaWiki:Openproxylist * * @package DantmanQuickExts * @subpackage RudeProxyBlock * @author Daniel Friesen (http://www.wikia.com/wiki/User:Dantman) (dan_the_man@telus.net) * @license http://www.gnu.org/copyleft/gpl.html GNU General Public Licence 2.0 or later */ if( !defined( 'MEDIAWIKI' ) ) die( "This is an extension to the MediaWiki package and cannot be run standalone." ); $wgExtensionFunctions[] = 'efRudeProxyBlockSetup'; require_once( "$IP/includes/SpecialPage.php" ); $wgExtensionCredits['other'][] = array( 'name' => 'RudeProxyBlock', 'author' => '[http://www.wikia.com/wiki/User:Dantman Daniel Friesen (aka: Dantman)]', 'url' => 'http://www.mediawiki.org/wiki/Extension:RudeProxyBlock', 'description' => 'An extension to block open proxies', ); $wgHooks['userCan'][] = "efBlockOpenProxies"; function efRudeProxyBlockSetup() { global $egOpenProxies, $egIsOpenProxy, $wgMessageCache; $egOpenProxies = explode("\n", wfMsg('openproxylist')); $egIsOpenProxy = in_array( wfGetIP(), $egOpenProxies ); $wgMessageCache->addMessages( array( 'rudeproxyblock' => "Rude Proxy Block", 'rudeproxyblockmsg' => "We're sorry, but you are using a IP address which is listed as an Open Proxy.\n\nThis site does not allow users to view or edit the site under an open proxy." ) ); SpecialPage::addPage( new SpecialRudeProxyBlock() ); } function efBlockOpenProxies( &$self, &$wgUser, $action, &$result ) { global $egIsOpenProxy, $wgOut; if( $egIsOpenProxy ) { $s = SpecialPage::getTitleFor( 'RudeProxyBlock' ); if( !$self->equals( $s ) ) { $result = false; $wgOut->redirect( $s->getFullURL() ); return false; } } return true; } class SpecialRudeProxyBlock extends SpecialPage { function SpecialRudeProxyBlock() { global $wgRequest; SpecialPage::SpecialPage( 'RudeProxyBlock', false, false, false, 'default', false ); } /** * Execute */ function execute( $par = null ) { global $wgOut, $egIsOpenProxy; $this->setHeaders(); if( $egIsOpenProxy ) { $wgOut->addHTML(wfMsg('rudeproxyblockmsg')); } else { $wgOut->returnToMain(); } } }

