diff --git a/login.php b/login.php new file mode 100644 index 0000000..56e6d87 --- /dev/null +++ b/login.php @@ -0,0 +1,102 @@ +prepare("SELECT * FROM users WHERE email = ?"); + $stmt->execute([$email]); + $user = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($user && password_verify($password, $user['password'])) { + if (!$user['is_verified']) { + $error = t('verify_email_first'); + } else { + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + $_SESSION['email'] = $user['email']; + + header('Location: dashboard.php'); + exit; + } + } else { + $error = t('invalid_credentials'); + } + } +} +?> + + + + + + <?php echo t('login'); ?> - <?php echo SITE_NAME; ?> + + + + + + +
+
+
+

+ + +
+ +
+ + +
+
+ + +
+ +
+ + +
+ + +
+ + +
+
+
+ + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..12e441f --- /dev/null +++ b/logout.php @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/notifications.php b/notifications.php new file mode 100644 index 0000000..8263f84 --- /dev/null +++ b/notifications.php @@ -0,0 +1,194 @@ +prepare("UPDATE notifications SET is_read = TRUE WHERE id = ? AND user_id = ?"); + $stmt->execute([$notification_id, $_SESSION['user_id']]); + header('Location: notifications.php'); + exit; +} + +// 标记所有为已读 +if (isset($_POST['mark_all_read'])) { + $stmt = $pdo->prepare("UPDATE notifications SET is_read = TRUE WHERE user_id = ?"); + $stmt->execute([$_SESSION['user_id']]); + header('Location: notifications.php'); + exit; +} + +// 删除通知 +if (isset($_GET['delete'])) { + $notification_id = intval($_GET['delete']); + $stmt = $pdo->prepare("DELETE FROM notifications WHERE id = ? AND user_id = ?"); + $stmt->execute([$notification_id, $_SESSION['user_id']]); + header('Location: notifications.php'); + exit; +} + +// 获取通知列表 +$notifications = getUserNotifications($_SESSION['user_id'], 50); +$unreadCount = getUnreadNotificationCount($_SESSION['user_id']); + +$userSettings = getUserSettings($_SESSION['user_id']); +?> + + + + + + 通知中心 - PicHost + + + + + + +
+
+

通知中心

+
+ 0): ?> +
+ +
+ + 条未读 +
+
+ + +
+

📭 暂无通知

+

您还没有收到任何通知

+
+ +
+ +
+
+

+ + '公告', + 'tips' => '技巧', + 'feedback_result' => '反馈', + 'image_feedback' => '图片' + ]; + echo $typeLabels[$notification['type_name']] ?? $notification['type_name']; + ?> + +
+ +
+ +
+ + +
+ +
+ +
+ + \ No newline at end of file diff --git a/register.php b/register.php new file mode 100644 index 0000000..5f781e1 --- /dev/null +++ b/register.php @@ -0,0 +1,134 @@ +prepare("SELECT id FROM users WHERE username = ? OR email = ?"); + $stmt->execute([$username, $email]); + + if ($stmt->rowCount() > 0) { + $error = t('user_exists'); + } else { + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + $verification_code = md5(uniqid(rand(), true)); + + $stmt = $pdo->prepare("INSERT INTO users (username, email, password, verification_code) VALUES (?, ?, ?, ?)"); + + if ($stmt->execute([$username, $email, $hashed_password, $verification_code])) { + if (sendVerificationEmail($email, $username, $verification_code)) { + $success = t('registration_success_verify'); + } else { + $pdo->prepare("UPDATE users SET is_verified = 1 WHERE email = ?")->execute([$email]); + $success = t('registration_success_direct'); + } + } else { + $error = t('registration_failed'); + } + } + } +} +?> + + + + + + <?php echo t('register'); ?> - <?php echo SITE_NAME; ?> + + + + + + +
+
+
+

+ + +
+ +
+ + + +
+ +
+ + + +
+
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+ + +
+ + +
+ + + +
+
+
+ + \ No newline at end of file diff --git a/settings.php b/settings.php new file mode 100644 index 0000000..27226e3 --- /dev/null +++ b/settings.php @@ -0,0 +1,172 @@ + ['name' => 'announcement', 'label' => t('system_announcements'), 'description' => t('system_announcements_desc')], + 2 => ['name' => 'tips', 'label' => t('usage_tips'), 'description' => t('usage_tips_desc')], + 3 => ['name' => 'feedback_result', 'label' => t('feedback_results'), 'description' => t('feedback_results_desc')], + 4 => ['name' => 'image_feedback', 'label' => t('image_feedback'), 'description' => t('image_feedback_desc')] +]; + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $dark_mode = isset($_POST['dark_mode']) ? 1 : 0; + $language = $_POST['language'] ?? 'zh-CN'; + $items_per_page = intval($_POST['items_per_page'] ?? 20); + $email_notifications = isset($_POST['email_notifications']) ? 1 : 0; + $browser_notifications = isset($_POST['browser_notifications']) ? 1 : 0; + + $notification_settings = []; + foreach ($notificationTypes as $type_id => $type) { + $notification_settings[$type_id] = isset($_POST['notification_' . $type_id]); + } + + if ($items_per_page < 5 || $items_per_page > 100) { + $error = t('items_per_page_range_error'); + } else { + $newSettings = [ + 'dark_mode' => $dark_mode, + 'language' => $language, + 'items_per_page' => $items_per_page, + 'email_notifications' => $email_notifications, + 'browser_notifications' => $browser_notifications + ]; + + if (updateUserSettings($_SESSION['user_id'], $newSettings) && + updateUserNotificationSettings($_SESSION['user_id'], $notification_settings)) { + $success = t('settings_saved'); + $userSettings = $newSettings; + $notificationSettings = $notification_settings; + $_SESSION['language'] = $language; + } else { + $error = t('save_failed'); + } + } +} +?> + + + + + + <?php echo t('settings'); ?> - <?php echo SITE_NAME; ?> + + + + + + +
+

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

+ +
+ +
+
+ +
+

+ +
+ + +
+
+ +
+

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

+ $type): ?> +
+ +
+ +
+
+ +
+

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