root / plugins / minecraft / minecraft-sql-ultrabans-shame @ 007c2825
Historique | Voir | Annoter | Télécharger (3,88 ko)
| 1 |
#!/usr/bin/php |
|---|---|
| 2 |
<?php |
| 3 |
/** |
| 4 |
* Bukkit/MySQL Munin plugin |
| 5 |
* --------------------------------- |
| 6 |
* Kicks/bans/jails/etc. per day |
| 7 |
* |
| 8 |
* Shows the amount and kind of shame that |
| 9 |
* happens on your server via Ultrabans |
| 10 |
* (http://s.frd.mn/14qLR2B) |
| 11 |
* |
| 12 |
* Read more about my plugins on my blog: |
| 13 |
* http://s.frd.mn/XJsryR |
| 14 |
* |
| 15 |
* Author: Jonas Friedmann (http://frd.mn) |
| 16 |
* |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* MySQL configuration |
| 21 |
*/ |
| 22 |
|
| 23 |
$hostname = 'localhost'; |
| 24 |
$username = 'sql'; |
| 25 |
$password = 'pass'; |
| 26 |
$database = 'sql'; |
| 27 |
$port = 3306; |
| 28 |
|
| 29 |
/** |
| 30 |
* !!! DO NOT EDIT THIS PART BELOW !!! |
| 31 |
*/ |
| 32 |
|
| 33 |
if ((count($argv) > 1) && ($argv[1] == 'config')) |
| 34 |
{
|
| 35 |
print("graph_title Bukkit / Ultrabans - shame per day
|
| 36 |
graph_category bukkit_sql |
| 37 |
graph_vlabel amount of shame per day |
| 38 |
graph_args --base 1000 -l 0 |
| 39 |
unban.type GAUGE |
| 40 |
unban.label unbans |
| 41 |
kick.type GAUGE |
| 42 |
kick.label kicks |
| 43 |
warning.type GAUGE |
| 44 |
warning.label warnings |
| 45 |
ban.type GAUGE |
| 46 |
ban.label bans |
| 47 |
ipban.type GAUGE |
| 48 |
ipban.label ipbans |
| 49 |
fine.type GAUGE |
| 50 |
fine.label fines |
| 51 |
jail.type GAUGE |
| 52 |
jail.label jails |
| 53 |
permban.type GAUGE |
| 54 |
permban.label permbans |
| 55 |
mute.type GAUGE |
| 56 |
mute.label mutes |
| 57 |
"); |
| 58 |
exit(); |
| 59 |
} |
| 60 |
|
| 61 |
// Construct 'minumum' timstamp |
| 62 |
$current = mktime(); |
| 63 |
$today = mktime(0, 0, 0, date("n", $current), date("j", $current), date("Y", $current));
|
| 64 |
|
| 65 |
// Initiate connection |
| 66 |
$connection = mysqli_connect($hostname, $username, $password, $database, $port); |
| 67 |
|
| 68 |
// Check connection |
| 69 |
if (mysqli_connect_errno()) {
|
| 70 |
printf("Connect failed: %s\n", mysqli_connect_error());
|
| 71 |
exit(); |
| 72 |
} |
| 73 |
|
| 74 |
// Select queries for unbans return the amount of rows |
| 75 |
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 5 AND time > $today")) {
|
| 76 |
// Print values |
| 77 |
print('unban.value ' . mysqli_num_rows($result) . "\n");
|
| 78 |
} |
| 79 |
|
| 80 |
// Select queries for kicks return the amount of rows |
| 81 |
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 3 AND time > $today")) {
|
| 82 |
// Print values |
| 83 |
print('kick.value ' . mysqli_num_rows($result) . "\n");
|
| 84 |
} |
| 85 |
|
| 86 |
// Select queries for warnings return the amount of rows |
| 87 |
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 2 AND time > $today")) {
|
| 88 |
// Print values |
| 89 |
print('warning.value ' . mysqli_num_rows($result) . "\n");
|
| 90 |
} |
| 91 |
|
| 92 |
// Select queries for bans return the amount of rows |
| 93 |
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 0 AND time > $today")) {
|
| 94 |
// Print values |
| 95 |
print('ban.value ' . mysqli_num_rows($result) . "\n");
|
| 96 |
} |
| 97 |
|
| 98 |
// Select queries for ipbans return the amount of rows |
| 99 |
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 1 AND time > $today")) {
|
| 100 |
// Print values |
| 101 |
print('ipban.value ' . mysqli_num_rows($result) . "\n");
|
| 102 |
} |
| 103 |
|
| 104 |
// Select queries for fines return the amount of rows |
| 105 |
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 4 AND time > $today")) {
|
| 106 |
// Print values |
| 107 |
print('fine.value ' . mysqli_num_rows($result) . "\n");
|
| 108 |
} |
| 109 |
|
| 110 |
// Select queries for jails return the amount of rows |
| 111 |
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 6 AND time > $today")) {
|
| 112 |
// Print values |
| 113 |
print('jail.value ' . mysqli_num_rows($result) . "\n");
|
| 114 |
} |
| 115 |
|
| 116 |
// Select queries for permbans return the amount of rows |
| 117 |
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 9 AND time > $today")) {
|
| 118 |
// Print values |
| 119 |
print('permban.value ' . mysqli_num_rows($result) . "\n");
|
| 120 |
} |
| 121 |
|
| 122 |
// Select queries for mutes - part 1 return the amount of rows |
| 123 |
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 7 AND time > $today")) {
|
| 124 |
// Store result |
| 125 |
$tmp1 = mysqli_num_rows($result); |
| 126 |
} |
| 127 |
|
| 128 |
// Select queries for mutes - part 2 return the amount of rows |
| 129 |
if ($result = mysqli_query($connection, "SELECT name FROM banlist WHERE type = 8 AND time > $today")) {
|
| 130 |
// Store result |
| 131 |
$tmp2 = mysqli_num_rows($result); |
| 132 |
} |
| 133 |
|
| 134 |
$mutes = $tmp1 + $tmp2; |
| 135 |
|
| 136 |
print('mute.value ' . $mutes . "\n");
|
| 137 |
|
| 138 |
// Close connection |
| 139 |
mysqli_close($connection); |
| 140 |
?> |
