Index: trunk/phase3/includes/LinkFilter.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | /** |
5 | 5 | * Some functions to help implement an external link filter for spam control. |
6 | 6 | * |
7 | | - * TODO: implement the filter. Currently these are just some functions to help |
| 7 | + * @todo implement the filter. Currently these are just some functions to help |
8 | 8 | * maintenance/cleanupSpam.php remove links to a single specified domain. The |
9 | 9 | * next thing is to implement functions for checking a given page against a big |
10 | 10 | * list of domains. |
— | — | @@ -11,8 +11,13 @@ |
12 | 12 | * Another cool thing to do would be a web interface for fast spam removal. |
13 | 13 | */ |
14 | 14 | class LinkFilter { |
| 15 | + |
15 | 16 | /** |
16 | | - * @static |
| 17 | + * Check whether $text contains a link to $filterEntry |
| 18 | + * |
| 19 | + * @param $text String: text to check |
| 20 | + * @param $filterEntry String: domainparts, see makeRegex() for more details |
| 21 | + * @return Integer: 0 if no match or 1 if there's at least one match |
17 | 22 | */ |
18 | 23 | static function matchEntry( $text, $filterEntry ) { |
19 | 24 | $regex = LinkFilter::makeRegex( $filterEntry ); |
— | — | @@ -20,7 +25,11 @@ |
21 | 26 | } |
22 | 27 | |
23 | 28 | /** |
24 | | - * @static |
| 29 | + * Builds a regex pattern for $filterEntry. |
| 30 | + * |
| 31 | + * @param $filterEntry String: URL, if it begins with "*.", it'll be |
| 32 | + * replaced to match any subdomain |
| 33 | + * @return String: regex pattern, for preg_match() |
25 | 34 | */ |
26 | 35 | private static function makeRegex( $filterEntry ) { |
27 | 36 | $regex = '!http://'; |
— | — | @@ -46,9 +55,9 @@ |
47 | 56 | * |
48 | 57 | * Asterisks in any other location are considered invalid. |
49 | 58 | * |
50 | | - * @static |
51 | 59 | * @param $filterEntry String: domainparts |
52 | 60 | * @param $prot String: protocol |
| 61 | + * @return String |
53 | 62 | * @deprecated Use makeLikeArray() and pass result to Database::buildLike() instead |
54 | 63 | */ |
55 | 64 | public static function makeLike( $filterEntry , $prot = 'http://' ) { |
— | — | @@ -69,8 +78,8 @@ |
70 | 79 | } |
71 | 80 | |
72 | 81 | /** |
73 | | - * Make an array to be used for calls to Database::buildLike(), which will match the specified |
74 | | - * string. There are several kinds of filter entry: |
| 82 | + * Make an array to be used for calls to DatabaseBase::buildLike(), which |
| 83 | + * will match the specified string. There are several kinds of filter entry: |
75 | 84 | * *.domain.com - Produces http://com.domain.%, matches domain.com |
76 | 85 | * and www.domain.com |
77 | 86 | * domain.com - Produces http://com.domain./%, matches domain.com |
— | — | @@ -81,10 +90,10 @@ |
82 | 91 | * domain.com/xy but not www.domain.com/xy |
83 | 92 | * |
84 | 93 | * Asterisks in any other location are considered invalid. |
85 | | - * |
86 | | - * @static |
| 94 | + * |
87 | 95 | * @param $filterEntry String: domainparts |
88 | 96 | * @param $prot String: protocol |
| 97 | + * @return Array to be passed to DatabaseBase::buildLike() or false on error |
89 | 98 | */ |
90 | 99 | public static function makeLikeArray( $filterEntry , $prot = 'http://' ) { |
91 | 100 | $db = wfGetDB( DB_MASTER ); |
— | — | @@ -145,7 +154,7 @@ |
146 | 155 | |
147 | 156 | /** |
148 | 157 | * Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder. |
149 | | - * @static |
| 158 | + * |
150 | 159 | * @param $arr array: array to filter |
151 | 160 | * @return filtered array |
152 | 161 | */ |