made last changes in codebase befor finishing for presentation

This commit is contained in:
Patryk Hegenberg 2023-01-24 20:30:19 +01:00
parent 39d0d0306b
commit 99535db4ee
3 changed files with 35 additions and 3 deletions

View file

@ -58,7 +58,8 @@ class Database {
if (password_verify($params[1], $stmt["password"])) {
session_start();
$_SESSION["username"] = $stmt['username'];
$_SESSION["username"] = $stmt['username'];
$_SESSION["isAdmin"] = $stmt['isAdmin'];
header("Location: /profile");
} else {
@ -69,6 +70,10 @@ class Database {
}
}
public function getUsers($params = []) {
return $this->query("SELECT username, email, level FROM user WHERE username != :user", ['user' => $params])->get();
}
public function register($params = []) {
$stmt = $this->query("SELECT * FROM user WHERE username = :user", ['user' => $params['Username']])->get();
$count = sizeof($stmt);

View file

@ -10,6 +10,6 @@ if(!isset($_SESSION["username"])){
header("Location: /");
exit;
}
$users = $db->getUsers("admin");
$stats = $db->getPlayerStats($_SESSION['username']);
require "views/profile.view.php";

View file

@ -1,6 +1,6 @@
<?php require('partials/head.php') ?>
<?php require('partials/nav.php') ?>
<?php if (!($_SESSION['isAdmin'] == 1)) : ?>
<div class="profile">
<div style="padding: 20px; border-radius: 5px; box-shadow: 0 0 4px #433e4c; margin-top: 20px; margin-bottom: 20px; background-color: #2e1e26;">
<div class="container3">
@ -46,4 +46,31 @@
</div>
</div>
</div>
<?php else : ?>
<div class="profile">
<div style="padding: 20px; border-radius: 5px; box-shadow: 0 0 4px #433e4c; margin-top: 20px; margin-bottom: 20px; background-color: #2e1e26;">
<div class="container3">
<table style="display: flex; justify-content: center; align-items: center;">
<tr class="has-top-divider">
<th>Username</th>
<th>Email-Adresse</th>
<th>Level</th>
</tr>
<?php foreach($users as $user) {
echo '<tr class="has-top-divider" >' ;
echo "<th>". $user['username'] ."</th>";
echo "<th>". $user['email'] ."</th>";
echo "<th>". $user['level'] ."</th>";
echo "</tr>";
}
?>
</tr>
</table>
</div>
</div>
</div>
<?php endif; ?>
<?php require('partials/footer.php') ?>