Skip to content

Commit 5b77b74

Browse files
committed
Enhance ordering and avoid try get broken symlink
1 parent 2d79174 commit 5b77b74

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/functions.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@
116116
usort($paths, function ($path1, $path2) {
117117
$order_by = $_GET['order_by'];
118118

119-
$path1['mTime'] = strtotime($path1['mTime']);
120-
$path2['mTime'] = strtotime($path2['mTime']);
121-
122119
if ($path1[$order_by] === $path2[$order_by])
123120
{
124121
return 0;
@@ -133,5 +130,15 @@
133130
$paths = array_reverse($paths);
134131
}
135132

133+
$count = count($paths);
134+
135+
for ($i = 0; $i < $count; $i++)
136+
{
137+
$paths[$i]['mTime'] = date('Y-m-d H:i:s', $paths[$i]['mTime']);
138+
$paths[$i]['size'] = strpos($paths[$i]['size'], 'item') !== false
139+
? $paths[$i]['size']
140+
: $GLOBALS['function_size_conversion']($paths[$i]['size']);
141+
}
142+
136143
return $paths;
137144
};

src/server_router.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@
107107

108108
foreach ($filesystem as $pathname => $SplFileInfo)
109109
{
110+
if (! file_exists($SplFileInfo->getRealPath()))
111+
{
112+
continue;
113+
}
114+
110115
if ($SplFileInfo->isDir())
111116
{
112117
$fi = new FilesystemIterator($SplFileInfo->getRealPath());
@@ -117,11 +122,11 @@
117122
'realPath' => $SplFileInfo->getRealPath(),
118123
'filename' => $SplFileInfo->getFilename(),
119124
'isDir' => $SplFileInfo->isDir(),
120-
'size' => $SplFileInfo->isDir() ? iterator_count($fi) . ' items' : $function_size_conversion($SplFileInfo->getSize()),
125+
'size' => $SplFileInfo->isDir() ? iterator_count($fi) . ' items' : $SplFileInfo->getSize(),
121126
'owner' => $SplFileInfo->getOwner(),
122127
'group' => $SplFileInfo->getGroup(),
123128
'perms' => substr(sprintf('%o', $SplFileInfo->getPerms()), -4),
124-
'mTime' => date('Y-m-d H:i:s', $SplFileInfo->getMTime()),
129+
'mTime' => $SplFileInfo->getMTime(),
125130
'href' => $function_path_href($SplFileInfo),
126131
];
127132
}

0 commit comments

Comments
 (0)