新建一次合并、继续重构
This commit is contained in:
9
public/blog/master/index.html
Executable file
9
public/blog/master/index.html
Executable file
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" lang="zh-CN">
|
||||
<title>master 页面</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="./push.php">跳转建立索引</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +0,0 @@
|
||||
{2025/07/30};{"第一篇文章"}
|
||||
@@ -1,27 +1,27 @@
|
||||
<?php
|
||||
|
||||
// 1. 定义要写入的文件路径
|
||||
$file = './index.txt';
|
||||
$file = '../../../databases/no_db/post.text';
|
||||
|
||||
// 2. 检查是否通过 POST 请求接收到了数据
|
||||
// 'data' 是表单中 <textarea> 标签的 name 属性
|
||||
if (isset($_POST['data']) && !empty($_POST['data'])) {
|
||||
|
||||
// 自动获取当前日期和时间
|
||||
|
||||
// 自动获取当前日期
|
||||
$date = date('Y/m/d');
|
||||
|
||||
// 获取你在网页输入框中写的数据
|
||||
$data = $_POST['data'];
|
||||
|
||||
// 3. 构建完整的单行内容,格式为 {日期};{数据},并以换行符 \n 结尾
|
||||
$content = "{" . $date . "};" . "{" . '"' . $data . '"' . "}" . "\n";
|
||||
// 3. 构建完整的单行内容
|
||||
// 使用 PHP_EOL 常量确保正确的换行符
|
||||
$content = "{" . $date . "};" . "{" . '"' . $data . '"' . "}" . ";" . PHP_EOL;
|
||||
|
||||
// 4. 将内容追加到文件末尾
|
||||
$result = file_put_contents($file, $content, FILE_APPEND | LOCK_EX);
|
||||
|
||||
// 5. 检查是否写入成功并给出反馈
|
||||
if ($result !== false) {
|
||||
echo "数据已成功写入到 " . $file . " 文件。你可以 <a href='https://open-ww3-project.ww3.tw/blog/master/'>返回</a>。";
|
||||
echo "数据已成功写入到 " . $file . " 文件。你可以 <a href='https://open-ww3-project.ww3.tw/blog/master/push.php'>返回</a>。";
|
||||
} else {
|
||||
echo "写入文件失败,请检查文件权限。";
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
?>
|
||||
<title>master</title>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; padding: 20px; }
|
||||
textarea { width: 400px; height: 150px; }
|
||||
input[type="submit"] { padding: 10px 20px; font-size: 16px; cursor: pointer; }
|
||||
</style>
|
||||
|
||||
|
||||
<form action="post_data.php" method="POST">
|
||||
<textarea name="data" placeholder="在这里输入数据..."></textarea>
|
||||
Reference in New Issue
Block a user