From b2fc2494ba9cafe2ea140c9959a634e0bc1b3426 Mon Sep 17 00:00:00 2001 From: Tiaotiao <65841827@qq.com> Date: Fri, 5 Dec 2025 20:33:14 +0800 Subject: [PATCH 1/4] Add discussion.php for community interaction --- discussion.php | 172 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 discussion.php diff --git a/discussion.php b/discussion.php new file mode 100644 index 0000000..235c28b --- /dev/null +++ b/discussion.php @@ -0,0 +1,172 @@ +window.location.href = "' . $redirectUrl . '";'; + exit; + } +} + +// 检查登录状态 +$isLoggedIn = isset($dt['Data']['User']['Nickname']) && $dt['Data']['User']['Nickname'] !== '点击登录'; + +function getCommunityData() { + $baseUrl = "http://nlm-api-cn.turtlesim.com/"; + + // 准备请求数据 + $requestData = [ + 'Identifier' => 'Discussions', + 'Language' => "Chinese" + ]; + + // 准备请求头 + $headers = [ + 'Content-Type: application/json', + 'Accept: application/json', + 'Accept-Language: zh-CN', + ]; + + // 添加认证头(修复了多余的大括号) + $headers[] = 'x-API-Token: ' . $_SESSION['token']; + $headers[] = 'x-API-AuthCode: ' . $_SESSION['authCode']; + + // 发送POST请求 + $url = $baseUrl . 'Contents/GetLibrary'; + + $ch = curl_init(); + curl_setopt_array($ch, [ + CURLOPT_URL => $url, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => json_encode($requestData, JSON_UNESCAPED_UNICODE), + CURLOPT_HTTPHEADER => $headers, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_TIMEOUT => 30, + ]); + + $response = curl_exec($ch); + curl_close($ch); + $data = json_decode($response, true); + return $data; +} + +// 处理日期格式 +function formatDate($id) { + return (strlen($id) >= 8) ? date('m/d', hexdec(substr($id, 0, 8)) * 1000 / 1000) : '未知日期'; +} + +// 获取数据 +$communityData = getCommunityData(); + +// 模块配置 +$modules = [ + ['title' => '海水公告', 'count' => 3, 'featured' => true, 'type' => 'explore', 'category' => 'Discussion'], + ['title' => '海水精选', 'count' => 3, 'featured' => true, 'type' => 'featured', 'category' => 'Discussion'], + ['title' => '热门交流', 'count' => 4, 'featured' => false, 'type' => 'daily', 'category' => 'Discussion'], + ['title' => '最新交流', 'count' => 4, 'featured' => false, 'type' => 'hot', 'category' => 'Discussion'], + ['title' => '社区知识库', 'count' => 4, 'featured' => false, 'type' => 'new', 'category' => 'Discussion'], + ['title' => '海水模版', 'count' => 4, 'featured' => false, 'type' => 'visual', 'category' => 'Discussion'] +]; +?> + + + + + + Turtle Universe Web - Discussion + + + + +
+

海水

+
+ +
+ + +
+ $module): ?> + + +
+
+
+ + +
+ <?= htmlspecialchars($subject) ?> +
+
+
-
+ +
+ + + +
+ +
+
+ +
+
+ +
+
+ + +
+ +
+

无法加载社区数据,请检查网络连接或稍后重试

