| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\ConfirmEdit\FancyCaptcha; |
| 4 |
|
| 5 |
use MediaWiki\Api\ApiBase; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
class ApiFancyCaptchaReload extends ApiBase { |
| 14 |
public function execute() { |
| 15 |
$result = $this->getResult(); |
| 16 |
|
| 17 |
if ( $this->getUser()->pingLimiter( 'badcaptcha', 1 ) ) { |
| 18 |
$result->addValue( null, $this->getModuleName(), [ 'index' => 0 ] ); |
| 19 |
return true; |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
$captcha = new FancyCaptcha(); |
| 24 |
$info = $captcha->getCaptcha(); |
| 25 |
$captchaIndex = $captcha->storeCaptcha( $info ); |
| 26 |
|
| 27 |
$result->addValue( null, $this->getModuleName(), [ 'index' => $captchaIndex ] ); |
| 28 |
return true; |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
public function isInternal() { |
| 33 |
return true; |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
public function getAllowedParams() { |
| 38 |
return []; |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
protected function getExamplesMessages() { |
| 46 |
return [ |
| 47 |
'action=fancycaptchareload' |
| 48 |
=> 'apihelp-fancycaptchareload-example-1', |
| 49 |
]; |
| 50 |
} |
| 51 |
} |