Skip to content

Instantly share code, notes, and snippets.

@ianthrive
Last active May 2, 2020 16:48
Show Gist options
  • Save ianthrive/3918260 to your computer and use it in GitHub Desktop.
Save ianthrive/3918260 to your computer and use it in GitHub Desktop.
Directory listing of file repository on bluffdale.com
if(is_dir($currentPath)) {
?><table class="file-list"><?
$scan = scandir($currentPath);
array_shift($scan);
array_shift($scan);
foreach($scan as $name) {
if($name[0] != '.' && $name[0] != '_') {
$path = $currentPath.'/'.$name;
$icon = 'unknown';
if(is_dir($path)) {
$link = $scriptName.$pathInfo.'/'.$name;
$icon = 'dir';
} else if(is_file($path)) {
$link = dirname($scriptName).'/download.php'.$pathInfo.'/'.$name;
$extension = explode('.', basename($name));
$extension = $extension[count($extension)-1];
switch($extension) {
case 'pdf':
$icon = 'pdf'; break;
case 'xls':
case 'xlsx':
$icon = 'xls'; break;
case 'doc':
case 'docx':
$icon = 'doc'; break;
case 'jpg':
case 'png':
case 'gif':
case 'jpeg':
case 'tif':
case 'tiff':
case 'bmp':
$icon = 'image'; break;
case 'txt':
case 'rtf':
$icon = 'text'; break;
case 'ppt':
$icon = 'ppt'; break;
case 'mov':
case 'wmv':
case 'mp4':
case 'm4v':
$icon = 'movie'; break;
}
}
$stat = stat($path);
?><tr>
<td><img src="/_assets/images/icons/<?= $icon ?>.png"></td>
<td><a href="<?= $link ?>"><?= $name ?></a></td>
<td style="text-align: right; padding-left: 25px;"><?= date('d M Y', $stat['mtime']) ?></td>
<td style="text-align: right; padding-left: 25px;"><?= number_format($stat['size']/1000/1000, 2) ?>MB</td>
</tr><?
}
}
?></table><?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment