Index: trunk/phase3/maintenance/cleanupSpam.php |
— | — | @@ -53,6 +53,9 @@ |
54 | 54 | } |
55 | 55 | //------------------------------------------------------------------------------ |
56 | 56 | |
| 57 | + |
| 58 | + |
| 59 | + |
57 | 60 | $username = wfMsg( 'spambot_username' ); |
58 | 61 | $fname = $username; |
59 | 62 | $wgUser = User::newFromName( $username ); |
— | — | @@ -74,15 +77,36 @@ |
75 | 78 | |
76 | 79 | $dbr =& wfGetDB( DB_SLAVE ); |
77 | 80 | |
78 | | -$res = $dbr->select( 'externallinks', array( 'el_from' ), |
79 | | - array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname ); |
80 | | -$count = $dbr->numRows( $res ); |
81 | | -print "Found $count articles containing $spec\n"; |
82 | | -while ( $row = $dbr->fetchObject( $res ) ) { |
83 | | - cleanupArticle( $row->el_from, $spec ); |
| 81 | +if ( $options['all'] ) { |
| 82 | + // Clean up spam on all wikis |
| 83 | + $dbr =& wfGetDB( DB_SLAVE ); |
| 84 | + print "Finding spam on " . count($wgLocalDatabases) . " wikis\n"; |
| 85 | + $found = false; |
| 86 | + foreach ( $wgLocalDatabases as $db ) { |
| 87 | + $count = $dbr->selectField( "`$db`.externallinks", 'COUNT(*)', |
| 88 | + array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname ); |
| 89 | + if ( $count ) { |
| 90 | + $found = true; |
| 91 | + passthru( "php cleanupSpam.php $db $spec | sed s/^/$db: /" ); |
| 92 | + } |
| 93 | + } |
| 94 | + if ( $found ) { |
| 95 | + print "All done\n"; |
| 96 | + } else { |
| 97 | + print "None found\n"; |
| 98 | + } |
| 99 | +} else { |
| 100 | + // Clean up spam on this wiki |
| 101 | + $res = $dbr->select( 'externallinks', array( 'DISTINCT el_from' ), |
| 102 | + array( 'el_index LIKE ' . $dbr->addQuotes( $like ) ), $fname ); |
| 103 | + $count = $dbr->numRows( $res ); |
| 104 | + print "Found $count articles containing $spec\n"; |
| 105 | + while ( $row = $dbr->fetchObject( $res ) ) { |
| 106 | + cleanupArticle( $row->el_from, $spec ); |
| 107 | + } |
| 108 | + if ( $count ) { |
| 109 | + print "Done\n"; |
| 110 | + } |
84 | 111 | } |
85 | | -if ( $count ) { |
86 | | - print "Done\n"; |
87 | | -} |
88 | 112 | |
89 | 113 | ?> |