27 lines
499 B
Perl
27 lines
499 B
Perl
#!/usr/bin/perl
|
|
use CGI;
|
|
use strict;
|
|
use warnings;
|
|
use Path::Tiny;
|
|
|
|
my $q = CGI->new;
|
|
my $dir = $q->param("r");
|
|
|
|
#if ($dir =~ m"/usr/") {
|
|
if (rindex ($dir, "/", 0) == 0) {
|
|
print "Content-Type: text/html\n\n";
|
|
my $uri = path($dir);
|
|
|
|
# Iterate over the content of foo/bar
|
|
my $iter = $uri->iterator;
|
|
while (my $file = $iter->()) {
|
|
# See if it is a directory and skip
|
|
# next if $file->is_dir();
|
|
# Print out the file name and path
|
|
print "$file\n";
|
|
}
|
|
}
|
|
else {
|
|
print $dir;
|
|
}
|