#!/usr/bin/perl # # CYCLONIC WEBMAIL ENGINE - Version 4.0 (Release) # Copyright STALLION Networking 1998-2001 # # Version 4.00 # Released: 10/12/2000 # ################################################ # # No part of this script may be reproduced # or used in other software. Doing so # contravenes the Copyright License you # have agreed to by installing the # Cyclonic Software. # ################################################ require ('cyclonic.conf'); require ('require/cyclonic.ini'); if (!($sid)) { &print_login; } if (!($newpop)) { $newpop = $popserver; } if ($sid eq "NONE") { srand (time|$$); $sessionidfile = int(rand(100000)); $sessionidfile .= ".$$"; $sessionid = "$popname $poppass $currentlanguage $newpop @"; $cryptsess = pack("u*", $sessionid); open(SESSID, "> $base_sid_directory$sessionidfile") || die "Cannot open $base_sid_directory$sessionidfile"; $cryptsess =~ s/\n//g; print SESSID "$cryptsess"; close(SESSID); $sid = $sessionidfile; $logstat = "LOGIN"; &logging; } elsif ($sessionid =~ /\@/) { @pop = split (/ /, $sessionid); $popname = $pop[0]; $poppass = $pop[1]; $currentlanguage = $pop[2]; $newpop = $pop[3]; open(SESSID, "< $base_sid_directory$sid") || die "Error opening db $sessiondb"; $newsession = ; close(SESSID); # Touch the file to keep it fresh open(SESSID, "> $base_sid_directory$sid") || die "Cannot open $base_sid_directory$sid"; print SESSID "$newsession"; close(SESSID); } use Socket; use CGI qw(:cgi); use Fcntl; use File::Path; use MIME::Parser; use File::Basename; use Time::CTime; use Time::ParseDate; use Net::POP3; use Mail::Internet; $popfold = "$popname-$newpop"; opendir (SESSIONID, "$base_sid_directory") || die "I was unable to open the directory sids"; @sidfiles = readdir(SESSIONID); closedir (SESSIONID); foreach $checkingsid (@sidfiles) { if (-M "$base_sid_directory$checkingsid" > .1) { unlink("$base_sid_directory$checkingsid"); } } opendir (ATT, "./attdld") || die "I was unable to open the directory attdld"; @attfiles = readdir(ATT); closedir (ATT); foreach $checkingatt (@attfiles) { if (-M "./attdld/$checkingatt" > .03) { unlink("./attdld/$checkingatt"); } } $user = "$popname\@$newpop"; &language_check; if ($button eq "Login") { &login; } if (-e "$userdat$popfold/$popname.dat") { } else { $tempuserdat = "$userdat$popfold/$popname.dat"; mkdir ("$userdat$popfold", 0777); mkdir ("$userdat$popfold/folders", 0777); mkdir ("$userdat$popfold/decode", 0777); mkdir ("$userdat$popfold/folders/Sent Items", 0777); mkdir ("$userdat$popfold/folders/Drafts", 0777); mkdir ("$userdat$popfold/folders/Drafts", 0777); open(USERDAT, "> $tempuserdat") || die "Cannot open $tempuserdat"; print USERDAT "FULLNAME|\n"; print USERDAT "SINATURE|\n"; print USERDAT "REPLYTOADD|\n"; print USERDAT "INBOXSORT|Normal\n"; close(USERDAT); &pummelpopserver; } if ($button eq "$b4") { 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 "Logout") { print "Content-type: text/html\n\n"; print qq^ Web-Mail Logout

 

 

Thank You for using the Web-Mail
Service @ www.$popdomain!

Please wait ...... Closing Session!

 

 

