Update policy of checking environment

This commit is contained in:
Pig Fang 2019-09-10 21:10:27 +08:00
parent e38d74455c
commit 21c28c8b1c
2 changed files with 6 additions and 17 deletions

View File

@ -45,23 +45,18 @@
foreach ($requirements['write_permission'] as $dir) { foreach ($requirements['write_permission'] as $dir) {
$realPath = realpath(__DIR__."/../$dir"); $realPath = realpath(__DIR__."/../$dir");
if (! file_exists($realPath)) { if (! is_writable($realPath)) {
die_with_utf8_encoding( die_with_utf8_encoding(
"[Error] The directory < $dir > does not exist <br>". "[Error] The directory '$dir' is not writable. <br>".
"[错误] 目录 < $dir > 不存在,请在程序根目录下手动创建" "[错误] 目录 '$dir' 不可写,请检查该目录的权限"
); );
} }
if (! is_writable($realPath)) { if (! is_writable($realPath)) {
die_with_utf8_encoding( die_with_utf8_encoding(
"[Error] The program lacks write permission to directory < $dir > <br>". "[Error] The program lacks write permission to directory '$dir' <br>".
"[错误] 程序缺少对 < $dir > 目录的写权限,请手动授权。" "[错误] 程序缺少对 '$dir' 目录的写权限,请手动授权。"
); );
} }
} }
$autoload = file_get_contents(__DIR__.'/../vendor/autoload.php');
$lines = explode("\n", $autoload);
$lines[1] = '$GLOBALS["env_checked"] = true;';
file_put_contents(__DIR__.'/../vendor/autoload.php', implode("\n", $lines));
})(); })();

View File

@ -1,17 +1,11 @@
<?php <?php
/**
* Entrance of Blessing Skin Server.
*
* @author printempw <h@prinzeugen.net>
*/
@ini_set('display_errors', 'on'); @ini_set('display_errors', 'on');
require __DIR__.'/../bootstrap/autoload.php'; require __DIR__.'/../bootstrap/autoload.php';
if (! isset($GLOBALS['env_checked'])) { if (! file_exists(__DIR__.'/../storage/install.lock')) {
require __DIR__.'/../bootstrap/chkenv.php'; require __DIR__.'/../bootstrap/chkenv.php';
} }
// Process the request
require __DIR__.'/../bootstrap/kernel.php'; require __DIR__.'/../bootstrap/kernel.php';