^;
&print_footer;
exit;
}
if ($dbaction eq "$b14")
{
if (($filter) && ($contains) && ($movefolder))
{
if (!($contains eq ""))
{
if (!($movefolder eq "-- $l11 --"))
{
$newfilter = "$filter|$contains|$movefolder";
open (FILTER, ">> $userdat$popfold/filters.dat");
print FILTER "$newfilter\n";
close (FILTER);
}
}
}
}
if ($dbaction eq "Delete Filter")
{
$countrows=1;
open (FILTER, " $userdat$popfold/filters.dat") || die "Cant Open Filters1";
flock(FILTER, $LOCK_EX);
while ()
{
$rowdel = $_;
chop $rowdel;
@fields = split (/\|/, $rowdel);
$selected="row" . "$countrows";
if ($filter ne $countrows)
{
$new_row .= "$rowdel\n";
}
$countrows++;
}
close (FILTER);
open (FILTER, "> $userdat$popfold/filters.dat") || die "Cant Open Filters2";
flock(FILTER, $LOCK_EX);
print FILTER "$new_row";
close (FILTER);
}
&print_header;
print qq^
^;
if ($entries < 5)
{
print qq^
^;
}
if ($entries eq "5")
{
print qq^
$l26
^;
}
&print_footer;
exit;
}
if ($action eq "folders")
{
if ($dbaction eq "$b8")
{
$modfolder =~ s/\.//g;
$modfolder =~ s/\///g;
$modfolder =~ s/\\//g;
if ($modfolder)
{
if (-e "$userdat$popfold/folders/$modfolder")
{
$deldir = "$userdat$popfold/folders/$modfolder";
rmtree($deldir);
}
}
}
if ($dbaction eq "$b9")
{
if ($foldername1)
{
$foldername1 =~ s/\.//g;
$foldername1 =~ s/\///g;
$foldername1 =~ s/\\//g;
if ($foldername1 =~ /inbox/i)
{
}
elsif ($foldername1 =~ /trash/i)
{
}
elsif ($foldername1 =~ /Sent items/i)
{
}
elsif ($foldername1 =~ /Drafts/i)
{
}
elsif (!(-e "$userdat$popfold/folders/$foldername1"))
{
$newdir = "$userdat$popfold/folders/$foldername1";
mkdir("$newdir", 0777);
}
}
}
if ($dbaction eq "$b10")
{
if ($foldername2)
{
$foldername2 =~ s/\.//g;
$foldername2 =~ s/\///g;
$foldername2 =~ s/\\//g;
if ($foldername2 =~ /inbox/i)
{
}
elsif ($foldername2 =~ /trash/i)
{
}
elsif ($foldername2 =~ /Sent items/i)
{
}
elsif ($foldername2 =~ /Drafts/i)
{
}
elsif (!(-e "$userdat$popfold/folders/$foldername2"))
{
if ($modfolder)
{
$modfolder =~ s/\.//g;
$modfolder =~ s/\///g;
$modfolder =~ s/\\//g;
$olddir = "$userdat$popfold/folders/$modfolder";
$newdir = "$userdat$popfold/folders/$foldername2";
`mv "$olddir" "$newdir"`;
}
}
}
}
&print_header;
print qq^
^;
&print_footer;
exit;
}
if ($action eq "contacts")
{
if ($dbaction eq "Modify")
{
&print_header;
print " ";
$count=1;
open (DATABASE, " $userdat$popfold/addressbook.db") || die "Cant Open Contact DB";
flock(DATABASE, $LOCK_EX);
while ()
{
$row = $_;
chop $row;
@fields = split (/\|/, $row);
if ($edit eq $count)
{
$counter=0;
open (DATABASE, "$base_require_directory/contact_fields.dat") || die "Can't Open Fields";
flock(DATABASE, $LOCK_EX);
while ()
{
$row = $_;
$table_fields = "$row";
}
close (DATABASE);
@split_table_fields = split (/\,/, $table_fields);
foreach $split_table_fields (@split_table_fields)
{
$DATA{$split_table_fields} = "$fields[$counter]";
$counter++;
}
foreach $key (keys %DATA)
{
$field_data = $DATA{$key};
if ($key eq "\n")
{
}
elsif ($key eq "nick_name")
{
$nick_name = $key;
$nick_name_data = $field_data;
}
elsif ($key eq "first_name")
{
$first_name = $key;
$first_name_data = $field_data;
}
elsif ($key eq "last_name")
{
$last_name = $key;
$last_name_data = $field_data;
}
elsif ($key eq "email_address")
{
$email_address = $key;
$email_address_data = $field_data;
}
elsif ($key eq "web_address")
{
$web_address = $key;
$web_address_data = $field_data;
}
elsif ($key eq "home_street")
{
$home_street = $key;
$home_street_data = $field_data;
}
elsif ($key eq "home_city")
{
$home_city = $key;
$home_city_data = $field_data;
}
elsif ($key eq "home_state")
{
$home_state = $key;
$home_state_data = $field_data;
}
elsif ($key eq "home_zip")
{
$home_zip = $key;
$home_zip_data = $field_data;
}
elsif ($key eq "home_country")
{
$home_country = $key;
$home_country_data = $field_data;
}
elsif ($key eq "home_phone")
{
$home_phone = $key;
$home_phone_data = $field_data;
}
elsif ($key eq "home_fax")
{
$home_fax = $key;
$home_fax_data = $field_data;
}
elsif ($key eq "company_name")
{
$company_name = $key;
$company_name_data = $field_data;
}
elsif ($key eq "company_street")
{
$company_street = $key;
$company_street_data = $field_data;
}
elsif ($key eq "company_city")
{
$company_city = $key;
$company_city_data = $field_data;
}
elsif ($key eq "company_state")
{
$company_state = $key;
$company_state_data = $field_data;
}
elsif ($key eq "company_zip")
{
$company_zip = $key;
$company_zip_data = $field_data;
}
elsif ($key eq "company_country")
{
$company_country = $key;
$company_country_data = $field_data;
}
elsif ($key eq "company_phone")
{
$company_phone = $key;
$company_phone_data = $field_data;
}
elsif ($key eq "company_mobile")
{
$company_mobile = $key;
$company_mobile_data = $field_data;
}
elsif ($key eq "company_fax")
{
$company_fax = $key;
$company_fax_data = $field_data;
}
else
{
}
}
}
$count++;
}
close (DATABASE);
print qq^
^;
&print_footer;
exit;
}
if ($dbaction eq "Display")
{
&print_header;
print " ";
$count=1;
open (DATABASE, " $userdat$popfold/addressbook.db") || die "Cant Open Contact DB";
flock(DATABASE, $LOCK_EX);
while ()
{
$row = $_;
chop $row;
@fields = split (/\|/, $row);
if ($edit eq $count)
{
$counter=0;
open (DATABASE, "$base_require_directory/contact_fields.dat") || die "Can't Open Fields";
flock(DATABASE, $LOCK_EX);
while ()
{
$row = $_;
$table_fields = "$row";
}
close (DATABASE);
@split_table_fields = split (/\,/, $table_fields);
foreach $split_table_fields (@split_table_fields)
{
$DATA{$split_table_fields} = "$fields[$counter]";
$counter++;
}
foreach $key (keys %DATA)
{
$field_data = $DATA{$key};
if ($key eq "\n")
{
}
elsif ($key eq "nick_name")
{
$nick_name = $key;
$nick_name_data = $field_data;
}
elsif ($key eq "first_name")
{
$first_name = $key;
$first_name_data = $field_data;
}
elsif ($key eq "last_name")
{
$last_name = $key;
$last_name_data = $field_data;
}
elsif ($key eq "email_address")
{
$email_address = $key;
$email_address_data = $field_data;
}
elsif ($key eq "web_address")
{
$web_address = $key;
$web_address_data = $field_data;
}
elsif ($key eq "home_street")
{
$home_street = $key;
$home_street_data = $field_data;
}
elsif ($key eq "home_city")
{
$home_city = $key;
$home_city_data = $field_data;
}
elsif ($key eq "home_state")
{
$home_state = $key;
$home_state_data = $field_data;
}
elsif ($key eq "home_zip")
{
$home_zip = $key;
$home_zip_data = $field_data;
}
elsif ($key eq "home_country")
{
$home_country = $key;
$home_country_data = $field_data;
}
elsif ($key eq "home_phone")
{
$home_phone = $key;
$home_phone_data = $field_data;
}
elsif ($key eq "home_fax")
{
$home_fax = $key;
$home_fax_data = $field_data;
}
elsif ($key eq "company_name")
{
$company_name = $key;
$company_name_data = $field_data;
}
elsif ($key eq "company_street")
{
$company_street = $key;
$company_street_data = $field_data;
}
elsif ($key eq "company_city")
{
$company_city = $key;
$company_city_data = $field_data;
}
elsif ($key eq "company_state")
{
$company_state = $key;
$company_state_data = $field_data;
}
elsif ($key eq "company_zip")
{
$company_zip = $key;
$company_zip_data = $field_data;
}
elsif ($key eq "company_country")
{
$company_country = $key;
$company_country_data = $field_data;
}
elsif ($key eq "company_phone")
{
$company_phone = $key;
$company_phone_data = $field_data;
}
elsif ($key eq "company_mobile")
{
$company_mobile = $key;
$company_mobile_data = $field_data;
}
elsif ($key eq "company_fax")
{
$company_fax = $key;
$company_fax_data = $field_data;
}
else
{
}
}
}
$count++;
}
close (DATABASE);
print qq^
^;
&print_footer;
exit;
}
if ($dbaction eq "Delete")
{
$countrows=1;
open (DATABASE, " $userdat$popfold/addressbook.db") || die "Cant Open Contact DB";
flock(DATABASE, $LOCK_EX);
while ()
{
$rowdel = $_;
chop $rowdel;
@fields = split (/\|/, $rowdel);
$selected="row" . "$countrows";
if ($delete ne $countrows)
{
$new_row .= "$rowdel\n";
}
$countrows++;
}
close (DATABASE);
open (DATABASE, "> $userdat$popfold/addressbook.db") || die "Cant Open Contact DB";
flock(DATABASE, $LOCK_EX);
print DATABASE "$new_row";
close (DATABASE);
}
if ($dbaction eq "$b13")
{
&print_header;
print " ";
open (CONTACTPAGE, "$base_require_directory/contact_html.dat");
flock(CONTACTPAGE, $LOCK_EX);
while ()
{
$row = $_;
$html .= "$row\n";
}
close (CONTACTPAGE);
print "$html";
print qq^
^;
&print_footer;
exit;
}
if ($dbaction eq "$b15")
{
open (DATABASE, ">> $userdat$popfold/addressbook.db") || die "Cant Open Contact DB";
$new_row1 ="$nick_name|$first_name|$last_name|$email_address|$web_address";
$new_row2 ="|$home_street|$home_city|$home_state|$home_zip|$home_country|";
$new_row3 ="$home_phone|$home_fax|$company_name|$company_street|$company_city|";
$new_row4 ="$company_state|$company_zip|$company_country|$company_phone|";
$new_row5 ="$company_mobile|$company_fax";
$new_row = "$new_row1$new_row2$new_row3$new_row4$new_row5";
print DATABASE "$new_row\n";
close (DATABASE);
}
if ($dbaction eq "$b16")
{
$count=1;
open (DATABASE, " $userdat$popfold/addressbook.db") || die "Cant Open Contact DB";
flock(DATABASE, $LOCK_EX);
while ()
{
$row = $_;
chop $row;
@fields = split (/\|/, $row);
if ($edit ne $count)
{
$new_row .= "$row\n";
}
else
{
$row1 ="$nick_name|$first_name|$last_name|$email_address|$web_address";
$row2 ="|$home_street|$home_city|$home_state|$home_zip|$home_country|";
$row3 ="$home_phone|$home_fax|$company_name|$company_street|$company_city|";
$row4 ="$company_state|$company_zip|$company_country|$company_phone|";
$row5 ="$company_mobile|$company_fax";
$row = "$row1$row2$row3$row4$row5";
$new_row .= "$row\n";
}
$count++;
}
close (DATABASE);
open (DATABASE, "> $userdat$popfold/addressbook.db") || die "Cant Open Contact DB";
flock(DATABASE, $LOCK_EX);
print DATABASE "$new_row";
close (DATABASE);
}
else
{
}
&print_header;
print " ";
print qq^
^;
&print_footer;
exit;
}
&print_header;
print qq^
$l27
$l28
$l29
$l30
$l41
^;
$date = `date`;
$displayname = $popname;
$remote = $ENV{'REMOTE_ADDR'};
$printinfo = qq^
User: $displayname
Pop: $newpop
Remote Host: $remote
^;
print qq^
$printinfo
^;
&print_footer;
exit;
}
if ($button eq "abook")
{
print "Content-type: text/html\n\n";
print "Contact Manager ";
print qq^
^;
exit;
}
if ($button eq "$b3")
{
$sentmessages = "$userdat$popfold/folders/Sent Items";
if (!(-e $sentmessages))
{
mkdir($sentmessages, 0777);
}
srand (time|$$);
$sentfile = "";
$sentfile = int(rand(10000000));
$sentfile .= ".$$";
if ($savesent)
{
open(SENT, "> $sentmessages/$sentfile") || "Can't Open Sent Items Folder and File";
$date = `date`;
$sendtextsave = $sendtext;
$sendtextsave =~ s/\n/ /g;
$sendtextreply =~ s/^M//g;
$sendtextreply = $sendtextsave;
$sendtextreply =~ s/\n/^/g;
$sendtextreply =~ s/ //g;
print SENT "CYC_SAVE_FROM: $sendfrom\n\n";
print SENT "CYC_SAVE_TO: $sendto\n\n";
print SENT "CYC_SAVE_CC: $sendcc\n\n";
print SENT "CYC_SAVE_BCC: $sendbcc\n\n";
print SENT "CYC_SAVE_SUBJECT: $sendsubject\n\n";
print SENT "CYC_SAVE_DATE: $date\n\n";
print SENT "CYC_SAVE_BODY:$sendtextsave\n\n";
print SENT "CYC_SAVE_REPLY: $sendtextreply\n\n";
print SENT "$linebuffer\r\n";
print SENT "$defaultsig\r\n.\r\n";
close(SENT);
}
$display_message = $message;
$message =~ s/\>\;/>/g;
$message =~ s/\<\;/\r\n", 0;
recv Socket_Handle, $junk, 512, 0;
foreach $line (@to)
{
$line =~ s/.*/g;
$line =~ s/>.*//g;
send Socket_Handle, "RCPT To: $line\r\n", 0;
}
foreach $line (@cc)
{
$line =~ s/.*/g;
$line =~ s/>.*//g;
send Socket_Handle, "RCPT To: $line\r\n", 0;
}
foreach $line (@bcc)
{
$line =~ s/.*/g;
$line =~ s/>.*//g;
send Socket_Handle, "RCPT To: $line\r\n", 0;
}
recv Socket_Handle, $junk, 512, 0;
send Socket_Handle, "DATA\r\n", 0;
recv Socket_Handle, $junk, 512, 0;
if(-e "$userdat$popfold/$popname.dat")
{
$tempuserdat = "$userdat$popfold/$popname.dat";
open(USERDAT, "< $tempuserdat") || die "Cannot open $tempuserdat";
while ()
{
$line = $_;
if ($line =~ /FULLNAME/)
{
$fullname = $line;
$fullname =~ s/FULLNAME\|//g;
$fullname =~ s/\n//g;
}
}
close(USERDAT);
}
if (!($fullname eq ""))
{
send Socket_Handle, "From: $fullname <$sendfrom>\r\n", 0;
}
else
{
send Socket_Handle, "From: $sendfrom\r\n", 0;
}
send Socket_Handle, "To: $sendto\r\n", 0;
if ($sendcc)
{
foreach $line (@cc2)
{
send Socket_Handle, "CC: $line\r\n", 0;
}
}
if ((!($sendsubject)) ||($sendsubject eq ""))
{
$sendsubject = "No Subject....";
}
send Socket_Handle, "Subject: $sendsubject\r\n", 0;
if ($delivery)
{
if (!($fullname eq ""))
{
send Socket_Handle, "Disposition-Notification-To: $fullname <$sendfrom>\r\n", 0;
}
else
{
send Socket_Handle, "Disposition-Notification-To: $sendfrom\r\n", 0;
}
}
send Socket_Handle, "X-Mailer: Cyclonic Webmail - Build 4.00\r\n", 0;
send Socket_Handle, "X-Mime: Produced by Stallion Networking Mime-Engine Ver: 2.03\r\n", 0;
send Socket_Handle, "X-WMSoftware: Cyclonic Webmail (C) 1998-2000\r\n", 0;
if (!($sendtext))
{
$sendtext = " ";
}
if ($attachment1 || $attachment2)
{
$boundary = "-CYCLONE-ATTACH-BOUNDARY-" . time . "---";
send Socket_Handle, "MIME-Version: 1.0\r\n", 0;
send Socket_Handle, "Content-Type: multipart/mixed; ", 0;
send Socket_Handle, "boundary=\"$boundary\"\r\n", 0;
send Socket_Handle, "\r\n--$boundary\r\n", 0;
send Socket_Handle, "Content-Type: text/plain\r\n\r\n", 0;
send Socket_Handle, "$sendtext\r\n", 0;
send Socket_Handle, "\r\n$linebuffer\r\n", 0;
send Socket_Handle, "$defaultsig\r\n", 0;
if ($attachment1)
{
send Socket_Handle, "\r\n--$boundary\r\n", 0;
$type1 = $query->uploadInfo($attachment1)->{"Content-Type"};
@filename1 = split(/\/|\\|:/, $attachment1);
send Socket_Handle, "Content-Type: $type1;\r\n", 0;
send Socket_Handle, " name=\"$filename1[-1]\"\r\n", 0;
send Socket_Handle, "Content-Transfer-Encoding: base64\r\n", 0;
send Socket_Handle, "Content-Disposition: attachment;\r\n", 0;
send Socket_Handle, " filename=\"$filename1[-1]\"\r\n\r\n", 0;
while(read($attachment1,$input,1024)){$temp1 .= $input;}
send Socket_Handle, encode_base64($temp1), 0;
}
if ($attachment2)
{
send Socket_Handle, "\r\n--$boundary\r\n", 0;
$type2 = $query->uploadInfo($attachment2)->{"Content-Type"};
@filename2 = split(/\/|\\|:/, $attachment2);
send Socket_Handle, "Content-Type: $type2;\r\n", 0;
send Socket_Handle, " name=\"$filename2[-1]\"\r\n", 0;
send Socket_Handle, "Content-Transfer-Encoding: base64\r\n", 0;
send Socket_Handle, "Content-Disposition: attachment;\r\n", 0;
send Socket_Handle, " filename=\"$filename2[-1]\"\r\n\r\n", 0;
while(read($attachment2,$input,1024)){$temp2 .= $input;}
send Socket_Handle, encode_base64($temp2), 0;
}
send Socket_Handle, "--$boundary--\r\n\r\n", 0;
send Socket_Handle, "\r\n.\r\n", 0;
}
else
{
send Socket_Handle, "\r\n$sendtext\r\n", 0;
send Socket_Handle, "\r\n$linebuffer\r\n", 0;
send Socket_Handle, "$defaultsig\r\n.\r\n", 0;
}
recv Socket_Handle, $junk, 2048, 0;
send Socket_Handle, "QUIT\n", 0;
recv Socket_Handle, $junk, 512, 0;
close Socket_Handle;
if ($junk =~ /^5/)
{
&print_header;
print "
";
print "
";
print "There were Errors Sending this Message:\n\n";
print $junk;
print "
";
print "
";
&print_footer;
exit;
}
else
{
if (($currentfolder eq "Inbox") || ($currentfolder eq ""))
{
&print_header;
&list_inbox;
&print_footer;
exit;
}
else
{
&print_header;
$folder = $currentfolder;
&list_folder;
&print_footer;
exit;
}
}
}
if ($button eq "Read")
{
my $retrievemess = pummelpopserver($newpop, $popname, $poppass);
my $messagebody = $retrievemess->get($message);
&print_header;
if ($messagebody)
{
$attachdir = "$userdat$popfold/decode/";
# Create and set the output directory:
(-d "$attachdir") || mkdir "$attachdir",0755 || die "mkdir: $!";
(-w "$attachdir") || die "can't write to directory";
show_mime($messagebody);
}
else
{
print "Error collecting POP3 Message!";
}
&print_footer;
exit;
}
if ($button eq "readsaved")
{
if ($folder eq "Drafts")
{
&print_header;
if(-e "$userdat$popfold/$popname.dat")
{
$tempuserdat = "$userdat$popfold/$popname.dat";
open(USERDAT, "< $tempuserdat") || die "Cannot open $tempuserdat";
while ()
{
$line = $_;
if ($line =~ /REPLYTOADD/)
{
$sendfrom = $line;
$sendfrom =~ s/REPLYTOADD\|//g;
$sendfrom =~ s/\n//g;
}
}
close(USERDAT);
}
if (!($sendfrom))
{
if ($popname =~ /\@/) {
$sendfrom = $popname;
} else {
$sendfrom = $popname . '@' . $newpop;
}
}
print qq^
^;
$saveddir = "$userdat$popfold/folders/$folder/$message";
open(FILELIST, "< $saveddir") || die "Cannot open User Folder";
while()
{
$temp = $_;
$savedmessbody .= $temp;
}
close(FILELIST);
@savedmessbody = split(/\n/, $savedmessbody);
foreach $line (@savedmessbody)
{
if ($line =~ /CYC_SAVE_FROM:/)
{
$cycfrom = $line;
$cycfrom =~ s/CYC_SAVE_FROM:\s//g;
$cycfrom =~ s/CYC_SAVE_FROM://g;
if ($cycfrom =~ /^<.*/)
{
$cycfrom =~ s//g;
$cycfrom =~ s/>//g;
}
}
elsif ($line =~ /CYC_SAVE_TO:/)
{
$cycto = $line;
$cycto =~ s/CYC_SAVE_TO:\s//g;
$cycto =~ s/CYC_SAVE_TO://g;
if ($cycto =~ /^<.*/)
{
$cycto =~ s//g;
$cycto =~ s/>//g;
}
}
elsif ($line =~ /CYC_SAVE_CC:/)
{
$cyccc = $line;
$cyccc =~ s/CYC_SAVE_CC:\s//g;
$cyccc =~ s/CYC_SAVE_CC://g;
if ($cyccc =~ /^<.*/)
{
$cyccc =~ s//g;
$cyccc =~ s/>//g;
}
}
elsif ($line =~ /CYC_SAVE_BCC:/)
{
$cycbcc = $line;
$cycbcc =~ s/CYC_SAVE_BCC:\s//g;
$cycbcc =~ s/CYC_SAVE_BCC://g;
if ($cycbcc =~ /^<.*/)
{
$cycbcc =~ s//g;
$cycbcc =~ s/>//g;
}
}
elsif ($line =~ /CYC_SAVE_SUBJECT:/)
{
$cycsubject = $line;
$cycsubject =~ s/CYC_SAVE_SUBJECT:\s//g;
$cycsubject =~ s/CYC_SAVE_SUBJECT://g;
}
elsif ($line =~ /CYC_SAVE_DATE:/)
{
$cycdate = $line;
$cycdate =~ s/CYC_SAVE_DATE:\s//g;
$cycdate =~ s/CYC_SAVE_DATE://g;
$cycdate = parse_date($cycdate);
}
elsif ($line =~ /CYC_SAVE_BODY:/)
{
$cycmess = $line;
$cycmess =~ s/CYC_SAVE_BODY:\s//g;
$cycmess =~ s/CYC_SAVE_BODY://g;
$cycmess =~ s/ /\n/g;
}
elsif ($line =~ /CYC_SAVE_REPLY:/)
{
$cycreply = $line;
$cycreply =~ s/CYC_SAVE_REPLY:\s//g;
$cycreply =~ s/CYC_SAVE_REPLY://g;
$cycreply =~ s/\^/\n/g;
}
else
{
}
}
print qq^
^;
&print_footer;
exit;
}
else
{
&print_header;
$saveddir = "$userdat$popfold/folders/$folder";
if(-e $saveddir)
{
$tempuserdat = "$userdat$popfold/$popname.dat";
open(USERDAT, "< $tempuserdat") || die "Cannot open $tempuserdat";
while ()
{
$line = $_;
if ($line =~ /INBOXSORT/)
{
$sigline = $line;
my @row4=split (/\|/, $sigline);
$inboxsort = $row4[1];
}
}
close(USERDAT);
if ($inboxsort =~ /Reversed/)
{
# Reverse Sort
@savedfilelistrev = sort reverse @savedfilelist;
@savedfilelist = @savedfilelistrev;
}
else
{
# Forward Sort
}
$saveddir = "$userdat$popfold/folders/$folder/$message";
open(FILELIST, "< $saveddir") || die "Cannot open User Folder";
while()
{
$temp = $_;
$savedmessbody .= $temp;
}
close(FILELIST);
if ($savedmessbody)
{
if ($savedmessbody =~ /CYC_SAVE_FROM/)
{
@savedmessbody = split(/\n/, $savedmessbody);
$attcount = 0;
foreach $line (@savedmessbody)
{
if ($line =~ /CYC_SAVE_FROM:/)
{
$cycfrom = $line;
$cycfrom =~ s/CYC_SAVE_FROM:\s//g;
if ($cycfrom =~ /^<.*/)
{
$cycfrom =~ s//g;
$cycfrom =~ s/>//g;
}
}
elsif ($line =~ /CYC_SAVE_TO:/)
{
$cycto = $line;
$cycto =~ s/CYC_SAVE_TO:\s//g;
if ($cycto =~ /^<.*/)
{
$cycto =~ s//g;
$cycto =~ s/>//g;
}
}
elsif ($line =~ /CYC_SAVE_SUBJECT:/)
{
$cycsubject = $line;
$cycsubject =~ s/CYC_SAVE_SUBJECT:\s//g;
}
elsif ($line =~ /CYC_SAVE_DATE:/)
{
$cycdate = $line;
$cycdate =~ s/CYC_SAVE_DATE:\s//g;
$cycdate = parse_date($cycdate);
}
elsif ($line =~ /CYC_SAVE_BODY:/)
{
$cycbody = $line;
$cycbody =~ s/CYC_SAVE_BODY:\s//g;
}
elsif ($line =~ /CYC_SAVE_REPLY:/)
{
$cycreply = $line;
$cycreply =~ s/CYC_SAVE_REPLY:\s//g;
$cycreply =~ s/\^/\n/g;
}
elsif ($line =~ /ATTACH:/)
{
$attcount++;
$cycattach = $line;
$cycattach =~ s/ATTACH:\s//g;
$cycattach =~ s/\^/\n/g;
$cycdir = $cyclonic;
$cycdir =~ s/cyclonic.pl/attdld\//g;
$oldattfile = "$userdat$popfold/attach/$cycattach";
$dldattachfile = int(rand(100000));
$dldattachfile .= "-$$";
$dldattachfile .= ".cgi";
if ($attcount == 4)
{
$cycarray = "
$cycattach ";
$attcounter = 0;
}
else
{
$cycarray = "
$cycattach ";
}
push (@all_attach, $cycarray);
open(DLD, "> ./attdld/$dldattachfile") || die "Cannot open Message";
$attdld = "#!/usr/bin/perl\n";
$attdld .= "print \"Content-Type: application/octet-stream \\n\";\n";
$attdld .= "print \"Content-Disposition: inline; \";\n";
$attdld .= "print \"filename=$cycattach \\n\\n\";\n\n";
$attdld .= "open (MYFILE, '$oldattfile') || die \"Cannot Open Attachment\";\n";
$attdld .= "do {\n";
$attdld .= " \$line = ;\n";
$attdld .= " print \$line;\n";
$attdld .= "}\n";
$attdld .= "while (\$line ne \"\");\n\n";
$attdld .= "close (MYFILE);\n";
$attdld .= "exit;\n";
print DLD $attdld;
close (DLD);
chmod (0555, "./attdld/$dldattachfile");
}
else
{
}
}
print qq^
^;
}
else
{
show_mime($savedmessbody);
}
}
else
{
print "Error collecting Saved Message ";
}
}
&print_footer;
exit;
}
}
if ($button eq "$b2")
{
if ($listnext)
{
$listnext = $listnext - 10;
}
if (!($currentfolder eq "Inbox"))
{
$countinfolder = 0;
$saveddir = "$userdat$popfold/folders/$currentfolder";
opendir (SAVEDLIST, "$saveddir")|| die "I was unable to open the directory";
while ($file = readdir(SAVEDLIST2))
{
if (!($file eq "."))
{
if (!($file eq ".."))
{
$savedfilelist[$countinfolder] = $file;
$countinfolder++;
}
}
}
closedir (SAVEDLIST2);
if ($movefolder eq "Trash")
{
foreach $mess_no (@messages)
{
$savedmessage = "$userdat$popfold/folders/$currentfolder/$mess_no";
open(MESS, "< $savedmessage") || die "Cannot open Message";
while()
{
$temp = $_;
$savedmessbody .= $temp;
}
close(MESS);
@savedmessbody = split(/\n/, $savedmessbody);
foreach $line (@savedmessbody)
{
if ($line =~ /ATTACH:/)
{
$cycattach = $line;
$cycattach =~ s/ATTACH:\s//g;
$cycattach =~ s/\^/\n/g;
unlink("$userdat$popfold/attach/$cycattach");
}
}
unlink("$savedmessage");
}
$folder = $currentfolder;
&print_header;
&list_folder;
&print_footer;
exit;
}
else
{
foreach $mess_no (@messages)
{
$savedmessage = "$userdat$popfold/folders/$currentfolder/$mess_no";
$newsavedmessage = "$userdat$popfold/folders/$movefolder/";
`mv \"$savedmessage\" \"$newsavedmessage\"`;
}
$folder = $currentfolder;
&print_header;
&list_folder;
&print_footer;
exit;
}
}
elsif ($movefolder eq "Trash")
{
my $savemess = pummelpopserver($newpop, $popname, $poppass);
foreach $mess_no (@messages)
{
$savemess->delete($mess_no);
}
$savemess->quit;
}
else
{
$savedmessages = "$userdat$popfold/folders/$movefolder/";
srand (time|$$);
my $savemess = pummelpopserver($newpop, $popname, $poppass);
foreach $mess_no (@messages)
{
$savedfile = "";
$savedfile = int(rand(10000000));
$savedfile .= ".$$";
my $mess = $savemess->get($mess_no);
if (open(SAVED, "> $savedmessages$savedfile"))
{
$x = 0;
while ($mess->[$x] ne "")
{
print SAVED $mess->[$x];
$x++;
}
}
close(SAVED);
}
foreach $mess_no (@messages)
{
$savemess->delete($mess_no);
}
$savemess->quit;
}
}
if (($button eq "$b5") || ($button eq "$b6") || ($button eq "Compose") || ($button eq "$b12"))
{
&print_header;
if ($button eq "$b5")
{
$subject_type = "Re: ";
$mess_type = "You Wrote:\n----------\n\n";
}
elsif ($button eq "$b6")
{
$subject_type = "Fwd: ";
$mess_type = "Forwarded Message follows:\n--------------------------\n\n";
}
else
{
$subject_type = "";
$mess_type = "";
}
if(-e "$userdat$popfold/$popname.dat")
{
$tempuserdat = "$userdat$popfold/$popname.dat";
open(USERDAT, "< $tempuserdat") || die "Cannot open $tempuserdat";
while ()
{
$line = $_;
if ($line =~ /REPLYTOADD/)
{
$sendfrom = $line;
$sendfrom =~ s/REPLYTOADD\|//g;
$sendfrom =~ s/\n//g;
}
}
close(USERDAT);
}
if (!($sendfrom))
{
if ($popname =~ /\@/) {
$sendfrom = $popname;
} else {
$sendfrom = $popname . '@' . $newpop;
}
}
print qq^
^;
print qq^
^;
&print_footer;
exit;
}
if ($button eq "$b17")
{
$draftmessages = "$userdat$popfold/folders/Drafts";
if (!(-e $draftmessages))
{
mkdir($draftmessages, 0777);
}
srand (time|$$);
$draftfile = "";
$draftfile = int(rand(10000000));
$draftfile .= ".$$";
open(DRAFT, "> $draftmessages/$draftfile") || "Can't Open Draft Items Folder and File";
$date = `date`;
$drafttextsave = $sendtext;
$drafttextsave =~ s/\n/ /g;
$drafttextreply =~ s/^M//g;
$drafttextreply = $drafttextsave;
$drafttextreply =~ s/\n/^/g;
$drafttextreply =~ s/ //g;
print DRAFT "CYC_SAVE_FROM: $sendfrom\n\n";
print DRAFT "CYC_SAVE_TO: $sendto\n\n";
print DRAFT "CYC_SAVE_CC: $sendcc\n\n";
print DRAFT "CYC_SAVE_BCC: $sendbcc\n\n";
print DRAFT "CYC_SAVE_SUBJECT: $sendsubject\n\n";
print DRAFT "CYC_SAVE_DATE: $date\n\n";
print DRAFT "CYC_SAVE_BODY:$drafttextsave\n\n";
print DRAFT "CYC_SAVE_REPLY: $drafttextreply\n\n";
close(DRAFT);
&print_header;
&list_inbox;
&print_footer;
exit;
}
if ($button eq "$b1")
{
if (($folder eq "Inbox") || ($folder eq "-- $l11 --"))
{
if (!($folder eq $currentfolder))
{
$listnext = 10;
}
&print_header;
&list_inbox;
&print_footer;
exit;
}
else
{
&print_header;
&list_folder;
&print_footer;
exit;
}
}
$currentfolder = "Inbox";
&print_header;
&list_inbox;
&print_footer;
exit;
sub list_folder
{
$countinfolder = 0;
$saveddir = "$userdat$popfold/folders/$folder";
if(-e $saveddir)
{
opendir (SAVEDLIST, "$saveddir")|| die "I was unable to open the directory";
while ($file = readdir(SAVEDLIST))
{
if (!($file eq "."))
{
if (!($file eq ".."))
{
$savedfilelist[$countinfolder] = $file;
$countinfolder++;
}
}
}
closedir (SAVEDLIST);
}
$tempuserdat = "$userdat$popfold/$popname.dat";
open(USERDAT, "< $tempuserdat") || die "Cannot open $tempuserdat";
while ()
{
$line = $_;
if ($line =~ /INBOXSORT/)
{
$sigline = $line;
my @row4=split (/\|/, $sigline);
$inboxsort = $row4[1];
}
}
close(USERDAT);
if ($inboxsort =~ /Reversed/)
{
# Reverse Sort
@savedfilelistrev = sort reverse @savedfilelist;
@savedfilelist = @savedfilelistrev;
}
else
{
# Forward Sort
}
print qq^
^;
print qq^
^;
print qq^
^;
}
sub login
{
$error = "Error: ";
if (!($newpop))
{
$error .= "You must supply a Pop Server!";
&print_login;
}
my $poplogin = new Net::POP3($newpop);
$poplogin->login($popname, $poppass);
if ((not defined $poplogin) || (!$poplogin->ok) || ($poplogin->code() >= 400))
{
$error .= $poplogin->message();
&print_login;
}
$poplogin->quit;
#&print_header;
#&list_inbox;
#&print_footer;
#exit
}
sub print_login
{
print "Content-type: text/html\n\n";
open (LOGIN, "$base_require_directory/startpage.dat");
flock(LOGIN, $LOCK_EX);
while ()
{
$row = $_;
$login .= "$row";
}
close (LOGIN);
$startform =" ";
$printnext = $listmaxcheck;
$listnexttime = $max + 10;
$result_pages = qq^
Message Pages: ^;
$mess_pages = $countinbox / 10;
if ($mess_pages =~ /\./)
{
$mess_pages +=1;
}
if ($current_pane > 10)
{
$next = $current_pane - 10;
if (!($next <= 0))
{
$result_pages .= qq^ < Prev ^;
$result_pages .= qq^ ^;
}
}
for ($i = 1; $i <= $mess_pages; $i++)
{
$nh = ($i - 1) * 10;
if (!($result_max))
{
$result_max = 0;
}
$result_max += 10;
if ($result_max == $current_pane)
{
$result_pages .= qq^ $i ^;
}
else
{
$result_pages .= qq^ $i ^;
}
}
if ($result_max > 10)
{
$next = $current_pane + 10;
if ($next <= $result_max)
{
$result_pages .= qq^ ^;
$result_pages .= qq^ Next > ^;
}
}
print qq^
^;
$poplogin->quit;
}
sub filter_inbox
{
my $poplogin = pummelpopserver($newpop, $popname, $poppass);
my $countinbox = ($poplogin->popstat)[0];
my $mailboxk = ($poplogin->popstat)[1]; # gets the mailbox size
my($from, $subject, $date, $to, $i);
open (FILTER, "$userdat$popfold/filters.dat");
while ()
{
chop;
@all = split(/\n/);
foreach $line (@all)
{
($filter, $contains, $action) = split(/\|/, $line);
if ($filter)
{
# And do it for every message...
for ($i = 1; $i <= $countinbox; $i++)
{
my $p = $poplogin->top($i,0); # gets just the header
next unless defined $p;
my $head = new Mail::Header $p;
$subject = $head->get('Subject');
$from = $head->get('From');
$to = $head->get('To');
if ($filter eq "from")
{
if ($from =~ /$contains/i)
{
$filtered = $i;
if ($action eq "Trash")
{
$poplogin->delete($filtered);
}
else
{
$savedmessages = "$userdat$popfold/folders/$action/";
srand (time|$$);
$savedfile = "";
$savedfile = int(rand(10000000));
$savedfile .= ".$$";
my $mess = $poplogin->get($filtered);
if (open(SAVED, "> $savedmessages$savedfile"))
{
$x = 0;
while ($mess->[$x] ne "")
{
print SAVED $mess->[$x];
$x++;
}
close(SAVED);
}
$poplogin->delete($filtered);
}
}
}
elsif ($filter eq "to")
{
if ($to =~ /$contains/i)
{
$filtered = $i;
if ($action eq "Trash")
{
$poplogin->delete($filtered);
}
else
{
$savedmessages = "$userdat$popfold/folders/$action/";
srand (time|$$);
$savedfile = "";
$savedfile = int(rand(10000000));
$savedfile .= ".$$";
my $mess = $poplogin->get($filtered);
if (open(SAVED, "> $savedmessages$savedfile"))
{
$x = 0;
while ($mess->[$x] ne "")
{
print SAVED $mess->[$x];
$x++;
}
close(SAVED);
}
$poplogin->delete($filtered);
}
}
}
elsif ($filter eq "subject")
{
if ($subject =~ /$contains/i)
{
$filtered = $i;
if ($action eq "Trash")
{
$poplogin->delete($filtered);
}
else
{
$savedmessages = "$userdat$popfold/folders/$action/";
srand (time|$$);
$savedfile = "";
$savedfile = int(rand(10000000));
$savedfile .= ".$$";
my $mess = $poplogin->get($filtered);
if (open(SAVED, "> $savedmessages$savedfile"))
{
$x = 0;
while ($mess->[$x] ne "")
{
print SAVED $mess->[$x];
$x++;
}
close(SAVED);
}
$poplogin->delete($filtered);
}
}
}
}
}
}
}
close (FILTER);
$poplogin->quit;
}
##########################################
# Set up Message Body for Decoding
##########################################
sub show_mime
{
my($messagebody) = @_;
$mesgbody1 = "NO";
$mesgbody2 = "NO";
$attachdir = "$userdat$popfold/decode/";
opendir (ATTACH, "$attachdir") || die "I was unable to open the directory attachdir";
@attfiles = readdir(ATTACH);
closedir (ATTACH);
foreach $checkatt (@attfiles)
{
if (-M "$attachdir$checkatt" > .03)
{
unlink("$attachdir$checkatt");
}
}
my $parser = new MIME::Parser;
$parser->output_to_core('NONE');
$parser->output_dir("$attachdir");
$parser->parse_nested_messages('REPLACE');
my $entity = $parser->parse_data($messagebody) or die "Parse error! Error while paring MIME message.";
chkfor_html($entity, 'email');
dump_entity($entity, 'email');
if ($attachtable eq "NO")
{
print "";
}
else
{
}
print qq^
^;
$press_button = "move";
&list_folders;
print qq^
^;
}
sub chkfor_html
{
my ($entity, $name) = @_;
my $IO;
my @parts = $entity->parts;
if (@parts)
{
foreach my $i (0 .. $#parts)
{
chkfor_html($parts[$i], $name . ", part " . $i);
}
}
else
{
my ($type, $subtype) = split('/', $entity->head->mime_type);
my $body = $entity->bodyhandle;
my $filename = $entity->head->recommended_filename || 'no-name';
#print "---> $filename ";
#print "---> $subtype ";
if ($filename eq "no-name")
{
if ($subtype =~ /html/i)
{
#print "------- HTML Message Found ----- ";
$html_found = "YES";
}
}
}
}
sub dump_entity
{
my ($entity, $name) = @_;
my $IO;
my($from_head, $to_head, $subject_head, $date_head);
$from_head = $entity->head->get('From');
$subject_head = $entity->head->get('Subject');
$date_head = $entity->head->get('Date');
$cleandate_head = parse_date($date_head);
$to_head = $entity->head->get('To');
if (defined $from_head and defined $date_head and defined $to_head)
{
if ($mesgbody1 eq "NO")
{
$from_head =~ s/\n//g;
$subject_head =~ s/\n//g;
$subject2 = $subject_head;
$subject2 =~ s/\s//g;
if ($subject2 eq "")
{
$subject_head = $subject2;
}
else
{
}
if ((!($subject_head)) || ($subject_head eq ""))
{
$subject_head = "No Subject...."
}
else
{
}
$date_head =~ s/\n//g;
$to_head =~ s/\n//g;
if ($from_head =~ /^<.*/)
{
$from_head =~ s//g;
$from_head =~ s/>//g;
}
if ($to_head =~ /^<.*/)
{
$to_head =~ s//g;
$to_head =~ s/>//g;
}
print qq^
$l6
^;
$mesgbody1 = "YES";
}
}
my @parts = $entity->parts;
if (@parts)
{
$attachcounter = 0;
$attachtable = "YES";
foreach my $i (0 .. $#parts)
{
dump_entity($parts[$i], $name . ", part " . $i);
}
}
else
{
my ($type, $subtype) = split('/', $entity->head->mime_type);
my $body = $entity->bodyhandle;
my $filename = $entity->head->recommended_filename || 'no-name';
if ($filename eq "no-name")
{
if (($type =~ /^(text|message)$/) && (!($html_found eq "YES")))
{
if ($IO = $body->open("r"))
{
my $txt;
$txt .= $_ while (defined($_ = $IO->getline));
$IO->close;
if (($txt =~ //i) && ($mesgbody2 eq "NO"))
{
$txtreply = $txt;
$txtreply =~ s/&/&/g;
$txtreply =~ s/"/"/g;
$txtreply =~ s/</g;
$txtreply =~ s/>/>/g;
$rlink = $cyclonic;
$rlink =~ s/cyclonic.pl/rlink.cgi/g;
$txt =~ s|href="|href="$rlink?site=|g;
$txt =~ s|^[A-Z]*>.*|$& |gm;
$txt =~ s|([^/>])(www\.[a-z\-0-9/~._,\#=;?&]+\.[a-z\-0-9/_]+)|$1$2 |igm;
$txt =~ s|(ftp://[a-z\-0-9/~._,]+[a-z\-0-9/_])|$1 |igm;
$txt =~ s|([a-z\-0-9._,]+\@[a-z.]+[a-z])|$1 |igm;
$txt =~ s|([^\"])(mailto:[a-z\-0-9._,]+@[a-z\-0-9.]+[a-z\-0-9])|$1$2 |igm;
print "
";
print "$txt";
print " ";
$mesgbody2 = "YES";
}
else
{
}
$txt =~ s/&/&/g;
$txt =~ s/"/"/g;
$txt =~ s/</g;
$txt =~ s/>/>/g;
$txt =~ s/\n/ \n/g;
$txtreply = $txt;
$rlink = $cyclonic;
$rlink =~ s/cyclonic.pl/rlink.cgi/g;
$txt =~ s|href="|href="$rlink?site=|g;
$txt =~ s|^[A-Z]*>.*|$& |gm;
$txt =~ s|(https?://[a-z\-0-9/~._,\#=;?&%]+[a-z\-0-9/_])|$1 |igm;
$txt =~ s|(.+?)> ;|$2 >|igm;
$txt =~ s|([^/>])(www\.[a-z\-0-9/~._,\#=;?&]+\.[a-z\-0-9/_]+)|$1$2 |igm;
$txt =~ s|(ftp://[a-z\-0-9/~._,]+[a-z\-0-9/_])|$1 |igm;
$txt =~ s|([a-z\-0-9._,]+\@[a-z.]+[a-z])|$1 |igm;
$txt =~ s|([^\"])(mailto:[a-z\-0-9._,]+@[a-z\-0-9.]+[a-z\-0-9])|$1$2 |igm;
if ($mesgbody2 eq "NO")
{
print "$txt";
$txtreply =~ s/ //g;
print " ";
$mesgbody2 = "YES";
}
}
else
{
print "MIME Error MIME Error.";
}
}
elsif (($html_found eq "YES") && ($subtype =~ /html/i) && ($mesgbody2 eq "NO"))
{
if ($IO = $body->open("r"))
{
my $txt;
$txt .= $_ while (defined($_ = $IO->getline));
$IO->close;
#print "---- HTML Printing ---- ";
$txtreply = $txt;
$txtreply =~ s/&/&/g;
$txtreply =~ s/"/"/g;
$txtreply =~ s/</g;
$txtreply =~ s/>/>/g;
$rlink = $cyclonic;
$rlink =~ s/cyclonic.pl/rlink.cgi/g;
$txt =~ s|href="|href="$rlink?site=|g;
$txt =~ s|^[A-Z]*>.*|$& |gm;
$txt =~ s|([^/>])(www\.[a-z\-0-9/~._,\#=;?&]+\.[a-z\-0-9/_]+)|$1$2 |igm;
$txt =~ s|(ftp://[a-z\-0-9/~._,]+[a-z\-0-9/_])|$1 |igm;
$txt =~ s|([^\"])(mailto:[a-z\-0-9._,]+@[a-z\-0-9.]+[a-z\-0-9])|$1$2 |igm;
$txt =~ s|([a-z\-0-9._,]+\@[a-z.]+[a-z])|$1 |igm;
print "
";
print "$txt";
print " ";
$mesgbody2 = "YES";
}
}
}
else
{
my $path = $body->path;
my $size = ($path ? (-s $path) : '???');
my $filename = $entity->head->recommended_filename || 'no-name';
if ($attachtable eq "YES")
{
print qq^
$l14:
^;
$attachtable = "NO";
}
$cycdir = $cyclonic;
$cycdir =~ s/cyclonic.pl/attdld\//g;
$filename2 = $filename;
#$filename2 =~ s/\s/\%20/g;
$dldattachfile = int(rand(100000));
$dldattachfile .= "-$$";
$dldattachfile .= ".cgi";
print qq^
$filename - $size bytes
File Type: $type/$subtype
^;
open(DLD, "> ./attdld/$dldattachfile") || die "Cannot open Message";
$attdld = "#!/usr/bin/perl\n";
$attdld .= "print \"Content-Type: application/octet-stream \\n\";\n";
$attdld .= "print \"Content-Disposition: inline; \";\n";
$attdld .= "print \"filename=$filename2 \\n\\n\";\n\n";
$attdld .= "open (MYFILE, '$userdat$popfold/decode/$filename') || die \"Cannot Open Attachment\";\n";
$attdld .= "do {\n";
$attdld .= " \$line = ;\n";
$attdld .= " print \$line;\n";
$attdld .= "}\n";
$attdld .= "while (\$line ne \"\");\n\n";
$attdld .= "close (MYFILE);\n";
$attdld .= "exit;\n";
print DLD $attdld;
close (DLD);
chmod (0555, "./attdld/$dldattachfile");
$attachcounter++;
}
if ($attachcounter == 3)
{
print " ";
$attachcounter = 0;
}
}
}
sub clean_header
{
my($header) = @_;
if ($header)
{
$header =~ s|<|<|m;
$header =~ s|>|>|m;
chomp $header;
}
return $header;
}
sub parse_date
{
my($date) = clean_header(@_);
$date = parsedate($date);
#if ($date > (time - (60*60*24)))
#{
# $date = strftime("%R", localtime $date);
#}
#elsif ($date > (time - (60*60*24*7)))
#{
# $date = strftime("%a %R", localtime $date);
#}
#else
#{
# $date = strftime("%a %e/%m/%y %R", localtime $date);
$date = strftime("%a %D %R", localtime $date);
#}
return $date;
}
sub list_folders
{
if ($press_button eq "move")
{
print qq^
-- $l11 --
^;
}
else
{
print qq^
-- $l11 --
Inbox
^;
}
opendir (DIR, "$userdat$popfold/folders");
@dir = grep(!/^\.\.?$/, readdir(DIR));
closedir (DIR);
foreach (@dir)
{
if ($_ eq "Sent Items")
{
if ($press_button eq "move")
{
}
else
{
print qq^
$_
^;
}
}
elsif ($_ eq "Drafts")
{
if ($press_button eq "move")
{
}
else
{
print qq^
$_
^;
}
}
else
{
if ($allow_save == 1)
{
}
else
{
print qq%
$_
%;
}
}
}
if ($press_button eq "move")
{
print qq^
Trash
^;
}
print qq%
%;
}
sub clean_address
{
my($from) = clean_header(@_);
if ($from)
{
if (($from =~ m|\@.+\@|) && ($from =~ m|, |))
{
my @froms = split ',', $from;
@froms = map clean_oneaddress($_), @froms;
return join ', ', @froms;
}
else
{
return clean_oneaddress($from);
}
}
else
{
return ' ';
}
}
sub clean_oneaddress
{
my($from) = clean_header(@_);
$from =~ s|^\s+||;
$from =~ s|\s+$||;
$from =~ s|\"||g;
$from =~ s|\n||g;
if ($from =~ s|^(.+) <(.+)>$||i)
{
$from = "$2";
}
elsif ($from =~ s|^(.+) \((.+)\)$||i)
{
$from = "$1";
}
elsif ($from =~ m|^(.+\@.+)$|)
{
$from = "$from";
}
$from =~ s|^\"||;
$from =~ s|\s$||;
$from =~ s|\"$||;
$from = " " if ($from eq "");
return $from;
}
sub encode_base64 ($;$)
{
my $res = "";
my $eol = $_[1];
$eol = "\n" unless defined $eol;
pos($_[0]) = 0;
while ($_[0] =~ /(.{1,45})/gs)
{
$res .= substr(pack('u', $1), 1);
chop($res);
}
$res =~ tr|` -_|AA-Za-z0-9+/|;
my $padding = (3 - length($_[0]) % 3) % 3;
$res =~ s/.{$padding}$/'=' x $padding/e if $padding;
if (length $eol)
{
$res =~ s/(.{1,76})/$1$eol/g;
}
$res;
}