Repository navigation
Expand file tree
/
Copy pathstats.php
More file actions
175 lines (143 loc) · 6.04 KB
/
Copy pathstats.php
File metadata and controls
175 lines (143 loc) · 6.04 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/**
**************************
** FreeTSP Version: 1.0 **
**************************
** http://www.freetsp.info
** https://github.com/Krypto/FreeTSP
** Licence Info: GPL
** Copyright (C) 2010 FreeTSP v1.0
** A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
** Project Leaders: Krypto, Fireknight.
**/
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'functions'.DIRECTORY_SEPARATOR.'function_main.php');
require_once(FUNC_DIR.'function_user.php');
require_once(FUNC_DIR.'function_vfunctions.php');
db_connect(false);
logged_in();
if (get_user_class() < UC_MODERATOR)
{
error_message("warn", "Warning", "Permission Denied.");
}
site_header("Stats");
?>
<?php
$res = sql_query("SELECT COUNT(*)
FROM torrents") or sqlerr(__FILE__, __LINE__);
$n = mysql_fetch_row($res);
$n_tor = $n[0];
$res = sql_query("SELECT COUNT(*)
FROM peers") or sqlerr(__FILE__, __LINE__);
$n = mysql_fetch_row($res);
$n_peers = $n[0];
$uporder = isset($_GET['uporder']) ? $_GET['uporder'] : '';
$catorder = isset($_GET["catorder"]) ? $_GET["catorder"] : '';
if ($uporder == "lastul")
{
$orderby = "last DESC, name";
}
elseif ($uporder == "torrents")
{
$orderby = "n_t DESC, name";
}
elseif ($uporder == "peers")
{
$orderby = "n_p DESC, name";
}
else
{
$orderby = "name";
}
$query = "SELECT u.id, u.username AS name, MAX(t.added) AS last, COUNT(DISTINCT t.id) AS n_t, COUNT(p.id) AS n_p
FROM users AS u
LEFT JOIN torrents AS t ON u.id = t.owner
LEFT JOIN peers AS p ON t.id = p.torrent
WHERE u.class = ".UC_UPLOADER."
GROUP BY u.id
UNION SELECT u.id, u.username AS name, MAX(t.added) AS last, COUNT(DISTINCT t.id) AS n_t, COUNT(p.id) AS n_p
FROM users AS u
LEFT JOIN torrents AS t ON u.id = t.owner
LEFT JOIN peers AS p ON t.id = p.torrent
WHERE u.class > ".UC_UPLOADER."
GROUP BY u.id
ORDER BY $orderby";
$res = sql_query($query) or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 0)
{
error_message("info", "Sorry...", "No Uploaders.");
}
else
{
begin_frame("Uploader Activity", true);
begin_table();
echo("<tr>\n
<td class='colhead'><a href='".$_SERVER['PHP_SELF']."?uporder=uploader&catorder=$catorder' class='colheadlink'>Uploader</a></td>\n
<td class='colhead'><a href='".$_SERVER['PHP_SELF']."?uporder=lastul&catorder=$catorder' class='colheadlink'>Last Upload</a></td>\n
<td class='colhead'><a href='".$_SERVER['PHP_SELF']."?uporder=torrents&catorder=$catorder' class='colheadlink'>Torrents</a></td>\n
<td class='colhead'>Perc.</td>\n
<td class='colhead'><a href='".$_SERVER['PHP_SELF']."?uporder=peers&catorder=$catorder' class='colheadlink'>Peers</a></td>\n
<td class='colhead'>Perc.</td>\n
</tr>\n");
while ($uper = mysql_fetch_assoc($res))
{
echo("<tr><td class='std'><a href='userdetails.php?id=".$uper['id']."'><span style='font-weight:bold;'>".$uper['name']."</span></a></td>\n");
echo("<td ".($uper['last'] ? (">".$uper['last']." (".get_elapsed_time(sql_timestamp_to_unix_timestamp($uper['last']))." ago)") : " class='rowhead' align='center'>---")."</td>\n");
echo("<td class='rowhead' align='right'>".$uper['n_t']."</td>\n");
echo("<td class='rowhead' align='right'>".($n_tor > 0 ? number_format(100 * $uper['n_t'] / $n_tor, 1)."%" : "---")."</td>\n");
echo("<td class='rowhead' align='right'>".$uper['n_p']."</td>\n");
echo("<td class='rowhead' align='right'>".($n_peers > 0 ? number_format(100 * $uper['n_p'] / $n_peers, 1)."%" : "---")."</td></tr>\n");
}
end_table();
end_frame();
}
if ($n_tor == 0)
{
error_message("info", "Sorry...", "No Categories Defined!");
}
else
{
if ($catorder == "lastul")
{
$orderby = "last DESC, c.name";
}
elseif ($catorder == "torrents")
{
$orderby = "n_t DESC, c.name";
}
elseif ($catorder == "peers")
{
$orderby = "n_p DESC, name";
}
else
{
$orderby = "c.name";
}
$res = sql_query("SELECT c.name, MAX(t.added) AS last, COUNT(DISTINCT t.id) AS n_t, COUNT(p.id) AS n_p
FROM categories AS c
LEFT JOIN torrents AS t ON t.category = c.id
LEFT JOIN peers AS p ON t.id = p.torrent
GROUP BY c.id
ORDER BY $orderby") or sqlerr(__FILE__, __LINE__);
begin_frame("Category Activity", true);
begin_table();
echo("<tr><td class='colhead'><a href='".$_SERVER['PHP_SELF']."?uporder=$uporder&catorder=category' class='colheadlink'>Category</a></td>
<td class='colhead'><a href='".$_SERVER['PHP_SELF']."?uporder=$uporder&catorder=lastul' class='colheadlink'>Last Upload</a></td>
<td class='colhead'><a href='".$_SERVER['PHP_SELF']."?uporder=$uporder&catorder=torrents' class='colheadlink'>Torrents</a></td>
<td class='colhead'>Perc.</td>
<td class='colhead'><a href='".$_SERVER['PHP_SELF']."?uporder=$uporder&catorder=peers' class='colheadlink'>Peers</a></td>
<td class='colhead'>Perc.</td></tr>\n");
while ($cat = mysql_fetch_assoc($res))
{
echo("<tr><td class='rowhead'>".$cat['name']."</td>");
echo("<td ".($cat['last'] ? (">".$cat['last']." (".get_elapsed_time(sql_timestamp_to_unix_timestamp($cat['last']))." ago)") : "align = 'center'>---")."</td>");
echo("<td class='rowhead' align='right'>".$cat['n_t']."</td>");
echo("<td class='rowhead' align='right'>".number_format(100 * $cat['n_t'] / $n_tor, 1)."%</td>");
echo("<td class='rowhead' align='right'>".$cat['n_p']."</td>");
echo("<td class='rowhead' align='right'>".($n_peers > 0 ? number_format(100 * $cat['n_p'] / $n_peers, 1)."%" : "---")."</td></tr>\n");
}
end_table();
end_frame();
}
site_footer();
die;
?>