Add detection of directory write permission

This commit is contained in:
printempw 2017-06-30 11:23:26 +08:00
parent b6506e2776
commit f4dc8cbcf9
2 changed files with 13 additions and 1 deletions

View File

@ -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 <br>".
"[错误] 程序缺少对 $dir 目录的写权限或目录不存在,请手动授权/创建"
);
}
}
}
}

View File

@ -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