Index: trunk/extensions/CommentSpammer/CommentSpammer.php |
— | — | @@ -14,6 +14,12 @@ |
15 | 15 | } |
16 | 16 | |
17 | 17 | $wgExtensionFunctions[] = 'efCommentSpammer'; |
| 18 | +$wgExtensionCredits['other'][] = array( |
| 19 | + 'name' => 'CommentSpammer', |
| 20 | + 'author' => 'Nick Jenkins', |
| 21 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:CommentSpammer', |
| 22 | + 'description' => 'Rejects edits from suspected comment spammers on a DNS blacklist.', |
| 23 | +); |
18 | 24 | |
19 | 25 | function efCommentSpammer() { |
20 | 26 | global $wgMessageCache; |
— | — | @@ -25,7 +31,7 @@ |
26 | 32 | /** |
27 | 33 | * Add the hook on which we trigger. |
28 | 34 | */ |
29 | | -$wgHooks['EditFilter'][] = array( 'HoneyPotCommentSpammer::commentSpammerHook' ); |
| 35 | +$wgHooks['EditFilter'][] = 'HoneyPotCommentSpammer::commentSpammerHook'; |
30 | 36 | |
31 | 37 | /** |
32 | 38 | * Another log type, 'cSpammer', is added, if logging has been enabled, and appropriate |
— | — | @@ -37,7 +43,7 @@ |
38 | 44 | $wgLogTypes[] = 'cSpammer'; |
39 | 45 | $wgLogHeaders['cSpammer'] = 'cspammerlogpagetext'; |
40 | 46 | $wgLogNames['cSpammer'] = 'cspammer-log-page'; |
41 | | - $wgHooks['LogLine'][] = array( 'HoneyPotCommentSpammer::showLogLine' ); |
| 47 | + $wgHooks['LogLine'][] = 'HoneyPotCommentSpammer::showLogLine'; |
42 | 48 | } |
43 | 49 | |
44 | 50 | /** |
— | — | @@ -48,8 +54,8 @@ |
49 | 55 | class HoneyPotCommentSpammer { |
50 | 56 | |
51 | 57 | /** |
52 | | - * Class constants that relate to: http://www.projecthoneypot.org/httpbl_api.php |
53 | | - */ |
| 58 | + * Class constants that relate to: http://www.projecthoneypot.org/httpbl_api.php |
| 59 | + */ |
54 | 60 | const HONEY_POT_DNSBL = 'dnsbl.httpbl.org'; |
55 | 61 | const HONEY_POT_NO_ERROR = 127; // The "everything is a-okay" response code that we want to see. |
56 | 62 | const MAX_STALENESS = 14; // Number of days since this IP last spammed before we forgive. |
— | — | @@ -57,10 +63,10 @@ |
58 | 64 | const COMMENT_SPAMMER_CODE = 4; // The code for a comment spammer. |
59 | 65 | |
60 | 66 | /** |
61 | | - * Determines whether the specified IP address corresponds to a known active comment spammer. |
62 | | - * @param string $ip_addr A IP address string like '87.101.244.10' |
63 | | - * @return boolean True for spammer, false for non-spammer or if get unexpected results. |
64 | | - */ |
| 67 | + * Determines whether the specified IP address corresponds to a known active comment spammer. |
| 68 | + * @param string $ip_addr A IP address string like '87.101.244.10' |
| 69 | + * @return boolean True for spammer, false for non-spammer or if get unexpected results. |
| 70 | + */ |
65 | 71 | public static function isCommentSpammer( $ip_addr = null ) { |
66 | 72 | // logged in users are assumed to not be comment spammers. |
67 | 73 | global $wgUser; |
— | — | @@ -145,14 +151,14 @@ |
146 | 152 | } |
147 | 153 | |
148 | 154 | /** |
149 | | - * Determines whether the specified IP address corresponds to a known active comment spammer, and if |
150 | | - * so denies the edit and outputs a message to this effect. |
151 | | - * // @param EditPage $editPage EditPage object for page modification. |
152 | | - * // @param string $textbox The text the user submitted. (param not used) |
153 | | - * // @param string $section The section the user modified. (param not used) |
154 | | - * // @param string $hookError Return value for error about why the edit was rejected, if applicable. (param not used) |
155 | | - * @return boolean True for allowing the edit, false for denying the edit. |
156 | | - */ |
| 155 | + * Determines whether the specified IP address corresponds to a known active comment spammer, and if |
| 156 | + * so denies the edit and outputs a message to this effect. |
| 157 | + * // @param EditPage $editPage EditPage object for page modification. |
| 158 | + * // @param string $textbox The text the user submitted. (param not used) |
| 159 | + * // @param string $section The section the user modified. (param not used) |
| 160 | + * // @param string $hookError Return value for error about why the edit was rejected, if applicable. (param not used) |
| 161 | + * @return boolean True for allowing the edit, false for denying the edit. |
| 162 | + */ |
157 | 163 | public static function commentSpammerHook( /* $editPage = null, $textbox = '', $section = '', & $hookError = '' */ ) { |
158 | 164 | $spammer = self::isCommentSpammer( ); |
159 | 165 | if( $spammer ) { |
— | — | @@ -163,10 +169,10 @@ |
164 | 170 | } |
165 | 171 | |
166 | 172 | /** |
167 | | - * Gets the blacklist DNS response for the specified IP address. |
168 | | - * @param string $ip_addr A IP address string like '87.101.244.10' |
169 | | - * @return array DNS data as an array. |
170 | | - */ |
| 173 | + * Gets the blacklist DNS response for the specified IP address. |
| 174 | + * @param string $ip_addr A IP address string like '87.101.244.10' |
| 175 | + * @return array DNS data as an array. |
| 176 | + */ |
171 | 177 | private static function getDnsResults( $ip_addr ) { |
172 | 178 | global $wgHoneyPotKey; |
173 | 179 | |
— | — | @@ -184,11 +190,11 @@ |
185 | 191 | } |
186 | 192 | |
187 | 193 | /** |
188 | | - * Determines whether the DNS results indicate a spammer or not. |
189 | | - * @param array $result DNS data as an array. |
190 | | - * @param array $params Return array built with the response values from the DNS result. |
191 | | - * @return boolean True for spammer, false for non-spammer, or if get unexpected results. |
192 | | - */ |
| 194 | + * Determines whether the DNS results indicate a spammer or not. |
| 195 | + * @param array $result DNS data as an array. |
| 196 | + * @param array $params Return array built with the response values from the DNS result. |
| 197 | + * @return boolean True for spammer, false for non-spammer, or if get unexpected results. |
| 198 | + */ |
193 | 199 | private static function resultsSaySpammer( $result, & $params ) { |
194 | 200 | //wfDebug( __METHOD__ . ": Entering\n" ); |
195 | 201 | // if there was anything wrong with the data we got, assume they're |
— | — | @@ -238,4 +244,4 @@ |
239 | 245 | |
240 | 246 | } |
241 | 247 | |
242 | | -?> |
\ No newline at end of file |
| 248 | +?> |