sub manager { form_head(); menu_head(); if($Form{'NewList'}){ $Form{'List'}="site_list_".$Form{'NewList'}.".txt"; $Form{'List'}=~ s/\s//g; check_list(); } print qq| |; if ($Form{'Address'} ne '' || $Form{'DEA'} ne '') { edit_emails(); } print qq|

Mail Manager

Email List : @{[list_files()]}
|; if($Form{'List'} && $Form{'List'}!~ /AllUsers|NewsLetter/oi) { list_emails(); print qq|
Resource :
First Name :
Last Name :
New Address :

$clear
|; $script =qq| var line=''; for(var y=0;yEditing for registered $tf is not currently available. |; } else { print qq|
Editing for registered $tf is not currently available.
|; } print qq| |; } sub mailer { form_head(); menu_head(); print qq| |; list_records(); if($Form{'Act'} eq 'AddRejects'){ AddRejects(); } print qq| |; if ($Form{'Email1'} ne '' || $Form{'Email2'} ne ''){ alter_emails(); } print qq|

Send Emails

Sender :
Subject :
Email List : @{[list_files()]}
Confirmed : (Yes = Confirmed Email addresses Only)

$clear

Lists

Email 1. : Removes this addresss from ALL lists ONLY
Email 2. : Replace Address above in ALL lists. ONLY

New List

Name : Create a new list for emailing. (No spaces)

|; } sub create_record { @record=($Form{'Letter'}); if(-e "$data_file.ltr") { print "

File $data_file already on file.

"; } else { open(MAIN,">$data_file.ltr") || die $!; my $newrecord = join('|',@record); print MAIN "$newrecord\n"; $recorded= "Created $time\n"; close(MAIN); } } sub edit_document { $recsaved=0; if(open(NUMBER,">$data_file.ltr")) { $Form{'Letter'}=~ s/\<\;//g; $Form{'Letter'}=~ s/

/\n/g; $Form{'Letter'}=~ s/<\/P>/\n/g; print NUMBER "$Form{'Letter'}"; $recsaved = 1; close(NUMBER); } if ($recsaved ne 0) { $recorded= "Updated $time\n"; } else { $recorded= print " Error Updating \n"; } } sub delete_document { $recdeleted=0; if(unlink ("$data_file.ltr")) { $recdeleted = 1; print "

$data_file File deleted sucessfuly
\n"; $data_file = "$file_dir/auz_letter" } else { print "
$data_file Error Deleting File
\n"; } } sub disp_record { if (open(MAIN,"$data_file.ltr") || open(MAIN,"$data_file.html")) { @main=&check_me(
); close(MAIN); foreach(@main) { # $_=~ s/\[home\]/$home/g; # $_=~ s/\[sitebase\]/$sitebase/g; # $_=~ s/\[bgcolor\]/$bgcolor/g; print $_; } } else{ print"$data_file not found."; } } sub list_records { chdir "$file_dir" or die "Can't cd to $file_dir: $!\n"; opendir THISDIR, "." or die "serious dainbramage: $!"; @allfiles = grep !/^\.\.?$/, readdir THISDIR; closedir THISDIR; @allfiles = sort @allfiles; $allfiles = @allfiles; $x=0; print qq| Letters : |; } sub list_files { my ($form,$sel,$x)=''; chdir "$file_dir" or die "Can't cd to $file_dir: $!\n"; opendir THISDIR, "." or die "serious dainbramage: $!"; @allfiles = grep !/^\.\.?$/, readdir THISDIR; closedir THISDIR; push(@allfiles,'NewsLetter','AllUsers'); @allfiles = sort @allfiles; $x=0; $form= qq| |; # chdir "$datapath/letters/rejects"; # opendir THISDIR, "." or die "serious dainbramage: $!"; # @allfiles = grep !/^\.\.?$/, readdir THISDIR; # closedir THISDIR; # foreach(@allfiles){ $f++;} # if($f){ print "

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 "\n"; } print qq~
$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~ ~; $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| |; } } print qq|
No Created Visited Name Email Sent Read Returns
$x @{[strdate($Date)]} @{[strdate($LDate)]} $First $Last $Email $sentemails $reademails $returnedemails
@{[&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|
|; print $form; } sub menu_head() { $Form{'Action'} eq 'Manager'?($Sel='Mailer'):($Sel='Manager'); my $form =qq|
$Form{'Action'}  
|; print $form; } 1;