Alert....before mailing \n"; } return $form; } sub check_list { if(!-e "$file_dir/$Form{'List'}") { open(FILE, ">>$file_dir/$Form{'List'}"); print FILE "$adminemail|Website|Owner|Admin|Online|$Date\n"; close(FILE); } } ######################################################## EMAIL sub list_emails { @struct_emails=('Address','First','Last','Source','Type','Date'); if($Form{'List'}!~ /AllUsers|NewsLetter/oi){ check_list(); } open(MAIN,"$file_dir/$Form{'List'}") || die print "
$file_dir/'$Form{'List'}' help $!\n";
@main = ;
close(MAIN);
$found = 0;
$efile=$Form{'List'};
$efile=~ s/\_/ /g;
$efile=~ s/\.txt//g;
$Form{'Addresses'};
print qq~
$Form{'List'} Emails
~;
$x=0;
foreach (@main)
{
$x++;
pageit(100);
split_file($_,@struct_emails);
print "$x $Address $First $Last $Source $Type $Date \n";
}
print qq~
~;
}
sub list_addresses
{
open(MAIN,"$cgi_path/$tf/$tf\.db") || open(MAIN,">$cgi_path/$tf/$tf\.db") || oops "
$tf help $!";
@Users = ;
close(MAIN);
open(MAIN,"$cgi_path/$tf/$tf\.db") || open(MAIN,">$cgi_path/$tf/$tf\.db") || oops "$tf help $!";
@Users = ;
close(MAIN);
open (SENT, "$cgi_path/$tf/emailssent.txt") || open (SENT, ">$cgi_path/$tf/emailssent.txt");
@sent = sort ;
close(SENT);
list_head();
print qq~
No
Created
Visited
Name
Email
Sent
Read
Returns
~;
$x=0;
foreach(@Users)
{
split_file($_,@$struct);
if(user_type($Form{'List'}))
{
$x++;
pageit(100);
$sentemails='';
$reademails='';
$returnedemails='';
foreach $sent(@sent)
{
chomp($sent);
split_file($sent,@sent_emails);
if($Email eq $SEmail){ $sentemails++; if($Read){ $reademails++; } if($Returned){ $returnedemails++; } }
}
print qq|
$x
@{[strdate($Date)]}
@{[strdate($LDate)]}
$First $Last
$Email
$sentemails
$reademails
$returnedemails
|;
}
}
print qq|
@{[&pagebreak($page_cnt,'pagenum')]}
|;
if($Form{'Action'} ne 'Manager'){ list_send(); }
}
sub byemail
{
@x = split(/\|/,$a);
@y = split(/\|/,$b);
($x[0] cmp $y[0]);
}
sub edit_emails
{
if(open(MAIN,"$file_dir/$Form{'List'}") || open(MAIN,">$file_dir/$Form{'List'}"))
{
@main = ;
close(MAIN);
}
else{ die print "cant open $file_dir/$Form{'List'} file $!"; }
# @sorted = sort byemail @main;
# @main = @sorted;
@remove = split(/\|/,$Form{'DEA'});
$number=scalar(@remove);
open(NUMBER,">$file_dir/$Form{'List'}");
$x=0;
foreach $Line (@main)
{
$count=0;
$found=0;
$x++;
chomp($Line);
($Address,$First,$Last,$Resource,$Type,$Date) = split(/\|/,$Line);
while ($count<=$number)
{
if($x eq @remove[$count]){ $found=1; $count=$number-1;}
$count++;
}
if ($found==0){ print NUMBER "$Line\n"; }
}
if ($Form{'Address'} ne '')
{
@record=($Form{'Address'},$Form{'First'},$Form{'Last'},'Net',$Form{'Resource'});
my $newrecord = join('|',@record,$tdate);
print NUMBER "$newrecord\n";
}
close(NUMBER);
}
sub alter_emails
{
chdir "$file_dir" or die "Can't cd to $file_dir: $!\n";
opendir THISDIR, "." or die "serious dainbramage: $!";
@allfiles = grep !/^\.\.?$/, readdir THISDIR;
closedir THISDIR;
$x=0;
foreach $allfiles (@allfiles)
{
if($allfiles=~ /list\_/)
{
$record=0;
open(MAIN,"$allfiles") || die print "$allfiles 1 help $!\n";
@main = ;
open(MAIN2,">$allfiles") || die print "$allfiles 2 help $!\n";
foreach $Line (@main)
{
$record++;
chomp($Line);
($Address,@rest) = split(/\|/,$Line);
$Address=~ s/ //g;
if($Form{'Email1'} eq $Address)
{ $x++;
if($Form{'Email2'} ne '')
{
$Line=join('|',$Form{'Email2'},@rest);
}
}
print MAIN2 "$Line\n";
}
close(MAIN2);
# print "Looked in $allfiles ($record)
\n";
}
}
if ($x==0){ print" $Form{'Email1'} not found. \n"; }
else { print"$x $Form{'Email1'} Edited. \n"; }
return $form;
}
sub list_send
{
print qq~
$clear
~;
}
sub list_head
{
my($type)=@_;
print qq~
$tf $Form{'List'} Emails
~;
}
sub user_type
{
my($Search)=@_;
if($cookie{'confirmed'} eq 'Yes' && !$LDate){ return 0; }
if($Search eq 'NewsLetter' && $NewsLetter ne 'N'){ return 1; }
if($Search eq 'AllUsers'){ return 1; }
#print"$Search eq 'AllUsers'
\n";
return 0;
}
sub AddRejects
{
if(-e "$datapath/letters/rejects/rejects.db")
{
$found=0;
@emails=();
# print"$htmlhead";
chdir "$datapath/letters/rejects";
opendir THISDIR, "." or die "serious dainbramage: $!";
@allfiles = grep !/^\.\.?$/, readdir THISDIR;
closedir THISDIR;
foreach(@allfiles)
{
open(FILE, "$datapath/letters/rejects/$_");
@file=;
close(FILE);
$go=0; $on=0;
foreach(@file)
{
$_=~ /The following address\(es\) failed/i and $go++;
$_=~ /------ This is a copy of the message, including all the headers. ------/i and $on++;
if($go && $on)
{
if($_=~ /^From: (.*)<(.*)>/i){ $from = $2; } # print"From:$from
\n";
if($from=~ /$website/ && $_=~ /^To: (.*)/i){ $to = $1; $found++; $to=~ s/\r|\n|\s//g; push(@emails,$to); } # print"To:$to
\n";
if($_=~ /Message-Id:/){ $go=0; $on=0; }
}
}
unlink("$datapath/letters/rejects/$_");
}
if($found)
{
open(MEMBERS, "$cgi_path/$tf/$tf\.db");
@members=;
close(MEMBERS);
open(MEMBERS, ">$cgi_path/$tf/$tf\.db");
foreach(@members)
{
split_file($_,@$struct);
foreach $emails (@emails){ if($emails eq $Email){ $Rejects++; $_=join_file(0,0,@$struct)."$nl"; last; } }
$Rejects<5 and print MEMBERS $_;
}
close(MEMBERS);
}
# $Form{'Action'}='Mailer';
}
}
sub form_head
{
my $form =qq|
$Form{'List'} Emails
| $x | $Address | $First | $Last | $Source | $Type | $Date | |
~; } sub list_addresses { open(MAIN,"$cgi_path/$tf/$tf\.db") || open(MAIN,">$cgi_path/$tf/$tf\.db") || oops "
$tf help $!";
@Users = ;
close(MAIN);
open(MAIN,"$cgi_path/$tf/$tf\.db") || open(MAIN,">$cgi_path/$tf/$tf\.db") || oops "$tf help $!";
@Users = ;
close(MAIN);
open (SENT, "$cgi_path/$tf/emailssent.txt") || open (SENT, ">$cgi_path/$tf/emailssent.txt");
@sent = sort ;
close(SENT);
list_head();
print qq~
No
Created
Visited
Name
Email
Sent
Read
Returns
~;
$x=0;
foreach(@Users)
{
split_file($_,@$struct);
if(user_type($Form{'List'}))
{
$x++;
pageit(100);
$sentemails='';
$reademails='';
$returnedemails='';
foreach $sent(@sent)
{
chomp($sent);
split_file($sent,@sent_emails);
if($Email eq $SEmail){ $sentemails++; if($Read){ $reademails++; } if($Returned){ $returnedemails++; } }
}
print qq|
$x
@{[strdate($Date)]}
@{[strdate($LDate)]}
$First $Last
$Email
$sentemails
$reademails
$returnedemails
|;
}
}
print qq|
@{[&pagebreak($page_cnt,'pagenum')]}
|;
if($Form{'Action'} ne 'Manager'){ list_send(); }
}
sub byemail
{
@x = split(/\|/,$a);
@y = split(/\|/,$b);
($x[0] cmp $y[0]);
}
sub edit_emails
{
if(open(MAIN,"$file_dir/$Form{'List'}") || open(MAIN,">$file_dir/$Form{'List'}"))
{
@main = ;
close(MAIN);
}
else{ die print "cant open $file_dir/$Form{'List'} file $!"; }
# @sorted = sort byemail @main;
# @main = @sorted;
@remove = split(/\|/,$Form{'DEA'});
$number=scalar(@remove);
open(NUMBER,">$file_dir/$Form{'List'}");
$x=0;
foreach $Line (@main)
{
$count=0;
$found=0;
$x++;
chomp($Line);
($Address,$First,$Last,$Resource,$Type,$Date) = split(/\|/,$Line);
while ($count<=$number)
{
if($x eq @remove[$count]){ $found=1; $count=$number-1;}
$count++;
}
if ($found==0){ print NUMBER "$Line\n"; }
}
if ($Form{'Address'} ne '')
{
@record=($Form{'Address'},$Form{'First'},$Form{'Last'},'Net',$Form{'Resource'});
my $newrecord = join('|',@record,$tdate);
print NUMBER "$newrecord\n";
}
close(NUMBER);
}
sub alter_emails
{
chdir "$file_dir" or die "Can't cd to $file_dir: $!\n";
opendir THISDIR, "." or die "serious dainbramage: $!";
@allfiles = grep !/^\.\.?$/, readdir THISDIR;
closedir THISDIR;
$x=0;
foreach $allfiles (@allfiles)
{
if($allfiles=~ /list\_/)
{
$record=0;
open(MAIN,"$allfiles") || die print "$allfiles 1 help $!\n";
@main = ;
open(MAIN2,">$allfiles") || die print "$allfiles 2 help $!\n";
foreach $Line (@main)
{
$record++;
chomp($Line);
($Address,@rest) = split(/\|/,$Line);
$Address=~ s/ //g;
if($Form{'Email1'} eq $Address)
{ $x++;
if($Form{'Email2'} ne '')
{
$Line=join('|',$Form{'Email2'},@rest);
}
}
print MAIN2 "$Line\n";
}
close(MAIN2);
# print "Looked in $allfiles ($record)
\n";
}
}
if ($x==0){ print" $Form{'Email1'} not found. \n"; }
else { print"$x $Form{'Email1'} Edited. \n"; }
return $form;
}
sub list_send
{
print qq~
$clear
~;
}
sub list_head
{
my($type)=@_;
print qq~
$tf $Form{'List'} Emails
~;
}
sub user_type
{
my($Search)=@_;
if($cookie{'confirmed'} eq 'Yes' && !$LDate){ return 0; }
if($Search eq 'NewsLetter' && $NewsLetter ne 'N'){ return 1; }
if($Search eq 'AllUsers'){ return 1; }
#print"$Search eq 'AllUsers'
\n";
return 0;
}
sub AddRejects
{
if(-e "$datapath/letters/rejects/rejects.db")
{
$found=0;
@emails=();
# print"$htmlhead";
chdir "$datapath/letters/rejects";
opendir THISDIR, "." or die "serious dainbramage: $!";
@allfiles = grep !/^\.\.?$/, readdir THISDIR;
closedir THISDIR;
foreach(@allfiles)
{
open(FILE, "$datapath/letters/rejects/$_");
@file=;
close(FILE);
$go=0; $on=0;
foreach(@file)
{
$_=~ /The following address\(es\) failed/i and $go++;
$_=~ /------ This is a copy of the message, including all the headers. ------/i and $on++;
if($go && $on)
{
if($_=~ /^From: (.*)<(.*)>/i){ $from = $2; } # print"From:$from
\n";
if($from=~ /$website/ && $_=~ /^To: (.*)/i){ $to = $1; $found++; $to=~ s/\r|\n|\s//g; push(@emails,$to); } # print"To:$to
\n";
if($_=~ /Message-Id:/){ $go=0; $on=0; }
}
}
unlink("$datapath/letters/rejects/$_");
}
if($found)
{
open(MEMBERS, "$cgi_path/$tf/$tf\.db");
@members=;
close(MEMBERS);
open(MEMBERS, ">$cgi_path/$tf/$tf\.db");
foreach(@members)
{
split_file($_,@$struct);
foreach $emails (@emails){ if($emails eq $Email){ $Rejects++; $_=join_file(0,0,@$struct)."$nl"; last; } }
$Rejects<5 and print MEMBERS $_;
}
close(MEMBERS);
}
# $Form{'Action'}='Mailer';
}
}
sub form_head
{
my $form =qq|
$tf help $!";
@Users = ;
close(MAIN);
open (SENT, "$cgi_path/$tf/emailssent.txt") || open (SENT, ">$cgi_path/$tf/emailssent.txt");
@sent = sort ;
close(SENT);
list_head();
print qq~
No
Created
Visited
Name
Email
Sent
Read
Returns
~;
$x=0;
foreach(@Users)
{
split_file($_,@$struct);
if(user_type($Form{'List'}))
{
$x++;
pageit(100);
$sentemails='';
$reademails='';
$returnedemails='';
foreach $sent(@sent)
{
chomp($sent);
split_file($sent,@sent_emails);
if($Email eq $SEmail){ $sentemails++; if($Read){ $reademails++; } if($Returned){ $returnedemails++; } }
}
print qq|
$x
@{[strdate($Date)]}
@{[strdate($LDate)]}
$First $Last
$Email
$sentemails
$reademails
$returnedemails
|;
}
}
print qq|
@{[&pagebreak($page_cnt,'pagenum')]}
|;
if($Form{'Action'} ne 'Manager'){ list_send(); }
}
sub byemail
{
@x = split(/\|/,$a);
@y = split(/\|/,$b);
($x[0] cmp $y[0]);
}
sub edit_emails
{
if(open(MAIN,"$file_dir/$Form{'List'}") || open(MAIN,">$file_dir/$Form{'List'}"))
{
@main = ;
close(MAIN);
}
else{ die print "cant open $file_dir/$Form{'List'} file $!"; }
# @sorted = sort byemail @main;
# @main = @sorted;
@remove = split(/\|/,$Form{'DEA'});
$number=scalar(@remove);
open(NUMBER,">$file_dir/$Form{'List'}");
$x=0;
foreach $Line (@main)
{
$count=0;
$found=0;
$x++;
chomp($Line);
($Address,$First,$Last,$Resource,$Type,$Date) = split(/\|/,$Line);
while ($count<=$number)
{
if($x eq @remove[$count]){ $found=1; $count=$number-1;}
$count++;
}
if ($found==0){ print NUMBER "$Line\n"; }
}
if ($Form{'Address'} ne '')
{
@record=($Form{'Address'},$Form{'First'},$Form{'Last'},'Net',$Form{'Resource'});
my $newrecord = join('|',@record,$tdate);
print NUMBER "$newrecord\n";
}
close(NUMBER);
}
sub alter_emails
{
chdir "$file_dir" or die "Can't cd to $file_dir: $!\n";
opendir THISDIR, "." or die "serious dainbramage: $!";
@allfiles = grep !/^\.\.?$/, readdir THISDIR;
closedir THISDIR;
$x=0;
foreach $allfiles (@allfiles)
{
if($allfiles=~ /list\_/)
{
$record=0;
open(MAIN,"$allfiles") || die print "$allfiles 1 help $!\n";
@main = ;
open(MAIN2,">$allfiles") || die print "$allfiles 2 help $!\n";
foreach $Line (@main)
{
$record++;
chomp($Line);
($Address,@rest) = split(/\|/,$Line);
$Address=~ s/ //g;
if($Form{'Email1'} eq $Address)
{ $x++;
if($Form{'Email2'} ne '')
{
$Line=join('|',$Form{'Email2'},@rest);
}
}
print MAIN2 "$Line\n";
}
close(MAIN2);
# print "Looked in $allfiles ($record)
\n";
}
}
if ($x==0){ print" $Form{'Email1'} not found. \n"; }
else { print"$x $Form{'Email1'} Edited. \n"; }
return $form;
}
sub list_send
{
print qq~
$clear
~;
}
sub list_head
{
my($type)=@_;
print qq~
$tf $Form{'List'} Emails
~;
}
sub user_type
{
my($Search)=@_;
if($cookie{'confirmed'} eq 'Yes' && !$LDate){ return 0; }
if($Search eq 'NewsLetter' && $NewsLetter ne 'N'){ return 1; }
if($Search eq 'AllUsers'){ return 1; }
#print"$Search eq 'AllUsers'
\n";
return 0;
}
sub AddRejects
{
if(-e "$datapath/letters/rejects/rejects.db")
{
$found=0;
@emails=();
# print"$htmlhead";
chdir "$datapath/letters/rejects";
opendir THISDIR, "." or die "serious dainbramage: $!";
@allfiles = grep !/^\.\.?$/, readdir THISDIR;
closedir THISDIR;
foreach(@allfiles)
{
open(FILE, "$datapath/letters/rejects/$_");
@file=;
close(FILE);
$go=0; $on=0;
foreach(@file)
{
$_=~ /The following address\(es\) failed/i and $go++;
$_=~ /------ This is a copy of the message, including all the headers. ------/i and $on++;
if($go && $on)
{
if($_=~ /^From: (.*)<(.*)>/i){ $from = $2; } # print"From:$from
\n";
if($from=~ /$website/ && $_=~ /^To: (.*)/i){ $to = $1; $found++; $to=~ s/\r|\n|\s//g; push(@emails,$to); } # print"To:$to
\n";
if($_=~ /Message-Id:/){ $go=0; $on=0; }
}
}
unlink("$datapath/letters/rejects/$_");
}
if($found)
{
open(MEMBERS, "$cgi_path/$tf/$tf\.db");
@members=;
close(MEMBERS);
open(MEMBERS, ">$cgi_path/$tf/$tf\.db");
foreach(@members)
{
split_file($_,@$struct);
foreach $emails (@emails){ if($emails eq $Email){ $Rejects++; $_=join_file(0,0,@$struct)."$nl"; last; } }
$Rejects<5 and print MEMBERS $_;
}
close(MEMBERS);
}
# $Form{'Action'}='Mailer';
}
}
sub form_head
{
my $form =qq|
| No | Created | Visited | Name | Sent | Read | Returns | ||
|---|---|---|---|---|---|---|---|---|
| $x | @{[strdate($Date)]} | @{[strdate($LDate)]} | $First $Last | $sentemails | $reademails | $returnedemails |
$allfiles 1 help $!\n";
@main = ;
open(MAIN2,">$allfiles") || die print "$allfiles 2 help $!\n";
foreach $Line (@main)
{
$record++;
chomp($Line);
($Address,@rest) = split(/\|/,$Line);
$Address=~ s/ //g;
if($Form{'Email1'} eq $Address)
{ $x++;
if($Form{'Email2'} ne '')
{
$Line=join('|',$Form{'Email2'},@rest);
}
}
print MAIN2 "$Line\n";
}
close(MAIN2);
# print "Looked in $allfiles ($record)
\n";
}
}
if ($x==0){ print" $Form{'Email1'} not found. \n"; }
else { print"$x $Form{'Email1'} Edited. \n"; }
return $form;
}
sub list_send
{
print qq~
$clear
~;
}
sub list_head
{
my($type)=@_;
print qq~
$tf $Form{'List'} Emails
~;
}
sub user_type
{
my($Search)=@_;
if($cookie{'confirmed'} eq 'Yes' && !$LDate){ return 0; }
if($Search eq 'NewsLetter' && $NewsLetter ne 'N'){ return 1; }
if($Search eq 'AllUsers'){ return 1; }
#print"$Search eq 'AllUsers'
\n";
return 0;
}
sub AddRejects
{
if(-e "$datapath/letters/rejects/rejects.db")
{
$found=0;
@emails=();
# print"$htmlhead";
chdir "$datapath/letters/rejects";
opendir THISDIR, "." or die "serious dainbramage: $!";
@allfiles = grep !/^\.\.?$/, readdir THISDIR;
closedir THISDIR;
foreach(@allfiles)
{
open(FILE, "$datapath/letters/rejects/$_");
@file=;
close(FILE);
$go=0; $on=0;
foreach(@file)
{
$_=~ /The following address\(es\) failed/i and $go++;
$_=~ /------ This is a copy of the message, including all the headers. ------/i and $on++;
if($go && $on)
{
if($_=~ /^From: (.*)<(.*)>/i){ $from = $2; } # print"From:$from
\n";
if($from=~ /$website/ && $_=~ /^To: (.*)/i){ $to = $1; $found++; $to=~ s/\r|\n|\s//g; push(@emails,$to); } # print"To:$to
\n";
if($_=~ /Message-Id:/){ $go=0; $on=0; }
}
}
unlink("$datapath/letters/rejects/$_");
}
if($found)
{
open(MEMBERS, "$cgi_path/$tf/$tf\.db");
@members=;
close(MEMBERS);
open(MEMBERS, ">$cgi_path/$tf/$tf\.db");
foreach(@members)
{
split_file($_,@$struct);
foreach $emails (@emails){ if($emails eq $Email){ $Rejects++; $_=join_file(0,0,@$struct)."$nl"; last; } }
$Rejects<5 and print MEMBERS $_;
}
close(MEMBERS);
}
# $Form{'Action'}='Mailer';
}
}
sub form_head
{
my $form =qq|
$allfiles 2 help $!\n";
foreach $Line (@main)
{
$record++;
chomp($Line);
($Address,@rest) = split(/\|/,$Line);
$Address=~ s/ //g;
if($Form{'Email1'} eq $Address)
{ $x++;
if($Form{'Email2'} ne '')
{
$Line=join('|',$Form{'Email2'},@rest);
}
}
print MAIN2 "$Line\n";
}
close(MAIN2);
# print "Looked in $allfiles ($record)
\n";
}
}
if ($x==0){ print" $Form{'Email1'} not found. \n"; }
else { print"$x $Form{'Email1'} Edited. \n"; }
return $form;
}
sub list_send
{
print qq~
\n"; } } if ($x==0){ print"
$clear ~; } sub list_head { my($type)=@_; print qq~
$tf $Form{'List'} Emails
~; } sub user_type { my($Search)=@_; if($cookie{'confirmed'} eq 'Yes' && !$LDate){ return 0; } if($Search eq 'NewsLetter' && $NewsLetter ne 'N'){ return 1; } if($Search eq 'AllUsers'){ return 1; } #print"$Search eq 'AllUsers'\n"; return 0; } sub AddRejects { if(-e "$datapath/letters/rejects/rejects.db") { $found=0; @emails=(); # print"$htmlhead"; chdir "$datapath/letters/rejects"; opendir THISDIR, "." or die "serious dainbramage: $!"; @allfiles = grep !/^\.\.?$/, readdir THISDIR; closedir THISDIR; foreach(@allfiles) { open(FILE, "$datapath/letters/rejects/$_"); @file=
\n"; if($from=~ /$website/ && $_=~ /^To: (.*)/i){ $to = $1; $found++; $to=~ s/\r|\n|\s//g; push(@emails,$to); } # print"To:$to
\n"; if($_=~ /Message-Id:/){ $go=0; $on=0; } } } unlink("$datapath/letters/rejects/$_"); } if($found) { open(MEMBERS, "$cgi_path/$tf/$tf\.db"); @members=