#!@PERL@
#
# Directory list CGI by Hironori Sakamoto (hsaka@mth.biglobe.ne.jp)
#
if ( $^O =~ /^(ms)?(dos|win(32|nt)?)/i ) {
$WIN32 = 1;
$CYGPATH = 1;
}
elsif ( $^O =~ /cygwin|os2/i ) {
$WIN32 = 1;
$CYGPATH = 0;
}
else {
$WIN32 = 0;
$CYGPATH = 0;
}
$RC_DIR = '@RC_DIR@';
$RC_DIR =~ s@^~/@$ENV{'HOME'}/@;
if ($CYGPATH) {
$RC_DIR = &cygwin_pathconv("$RC_DIR");
}
$CONFIG = "$RC_DIR/dirlist";
$CGI = $ENV{'SCRIPT_NAME'} || $0;
$CGI = "file://" . &file_encode("$CGI");
$AFMT = '%s';
$NOW = time();
@OPT = &init_option($CONFIG);
$query = $ENV{'QUERY_STRING'};
$dir = '';
$cmd = '';
$cookie = '';
$local_cookie = '';
foreach(split(/\&/, $query)) {
if (s/^dir=//) {
$dir = &form_decode($_);
}
}
$body = undef;
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
sysread(STDIN, $body, $ENV{'CONTENT_LENGTH'});
foreach(split(/\&/, $body)) {
if (s/^dir=//) {
$dir = &form_decode($_);
} elsif (s/^opt(\d+)=//) {
$OPT[$1] = $_;
} elsif (s/^cmd=//) {
$cmd = $_;
} elsif (s/^cookie=//) {
$cookie = &form_decode($_);
}
}
}
$cookie_file = $ENV{'LOCAL_COOKIE_FILE'};
if (-f $cookie_file) {
open(F, "< $cookie_file");
$local_cookie = ;
close(F);
}
if ($local_cookie eq '' || (defined($body) && $cookie ne $local_cookie)) {
print <
Directory list of $qdir
$qdir: $! !