forked from sicalpath/tjupt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
users.php
133 lines (107 loc) · 4.32 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
<?php
require "include/bittorrent.php";
dbconn();
require_once(get_langfile_path());
loggedinorreturn();
parked();
global $viewuserlist_class;
if (get_user_class() < $viewuserlist_class)
permissiondenied();
$search = trim($_GET['search']);
$class = $_GET['class'];
$country = 0 + $_GET['country'];
$letter = trim($_GET["letter"]);
if (strlen($letter) > 1)
die;
if (!is_valid_user_class($class))
$class = '-';
if (($search != '' || $class != '-') && $letter == '') {
$query = "username LIKE " . sqlesc("%$search%") . " AND status='confirmed'";
if ($search)
$q = "search=" . rawurlencode($search);
} elseif ($letter != '' && strpos("0abcdefghijklmnopqrstuvwxyz", $letter) == true) {
$query = "username LIKE '$letter%' AND status='confirmed'";
$q = "letter=$letter";
} else {
$query = "status='confirmed'";
}
if ($class != '-') {
$query .= " AND class=$class";
$q .= ($q ? "&" : "") . "class=$class";
}
if ($country > 0) {
$query .= " AND country=$country";
$q .= ($q ? "&" : "") . "country=$country";
}
stdhead($lang_users['head_users']);
print($lang_users['text_users']);
print("<form method=get action=?>\n");
print($lang_users['text_search'] . " <input type=text style=\"width:100px\" name=search value=$search> \n");
print("<select name=class>\n");
print("<option value='-'>" . $lang_users['select_any_class'] . "</option>\n");
for ($i = 0; ; ++$i) {
if ($c = get_user_class_name($i, false, true, true))
print("<option value=$i" . ($class != '-' && $class == $i ? " selected" : "") . ">$c</option>\n");
else
break;
}
print("</select>\n");
$countries = "<option value=0>" . $lang_users['select_any_country'] . "</option>\n";
$ct_r = sql_query("SELECT id,name FROM countries ORDER BY name") or die;
while ($ct_a = mysql_fetch_array($ct_r))
$countries .= "<option value=" . htmlspecialchars($ct_a['id']) . ">" . htmlspecialchars($ct_a['name']) . "</option>\n";
print("<select name=country>" . $countries . "</select>");
print("<input type=submit value=\"" . $lang_users['submit_okay'] . "\">\n");
print("</form>\n");
print("<p>\n");
for ($i = 97; $i < 123; ++$i) {
$l = chr($i);
$L = chr($i - 32);
//stderr("",$class);
if ($l == $letter)
print("<font class=gray><b>$L</b></font>\n");
else {
if ($class == '-')
print("<a href=?letter=$l" . ($country > 0 ? "&country=" . $country : "") . "><b>$L</b></a>\n");
else {
print("<a href=?letter=$l&class=$class" . ($country > 0 ? "&country=" . $country : "") . "><b>$L</b></a>\n");
}
}
}
print("</p>\n");
$perpage = 50;
$res = sql_query("SELECT COUNT(*) FROM users WHERE $query") or sqlerr();
$arr = mysql_fetch_row($res);
$count = $arr[0];
list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, "users.php?" . $q . ($q ? "&" : ""));
print($pagertop);
$country_sql = "concat('<img src=\"pic/flag/', countries.flagpic, '\" alt=\"', countries.name ,'\">')";
$sql = sprintf('SELECT
users.id as id,
users.class as class,
IF (
users.country >0, %s, \'---\'
) as country,
IF (
users.added = "0000-00-00 00:00:00", "-", users.added
) as added,
IF (
users.last_access = "0000-00-00 00:00:00", "-", users.last_access
) as last_access
FROM users
LEFT JOIN countries ON users.country = countries.id
WHERE %s
ORDER BY username %s',
$country_sql, $query, $limit);
$res = sql_query($sql) or sqlerr();
$num = mysql_num_rows($res);
print("<table border=1 cellspacing=0 cellpadding=5>\n");
print("<tr><td class=colhead align=left>" . $lang_users['col_user_name'] . "</td><td class=colhead>" . $lang_users['col_registered'] . "</td><td class=colhead>" . $lang_users['col_last_access'] . "</td><td class=colhead align=left>" . $lang_users['col_class'] . "</td><td class=colhead>" . $lang_users['col_country'] . "</td></tr>\n");
for ($i = 0; $i < $num; ++$i) {
$arr = mysql_fetch_assoc($res);
print("<tr><td align=left>" . get_username($arr['id']) . "</td><td>" . gettime($arr['added'], true, false) . "</td><td>" . gettime($arr['last_access'], true, false) . "</td><td align=left>" . get_user_class_name($arr['class'], false, true, true) . "</td><td align=center>" . $arr['country'] . "</td></tr>");
}
print("</table>");
print($pagerbottom);
stdfoot();
die;