#!/usr/bin/perl -w use strict; # 'taint' in the import list is currently a no-op. See the documentation use CGI::Carp 'fatalsToBrowser'; use CGI::Safe qw/:standard taint/; use Mail::Sender; my $summary = param( 'summary' ) || ''; my $num_sites = param( 'websites' ) || ''; my $ip = param( 'ip' ) || ''; ... my (@days,$string,$result,$sender,$src,$direct); my $dir = "/var/tmp"; my $header = "$dir/header"; my $output = "$dir/output"; # Delete the output file if it exist unlink $output; # Run the subroutines &check_email(); &display_page(); # Delete the output file once we are done unlink $output; exit; sub check_email { # Make sure the user enters a company email address. if ($email =~ /([.\w]+)(\@acme+\.com$)/) { &do_work(); } else { die "$email is not a valid email address. Please try again.\n"; } } sub do_work { # Copy the 1st line from the log files which is necessary for fwlogsum open (IN,"$header") or die "can't open file $header: $!"; open (OUT,">$output") or die "can't open file $output: $!"; while () { print OUT $_; } # Add each day to an array $string = "$month1" . "$year"; @days = ($day1 .. $day2); @days = map {$_ .= "$string"} @days; # add the month and year to each day if ($summary eq 'yes') { if ($direction eq 'inbound') { ... } } elsif ($direction eq 'outbound') { .... } } elsif ($summary eq 'no') { ... } elsif ($direction eq 'outbound') { ... } close (IN); close (OUT); my $fwlogsum = "/usr/local/bin/fwlogsum -ra -w -sc -bo -T -l $output -o /exported/web-usage/$report.html"; my $fwlogsum_sum = "/usr/local/bin/fwlogsum -ra -w -sc -bo -T -S -P $num_sites -l $output -o /exported/web-usage/$report.html"; my $fwlogsum_sum_dns = "/usr/local/bin/fwlogsum -ra -w -sc -bo -C -T -R -S -P $num_sites -l $output -o /exported/web-usage/$report.html"; my $fwlogsum_dns = "/usr/local/bin/fwlogsum -ra -w -sc -bo -C -T -R -l $output -o /exported/web-usage/$report.html"; if ($dns eq 'yes' && $summary eq 'yes') { $result = `$fwlogsum_sum_dns`; } elsif ($dns eq 'yes' && $summary eq 'no'){ $result = `$fwlogsum_dns`; } elsif ($dns eq 'no' && $summary eq 'yes'){ $result = `$fwlogsum_sum`; } else { $result = `$fwlogsum`; } #end else mail(); } sub mail { ... } sub display_page { my $message = shift; print header, start_html( "-title" => "Results Page"), p(" "), p( strong("Mail Sent Ok") ), end_html; }