mirror of
https://github.com/YGGverse/next.git
synced 2026-03-31 17:55:34 +00:00
implement directory listing navigation
This commit is contained in:
parent
c8bd899811
commit
1723cd3ed1
1 changed files with 33 additions and 14 deletions
47
src/nex.php
47
src/nex.php
|
|
@ -220,11 +220,28 @@ $server->start(
|
||||||
|
|
||||||
foreach ((array) scandir($goal) as $link)
|
foreach ((array) scandir($goal) as $link)
|
||||||
{
|
{
|
||||||
// Skip hidden entities and make sure the destination is accessible
|
// Skip system entities
|
||||||
if (!str_starts_with($link, '.') && is_readable($goal . $link))
|
if (str_starts_with($link, '.'))
|
||||||
{
|
{
|
||||||
// Directory
|
// Keep parent navigation entities only
|
||||||
if (is_dir($link))
|
if ($link == '..' && $parent = realpath($goal . $link))
|
||||||
|
{
|
||||||
|
if (str_starts_with($parent . DIRECTORY_SEPARATOR, NEXT_PATH))
|
||||||
|
{
|
||||||
|
if (is_readable($parent))
|
||||||
|
{
|
||||||
|
$links[] = '=> ../';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Directory
|
||||||
|
if (is_dir($goal . $link))
|
||||||
|
{
|
||||||
|
if (is_readable($goal . $link))
|
||||||
{
|
{
|
||||||
$links[] = sprintf(
|
$links[] = sprintf(
|
||||||
'=> %s/',
|
'=> %s/',
|
||||||
|
|
@ -234,16 +251,18 @@ $server->start(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// File
|
continue;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
$links[] = sprintf(
|
// File
|
||||||
'=> %s',
|
if (is_readable($goal . $link))
|
||||||
urlencode(
|
{
|
||||||
$link
|
$links[] = sprintf(
|
||||||
)
|
'=> %s',
|
||||||
);
|
urlencode(
|
||||||
}
|
$link
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue