Refactored file system

Changed the file system to a more ordered state and updated links in
files accordingly. Also the reffering to files is now uniform
This commit is contained in:
sraffauf
2026-01-21 17:58:15 +01:00
parent a3b261e9ae
commit 77fd4e836b
15 changed files with 99 additions and 52 deletions

View File

@@ -6,7 +6,7 @@
<title>CSG Ticketsystem</title> <title>CSG Ticketsystem</title>
<link rel="stylesheet" href="./css/style.css"/> <link rel="stylesheet" href="./css/style.css"/>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="header-with-image"> <div class="header-with-image">
<h2>CSG Ticketsystem</h2> <h2>CSG Ticketsystem</h2>
@@ -17,4 +17,5 @@
<button type="submit">Login</button> <button type="submit">Login</button>
</form> </form>
</div> </div>
</body> </body>
</html>

View File

@@ -7,14 +7,14 @@ document.getElementById("loginForm").addEventListener("submit", async function (
formData.append("username", username); formData.append("username", username);
formData.append("password", password); formData.append("password", password);
const response = await fetch("backend/login.php", { const response = await fetch("../php/login.php", {
method: "POST", method: "POST",
body: formData body: formData
}); });
const result = await response.json(); const result = await response.json();
if (result.success) { if (result.success) {
window.location.href = "admin.php"; window.location.href = "../php/admin.php";
} else { } else {
document.getElementById("errorMsg").innerText = "Login fehlgeschlagen!"; document.getElementById("errorMsg").innerText = "Login fehlgeschlagen!";
} }

View File

@@ -3,12 +3,12 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>Admin Dashboard</title> <title>Admin Dashboard</title>
<link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="../css/style.css" />
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<h2>Admin Dashboard</h2> <h2>Admin Dashboard</h2>
<a href="backend/logout.php">Logout</a> <a href="../php/logout.php">Logout</a>
<div id="ticket-container">Tickets werden geladen...</div> <div id="ticket-container">Tickets werden geladen...</div>
</div> </div>
<script> <script>
@@ -25,7 +25,7 @@
async function ladeTickets() { async function ladeTickets() {
try { try {
const response = await fetch('backend/tickets.json'); const response = await fetch('../data/tickets.json');
if (!response.ok) throw new Error("Fehler beim Laden der Datei"); if (!response.ok) throw new Error("Fehler beim Laden der Datei");
const tickets = await response.json(); const tickets = await response.json();

View File

@@ -10,7 +10,7 @@
<div class="container"> <div class="container">
<div class="header-with-image"> <div class="header-with-image">
<h2>Admin Login</h2> <h2>Admin Login</h2>
<img src="img/csg.png" width="100" /> <img src="./img/csg.png" width="100" />
</div> </div>
<form id="loginForm"> <form id="loginForm">
<label for="username">Benutzername</label> <label for="username">Benutzername</label>

46
pages/ticket_submit.html Normal file
View File

@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Schul-IT Ticketsystem</title>
<link rel="stylesheet" href="../css/style.css" />
</head>
<body>
<div class="container">
<div class="header-with-image">
<h2>CSG IT Ticket System</h2>
<img src="../img/csg.png" width="100" />
</div>
<form action="../php/save_ticket.php" method="post">
<label for="title">Betreff</label>
<input type="text" id="title" name="title" required />
<label for="description">Problem-Beschreibung</label>
<textarea id="description" name="description" rows="5" required></textarea>
<label for="room">Raum</label>
<input type="number" id="room" name="room" required />
<label for="name">Name, Vorname</label>
<input type="text" id="name" name="name" required>
<label for="category">Kategorie</label>
<select id="category" name="category">
<option value="Whiteboard">Whiteboard</option>
<option value="Internet">Internet</option>
<option value="Schülerportal">Schülerportal</option>
<option value="Ipad(Koffer)">Ipad(Koffer)</option>
<option value="Apple TV">Apple TV</option>
<option value="DocuCam">Docu Kamera</option>
<option value="Sonstiges">Sonstiges</option>
</select>
<button type="submit">Ticket absenden</button>
<a href="./login.html" class="login-btn">Admin Login</a>
</form>
</div>
</body>
</html>

View File

@@ -1,7 +1,7 @@
<?php <?php
session_start(); session_start();
if (!isset($_SESSION["loggedIn"])) { if (!isset($_SESSION["loggedIn"])) {
header("Location: login.html"); header("Location: ../pages/login.html");
exit; exit;
} }
?> ?>
@@ -10,7 +10,7 @@ if (!isset($_SESSION["loggedIn"])) {
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Admin Dashboard</title> <title>Admin Dashboard</title>
<link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="../css/style.css">
</head> </head>
<body> <body>
<div class="container-dashboard"> <div class="container-dashboard">
@@ -19,7 +19,7 @@ if (!isset($_SESSION["loggedIn"])) {
<img src="img/csg.png" width="100" /> <img src="img/csg.png" width="100" />
</div> </div>
<a href="backend/logout.php" class="logout-btn">Logout</a> <a href="../php/logout.php" class="logout-btn">Logout</a>
<div class="dashboard"> <div class="dashboard">
<!-- Linke Ticket-Übersicht --> <!-- Linke Ticket-Übersicht -->
@@ -40,7 +40,7 @@ let tickets = [];
async function ladeTickets() { async function ladeTickets() {
try { try {
const response = await fetch('backend/tickets.json?ts=' + Date.now(), {cache:"no-store"}); const response = await fetch('../data/tickets.json?ts=' + Date.now(), {cache:"no-store"});
tickets = await response.json(); tickets = await response.json();
const ul = document.getElementById('tickets-ul'); const ul = document.getElementById('tickets-ul');
@@ -91,7 +91,7 @@ function showTicketDetails(index) {
const newStatus = document.getElementById('status-select').value; const newStatus = document.getElementById('status-select').value;
ticket.status = newStatus; ticket.status = newStatus;
const res = await fetch('backend/update_ticket.php', { const res = await fetch('./update_ticket.php', {
method:'POST', method:'POST',
headers:{'Content-Type':'application/json'}, headers:{'Content-Type':'application/json'},
body:JSON.stringify({index, ticket}) body:JSON.stringify({index, ticket})
@@ -108,7 +108,7 @@ function showTicketDetails(index) {
document.getElementById('delete-ticket').addEventListener('click', async () => { document.getElementById('delete-ticket').addEventListener('click', async () => {
if(!confirm("Ticket wirklich löschen?")) return; if(!confirm("Ticket wirklich löschen?")) return;
const res = await fetch('backend/delete_ticket.php', { const res = await fetch('./backend/delete_ticket.php', {
method:'POST', method:'POST',
headers:{'Content-Type':'application/json'}, headers:{'Content-Type':'application/json'},
body:JSON.stringify({index}) body:JSON.stringify({index})

View File

@@ -1,7 +1,7 @@
<?php <?php
session_start(); session_start();
if(!isset($_SESSION['user_id'])){ if(!isset($_SESSION['user_id'])){
header("Location: login.html"); header("Location: ../pages/login.html");
exit; exit;
} }
echo "Willkommen im Dashboard, ".$_SESSION['role']."!"; echo "Willkommen im Dashboard, ".$_SESSION['role']."!";
@@ -82,7 +82,7 @@ echo "Willkommen im Dashboard, ".$_SESSION['role']."!";
<a href="#" data-section="tickets">Tickets</a> <a href="#" data-section="tickets">Tickets</a>
<a href="#" data-section="users">Benutzer</a> <a href="#" data-section="users">Benutzer</a>
<a href="#" data-section="settings">Persönliche Einstellungen</a> <a href="#" data-section="settings">Persönliche Einstellungen</a>
<a href="backend/logout.php">Logout</a> <a href="./logout.php">Logout</a>
</div> </div>
<div class="content" id="main-content"> <div class="content" id="main-content">
@@ -90,7 +90,7 @@ echo "Willkommen im Dashboard, ".$_SESSION['role']."!";
<div class="welcome-box"> <div class="welcome-box">
<h2>Admin Dashboard</h2> <h2>Admin Dashboard</h2>
<p>Angemeldet als: <?= htmlspecialchars($_SESSION["username"]) ?></p> <p>Angemeldet als: <?= htmlspecialchars($_SESSION["username"]) ?></p>
<a href="backend/logout.php">Logout</a> <a href="./logout.php">Logout</a>
</div> </div>
</div> </div>
@@ -114,10 +114,10 @@ echo "Willkommen im Dashboard, ".$_SESSION['role']."!";
<h2>Willkommen, ${username}!</h2> <h2>Willkommen, ${username}!</h2>
<p>Hier siehst du eine Übersicht und kannst über die Buttons neue Bereiche öffnen:</p> <p>Hier siehst du eine Übersicht und kannst über die Buttons neue Bereiche öffnen:</p>
<div class="button-panel"> <div class="button-panel">
<button onclick="window.location.href='users.php'">Benutzer erstellen</button> <button onclick="window.location.href='./users.php'">Benutzer erstellen</button>
<button onclick="window.location.href='admin.php'">Tickets verwalten</button> <button onclick="window.location.href='./admin.php'">Tickets verwalten</button>
<button onclick="window.location.href='deleted_tickets.php'">Gelöschte Tickets</button> <button onclick="window.location.href='./deleted_tickets.php'">Gelöschte Tickets</button>
<button onclick="window.location.href='settings.php'">Persönliche Einstellungen</button> <button onclick="window.location.href='./settings.php'">Persönliche Einstellungen</button>
</div> </div>
</div>`; </div>`;
break; break;

View File

@@ -13,7 +13,7 @@ if($index === null){
exit; exit;
} }
$ticketsPath = __DIR__ . '/tickets.json'; $ticketsPath = __DIR__ . '../data/tickets.json';
$tickets = []; $tickets = [];
if(file_exists($ticketsPath)){ if(file_exists($ticketsPath)){

View File

@@ -4,7 +4,7 @@ session_start();
$username = $_POST['username'] ?? ''; $username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? ''; $password = $_POST['password'] ?? '';
$usersFile = __DIR__ . "/users.json"; $usersFile = __DIR__ . "../data/users.json";
if (!file_exists($usersFile)) { if (!file_exists($usersFile)) {
die("Benutzerdaten fehlen!"); die("Benutzerdaten fehlen!");
} }
@@ -24,9 +24,9 @@ if (is_array($users)) {
if ($loginOk) { if ($loginOk) {
$_SESSION['loggedIn'] = true; $_SESSION['loggedIn'] = true;
$_SESSION['username'] = $username; $_SESSION['username'] = $username;
header("Location: ../admin.php"); header("Location: ./admin.php");
exit; exit;
} else { } else {
header("Location: ../login.html?error=1"); header("Location: ../pages/login.html?error=1");
exit; exit;
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
session_start(); session_start();
session_destroy(); session_destroy();
header("Location: ../login.html"); header("Location: ../pages/login.html");
exit; exit;
?> ?>

View File

@@ -22,7 +22,7 @@ $newTicket = [
'date' => $date 'date' => $date
]; ];
$ticketsPath = __DIR__ . '/tickets.json'; $ticketsPath = __DIR__ . '../data/tickets.json';
$tickets = []; $tickets = [];
if (file_exists($ticketsPath)) { if (file_exists($ticketsPath)) {
@@ -36,5 +36,5 @@ $tickets[] = $newTicket;
file_put_contents($ticketsPath, json_encode($tickets, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), LOCK_EX); file_put_contents($ticketsPath, json_encode($tickets, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), LOCK_EX);
// Redirect zurück ins Dashboard oder zur Hauptseite // Redirect zurück ins Dashboard oder zur Hauptseite
header('Location: ../ticket_submit.html?success=1'); header('Location: ../pages/ticket_submit.html?success=1');
exit; exit;

View File

@@ -14,7 +14,7 @@ if($index === null || $ticket === null){
exit; exit;
} }
$ticketsPath = __DIR__ . '/tickets.json'; $ticketsPath = __DIR__ . '../data/tickets.json';
$tickets = []; $tickets = [];
if(file_exists($ticketsPath)){ if(file_exists($ticketsPath)){

View File

@@ -4,16 +4,16 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Schul-IT Ticketsystem</title> <title>Schul-IT Ticketsystem</title>
<link rel="stylesheet" href="./css/style.css" /> <link rel="stylesheet" href="../css/style.css" />
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="header-with-image"> <div class="header-with-image">
<h2>CSG IT Ticket System</h2> <h2>CSG IT Ticket System</h2>
<img src="img/csg.png" width="100" /> <img src="../img/csg.png" width="100" />
</div> </div>
<form action="backend/save_ticket.php" method="post"> <form action="../php/save_ticket.php" method="post">
<label for="title">Betreff</label> <label for="title">Betreff</label>
<input type="text" id="title" name="title" required /> <input type="text" id="title" name="title" required />
@@ -38,7 +38,7 @@
</select> </select>
<button type="submit">Ticket absenden</button> <button type="submit">Ticket absenden</button>
<a href="login.html" class="login-btn">Admin Login</a> <a href="./login.html" class="login-btn">Admin Login</a>
</form> </form>
</div> </div>