From fdeba3dbbfb6d2d666f7a04349314e6f0ae2cf78 Mon Sep 17 00:00:00 2001 From: zhang-pu <69795881+zhang-pu@users.noreply.github.com> Date: Mon, 1 Jun 2026 09:48:36 +0800 Subject: [PATCH] Add files via upload --- CHANGELOG.md | 46 ++++++ LICENSE | 21 +++ README.md | 118 ++++++++++++++ config.php.new | 18 +++ index.php | 18 +++ install.php | 432 +++++++++++++++++++++++++++++++++++++++++++++++++ install.sql | 58 +++++++ 7 files changed, 711 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 config.php.new create mode 100644 index.php create mode 100644 install.php create mode 100644 install.sql diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3169d11 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,46 @@ +# 更新日志 + +所有版本更新记录均在此文件更新。 + +--- + +## [v1.2.0] - 2024-05-31 + +### 定时任务 + 远程备份 + +- ⏰ 完整的定时任务管理(创建/删除/启用/禁用/立即执行) +- ✅ Cron 表达式格式验证(分/时/日/月/周五段校验) +- 💾 远程 rsync 备份(SSH 主机/端口/用户/密钥) +- 🔗 远程连接测试工具(部署前验证连通性) +- 📊 备份统计面板(总数/本地大小/远程大小/磁盘占用) +- 📁 文件管理:浏览/上传/编辑/删除/新建目录/权限显示 +- 🔐 SSL 证书列表(到期天数/状态指示灯) +- 🔄 SSL 单个续期 + 批量续期 +- 🛡️ 自动漏洞修复(每日凌晨3点执行) + +--- + +## [v1.0.0] - 2024-05-31 + +### 首发版本 + +- 🚀 完整的博客系统,包含文章发布、分类管理、评论系统 +- 🎨 双主题支持:Flow(浅色)和 Magine(深色) +- 🔐 安全特性:CSRF 防护、XSS 过滤、bcrypt 密码哈希、评论速率限制 +- 📱 响应式设计,支持移动端访问 +- ✏️ 富文本编辑器,支持 Markdown 快捷键 +- 🛡️ 垃圾评论过滤(蜜罐 + 关键词检测) +- ⚙️ 安装向导,开箱即用 + +--- + +## 待办 + +- [ ] 多 PHP 版本切换 +- [ ] Node.js 支持 +- [ ] nginx 日志查看器 +- [ ] 插件系统 + +--- + +> 关注 GitHub 仓库获取最新更新:https://github.com/tblog-cn/tblog \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4821aa2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 TBlog + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a176867 --- /dev/null +++ b/README.md @@ -0,0 +1,118 @@ +# TBlog + +一个简洁、优雅的开源博客系统,基于 PHP + MySQL 开发。 + +🌐 网址:https://tblog.cn + +--- + +## 特性 + +- ✏️ 富文本编辑器,写作体验流畅 +- 🎨 两套主题可选(Flow 浅色 / Magine 深色) +- 💬 评论系统,支持垃圾评论过滤 +- 📁 分类管理,文章归档 +- 🔐 安全防护:CSRF 防护、XSS 过滤、密码 bcrypt 哈希、评论速率限制 +- 📱 响应式布局,适配移动端 +- 🛠 轻量高效,无需复杂依赖 + +--- + +## 环境要求 + +- PHP >= 7.0 +- MySQL >= 5.6 +- mysqli 扩展 +- PDO 扩展(可选) + +--- + +## 安装 + +### 方式一:向导安装 + +1. 解压源码,上传至网站目录 +2. 访问 `http://你的域名/install.php` +3. 按提示填写数据库信息,完成安装 +4. 初始管理员账号:`admin` / `admin123`(安装后请立即修改) + +### 方式二:手动配置 + +1. 创建数据库(例如 `tblog`) +2. 导入 `install.sql` 建表 +3. 复制并重命名 `config.php.new` 为 `config.php`,填入数据库信息 +4. 通过 SQL 设置管理员密码哈希: + +```sql +INSERT INTO settings (`key`, value) VALUES ('admin_user', 'admin'); +INSERT INTO settings (`key`, value) VALUES ('admin_hash', '$2y$10$YOUR_HASH_HERE'); +``` + +生成哈希:PHP 执行 `echo password_hash('你的密码', PASSWORD_DEFAULT);` + +--- + +## 目录结构 + +``` +tblog/ +├── admin/ 管理后台 +│ ├── assets/ 样式资源 +│ ├── category.php 分类管理 +│ ├── comment.php 评论管理 +│ ├── index.php 管理概览 +│ ├── login.php 登录页 +│ ├── logout.php 退出 +│ ├── post.php 文章管理 +│ └── settings.php 系统设置 +├── include/ 核心类库 +│ ├── db.php 数据库连接 +│ ├── router.php URL 路由 +│ ├── function.common.php +│ ├── function.post.php +│ ├── function.category.php +│ ├── function.comment.php +│ └── HTMLPurifier.simple.php HTML 净化 +├── static/ 静态资源 +├── templates/ 主题模板 +│ ├── flow/ Flow 主题(浅色) +│ └── magine/ Magine 主题(深色) +├── index.php 入口文件 +├── config.php.new 配置文件模板 +├── install.php 安装向导 +└── install.sql 数据库建表脚本 +``` + +--- + +## 管理后台 + +访问 `http://你的域名/admin/`,使用安装时设置的管理员账号登录。 + +--- + +## 主题切换 + +文章可独立选择模板(Flow / Magine),全站默认模板可在后台「设置」中修改。 + +--- + +## 开源协议 + +MIT License + +--- + +## 更新日志 + +详见 [CHANGELOG.md](./CHANGELOG.md) + +--- + +## 问题反馈 + +如有 Bug 或建议,欢迎提交 Issue。 + +--- + +**TBlog** — 简洁而不简单。 \ No newline at end of file diff --git a/config.php.new b/config.php.new new file mode 100644 index 0000000..166d805 --- /dev/null +++ b/config.php.new @@ -0,0 +1,18 @@ +connect_error) { + $error = '数据库连接失败: ' . $mysqli->connect_error; + } else { + // Create database if not exists + $mysqli->query("CREATE DATABASE IF NOT EXISTS `{$_SESSION['db_name']}` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); + $mysqli->select_db($_SESSION['db_name']); + + // Read and execute install.sql + $sql_file = file_get_contents(__DIR__ . '/install.sql'); + $statements = array_filter(array_map('trim', explode(';', $sql_file))); + + foreach ($statements as $statement) { + if (!empty($statement)) { + if (!$mysqli->query($statement)) { + $error = '数据库初始化失败: ' . $mysqli->error; + break; + } + } + } + + if (!$error) { + $success = '数据库连接成功,配置已保存'; + header('Location: ?step=3'); + exit; + } + $mysqli->close(); + } +} + +// Handle step 3 - save config and set admin credentials +if ($step === 3) { + $config_content = "connect_error) { + $admin_user = 'admin'; + $admin_hash = password_hash('admin123', PASSWORD_DEFAULT); + $mysqli->query("INSERT INTO settings (`key`, value) VALUES ('admin_user', 'admin') ON DUPLICATE KEY UPDATE value = 'admin'"); + $mysqli->query("INSERT INTO settings (`key`, value) VALUES ('admin_hash', '$admin_hash') ON DUPLICATE KEY UPDATE value = '$admin_hash'"); + $mysqli->close(); + } + header('Location: ?step=4'); + exit; + } +} + +// Step 5 - completion +if ($step === 5) { + session_destroy(); +} +?> + + +
+ + +一个简洁优雅的博客系统
+ +正在创建 config.php 配置文件...
感谢使用 TBlog
+