Files
ClassManager/frontend/reset_password.php
T
canglan 768ea281e0 v4.4 数据报表/操作日志/系统设置与月度分排行
1. 月度分排行:管理端首页支持总分/月度分切换与月份选择,新增排行榜导出CSV
2. 数据报表:新增考勤/作业统计页(日期范围、汇总与每人明细、CSV导出)
3. 操作日志:新增查看页(操作类型/操作人/日期筛选,分页)
4. 系统设置:密码策略可配置(长度/字符种类),全站改密与重置统一校验、前端提示同步;策略通过公开配置下发
5. 学期归档对比:查看归档时展示与上一学期的分数变化与名次升降
6. 历史记录导出支持按学生分表(每人一段,便于发家长)
7. 移动端适配:导航横向滚动、表格触控滚动、字号与弹窗优化
8. 版本升级至4.4(无数据库结构变更)
2026-10-09 15:00:32 +08:00

158 lines
6.8 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
/**
* 班级操行分管理系统 - 重置密码
*
* 开发者: Canglan
* 联系方式: admin@sea-studio.top
* 版权归属: Sea Network Technology Studio
* 许可证: MIT License
*
* 版权所有 © Sea Network Technology Studio
*/
require_once __DIR__ . '/config.php';
$token = isset($_GET['token']) ? preg_replace('/[^A-Za-z0-9_\-]/', '', $_GET['token']) : '';
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title><?php echo SITE_NAME; ?> - 重置密码</title>
<link rel="stylesheet" href="/assets/css/style.css">
</head>
<body>
<div class="login-container">
<div class="login-header">
<h1><?php echo SITE_NAME; ?></h1>
<p>重置管理员密码</p>
</div>
<div id="loadingBox" class="login-form text-muted" style="text-align:center;">正在校验链接...</div>
<form id="resetForm" class="login-form" style="display:none;">
<div class="form-group">
<label>账号</label>
<input type="text" id="accountName" disabled>
</div>
<div class="form-group">
<label>新密码 <span style="color:red;">*</span></label>
<input type="password" id="newPassword" required>
<small class="pwd-policy">密码长度6-20位,需包含大写字母、小写字母、数字、特殊符号中的至少3种</small>
</div>
<div class="form-group">
<label>确认新密码 <span style="color:red;">*</span></label>
<input type="password" id="confirmPassword" required>
</div>
<button type="submit" class="btn-login" id="submitBtn">确认重置</button>
<div id="tipMsg" class="error-msg" style="display: none;"></div>
</form>
<div id="invalidBox" class="login-form" style="display:none; text-align:center;">
<p class="text-danger" style="margin-bottom:16px;">重置链接无效或已过期,请重新申请。</p>
<a href="/forgot_password.php" class="link">重新申请</a>
</div>
<div class="login-footer">
<p>&copy; <?php echo date('Y'); ?> Sea Network Technology Studio</p>
<?php if (defined('ICP_ENABLED') && ICP_ENABLED && defined('ICP_NUMBER') && ICP_NUMBER): ?>
<p><a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer"><?php echo htmlspecialchars(ICP_NUMBER); ?></a></p>
<?php endif; ?>
</div>
</div>
<script src="/assets/js/common.js"></script>
<script>
window.API_BASE_URL = '<?php echo API_BASE_URL; ?>';
const RESET_TOKEN = '<?php echo htmlspecialchars($token, ENT_QUOTES, 'UTF-8'); ?>';
// 加载密码策略(公开配置)
fetch(window.API_BASE_URL + '/api/config/deduction-rules')
.then(function(r) { return r.json(); })
.then(function(resp) {
if (resp && resp.success && resp.data) {
window.PASSWORD_MIN_LENGTH = resp.data.PASSWORD_MIN_LENGTH;
window.PASSWORD_MAX_LENGTH = resp.data.PASSWORD_MAX_LENGTH;
window.PASSWORD_MIN_TYPES = resp.data.PASSWORD_MIN_TYPES;
document.querySelectorAll('.pwd-policy').forEach(function(el) {
el.textContent = describePasswordPolicy();
});
}
})
.catch(function() {});
function showTip(msg, isError) {
const tip = document.getElementById('tipMsg');
tip.textContent = msg;
tip.className = isError ? 'error-msg' : 'success-msg';
tip.style.display = 'block';
}
(async function verifyToken() {
if (!RESET_TOKEN) {
document.getElementById('loadingBox').style.display = 'none';
document.getElementById('invalidBox').style.display = 'block';
return;
}
try {
const response = await fetch(`${window.API_BASE_URL}/api/auth/reset-token/check?token=${encodeURIComponent(RESET_TOKEN)}`);
const data = await response.json();
const info = data && data.success ? data.data : null;
document.getElementById('loadingBox').style.display = 'none';
if (info && info.valid) {
document.getElementById('accountName').value =
(info.real_name || '') + '(' + info.username + ')';
document.getElementById('resetForm').style.display = 'block';
} else {
document.getElementById('invalidBox').style.display = 'block';
}
} catch (error) {
console.error('令牌校验失败:', error);
document.getElementById('loadingBox').style.display = 'none';
document.getElementById('invalidBox').style.display = 'block';
}
})();
document.getElementById('resetForm').addEventListener('submit', async (e) => {
e.preventDefault();
const newPassword = document.getElementById('newPassword').value;
const confirmPassword = document.getElementById('confirmPassword').value;
if (newPassword !== confirmPassword) {
showTip('两次输入的密码不一致', true);
return;
}
const policyError = validatePasswordByPolicy(newPassword);
if (policyError) {
showTip(policyError, true);
return;
}
const btn = document.getElementById('submitBtn');
btn.disabled = true;
btn.textContent = '提交中...';
try {
const response = await fetch(`${window.API_BASE_URL}/api/auth/reset-password`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ token: RESET_TOKEN, new_password: newPassword })
});
const data = await response.json();
if (data.success) {
showTip(data.message || '密码重置成功', false);
setTimeout(() => { window.location.href = '/index.php'; }, 1800);
} else {
showTip(data.message || '重置失败', true);
btn.disabled = false;
btn.textContent = '确认重置';
}
} catch (error) {
console.error('重置密码失败:', error);
showTip('网络错误,请稍后重试', true);
btn.disabled = false;
btn.textContent = '确认重置';
}
});
</script>
</body>
</html>