首页增加cookie保存输入的key,日志文件保存成php格式,防止游客查看
pull/99/head
dirk1983 4 years ago
parent ff5688f59c
commit 0bff0e35d0

@ -1,4 +0,0 @@
127.0.0.1 | 2023-03-08 10:37:47
Q:你好
A:你好!有什么我可以帮助你的吗?
----------------

@ -0,0 +1 @@
<?php header('HTTP/1.1 404 Not Found');exit; ?>

@ -227,6 +227,22 @@ $type = "个人";
} }
}); });
</script> </script>
<script>
if ($('#key').length) {
$(document).ready(function() {
var key = $.cookie('key');
if (key) {
$('#key').val(key);
}
$('#key').on('input', function() {
var inputVal = $(this).val();
$.cookie('key', inputVal, {
expires: 365
});
});
});
}
</script>
</body> </body>
</html> </html>

@ -108,6 +108,6 @@ foreach ($responsearr as $msg) {
$questionarr = json_decode($postData, true); $questionarr = json_decode($postData, true);
$filecontent = $_SERVER["REMOTE_ADDR"] . " | " . date("Y-m-d H:i:s") . "\n"; $filecontent = $_SERVER["REMOTE_ADDR"] . " | " . date("Y-m-d H:i:s") . "\n";
$filecontent .= "Q:" . end($questionarr['messages'])['content'] . "\nA:" . trim($answer) . "\n----------------\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); fwrite($myfile, $filecontent);
fclose($myfile); fclose($myfile);

Loading…
Cancel
Save