:User:SoxBot II/Source
Source to SoxBot II
<?PHPinclude '../Cluebot2/wikibot.classes.php';
include '../Cluebot2/cluebot2.config.php';
$wpq = new wikipediaquery;
$wpapi = new wikipediaapi;
$wpi = new wikipediaindex;
$wpapi->login($user,$pass);
$wpi->forcepost('User:'.$user.'/Source',"The following is automatically generated by .\n\n\n\n* wikibot.classes.php is here.\n\n\n\n==Source to ".$user."==\n\n<pre>".htmlentities(file_get_contents(__FILE__))."</pre>\n\n\n\n~~~",'Automated source upload.'); /* Our source code, we force post this because this is *our* page, and it triggers the nobots. */
$text = $wpq->getpage('Wikipedia:Requests for adminship');
$result = array();
foreach (array(adminship,bureaucratship) as $rfx) {
preg_match_all('/\{\{Wikipedia\:Requests for '.$rfx.'\/(.*)\}\}/', $text, $r);
unset($r[1]);
if ($rfx == 'adminship') {
unset($r[0][0]);
array_pop($r[0]);
}
print_r($r);
$count = '0';
foreach ($r[0] as $data) {
$count = $count + 1;
}
$month = array(4=>0,5=>1,6=>2,7=>3,8=>4,9=>5,10=>6,11=>7,12=>8,1=>9,2=>10,3=>11);
$days = array(28=>8.6,29=>8.3,30=>8,31=>7.7);
$out = (240*$month[date("n")])+(date("j")*($days[date("t")])).",".($count * 50);
echo $out."\n";
array_push($result, $out);
}
print_r($result);
$code = $wpq->getpage('User:Soxred93/RfA Graph');
$code = str_replace("<polyline stroke=\"#4A7EBB\" points=\"", "<polyline stroke=\"#4A7EBB\" points=\"\n".$result[0], $code);
$code = str_replace("<polyline stroke=\"#BE4B48\" points=\"", "<polyline stroke=\"#BE4B48\" points=\"\n".$result[1], $code);
file_put_contents('../Cluebot2/Graph of RfA and RfB.svg', $code);
if (date("w") == '3') {
$wpi->upload('../Cluebot2/Graph of RfA and RfB.svg','/home/soxred93/Cluebot2/Graph of RfA and RfB.svg','Automated upload of graph');
}
$wpi->post('User:Soxred93/RfA Graph', $code, 'Posting the code for an SVG graph (BOT EDIT)');
?>