From Wikipedia, the free encyclopedia
<?php
/* Chris G Bot - http://en.wikipedia.org/wiki/User:Chris_G
Copyright (C) 2008 Chris Grant - http://en.wikipedia.org/wiki/User:Chris_G
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., 675 Mass Ave, Cambridge, MA 02139, USA.
Developers (add your self here if you worked on the code):
Chris - [[User:Chris_G]] - Wrote up the main code
Cobi - [[User:Cobi]] - Wrote wikibot.classes.php
*/
include("wikibot.classes.php"); #Use Cobi's classes - see [[User:Cobi]] and [[User:ClueBot/Source]]
#Setup the classes
$h = new http;
$wpapi = new wikipediaapi;
$wpq = new wikipediaquery;
$wpi = new wikipediaindex;
#All the login stuff
$user = "Chris G Bot";
include("password.php");
$wpapi->login($user,$pass);
#Get The users to revert
$users = explode('\n',$wpq->getPage('User:Chris G Bot/Users.js'));
foreach ($users as $user) {
#Get all the users moves from the api
$i=0;
$x = $h->get('http://en.wikipedia.org/w/api.php?action=query&list=logevents&letype=move&leuser='.urlencode($user).'&lelimit=5000&format=php');
$x = unserialize($x);
foreach ($x['query']['logevents'] as $t) {
$moves[$i]['old'] = $t['title']; #The page name '''before''' $user moved it
$moves[$i]['new'] = $t['move']['new_title']; #The page name '''after''' $user moved it
$i++;
}
#Revert all the pagemoves
$i = 0;
foreach ($moves as $p) {
$wpi->move($p[$i]['new'],$p[$i]['old'],'Reverting Vanadal Page Move');
$del = $del."* [[".$p[$i]['new']."]]\n"
$i++;
}
$wpi->forcepost('User:Chris G/Del',$del);
}
$wpi->forcepost('User:Chris G/Users.js','');