+ +
+ +
+ + + + + + From 34188fba67750dc8b1968d6b832bb1b58ec73515 Mon Sep 17 00:00:00 2001 From: Tiaotiao <65841827@qq.com> Date: Fri, 5 Dec 2025 20:34:24 +0800 Subject: [PATCH 2/4] Add model.php for community data handling --- model.php | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 model.php diff --git a/model.php b/model.php new file mode 100644 index 0000000..2682e62 --- /dev/null +++ b/model.php @@ -0,0 +1,176 @@ +window.location.href = "' . $redirectUrl . '";'; + exit; + } +} + +// 检查登录状态 +$isLoggedIn = isset($dt['Data']['User']['Nickname']) && $dt['Data']['User']['Nickname'] !== '点击登录'; + +function getCommunityData() { + $baseUrl = "http://nlm-api-cn.turtlesim.com/"; + + // 准备请求数据 + $requestData = [ + 'Identifier' => 'Library', + 'Language' => "Chinese" + ]; + + // 准备请求头 + $headers = [ + 'Content-Type: application/json', + 'Accept: application/json', + 'Accept-Language: zh-CN', + ]; + + // 添加认证头(修复了多余的大括号) + $headers[] = 'x-API-Token: ' . $_SESSION['token']; + $headers[] = 'x-API-AuthCode: ' . $_SESSION['authCode']; + + // 发送POST请求 + $url = $baseUrl . 'Contents/GetLibrary'; + + $ch = curl_init(); + curl_setopt_array($ch, [ + CURLOPT_URL => $url, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => json_encode($requestData, JSON_UNESCAPED_UNICODE), + CURLOPT_HTTPHEADER => $headers, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_TIMEOUT => 30, + ]); + + $response = curl_exec($ch); + curl_close($ch); + $data = json_decode($response, true); + return $data; +} + +// 处理日期格式 +function formatDate($id) { + return (strlen($id) >= 8) ? date('m/d', hexdec(substr($id, 0, 8)) * 1000 / 1000) : '未知日期'; +} + +// 获取数据 +$communityData = getCommunityData(); + +// 模块配置 +$modules = [ + ['title' => '每日模型', 'count' => 4, 'featured' => false, 'type' => 'explore', 'category' => 'Model'], + ['title' => '最新模型', 'count' => 4, 'featured' => false, 'type' => 'featured', 'category' => 'Model'], + ['title' => '生物学', 'count' => 4, 'featured' => false, 'type' => 'daily', 'category' => 'Model'], + ['title' => '地球科学', 'count' => 4, 'featured' => false, 'type' => 'hot', 'category' => 'Model'], + ['title' => '艺术', 'count' => 4, 'featured' => false, 'type' => 'new', 'category' => 'Model'], + ['title' => '化学', 'count' => 4, 'featured' => false, 'type' => 'visual', 'category' => 'Model'], + ['title' => '物理学', 'count' => 4, 'featured' => false, 'type' => 'explore', 'category' => 'Model'], + ['title' => '数学', 'count' => 4, 'featured' => false, 'type' => 'featured', 'category' => 'Model'], + ['title' => '社会科学', 'count' => 4, 'featured' => false, 'type' => 'daily', 'category' => 'Model'], + ['title' => '游戏', 'count' => 4, 'featured' => false, 'type' => 'new', 'category' => 'Model'] +]; +?> + + + + + + Turtle Universe Web - Model Library + + + + +
+

模型图书馆

+
+ +
+ + +
+ $module): ?> + + +
+
+
+ + +
+ <?= htmlspecialchars($subject) ?> +
+
+
-
+ +
+ + + +
+ +
+
+ +
+
+ +
+
+ + +
+ +
+

无法加载社区数据,请检查网络连接或稍后重试

+ +
+ +
+ + + + + + From b99aafca79fb175abf76b0b07152ab0c01017867 Mon Sep 17 00:00:00 2001 From: Tiaotiao <65841827@qq.com> Date: Fri, 5 Dec 2025 20:35:41 +0800 Subject: [PATCH 3/4] Update image source and footer links in index.php --- index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 60a1648..6b63a84 100644 --- a/index.php +++ b/index.php @@ -92,7 +92,7 @@ function formatDate($id) { $author = $exp['User']['Nickname'] ?? '未知作者'; $date = formatDate($exp['ID'] ?? ''); $tags = $exp['Tags'] ?? []; - $imgSrc = 'http://netlogo-static-cn.turtlesim.com/experiments/images/' . + $imgSrc = 'http://netlogo-cn.oss-cn-hongkong.aliyuncs.com/experiments/images/' . substr($exp['ID'] ?? '0000000000000000', 0, 4) . '/' . substr($exp['ID'] ?? '0000000000000000', 4, 2) . '/' . substr($exp['ID'] ?? '0000000000000000', 6, 2) . '/' . @@ -133,8 +133,8 @@ function formatDate($id) { From 2a3fb7fad9812663bcee7d9160aeea48231ba2ef Mon Sep 17 00:00:00 2001 From: Tiaotiao <65841827@qq.com> Date: Fri, 5 Dec 2025 20:36:26 +0800 Subject: [PATCH 4/4] Update category display in med.php --- med.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/med.php b/med.php index e09d144..f12fc52 100644 --- a/med.php +++ b/med.php @@ -133,7 +133,7 @@ function formatDate($timestamp) {
- +