From d79bbeefc8a626956544d57102f654463d10c05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=85=E6=B2=BB=E6=98=8E=E5=8D=83=E6=A0=91=E6=B1=90?= Date: Sat, 3 Sep 2022 04:08:07 +0800 Subject: [PATCH] fix: the initial database is empty --- Public/index.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Public/index.php b/Public/index.php index f0d0196..8d127d2 100644 --- a/Public/index.php +++ b/Public/index.php @@ -27,23 +27,6 @@ $helper = new GlobalHelper($database); -/** - * 初始参数 - */ -// 程序版本 -define('VERSION', '0.1.0'); -// 关闭 PHP 警告提示 -if (DEBUG_MODE === false) { - error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED); -} -// 设置 PHP 超时时限 -ini_set('max_execution_time', 60); -// 设置 Contect-Type 请求头为 text/html -header('Content-Type: text/html; charset=utf-8'); -// 获取控制器,并使用二进制安全的方式剥去字符串左右的空白与其中的 HTML 标签 -$controller = empty($_GET['c']) ? 'Index' : htmlspecialchars(trim($_GET['c'])); - - /** * 载入配置文件 */ @@ -53,7 +36,7 @@ exit(); } // 检查数据库是否存在,不存在则复制数据库 -if (!file_exists('../Data/Database.db3')) { +if (!file_exists('../Data/Database.db3') || filesize('../Data/Database.db3') === 0) { if (!copy('../Data/Database.sample.db3', '../Data/Database.db3')) { exit('数据库初始化失败,请检查 Data 目录是否拥有写入权限!'); } @@ -61,6 +44,23 @@ require_once('../Data/Config.php'); +/** + * 初始参数 + */ +// 程序版本 +define('VERSION', '0.1.1'); +// 关闭 PHP 警告提示 +if (DEBUG_MODE === false) { + error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED); +} +// 设置 PHP 超时时限 +ini_set('max_execution_time', 60); +// 设置 Contect-Type 请求头为 text/html +header('Content-Type: text/html; charset=utf-8'); +// 获取控制器,并使用二进制安全的方式剥去字符串左右的空白与其中的 HTML 标签 +$controller = empty($_GET['c']) ? 'Index' : htmlspecialchars(trim($_GET['c'])); + + /** * 根据请求载入控制器 */