Jump to content

User:Chris G Bot/Source

From Wikipedia, the free encyclopedia
<?php
/* Chris G Bot - http://en.wikipedia.org/wiki/User:Chris_G_Bot
   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
*/
 
//Includes
include("wikibot.classes.php"); //Use Cobi's classes - see [[User:Cobi]] and [[User:ClueBot/Source]]
 
//Setup the classes
$wpapi  = new wikipediaapi;
$wpq    = new wikipediaquery;
$wpi    = new wikipediaindex;
 
//Login
$user = 'Chris G Bot';
include('password.php');
$wpapi->login($user,$pass);
 
//Go through all the pages
$pages = $wpapi->categorymembers('Category:NA-Class Baseball articles',500);
foreach ($pages as $p) {
        $content = $wpq->getpage($p['title']);
        preg_match('/{{(Baseball-WikiProject|WikiProject Baseball).*}}/i',$content,$temp);
        $content = str_replace(array('Baseball-WikiProject','|class=NA'),array('WikiProject Baseball',''),$temp[0]).str_replace($temp[0],'',$content);
        $wpapi->edit($p['title'],$content,'Updating Template ([[WP:BOT|BOT]] - [[WP:Bots/Requests for approval/Chris G Bot (3rd Request)|BRFA]])');
        sleep(1);
}
//