mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-24 06:03:49 +00:00
3aa76b0f5f
Since this extension uses extension.json, it already requires 1.25+ so no need to keep the old code around. Change-Id: I6f968be3b7ef7cbc7193c8e103beb36ecf9c7b60
52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php
|
|
|
|
class ApiAbuseFilterCheckSyntax extends ApiBase {
|
|
|
|
public function execute() {
|
|
// "Anti-DoS"
|
|
if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
|
|
$this->dieUsage(
|
|
'You don\'t have permission to check syntax of abuse filters',
|
|
'permissiondenied'
|
|
);
|
|
}
|
|
|
|
$params = $this->extractRequestParams();
|
|
$result = AbuseFilter::checkSyntax( $params[ 'filter' ] );
|
|
|
|
$r = array();
|
|
if ( $result === true ) {
|
|
// Everything went better than expected :)
|
|
$r['status'] = 'ok';
|
|
} else {
|
|
$r = array(
|
|
'status' => 'error',
|
|
'message' => $result[0],
|
|
'character' => $result[1],
|
|
);
|
|
}
|
|
|
|
$this->getResult()->addValue( null, $this->getModuleName(), $r );
|
|
}
|
|
|
|
public function getAllowedParams() {
|
|
return array(
|
|
'filter' => array(
|
|
ApiBase::PARAM_REQUIRED => true,
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @see ApiBase::getExamplesMessages()
|
|
*/
|
|
protected function getExamplesMessages() {
|
|
return array(
|
|
'action=abusefilterchecksyntax&filter="foo"'
|
|
=> 'apihelp-abusefilterchecksyntax-example-1',
|
|
'action=abusefilterchecksyntax&filter="bar"%20bad_variable'
|
|
=> 'apihelp-abusefilterchecksyntax-example-2',
|
|
);
|
|
}
|
|
}
|