-
Notifications
You must be signed in to change notification settings - Fork 2
/
adleader.php
105 lines (99 loc) · 2.01 KB
/
adleader.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
<html>
<head>
<title>Leaderboard</title>
<style>
tr{
color:ivory;
text-align:center;
}
th {
color:yellow;
}
#tab{
width:100%;
text-align:center;
background-color:grey;
}
#paging {
text-align:center;
background-color:#333300;
}
a.link {
padding:2px;
border:1px solid white;
color:#ff99ff;
}
</style>
</head>
<?php
session_start();
if ((!isset($_SESSION["fbuid"]))||(($_SESSION["role"])!=10))
{$output = "<script>
window.location='index.php';
</script>";
echo $output; }
require_once("database.php");
global $result;
if ($_SESSION["role"]!=10)
{
Header("Location:index.php");
}
require_once("adtheme.php");
$sql = "SELECT name,level,college FROM users ORDER BY name";
$ref = $result->query($sql);
$count=mysqli_num_rows($ref);
$per=20;
$pagecount=ceil($count/$per);
$page=$_GET["page"];
if ($page=="")
{
$page=1;
}
if ($page==1)
{
$offset=0;
}
else {
$offset=($page-1)*$per;
}
$sql = "SELECT * FROM users WHERE role!=10 ORDER BY name LIMIT $offset,$per";
$ref = $result->query($sql);
$rank=$offset+1;
echo"
<table id=\"tab\">
<tr>
<th>Rank</th>
<th>Name</th>
<th>College</th>
<th>Level</th>
</tr>";
while($row = mysqli_fetch_assoc($ref))
{
echo "<tr class=\"row\"><td>".$rank."</td><td><a href=\"edituser.php?id=".$row["fbuid"]."\">".$row["name"]."</a></td><td>".$row["college"]."</td><td>".$row["level"]."</td></tr>";
$rank++;
}
?></table>
<div id="paging">
<?php
if($page>1)
{
?><a class="link" href="adleader.php?page=<?php echo $page-1?>"><?php echo "previous " ?></a> <?php
}
$adjacents=2;
$start = ($page < $adjacents ? 1 : $page - $adjacents);
$end = ($page > $pagecount - $adjacents ? $pagecount : $page + $adjacents);
if($start==0)
{
$start=1;
}
for ($i=$start;$i<=$end;$i++)
{
?><a class="link" href="adleader.php?page=<?php echo $i?>"><?php echo $i." " ?></a> <?php
}
if($pagecount>$page)
{
?><a class="link" href="adleader.php?page=<?php echo $page+1?>"><?php echo "Next " ?></a> <?php
}
?>
</div>
</html>