[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/ -> LinkFilter.php (summary)

Functions to help implement an external link filter for spam control. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 190 lines (6 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class

LinkFilter:: (4 methods):
  matchEntry()
  makeRegex()
  makeLikeArray()
  keepOneWildcard()


Class: LinkFilter  - X-Ref

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

matchEntry( Content $content, $filterEntry )   X-Ref
Check whether $content contains a link to $filterEntry

param: Content $content Content to check
param: string $filterEntry Domainparts, see makeRegex() for more details
return: int 0 if no match or 1 if there's at least one match

makeRegex( $filterEntry )   X-Ref
Builds a regex pattern for $filterEntry.

param: string $filterEntry URL, if it begins with "*.", it'll be
return: string Regex pattern, for preg_match()

makeLikeArray( $filterEntry, $protocol = 'http:)   X-Ref
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.

This function does the same as wfMakeUrlIndexes(), except it also takes care
of adding wildcards

param: string $filterEntry Domainparts
param: string $protocol Protocol (default http://)
return: array Array to be passed to DatabaseBase::buildLike() or false on error

keepOneWildcard( $arr )   X-Ref
Filters an array returned by makeLikeArray(), removing everything past first
pattern placeholder.

param: array $arr Array to filter
return: array Filtered array



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1