From f4dc8cbcf9f6127ca143c243f47432933b54e493 Mon Sep 17 00:00:00 2001 From: printempw Date: Fri, 30 Jun 2017 11:23:26 +0800 Subject: [PATCH] Add detection of directory write permission --- app/helpers.php | 11 +++++++++++ index.php | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/helpers.php b/app/helpers.php index b73d3572..ca1955e6 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -404,5 +404,16 @@ if (! function_exists('runtime_check')) { ); } } + + foreach (array_get($requirements, 'write_permission', []) as $dir) { + $realPath = realpath(__DIR__."/../$dir"); + + if (!is_writable($realPath)) { + exit( + "[Error] The program lacks write permission to directory $dir
". + "[错误] 程序缺少对 $dir 目录的写权限或目录不存在,请手动授权/创建" + ); + } + } } } diff --git a/index.php b/index.php index 93e8c448..4c05b3f3 100755 --- a/index.php +++ b/index.php @@ -21,7 +21,8 @@ require __DIR__.'/bootstrap/autoload.php'; // check the runtime environment runtime_check(array( - 'extensions' => array('pdo_mysql', 'openssl', 'gd', 'mbstring', 'tokenizer') + 'extensions' => array('pdo_mysql', 'openssl', 'gd', 'mbstring', 'tokenizer'), + 'write_permission' => array('storage', 'resources', 'plugins') )); // handle the request