Jump to content

Wikipedia:Bots/Requests for approval/MadmanBot 7/Source code

From Wikipedia, the free encyclopedia
<?php

    define('PILLAR', 'PILLAR');
    require_once 'class.pillar.php';
    $pillar =& Pillar::ini_launch('madmanbot.ini');

    $categories = array('Category:FA Cup seasons', 
        'Category:Football Conference seasons', 
        'Category:Football League Cup seasons', 
        'Category:The Football League seasons');

    foreach ($categories as $category)
    {
        $continue = NULL;
        $members = array();
        do
        {
            $result = $pillar->cursite->get_categorymembers($category, 500, 
                $continue, 0);
            $members = array_merge($result, $members);
        }
        while ($continue != NULL);

        foreach ($members as $member)
        {
            $to = preg_replace(
                '/^(The )?(.+) (\\d+–\\d+)( Qualifying Rounds)?$/', 
                '\\3 \\2\\4', $member['title']);

            if ($member['title'] === $to)
            {
                continue;
            }

            try
            {
                $page = new Page($pillar->cursite, $member['title']);

                if (!$page->checkexcluded('MadmanBot'))
                {
                    $page->move($to, 'Per [[Wikipedia:Bot requests' . 
                        '#English football competition seasons]]');
                }
            }
            catch (PillarException $ex)
            {
                continue;
            }
        }
    }

?>