) {
printf "$_";
}
#
close ( FRD );
#
# get rid of the temporary file
unlink $html ;
#
}
#
#
} # pr_html
#
#
# Daily, Monthly Yearly Summary
# -----------------------------
#
sub pr_html_dmy
{
#
my ( $title ) = $_[0];
#
printf FWR "\n";
printf FWR "\n";
#
printf FWR "\n";
printf FWR "| $title Summary | \n";
#
printf FWR "| Outgoing | \n";
printf FWR "| | From | To | \n";
printf FWR "
| \n";
#
printf FWR "| Incoming | \n";
printf FWR "| | From | To | \n";
printf FWR "
| \n";
#
printf FWR "| Spam Types | \n";
printf FWR "| | RuleSet | Reject Status | \n";
#
printf FWR " \n";
printf FWR " | \n";
#
} # pr_html_ymd
#
# ------------------------------------------------------------------
#
sub pr_html_head
{
#
printf FWR "\n";
printf FWR "\n";
printf FWR "\n";
printf FWR " MailLog Statistics for $HOST \n";
printf FWR "\n";
#
printf FWR "\n";
printf FWR "
\n";
printf FWR "\n";
printf FWR "
\n";
#
} # pr_html_head
#
#
#
sub pr_html_end
{
#
printf FWR "\n";
#
} # pr_html_end
#
#
# Make sure the directory exists
# ------------------------------
#
sub mk_dir
{
#
my ( $ok ) = $_[0];
my ( $dir ) = $_[1];
#
#
if ( ! -d $dir ) {
#
# if ( $ok eq 0 ) {
if ( $ok eq 1 ) {
#
# Make sure the permissions are set right if we create a dir
#
printf "Creating Missing dir=$dir..\n";
mkdir ( $dir, "0775" );
chown ( $WebMaster, $dir ) ;
chmod 0775, $dir ;
#
} else {
#
printf "Aborting: Missing dir=$dir..\n";
exit 1;
#
}
#
} # no such dir
#
} # mk_dir
#
#
#
# Process the WebPage form data
# -----------------------------
#
sub proc_data
{
my ( @p_v ) = @_;
#
my ( $id ) = 0 ;
my ( $p, $v ) = "";
my ( $foo ) = 0;
#
my ( @res ) = ();
#
#
# Needed for Error Messages
#
# $Content_type = printf "Content-type: text/html\n\n" if ( $Content_type == 0 );
#
# QUERY_STRING=Login=alvin&Param=Value..
#
# printf "..p_v[$#p_v]=$p_v[0]..
\n";
#
while ( $id <= $#p_v ) {
#
( $p, $v ) = split ( /=/, $p_v[$id] );
#
#
# 24-Nov-01 amo Disallow bad options
#
$v =~ s/\/$//g; # trailing http://foo.com/
$v =~ s/^\s+//g; # leading spaces
$v =~ s/\s+$//g; # traling spaces
$v =~ s/\n//g;
$v =~ s/\`//g;
$v =~ s/\'//g;
$v =~ s/\|//g;
$v =~ s/\"//g;
$v =~ s/\/g;
$v =~ s/\>//g;
$v =~ s/\;//g;
$v =~ s/\?//g;
$v =~ s/\*//g;
#v =~ s/\///g; # allow ip#/24
$v =~ s/\+/ /g; # convert -v+-sS to -v -sS
#v =~ s/\ //g; # allow spaces
$v =~ s/\\//g; # skip \
#v =~ s/^\-//g; # allow -v options
$v =~ s/\$//g;
$v =~ s/\%//g;
#
$v =~ s/-m//g; # prevent nmap logging
$v =~ s/-o//g;
#
$v =~ s/^\s+//; # take out leading spaces
#
#
# printf "..p=$p..v=$v..
\n";
#
if ( $p eq Help ) {
#
$Help = 1;
#
} elsif ( $p eq Debug || $p eq debug ) {
#
$DEBUG = 99; # form button
#
} elsif ( $p eq Skip ) {
#
$Skip_Stdin = 1;
#
} elsif ( $p eq "month" ) {
#
$SearchMon = "$v" if ( "$v" ne "" );
#
} elsif ( $p eq "day" ) {
#
if ( "$v" ne "" ) {
#
$SearchDay = "$v" ;
$DD = sprintf ( "%2s", $v );
#
}
#
} elsif ( $p eq "mta" ) {
#
$SearchMTA = "$v" if ( "$v" ne "" );
#
} elsif ( $p eq "Search" ) { # generic search box request
#
$SearchMTA = "$v" if ( "$v" ne "" );
#
} elsif ( $p eq "rev" ) { # grep -v SearchMTA
#
$REV = "-v";
#
}
#
$id += 1;
#
} # All form data
#
# my ( @srch ) = split ( /\;/, $SEARCH ); # $p:$val;$p:$val...
#
# printf "..pv_SearchDay=$SearchDay..
\n";
#
} # proc_data
#
#
#
# Process the variables from the WebPage forms
# --------------------------------------------
#
sub proc_form
{
#
# Prevent waiting for ^D if script run from command line
#
my ( $postinput ) = if ( $Skip_Stdin == 0);
#
# Define this to be able to debug
#
# $Content_type = printf "Content-type: text/html\n\n" if ( $Content_type == 0) ;
#
# print "Posted input content-length = $len..GN=$ENV{'GN_QUERY'}..
\n";
# print "Posted input content-length = $len..QS=$ENV{'QUERY_STRING'}..
\n";
#
#
if ( $ENV{REQUEST_METHOD} eq "POST") {
#
# print "Undecoded posted input:
..$postinput
\n\n";
# $postinput =~ s/&/&
\n/g;
$postinput =~ s/\+/ /g;
$postinput =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig;
#
# print "Decoded posted input:
..$postinput
\n"; # Content-type required
#
} # post
#
#
# append: monitor.pl?Login=USR¶m=value
#
$postinput .= "&" . "$ENV{'QUERY_STRING'}";
#
#
$Visitor = $ENV{REMOTE_ADDR}; # who are they
#
# printf "..postinput=$postinput..
\n"; # Content-type required
#
return ( split ( /&/, $postinput ) );
#
} # proc_form
#
#
#
# Parse the command lines
# -----------------------
#
sub cmd_args
{
#
my ( $arg ) = "";
my ( $id ) = 0;
#
# Does NOT work if from web page
#
# $Help = 1 if ( $#ARGV == -1 ); # no options given...
#
#
# Check the Command line options
#
while ( $id <= $#ARGV ) {
#
$arg = $ARGV[$id];
#
# $Content_type = printf "Content-type: text/html\n\n" if ( $Content_type == 0) ;
# printf "..checking $arg..
\n";
#
if ( $arg eq "-h" ) {
$Help = 1;
#
} elsif ( $arg eq "-d" || $arg eq "-debug" ) {
$DEBUG = 1;
#
} elsif ( $arg eq "-skip" ) {
#
$Skip_Stdin = 1; # Skip stdin check in proc_form
#
} elsif ( $arg eq "-day" ) {
#
$id += 1;
$arg = $ARGV[$id];
#
$DD = sprintf ( "%2s", $arg); # Which date to process
#
}
#
$id += 1;
#
} # args
#
return ( 0 );
#
} # cmd_args
#
#
#
# end of file