LinkFilter Class Reference

Some functions to help implement an external link filter for spam control. More...

List of all members.

Static Public Member Functions

static matchEntry ($text, $filterEntry)
 Check whether $text contains a link to $filterEntry.
static makeLike ($filterEntry, $prot= 'http://')
 Make a string to go after an SQL LIKE, which will match the specified string.
static makeLikeArray ($filterEntry, $prot= 'http://')
 Make an array to be used for calls to DatabaseBase::buildLike(), which will match the specified string.
static keepOneWildcard ($arr)
 Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder.

Static Private Member Functions

static makeRegex ($filterEntry)
 Builds a regex pattern for $filterEntry.


Detailed Description

Some functions to help implement an external link filter for spam control.

Todo:
implement the filter. Currently these are just some functions to help maintenance/cleanupSpam.php remove links to a single specified domain. The next thing is to implement functions for checking a given page against a big list of domains.
Another cool thing to do would be a web interface for fast spam removal.

Definition at line 13 of file LinkFilter.php.


Member Function Documentation

static LinkFilter::keepOneWildcard ( arr  )  [static]

Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder.

Parameters:
$arr array: array to filter
Returns:
filtered array

Definition at line 161 of file LinkFilter.php.

Referenced by LinkSearchPage::getSQL(), and ApiQueryExtLinksUsage::run().

static LinkFilter::makeLike ( filterEntry,
prot = 'http://' 
) [static]

Make a string to go after an SQL LIKE, which will match the specified string.

There are several kinds of filter entry: *.domain.com - Produces http://com.domain.%, matches domain.com and www.domain.com domain.com - Produces http://com.domain./%, matches domain.com or domain.com/ but not www.domain.com *.domain.com/x - Produces http://com.domain.%/x%, matches www.domain.com/xy domain.com/x - Produces http://com.domain./x%, matches domain.com/xy but not www.domain.com/xy

Asterisks in any other location are considered invalid.

Parameters:
$filterEntry String: domainparts
$prot String: protocol
Returns:
String
Deprecated:
Use makeLikeArray() and pass result to Database::buildLike() instead

Definition at line 63 of file LinkFilter.php.

References $dbw, $s, makeLikeArray(), wfDeprecated(), and wfGetDB().

static LinkFilter::makeLikeArray ( filterEntry,
prot = 'http://' 
) [static]

Make an array to be used for calls to DatabaseBase::buildLike(), which will match the specified string.

There are several kinds of filter entry: *.domain.com - Produces http://com.domain.%, matches domain.com and www.domain.com domain.com - Produces http://com.domain./%, matches domain.com or domain.com/ but not www.domain.com *.domain.com/x - Produces http://com.domain.%/x%, matches www.domain.com/xy domain.com/x - Produces http://com.domain./x%, matches domain.com/xy but not www.domain.com/xy

Asterisks in any other location are considered invalid.

Parameters:
$filterEntry String: domainparts
$prot String: protocol
Returns:
Array to be passed to DatabaseBase::buildLike() or false on error

Definition at line 98 of file LinkFilter.php.

References $path, and wfGetDB().

Referenced by CleanupSpam::execute(), makeLike(), LinkSearchPage::mungeQuery(), and ApiQueryExtLinksUsage::run().

static LinkFilter::makeRegex ( filterEntry  )  [static, private]

Builds a regex pattern for $filterEntry.

Parameters:
$filterEntry String: URL, if it begins with "*.", it'll be replaced to match any subdomain
Returns:
String: regex pattern, for preg_match()

Definition at line 34 of file LinkFilter.php.

Referenced by matchEntry().

static LinkFilter::matchEntry ( text,
filterEntry 
) [static]

Check whether $text contains a link to $filterEntry.

Parameters:
$text String: text to check
$filterEntry String: domainparts, see makeRegex() for more details
Returns:
Integer: 0 if no match or 1 if there's at least one match

Definition at line 22 of file LinkFilter.php.

References makeRegex().

Referenced by CleanupSpam::cleanupArticle().


The documentation for this class was generated from the following file:

Generated on Sat Apr 30 22:57:42 2011 for MediaWiki by  doxygen 1.5.9