Built-in File Manager (#458)

This commit is contained in:
Saeed Vaziry
2025-02-16 19:56:21 +01:00
committed by GitHub
parent 75e554ad74
commit e2b9d18a71
17 changed files with 907 additions and 29 deletions

View File

@ -178,3 +178,31 @@ function get_from_route(string $modelName, string $routeKey): mixed
return null;
}
function absolute_path(string $path): string
{
$parts = explode('/', $path);
$absoluteParts = [];
foreach ($parts as $part) {
if ($part === '' || $part === '.') {
continue; // Skip empty and current directory parts
}
if ($part === '..') {
array_pop($absoluteParts); // Move up one directory
} else {
$absoluteParts[] = $part; // Add valid directory parts
}
}
return '/'.implode('/', $absoluteParts);
}
function home_path(string $user): string
{
if ($user === 'root') {
return '/root';
}
return '/home/'.$user;
}