SPONSORED LINKS

Index of /licenses/cgi/ on afswww.icequake.net

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory  -  
[TXT]fancyindex.cgi2007-07-20 15:03 1.9K 
[TXT]license.cgi2012-05-30 22:00 2.0K 

#!/usr/bin/perl -w --
#
# Generate a directory listing with metadata from database
# If none available, print the first text/plain file with 'index' in the name
# Print any README type file found as in /READ.*ME(\..*)?$/i
# Print any .NFO/.DIZ/.SDI file as plaintext

# WTF? This print has to be HERE AND be multi-line, or no output from Apache...
#
print qq{

}; use warnings; use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use File::MMagic; use Data::Dumper; my $path = ''; if ($ENV{'SERVER_NAME'} =~ /afswww.icequake.net/) { $path = $ENV{'REQUEST_URI'}; $path =~ s/^/\/pub/g; } else { exit 0; } my $location = "/afs/icequake.net" . $path; if ($location !~ /\/$/) { $location .= "/"; } my $fh; opendir my $dir, $location; my @dir = grep !/^\.+$/, readdir $dir; closedir $dir; my @indices = grep /index/i, @dir; my @nfo = grep /READ.*ME(\..*)?$/i, @dir; @nfo = (@nfo, grep /\.nfo$/i, @dir); @nfo = (@nfo, grep /(\.diz|\.sdi)$/i, @dir); my $mm = new File::MMagic; my $mime = ''; my $fname; # If a text file is marked executable, the MIME::Magic returns # x-system/x-unix; commands text while ($mime !~ /text\/plain/ && $mime !~ /x-system\/x-unix/) { $fname = shift @indices; if (!defined($fname)) { last; } #warn $fname; if (!defined($fname)) { last; } if ( -f $location.$fname ) { $mime = $mm->checktype_filename($location.$fname); #warn $mime; } else { next; } } print qq{

};
open $fh, "<".$location.$fname;
while (<$fh>) { print $_; }
close $fh;
print qq{
}; while(1) { $fname = shift @nfo; if (!defined($fname)) { last; } if ( -f $location.$fname ) { $mime = $mm->checktype_filename($location.$fname); } else { next; } if ($mime eq 'text/plain') { print qq{
};
	}
	elsif ($mime eq 'text/html') {
	}
	else {
		next;
	}

	open my $fh, "<".$location.$fname;
	while (<$fh>) { print $_; }
	close $fh;

	if ($mime eq 'text/plain') {
		print qq{
}; } } warningsToBrowser(1); exit 0;