-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
70 lines (59 loc) · 1.8 KB
/
Copy pathadmin.php
File metadata and controls
70 lines (59 loc) · 1.8 KB
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
<?php
require_once('connect.php');
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) || ($_SERVER['PHP_AUTH_USER'] != ADM_USER)
|| ($_SERVER['PHP_AUTH_PW'] != ADM_PASSWORD)){
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate:Basic realm = "Gravitational"');
exit('<h2>Gravitational</h2>You dont have access to this page');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>DB Admin</title>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,500,700&display=swap" rel="stylesheet">
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
</head>
<body>
<?php
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$query = "SELECT * FROM user_score";
$rank = mysqli_query($dbc, $query);
// DELETE SCORE FROM DB
if(isset($_POST['remove'])){
$id = $_POST['user_id'];
$query = "DELETE FROM user_score WHERE user_id = $id";
$delete = mysqli_query($dbc, $query);
mysqli_close($dbc);
}
echo "<h2>Gravitational Database</h2>";
echo "<div id='admDiv'>
<table id='admTabble' border=1 cellpadding=10>
<tr>
<th>ID</th>
<th>Username</th>
<th>Score</th>
<th>IP</th>
<th>Remove</th>
</tr>";
while($row = mysqli_fetch_array($rank)){
echo "<tr>";
echo "<td>" . $row['user_id'] . "</td>";
echo "<td>" . $row['username'] . "</td>";
echo "<td>" . $row['score'] . "</td>";
echo "<td>" . $row['ip'] . "</td>";
?>
<td><form id='remove' method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="user_id" value="<?php echo $row['user_id'];?>">
<input type="submit" value='Remove' name="remove" />
</form>
</td>
<?php
echo "</tr>";
}
echo "</table>
</div>";
?>
</body>
</html>