Go to the documentation of this file.
24 require_once __DIR__ .
'/Maintenance.php';
34 parent::__construct();
35 $this->mDescription =
"Cleanup all spam from a given hostname";
36 $this->
addOption(
'all',
'Check all wikis in $wgLocalDatabases' );
37 $this->
addOption(
'delete',
'Delete pages containing only spam instead of blanking them' );
38 $this->
addArg(
'hostname',
'Hostname that was spamming, single * wildcard in the beginning allowed' );
44 $username =
wfMessage(
'spambot_username' )->text();
47 $this->
error(
"Invalid username specified in 'spambot_username' message: $username",
true );
50 if ( !$wgUser->getId() ) {
56 $this->
error(
"Not a valid hostname specification: $spec",
true );
61 $this->
output(
"Finding spam on " . count( $wgLocalDatabases ) .
" wikis\n" );
63 foreach ( $wgLocalDatabases
as $wikiID ) {
66 $count =
$dbr->selectField(
'externallinks',
'COUNT(*)',
67 array(
'el_index' .
$dbr->buildLike( $like ) ), __METHOD__ );
71 array(
'--wiki', $wikiID, $spec ) );
72 passthru(
"$cmd | sed 's/^/$wikiID: /'" );
76 $this->
output(
"All done\n" );
78 $this->
output(
"None found\n" );
84 $res =
$dbr->select(
'externallinks',
array(
'DISTINCT el_from' ),
85 array(
'el_index' .
$dbr->buildLike( $like ) ), __METHOD__ );
87 $this->
output(
"Found $count articles containing $spec\n" );
100 $this->
error(
"Internal error: no page for ID $id" );
106 $currentRevId =
$rev->getId();
113 if (
$rev &&
$rev->getId() == $currentRevId ) {
116 $this->
output(
"False match\n" );
119 $dbw->begin( __METHOD__ );
125 $this->
output(
"reverting\n" );
126 $page->doEditContent( $content,
wfMessage(
'spam_reverting', $domain )->inContentLanguage()->
text(),
128 } elseif ( $this->
hasOption(
'delete' ) ) {
130 $this->
output(
"deleting\n" );
131 $page->doDeleteArticle(
wfMessage(
'spam_deleting', $domain )->inContentLanguage()->
text() );
135 $content = $handler->makeEmptyContent();
137 $this->
output(
"blanking\n" );
138 $page->doEditContent( $content,
wfMessage(
'spam_blanking', $domain )->inContentLanguage()->
text() );
140 $dbw->commit( __METHOD__ );
Maintenance script to cleanup all spam from a given hostname.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
static matchEntry(Content $content, $filterEntry)
Check whether $content contains a link to $filterEntry.
require_once RUN_MAINTENANCE_IF_MAIN
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
cleanupArticle( $id, $domain)
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
static makeLikeArray( $filterEntry, $protocol='http://')
Make an array to be used for calls to DatabaseBase::buildLike(), which will match the specified strin...
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
wfShellWikiCmd( $script, array $parameters=array(), array $options=array())
Generate a shell-escaped command line string to run a MediaWiki cli script.
static newFromTitle( $title, $id=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given title.
presenting them properly to the user as errors is done by the caller $title
__construct()
Default constructor.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
addArg( $arg, $description, $required=true)
Add some args that are needed.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular param exists.
execute()
Do the actual work.
getArg( $argId=0, $default=null)
Get an argument.
static newFromID( $id, $flags=0)
Create a new Title from an article ID.