Files
sld-blocknotes/pages/login.php
T

77 lines
2.8 KiB
PHP

<?php
if (is_logged_in()) {
header("Location: index.php?page=home");
exit;
}
$error_msg = "";
$success_msg = "";
if (isset($_GET['installed'])) {
$success_msg = __('login_installed_success');
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
$res = login_user($username, $password);
if ($res['success']) {
header("Location: index.php?page=home");
exit;
} else {
$error_msg = $res['message'];
}
}
?>
<main class="main-content">
<div style="max-width: 420px; margin: 3rem auto;">
<div class="card" style="padding: 2.25rem;">
<div style="text-align: center; margin-bottom: 2rem;">
<span style="font-size: 3rem;">📝</span>
<h2 style="font-size: 1.6rem; font-weight: 700; color: #fff; margin-top: 0.5rem;"><?= __('login_title') ?></h2>
<p style="color: #94a3b8; font-size: 0.9rem; margin-top: 0.25rem;"><?= __('login_subtitle') ?></p>
</div>
<?php if (!empty($success_msg)): ?>
<div class="alert alert-success">
✅ <?= htmlspecialchars($success_msg) ?>
</div>
<?php endif; ?>
<?php if (!empty($error_msg)): ?>
<div class="alert alert-danger">
⚠️ <?= htmlspecialchars($error_msg) ?>
</div>
<?php endif; ?>
<form action="index.php?page=login" method="POST">
<div class="form-group">
<label for="username"><?= __('label_username') ?></label>
<input type="text" name="username" id="username" class="form-control" required placeholder="<?= __('placeholder_username') ?>" autofocus value="<?= htmlspecialchars($_POST['username'] ?? '') ?>">
</div>
<div class="form-group">
<label for="password"><?= __('label_password') ?></label>
<input type="password" name="password" id="password" class="form-control" required placeholder="<?= __('placeholder_password') ?>">
</div>
<button type="submit" class="btn btn-primary" style="width: 100%; justify-content: center; margin-top: 1rem; padding: 0.8rem;">
<?= __('btn_submit_login') ?>
</button>
</form>
<?php $admin_email = get_site_setting('admin_email', '[email protected]'); ?>
<?php if (!empty($admin_email)): ?>
<div style="margin-top: 1.5rem; text-align: center; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.08); font-size: 0.85rem; color: #94a3b8;">
<?= __('login_request_account') ?><br>
<a href="mailto:<?= htmlspecialchars($admin_email) ?>" style="color: #7dd3fc; font-weight: 600; text-decoration: underline; margin-top: 0.35rem; display: inline-block;">
✉️ <?= htmlspecialchars($admin_email) ?>
</a>
</div>
<?php endif; ?>
</div>
</div>
</main>