24 require_once __DIR__ .
'/Maintenance.php';
39 parent::__construct();
41 $this->
addOption(
'limit',
"Max number of passwords to write",
false,
true,
'l' );
42 $this->
addArg(
'inputfile',
'List of passwords (one per line) to use or - for stdin',
true );
45 "Location to write CDB file to (Try $IP/serialized/commonpasswords.cdb)",
54 $infile = $this->
getArg( 0 );
55 if ( $infile ===
'-' ) {
56 $infile =
'php://stdin';
58 $outfile = $this->
getArg( 1 );
60 if ( !is_readable( $infile ) && $infile !==
'php://stdin' ) {
61 $this->
error(
"Cannot open input file $infile for reading", 1 );
64 $file = fopen( $infile,
'r' );
65 if ( $file ===
false ) {
66 $this->
error(
"Cannot read input file $infile", 1 );
74 for ( $i = 0; ( $i - $skipped ) <
$limit; $i++ ) {
75 if ( feof( $file ) ) {
78 $rawLine = fgets( $file );
80 if ( $rawLine ===
false ) {
81 $this->
error(
"Error reading input file" );
84 if ( substr( $rawLine, -1 ) !==
"\n" && !feof( $file ) ) {
86 $this->
error(
"fgets did not return whole line at $i??" );
88 $line = $langEn->lc( trim( $rawLine ) );
90 $this->
error(
"Line number " . ( $i + 1 ) .
" is blank?" );
94 if ( isset( $alreadyWritten[
$line] ) ) {
95 $this->
output(
"Password '$line' already written (line " . ( $i + 1 ) .
")\n" );
99 $alreadyWritten[
$line] =
true;
100 $db->set( $line, $i + 1 - $skipped );
103 $db->set(
'_TOTALENTRIES', $i - $skipped );
106 $this->
output(
"Successfully wrote " . ( $i - $skipped ) .
107 " (out of $i) passwords to $outfile\n"
110 $this->
error(
"Error writing cdb file: " . $e->getMessage(), 2 );
addArg($arg, $description, $required=true)
Add some args that are needed.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
require_once RUN_MAINTENANCE_IF_MAIN
when a variable name is used in a it is silently declared as a new local masking the global
Maintenance script to create common password cdb database.
addOption($name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
addDescription($text)
Set the description text.
getOption($name, $default=null)
Get an option, or return the default.
output($out, $channel=null)
Throw some output to the user.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
error($err, $die=0)
Throw an error to the user.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
getArg($argId=0, $default=null)
Get an argument.
static factory($code)
Get a cached or new language object for a given language code.