-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbukkit-ultrabans-shame
140 lines (120 loc) · 3.86 KB
/
bukkit-ultrabans-shame
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
135
136
137
138
139
140
#!/usr/bin/php
<?php
/**
* Bukkit/MySQL Munin plugin
* ---------------------------------
* Kicks/bans/jails/etc. per day
*
* Shows the amount and kind of shame that
* happens on your server via Ultrabans
* (http://s.frd.mn/14qLR2B)
*
* Read more about my plugins on my blog:
* http://s.frd.mn/XJsryR
*
* Author: Jonas Friedmann (http://frd.mn)
*
*/
/**
* MySQL configuration
*/
$hostname = 'localhost';
$username = 'sql';
$password = 'pass';
$database = 'sql';
$port = 3306;
/**
* !!! DO NOT EDIT THIS PART BELOW !!!
*/
if ((count($argv) > 1) && ($argv[1] == 'config'))
{
print("graph_title Bukkit / Ultrabans - shame per day
graph_category bukkit
graph_vlabel amount of shame per day
graph_args --base 1000 -l 0
unban.type GAUGE
unban.label unbans
kick.type GAUGE
kick.label kicks
warning.type GAUGE
warning.label warnings
ban.type GAUGE
ban.label bans
ipban.type GAUGE
ipban.label ipbans
fine.type GAUGE
fine.label fines
jail.type GAUGE
jail.label jails
permban.type GAUGE
permban.label permbans
mute.type GAUGE
mute.label mutes
");
exit();
}
// Construct 'minumum' timstamp
$current = mktime();
$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current));
// Initiate connection
$connection = mysqli_connect($hostname, $username, $password, $database, $port);
// Check connection
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
// Select queries for unbans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 5 AND time > $today")) {
// Print values
print('unban.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for kicks return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 3 AND time > $today")) {
// Print values
print('kick.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for warnings return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 2 AND time > $today")) {
// Print values
print('warning.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for bans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 0 AND time > $today")) {
// Print values
print('ban.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for ipbans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 1 AND time > $today")) {
// Print values
print('ipban.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for fines return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 4 AND time > $today")) {
// Print values
print('fine.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for jails return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 6 AND time > $today")) {
// Print values
print('jail.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for permbans return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 9 AND time > $today")) {
// Print values
print('permban.value ' . mysqli_num_rows($result) . "\n");
}
// Select queries for mutes - part 1 return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 7 AND time > $today")) {
// Store result
$tmp1 = mysqli_num_rows($result);
}
// Select queries for mutes - part 2 return the amount of rows
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 8 AND time > $today")) {
// Store result
$tmp2 = mysqli_num_rows($result);
}
$mutes = $tmp1 + $tmp2;
print('mute.value ' . $mutes . "\n");
// Close connection
mysqli_close($connection);
?>