Index: trunk/extensions/AbuseFilter/AbuseFilter.php |
— | — | @@ -58,14 +58,14 @@ |
59 | 59 | $wgAPIListModules['abuselog'] = 'ApiQueryAbuseLog'; |
60 | 60 | $wgAutoloadClasses['ApiQueryAbuseFilters'] = "$dir/api/ApiQueryAbuseFilters.php"; |
61 | 61 | $wgAPIListModules['abusefilters'] = 'ApiQueryAbuseFilters'; |
62 | | -$wgAutoloadClasses['ApiCheckFilterSyntax'] = "$dir/api/ApiCheckFilterSyntax.php"; |
63 | | -$wgAPIModules['checkfiltersyntax'] = 'ApiCheckFilterSyntax'; |
64 | | -$wgAutoloadClasses['ApiEvalFilterExpression'] = "$dir/api/ApiEvalFilterExpression.php"; |
65 | | -$wgAPIModules['evalfilterexpression'] = 'ApiEvalFilterExpression'; |
66 | | -$wgAutoloadClasses['ApiUnblockAutopromote'] = "$dir/api/ApiUnblockAutopromote.php"; |
67 | | -$wgAPIModules['unblockautopromote'] = 'ApiUnblockAutopromote'; |
68 | | -$wgAutoloadClasses['ApiCheckFilterMatch'] = "$dir/api/ApiCheckFilterMatch.php"; |
69 | | -$wgAPIModules['checkfiltermatch'] = 'ApiCheckFilterMatch'; |
| 62 | +$wgAutoloadClasses['ApiAbuseFilterCheckSyntax'] = "$dir/api/ApiAbuseFilterCheckSyntax.php"; |
| 63 | +$wgAPIModules['abusefilterchecksyntax'] = 'ApiAbuseFilterCheckSyntax'; |
| 64 | +$wgAutoloadClasses['ApiAbuseFilterEvalExpression'] = "$dir/api/ApiAbuseFilterEvalExpression.php"; |
| 65 | +$wgAPIModules['abusefilterevalexpression'] = 'ApiAbuseFilterEvalExpression'; |
| 66 | +$wgAutoloadClasses['ApiAbuseFilterUnblockAutopromote'] = "$dir/api/ApiAbuseFilterUnblockAutopromote.php"; |
| 67 | +$wgAPIModules['abusefilterunblockautopromote'] = 'ApiAbuseFilterUnblockAutopromote'; |
| 68 | +$wgAutoloadClasses['ApiAbuseFilterCheckMatch'] = "$dir/api/ApiAbuseFilterCheckMatch.php"; |
| 69 | +$wgAPIModules['abusefiltercheckmatch'] = 'ApiAbuseFilterCheckMatch'; |
70 | 70 | |
71 | 71 | $wgHooks['EditFilterMerged'][] = 'AbuseFilterHooks::onEditFilterMerged'; |
72 | 72 | $wgHooks['GetAutoPromoteGroups'][] = 'AbuseFilterHooks::onGetAutoPromoteGroups'; |
Index: trunk/extensions/AbuseFilter/modules/ext.abuseFilter.edit.js |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | this.disabled = true; |
42 | 42 | $.getJSON( |
43 | 43 | mw.util.wikiScript( 'api' ), { |
44 | | - action: 'checkfiltersyntax', |
| 44 | + action: 'abusefilterchecksyntax', |
45 | 45 | filter: filter, |
46 | 46 | format: 'json' |
47 | 47 | }, that.processSyntaxResult |
Index: trunk/extensions/AbuseFilter/modules/ext.abuseFilter.examine.js |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | // Large amount of data |
38 | 38 | $.post( |
39 | 39 | mw.util.wikiScript( 'api' ), $.extend( params, { |
40 | | - action: 'checkfiltermatch', |
| 40 | + action: 'abusefiltercheckmatch', |
41 | 41 | filter: filter, |
42 | 42 | format: 'json' |
43 | 43 | } ), that.examinerTestProcess, 'json' |
Index: trunk/extensions/AbuseFilter/modules/ext.abuseFilter.tools.js |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | $( this ).injectSpinner( 'abusefilter-expr' ); |
17 | 17 | $.getJSON( |
18 | 18 | mw.util.wikiScript( 'api' ), { |
19 | | - action: 'evalfilterexpression', |
| 19 | + action: 'abusefilterevalexpression', |
20 | 20 | expression: expr, |
21 | 21 | format: 'json' |
22 | 22 | }, that.processExprResult |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | $( this ).injectSpinner( 'abusefilter-reautoconfirm' ); |
49 | 49 | $.post( |
50 | 50 | mw.util.wikiScript( 'api' ), { |
51 | | - action: 'unblockautopromote', |
| 51 | + action: 'abusefilterunblockautopromote', |
52 | 52 | user: name, |
53 | 53 | token: mw.user.tokens.get( 'editToken' ), |
54 | 54 | format: 'json' |
Index: trunk/extensions/AbuseFilter/api/ApiCheckFilterMatch.php |
— | — | @@ -1,114 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -class ApiCheckFilterMatch extends ApiBase { |
5 | | - public function execute() { |
6 | | - global $wgUser; |
7 | | - $params = $this->extractRequestParams(); |
8 | | - $this->requireOnlyOneParameter( $params, 'vars', 'rcid', 'logid' ); |
9 | | - |
10 | | - // "Anti-DoS" |
11 | | - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
12 | | - $this->dieUsageMsg( 'permissiondenied' ); |
13 | | - } |
14 | | - |
15 | | - if ( $params['vars'] ) { |
16 | | - $vars = json_decode( $params['vars'], true ); |
17 | | - } elseif ( $params['rcid'] ) { |
18 | | - $dbr = wfGetDB( DB_SLAVE ); |
19 | | - $row = $dbr->selectRow( |
20 | | - 'recentchanges', |
21 | | - '*', |
22 | | - array( 'rc_id' => $params['rcid'] ), |
23 | | - __METHOD__ |
24 | | - ); |
25 | | - |
26 | | - if ( !$row ) { |
27 | | - $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) ); |
28 | | - } |
29 | | - |
30 | | - $vars = AbuseFilter::getVarsFromRCRow( $row ); |
31 | | - } elseif ( $params['logid'] ) { |
32 | | - $dbr = wfGetDB( DB_SLAVE ); |
33 | | - $row = $dbr->selectRow( |
34 | | - 'abuse_filter_log', |
35 | | - '*', |
36 | | - array( 'afl_id' => $params['logid'] ), |
37 | | - __METHOD__ |
38 | | - ); |
39 | | - |
40 | | - if ( !$row ) { |
41 | | - $this->dieUsage( |
42 | | - "There is no abuselog entry with the id ``{$params['logid']}''", |
43 | | - 'nosuchlogid' |
44 | | - ); |
45 | | - } |
46 | | - |
47 | | - $vars = AbuseFilter::loadVarDump( $row->afl_var_dump ); |
48 | | - } |
49 | | - |
50 | | - if ( AbuseFilter::checkSyntax( $params[ 'filter' ] ) !== true ) { |
51 | | - $this->dieUsage( 'The filter has invalid syntax', 'badsyntax' ); |
52 | | - } |
53 | | - |
54 | | - $result = AbuseFilter::checkConditions( $params['filter'], $vars ); |
55 | | - $this->getResult()->addValue( |
56 | | - null, |
57 | | - $this->getModuleName(), |
58 | | - array( 'result' => $result ) |
59 | | - ); |
60 | | - } |
61 | | - |
62 | | - public function getAllowedParams() { |
63 | | - return array( |
64 | | - 'filter' => array( |
65 | | - ApiBase::PARAM_REQUIRED => true, |
66 | | - ), |
67 | | - 'vars' => null, |
68 | | - 'rcid' => array( |
69 | | - ApiBase::PARAM_TYPE => 'integer' |
70 | | - ), |
71 | | - 'logid' => array( |
72 | | - ApiBase::PARAM_TYPE => 'integer' |
73 | | - ), |
74 | | - ); |
75 | | - } |
76 | | - |
77 | | - public function getParamDescription() { |
78 | | - return array( |
79 | | - 'filter' => 'The full filter text to check for a match', |
80 | | - 'vars' => 'JSON encoded array of variables to test against', |
81 | | - 'rcid' => 'Recent change ID to check against', |
82 | | - 'logid' => 'Abuse filter log ID to check against', |
83 | | - ); |
84 | | - } |
85 | | - |
86 | | - public function getDescription() { |
87 | | - return array( |
88 | | - 'Check to see if an AbuseFilter matches a set of variables, edit' |
89 | | - . 'or logged AbuseFilter event.', |
90 | | - 'vars, rcid or logid is required however only one may be used', |
91 | | - ); |
92 | | - } |
93 | | - |
94 | | - public function getPossibleErrors() { |
95 | | - return array_merge( parent::getPossibleErrors(), |
96 | | - $this->getRequireOnlyOneParameterErrorMessages( array( 'vars', 'rcid', 'logid' ) ), |
97 | | - array( |
98 | | - array( 'permissiondenied' ), |
99 | | - array( 'nosuchrcid' ), |
100 | | - array( 'code' => 'nosuchlogid', 'info' => 'There is no abuselog entry with the id given' ), |
101 | | - array( 'code' => 'badsyntax', 'info' => 'The filter has invalid syntax' ), |
102 | | - ) |
103 | | - ); |
104 | | - } |
105 | | - |
106 | | - public function getExamples() { |
107 | | - return array( |
108 | | - 'api.php?action=checkfiltermatch&filter=!("autoconfirmed"%20in%20user_groups)&rcid=15' |
109 | | - ); |
110 | | - } |
111 | | - |
112 | | - public function getVersion() { |
113 | | - return __CLASS__ . ': $Id$'; |
114 | | - } |
115 | | -} |
Index: trunk/extensions/AbuseFilter/api/ApiCheckFilterSyntax.php |
— | — | @@ -1,67 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -class ApiCheckFilterSyntax extends ApiBase { |
5 | | - |
6 | | - public function execute() { |
7 | | - global $wgUser; |
8 | | - |
9 | | - // "Anti-DoS" |
10 | | - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
11 | | - $this->dieUsageMsg( 'permissiondenied' ); |
12 | | - } |
13 | | - |
14 | | - $params = $this->extractRequestParams(); |
15 | | - $result = AbuseFilter::checkSyntax( $params[ 'filter' ] ); |
16 | | - |
17 | | - $r = array(); |
18 | | - if ( $result === true ) { |
19 | | - // Everything went better than expected :) |
20 | | - $r['status'] = 'ok'; |
21 | | - } else { |
22 | | - $r = array( |
23 | | - 'status' => 'error', |
24 | | - 'message' => $result[0], |
25 | | - 'character' => $result[1], |
26 | | - ); |
27 | | - } |
28 | | - |
29 | | - $this->getResult()->addValue( null, $this->getModuleName(), $r ); |
30 | | - } |
31 | | - |
32 | | - public function getAllowedParams() { |
33 | | - return array( |
34 | | - 'filter' => array( |
35 | | - ApiBase::PARAM_REQUIRED => true, |
36 | | - ), |
37 | | - ); |
38 | | - } |
39 | | - |
40 | | - public function getParamDescription() { |
41 | | - return array( |
42 | | - 'filter' => 'The full filter text to check syntax on', |
43 | | - ); |
44 | | - } |
45 | | - |
46 | | - public function getDescription() { |
47 | | - return array( |
48 | | - 'Check syntax of an AbuseFilter filter' |
49 | | - ); |
50 | | - } |
51 | | - |
52 | | - public function getPossibleErrors() { |
53 | | - return array_merge( parent::getPossibleErrors(), array( |
54 | | - array( 'permissiondenied' ), |
55 | | - ) ); |
56 | | - } |
57 | | - |
58 | | - public function getExamples() { |
59 | | - return array( |
60 | | - 'api.php?action=checkfiltersyntax&filter="foo"', |
61 | | - 'api.php?action=checkfiltersyntax&filter="bar"%20bad_variable', |
62 | | - ); |
63 | | - } |
64 | | - |
65 | | - public function getVersion() { |
66 | | - return __CLASS__ . ': $Id$'; |
67 | | - } |
68 | | -} |
\ No newline at end of file |
Index: trunk/extensions/AbuseFilter/api/ApiUnblockAutopromote.php |
— | — | @@ -1,87 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -class ApiUnblockAutopromote extends ApiBase { |
5 | | - public function execute() { |
6 | | - global $wgUser; |
7 | | - |
8 | | - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
9 | | - $this->dieUsage( 'You do not have permissions to unblock autopromotion', 'permissiondenied' ); |
10 | | - } |
11 | | - |
12 | | - $params = $this->extractRequestParams(); |
13 | | - $user = User::newFromName( $params['user'] ); |
14 | | - |
15 | | - if ( $user === false ) { |
16 | | - // Same as below |
17 | | - $msg = wfMsgExt( 'abusefilter-reautoconfirm-none', array( 'parsemag' ), $params['user'] ); |
18 | | - $this->dieUsage( $msg, 'notsuspended' ); |
19 | | - } |
20 | | - |
21 | | - global $wgMemc; |
22 | | - $key = AbuseFilter::autoPromoteBlockKey( $user ); |
23 | | - |
24 | | - if ( !$wgMemc->get( $key ) ) { |
25 | | - // Oh god this is so bad but this message uses GENDER |
26 | | - $msg = wfMsgExt( 'abusefilter-reautoconfirm-none', array( 'parsemag' ), $params['user'] ); |
27 | | - $this->dieUsage( $msg, 'notsuspended' ); |
28 | | - } |
29 | | - |
30 | | - $wgMemc->delete( $key ); |
31 | | - |
32 | | - $res = array( 'user' => $params['user'] ); |
33 | | - $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
34 | | - } |
35 | | - |
36 | | - public function mustBePosted() { |
37 | | - return true; |
38 | | - } |
39 | | - |
40 | | - public function isWriteMode() { |
41 | | - return true; |
42 | | - } |
43 | | - |
44 | | - public function getAllowedParams() { |
45 | | - return array( |
46 | | - 'user' => array( |
47 | | - ApiBase::PARAM_REQUIRED => true |
48 | | - ), |
49 | | - 'token' => null, |
50 | | - ); |
51 | | - } |
52 | | - |
53 | | - public function getParamDescription() { |
54 | | - return array( |
55 | | - 'user' => 'Username of the user you want to unblock', |
56 | | - 'token' => 'An edit token', |
57 | | - ); |
58 | | - } |
59 | | - |
60 | | - public function getDescription() { |
61 | | - return 'Unblocks a user from receiving autopromotions due to an abusefilter consequence'; |
62 | | - } |
63 | | - |
64 | | - public function getPossibleErrors() { |
65 | | - return array_merge( parent::getPossibleErrors(), array( |
66 | | - array( 'code' => 'notsuspended', 'info' => 'That user has not had their autoconfirmed status suspended'), |
67 | | - array( 'code' => 'permissiondenied', 'info' => 'You do not have permissions to unblock autopromotion' ), |
68 | | - ) ); |
69 | | - } |
70 | | - |
71 | | - public function needsToken() { |
72 | | - return true; |
73 | | - } |
74 | | - |
75 | | - public function getTokenSalt() { |
76 | | - return ''; |
77 | | - } |
78 | | - |
79 | | - public function getExamples() { |
80 | | - return array( |
81 | | - 'api.php?action=unblockautopromote&user=Bob' |
82 | | - ); |
83 | | - } |
84 | | - |
85 | | - public function getVersion() { |
86 | | - return __CLASS__ . ': $Id$'; |
87 | | - } |
88 | | -} |
Index: trunk/extensions/AbuseFilter/api/ApiEvalFilterExpression.php |
— | — | @@ -1,41 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -class ApiEvalFilterExpression extends ApiBase { |
5 | | - public function execute() { |
6 | | - $params = $this->extractRequestParams(); |
7 | | - |
8 | | - $result = AbuseFilter::evaluateExpression( $params['expression'] ); |
9 | | - |
10 | | - $this->getResult()->addValue( null, $this->getModuleName(), array( 'result' => $result ) ); |
11 | | - } |
12 | | - |
13 | | - public function getAllowedParams() { |
14 | | - return array( |
15 | | - 'expression' => array( |
16 | | - ApiBase::PARAM_REQUIRED => true, |
17 | | - ), |
18 | | - ); |
19 | | - } |
20 | | - |
21 | | - public function getParamDescription() { |
22 | | - return array( |
23 | | - 'expression' => 'The expression to evaluate', |
24 | | - ); |
25 | | - } |
26 | | - |
27 | | - public function getDescription() { |
28 | | - return array( |
29 | | - 'Evaluates an AbuseFilter expression' |
30 | | - ); |
31 | | - } |
32 | | - |
33 | | - public function getExamples() { |
34 | | - return array( |
35 | | - 'api.php?action=evalfilterexpression&expression=lcase("FOO")' |
36 | | - ); |
37 | | - } |
38 | | - |
39 | | - public function getVersion() { |
40 | | - return __CLASS__ . ': $Id$'; |
41 | | - } |
42 | | -} |
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckMatch.php |
— | — | @@ -0,0 +1,114 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class ApiAbuseFilterCheckMatch extends ApiBase { |
| 5 | + public function execute() { |
| 6 | + global $wgUser; |
| 7 | + $params = $this->extractRequestParams(); |
| 8 | + $this->requireOnlyOneParameter( $params, 'vars', 'rcid', 'logid' ); |
| 9 | + |
| 10 | + // "Anti-DoS" |
| 11 | + if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 12 | + $this->dieUsageMsg( 'permissiondenied' ); |
| 13 | + } |
| 14 | + |
| 15 | + if ( $params['vars'] ) { |
| 16 | + $vars = json_decode( $params['vars'], true ); |
| 17 | + } elseif ( $params['rcid'] ) { |
| 18 | + $dbr = wfGetDB( DB_SLAVE ); |
| 19 | + $row = $dbr->selectRow( |
| 20 | + 'recentchanges', |
| 21 | + '*', |
| 22 | + array( 'rc_id' => $params['rcid'] ), |
| 23 | + __METHOD__ |
| 24 | + ); |
| 25 | + |
| 26 | + if ( !$row ) { |
| 27 | + $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) ); |
| 28 | + } |
| 29 | + |
| 30 | + $vars = AbuseFilter::getVarsFromRCRow( $row ); |
| 31 | + } elseif ( $params['logid'] ) { |
| 32 | + $dbr = wfGetDB( DB_SLAVE ); |
| 33 | + $row = $dbr->selectRow( |
| 34 | + 'abuse_filter_log', |
| 35 | + '*', |
| 36 | + array( 'afl_id' => $params['logid'] ), |
| 37 | + __METHOD__ |
| 38 | + ); |
| 39 | + |
| 40 | + if ( !$row ) { |
| 41 | + $this->dieUsage( |
| 42 | + "There is no abuselog entry with the id ``{$params['logid']}''", |
| 43 | + 'nosuchlogid' |
| 44 | + ); |
| 45 | + } |
| 46 | + |
| 47 | + $vars = AbuseFilter::loadVarDump( $row->afl_var_dump ); |
| 48 | + } |
| 49 | + |
| 50 | + if ( AbuseFilter::checkSyntax( $params[ 'filter' ] ) !== true ) { |
| 51 | + $this->dieUsage( 'The filter has invalid syntax', 'badsyntax' ); |
| 52 | + } |
| 53 | + |
| 54 | + $result = AbuseFilter::checkConditions( $params['filter'], $vars ); |
| 55 | + $this->getResult()->addValue( |
| 56 | + null, |
| 57 | + $this->getModuleName(), |
| 58 | + array( 'result' => $result ) |
| 59 | + ); |
| 60 | + } |
| 61 | + |
| 62 | + public function getAllowedParams() { |
| 63 | + return array( |
| 64 | + 'filter' => array( |
| 65 | + ApiBase::PARAM_REQUIRED => true, |
| 66 | + ), |
| 67 | + 'vars' => null, |
| 68 | + 'rcid' => array( |
| 69 | + ApiBase::PARAM_TYPE => 'integer' |
| 70 | + ), |
| 71 | + 'logid' => array( |
| 72 | + ApiBase::PARAM_TYPE => 'integer' |
| 73 | + ), |
| 74 | + ); |
| 75 | + } |
| 76 | + |
| 77 | + public function getParamDescription() { |
| 78 | + return array( |
| 79 | + 'filter' => 'The full filter text to check for a match', |
| 80 | + 'vars' => 'JSON encoded array of variables to test against', |
| 81 | + 'rcid' => 'Recent change ID to check against', |
| 82 | + 'logid' => 'Abuse filter log ID to check against', |
| 83 | + ); |
| 84 | + } |
| 85 | + |
| 86 | + public function getDescription() { |
| 87 | + return array( |
| 88 | + 'Check to see if an AbuseFilter matches a set of variables, edit' |
| 89 | + . 'or logged AbuseFilter event.', |
| 90 | + 'vars, rcid or logid is required however only one may be used', |
| 91 | + ); |
| 92 | + } |
| 93 | + |
| 94 | + public function getPossibleErrors() { |
| 95 | + return array_merge( parent::getPossibleErrors(), |
| 96 | + $this->getRequireOnlyOneParameterErrorMessages( array( 'vars', 'rcid', 'logid' ) ), |
| 97 | + array( |
| 98 | + array( 'permissiondenied' ), |
| 99 | + array( 'nosuchrcid' ), |
| 100 | + array( 'code' => 'nosuchlogid', 'info' => 'There is no abuselog entry with the id given' ), |
| 101 | + array( 'code' => 'badsyntax', 'info' => 'The filter has invalid syntax' ), |
| 102 | + ) |
| 103 | + ); |
| 104 | + } |
| 105 | + |
| 106 | + public function getExamples() { |
| 107 | + return array( |
| 108 | + 'api.php?action=checkfiltermatch&filter=!("autoconfirmed"%20in%20user_groups)&rcid=15' |
| 109 | + ); |
| 110 | + } |
| 111 | + |
| 112 | + public function getVersion() { |
| 113 | + return __CLASS__ . ': $Id$'; |
| 114 | + } |
| 115 | +} |
Property changes on: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckMatch.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 116 | + native |
Added: svn:keywords |
2 | 117 | + Id |
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterUnblockAutopromote.php |
— | — | @@ -0,0 +1,87 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class ApiAbuseFilterUnblockAutopromote extends ApiBase { |
| 5 | + public function execute() { |
| 6 | + global $wgUser; |
| 7 | + |
| 8 | + if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 9 | + $this->dieUsage( 'You do not have permissions to unblock autopromotion', 'permissiondenied' ); |
| 10 | + } |
| 11 | + |
| 12 | + $params = $this->extractRequestParams(); |
| 13 | + $user = User::newFromName( $params['user'] ); |
| 14 | + |
| 15 | + if ( $user === false ) { |
| 16 | + // Same as below |
| 17 | + $msg = wfMsgExt( 'abusefilter-reautoconfirm-none', array( 'parsemag' ), $params['user'] ); |
| 18 | + $this->dieUsage( $msg, 'notsuspended' ); |
| 19 | + } |
| 20 | + |
| 21 | + global $wgMemc; |
| 22 | + $key = AbuseFilter::autoPromoteBlockKey( $user ); |
| 23 | + |
| 24 | + if ( !$wgMemc->get( $key ) ) { |
| 25 | + // Oh god this is so bad but this message uses GENDER |
| 26 | + $msg = wfMsgExt( 'abusefilter-reautoconfirm-none', array( 'parsemag' ), $params['user'] ); |
| 27 | + $this->dieUsage( $msg, 'notsuspended' ); |
| 28 | + } |
| 29 | + |
| 30 | + $wgMemc->delete( $key ); |
| 31 | + |
| 32 | + $res = array( 'user' => $params['user'] ); |
| 33 | + $this->getResult()->addValue( null, $this->getModuleName(), $res ); |
| 34 | + } |
| 35 | + |
| 36 | + public function mustBePosted() { |
| 37 | + return true; |
| 38 | + } |
| 39 | + |
| 40 | + public function isWriteMode() { |
| 41 | + return true; |
| 42 | + } |
| 43 | + |
| 44 | + public function getAllowedParams() { |
| 45 | + return array( |
| 46 | + 'user' => array( |
| 47 | + ApiBase::PARAM_REQUIRED => true |
| 48 | + ), |
| 49 | + 'token' => null, |
| 50 | + ); |
| 51 | + } |
| 52 | + |
| 53 | + public function getParamDescription() { |
| 54 | + return array( |
| 55 | + 'user' => 'Username of the user you want to unblock', |
| 56 | + 'token' => 'An edit token', |
| 57 | + ); |
| 58 | + } |
| 59 | + |
| 60 | + public function getDescription() { |
| 61 | + return 'Unblocks a user from receiving autopromotions due to an abusefilter consequence'; |
| 62 | + } |
| 63 | + |
| 64 | + public function getPossibleErrors() { |
| 65 | + return array_merge( parent::getPossibleErrors(), array( |
| 66 | + array( 'code' => 'notsuspended', 'info' => 'That user has not had their autoconfirmed status suspended'), |
| 67 | + array( 'code' => 'permissiondenied', 'info' => 'You do not have permissions to unblock autopromotion' ), |
| 68 | + ) ); |
| 69 | + } |
| 70 | + |
| 71 | + public function needsToken() { |
| 72 | + return true; |
| 73 | + } |
| 74 | + |
| 75 | + public function getTokenSalt() { |
| 76 | + return ''; |
| 77 | + } |
| 78 | + |
| 79 | + public function getExamples() { |
| 80 | + return array( |
| 81 | + 'api.php?action=unblockautopromote&user=Bob' |
| 82 | + ); |
| 83 | + } |
| 84 | + |
| 85 | + public function getVersion() { |
| 86 | + return __CLASS__ . ': $Id$'; |
| 87 | + } |
| 88 | +} |
Property changes on: trunk/extensions/AbuseFilter/api/ApiAbuseFilterUnblockAutopromote.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 89 | + native |
Added: svn:keywords |
2 | 90 | + Id |
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckSyntax.php |
— | — | @@ -0,0 +1,67 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class ApiAbuseFilterCheckSyntax extends ApiBase { |
| 5 | + |
| 6 | + public function execute() { |
| 7 | + global $wgUser; |
| 8 | + |
| 9 | + // "Anti-DoS" |
| 10 | + if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 11 | + $this->dieUsageMsg( 'permissiondenied' ); |
| 12 | + } |
| 13 | + |
| 14 | + $params = $this->extractRequestParams(); |
| 15 | + $result = AbuseFilter::checkSyntax( $params[ 'filter' ] ); |
| 16 | + |
| 17 | + $r = array(); |
| 18 | + if ( $result === true ) { |
| 19 | + // Everything went better than expected :) |
| 20 | + $r['status'] = 'ok'; |
| 21 | + } else { |
| 22 | + $r = array( |
| 23 | + 'status' => 'error', |
| 24 | + 'message' => $result[0], |
| 25 | + 'character' => $result[1], |
| 26 | + ); |
| 27 | + } |
| 28 | + |
| 29 | + $this->getResult()->addValue( null, $this->getModuleName(), $r ); |
| 30 | + } |
| 31 | + |
| 32 | + public function getAllowedParams() { |
| 33 | + return array( |
| 34 | + 'filter' => array( |
| 35 | + ApiBase::PARAM_REQUIRED => true, |
| 36 | + ), |
| 37 | + ); |
| 38 | + } |
| 39 | + |
| 40 | + public function getParamDescription() { |
| 41 | + return array( |
| 42 | + 'filter' => 'The full filter text to check syntax on', |
| 43 | + ); |
| 44 | + } |
| 45 | + |
| 46 | + public function getDescription() { |
| 47 | + return array( |
| 48 | + 'Check syntax of an AbuseFilter filter' |
| 49 | + ); |
| 50 | + } |
| 51 | + |
| 52 | + public function getPossibleErrors() { |
| 53 | + return array_merge( parent::getPossibleErrors(), array( |
| 54 | + array( 'permissiondenied' ), |
| 55 | + ) ); |
| 56 | + } |
| 57 | + |
| 58 | + public function getExamples() { |
| 59 | + return array( |
| 60 | + 'api.php?action=checkfiltersyntax&filter="foo"', |
| 61 | + 'api.php?action=checkfiltersyntax&filter="bar"%20bad_variable', |
| 62 | + ); |
| 63 | + } |
| 64 | + |
| 65 | + public function getVersion() { |
| 66 | + return __CLASS__ . ': $Id$'; |
| 67 | + } |
| 68 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckSyntax.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 69 | + native |
Added: svn:keywords |
2 | 70 | + Id |
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterEvalExpression.php |
— | — | @@ -0,0 +1,41 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class ApiAbuseFilterEvalExpression extends ApiBase { |
| 5 | + public function execute() { |
| 6 | + $params = $this->extractRequestParams(); |
| 7 | + |
| 8 | + $result = AbuseFilter::evaluateExpression( $params['expression'] ); |
| 9 | + |
| 10 | + $this->getResult()->addValue( null, $this->getModuleName(), array( 'result' => $result ) ); |
| 11 | + } |
| 12 | + |
| 13 | + public function getAllowedParams() { |
| 14 | + return array( |
| 15 | + 'expression' => array( |
| 16 | + ApiBase::PARAM_REQUIRED => true, |
| 17 | + ), |
| 18 | + ); |
| 19 | + } |
| 20 | + |
| 21 | + public function getParamDescription() { |
| 22 | + return array( |
| 23 | + 'expression' => 'The expression to evaluate', |
| 24 | + ); |
| 25 | + } |
| 26 | + |
| 27 | + public function getDescription() { |
| 28 | + return array( |
| 29 | + 'Evaluates an AbuseFilter expression' |
| 30 | + ); |
| 31 | + } |
| 32 | + |
| 33 | + public function getExamples() { |
| 34 | + return array( |
| 35 | + 'api.php?action=evalfilterexpression&expression=lcase("FOO")' |
| 36 | + ); |
| 37 | + } |
| 38 | + |
| 39 | + public function getVersion() { |
| 40 | + return __CLASS__ . ': $Id$'; |
| 41 | + } |
| 42 | +} |
Property changes on: trunk/extensions/AbuseFilter/api/ApiAbuseFilterEvalExpression.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 43 | + native |
Added: svn:keywords |
2 | 44 | + Id |