Jump to content

User:CountBot

From Wikipedia, the free encyclopedia

This bot is unapproved by BAG. It is being made by A930913 and BarkingFish. When the bot is working, I shall submit it for approval. Until then, I shall test it on my own page, and pages like the sandbox, and perhaps some other users with their permission.
This bot updates the template {{User:A930913/Editcount}} on purge.

Code

[edit]
<?php
include("botclasses.php"); // Botclasses.php was written by User:Chris_G and is available under the GNU General Public License
include("loginfo.php");

$objwiki = new wikipedia();
$objwiki->login($username, $password);

$transcludes = $objwiki->getTransclusions("User:A930913/Editcount");
for ($i = 0; $i < count($transcludes); $i++) {
$contents = $objwiki->getpage($transcludes[$i]);
$startuserpos=strpos($contents,"{{User:A930913/Editcount|")+25;
$enduserpos1=strpos($contents,"|",$startuserpos);
$enduserpos2=strpos($contents,"}}",$startuserpos);
$enduserpos=$enduserpos2;if($enduserpos1<$enduserpos2&&$enduserpos1!=0){$enduserpos=$enduserpos1;}
$endtemppos=strpos($contents,"}}",$startuserpos);
$tempuser=substr($contents,$startuserpos,$enduserpos-$startuserpos);
$edits=$objwiki->contribcount($tempuser);
$newpage=substr($contents,0,$enduserpos)."|".$edits.substr($contents,$endtemppos);
$objwiki->edit($transcludes[$i],$newpage,"Updating Editcount",true,true);}?>