forked from TheGamesDB/TheGamesDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtab_userlist.php
148 lines (133 loc) · 4.96 KB
/
tab_userlist.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
<?php
if ($adminuserlevel == 'ADMINISTRATOR') {
if ($function == 'Search') {
$title = 'Search : ' . $string;
}
//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
$pagenum = 1;
}
//Here we count the number of results
//Edit $data to be your query
if ($function == 'UserSearch') {
$query = "SELECT * FROM users WHERE username LIKE '%$string%' AND userlevel = 'USER' ORDER BY username";
}
elseif ($function == 'admin') {
if ($_SESSION['userlevel'] == 'SUPERADMIN') {
$query = "SELECT * FROM users WHERE userlevel='ADMINISTRATOR' OR userlevel='SUPERADMIN' ORDER BY username";
$title = 'Administrators';
}
}
else {
$query = "SELECT * FROM users WHERE userlevel = 'USER'";
}
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
$rows = mysql_num_rows($result);
if ($rows != 0 ) {
//This is the number of results displayed per page
$page_rows = 30;
//This tells us the page number of our last page
$last = ceil($rows/$page_rows);
//this makes sure the page number isn't below one, or more than our maximum pages
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
//This sets range that we will display in our query
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
}
?>
<div id="gameHead">
<div style="text-align: center;">
<h1 class="arcade">Site Reports & Statistics:</h1>
<h2 class="arcade" style="color: #FF4F00;">User List | <?=$title?></h2>
<table width="100%" border="0" cellspacing="0" cellpadding="2" align="center" id="listtable">
<tr>
<td class="head">User ID</td>
<td class="head">UserName</td>
<td class="head">Email</td>
<td class="head">Language</td>
<td class="head">Banner Limit</td>
</tr>
<?php
if ($rows == 0 ) {
print "<tr><td> </td><td>No Users With That Name</td><td colspan=3> </td></tr>\n";
}
else {
if ($function == 'UserSearch') {
$query = "SELECT * FROM users WHERE username LIKE '%$string%' AND userlevel = 'USER' ORDER BY username $max ";
}
elseif ($function == 'admin') {
if ($_SESSION['userlevel'] == 'SUPERADMIN') {
$query = "SELECT * FROM users WHERE userlevel='ADMINISTRATOR' OR userlevel='SUPERADMIN' ORDER BY username $max ";
$title = 'Administrators';
}
}
else {
$query = "SELECT * FROM users WHERE userlevel = 'USER' $max ";
}
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while ($userlist = mysql_fetch_object($result)) {
if ($class == 'odd') { $class = 'even'; } else { $class = 'odd'; }
$query2 = "SELECT * FROM languages WHERE id=$userlist->languageid";
$result2 = mysql_query($query2) or die('Query failed: ' . mysql_error());
while ($languages = mysql_fetch_object($result2)) {
$currentlang = $languages->name;
}
print "<tr><td class=\"$class\">$userlist->id</td><td class=\"$class\"><a href=\"/?tab=userinfoadmin&id=$userlist->id\">$userlist->username</a></td><td class=\"$class\"><a href='mailto:$userlist->emailaddress'>$userlist->emailaddress</a></td><td class=\"$class\">$currentlang</td><td class=\"$class\">$userlist->bannerlimit</td></tr>\n";
$currentlang = "";
}
}
?>
</table>
</div>
<?php
//echo "<div class=\"section\">";
echo '<table width="100%" border="0" cellspacing="0" cellpadding="2" align="center">';
echo '<tr><td width="33%">';
// This shows the user what page they are on, and the total number of pages
echo " -- Page $pagenum of $last -- </td>"; ?>
<td style="background-image: url(/images/search.png); background-repeat:no-repeat;">
<form method="get" id="searchbox" target="_top">
<input type="text" name="string" id="usersearch" value="Username Search" onFocus="this.value=''" style="margin-left:25px;">
<input type="hidden" name="tab" value="userlist">
<input type="hidden" name="function" value="UserSearch">
</form>
</td>
<?php echo "<td align='right'>";
// First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.
if ($pagenum == 1)
{}
else {
echo " <a href='$baseurl/?tab=userlist&pagenum=1'> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href='$baseurl/?tab=userlist&pagenum=$previous'> <-Previous</a> ";
}
//just a spacer
echo " ---- ";
//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum == $last)
{}
else {
$next = $pagenum+1;
echo " <a href='$baseurl/?tab=userlist&pagenum=$next'>Next -></a> ";
echo " ";
echo " <a href='$baseurl/?tab=userlist&pagenum=$last'>Last ->></a> ";
}
echo "</td></tr></table>";
} //
else {
?>
<div class="section">
<h1>Administrators Only</h1>
</div>
<?php
}
?>
</div>