-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimplewiki-adminstats.php
More file actions
134 lines (120 loc) · 5.17 KB
/
simplewiki-adminstats.php
File metadata and controls
134 lines (120 loc) · 5.17 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
define('PILLAR','PILLAR');
require_once('/home/soxred93/pillar/trunk/class.pillar.php');
require_once('/home/soxred93/database.inc');
$pillar = Pillar::ini_launch('/home/soxred93/configs/simplewiki-adminstats.cfg');
//$pillar = Pillar::get_instance;
$site = $pillar->cursite;
mysql_connect('sql-s3',$toolserver_username,$toolserver_password);
@mysql_select_db('simplewiki_p') or print mysql_error();
$u = array();
$users = $site->get_embeddedin('Template:Adminstats','500',$continue,2);
foreach( $users as $user ) {
$u[] = $user;
}
while( isset($users[499]) ) {
$users = $site->get_embeddedin('Template:Adminstats','500',$continue,2);
foreach( $users as $user ) {
$u[] = $user;
}
}
//$u = array("User talk:X!");
foreach ($u as $name) {
preg_match("/User( talk)?:([^\/]*)/i", $name, $m);
process($m[2]);
}
function process ($rawuser) {
global $pillar;
$user = mysql_real_escape_string($rawuser);
$query = "SELECT count(rev_id) FROM revision WHERE rev_user_text = '$user'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$out = '{{Adminstats/Core'."\n";
$numsqlbot = $row['count(rev_id)'];
$out = $out . "|edits=$numsqlbot\n";
$query = "SELECT * FROM user WHERE user_name = '$user'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$uid = $row[user_id];
$numall = $row[user_editcount];
$out = $out . "|ed=$numall\n";
$query = "SELECT * FROM user_groups WHERE ug_user = '$uid'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
if($row[ug_group] == "sysop") { $approved = 1; }
}
if ($approved != 1) { return; }
$query = "SELECT count(log_action) FROM logging WHERE log_user = '$uid' AND log_type = 'newusers'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$newusers = $row['count(log_action)'];
$out = $out . "|created=$newusers\n";
$query = "SELECT count(log_action) FROM logging WHERE log_user = '$uid' AND log_action = 'delete'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$deletions = $row['count(log_action)'];
$out = $out . "|deleted=$deletions\n";
$query = "SELECT count(log_action) FROM logging WHERE log_user = '$uid' AND log_action = 'restore'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$restores = $row['count(log_action)'];
$out = $out . "|restored=$restores\n";
$query = "SELECT count(log_action) FROM logging WHERE log_user = '$uid' AND log_action = 'block'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$blocks = $row['count(log_action)'];
$out = $out . "|blocked=$blocks\n";
$query = "SELECT count(log_action) FROM logging WHERE log_user = '$uid' AND log_action = 'protect'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$protects = $row['count(log_action)'];
$out = $out . "|protected=$protects\n";
$query = "SELECT count(log_action) FROM logging WHERE log_user = '$uid' AND log_action = 'unprotect'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$unprotects = $row['count(log_action)'];
$out = $out . "|unprotected=$unprotects\n";
$query = "SELECT count(log_action) FROM logging WHERE log_user = '$uid' AND log_action = 'rights'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$grants = $row['count(log_action)'];
$out = $out . "|rights=$grants\n";
$query = "SELECT count(log_action) FROM logging WHERE log_user = '$uid' AND log_action = 'reblock'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$protects = $row['count(log_action)'];
$out = $out . "|reblock=$protects\n";
$query = "SELECT count(log_action) FROM logging WHERE log_user = '$uid' AND log_action = 'modify'";
$result = mysql_query($query);
if(!$result) toDie("ERROR: No result returned." . mysql_error());
$row = mysql_fetch_assoc($result);
$protects = $row['count(log_action)'];
$out = $out . "|modify=$protects\n";
$out = $out . '|style={{{style|}}}}}';
echo $out;
echo "\n";
$toedit = "Template:Adminstats/$rawuser\n";
echo "Editing $toedit";
try {
$page = new Page($pillar->cursite,$toedit);
} catch (PillarException $e) {
continue;
}
try {
$page->put($out,"Updating Admin Stats",true);
} catch (PillarException $e) {
continue;
}
}
?>