-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrfx-graph.php
51 lines (42 loc) · 2.04 KB
/
rfx-graph.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?PHP
ini_set('memory_limit','16M');
include '/home/soxred93/wikibot.classes.php';
$wpq = new wikipediaquery;
$wpapi = new wikipediaapi;
$wpi = new wikipediaindex;
$http = new http;
$user = "SoxBot";
$pass = file_get_contents('/home/soxred93/.password');
$wpapi->login($user,$pass);
if( !preg_match( '/(enable|yes|run|go|start)/i', $wpq->getpage("User:SoxBot/Run/RFAGraph") ) ) {
die( "Bot is disabled.\n" );
}
//$wpi->forcepost('User:'.$user.'/Source',"The following is automatically generated by [[User:".$user."|]].\n\n\n\n* wikibot.classes.php is [[User:ClueBot/Source|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:X!/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('/home/soxred93/public_html/Graph of RfA and RfB.svg', $code);
$wpi->upload('/home/soxred93/public_html/Graph of RfA and RfB.svg','/home/soxred93/public_html/Graph of RfA and RfB.svg','Automated upload of graph');
$wpi->post('User:X!/RfA Graph', $code, 'Posting the code for an SVG graph (BOT EDIT)');
?>