#!/usr/local/bin/perl push( @INC, "/usr/local/lib/perl5" ); # MD5 for a selected file from an archive and return that as the document # This script is based on leo-findex by Maex Stumpf et al(?) # Karl Ewald, 85635 Hoehenkirchen, Germany; ewald@leo.org # path is archive file. require "a2h-config.pl"; $archfile = $ENV{'PATH_INFO'}; $full_path = $ARCHIV_ROOT . $archfile; if ( ! -d $full_path && ! -f $full_path ) { print "Status: 404 Not Found\r\n"; print "Server: $ENV{'SERVER_SOFTWARE'}\r\n"; print "Gateway-Interface: $ENV{'GATEWAY_INTERFACE'}\r\n"; print "MIME-version: 1.0\r\n"; # print "Content-length: 100\n"; print "Content-type: text/html\r\n\r\n"; print "404 Not Found\n"; print "

404 Not Found

\n"; print "The requested URL $archfile was not found on this server.

\n"; print "\n"; exit(0); } #print "HTTP/1.0 200 Document follows\n"; print "Server: $ENV{'SERVER_SOFTWARE'}\r\n"; print "Gateway-Interface: $ENV{'GATEWAY_INTERFACE'}\r\n"; print "MIME-version: 1.0\r\n"; print "Content-type: text/html\r\n\r\n"; print "MD5 fingerprint for $archfile\n"; print "\n"; print $md5_address; print "


"; print "

$archfile:

\n"; if ( -d $archfile ) { &gen_dir_info($archfile) } else { print "MD5 fingerprint = "; $md5 = `/usr/local/bin/md5 $full_path`; $md5 =~ s/^.*\=//; print "$md5

\n"; } print $md5_explain; print "


\n"; print "$webmastersig,
generated by Karl Ewald's a2h-md5 "; ( $m_s, $m_m, $m_h, $m_day, $m_mon, $m_year ) = (localtime)[0,1,2,3,4,5]; printf(" on %02d. %s %d %02d:%02d:%02d\n", $m_day, $mon_names[$m_mon], $m_year+1900, $m_h, $m_m, $m_s); print "
\n"; print "\n"; exit (0); sub gen_dir_info { local ($dir) = @_; local (*DH, *FH, $fname, $file, @files); opendir(DH, $dir); @files = readdir(DH); closedir(DH); print "
";
    printf("%-30s  %s\n\n", "Filename", "MD5 fingerprint");
    foreach $file (@files) {
	next if ($file eq '.');
	next if ($file eq '..');
	next if ($file eq '00-index.html');
	next if ($file =~ /^\..*/o );
	next if ($file =~ /^.*\.idx$/o );

	$fname = "$dir/$file";

	if ( -f $fname ) {
	    $md5 = `$md5_prog $full_path/$file`;
	    $md5 =~ s/^.*\=//;
	    printf("%-30s %s", $file, $md5);
	}
    }
    close(FH);
    print "
"; }