From 0bff0e35d0a26244e3564f15e3aac6f5cb60e657 Mon Sep 17 00:00:00 2001 From: dirk1983 Date: Tue, 6 Jun 2023 15:56:33 +0800 Subject: [PATCH] Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 首页增加cookie保存输入的key,日志文件保存成php格式,防止游客查看 --- chat.txt | 4 ---- chatlog.php | 1 + index.php | 18 +++++++++++++++++- stream.php | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) delete mode 100644 chat.txt create mode 100644 chatlog.php diff --git a/chat.txt b/chat.txt deleted file mode 100644 index 7b0db87..0000000 --- a/chat.txt +++ /dev/null @@ -1,4 +0,0 @@ -127.0.0.1 | 2023-03-08 10:37:47 -Q:你好 -A:你好!有什么我可以帮助你的吗? ----------------- diff --git a/chatlog.php b/chatlog.php new file mode 100644 index 0000000..a30288c --- /dev/null +++ b/chatlog.php @@ -0,0 +1 @@ + diff --git a/index.php b/index.php index e387627..8349fec 100644 --- a/index.php +++ b/index.php @@ -227,6 +227,22 @@ $type = "个人"; } }); + - + \ No newline at end of file diff --git a/stream.php b/stream.php index b86b6d4..be98a2e 100644 --- a/stream.php +++ b/stream.php @@ -108,6 +108,6 @@ foreach ($responsearr as $msg) { $questionarr = json_decode($postData, true); $filecontent = $_SERVER["REMOTE_ADDR"] . " | " . date("Y-m-d H:i:s") . "\n"; $filecontent .= "Q:" . end($questionarr['messages'])['content'] . "\nA:" . trim($answer) . "\n----------------\n"; -$myfile = fopen(__DIR__ . "/chat.txt", "a") or die("Writing file failed."); +$myfile = fopen(__DIR__ . "/chatlog.php", "a") or die("Writing file failed."); fwrite($myfile, $filecontent); fclose($myfile);