Files
JiJin/login.php
2025-11-18 14:25:00 +08:00

241 lines
6.7 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
// 基金监控系统登录页面
// 初始化错误信息
$error = '';
// 处理登录请求
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// 获取表单提交的密码
$password = $_POST['password'] ?? '';
// 简单的密码验证(实际项目中应使用更安全的验证方式)
$correct_password = 'qiyu123123';
if ($password === $correct_password) {
// 登录成功,创建会话
session_start();
$_SESSION['admin_logged_in'] = true;
$_SESSION['login_time'] = time();
// 记录登录日志
$log_entry = [
'timestamp' => date('Y-m-d H:i:s'),
'action' => '管理员登录',
'ip' => $_SERVER['REMOTE_ADDR']
];
// 保存登录日志
saveLog($log_entry);
// 跳转到管理页面
header('Location: admin.php');
exit;
} else {
// 登录失败
$error = '密码错误,请重试';
}
}
// 保存日志函数
function saveLog($log_entry) {
$log_file = 'data/operation_log.json';
// 检查目录是否存在,不存在则创建
if (!file_exists(dirname($log_file))) {
mkdir(dirname($log_file), 0777, true);
}
// 读取现有日志
$logs = [];
if (file_exists($log_file)) {
$content = file_get_contents($log_file);
if (!empty($content)) {
$logs = json_decode($content, true);
}
}
// 添加新日志
array_unshift($logs, $log_entry);
// 限制日志数量只保留最新的500条
if (count($logs) > 500) {
$logs = array_slice($logs, 0, 500);
}
// 保存日志
file_put_contents($log_file, json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🚀 基金监控 - 登录</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.login-container {
background: white;
border-radius: 12px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
padding: 40px;
width: 100%;
max-width: 400px;
transform: translateY(0);
animation: float 6s ease-in-out infinite;
}
@keyframes float {
0% { transform: translateY(0px); }
50% { transform: translateY(-10px); }
100% { transform: translateY(0px); }
}
.logo {
text-align: center;
margin-bottom: 30px;
}
.logo h1 {
color: #333;
font-size: 24px;
margin-bottom: 10px;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.logo p {
color: #666;
font-size: 14px;
}
.form-group {
margin-bottom: 20px;
}
.form-label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 500;
font-size: 14px;
}
.form-control {
width: 100%;
padding: 12px 16px;
border: 2px solid #e1e5e9;
border-radius: 8px;
font-size: 16px;
transition: border-color 0.3s ease;
}
.form-control:focus {
outline: none;
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.btn {
width: 100%;
padding: 12px;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
}
.btn-primary {
background-color: #667eea;
color: white;
}
.btn-primary:hover {
background-color: #5a67d8;
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.alert {
padding: 12px 16px;
border-radius: 8px;
margin-bottom: 20px;
font-size: 14px;
}
.alert-error {
background-color: #fee2e2;
color: #dc2626;
border: 1px solid #fecaca;
}
.footer {
text-align: center;
margin-top: 20px;
font-size: 12px;
color: #9ca3af;
}
@media (max-width: 480px) {
.login-container {
padding: 30px 20px;
}
}
</style>
</head>
<body>
<div class="login-container">
<div class="logo">
<h1><i class="fas fa-lock"></i> 基金监控管理后台</h1>
<p>请输入密码进行登录</p>
</div>
<?php if (!empty($error)): ?>
<div class="alert alert-error">
<i class="fas fa-exclamation-circle"></i> <?php echo htmlspecialchars($error); ?>
</div>
<?php endif; ?>
<form method="post" action="login.php">
<div class="form-group">
<label class="form-label" for="password">管理员密码</label>
<input type="password" class="form-control" id="password" name="password" required
placeholder="请输入密码" autocomplete="current-password">
</div>
<button type="submit" class="btn btn-primary">
<i class="fas fa-sign-in-alt"></i> 登录
</button>
<button type="button" class="btn" style="background-color: #f3f4f6; color: #4b5563; margin-top: 15px;" onclick="window.location.href='index.php'">
<i class="fas fa-home"></i> 返回主界面
</button>
</form>
<div class="footer">
<p>© 2025 基金监控系统 - Tsama</p>
</div>
</div>
</body>
</html>