Fix realppath not working when does not exist

This commit is contained in:
Bofh 2022-12-29 00:19:35 +01:00
parent 5eae25fec6
commit 15487b57f2
1 changed files with 6 additions and 1 deletions

View File

@ -177,7 +177,12 @@ function filedb_exists($ns, $file=''){ return file_exists(filedb_getdir($ns,$fil
function filedb_getdir($ns, $file='') { function filedb_getdir($ns, $file='') {
$dir = $GLOBALS['appconf']['data_dir']; $dir = $GLOBALS['appconf']['data_dir'];
$ns = trim($ns, '/'); $ns = trim($ns, '/');
$dir = realpath($dir.'/'.$ns); $_ = realpath($dir.'/'.$ns);
if ($_ === false) {
mkdir($dir.'/'.$ns);
$_ = realpath($dir.'/'.$ns);
}
$dir = $_;
if (strpos($dir, $GLOBALS['appconf']['data_dir']) === false) if (strpos($dir, $GLOBALS['appconf']['data_dir']) === false)
return false; return false;
return $dir.'/'.$file; return $dir.'/'.$file;