User:Leucosticte/RudeSpamBlock

RudeProxyBlock.php
<?php /** * The RudeProxyBlock Extension's task's are: * - Auto Blocking and Restriction of users using an OpenProxy listed in MediaWiki:Openproxylist * * @file * @ingroup Extensions * @version 0.1 * @author Daniel Friesen (https://www.mediawiki.org/wiki/User:Dantman) (mediawiki@danielfriesen.name) * @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'; $wgExtensionMessagesFiles['RudeProxyBlock'] = __DIR__. '/RudeProxyBlock.i18n.php'; $wgAutoloadClasses['SpecialRudeProxyBlock'] = __DIR__. '/SpecialRudeProxyBlock.php'; $wgSpecialPages['RudeProxyBlock'] = 'SpecialRudeProxyBlock';

$wgExtensionCredits['antispam'][] = array(	'name' => 'RudeProxyBlock',	'version' => '1.0.2',	'author' => array( 'Daniel Friesen (aka: Dantman)', 'Nathan Larson (aka: Leucosticte)' ),	'url' => 'https://www.mediawiki.org/wiki/Extension:RudeProxyBlock',	'description' => 'An extension to block open proxies' );

$wgHooks['userCan'][] = 'efBlockOpenProxies'; $wgRudeProxyBlockDelimiter = "\n"; $wgRudeProxyBlockActions = array( "edit" ); // This doesn't actually do anything useful

function efRudeProxyBlockSetup { global $egOpenProxies, $egIsOpenProxy, $wgMessageCache, $wgRudeProxyBlockDelimiter; $egOpenProxies = explode( $wgRudeProxyBlockDelimiter, wfMsg( 'openproxylist' ) ); $egIsOpenProxy = in_array( wfGetIP, $egOpenProxies ); }

function efBlockOpenProxies( &$self, &$wgUser, $action, &$result ) { global $egIsOpenProxy, $wgOut, $wgRudeProxyBlockActions; global $wgProxyList; $ip = $wgUser->getRequest->getIP; $wgProxyList[] = $ip; /*	if ( !is_array( $wgRudeProxyBlockActions ) ) { $wgRudeProxyBlockActions = array( $wgRudeProxyBlockActions ); }	if( $egIsOpenProxy && in_array( $action, $wgRudeProxyBlockActions ) && $self->getFullText !=		wfMessage( 'rudeproxyblock-page' )->plain ) { die ( $action ); $s = SpecialPage::getTitleFor( 'RudeProxyBlock' ); if( !$self->equals( $s ) ) { $result = false; $wgOut->redirect( $s->getFullURL ); return false; }	}*/	return true; }

RudeProxyBlock.i18n.php
 'Rude Proxy Block',    'rudeproxyblock-msg' => "We're sorry, but you are using a IP address which is listed as an Open Proxy. This site does not allow users to view or edit the site under an open proxy. If you feel you have reached this message in error, please leave a message at Project:WikiProject on open proxies/Requests.",    'rudeproxyblock-page' => "Project:WikiProject on open proxies/Requests" );
 * @author Nathan Larson (Leucosticte)

SpecialRudeProxyBlock.php
getOutput;

$this->setHeaders;

if( $egIsOpenProxy ) { $output->addWikiMsg( 'rudeproxyblock-msg',                           wfMessage( 'rudeproxyblock-page' )->plain ); } else { $output->returnToMain; }

} }