-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathafd-calc.php
95 lines (75 loc) · 2.21 KB
/
afd-calc.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
echo date('r')."\n";
define('PILLAR','PILLAR');
require_once('/home/soxred93/pillar/trunk/class.pillar.php');
require_once('/home/soxred93/wikibot.classes.php');
$http = new http;
$pillar = Pillar::ini_launch('/home/soxred93/configs/afd-calc.cfg');
//$pillar = Pillar::get_instance;
$site = $pillar->cursite;
$u = array();
$users = $site->get_embeddedin('Template:REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD','500',$continue,4);
foreach( $users as $user ) {
if( substr($user,0,36) == 'Wikipedia:Articles for deletion/Log/' ) continue;
if( substr($user,0,32) != 'Wikipedia:Articles for deletion/' ) continue;
$u[] = $user;
}
while( isset($users[499]) ) {
try {
$users = $site->get_embeddedin('Template:REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD','500',$continue,4);
} catch (PillarException $e) {
break;
}
foreach( $users as $user ) {
if( substr($user,0,36) == 'Wikipedia:Articles for deletion/Log/' ) continue;
if( substr($user,0,32) != 'Wikipedia:Articles for deletion/' ) continue;
$u[] = $user;
}
}
//$u = array('Wikipedia:Articles for deletion/IrishJack');
$afds = array();
foreach ($u as $name) {
$rawuser = $name;
try {
$page = new Page($pillar->cursite,$rawuser);
} catch (PillarException $e) {
continue;
}
$text = $page->get_text();
if( preg_match( '/(\d{2}):(\d{2}), (\d{2}) (\w*?) (\d{4}) \(UTC\)/S', $text, $date ) ) {
$nomdate = date('Y F d', strtotime("{$date[3]} {$date[4]} {$date[5]} {$date[1]}:{$date[2]}:00"));
}
echo $nomdate."\n\n";
$afds[$nomdate][] = $rawuser;
}
print_r($afds);
$out = "{| class=\"wikitable collapsible collapsed\"\n|-\n";
foreach($afds as $nomdate => $afd) {
$out .= "! Nominated $nomdate (".count($afd).")\n|-\n";
foreach($afd as $a) {
$name = substr($a,32);
$out .= "| [[Wikipedia:Articles for deletion/$name|$name]]\n|-\n";
}
}
$out .= '|}';
echo $out;
try {
$page = new Page($site,'User:X!/AFD report');
} catch (PillarException $e) {
try {
$page = new Page($site,'User:X!/AFD report');
} catch (PillarException $e) {
die;
}
}
try {
$page->put($out,"Updating AFD table",true);
} catch (PillarException $e) {
try {
$page->put($out,"Updating AFD table",true);
} catch (PillarException $e) {
continue;
}
}
echo date('r');
?>