2025.11.02

日志以及文章完善了数据库存储
接下来就是完成上传数据库的前端与后端的融合了

**署名**
SkimrMe

 # 修改部分
 Changes to be committed:
	modified:   public/blog/index.php
	modified:   public/blog/logs.php
	new file:   public/blog/post/index.php
	new file:   public/blog/post/s/index.php
	deleted:    public/blog/read_file.php
	modified:   public/index.php
	deleted:    public/request/posts.php
	deleted:    src/views/index.php
	deleted:    src/views/post.php
	deleted:    src/views/posts.php
This commit is contained in:
2025-11-02 14:54:04 +08:00
parent 7727a97e4a
commit 0c70b66966
10 changed files with 162 additions and 162 deletions

View File

@@ -1,5 +0,0 @@
<?php
require './MD.php';
$md=new MD('114514.md');
$md->output();

View File

@@ -1,35 +0,0 @@
<center>
<h1>
全部文章
</h1>
</center>
<?php
$file = '../databases/no_db/post.text';
$content = file_get_contents($file);
//分割输出内容
$lines = explode("\n",$content);
$sequence_id = 1; // 设定id起始数字
echo "文章如下: ";
// 输出提取到的内容
foreach ($lines as $line) {
if (preg_match('/\{([^}]+)\};\{"([^"]+)\"};/', $line, $matches)) {
$data = $matches[1]; // 提取出数据
$title = $matches[2]; // 提取出标题
echo "<br><br>";
echo "文章顺序ID: " . $sequence_id . "<br>"; // 输出顺序ID
echo "" . $data . "\n";
echo "" . $title . "\n";
echo "<a href='https://ww3.tw/blog/md/post/s/$sequence_id' style='color: black;'> 跳转页面</a>";
//echo '链接 (URL): <a herf="">链接</a>';
$sequence_id++; // 每次循环后顺序ID加1
}
}
//print_r ($lines);

View File

@@ -1,36 +0,0 @@
<?php
// 在文件顶部启动 session
session_start();
if (isset($post_id)) {
$file_path = "../md/" . $post_id . ".md";
if (file_exists($file_path)) {
// 检查是否是重定向后的请求
if (isset($_SESSION['redirected_to_post']) && $_SESSION['redirected_to_post'] == $post_id) {
// 是重定向后的请求,直接显示内容
$content = file_get_contents($file_path);
sleep(2);
unset($_SESSION['redirected_to_post']); // 清除 session 标记,避免影响其他请求
require_once '../md/MD.php';
$md = new MD('../md/' . $post_id . '.md');
// 输出处理后的内容
echo $md->output();
exit();
} else {
$random_string = substr(str_shuffle("a_bc-def_ghij-klmno_-pq-rs_tu-vwxyz-_$&_#12-34-567-8-0"), 0, 16);
// 这是第一次请求,执行重定向
echo "<h2>" . "找到id为" . $post_id . "的文章<br>正在为您跳转" . "</h2>";
$delay = 0.5;
$_SESSION['redirected_to_post'] = $post_id; // 设置 session 标记
header("Refresh: $delay; url=/blog/md/post/s/$post_id#content&$random_string");
exit();
}
} else {
echo "<h2>没有id为" . $post_id . "的文章</h2>";
}
} else {
echo "<h1>抱歉没有找到对应id文章请检查</h1>";
}