-
Notifications
You must be signed in to change notification settings - Fork 29
/
stats.php
152 lines (134 loc) · 6.82 KB
/
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?
/*
// +--------------------------------------------------------------------------+
// | Project: TBDevYSE - TBDev Yuna Scatari Edition |
// +--------------------------------------------------------------------------+
// | This file is part of TBDevYSE. TBDevYSE is based on TBDev, |
// | originally by RedBeard of TorrentBits, extensively modified by |
// | Gartenzwerg. |
// | |
// | TBDevYSE is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation; either version 2 of the License, or |
// | (at your option) any later version. |
// | |
// | TBDevYSE is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with TBDevYSE; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +--------------------------------------------------------------------------+
// | Do not remove above lines! |
// +--------------------------------------------------------------------------+
*/
require "include/bittorrent.php";
dbconn(false);
loggedinorreturn();
if (get_user_class() < UC_MODERATOR)
stderr($tracker_lang['error'], "Permission denied.");
stdhead("Ñòàòèñòèêà");
?>
<STYLE TYPE="text/css" MEDIA=screen>
<!--
a.colheadlink:link, a.colheadlink:visited{
font-weight: bold;
color: #FFFFFF;
text-decoration: none;
}
a.colheadlink:hover {
text-decoration: underline;
}
-->
</STYLE>
<?
begin_main_frame();
$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 = htmlspecialchars_uni($_GET['uporder']);
$catorder = htmlspecialchars_uni($_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)
stdmsg("Èçâèíèòå", "Íåò çàëèâàþùèõ.");
else
{
begin_frame("Ñòàòèñòèêà çàëèâàþùèõ", True);
begin_table();
print("<tr>\n
<td class=colhead><a href=\"" . $_SERVER['PHP_SELF'] . "?uporder=uploader&catorder=$catorder\" class=colheadlink>Çàëèâàþùèé</a></td>\n
<td class=colhead><a href=\"" . $_SERVER['PHP_SELF'] . "?uporder=lastul&catorder=$catorder\" class=colheadlink>Ïîñëåäíÿÿ çàëèâêà</a></td>\n
<td class=colhead><a href=\"" . $_SERVER['PHP_SELF'] . "?uporder=torrents&catorder=$catorder\" class=colheadlink>Òîððåíòîâ</a></td>\n
<td class=colhead>Çàâåðøåíî</td>\n
<td class=colhead><a href=\"" . $_SERVER['PHP_SELF'] . "?uporder=peers&catorder=$catorder\" class=colheadlink>Ïèðîâ</a></td>\n
<td class=colhead>Çàâåðøåíî</td>\n
</tr>\n");
while ($uper = mysql_fetch_array($res))
{
print("<tr><td><a href=userdetails.php?id=".$uper['id']."><b>".$uper['name']."</b></a></td>\n");
print("<td " . ($uper['last']?(">".$uper['last']." (".get_elapsed_time(sql_timestamp_to_unix_timestamp($uper['last']))." íàçàä)"):"align=center>---") . "</td>\n");
print("<td align=right>" . $uper['n_t'] . "</td>\n");
print("<td align=right>" . ($n_tor > 0?number_format(100 * $uper['n_t']/$n_tor,1)."%":"---") . "</td>\n");
print("<td align=right>" . $uper['n_p']."</td>\n");
print("<td 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)
stdmsg("Èçâèíèòå", "Äàííûå ïî êàòåãîðèÿì îòñóòñòâóþò!");
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("Àêòèâíîñòü êàòåãîðèé", True);
begin_table();
print("<tr><td class=colhead><a href=\"" . $_SERVER['PHP_SELF'] . "?uporder=$uporder&catorder=category\" class=colheadlink>Êàòåãîðèÿ</a></td>
<td class=colhead><a href=\"" . $_SERVER['PHP_SELF'] . "?uporder=$uporder&catorder=lastul\" class=colheadlink>Ïîñëåäíÿÿ çàëèâêà</a></td>
<td class=colhead><a href=\"" . $_SERVER['PHP_SELF'] . "?uporder=$uporder&catorder=torrents\" class=colheadlink>Òîððåíòîâ</a></td>
<td class=colhead>Çàâåðøåíî</td>
<td class=colhead><a href=\"" . $_SERVER['PHP_SELF'] . "?uporder=$uporder&catorder=peers\" class=colheadlink>Ïèðîâ</a></td>
<td class=colhead>Çàâåðøåíî</td></tr>\n");
while ($cat = mysql_fetch_array($res))
{
print("<tr><td class=rowhead>" . $cat['name'] . "</b></a></td>");
print("<td " . ($cat['last']?(">".$cat['last']." (".get_elapsed_time(sql_timestamp_to_unix_timestamp($cat['last']))." íàçàä)"):"align = center>---") ."</td>");
print("<td align=right>" . $cat['n_t'] . "</td>");
print("<td align=right>" . number_format(100 * $cat['n_t']/$n_tor,1) . "%</td>");
print("<td align=right>" . $cat['n_p'] . "</td>");
print("<td align=right>" . ($n_peers > 0?number_format(100 * $cat['n_p']/$n_peers,1)."%":"---") . "</td>\n");
}
end_table();
end_frame();
}
end_main_frame();
stdfoot();
die;
?>