<?php
require_once __DIR__ . '/lib/functions.php';
mdw_start_admin();
global $mdw_admin_password;
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $password = $_POST['password'] ?? '';
    if (hash_equals($mdw_admin_password, $password)) {
        $_SESSION['mdw_admin_logged_in'] = true;
        header('Location: index.php');
        exit;
    }
    $error = 'Invalid admin password.';
}
?>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>MDW Admin Login</title><link rel="stylesheet" href="assets/admin.css"></head><body><main class="login panel"><h1>Murdock DevWorks Admin</h1><p class="muted">Separate content and update tools for the MDW website.</p><?php if($error): ?><div class="alert error"><?php echo mdw_h($error); ?></div><?php endif; ?><form method="post"><label>Password</label><input type="password" name="password" required autofocus><br><br><button class="button" type="submit">Login</button></form><p class="muted small">Default password is set in <code>devworks-admin/config.php</code>. Change it after install.</p></main></body></html>
