From Wikipedia, the free encyclopedia
<?php
require_once('./rfalib2.php');
require_once('./SxWiki.php');
require_once('./config.php');
$output = "Wikipedia:Bureaucrats' noticeboard/RfB Report";
#$output = "User:SQL/RfB Report";
echo "Processing $argv[1]\n";
function bailout($message) {
echo "Fatal Error\n";
echo "$message\n";
exit;
}
function processrfa($cantidate) {
$rfabasename = "Wikipedia:Requests for bureaucratship/";
$myRFA = new RFA();
$buffer = sxGetPage($rfabasename . $cantidate);
$result = $myRFA->analyze($buffer);
if ($result !== TRUE) {
bailout($myRFA->lasterror);
}
$enddate = $myRFA->enddate;
$tally = count($myRFA->support).'/'.count($myRFA->oppose).'/'.count($myRFA->neutral);
$opposes = count($myRFA->oppose);
$supports = count($myRFA->support);
$neutrals = count($myRFA->neutral);
$n_dup = 0;
foreach($myRFA->duplicates as $dup) {
$n_dup++;
}
$dups = "no";
if ($n_dup > 0) {
$dups = "'''yes'''";
}
return "{{Bureaucrat candidate|candidate= $cantidate|support= $supports|oppose= $opposes|neutral= $neutrals|end date= $enddate|dups= $dups}}";
}
$findrfb = "/\{\{Wikipedia:Requests for bureaucratship\/(.*)\}\}/";
$rfabuffer = sxGetPage("Wikipedia:Requests for adminship");
#$rfabuffer = sxGetPage("User:SQL/RFATest");
preg_match_all($findrfb, $rfabuffer, $matches);
$numrfb = 0;
foreach ($matches[1] as $rfb) {
$result = processrfa($rfb);
$out = $out . "\n|-\n" . $result;
$numrfb++;
}
$out = "<noinclude>{{shortcut|WP:RFBR}}</noinclude>\n{| align=\"right\" cellspacing=\"0\" cellpadding=\"0\" style=\"white-space:nowrap; clear: left; margin-top: 0em; margin-bottom: .5em; float: right;padding: .5em 0em 0em 1.4em; background: none;\"\n|\n{| class=\"wikitable\"\n! RfB candidate !! S !! O !! N !! S% !! Ending !! Dups? !! Report" . $out;
$out = $out . "\n|}<div align=\"right\">\n''Last updated by '''~~~''' on '''~~~~~'''''\n</div>\n|}\n";
echo $out;
$runme = sxGetPage("User:SQLBot/rfbbot.run");
$runme = ltrim($runme);
$runme = rtrim($runme);
if ($runme == "go") {
if($numrfb > 0) {
sxPutPage($output, "Updating RFB Report, $numrfb RFB's", $out);
} else {
sxPutPage($output, "No more active RFB's", "");
}
} else {
echo "Could not run, disabled!\n";
}
?>