2011-08-26 20:12:34 +00:00
|
|
|
<?php
|
|
|
|
|
2011-09-29 23:30:42 +00:00
|
|
|
class ApiAbuseFilterCheckSyntax extends ApiBase {
|
2011-08-26 20:12:34 +00:00
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
// "Anti-DoS"
|
2011-11-16 05:34:24 +00:00
|
|
|
if ( !$this->getUser()->isAllowed( 'abusefilter-modify' ) ) {
|
2015-09-28 18:03:35 +00:00
|
|
|
$this->dieUsage(
|
|
|
|
'You don\'t have permission to check syntax of abuse filters',
|
|
|
|
'permissiondenied'
|
|
|
|
);
|
2011-08-26 20:12:34 +00:00
|
|
|
}
|
|
|
|
|
2011-08-26 23:52:46 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2011-08-26 20:12:34 +00:00
|
|
|
$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,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-10-28 16:25:22 +00:00
|
|
|
/**
|
|
|
|
* @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',
|
|
|
|
);
|
2011-08-26 20:12:34 +00:00
|
|
|
}
|
2012-01-13 21:36:51 +00:00
|
|
|
}
|