Files
portspoof_concentrator/login.php

82 lines
2.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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>