summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php20
1 files changed, 16 insertions, 4 deletions
diff --git a/index.php b/index.php
index a27b5f0..dcf9a39 100644
--- a/index.php
+++ b/index.php
@@ -52,6 +52,13 @@ function classify($root, $dirname, $filename) {
if ($filename === '..') { return [ [ 'dir', 'parent' ], $stat]; }
$classes = array();
+
+ if (stat_is_link($stat)) {
+ $classes[] = 'link';
+ $lstat = $stat;
+ $stat = stat($filepath);
+ }
+
if ($parts == 0) {
// in the top-level
if (stat_is_dir($stat) && is_dir($filepath.'/os')) {
@@ -70,7 +77,6 @@ function classify($root, $dirname, $filename) {
}
}
if ($filename[0] === '.' || substr($filename, -1) === '~') { $classes[] = 'hidden'; }
- if (stat_is_link($stat)) { $classes[] = 'link'; }
if (stat_is_dir( $stat)) { $classes[] = 'dir'; }
if (stat_is_file($stat)) { $classes[] = 'file'; }
@@ -78,6 +84,9 @@ function classify($root, $dirname, $filename) {
if (preg_match("/\.tar(\..z|\.bz2)?$/", $filename) == 1) { $classes[] = 'tar'; }
$classes[] = pathinfo($filename, PATHINFO_EXTENSION);
+ if (isset($lstat)) {
+ $stat = $lstat;
+ }
return [ $classes, $stat ];
}
@@ -143,11 +152,14 @@ if (!is_dir($root.'/'.$dirname)) {
if ($filename === '..' && is_root($root,$dirname)) { continue; }
list($classes, $stat) = classify($root, $dirname, $filename);
echo "\t\t\t\t<tr class=\"".implode(' ', $classes)."\">";
+
+ echo "<td>";
+ echo "<a href=\"".htmlentities($filename)."\">".htmlentities($filename)."</a>";
if (stat_is_link($stat)) {
- echo "<td><a href=\"".htmlentities($filename)."\">".htmlentities($filename)."</a> -> ".htmlentities(readlink($root.'/'.$dirname.'/'.$filename))."</td>";
- } else {
- echo "<td><a href=\"".htmlentities($filename)."\">".htmlentities($filename)."</a></td>";
+ $target = readlink($root.'/'.$dirname.'/'.$filename);
+ echo " -&gt; <a href=\"".htmlentities($target)."\">".htmlentities($target)."</a>";
}
+ echo "</td>";
if ($filename === '..') {
echo '<td></td><td></td>';