コード例 #1
0
        global $wgUser;
        $start_at = 99442;
        $batch_size = 1000;
        //save user
        $tempUser = $wgUser;
        //swap user
        $wgUser = User::newFromName('LargeImageBot');
        //get all
        $articles = self::getArticles($start_at, 150000);
        $count = 0;
        $full_count = $start_at;
        //cycle through 1000 at a time
        while ($a = array_shift($articles)) {
            $res = self::resizeImages($a);
            print $full_count . ' - ' . $res . "\n";
            if ($count >= $batch_size) {
                $count = 0;
                //SLEEP IN HEAVENLY PEACE!!!
                print "sleeping...\n";
                sleep(4 * 60);
            } else {
                $count++;
            }
            $full_count++;
        }
        //swap back
        $wgUser = $tempUser;
    }
}
ImageResize::main();