diff --git a/delete-image.php b/delete-image.php new file mode 100644 index 0000000..3c21293 --- /dev/null +++ b/delete-image.php @@ -0,0 +1,37 @@ +prepare("SELECT filename, user_id FROM images WHERE id = ?"); + $stmt->execute([$image_id]); + $image = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($image && ($_SESSION['user_id'] == $image['user_id'] || $_SESSION['username'] === 'admin')) { + $stmt = $pdo->prepare("DELETE FROM images WHERE id = ?"); + $stmt->execute([$image_id]); + + $file_path = 'uploads/' . $image['filename']; + if (file_exists($file_path)) { + unlink($file_path); + } + + $_SESSION['success'] = t('image_deleted_success'); + } else { + $_SESSION['error'] = t('no_permission_delete'); + } + } catch(PDOException $e) { + $_SESSION['error'] = t('delete_failed') . ': ' . $e->getMessage(); + } +} + +header('Location: dashboard.php'); +exit; +?> \ No newline at end of file diff --git a/feedback.php b/feedback.php new file mode 100644 index 0000000..8ec943d --- /dev/null +++ b/feedback.php @@ -0,0 +1,276 @@ +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(); + } + } +} +?> + + + + + + + 意见反馈 - <?php echo SITE_NAME; ?> + + + + + + +
+
+ + + +
+ +
+ + + +
+ +
+ + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/forgot-password.php b/forgot-password.php new file mode 100644 index 0000000..659b3d6 --- /dev/null +++ b/forgot-password.php @@ -0,0 +1,179 @@ +prepare("SELECT id, username FROM users WHERE email = ?"); + $stmt->execute([$email]); + $user = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($user) { + $token = bin2hex(random_bytes(32)); + $expires_at = date('Y-m-d H:i:s', time() + PASSWORD_RESET_EXPIRE); + + $pdo->prepare("DELETE FROM password_resets WHERE email = ?")->execute([$email]); + + $stmt = $pdo->prepare("INSERT INTO password_resets (email, token, expires_at) VALUES (?, ?, ?)"); + + if ($stmt->execute([$email, $token, $expires_at])) { + if (sendPasswordResetEmail($email, $user['username'], $token)) { + $success = t('reset_link_sent'); + } else { + $reset_link = SITE_URL . "/reset-password.php?token=" . $token; + $success = t('reset_link_generated') . "
$reset_link"; + } + } else { + $error = t('system_error'); + } + } else { + $error = t('email_not_registered'); + } + } +} +?> + + + + + + <?php echo t('forgot_password'); ?> - <?php echo SITE_NAME; ?> + + + + + + +
+
+
+

+ +
+

+
    +
  • +
  • +
  • +
  • +
+
+ + +
+ +
+ + + +
+ +
+ + +
+

+

+

:

+
+ +
+

+

+

+
+ + + + +
+
+ + +
+ + +
+ +
+ + <?php echo t('captcha'); ?> +
+
+ + + +
+ + + +
+
+
+ + + + \ No newline at end of file diff --git a/generate-api-key.php b/generate-api-key.php new file mode 100644 index 0000000..ac2028e --- /dev/null +++ b/generate-api-key.php @@ -0,0 +1,20 @@ +prepare("UPDATE users SET api_key = ? WHERE id = ?"); + +if ($stmt->execute([$api_key, $_SESSION['user_id']])) { + $_SESSION['success'] = t('api_key_generated'); +} else { + $_SESSION['error'] = t('api_key_generation_failed'); +} + +header('Location: ' . ($_SERVER['HTTP_REFERER'] ?? 'dashboard.php')); +exit; +?> \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..8cc1f9b --- /dev/null +++ b/index.php @@ -0,0 +1,180 @@ +prepare(" + SELECT i.*, u.username, + (SELECT COUNT(*) FROM image_feedbacks WHERE image_id = i.id AND type = 'like') as like_count + FROM images i + LEFT JOIN users u ON i.user_id = u.id + WHERE i.is_public = 1 + ORDER BY i.uploaded_at DESC + LIMIT 12 + "); + $stmt->execute(); + $publicImages = $stmt->fetchAll(PDO::FETCH_ASSOC); +} catch(PDOException $e) { + $publicImages = []; +} +?> + + + + + + + <?php echo t('site_title'); ?> + + + + + + +
+ + +
+
+
+ <?php echo htmlspecialchars($bingImage['title']); ?> +
+
+

+

+ +
+ + + + + + +
+
+
+
+ + + +
+

+

+ + + + + + + +
+ + +
+

+
+
+
+ +
+

+

+
+
+
+ +
+

+

+
+
+
+ +
+

+

+
+
+
+ + + + + +
+ + + + + + + \ No newline at end of file