NewHome/admin/login.php

57 lines
1.9 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
/**
* admin/login.php —— 后台登录页
*/
$P = '../';
require_once dirname(__DIR__) . '/includes/auth.php';
require_once dirname(__DIR__) . '/includes/layout.php';
$err = '';
$loggedOut = isset($_GET['out']);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim((string)($_POST['username'] ?? ''));
$password = (string)($_POST['password'] ?? '');
if ($username === '' || $password === '') {
$err = '请输入用户名和密码。';
} elseif (hp_login($username, $password)) {
header('Location: nav.php');
exit;
} else {
// 轻量防爆破延时
usleep(500000);
$err = '用户名或密码错误。';
}
}
$site = setting_get('site_name', '知识导航站');
layout_head('后台登录');
?>
<main class="login-page">
<div class="login-card">
<div class="login-logo"><?php layout_logo_img('', $site); ?></div>
<h1>后台管理登录</h1>
<p class="lc-sub"><?= he($site) ?></p>
<?php if ($err !== ''): ?>
<div class="err-msg"><?= he($err) ?></div>
<?php endif; ?>
<?php if ($loggedOut): ?>
<div class="ok-msg">已安全退出登录。</div>
<?php endif; ?>
<form method="post" action="login.php" autocomplete="off">
<label class="fl" for="username">用户名</label>
<input type="text" id="username" name="username" required autofocus>
<label class="fl" for="password">密码</label>
<input type="password" id="password" name="password" required>
<div style="margin-top:16px">
<button type="submit" class="btn btn-primary" style="width:100%">登录</button>
</div>
</form>
<p class="tip" style="margin-top:12px">初始账号admin / admin123首次登录后请在“内容与顺序”中修改</p>
</div>
</main>
<?php layout_theme_fab(); ?>
<script src="../assets/js/common.js"></script>
</body>
</html>