#!/usr/bin/perl use CGI; print "Content-type: text/html\n\n\n"; my $Home = "/usr/local/apache2/htdocs/fax"; my $Source = "$Home/source"; my $Archives = "$Home/archives"; my $AB_Archives = "$Home/ab"; my $Display = "$Home/display"; my $Home_Archives = "$Home/home"; `mkdir -p $Source`; `mkdir -p $Archives`; `mkdir -p $Display`; `rsync -av /var/spool/fax/incoming/fax* $Source`; `mkdir -p $AB_Archives`; #------------------------------------ my @Files = <$Source/fax*>; foreach my $File (@Files) { # print "$File\n"; my (@Temp) = split(/\//, $File); my $File_Name = pop @Temp; if (!(-e "$Archives/$File_Name\.pdf")) { print "
Processing new fax: $File\n"; my $Command = "tiff2ps $File > $Archives/$File_Name\.ps"; # print "$Command\n"; `$Command`; my $Command = "/usr/bin/ps2pdf $Archives/$File_Name\.ps $Archives/$File_Name\.pdf"; # print "$Command\n"; `$Command`; `cp $Archives/$File_Name\.pdf $Display/$File_Name\.pdf`; } } #--------------------------------------- my $query = new CGI; my $Action = $query->param('action'); my $File = $query->param('file'); $File =~ s/[^a-zA-Z0-9\_\.]//g; if (!(-e "$Display/$File")) {} elsif ($Action eq "archive") { print "
Archiving $File\n"; `rm -f $Display/$File`; } elsif ($Action eq "archive2") { print "
Archiving $File\n"; `cp $Display/$File $AB_Archives/`; `rm -f $Display/$File`; } elsif ($Action eq "archive_home") { print "
Archiving $File\n"; `cp $Display/$File $Home_Archives/`; `rm -f $Display/$File`; } print qq(
Archives -- might be password protected.
Home Archives -- might be password protected.
Audioboomerang Archives\n); my $Table_Entries = ""; my @Files = <$Display/fax*>; foreach my $File (sort @Files) { my (@Temp) = split(/\//, $File); my $File_Name = pop @Temp; my $Link = "$File_Name"; my $Delete = "archive file"; my $AB ="archive to AB"; my $Home ="archive for Home"; $Table_Entries .= qq($Link$Delete$Home$AB\n); } print "\n"; print $Table_Entries; print "
View FaxArchive the Fax Archive to AudioBoomerang
\n"; if (@Files < 1) {print "

No faxes or they are all archived.

\n";}