MediaWiki
master
|
Some functions to help implement an external link filter for spam control. More...
Static Public Member Functions | |
static | keepOneWildcard ($arr) |
Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder. | |
static | makeLikeArray ($filterEntry, $prot= 'http://') |
Make an array to be used for calls to DatabaseBase::buildLike(), which will match the specified string. | |
static | matchEntry (Content $content, $filterEntry) |
Check whether $content contains a link to $filterEntry. | |
Static Private Member Functions | |
static | makeRegex ($filterEntry) |
Builds a regex pattern for $filterEntry. |
Some functions to help implement an external link filter for spam control.
Another cool thing to do would be a web interface for fast spam removal.
Definition at line 34 of file LinkFilter.php.
static LinkFilter::keepOneWildcard | ( | $ | arr | ) | [static] |
Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder.
$arr | array: array to filter |
Definition at line 155 of file LinkFilter.php.
Referenced by LinkSearchPage\getQueryInfo(), and ApiQueryBase\prepareUrlQuerySearchString().
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.
$filterEntry | String: domainparts |
$prot | String: protocol |
Definition at line 92 of file LinkFilter.php.
References $path, array(), and wfGetDB().
Referenced by CleanupSpam\execute(), LinkSearchPage\mungeQuery(), and ApiQueryBase\prepareUrlQuerySearchString().
static LinkFilter::makeRegex | ( | $ | filterEntry | ) | [static, private] |
Builds a regex pattern for $filterEntry.
$filterEntry | String: URL, if it begins with "*.", it'll be replaced to match any subdomain |
Definition at line 64 of file LinkFilter.php.
Referenced by matchEntry().
static LinkFilter::matchEntry | ( | Content $ | content, |
$ | filterEntry | ||
) | [static] |
Check whether $content contains a link to $filterEntry.
$content | Content: content to check |
$filterEntry | String: domainparts, see makeRegex() for more details |
Definition at line 43 of file LinkFilter.php.
References Content\getNativeData(), and makeRegex().
Referenced by CleanupSpam\cleanupArticle().