Add nodes management and initial setup pages

- Implemented nodes management functionality in `nodes.php` including create, update, and delete actions.
- Added form validation and error handling for node operations.
- Created a new setup page in `setup.php` for initial administrator account creation.
- Included user feedback messages for successful operations and errors.
- Designed user interface for both nodes management and setup processes.
This commit is contained in:
2025-12-14 01:33:12 -05:00
parent cf0ec74888
commit d8b76233c0
19 changed files with 8800 additions and 0 deletions

181
pathvector-admin/login.php Normal file
View File

@@ -0,0 +1,181 @@
<?php
/**
* Pathvector Admin - Login Page
*/
session_start();
require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/lib/FlatFileDB.php';
require_once __DIR__ . '/lib/Logger.php';
require_once __DIR__ . '/lib/Auth.php';
$db = new FlatFileDB(DATA_PATH);
$logger = new Logger($db);
$auth = new Auth($db);
// Redirect if already logged in
if ($auth->isLoggedIn()) {
header('Location: index.php');
exit;
}
$error = '';
$username = '';
// Handle login form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
if (empty($username) || empty($password)) {
$error = 'Please enter both username and password.';
} else {
$result = $auth->login($username, $password);
if ($result['success']) {
$logger->log('auth', 'User logged in', ['username' => $username]);
header('Location: index.php');
exit;
} else {
$error = $result['message'];
$logger->log('auth', 'Failed login attempt', ['username' => $username, 'error' => $result['message']], 'warning');
}
}
}
?>
<!DOCTYPE html>
<html lang="en" data-color-mode="auto" data-light-theme="light" data-dark-theme="dark_dimmed">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Pathvector Admin</title>
<link rel="stylesheet" href="https://unpkg.com/@primer/css@^20.2.4/dist/primer.css">
<style>
body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: var(--color-canvas-subtle);
}
.login-container {
width: 100%;
max-width: 340px;
padding: 24px;
}
.login-header {
text-align: center;
margin-bottom: 24px;
}
.login-logo {
display: inline-flex;
align-items: center;
justify-content: center;
width: 64px;
height: 64px;
background: var(--color-accent-emphasis);
border-radius: 12px;
margin-bottom: 16px;
}
.login-logo svg {
width: 32px;
height: 32px;
fill: white;
}
.login-box {
background: var(--color-canvas-default);
border: 1px solid var(--color-border-default);
border-radius: 6px;
padding: 24px;
}
.login-footer {
text-align: center;
margin-top: 16px;
font-size: 12px;
color: var(--color-fg-muted);
}
.form-group {
margin-bottom: 16px;
}
.form-group:last-child {
margin-bottom: 0;
}
.form-group label {
display: block;
font-weight: 600;
margin-bottom: 4px;
font-size: 14px;
}
.form-group input {
width: 100%;
}
</style>
</head>
<body>
<div class="login-container">
<div class="login-header">
<div class="login-logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.75 4.75a.75.75 0 00-1.5 0v2.5h-2.5a.75.75 0 000 1.5h2.5v2.5a.75.75 0 001.5 0v-2.5h2.5a.75.75 0 000-1.5h-2.5v-2.5z"/>
</svg>
</div>
<h1 class="h3">Pathvector Admin</h1>
<p class="color-fg-muted">BGP Configuration Dashboard</p>
</div>
<div class="login-box">
<?php if ($error): ?>
<div class="flash flash-error mb-3">
<?= htmlspecialchars($error) ?>
</div>
<?php endif; ?>
<form method="POST" action="">
<div class="form-group">
<label for="username">Username</label>
<input type="text"
id="username"
name="username"
class="form-control"
value="<?= htmlspecialchars($username) ?>"
autocomplete="username"
autofocus
required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password"
id="password"
name="password"
class="form-control"
autocomplete="current-password"
required>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">
Sign in
</button>
</div>
</form>
</div>
<div class="login-footer">
<p>Pathvector Admin Dashboard</p>
<p>Need access? Contact your administrator.</p>
</div>
</div>
</body>
</html>