Ahah, well, thanks to you and Some Random Fox (thanks, E), I think I pretty much got it working :o) I got rid of the file-extensions part 'cause the pss and viewsourse.php scripts were stupid, so now it's all in showtext.php (which I'll fix later)

Aaaannd...here's the code ^.^:

#!/usr/bin/perl # RedFox! Productions: DirList # All coding done by one Ranna Fox use rfp; use strict; use CGI qw( :standard ); my $r = new rfp; my $file = param('d') || "prefix/"; $r->print_start("RF!P::DL->($file);"); if ($file =~ /^\//) { print "<b>Ahem...you may not list files with absolute paths. Especi +ally not <em>that</em> absolute path</b>\n"; $r->print_end; exit; } elsif ($file =~ /\.\./) { print "<b>'Scuse me, I won't list directories with .. in their path. + Better fix that.</b>\n"; $r->print_end; exit; } elsif (not $file =~ /^prefix\//) { print "<b>See, the way things work is that if you're gonna list a di +rectory, you gotta put a 'prefix/' before it, which means it has to b +e in my directory.<b>\n"; $r->print_end; exit; } my $filen; ($filen = $file) =~ s{^prefix/}{/home/admin/ranna/public_html/}; if (not -d $filen) { print "<b>That...uh...doesn't appear to exist... o.O</b>\n"; $r->print_end; exit; } &parse_dir($filen, $file); sub parse_dir { my $dir = $_[0]; my $req = $_[1]; opendir(PARSEDIR, "$dir") || die "Couldn't open directory $dir: $!\n +"; my $currdir; $dir =~ s/(.*)\/$/$1/; ($currdir = $dir) =~ s{.*/([^/]*)$}{$1}; print "<li><b>$currdir/</b>\n<ul>\n"; foreach my $file (readdir(PARSEDIR)) { my $fullname = $dir . "/" . $file; next if ($file =~ /^\..*/ || ! -r $fullname); if (-d $fullname) { $req = $req . "/" . $file; &parse_dir($fullname, $req); } else { my $dirn; ($dirn = $dir) =~ s{/home/admin/ranna/public_html}{}; print "<li>[<a href=$dirn/$file>Bare link</a>]"; if (-T $fullname) { print "[<a href=/showtext.php?file=prefix$dirn/$file>Online</a +>]"; } else { print "[<a href=$dirn/$file>Download</a>]"; } print " - $file</li>\n"; } } closedir(PARSEDIR); print "</ul>\n"; } $r->print_end;
And, not to forget, an example.

In reply to Re: CGI Directory Lister by Ranna
in thread CGI Directory Lister by Ranna

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.