You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.3 KiB
118 lines
3.3 KiB
<?php
|
|
session_start();
|
|
include("init.php");
|
|
$ptitle = "Návštěvní kniha - ADMIN";
|
|
|
|
if(isset($_SESSION["role"])){
|
|
if($_SESSION["role"] != 1){
|
|
header("Location: /?error=2");
|
|
}
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Navštěvní kniha</title>
|
|
<link rel="stylesheet" href="admin.css">
|
|
<link rel="stylesheet" href="css/bootstrap.css">
|
|
</head>
|
|
<body class="d-flex flex-column min-vh-100">
|
|
<div class="container">
|
|
|
|
<?php
|
|
include "menu.php";
|
|
?>
|
|
<!-- PHP výpis pro příspěvky -->
|
|
<h2>Příspěvky</h2>
|
|
|
|
<table class="table">
|
|
<tr>
|
|
<th>id</th>
|
|
<th>title</th>
|
|
<th>msg</th>
|
|
<th>Autor</th>
|
|
<th>čas vytvoření</th>
|
|
<th>delete</th>
|
|
<th>update</th>
|
|
</tr>
|
|
|
|
<?php
|
|
$sql = "SELECT nk_prispevky.id, nk_users.username, nk_prispevky.title, nk_prispevky.msg, nk_prispevky.created, nk_users.role
|
|
FROM nk_prispevky
|
|
INNER JOIN nk_users ON nk_prispevky.id_nk_users = nk_users.id
|
|
ORDER BY nk_prispevky.id DESC";
|
|
$result = mysqli_query($conn,$sql);
|
|
|
|
if (mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)){
|
|
if ($row["role"] == "1"){
|
|
echo "<tr class=\"bg-primary-subtle\">";//admin
|
|
}
|
|
if ($row["role"] == "3"){
|
|
echo "<tr class=\"bg-success-subtle\">";//moderator
|
|
}
|
|
if ($row["role"] == "5"){
|
|
echo "<tr class=\"bg-warning-subtle\">";//ucet
|
|
}
|
|
|
|
echo "<td>".$row["id"]."</td>";
|
|
echo "<td><strong>".$row["title"]."</strong></td>";
|
|
echo "<td>".$row["msg"]."</td>";
|
|
echo "<td><i>".$row["username"]."</i></td>";
|
|
//echo "<td>".$row["role"]."</td>"; //id=5">
|
|
echo "<td>".$row["created"]."</td>";
|
|
echo "<td> <a class=\"btn btn-danger\" href=\"action_delete.php?id=".$row["id"]."\">Delete</a></td>";
|
|
echo "<td> <a class=\"btn btn-warning\" href=\"update_prispevky.php?id=".$row["id"]."\">UPDATE</a></td>";
|
|
echo "</tr>";
|
|
}
|
|
}
|
|
?>
|
|
</table>
|
|
|
|
<h2>Users</h2>
|
|
<table class="table">
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Username</th>
|
|
<th>role</th>
|
|
</tr>
|
|
<?php
|
|
|
|
$sql = "SELECT * FROM nk_users";
|
|
$result = mysqli_query($conn,$sql);
|
|
|
|
if (mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)){
|
|
//echo "<p>id:".$row["id"]."; user:".$row["username"]."</p>";
|
|
|
|
if ($row["role"] == "1"){
|
|
echo "<tr class=\"bg-primary-subtle\">";//admin
|
|
}
|
|
if ($row["role"] == "3"){
|
|
echo "<tr class=\"bg-success-subtle\">";//moderator
|
|
}
|
|
if ($row["role"] == "5"){
|
|
echo "<tr class=\"bg-warning-subtle\">";//ucet
|
|
}
|
|
echo "<td>".$row["id"]."</td>";
|
|
echo "<td>".$row["username"]."</td>";
|
|
echo "<td>".$row["role"]."</td>";
|
|
echo "</tr>";
|
|
}
|
|
}
|
|
|
|
?>
|
|
</table>
|
|
</div>
|
|
|
|
<?php
|
|
include "footer.php";
|
|
?>
|
|
<script src="js/bootstrap.bundle.js"></script>
|
|
|
|
</body>
|
|
</html>
|