Adding passwords and versionning

This commit is contained in:
2026-03-11 10:43:23 -04:00
parent 20ed0eeadb
commit e0fe0c4d34
10 changed files with 341 additions and 6 deletions

81
login.php Normal file
View File

@@ -0,0 +1,81 @@
<?php
require_once __DIR__ . '/includes/auth.php';
if (!auth_enabled()) {
header('Location: index.php');
exit;
}
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// Already logged in
if (!empty($_SESSION['authenticated'])) {
header('Location: index.php');
exit;
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if (attempt_login($username, $password)) {
session_regenerate_id(true);
$_SESSION['authenticated'] = true;
$_SESSION['username'] = $username;
header('Location: index.php');
exit;
}
$error = 'Invalid username or password.';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login portspoof concentrator</title>
<style>
<?php include __DIR__ . '/includes/style.php'; ?>
.login-wrap {
min-height: 100vh;
display: flex; align-items: center; justify-content: center;
}
.login-box {
background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
padding: 2rem 2.25rem; width: 100%; max-width: 360px;
}
.login-box h1 { font-size: 1.1rem; font-weight: 600; color: #e6edf3; margin-bottom: 1.5rem; }
.login-box h1 span { color: var(--accent); }
.login-box form { max-width: 100%; }
.login-box button[type=submit] { width: 100%; margin-top: .25rem; }
</style>
</head>
<body>
<div class="login-wrap">
<div class="login-box">
<h1>portspoof<span>concentrator</span></h1>
<?php if ($error): ?>
<div class="alert err" style="margin-bottom:1rem"><?= htmlspecialchars($error, ENT_QUOTES, 'UTF-8') ?></div>
<?php endif; ?>
<form method="post">
<label>Username
<input type="text" name="username" autocomplete="username" required
value="<?= htmlspecialchars($_POST['username'] ?? '', ENT_QUOTES, 'UTF-8') ?>">
</label>
<label>Password
<input type="password" name="password" autocomplete="current-password" required>
</label>
<button type="submit">Sign in</button>
</form>
</div>
</div>
<?php include __DIR__ . '/includes/footer.php'; ?>
</body>
</html>