2007-12-08 21:06:21 +00:00
|
|
|
<?php
|
2008-08-05 15:57:10 +00:00
|
|
|
/**
|
2008-08-08 23:26:44 +00:00
|
|
|
* Title Blacklist class
|
|
|
|
* @author VasilievVV
|
|
|
|
* @copyright © 2007 VasilievVV
|
2008-08-09 01:54:39 +00:00
|
|
|
* @license GNU General Public License 2.0 or later
|
|
|
|
* @file
|
|
|
|
*/
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
* @package MediaWiki
|
|
|
|
* @subpackage Extensions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a title blacklist for MediaWiki
|
2007-12-08 21:06:21 +00:00
|
|
|
*/
|
|
|
|
class TitleBlacklist {
|
2008-01-08 18:00:59 +00:00
|
|
|
private $mBlacklist = null, $mWhitelist = null;
|
|
|
|
const VERSION = 2; //Blacklist format
|
2007-12-08 21:06:21 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Load all configured blacklist sources
|
|
|
|
*/
|
2007-12-08 21:06:21 +00:00
|
|
|
public function load() {
|
2007-12-31 23:02:22 +00:00
|
|
|
global $wgTitleBlacklistSources, $wgMemc, $wgTitleBlacklistCaching;
|
2008-01-08 18:00:59 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2007-12-19 18:35:44 +00:00
|
|
|
//Try to find something in the cache
|
2007-12-31 23:02:22 +00:00
|
|
|
$cachedBlacklist = $wgMemc->get( wfMemcKey( "title_blacklist_entries" ) );
|
2008-01-08 18:00:59 +00:00
|
|
|
if( is_array( $cachedBlacklist ) && count( $cachedBlacklist ) > 0 && ( $cachedBlacklist[0]->getFormatVersion() == self::VERSION ) ) {
|
2007-12-19 18:35:44 +00:00
|
|
|
|
|
|
|
$this->mBlacklist = $cachedBlacklist;
|
2008-01-08 18:00:59 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2007-12-19 18:35:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-12-23 09:47:36 +00:00
|
|
|
|
2007-12-09 12:15:13 +00:00
|
|
|
$sources = $wgTitleBlacklistSources;
|
2007-12-10 19:02:38 +00:00
|
|
|
$sources[] = array( 'type' => TBLSRC_MSG );
|
2007-12-09 12:15:13 +00:00
|
|
|
$this->mBlacklist = array();
|
|
|
|
foreach( $sources as $source ) {
|
|
|
|
$this->mBlacklist = array_merge( $this->mBlacklist, $this->parseBlacklist( $this->getBlacklistText( $source ) ) );
|
|
|
|
}
|
2007-12-31 23:02:22 +00:00
|
|
|
$wgMemc->set( wfMemcKey( "title_blacklist_entries" ), $this->mBlacklist, $wgTitleBlacklistCaching['expiry'] );
|
2008-01-08 18:00:59 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
2008-01-08 18:00:59 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Load all configured whitelist sources
|
|
|
|
*/
|
2008-01-08 18:00:59 +00:00
|
|
|
public function loadWhitelist() {
|
|
|
|
global $wgMemc, $wgTitleBlacklistCaching;
|
|
|
|
wfProfileIn( __METHOD__ );
|
|
|
|
$cachedWhitelist = $wgMemc->get( wfMemcKey( "title_whitelist_entries" ) );
|
|
|
|
if( is_array( $cachedWhitelist ) && count( $cachedWhitelist ) > 0 && ( $cachedWhitelist[0]->getFormatVersion() != self::VERSION ) ) {
|
|
|
|
$this->mWhitelist = $cachedWhitelist;
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->mWhitelist = $this->parseBlacklist( wfMsgForContent( 'titlewhitelist' ) );
|
|
|
|
$wgMemc->set( wfMemcKey( "title_whitelist_entries" ), $this->mWhitelist, $wgTitleBlacklistCaching['expiry'] );
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Get the text of a blacklist from a specified source
|
|
|
|
*
|
|
|
|
* @param $source A blacklist source from $wgTitleBlacklistSources
|
|
|
|
* @return The content of the blacklist source as a string
|
|
|
|
*/
|
|
|
|
private static function getBlacklistText( $source ) {
|
2007-12-09 12:15:13 +00:00
|
|
|
if( !is_array( $source ) || count( $source ) <= 0 ) {
|
|
|
|
return ''; //Return empty string in error case
|
|
|
|
}
|
|
|
|
|
2007-12-10 19:02:38 +00:00
|
|
|
if( $source['type'] == TBLSRC_MSG ) {
|
2007-12-09 12:15:13 +00:00
|
|
|
return wfMsgForContent( 'titleblacklist' );
|
2007-12-10 19:02:38 +00:00
|
|
|
} elseif( $source['type'] == TBLSRC_LOCALPAGE && count( $source ) >= 2 ) {
|
|
|
|
$title = Title::newFromText( $source['src'] );
|
2007-12-09 12:15:13 +00:00
|
|
|
if( is_null( $title ) ) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if( $title->getNamespace() == NS_MEDIAWIKI ) { //Use wfMsgForContent() for getting messages
|
|
|
|
$msg = wfMsgForContent( $title->getText() );
|
|
|
|
if( !wfEmptyMsg( 'titleblacklist', $msg ) ) {
|
|
|
|
return $msg;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$article = new Article( $title );
|
|
|
|
if( $article->exists() ) {
|
|
|
|
$article->followRedirect();
|
|
|
|
return $article->getContent();
|
|
|
|
}
|
|
|
|
}
|
2007-12-10 19:02:38 +00:00
|
|
|
} elseif( $source['type'] == TBLSRC_URL && count( $source ) >= 2 ) {
|
2008-08-09 01:54:39 +00:00
|
|
|
return self::getHttp( $source['src'] );
|
2007-12-10 19:02:38 +00:00
|
|
|
} elseif( $source['type'] == TBLSRC_FILE && count( $source ) >= 2 ) {
|
|
|
|
if( file_exists( $source['src'] ) ) {
|
|
|
|
return file_get_contents( $source['src'] );
|
2007-12-09 12:15:13 +00:00
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Parse blacklist from a string
|
|
|
|
*
|
|
|
|
* @param $list Text of a blacklist source, as a string
|
|
|
|
* @return An array of TitleBlacklistEntry entries
|
|
|
|
*/
|
|
|
|
public static function parseBlacklist( $list ) {
|
2008-01-08 18:00:59 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2007-12-08 21:06:21 +00:00
|
|
|
$lines = preg_split( "/\r?\n/", $list );
|
|
|
|
$result = array();
|
|
|
|
foreach ( $lines as $line )
|
|
|
|
{
|
2007-12-10 19:02:38 +00:00
|
|
|
$line = TitleBlacklistEntry :: newFromString( $line );
|
|
|
|
if ( $line ) {
|
|
|
|
$result[] = $line;
|
|
|
|
}
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
|
|
|
|
2008-01-08 18:00:59 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2008-01-14 13:52:05 +00:00
|
|
|
return $result;
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Check whether the blacklist restricts the current User from
|
|
|
|
* performing a specific action on the given Title
|
|
|
|
*
|
|
|
|
* @param $title Title to check
|
|
|
|
* @param $action Action to check; 'edit' if unspecified
|
|
|
|
* @return The corresponding TitleBlacklistEntry if blacklisted;
|
|
|
|
* otherwise FALSE
|
|
|
|
*/
|
2007-12-10 19:02:38 +00:00
|
|
|
public function isBlacklisted( $title, $action = 'edit' ) {
|
|
|
|
global $wgUser;
|
|
|
|
if( !($title instanceof Title) ) {
|
2009-05-17 14:12:38 +00:00
|
|
|
$title = Title::newFromText( $title );
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
|
|
|
$blacklist = $this->getBlacklist();
|
|
|
|
foreach ( $blacklist as $item ) {
|
2007-12-15 15:29:56 +00:00
|
|
|
if( !$item->userCan( $title, $wgUser, $action ) ) {
|
2008-01-08 18:00:59 +00:00
|
|
|
if( $this->isWhitelisted( $title, $action ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
2007-12-17 18:38:34 +00:00
|
|
|
return $item;
|
2007-12-08 21:06:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Check whether it has been explicitly whitelisted that the
|
|
|
|
* current User may perform a specific action on the given Title
|
|
|
|
*
|
|
|
|
* @param $title Title to check
|
|
|
|
* @param $action Action to check; 'edit' if unspecified
|
|
|
|
* @return TRUE if whitelisted; otherwise FALSE
|
|
|
|
*/
|
2008-01-08 18:00:59 +00:00
|
|
|
public function isWhitelisted( $title, $action = 'edit' ) {
|
|
|
|
global $wgUser;
|
|
|
|
if( !($title instanceof Title) ) {
|
2009-05-17 14:12:38 +00:00
|
|
|
$title = Title::newFromText( $title );
|
2008-01-08 18:00:59 +00:00
|
|
|
}
|
|
|
|
$whitelist = $this->getWhitelist();
|
|
|
|
foreach( $whitelist as $item ) {
|
|
|
|
if( !$item->userCan( $title, $wgUser, $action ) ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Get the current blacklist
|
|
|
|
*
|
|
|
|
* @return Array of TitleBlacklistEntry items
|
|
|
|
*/
|
2007-12-08 21:06:21 +00:00
|
|
|
public function getBlacklist() {
|
|
|
|
if( is_null( $this->mBlacklist ) ) {
|
|
|
|
$this->load();
|
|
|
|
}
|
|
|
|
return $this->mBlacklist;
|
|
|
|
}
|
2007-12-19 18:35:44 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/*
|
|
|
|
* Get the current whitelist
|
|
|
|
*
|
|
|
|
* @return Array of TitleBlacklistEntry items
|
|
|
|
*/
|
2008-01-08 18:00:59 +00:00
|
|
|
public function getWhitelist() {
|
|
|
|
if( is_null( $this->mWhitelist ) ) {
|
|
|
|
$this->loadWhitelist();
|
|
|
|
}
|
|
|
|
return $this->mWhitelist;
|
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Get the text of a blacklist source via HTTP
|
|
|
|
*
|
|
|
|
* @param $source URL of the blacklist source
|
|
|
|
* @return The content of the blacklist source as a string
|
|
|
|
*/
|
|
|
|
private static function getHttp( $url ) {
|
2007-12-31 23:02:22 +00:00
|
|
|
global $messageMemc, $wgTitleBlacklistCaching;
|
|
|
|
$key = "title_blacklist_source:" . md5( $url ); // Global shared
|
|
|
|
$warnkey = wfMemcKey( "titleblacklistwarning", md5( $url ) );
|
2007-12-19 18:35:44 +00:00
|
|
|
$result = $messageMemc->get( $key );
|
|
|
|
$warn = $messageMemc->get( $warnkey );
|
|
|
|
if ( !is_string( $result ) || ( !$warn && !mt_rand( 0, $wgTitleBlacklistCaching['warningchance'] ) ) ) {
|
|
|
|
$result = Http::get( $url );
|
|
|
|
$messageMemc->set( $warnkey, 1, $wgTitleBlacklistCaching['warningexpiry'] );
|
|
|
|
$messageMemc->set( $key, $result, $wgTitleBlacklistCaching['expiry'] );
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
2007-12-23 09:47:36 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Invalidate the blacklist cache
|
|
|
|
*/
|
2007-12-23 09:47:36 +00:00
|
|
|
public function invalidate() {
|
2007-12-31 23:02:22 +00:00
|
|
|
global $wgMemc;
|
|
|
|
$wgMemc->delete( wfMemcKey( "title_blacklist_entries" ) );
|
2007-12-23 09:47:36 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Validate a new blacklist
|
|
|
|
*
|
|
|
|
* @param $list Text of the new blacklist, as a string
|
|
|
|
* @return Array of bad entries; empty array means blacklist is valid
|
|
|
|
*/
|
2007-12-23 09:47:36 +00:00
|
|
|
public function validate( $blacklist ) {
|
|
|
|
$badEntries = array();
|
|
|
|
foreach( $blacklist as $e ) {
|
|
|
|
wfSuppressWarnings();
|
|
|
|
$regex = $e->getRegex();
|
|
|
|
if( preg_match( "/{$regex}/u", '' ) === false )
|
|
|
|
$badEntries[] = $e->getRaw();
|
|
|
|
wfRestoreWarnings();
|
|
|
|
}
|
|
|
|
return $badEntries;
|
|
|
|
}
|
2007-12-10 19:02:38 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a title blacklist entry
|
|
|
|
*/
|
2007-12-10 19:02:38 +00:00
|
|
|
class TitleBlacklistEntry {
|
|
|
|
private
|
2008-08-09 01:54:39 +00:00
|
|
|
$mRaw, ///< Raw line
|
|
|
|
$mRegex, ///< Regular expression to match
|
|
|
|
$mParams, ///< Parameters for this entry
|
|
|
|
$mFormatVersion; ///< Entry format version
|
2007-12-10 19:02:38 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Construct a new TitleBlacklistEntry.
|
|
|
|
*
|
|
|
|
* @param $regex Regular expression to match
|
|
|
|
* @param $params Parameters for this entry
|
|
|
|
* @param $raw Raw contents of this line
|
|
|
|
*/
|
|
|
|
private function __construct( $regex, $params, $raw ) {
|
2007-12-10 19:02:38 +00:00
|
|
|
$this->mRaw = $raw;
|
|
|
|
$this->mRegex = $regex;
|
|
|
|
$this->mParams = $params;
|
2008-01-08 18:00:59 +00:00
|
|
|
$this->mFormatVersion = TitleBlacklist::VERSION;
|
2007-12-10 19:02:38 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Check whether the specified User can perform the specified action
|
|
|
|
* on the specified Title
|
|
|
|
*
|
|
|
|
* @param $title Title to check
|
|
|
|
* @param $user User to check
|
|
|
|
* @param $action %Action to check
|
|
|
|
* @return TRUE if the user can; otherwise FALSE
|
|
|
|
*/
|
2007-12-10 19:02:38 +00:00
|
|
|
public function userCan( $title, $user, $action ) {
|
|
|
|
if( $user->isAllowed( 'tboverride' ) ) {
|
|
|
|
return true;
|
|
|
|
}
|
2007-12-23 09:47:36 +00:00
|
|
|
wfSuppressWarnings();
|
2008-05-21 23:00:39 +00:00
|
|
|
$match = preg_match( "/^(?:{$this->mRegex})$/us" . ( isset( $this->mParams['casesensitive'] ) ? '' : 'i' ), $title->getFullText() );
|
2007-12-23 09:47:36 +00:00
|
|
|
wfRestoreWarnings();
|
|
|
|
if( $match ) {
|
2007-12-10 19:02:38 +00:00
|
|
|
if( isset( $this->mParams['autoconfirmed'] ) && $user->isAllowed( 'autoconfirmed' ) ) {
|
2007-12-15 15:29:56 +00:00
|
|
|
return true;
|
2007-12-10 19:02:38 +00:00
|
|
|
}
|
2008-05-21 23:23:24 +00:00
|
|
|
if( isset( $this->mParams['moveonly'] ) && $action != 'move' ) {
|
|
|
|
return true;
|
|
|
|
}
|
2008-08-09 01:54:39 +00:00
|
|
|
if( isset( $this->mParams['newaccountonly'] ) && $action != 'new-account' ) {
|
|
|
|
return true;
|
|
|
|
}
|
2007-12-10 19:02:38 +00:00
|
|
|
if( !isset( $this->mParams['noedit'] ) && $action == 'edit' ) {
|
2007-12-15 15:29:56 +00:00
|
|
|
return true;
|
2007-12-10 19:02:38 +00:00
|
|
|
}
|
2008-05-22 01:35:48 +00:00
|
|
|
if ( isset( $this->mParams['reupload'] ) && $action == 'upload' ) {
|
|
|
|
// Special:Upload also checks 'create' permissions when not reuploading
|
2008-04-20 21:21:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-12-15 15:29:56 +00:00
|
|
|
return false;
|
2007-12-10 19:02:38 +00:00
|
|
|
}
|
2007-12-15 15:29:56 +00:00
|
|
|
return true;
|
2007-12-10 19:02:38 +00:00
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* Create a new TitleBlacklistEntry from a line of text
|
|
|
|
*
|
|
|
|
* @param $line String containing a line of blacklist text
|
|
|
|
* @return A new corresponding TitleBlacklistEntry
|
|
|
|
*/
|
2007-12-10 19:02:38 +00:00
|
|
|
public static function newFromString( $line ) {
|
2007-12-29 04:23:57 +00:00
|
|
|
$raw = $line; // Keep line for raw data
|
2007-12-10 19:02:38 +00:00
|
|
|
$regex = "";
|
|
|
|
$options = array();
|
2007-12-29 04:23:57 +00:00
|
|
|
// Strip comments
|
2007-12-10 19:02:38 +00:00
|
|
|
$line = preg_replace( "/^\\s*([^#]*)\\s*((.*)?)$/", "\\1", $line );
|
|
|
|
$line = trim( $line );
|
2007-12-29 04:23:57 +00:00
|
|
|
// Parse the rest of message
|
2008-05-29 20:23:05 +00:00
|
|
|
preg_match( '/^(.*?)(\s*<([^<>]*)>)?$/', $line, $pockets );
|
2007-12-10 19:02:38 +00:00
|
|
|
@list( $full, $regex, $null, $opts_str ) = $pockets;
|
|
|
|
$regex = trim( $regex );
|
2008-01-03 00:58:52 +00:00
|
|
|
$regex = str_replace( '_', ' ', $regex ); // We'll be matching against text form
|
2007-12-10 19:02:38 +00:00
|
|
|
$opts_str = trim( $opts_str );
|
2007-12-29 04:23:57 +00:00
|
|
|
// Parse opts
|
2007-12-10 19:02:38 +00:00
|
|
|
$opts = preg_split( '/\s*\|\s*/', $opts_str );
|
|
|
|
foreach( $opts as $opt ) {
|
2007-12-14 17:54:06 +00:00
|
|
|
$opt2 = strtolower( $opt );
|
|
|
|
if( $opt2 == 'autoconfirmed' ) {
|
2007-12-10 19:02:38 +00:00
|
|
|
$options['autoconfirmed'] = true;
|
|
|
|
}
|
2008-05-21 23:23:24 +00:00
|
|
|
if( $opt2 == 'moveonly' ) {
|
|
|
|
$options['moveonly'] = true;
|
|
|
|
}
|
2008-08-09 01:54:39 +00:00
|
|
|
if( $opt2 == 'newaccountonly' ) {
|
|
|
|
$options['newaccountonly'] = true;
|
|
|
|
}
|
2007-12-14 17:54:06 +00:00
|
|
|
if( $opt2 == 'noedit' ) {
|
2007-12-10 19:02:38 +00:00
|
|
|
$options['noedit'] = true;
|
|
|
|
}
|
2007-12-14 17:54:06 +00:00
|
|
|
if( $opt2 == 'casesensitive' ) {
|
|
|
|
$options['casesensitive'] = true;
|
|
|
|
}
|
2008-04-20 21:21:16 +00:00
|
|
|
if( $opt2 == 'reupload' ) {
|
|
|
|
$options['reupload'] = true;
|
|
|
|
}
|
2007-12-17 18:38:34 +00:00
|
|
|
if( preg_match( '/errmsg\s*=\s*(.+)/i', $opt, $matches ) ) {
|
|
|
|
$options['errmsg'] = $matches[1];
|
|
|
|
}
|
2007-12-14 17:54:06 +00:00
|
|
|
}
|
2007-12-29 04:23:57 +00:00
|
|
|
// Process magic words
|
2007-12-17 18:38:34 +00:00
|
|
|
preg_match_all( '/{{\s*([a-z]+)\s*:\s*(.+?)\s*}}/', $regex, $magicwords, PREG_SET_ORDER );
|
2007-12-14 17:54:06 +00:00
|
|
|
foreach( $magicwords as $mword ) {
|
2007-12-29 04:23:57 +00:00
|
|
|
global $wgParser; // Functions we're calling don't need, nevertheless let's use it
|
2007-12-14 17:54:06 +00:00
|
|
|
switch( strtolower( $mword[1] ) ) {
|
|
|
|
case 'ns':
|
|
|
|
$cpf_result = CoreParserFunctions::ns( $wgParser, $mword[2] );
|
|
|
|
if( is_string( $cpf_result ) ) {
|
2007-12-29 04:23:57 +00:00
|
|
|
$regex = str_replace( $mword[0], $cpf_result, $regex ); // All result will have the same value, so we can just use str_seplace()
|
2007-12-14 17:54:06 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'int':
|
2007-12-17 18:38:34 +00:00
|
|
|
$cpf_result = wfMsgForContent( $mword[2] );
|
2007-12-14 17:54:06 +00:00
|
|
|
if( is_string( $cpf_result ) ) {
|
|
|
|
$regex = str_replace( $mword[0], $cpf_result, $regex );
|
|
|
|
}
|
|
|
|
}
|
2007-12-10 19:02:38 +00:00
|
|
|
}
|
2007-12-29 04:23:57 +00:00
|
|
|
// Return result
|
2007-12-10 19:02:38 +00:00
|
|
|
if( $regex ) {
|
|
|
|
return new TitleBlacklistEntry( $regex, $options, $raw );
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* @returns This entry's regular expression
|
|
|
|
*/
|
2007-12-10 19:02:38 +00:00
|
|
|
public function getRegex() {
|
|
|
|
return $this->mRegex;
|
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* @returns This entry's raw line
|
|
|
|
*/
|
2007-12-10 19:02:38 +00:00
|
|
|
public function getRaw() {
|
|
|
|
return $this->mRaw;
|
|
|
|
}
|
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* @returns This entry's options
|
|
|
|
*/
|
2007-12-10 19:02:38 +00:00
|
|
|
public function getOptions() {
|
|
|
|
return $this->mOptions;
|
|
|
|
}
|
2007-12-17 18:38:34 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* @returns Custom message for this entry
|
|
|
|
*/
|
2007-12-17 18:38:34 +00:00
|
|
|
public function getCustomMessage() {
|
|
|
|
return isset( $this->mParams['errmsg'] ) ? $this->mParams['errmsg'] : null;
|
|
|
|
}
|
2007-12-19 18:35:44 +00:00
|
|
|
|
2008-08-09 01:54:39 +00:00
|
|
|
/**
|
|
|
|
* @returns The format version
|
|
|
|
*/
|
2007-12-19 18:35:44 +00:00
|
|
|
public function getFormatVersion() { return $this->mFormatVersion; }
|
2008-08-09 01:54:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the format version
|
|
|
|
*
|
|
|
|
* @param $v New version to set
|
|
|
|
*/
|
2007-12-19 18:35:44 +00:00
|
|
|
public function setFormatVersion( $v ) { $this->mFormatVersion = $v; }
|
2008-01-08 18:00:59 +00:00
|
|
|
}
|
2008-08-09 01:54:39 +00:00
|
|
|
|
|
|
|
//@}
|