| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
if ( getenv( 'MW_INSTALL_PATH' ) ) { |
| 24 |
$IP = getenv( 'MW_INSTALL_PATH' ); |
| 25 |
} else { |
| 26 |
$IP = __DIR__ . '/../../..'; |
| 27 |
} |
| 28 |
|
| 29 |
require_once "$IP/maintenance/Maintenance.php"; |
| 30 |
|
| 31 |
use MediaWiki\Extension\ConfirmEdit\FancyCaptcha\FancyCaptcha; |
| 32 |
use MediaWiki\Extension\ConfirmEdit\Hooks; |
| 33 |
use MediaWiki\Maintenance\Maintenance; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
class CountFancyCaptchas extends Maintenance { |
| 41 |
public function __construct() { |
| 42 |
parent::__construct(); |
| 43 |
$this->addDescription( "Counts the number of fancy captchas in storage" ); |
| 44 |
$this->addOption( |
| 45 |
'captchastoragedir', |
| 46 |
'Overrides the value of $wgCaptchaStorageDirectory', |
| 47 |
false, |
| 48 |
true |
| 49 |
); |
| 50 |
$this->requireExtension( "FancyCaptcha" ); |
| 51 |
} |
| 52 |
|
| 53 |
public function execute() { |
| 54 |
$instance = Hooks::getInstance(); |
| 55 |
if ( !( $instance instanceof FancyCaptcha ) ) { |
| 56 |
$this->fatalError( "\$wgCaptchaClass is not FancyCaptcha.\n", 1 ); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
if ( $this->hasOption( 'captchastoragedir' ) ) { |
| 61 |
global $wgCaptchaStorageDirectory; |
| 62 |
$wgCaptchaStorageDirectory = $this->getOption( 'captchastoragedir' ); |
| 63 |
} |
| 64 |
|
| 65 |
$countAct = $instance->getCaptchaCount(); |
| 66 |
$this->output( "Current number of stored captchas is $countAct.\n" ); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
$maintClass = CountFancyCaptchas::class; |
| 71 |
require_once RUN_MAINTENANCE_IF_MAIN; |