#!/usr/bin/perl -T $ENV{'PATH'} = '' ; my $tmpfile ="/tmp/hash-$$" ; use strict; use LWP::UserAgent; use Digest::MD5 qw( md5_base64 ) ; use CGI; my $cgi = new CGI; my $url = $cgi->param('url') || $ENV{'URL'} ; my %catalog = ( 'HTML' => '/usr/local/valet/sgmlib/catalog' , 'XHTML' => '/usr/local/valet/sgmlib/xhtml1/xhtml.soc' , 'XML' => '/usr/local/valet/sgmlib/xml.soc' , ) ; my $markup = $cgi->param('markup') || 'HTML' ; my $soc = $catalog{$markup} ; my $nsgmls = "SGML_CATALOG_FILES=$soc /usr/local/valet/bin/onsgmls -E0 " ; my $agent = new LWP::UserAgent; $agent->agent("Site Valet Metric") ; my $request = new HTTP::Request 'GET' , $url ; my $response = $agent->request($request) ; my $lm = $response->last_modified || "(not specified)" ; print qq(Content-Type: text/plain Cache-Control: no-cache Hashes for $url ) ; Last-modified: $lm if ( $response->is_success ) { if ( open ( TMP, ">$tmpfile" ) ) { print TMP $response->content ; close TMP ; my $in_all ; my $in_attr ; my $in_els ; my $in_hdrs ; my $in_text ; if ( open (VAL, "$nsgmls $tmpfile 2>/dev/null |") ) { for () { $in_all .= $_ ; $in_attr .= $_ if /^[\(\)A]/ ; $in_els .= $_ if /^[\(\)]/ ; $in_hdrs .= $_ if /^[\(\)]H[123456]/ ; $in_text .= $_ if /^\-/ ; } close VAL ; my $all = md5_base64($in_all) ; my $attr = md5_base64($in_attr) ; my $els = md5_base64($in_els) ; my $hdrs = md5_base64($in_hdrs) ; my $text = md5_base64($in_text) ; print qq( All Content: $all Elements+Attributes: $attr Elements: $els Headings: $hdrs Text: $text ) ; } else { print qq( Server error 2 ) ; } } else { print qq( Server error 1 ) ; } } else { print qq( Error parsing or fetching $url ) ; } END { unlink $tmpfile if -f $tmpfile ; }