diff --git a/README.md b/README.md index a518a20..32e4628 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,9 @@ feedback/ 2. 确认该站点使用的 PHP 版本 **≥ 7.4**(推荐 8.1~8.5;**8.5 已逐项实测,无弃用告警**),并已启用扩展: **pdo_sqlite、sqlite3、openssl、mbstring**(宝塔默认均已有;在「软件商店 → PHP → 安装扩展」可查看)。 **curl 为可选**:有则优先用它和 OSS 通信,没有会自动退回 PHP 内置的流式请求,功能不受影响。 + **fileinfo 为推荐**:开启后上传时按文件**真实内容**判断类型(`finfo`); + 没有也能正常用,但类型校验会退化为「扩展名 + 浏览器声明的 MIME」。 + ⚠️ 新装一套 PHP(尤其宝塔里的 8.5)时 `fileinfo` 常常**默认没开**,从旧版本切过来要顺手检查一次。 3. 给数据库目录写权限(宝塔一般已允许): ```bash chown -R www:www /www/wwwroot/你的域名/feedback diff --git a/install.php b/install.php index 584d95b..c4431fc 100644 --- a/install.php +++ b/install.php @@ -33,7 +33,16 @@ $already = fb_installed(); * ================================================================== */ function fb_install_checks() { $need = ['pdo_sqlite' => 'SQLite 数据库(PDO)', 'openssl' => 'SMTP / OSS 加密通信']; - $opt = ['curl' => '访问 OSS(可选,没有会退回 PHP 流式请求)', 'mbstring' => '中文字数统计(可选)']; + // 可选扩展:值是说明字符串;也可写成 [说明, 缺失时的状态文案, 缺失时的补救提示] + $opt = [ + 'curl' => '访问 OSS(可选,没有会退回 PHP 流式请求)', + 'mbstring' => '中文字数统计(可选)', + 'fileinfo' => [ + '上传文件的真实类型识别(推荐开启)', + '未启用(仍可用,但上传类型只按扩展名核对)', + '建议在 PHP 设置里开启 fileinfo,上传校验会更严格', + ], + ]; $dirs = [ FB_ROOT => '站点根目录(要写入 config.php)', @@ -54,8 +63,15 @@ function fb_install_checks() { $rows[] = ['PHP 扩展:' . $ext, $has ? '已启用' : '未启用', $has, $why, $has ? '' : ('请在 PHP 设置里开启 ' . $ext . ' 扩展')]; } foreach ($opt as $ext => $why) { + $note = '未启用(不影响安装)'; + $hint = ''; + if (is_array($why)) { + $note = isset($why[1]) ? $why[1] : $note; + $hint = isset($why[2]) ? $why[2] : ''; + $why = isset($why[0]) ? $why[0] : ''; + } $has = extension_loaded($ext); - $rows[] = ['PHP 扩展:' . $ext, $has ? '已启用' : '未启用(不影响安装)', true, $why, '']; + $rows[] = ['PHP 扩展:' . $ext, $has ? '已启用' : $note, true, $why, $has ? '' : $hint]; } foreach ($dirs as $d => $why) {