forked from Bigjoos/U-232-V5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
irc_stats.php
137 lines (134 loc) · 7.45 KB
/
irc_stats.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
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
<?php
/**
|--------------------------------------------------------------------------|
| https://github.com/Bigjoos/ |
|--------------------------------------------------------------------------|
| Licence Info: WTFPL |
|--------------------------------------------------------------------------|
| Copyright (C) 2010 U-232 V5 |
|--------------------------------------------------------------------------|
| A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon. |
|--------------------------------------------------------------------------|
| Project Leaders: Mindless, Autotron, whocares, Swizzles. |
|--------------------------------------------------------------------------|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
*/
$hash = "YXBwemZhbg";
$_hash = isset($_GET["hash"]) ? $_GET["hash"] : "";
$_user = isset($_GET["u"]) ? htmlspecialchars($_GET["u"]) : "";
$valid_do = array(
"stats",
"torrents",
"fls",
"irc",
"top_idle",
"top_uploaders",
"top_posters",
"top_torrents"
);
$_do = isset($_GET["do"]) && in_array($_GET["do"], $valid_do) ? $_GET["do"] : "";
function calctime($val)
{
$days = intval($val / 86400);
$val-= $days * 86400;
$hours = intval($val / 3600);
$val-= $hours * 3600;
$mins = intval($val / 60);
$secs = $val - ($mins * 60);
return "$days days, $hours hrs, $mins minutes";
}
if (substr($_do, 0, 3) == "top") {
$_type = end(explode("_", $_do));
$_do = "top";
}
//$_hash = "YXBwemZhbg";
if ($_hash === $hash) {
require_once (__DIR__ . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'bittorrent.php');
dbconn(false, false);
if (empty($_user) && ($_do == "stats" || $_do == "torrents" || $_do == "irc")) exit("Can't find the username");
if ($_do == "stats") {
$q = sql_query("SELECT id, username, last_access, downloaded, uploaded, added, status, warned, disable_reason, warn_reason FROM users WHERE username = " . sqlesc($_user)) or exit(((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
if (mysqli_num_rows($q) == 1) {
$a = mysqli_fetch_assoc($q);
$txt = $a["username"] . " is " . ((TIME_NOW - $a["last_access"]) < 300 ? "online" : "offline") . "\nJoined - " . get_date($a["added"], 'LONG', 0, 1) . "\nLast seen - " . get_date($a["last_access"], 'DATE', 0, 1) . "\nDownloaded - " . mksize($a["downloaded"]) . "\nUploaded - " . mksize($a["uploaded"]) . "\n";
if ($a["status"] == "disabled") $txt.= "This user is disabled. Reason " . $a["disable_reason"] . "\n";
if ($a["warned"] == "yes") $txt.= "This user is warned. Reason " . $a["warn_reason"] . "\n";
$txt.= $INSTALLER09['baseurl'] . "/userdetails.php?id=" . $a["id"];
echo ($txt);
} else exit("User \"" . $_user . "\" not found!");
unset($txt);
unset($a);
unset($q);
} elseif ($_do == "torrents") {
$q = sql_query("SELECT count(p.id) as count, p.seeder,p.agent,p.port,p.connectable, u.username FROM peers as p LEFT JOIN users as u ON u.id = p.userid WHERE u.username=" . sqlesc($_user) . " GROUP BY p.seeder") or exit(((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
if (mysqli_num_rows($q) == 0) exit("User \"" . $_user . "\" has no torrent active");
$act['seed'] = $act['leech'] = 0;
while ($a = mysqli_fetch_assoc($q)) {
$key = ($a["seeder"] == "yes" ? "seed" : "leech");
$act[$key] = $a["count"];
$agent = $a["agent"];
$port = $a["port"];
$con = $a["connectable"];
$user = $a["username"];
}
$txt = $user . " is " . ($con == "yes" ? "connectable" : "not connectable") . "\nActive torrents\n seeding - " . number_format($act["seed"]) . " | leeching - " . number_format($act["leech"]) . "\nAgent - " . $agent . " | Port - " . $port;
echo ($txt);
unset($txt);
unset($a);
unset($q);
} elseif ($_do == "fls") {
$q = sql_query("SELECT id,username,last_access ,supportfor FROM users WHERE support = 'yes' ORDER BY added desc") or exit(((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
$txt = "";
while ($a = mysqli_fetch_assoc($q)) {
$txt.= $a["username"] . " - status " . ((TIME_NOW - $a["last_access"]) < 300 ? "online" : "offline") . " | Support for " . $a["supportfor"] . "\n";
unset($support);
}
echo ($txt);
unset($_fls);
unset($a);
unset($q);
unset($txt);
} elseif ($_do == "irc") {
$q = sql_query("SELECT onirc, irctotal,username FROM users WHERE username = " . sqlesc($_user)) or exit(((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
if (mysqli_num_rows($q) == 0) exit("User \"" . $_user . "\" not found!");
$a = mysqli_fetch_assoc($q);
$txt = $a["username"] . " " . ($a["irctotal"] == 0 ? "never been on irc" : "has idled on irc " . calctime($a["irctotal"])) . "\nAnd now he " . ($a["onirc"] == "yes" ? "is" : "isn't") . " on irc";
echo ($txt);
unset($a);
unset($q);
unset($txt);
} elseif ($_do == "top") {
switch ($_type) {
case "idle":
$_q = "select username,irctotal FROM users ORDER BY irctotal DESC LIMIT 10";
$txt = "Top 10 idle\n";
break;
case "uploaders":
$_q = "select username, uploaded FROM users WHERE status = 'confirmed' ORDER BY uploaded DESC LIMIT 10";
$txt = "Best uploaders (selected after uploaded amount)\n";
break;
case "torrents":
$_q = "select count(t.id) as c, u.username FROM torrents as t LEFT JOIN users as u ON t.owner = u.id WHERE u.username <> '' GROUP BY u.id ORDER BY c DESC LIMIT 10";
$txt = "Best uploaders (selected after the torrents uploaded)\n";
break;
case "posters":
$_q = "select count(p.id) as c, u.username FROM posts as p LEFT JOIN users as u ON p.user_id = u.id WHERE u.username <> '' GROUP BY u.id ORDER BY c DESC LIMIT 10";
$txt = "Best posters (selected after number of posts)\n";
break;
}
$i = 1;
$q = sql_query($_q) or exit(((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
while ($a = mysqli_fetch_assoc($q)) {
$txt.= $i . " - " . $a["username"] . " with " . ($_type == "idle" ? calctime($a["irctotal"]) . " idle" : ($_type == "uploaders" ? mksize($a["uploaded"]) . " uploaded" : ($_type == "torrents" ? $a["c"] . " torrents" : $a["c"] . " posts"))) . "\n";
$i++;
}
echo $txt;
unset($a);
unset($q);
unset($txt);
}
}
?>