4 if (isset($_GET['download']))
6 header('Content-Disposition: filename=' . basename($_GET['download']));
7 header('Content-Type: ' . finfo_file(finfo_open(FILEINFO_MIME_TYPE
), $_GET['download']));
8 header('Content-Length: ' . filesize($_GET['download']));
9 readfile($_GET['download']);
13 $path = isset($_GET['path']) ?
$_GET['path'] : '';
17 <title
><?
= htmlentities('/' . $path) ?
></title
>
21 font
-family
: monospace
;
28 border
-top
: 1px solid
#c0c0c0;
29 border
-left
: 1px solid
#c0c0c0;
35 border
-bottom
: 1px solid
#c0c0c0;
36 border
-right
: 1px solid
#c0c0c0;
37 background
-color
: #fafafa;
43 border
-bottom
: 1px solid
#e0e0e0;
45 table tr td
:last
-child
47 border
-right
: 1px solid
#c0c0c0;
51 background
-color
: #fafafa;
62 display
: inline
-block
;
68 display
: inline
-block
;
69 vertical
-align
: text
-top
;
76 background
-image
: url(data
:image
/png
;base64
,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8
/9hAAAAB3RJTUUH4QodCzgDe8z3xAAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L
/GEFAAABI0lEQVR4nI2SXU7CQBSFuwQ2ZWulhFe3Ywyg0WAwRqPBQHQhBBUFFKtLMCmd
/qCAz8bjvYM0GQvOTHJyn75vOr3Hsn7P52sJ8xcPc9
/DjPPsYToqLvJUxMfjlsz7kDJwfevvYRjpNeWK0gaSFuWS0gTiC8o5EJ1RTjEZuMgLfM8IRnSCSX+FYCYFehjiGOlKAb3ZBIZoIH3YzAv4Z5nAEEdI7tcK9DDC+hoBrcoERniIpOfkBbxjE
/g7qCG+cxD3nEJeoIERHlCptmmNZZZ0FAE3TAdjvC9v
/3rbkVMVULt0MMZ7iG7tbCoCrqcORlBFdGNnUxX0XS2MoAIhBYupCFIp+B9GsAvRtbOpCqieXBAZ2rNcFYXfyp
/LNzIUdjeWc8rcDwr4lpMPISwtAAAAAElFTkSuQmCC
);
80 background
-image
: url(data
:image
/png
;base64
,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8
/9hAAAABGdBTUEAALGPC
/xhBQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAAAd0SU1FB+EKHQs4A3vM98QAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTczbp9jAAABrklEQVQ4T42STUsCURSG5yf0YyJo16bMNNq2NoKglf2DCvugKIookkLRPjHFDLGkkCm17MuKoEVtAnVGrcw2bqK3e46aDCrNhZdz53Ke95x77kjV9XXfi+KdGcWkGZ+kWzMKN6ayrk34uOphvV8KJYzJClZbBCPvFnIJOYGcQ2hdaA3I2oVWAXVFaBlvCSMqWG1RZT0w1CW8XTQwoLb1wFAWkW9oIO6sB4aygPx5d70BDUsPDGUeuXhTg
/9hZOaaGIin0gMjM4tczFAziMfjiEajkGUZkUgEJ8fHCIfDOAyFEAwG6+Cf1CSyUQOyMUMLGxBcKpUa6iAQ0MDIzIifql88Yx+ZRNiAKlPy44uKTusu2oc2WHS27
/drYKSnufr36yhHNqC2qxVHFsNoG3Sw6Nvn9WpgpKegnnX9RTagO1PytPsUrRY7rAshdAw7+WzP49HASE1APRUGlcgGNDBKHrD50DPi4v3Dc5rj7s6OBkbKBoUNypENaNqUfHT+BMuYh
/dVbW9uaWCkxqHIZFCObEBPRdOmgdGdqW2qTPCm2813pXapIkEZubMaC5IkSb+J6cYCnt4GFAAAAABJRU5ErkJggg
==);
84 background
-image
: url(data
:image
/png
;base64
,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8
/9hAAAAB3RJTUUH4QodCh4FULO74gAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L
/GEFAAABVklEQVR4nI2TSXLCMBBFOVJumITBYTCBQMCAYwgEuBE+BBtWWJZkV0dfnrA7i6jqL99rqbvVauXndDrRz
/FIh8OB9vs97XbftN1u6SsIyPd9Wm82FATBbel5T62
/DuA0TcskSFLlfD5TGIa08f3b
/HPBJagMUGlNSmmSSpGUiuI8EFyvV7pcLuSt1jcmwLWtoIBrAmkFruvaTGczYgK8GQIOZ4I4liRMtE5oMv3gAjQsKQQ1WJVwIRhPJlyAbqNZDJYVLOLYCtzxOxdgVBA04fgBjkQmGLljLsCcM4FsgHlEJRgMR1ywWq2NIOGgqVzAmUBTfzDkArNhpI2gCUcPcBQJuydOv88Fi+UyE4h6xSJ3A99zQc954wKznvZ9TTASooQLQafncMFsPq8Lojr4KGh3u1yA9bT
/4B95aXe4AOuJDcOSYM4YFbqNhuHNuDYqA35+bZeCXx4hpVjDFh23AAAAAElFTkSuQmCC
);
91 <th
><div
class="spacer" style
="width: 10px;"></div
>Name
</th
>
92 <th align
="right">Size
</th
>
100 print('<td colspan="6"><a href="?path=' . urlencode(($path == '' ?
'' : $path . '/') . '..') . '" title="Attempt directory traversal attack by adding \'..\' to the path (recommended when in top level directory)"><div class="spacer" style="width: 10px;"></div>');
101 print('<div class="icon icon-dir"></div>Traverse ..</a></td>');
106 foreach (array_merge([ '.' ], explode('/', $path)) as $tree)
110 $fullTree = ($fullTree == '' ?
'' : $fullTree . '/') . ($tree == '.' ?
'' : $tree);
113 print('<td colspan="6"><a href="?path=' . urlencode($fullTree) . '"><div class="spacer" style="width: ' . $treeDepth . 'px;"></div>');
114 print('<div class="icon icon-' . (is_link($fullTree) ?
'link' : 'dir') . '"></div>' . ($tree != '.' && str_replace('/', '', str_replace('.', '', $tree)) == '' ?
'<Up>' : htmlentities($tree)) . '</a></td>');
118 $spacerHtml = '<div class="spacer" style="width: ' . ($treeDepth +
10) . 'px;"></div>';
123 $directoryPath = $path == '' ?
'.' : $path;
124 if (is_dir($directoryPath))
126 foreach ([ 'dir', 'file' ] as $type)
128 foreach (array_diff(scandir($directoryPath), [ '.', '..' ]) as $file)
130 $fullPath = ($path == '' ?
'' : $path . '/') . $file;
131 if ($type == 'dir' ^
is_file($fullPath))
133 $link = urlencode($fullPath);
138 print('<td><a href="?path=' . $link . '">' . $spacerHtml . '<div class="icon icon-' . (is_link($fullPath) ?
'link' : 'dir') . '"></div>' . htmlentities($file) . '</a></td>');
139 print('<td align="right"></td>');
144 print('<td><a href="?download=' . $link . '">' . $spacerHtml . '<div class="icon icon-file"></div>' . htmlentities($file) . '</a></td>');
145 print('<td align="right">' . number_format(filesize($fullPath), 0, '', '.') . '</td>');
147 print('<td>' . date('d.m.Y H:i:s', @filemtime
($fullPath)) . '</td>');
148 print('<td>' . GetFilePermissions($fullPath) . '</td>');
149 print('<td>' . (function_exists('posix_getpwuid') ?
posix_getpwuid(fileowner($fullPath))['name'] : fileowner($fullPath)) . '</td>');
150 print('<td>' . (function_exists('posix_getpwuid') ?
posix_getpwuid(filegroup($fullPath))['name'] : filegroup($fullPath)) . '</td>');
159 print('<td colspan="6">Directory \'' . htmlentities('/' . $path) . '\' not found.</td>');
164 <th colspan
="6"><?
= $directorycount ?
> directories
, <?
= $fileCount ?
> files
</th
>
170 function GetFilePermissions($path)
172 $permissions = @fileperms
($path);
174 for ($i = 0, $perm = 0x100; $i < 9; $i++
, $perm >>= 1)
176 $result .= $permissions & $perm ?
'rwx'[$i %
3] : '-';