文件
parlz-domain/forgot_password.php

117 行
5.1 KiB
PHP

<?php
require_once 'functions.php';
$currentTheme = getTheme();
$message = null;
$success = false;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = trim($_POST['email'] ?? '');
if (empty($email)) {
$message = '请输入邮箱地址';
} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$message = '请输入有效的邮箱地址';
} else {
$result = requestPasswordReset($email);
if ($result['success']) {
$success = true;
$message = $result['message'];
} else {
$message = $result['message'];
}
}
}
$pageTitle = '忘记密码 - ' . SITE_NAME;
$pageDescription = '重置您的 ' . SITE_NAME . ' 账号密码,通过邮箱验证找回账号。';
?>
<!DOCTYPE html>
<html lang="zh-CN" data-theme="<?php echo $currentTheme; ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo htmlspecialchars($pageTitle); ?></title>
<meta name="description" content="<?php echo htmlspecialchars($pageDescription); ?>">
<link rel="canonical" href="https://<?php echo $_SERVER['HTTP_HOST']; ?>/forgot_password">
<meta name="robots" content="index, follow">
<link rel="alternate" hreflang="zh-CN" href="https://<?php echo $_SERVER['HTTP_HOST']; ?>/forgot_password.php" />
<link rel="icon" href="favicon.ico">
<meta property="og:title" content="<?php echo htmlspecialchars($pageTitle); ?>">
<meta property="og:description" content="<?php echo htmlspecialchars($pageDescription); ?>">
<meta property="og:image" content="https://<?php echo $_SERVER['HTTP_HOST']; ?>/favicon.ico">
<meta property="og:image:width" content="256">
<meta property="og:image:height" content="256">
<meta property="og:url" content="https://<?php echo $_SERVER['HTTP_HOST']; ?>/forgot_password.php">
<meta property="og:type" content="website">
<meta property="og:site_name" content="<?php echo SITE_NAME; ?>">
<meta property="og:locale" content="zh_CN">
<!-- ===== Twitter Card ===== -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="<?php echo htmlspecialchars($pageTitle); ?>">
<meta name="twitter:description" content="<?php echo htmlspecialchars($pageDescription); ?>">
<meta name="twitter:image" content="https://<?php echo $_SERVER['HTTP_HOST']; ?>/favicon.ico">
<meta name="twitter:site" content="https://<?php echo $_SERVER['HTTP_HOST']; ?>">
<!-- ===== Schema.org ===== -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebPage",
"name": "<?php echo htmlspecialchars($pageTitle); ?>",
"description": "<?php echo htmlspecialchars($pageDescription); ?>",
"url": "https://<?php echo $_SERVER['HTTP_HOST']; ?>/forgot-password",
"inLanguage": "zh-CN"
}
</script>
<link rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.0/css/all.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="auth-container">
<div class="auth-card">
<div class="icon-top">
<i class="fas fa-key"></i>
</div>
<h2>忘记密码</h2>
<p class="subtitle">输入您的邮箱,我们将发送重置链接</p>
<?php if ($message): ?>
<div class="alert alert-<?php echo $success ? 'success' : 'error'; ?>">
<i class="fas <?php echo $success ? 'fa-check-circle' : 'fa-exclamation-circle'; ?>"></i>
<?php echo htmlspecialchars($message); ?>
</div>
<?php endif; ?>
<?php if ($success): ?>
<div class="success-box">
<i class="fas fa-envelope"></i>
<h3>📧 邮件已发送</h3>
<p>请检查您的邮箱,点击邮件中的链接重置密码。<br>如果没收到邮件,请检查垃圾箱。</p>
<a href="/login" class="btn btn-primary" style="display:inline-flex;width:auto;padding:12px 32px;">
<i class="fas fa-sign-in-alt"></i> 返回登录
</a>
</div>
<?php else: ?>
<form method="POST">
<div class="form-group">
<label><i class="fas fa-envelope"></i> 邮箱地址</label>
<input type="email" name="email" placeholder="请输入注册邮箱" required>
</div>
<button type="submit" class="btn btn-primary">
<i class="fas fa-paper-plane"></i> 发送重置链接
</button>
</form>
<div class="auth-links">
想起密码了?<a href="/login">返回登录</a>
</div>
<?php endif; ?>
</div>
</div>
</div>
</body>
</html>