Jump to content

User:One bot/openbrfa.php

From Wikipedia, the free encyclopedia
<?php
/** openbrfa.php -- Removes old entries from Category:Open_Wikipedia_bot_requests_for_approval
 *  STABLE Version 1.0
 *
 *  (c) 2010 James Hare - http://en.wiki.x.io/wiki/User:Harej
 *
 *  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):
 *    James Hare - [[User:Harej]] - Wrote everything
 **/
ini_set("display_errors", 1);
error_reporting(E_ALL ^ E_NOTICE);
include("./public_html/botclasses.php");  // Botclasses.php was written by User:Chris_G and is available under the GNU General Public License
include("logininfo.php");

echo "Logging in...";
$objwiki = new wikipedia();
$objwiki->login($oneuser, $onepass);
echo " done.\n";

echo "Checking category members...";
$transcludes = $objwiki->categorymembers("Category:Open_Wikipedia_bot_requests_for_approval");
echo " done.\n";

for ($i = 0; $i < count($transcludes); $i++) {
	echo "Retrieving $transcludes[$i] contents... \n";
	$contents = $objwiki->getpage($transcludes[$i]);
	preg_match("/Please do not modify it/", $contents, $p);
	if ($p[0] != "") {
		$contents = preg_replace("/<noinclude>\[\[Category:Open Wikipedia bot requests for approval.*/", "", $contents);
		$objwiki->edit($transcludes[$i],$contents,"Removing Category:Open Wikipedia bot requests for approval",true,true);
	}
}

?>