..../cgi-bin/wiki.pl?action=dirview&dirname=uploads
You need to log in as admin or editor for viewing directories.
See an example [here]. DeadLink --BernhardZechmann
$UpLdName = "uploaddir"; # name of directory for uploads # only needed, if you want fixed dir-browsing $UpLdDir = "/path/to/uploads"; # real path to upload dir and DirViewThen configure them in your config file.
sub DoOtherRequest { ... } elsif ($action eq "dirview") { &DoDirView($dirname); ## Patch: DirView } elsif ($action eq "editlinks") { ...
## Patch: DirView if (&GetParam("dirview", 0)) { &DoDirView(); return; } if (&GetParam("enter_login", 0)) { ... }
Add new sub after DoPageLock?:
## Patch: DirView sub DoDirView { require "ctime.pl"; my ($dirname,$dirview,$dir,$testfile,$number,$tempnumber,$mtime,$size,$random,$key,$file,$stored,$a,$b, $title,$filedate,$month,$year,$time,$ctime,$hour,$day,$date); my %htmfilesunsorted; my (@filenames,@x,@y,@z); $dir = &GetParam("dirname"); # $dir = $UpLdName; # uncomment this line, for security purpose fixed directory $dirname = $UpLdDir."/".$dir; print &GetHeader('', Ts('Content of %s directory ', $dir), ''); if (&UserIsAdmin || &UserIsEditor){} else { print '<center>', T('Only Administrators and Editors can view the content of directories'), '</center>'; print &GetCommonFooter(); return; } if ($dirname eq "") { print '<p>', T('Missing directory name for listing...'); print &GetCommonFooter(); return; } if (! -d $dirname) { print '<p>', Ts('%s is not a directory...', $dirname); print &GetCommonFooter(); return; } chdir($dirname); # Get the list of files in the current directory. opendir(DIR,'.') || warn Ts('Can\'t open %s: %s', $dirname, $!), '\n'; @filenames = readdir(DIR); closedir(DIR); for (@filenames) { next if $_ eq '.'; next if $_ eq '..'; next if (! -f $_); # Is the filename really a file? next if ( /fat\.db$|FAT$/); # ignore some database files #next if (! /\.htm$/i); # uncomment it if you like to index only HTML-files $testfile = $_; @x = stat($testfile); $mtime = $x[9]; $size = $x[7]; $tempnumber++; srand($tempnumber); $random = int(rand(899)) + 100; $key = join("",$mtime,$random); # The age of the file and a random number # with four digits is used as key of the # array which will be sorted later. $htmfilesunsorted{$key} = join("\"\"","$dirname$testfile",$key,$size,$mtime); } # foreach $key (sort {$b <=> $a} keys(%htmfilesunsorted)) { $number = 0; foreach $key (sort keys(%htmfilesunsorted)) { ($file, $stored, $size, $mtime) = split(/""/, $htmfilesunsorted{$key}); # split the file name from the key $number++; # increment the counter for the number of files $file =~ s|$dirname||i; $filedate = &ctime($mtime); (@z) = split(/\s+/,$filedate); $month = $z[1]; $year = $z[4]; $time = $z[3]; if ($z[2] < 10) { $day = "0$z[2]"; } else { $day = $z[2]; } ($hour) = split(/:/,$z[3]); if ( $hour < 10) { $time = "0$z[3]"; } else { $time = $z[3]; } $filedate = "$month $day, $year, $time"; # like Mar 06, 1996, 09:45:10 undef $month; undef $day; undef $year; undef $time; undef $hour; # print HREF: print '<LI>'.$filedate.' <A HREF="'.$SiteBase.$dir.'/'.$file.'" target="_leer"><img src="'.$SiteUrl.$dir.'/'.$file.'" width="50"> '.$file.'</A> ('.$size.'b)<br>'; } # footer $date = &ctime(time); (@y) = split(/\s+/,$date); $date = "$y[1] $y[2], $y[4], $y[3]"; # like Mar 18, 1996, 09:45 print '</UL><HR>', Ts('The directory contains %s files.', $number), '<BR>'; print &GetCommonFooter(); } ## End Patch: DirView