This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
users.php
187 lines (152 loc) · 6.75 KB
/
users.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
/*
+------------------------------------------------
| TBDev.net BitTorrent Tracker PHP
| =============================================
| by CoLdFuSiOn
| (c) 2003 - 2011 TBDev.Net
| http://www.tbdev.net
| =============================================
| svn: http://sourceforge.net/projects/tbdevnet/
| Licence Info: GPL
+------------------------------------------------
| $Date$
| $Revision$
| $Author$
| $URL$
+------------------------------------------------
*/
require_once "include/bittorrent.php";
require_once "include/user_functions.php";
dbconn();
loggedinorreturn();
$lang = array_merge( load_language('global'), load_language('users') );
$search = isset($_GET['search']) ? strip_tags(trim($_GET['search'])) : '';
$class = isset($_GET['class']) ? $_GET['class'] : '-';
$letter = '';
$q = '';
if ($class == '-' || !ctype_digit($class))
$class = '';
if ($search != '' || $class)
{
$query = "username LIKE " . sqlesc("%$search%") . " AND status='confirmed'";
if ($search)
$q = "search=" . htmlsafechars($search);
}
else
{
$letter = isset($_GET['letter']) ? trim((string)$_GET["letter"]) : '';
if (strlen($letter) > 1)
die;
if ($letter == "" || strpos("abcdefghijklmnopqrstuvwxyz0123456789", $letter) === false)
$letter = "";
$query = "username LIKE '$letter%' AND status='confirmed'";
$q = "letter=$letter";
}
if (ctype_digit($class))
{
$query .= " AND class=$class";
$q .= ($q ? "&" : "") . "class=$class";
}
$HTMLOUT = '';
$HTMLOUT .= "
<div class='cblock'>
<div class='cblock-header'>Users</div>
<div class='cblock-content' style='text-align:center;'>";
$HTMLOUT .= " <form method='get' action='users.php?'>\n";
$HTMLOUT .= " {$lang['form_search']} <input type='text' size='30' name='search' />\n";
$HTMLOUT .= " <select name='class'>\n";
$HTMLOUT .= " <option value='-'>(any class)</option>\n";
for ($i = 0;;++$i)
{
if ($c = get_user_class_name($i))
$HTMLOUT .= " <option value='$i'" . (ctype_digit($class) && $class == $i ? " selected='selected'" : "") . ">$c</option>\n";
else
break;
}
$HTMLOUT .= " </select>\n";
$HTMLOUT .= " <input type='submit' value='{$lang['form_btn']}' class='btn' />\n";
$HTMLOUT .= " </form>\n";
$HTMLOUT .= " <br />\n";
$aa = range('0','9');
$bb = range('a','z');
$cc = array_merge($aa,$bb);
unset($aa,$bb);
$HTMLOUT .= " <div style='text-align:center;'>";
$count = 0;
foreach($cc as $L)
{
$HTMLOUT .= ($count == 10) ? "<br /><br />" : '';
if(!strcmp($L,$letter))
$HTMLOUT .= "<span class='btn' style='background:orange;'>".strtoupper($L)."</span>\n";
else
$HTMLOUT .= "<a href='users.php?letter=$L'><span class='btn'>".strtoupper($L)."</span></a>\n";
$count++;
}
$HTMLOUT .= "</div>";
$HTMLOUT .= "<br />\n";
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$perpage = 25;
$browsemenu = '';
$pagemenu = '';
$res = mysql_query("SELECT COUNT(*) FROM users WHERE $query") or sqlerr(__FILE__,__LINE__);
$arr = mysql_fetch_row($res);
if($arr[0] > $perpage) {
$pages = floor($arr[0] / $perpage);
if ($pages * $perpage < $arr[0])
++$pages;
if ($page < 1)
$page = 1;
else
if ($page > $pages)
$page = $pages;
for ($i = 1; $i <= $pages; ++$i)
{
$PageNo = $i+1;
if($PageNo < ($page - 2))
continue;
if ($i == $page)
$pagemenu .= " <span class='btn' style='background:orange;'>$i</span>\n";
else
$pagemenu .= " <a href='users.php?$q&page=$i'><span class='btn'>$i</span></a>\n";
if($PageNo > ($page + 3)) break;
}
if ($page == 1)
$browsemenu .= "<span class='btn' style='background:orange;'>‹</span>$pagemenu";
else
$browsemenu .= "<a href='users.php?$q&page=1' title='{$lang['pager_first']}(1)'><span class='btn'>«</span></a> <a href='users.php?$q&page=" . ($page - 1) . "'><span class='btn'>‹</span></a>$pagemenu";
//$browsemenu .= " ";
if ($page == $pages)
$browsemenu .= "<span class='btn' style='background:orange;'>›</span>";
else
$browsemenu .= "<a href='users.php?$q&page=" . ($page + 1) . "'><span class='btn'>›</span></a> <a href='users.php?$q&page=" . $pages . "' title='{$lang['pager_last']}($pages)'><span class='btn'>»</span></a>";
}
$HTMLOUT .= ($arr[0] > $perpage) ? "<p>$browsemenu<br /><br /></p>" : '<br /><br />';
$offset = ($page * $perpage) - $perpage;
if($arr[0] > 0) {
$res = mysql_query("SELECT users.*, countries.name, countries.flagpic FROM users FORCE INDEX ( username ) LEFT JOIN countries ON country = countries.id WHERE $query ORDER BY username LIMIT $offset,$perpage") or sqlerr(__FILE__,__LINE__);
//$num = mysql_num_rows($res);
$HTMLOUT .= "<table border='1' cellspacing='0' cellpadding='5'>\n";
$HTMLOUT .= "<tr><td class='colhead' align='left'>User name</td><td class='colhead'>{$lang['users_regd']}</td><td class='colhead'>{$lang['users_la']}</td><td class='colhead' align='left'>{$lang['users_class']}</td><td class='colhead'>{$lang['users_country']}</td></tr>\n";
while($row = mysql_fetch_assoc($res))
{
$country = ($row['name'] != NULL) ? "<td style='padding: 0px' align='center'><img src='{$TBDEV['pic_base_url']}flag/{$row['flagpic']}' alt='". htmlsafechars($row['name']) ."' /></td>" : "<td align='center'>---</td>";
/*
if ($row['added'] == '0000-00-00 00:00:00')
$row['added'] = '-';
if ($row['last_access'] == '0000-00-00 00:00:00')
$row['last_access'] = '-';
*/
$HTMLOUT .= "<tr><td align='left'><a href='userdetails.php?id={$row['id']}'><b>{$row['username']}</b></a>" .
($row["donor"] > 0 ? "<img src='{$TBDEV['pic_base_url']}star.gif' border='0' alt='Donor' />" : "")."</td>" .
"<td>".get_date( $row['added'],'' )."</td><td>".get_date( $row['last_access'], '')."</td>".
"<td align='left'>" . get_user_class_name($row["class"]) . "</td>$country</tr>\n";
}
$HTMLOUT .= "</table>\n";
}
$HTMLOUT .= ($arr[0] > $perpage) ? "<br /><p>$browsemenu</p>" : '<br /><br />';
$HTMLOUT .= " </div>
</div>\n";
print stdhead($lang['head_users']) . $HTMLOUT . stdfoot();
die;
?>