2017-02-07 15:43:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2017-02-16 16:25:21 +00:00
|
|
|
* Counts the number of fancy captchas remaining.
|
2017-02-07 15:43:08 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Maintenance
|
|
|
|
*/
|
|
|
|
if ( getenv( 'MW_INSTALL_PATH' ) ) {
|
|
|
|
$IP = getenv( 'MW_INSTALL_PATH' );
|
|
|
|
} else {
|
|
|
|
$IP = __DIR__ . '/../../..';
|
|
|
|
}
|
|
|
|
|
2017-07-08 13:55:41 +00:00
|
|
|
require_once "$IP/maintenance/Maintenance.php";
|
2017-02-07 15:43:08 +00:00
|
|
|
|
2022-04-08 16:53:12 +00:00
|
|
|
use MediaWiki\Extension\ConfirmEdit\FancyCaptcha\FancyCaptcha;
|
2022-04-08 16:40:15 +00:00
|
|
|
use MediaWiki\Extension\ConfirmEdit\Hooks;
|
|
|
|
|
2017-02-07 15:43:08 +00:00
|
|
|
/**
|
|
|
|
* Maintenance script that counts the number of captchas remaining.
|
|
|
|
*
|
|
|
|
* @ingroup Maintenance
|
|
|
|
*/
|
2017-02-16 16:25:21 +00:00
|
|
|
class CountFancyCaptchas extends Maintenance {
|
2017-02-07 15:43:08 +00:00
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
2024-01-15 15:17:21 +00:00
|
|
|
$this->addDescription( "Counts the number of fancy captchas in storage" );
|
|
|
|
$this->addOption(
|
|
|
|
'captchastoragedir',
|
|
|
|
'Overrides the value of $wgCaptchaStorageDirectory',
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
);
|
2017-02-07 15:43:08 +00:00
|
|
|
$this->requireExtension( "FancyCaptcha" );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute() {
|
2022-04-08 16:40:15 +00:00
|
|
|
$instance = Hooks::getInstance();
|
2017-02-07 15:43:08 +00:00
|
|
|
if ( !( $instance instanceof FancyCaptcha ) ) {
|
2020-09-18 16:11:12 +00:00
|
|
|
$this->fatalError( "\$wgCaptchaClass is not FancyCaptcha.\n", 1 );
|
2017-02-07 15:43:08 +00:00
|
|
|
}
|
|
|
|
|
2024-01-15 15:17:21 +00:00
|
|
|
// Overrides $wgCaptchaStorageDirectory for this script run
|
|
|
|
if ( $this->hasOption( 'captchastoragedir' ) ) {
|
|
|
|
global $wgCaptchaStorageDirectory;
|
|
|
|
$wgCaptchaStorageDirectory = $this->getOption( 'captchastoragedir' );
|
|
|
|
}
|
|
|
|
|
2017-02-07 18:02:46 +00:00
|
|
|
$countAct = $instance->getCaptchaCount();
|
2024-01-15 15:17:21 +00:00
|
|
|
$this->output( "Current number of stored captchas is $countAct.\n" );
|
2017-02-07 15:43:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-02 18:39:36 +00:00
|
|
|
$maintClass = CountFancyCaptchas::class;
|
2017-07-08 13:55:41 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|