上传文件至 /
This commit is contained in:
276
feedback.php
Normal file
276
feedback.php
Normal file
@@ -0,0 +1,276 @@
|
||||
<?php
|
||||
require_once 'config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$error = '';
|
||||
$success = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$type = $_POST['type'];
|
||||
$subject = trim($_POST['subject']);
|
||||
$message = trim($_POST['message']);
|
||||
|
||||
if (empty($subject) || empty($message)) {
|
||||
$error = '请填写主题和内容';
|
||||
} else {
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT INTO feedbacks (user_id, type, subject, message) VALUES (?, ?, ?, ?)");
|
||||
if ($stmt->execute([$_SESSION['user_id'], $type, $subject, $message])) {
|
||||
$success = '反馈提交成功!感谢您的意见。';
|
||||
|
||||
sendNotification(
|
||||
$_SESSION['user_id'],
|
||||
'feedback_result',
|
||||
'反馈已收到',
|
||||
"您的反馈「{$subject}」已提交成功,我们会尽快处理。",
|
||||
'feedback.php'
|
||||
);
|
||||
} else {
|
||||
$error = '提交失败,请稍后重试';
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
$error = '系统错误:' . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo $lang; ?>" data-theme="<?php echo $currentUserSettings['dark_mode'] ? 'dark' : 'light'; ?>">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>意见反馈 - <?php echo SITE_NAME; ?></title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
||||
<link rel="stylesheet" href="css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<?php include 'components/navbar.php'; ?>
|
||||
|
||||
<div class="container">
|
||||
<div class="feedback-container">
|
||||
<div class="feedback-header">
|
||||
<h1><i class="fas fa-comment-dots"></i> 意见反馈</h1>
|
||||
<p>您的建议对我们非常重要,我们会认真阅读每一条反馈</p>
|
||||
</div>
|
||||
|
||||
<?php if($error): ?>
|
||||
<div class="alert alert-error">
|
||||
<i class="fas fa-exclamation-triangle"></i> <?php echo $error; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($success): ?>
|
||||
<div class="alert alert-success">
|
||||
<i class="fas fa-check-circle"></i> <?php echo $success; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="feedback-form card">
|
||||
<form method="POST" action="">
|
||||
<div class="form-group">
|
||||
<label for="type">
|
||||
<i class="fas fa-tag"></i> 反馈类型
|
||||
</label>
|
||||
<select id="type" name="type" required>
|
||||
<option value="bug">错误报告</option>
|
||||
<option value="feature">功能建议</option>
|
||||
<option value="suggestion">改进建议</option>
|
||||
<option value="other">其他</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="subject">
|
||||
<i class="fas fa-heading"></i> 主题
|
||||
</label>
|
||||
<input type="text" id="subject" name="subject" required
|
||||
placeholder="请简要描述您的问题或建议"
|
||||
value="<?php echo isset($_POST['subject']) ? htmlspecialchars($_POST['subject']) : ''; ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="message">
|
||||
<i class="fas fa-edit"></i> 详细内容
|
||||
</label>
|
||||
<textarea id="message" name="message" rows="8" required
|
||||
placeholder="请详细描述您的问题、建议或改进想法..."><?php echo isset($_POST['message']) ? htmlspecialchars($_POST['message']) : ''; ?></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-paper-plane"></i> 提交反馈
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="feedback-info card">
|
||||
<h3><i class="fas fa-info-circle"></i> 反馈说明</h3>
|
||||
<div class="info-grid">
|
||||
<div class="info-item">
|
||||
<i class="fas fa-bug"></i>
|
||||
<div>
|
||||
<h4>错误报告</h4>
|
||||
<p>遇到系统错误、功能异常或显示问题</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fas fa-lightbulb"></i>
|
||||
<div>
|
||||
<h4>功能建议</h4>
|
||||
<p>希望添加的新功能或改进建议</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fas fa-cogs"></i>
|
||||
<div>
|
||||
<h4>改进建议</h4>
|
||||
<p>对现有功能的优化和改进意见</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-item">
|
||||
<i class="fas fa-question"></i>
|
||||
<div>
|
||||
<h4>其他反馈</h4>
|
||||
<p>其他任何想要告诉我们的内容</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="feedback-history card">
|
||||
<h3><i class="fas fa-history"></i> 我的反馈记录</h3>
|
||||
<?php
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT * FROM feedbacks WHERE user_id = ? ORDER BY created_at DESC LIMIT 5");
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$feedbacks = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (empty($feedbacks)) {
|
||||
echo '<p class="text-muted">暂无反馈记录</p>';
|
||||
} else {
|
||||
echo '<div class="feedback-list">';
|
||||
foreach ($feedbacks as $feedback) {
|
||||
$statusClass = [
|
||||
'pending' => 'status-pending',
|
||||
'reviewed' => 'status-verified',
|
||||
'resolved' => 'status-public'
|
||||
][$feedback['status']] ?? 'status-pending';
|
||||
|
||||
$typeLabels = [
|
||||
'bug' => '错误报告',
|
||||
'feature' => '功能建议',
|
||||
'suggestion' => '改进建议',
|
||||
'other' => '其他'
|
||||
];
|
||||
|
||||
echo '
|
||||
<div class="feedback-item">
|
||||
<div class="feedback-header">
|
||||
<strong>' . htmlspecialchars($feedback['subject']) . '</strong>
|
||||
<span class="status-badge ' . $statusClass . '">' . $feedback['status'] . '</span>
|
||||
</div>
|
||||
<div class="feedback-meta">
|
||||
<span class="feedback-type">' . ($typeLabels[$feedback['type']] ?? $feedback['type']) . '</span>
|
||||
<span class="feedback-time">' . date('Y-m-d H:i', strtotime($feedback['created_at'])) . '</span>
|
||||
</div>
|
||||
<div class="feedback-content">' . nl2br(htmlspecialchars($feedback['message'])) . '</div>
|
||||
</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
echo '<p class="text-muted">加载反馈记录失败</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.feedback-container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.feedback-header {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
.feedback-header h1 {
|
||||
color: var(--primary-color);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.feedback-form {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.feedback-info {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.info-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 15px;
|
||||
padding: 15px;
|
||||
background: var(--bg-color);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
.info-item i {
|
||||
font-size: 1.5rem;
|
||||
color: var(--primary-color);
|
||||
margin-top: 2px;
|
||||
}
|
||||
.info-item h4 {
|
||||
margin-bottom: 5px;
|
||||
color: var(--text-color);
|
||||
}
|
||||
.info-item p {
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
margin: 0;
|
||||
}
|
||||
.feedback-list {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.feedback-item {
|
||||
padding: 20px;
|
||||
margin-bottom: 15px;
|
||||
background: var(--bg-color);
|
||||
border-radius: var(--radius);
|
||||
border-left: 4px solid var(--primary-color);
|
||||
}
|
||||
.feedback-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.feedback-meta {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 0.9rem;
|
||||
color: #666;
|
||||
}
|
||||
.feedback-type {
|
||||
background: var(--primary-color);
|
||||
color: white;
|
||||
padding: 2px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.feedback-content {
|
||||
line-height: 1.6;
|
||||
color: var(--text-color);
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user