^; $logstat = "LOGOUT"; &logging; $todeletesid = "$base_sid_directory$sid"; if(-e $todeletesid) { unlink("$todeletesid"); } exit; } if ($button eq "$b13") { $button = "profile"; $action = "contacts"; $dbaction = "$b13"; } if ($button eq "$b15") { $button = "profile"; $action = "contacts"; $dbaction = "$b15"; } if ($button eq "$b16") { $button = "profile"; $action = "contacts"; $dbaction = "$b16"; } if ($button eq "profile") { if ($action eq "preferences") { $signature =~ s/\n//g; if ($dbaction eq "$b7") { $tempuserdat = "$userdat$popfold/$popname.dat"; open(USERDAT, "> $tempuserdat") || die "Cannot open $tempuserdat"; { print USERDAT "FULLNAME|$fullname\n"; print USERDAT "SIGNATURE|$signature\n"; print USERDAT "REPLYTOADD|$replytoadd\n"; print USERDAT "INBOXSORT|$inboxsort\n"; } close(USERDAT); } $tempuserdat = "$userdat$popfold/$popname.dat"; open(USERDAT, "< $tempuserdat") || die "Cannot open $tempuserdat"; while () { $line = $_; if ($line =~ /FULLNAME/) { $nameline = $line; my @row1=split (/\|/, $nameline); $fullnameshow = $row1[1]; } if ($line =~ /SIGNATURE/) { $sigline = $line; my @row2=split (/\|/, $sigline); $signatureshow = $row2[1]; } if ($line =~ /REPLYTOADD/) { $sigline = $line; my @row3=split (/\|/, $sigline); $replytoaddshow = $row3[1]; } if ($line =~ /INBOXSORT/) { $sigline = $line; my @row4=split (/\|/, $sigline); $inboxsortshow = $row4[1]; } } close(USERDAT); &print_header; print qq^

$l7
($l31)


Email Address
(Your Actual Email Address)


^; if ($inboxsortshow =~ /Reversed/) { print qq^ Mailbox Folder Sorting
(Reversed or Normal sorting of your Mail)


^; } else { print qq^ Mailbox Folder Sorting
(Reverse or Normal sorting of your Mail)


^; } print qq^

$l8
($l32)


^; &print_footer; exit; } if ($action eq "filters") { if ($dbaction eq "$b11") { &print_header; print qq^


^; print qq^
$l19 $l20 Action

 

$l37: ^; $press_button = "move"; &list_folders; print qq^

 

^; &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^



^; $entries = 1; open (FILTER, ">> $userdat$popfold/filters.dat"); close (FILTER); open (FILTER, "$userdat$popfold/filters.dat"); while () { chop; @all = split(/\n/); foreach $line (@all) { ($filter, $contains, $action) = split(/\|/, $line); print qq^ ^; $entries++; } } close (FILTER); $entries = $entries - 1; print qq^
$l19 $l20 $l21 $l22
$filter $contains $action

 

$l34  $entries $l36.

^; 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^


$l17 $l18

 


** $l33

$l11 $l21
^; print qq^



^; 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^
Required Information
Nick Name:
E-Mail Address:
 
Optional Information
First Name: Last Name:
Web Page:
 
  Personal Information
Street Address:
Suburb/City:
State:
Zip/Postal Code:
Country:
Home Phone:
Fax:
Mobile:
 
  Work Information
Company:
Street Address:
Suburb/City:
State:
Zip/Postal Code:
Country:
Work Phone:
Fax:
 
 
^; &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^
 
Nick Name:
E-Mail Address:
 
First Name: Last Name:
Web Page:
 
  Personal Information
Street Address:
Suburb/City:
State:
Zip/Postal Code:
Country:
Home Phone:
Fax:
Mobile:
 
  Work Information
Company:
Street Address:
Suburb/City:
State:
Zip/Postal Code:
Country:
Work Phone:
Fax:
 
Back to Contact Manager
 
^; &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^
^; $count=1; open (DATABASE, ">> $userdat$popfold/addressbook.db") || die "Cant Open Contact DB"; close (DATABASE); open (DATABASE, "$userdat$popfold/addressbook.db"); flock(DATABASE, $LOCK_EX); while () { $row = $_; chop $row; @dbrow = split (/\|/, $row); print qq^ ^; $count++; } close (DATABASE); $entries = $count - 1; print qq^
To Cc $l23 $l24 Web $l25 $l22
$dbrow[0] $dbrow[3] ^; if (!($dbrow[4] eq "") || ($dbrow[4] eq " ")) { print qq^ Contacts Web Site ^; } else { print " "; } print qq^ Edit this Contact Delete this Contact

 

$l35  $entries $l36.

^; &print_footer; exit; } &print_header; print qq^

 

^; $date = `date`; $displayname = $popname; $remote = $ENV{'REMOTE_ADDR'}; $printinfo = qq^ User: $displayname
Pop: $newpop
Remote Host: $remote ^; print qq^
 
$l27   $l28
     
 
$l29   $l30
     
 
$l41  $printinfo
     

 

^; &print_footer; exit; } if ($button eq "abook") { print "Content-type: text/html\n\n"; print "Contact Manager"; print qq^
Contact Manager Entries
^; $script .= qq^ ^; print "$script"; $num = "1"; open (DATABASE, "$userdat$popfold/addressbook.db"); flock(DATABASE, $LOCK_EX); while () { $row = $_; chop $row; @dbrow = split (/\|/, $row); print qq^ ^; $num++; } close(DATABASE); print "
To Cc Bcc   Entry
  $dbrow[0]
  ($dbrow[3])

"; 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; send Socket_Handle, "RCPT To: $line\r\n", 0; } foreach $line (@cc) { $line =~ s/.*.*//g; send Socket_Handle, "RCPT To: $line\r\n", 0; } foreach $line (@bcc) { $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; } } 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; } } 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; } } 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; } } 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 qq^ ^; $tempuserdat = "$userdat$popfold/$popname.dat"; open(USERDAT, "< $tempuserdat") || die "Cannot open $tempuserdat"; while () { $line = $_; if ($line =~ /SIGNATURE/) { $sigline = $line; my @row2=split (/\|/, $sigline); $signature = $row2[1]; } } close(USERDAT); print qq^
$l12: Address Book
Cc: Address Book
Bcc: Address Book
$l13:
$l14:
$l6:  $l15
^; $cycmess =~ s//\>/g; $cycmess =~ s/"/\"/g; 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; } } elsif ($line =~ /CYC_SAVE_TO:/) { $cycto = $line; $cycto =~ s/CYC_SAVE_TO:\s//g; if ($cycto =~ /^<.*/) { $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^

Date: $cycdate
$l16: $cycfrom
$l12: $cycto
$l13: $cycsubject

 

$l6: Print Message
^; print "$cycbody"; print ""; if (@all_attach) { print qq^
Attachments:
@all_attach
^; } 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^
^; if (@to) { foreach $line (@cc) { $line =~ s/\s//g; $line =~ s/\n//g; $linespc = ";"; $line .= ";"; $cc_array .= $line; } print qq^ ^; } else { print qq^ ^; } $tempuserdat = "$userdat$popfold/$popname.dat"; open(USERDAT, "< $tempuserdat") || die "Cannot open $tempuserdat"; while () { $line = $_; if ($line =~ /SIGNATURE/) { $sigline = $line; my @row2=split (/\|/, $sigline); $signature = $row2[1]; } } close(USERDAT); print qq^
$l12: Address Book
Cc: Address Book
Bcc: Address Book
$l12: Address Book
Cc: Address Book
Bcc: Address Book
$l13:
$l14:
$l6:  $l15
 

^; &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^

$l1: ^; if ($popname =~ /\@/) { print qq^$popname^; } else { print qq^$popname\@$newpop^; } print qq^ ^; &list_folders; print qq^
$folder: $countinfolder Messages
^; if ($countinfolder == "0") { print qq^ ^; } if (!($listnext)) { $num_col = 10; } else { $num_col = $listnext; } if (!($listnext)) { $max = 9; $next = $max - 9; $current_pane = 10; } else { $listnext -= 1; $max = $listnext; $next = $max - 9; $current_pane = $listnext + 1; } if ($max >= $countinfolder) { $countinboxtt = $countinfolder - 1; @newmesslist = @savedfilelist[$next..$countinboxtt]; } else { @newmesslist = @savedfilelist[$next..$max]; } #$start = 0; #$stop = 1; #$i = 0; #for($i = $start; $i <= $countinfolder - $stop; $i++) foreach $i (@newmesslist) { $from = ""; $date = ""; $subject = ""; $oldformat = "0"; $savedmessbody = ""; $saveddir = "$userdat$popfold/folders/$folder/$i"; #$saveddir = "$userdat$popfold/folders/$folder/$savedfilelist[$i]"; @stat_info = stat("$saveddir"); $savedmess_size += $stat_info[7]; use integer; $savedmess_size /= 1024; $user_kb += $savedmess_size; no integer; open(FILELIST, "< $saveddir") || die "Cannot open User Folder"; while() { $temp = $_; $savedmessbody .= $temp; } close(FILELIST); if ($savedmessbody =~ /CYC_SAVE_FROM/) { $oldformat = "1"; } else { $oldformat = "2"; } @savedmessbody = split(/\n/, $savedmessbody); if (!($num)) { $num = $num_col - 9; } if ($num =~ /\b[1-9]\b/) { $num = "0$num"; } else { } print qq^ ^; if ($oldformat eq "1") { $oldformat = "0"; foreach $line (@savedmessbody) { if ($line =~ /CYC_SAVE_FROM:/) { $from = $line; $from =~ s/CYC_SAVE_FROM:\s//g; if ($from =~ /^<.*/) { $from =~ s///g; } } elsif ($line =~ /CYC_SAVE_SUBJECT:/) { $subject = $line; $subject =~ s/CYC_SAVE_SUBJECT:\s//g; $subject2 = $subject; $subject2 =~ s/\s//g; if ($subject2 eq "") { $subject = $subject2; } else { } if ((!($subject)) || ($subject eq "")) { $subject = "No Subject...." } else { } } elsif ($line =~ /CYC_SAVE_DATE:/) { $date = $line; $date =~ s/CYC_SAVE_DATE:\s//g; $date = parse_date($date); } else { } } } else { $oldformat = "0"; foreach $line (@savedmessbody) { if ($line =~ /^From:/i) { $from = $line; $from =~ s/^From://g; $from =~ s/"//g; if ($from =~ ///g; } } elsif ($line =~ /^Date:/i) { $date = $line; $date =~ s/^Date://g; $date = parse_date($date); } elsif ($line =~ /^Subject:/i) { $subject = $line; $subject =~ s/^Subject://g; } else { } } } print " ^; print ""; print qq^ ^; $num++; } $printnext = $listmaxcheck; $listnexttime = $max + 10; $result_pages = qq^Message Pages:  ^; $mess_pages = $countinfolder / 10; if ($mess_pages =~ /\./) { $mess_pages +=1; } $b1 =~ s/\s/%20/g; $currentfolder =~ s/\s/%20/g; $folder =~ s/\s/%20/g; 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^


$l2

$l3

$l4

$l5

 

$l38!

 

$num
$from
"; $folder2 = $folder; $folder2 =~ s/\s/%20/g; print qq^ $subject
$date$savedmess_size Kb Saved Message
^; print qq^
$result_pages
^; print qq^
$l9 ^; $press_button = "move"; &list_folders; print qq^
$l10: $user_kb Kb
^; } 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 ="
"; $startid = ""; $startbutton = ""; $login =~ s/<--! STARTFORM -->/$startform$startid/g; $login =~ s/<--! BUTTON -->/$startbutton/g; $login =~ s/<--! ENDFORM -->/<\/form>/g; if ($error) { $login =~ s/<--! ERROR -->/$error/g; } else { $login =~ s/<--! ERROR -->//g; } print "$login"; exit; } sub logging { $hacklog = "$base_log_directory/access.log"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @months = ("Jan","Feb","Mar","Apr","May","June","July","Aug","Sep","Oct","Nov", "Dec"); $is_2000 = 0; if ($year>=100) { $is_2000 = 1; $year = $year - 100; } if ($year<10) { $year = "0" . "$year"; } if ($is_2000) { $year = "20" . "$year"; } if ($year<100) { $year = "19" . "$year"; } $stamp = "$hour:$min:$sec $months[$mon] $mday $year"; if (open(HACKER, "+>> $hacklog")) { flock HACKER, 2 or die"Cant flock the hacker file: $!"; print HACKER "$status $stamp $popname ---- $logstat \n"; close(HACKER); } } sub print_header { $headerfolder = $folder; $headerfolder =~ s/\s/%20/g; print "Content-type: text/html\n\n"; open (HEADER, "$base_require_directory/header.dat"); flock(HEADER, $LOCK_EX); while (
) { $row = $_; $header .= "$row"; } close (HEADER); $mstartform = ""; $msessionid = ""; $minbox = "$cyclonic?SESSIONID=$sid&CURRENTFOLDER=$currentfolder"; $mcompose = "$cyclonic?SESSIONID=$sid&BUTTON=Compose&CURRENTFOLDER=$headerfolder"; $moptions = "$cyclonic?SESSIONID=$sid&BUTTON=profile"; $mhelp = "$helppages"; $mlogout = "$cyclonic?SESSIONID=$sid&BUTTON=Logout"; $header =~ s/<--! STARTFORM -->/$mstartform/g; $header =~ s/<--! SESSIONID -->/$msessionid/g; $header =~ s/<--! INBOX -->/$minbox/g; $header =~ s/<--! COMPOSE -->/$mcompose/g; $header =~ s/<--! OPTIONS -->/$moptions/g; $header =~ s/<--! HELP -->/$mhelp/g; $header =~ s/<--! LOGOUT -->/$mlogout/g; print "$header"; } sub print_footer { open (FOOTER, "$base_require_directory/footer.dat"); flock(FOOTER, $LOCK_EX); while (
) { $row = $_; $footer .= "$row"; } close (FOOTER); $footer =~ s/<--! ENDFORM -->/<\/form>/g; print "$footer"; } ###################################### # New POP Server Login Routines ###################################### sub pummelpopserver { my $poplogin = new Net::POP3($newpop); $poplogin->login($popname, $poppass); if ((not defined $poplogin) || (!$poplogin->ok) || ($poplogin->code() >= 400)) { $error .= $poplogin->message(); &print_login; } return $poplogin; $status = "PASS"; } sub language_check { if ($currentlanguage eq "") { $currentlanguage = "English"; } $lrequire = "languages/$currentlanguage.dat"; require $lrequire; } ###################################### # Show Messages on Default Pop Server ###################################### sub list_inbox { &filter_inbox; my $poplogin = pummelpopserver($newpop, $popname, $poppass); my $countinbox = ($poplogin->popstat)[0]; my $mailboxk = ($poplogin->popstat)[1]; # gets the mailbox size use integer; $mailboxk /= 1024; no integer; $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); print qq^
$l1: ^; if ($popname =~ /\@/) { print qq^$popname^; } else { print qq^$popname\@$newpop^; } print qq^ ^; &list_folders; print qq^
Inbox: $countinbox Messages
^; if ($countinbox == "0") { print qq^ ^; } else { } my($from, $email, $subject, $date, $url, $size, $delete, $i); my $bgcolor = '#aaffaa'; ############################ # List Number Routine ############################ for ($i = 1; $i <= $countinbox; $i++) { if ($i =~ /\b[1-9]\b/) { $inew = "0$i"; push(@messlist, $inew); } else { push(@messlist, $i); } } if (!($listnext)) { $num_col = 10; } else { $num_col = $listnext; } if (!($listnext)) { $max = 9; $next = $max - 9; $current_pane = 10; } else { $listnext -= 1; $max = $listnext; $next = $max - 9; $current_pane = $listnext + 1; } if ($inboxsort =~ /Reversed/) { # Reverse Sort @messlistrev = sort { $b cmp $a; } @messlist; } else { # Forward Sort @messlistrev = @messlist; } if ($max >= $countinbox) { $countinboxtt = $countinbox - 1; @newmesslist = @messlistrev[$next..$countinboxtt]; } else { @newmesslist = @messlistrev[$next..$max]; } foreach $i (@newmesslist) #foreach $i (@messlistrev) { my $p = $poplogin->top($i,0); # gets just the header next unless defined $p; my $head = new Mail::Header $p; $status = $head->get('Status'); if ($status =~ /RO/i) { $status = "\"Old"; } else { $status = "\"New"; } $queryattach = $head->get('Content-Type'); if ($queryattach =~ /multipart/i ) { $queryattach = "\"Contains"; } else { $queryattach = ""; } $querypriority = $head->get('X-Priority'); if ($querypriority =~ /1/ ) { $querypriority = "\"High"; } else { $querypriority = ""; } $subject = $head->get('Subject'); $from = $head->get('From'); $from =~ s/"//g; if ($from =~ ///g; } $date = parse_date($head->get('Date')); $size = int($poplogin->list($i) / 1024); 1 while $size =~ s/(.*\d)(\d\d\d)/$1,$2/; $size .= " Kb"; $subject2 = $subject; $subject2 =~ s/\s//g; if ($subject2 eq "") { $subject = $subject2; } else { } if ((!($subject)) || ($subject eq "")) { $subject = "No Subject...." } else { } $query->param('show', $i); $url = $query->self_url; $query->delete('show'); $subject = qq^$subject^; $delete = $i; if (!($num)) { $num = $num_col - 9; } print qq^ ^; $num++; } print "


$l2

$l3

$l4

$l5

 

$l38!

 

$num
$from
$subject
  $date   $size   $status$queryattach$querypriority
"; $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^
$result_pages
$l9 ^; $press_button = "move"; &list_folders; print qq^
$l10: $mailboxk Kb
^; $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; } if ($to_head =~ /^<.*/) { $to_head =~ s///g; } print qq^
Date: $cleandate_head
$l16: $from_head
$l12: $to_head
$l13: $subject_head
^; $from_head = clean_address($from_head); print qq^
^; &list_folders; print qq^

$l6 Print Message
^; $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; $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/\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; $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^ ^; 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^ ^; } 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^ ^; } 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; }

$filename - $size bytes
File Type: $type/$subtype