Z
zoomcart.com
Hello and thanks in advance for you help.
I have a simple email program that has a bulk add feature where a user
can add an email list separated by returns. It works fine, except when
the user tries to edit and remove an email, the script is not
recognizing the email. If the email was added individually, it
recognizes it. This may only be caused when the user is using a mac. I
have tried several chomp variations.
This is the bulk add code..
sub add_bulk_email{
my ($newemail, $bademail, $email, $newemail, $checkemail);
$checkemail = param('checkemail');
@emails = split(/\n+/, $checkemail);
foreach $email(@emails){
unless ($email =~ /.*\@.*\..*/) {
$bademail=$email;
}
else{
$emailcnt++;
chomp $email;
#chomp $email if ($email =~ /\n$/);
#chomp $email if ($email =~ /\r$/);
$newemail .= "$email\n";
}
}
if($newemail){
open (USERS, ">>$userpath/lists/$list") || &adminerror("$userpath/
lists/$list Update Account" , __FILE__, __LINE__,);
print USERS $newemail;
close (USERS);
&success("$emailcnt Bulk emails have been added to the list");
}#new email
else{ &adminerror("There were No REAL emails in your list");
}
##########################
This is the code for the individual add...
sub add_new_email
{
my ($new_email, @fields, $checkemail, $line);
$checkemail = param('checkemail');
unless ($checkemail =~ /.*\@.*\..*/) {
&adminerror("Please incude a REAL email address.");
}
if($checkemail eq ""){
&adminerror("Please include an email address");
}
chomp $checkemail;
if(-e "$userpath/lists/$list"){
open (USERS, "$userpath/lists/$list") || &adminerror("$userpath/
lists/$list add new email " , __FILE__, __LINE__,);
flock(USERS, LOCK_EX);
while (<USERS>)
{
$line = $_;
chomp $line if ($line =~ /\n$/);
if ($checkemail eq $line){
$newemail = "";
}
else{
$newemail = $checkemail;
}#else
} # End of while (<USERS>)
close (USERS);
}
else{ &adminerror("$list was not found");}
if($newemail){
open (USERS, ">>$userpath/lists/$list") || &adminerror("$userpath/
lists/$list Update Account" , __FILE__, __LINE__,);
print USERS "$newemail\n";
close (USERS);
&success("$checkemail has been added to $list");
}#new email
else{ &adminerror("$checkemail is already on the list");
}
}#update
#########################
And this is the code for the remove email...
sub adminremove_email
my ($new_data, @fields, $old_data, $removeemail, $line);
$removeemail = param('checkemail');
if($removeemail eq ""){
&adminerror("You must include an email");
}
else{
$new_data = "";
open (USERS, "$userpath/lists/$list") || &adminerror("$userpath/
lists/$list Update" , __FILE__, __LINE__,);
flock(USERS, LOCK_EX);
while (<USERS>)
{
$line = $_;
#chop $line;
chomp $line;
#chomp ($line);
#chomp ($line) if ($line =~ /\n$/);
#chomp $line if ($line =~ /\n$/);
#chomp $line if ($line =~ /\r$/);
if ($removeemail ne $line){
$new_data .= "$line\n";
}
else{
$old_data .= "$line\n";
}#else
} # End of while (<USERS>)
close (USERS);
if($old_data){
open (USERS, ">$userpath/lists/$list") || &adminerror("$userpath/
lists/$list Update Account" , __FILE__, __LINE__,);
print USERS "$new_data";
close (USERS);
&success("$removeemail has been removed");
}
else{
&adminerror("$removeemail was not found");
}
}#we have an email
}#adminremove_email
I have a simple email program that has a bulk add feature where a user
can add an email list separated by returns. It works fine, except when
the user tries to edit and remove an email, the script is not
recognizing the email. If the email was added individually, it
recognizes it. This may only be caused when the user is using a mac. I
have tried several chomp variations.
This is the bulk add code..
sub add_bulk_email{
my ($newemail, $bademail, $email, $newemail, $checkemail);
$checkemail = param('checkemail');
@emails = split(/\n+/, $checkemail);
foreach $email(@emails){
unless ($email =~ /.*\@.*\..*/) {
$bademail=$email;
}
else{
$emailcnt++;
chomp $email;
#chomp $email if ($email =~ /\n$/);
#chomp $email if ($email =~ /\r$/);
$newemail .= "$email\n";
}
}
if($newemail){
open (USERS, ">>$userpath/lists/$list") || &adminerror("$userpath/
lists/$list Update Account" , __FILE__, __LINE__,);
print USERS $newemail;
close (USERS);
&success("$emailcnt Bulk emails have been added to the list");
}#new email
else{ &adminerror("There were No REAL emails in your list");
}
##########################
This is the code for the individual add...
sub add_new_email
{
my ($new_email, @fields, $checkemail, $line);
$checkemail = param('checkemail');
unless ($checkemail =~ /.*\@.*\..*/) {
&adminerror("Please incude a REAL email address.");
}
if($checkemail eq ""){
&adminerror("Please include an email address");
}
chomp $checkemail;
if(-e "$userpath/lists/$list"){
open (USERS, "$userpath/lists/$list") || &adminerror("$userpath/
lists/$list add new email " , __FILE__, __LINE__,);
flock(USERS, LOCK_EX);
while (<USERS>)
{
$line = $_;
chomp $line if ($line =~ /\n$/);
if ($checkemail eq $line){
$newemail = "";
}
else{
$newemail = $checkemail;
}#else
} # End of while (<USERS>)
close (USERS);
}
else{ &adminerror("$list was not found");}
if($newemail){
open (USERS, ">>$userpath/lists/$list") || &adminerror("$userpath/
lists/$list Update Account" , __FILE__, __LINE__,);
print USERS "$newemail\n";
close (USERS);
&success("$checkemail has been added to $list");
}#new email
else{ &adminerror("$checkemail is already on the list");
}
}#update
#########################
And this is the code for the remove email...
sub adminremove_email
my ($new_data, @fields, $old_data, $removeemail, $line);
$removeemail = param('checkemail');
if($removeemail eq ""){
&adminerror("You must include an email");
}
else{
$new_data = "";
open (USERS, "$userpath/lists/$list") || &adminerror("$userpath/
lists/$list Update" , __FILE__, __LINE__,);
flock(USERS, LOCK_EX);
while (<USERS>)
{
$line = $_;
#chop $line;
chomp $line;
#chomp ($line);
#chomp ($line) if ($line =~ /\n$/);
#chomp $line if ($line =~ /\n$/);
#chomp $line if ($line =~ /\r$/);
if ($removeemail ne $line){
$new_data .= "$line\n";
}
else{
$old_data .= "$line\n";
}#else
} # End of while (<USERS>)
close (USERS);
if($old_data){
open (USERS, ">$userpath/lists/$list") || &adminerror("$userpath/
lists/$list Update Account" , __FILE__, __LINE__,);
print USERS "$new_data";
close (USERS);
&success("$removeemail has been removed");
}
else{
&adminerror("$removeemail was not found");
}
}#we have an email
}#adminremove_email