#!/usr/local/bin/perl
# Works with Perl4 and Perl5
#
# unpgphtml -- a perl script to unmake PGP signed web-pages
#
# by Fabrizio Pivari <Pivari@geocities.com> 22 March 1998
#
# Requires the pgp program
#
# Copy, use, and redistribute freely, but don't take my name off it and
# clearly mark an altered version.  Fixes and enhancements cheerfully 
# accepted.
#
# This is version 3.0.
#
use strict;
use Getopt::Long;

my $help="";
my $verbose="";
do GetOptions("help"    => \$help,
              "verbose" => \$verbose) || printusage() ;
$help and printusage();

my $out = "unpgphtml-out$$";
my $x="";
if (@ARGV)
   {
   foreach $x (@ARGV)
      {
      if ($x=~/\.htm$/i || $x=~/\.html$/i)
         {
         $verbose and print "Processing file: $x\n\n";
         system("pgp < ${x} > ${out}");
         open(TEMP, "$out")
             || die("unpgphtml: couldn't open tempfile $out \n");
         open(HTML, ">$x")
             || die("unpgphtml: couldn't open $x\n");
         while (<TEMP>)
            {
            s/ -->\n//;
            s/<KBD>----BEGIN PGP SIGNED WEB-PAGE----<\/KBD>\n//;
            s/<!PGPHTML.*<PRE>/<\/BODY>\n<\/HTML>/;
            print HTML $_;
            }

         close(TEMP);
         }
      else {print "Warning: the extension of the file isn't one of these .htm .HTM .html .HTML\n";}
      unlink($out);
      }
   }
else {printusage();}

sub printusage {
    print <<USAGEDESC;

usage:
        unpgphtml [-options ...] files

where options include:
    -help                        print out this message
    -verbose                     verbose

files:
    with files you can use metacharacters and relative and absolute path name
    
If you want to know more about this tool, you might want
to read the docs. They came together with unpgphtml!

Home: http://www.geocities.com/CapeCanaveral/Lab/3469/pgphtml.html

USAGEDESC
    exit(1);
}
