First of all I would like to say you create a great mod. That being said I have know idea why this the function is not being called. These are the files. I used both winmerge and textpad and Nothing seems to be wrong. Here are the files:
includes/modules/pages/subscribe/header_php.php
} elseif (zen_validate_email($email_address) == false) {
$error = true;
$messageStack->add('subscribe', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
} else {
// check if email address exists in CUSTOMERS table or in SUBSCRIBERS table
$check_cust_email_query = "select count(*) as total from " . TABLE_CUSTOMERS .
" where customers_email_address = '" . zen_db_input($email_address) . "'";
$check_cust_email = $db->Execute($check_cust_email_query);
$check_news_email_query = "select count(*) as total from " . TABLE_SUBSCRIBERS .
" where email_address = '" . zen_db_input($email_address) . "'";
$check_news_email = $db->Execute($check_news_email_query);
if ($check_cust_email->fields['total'] > 0) {
$error = true;
$messageStack->add('subscribe', SUBSCRIBE_DUPLICATE_CUSTOMERS_ERROR);
} elseif ($check_news_email->fields['total'] > 0) {
$error = true;
$messageStack->add('subscribe', SUBSCRIBE_DUPLICATE_NEWSONLY_ERROR);
} else {
// we generate a random confirmation code so we can use it as an
// extra security measure to prevent spoofs/scams.
$confirm_code = substr(base64_encode(crypt(str_shuffle(time()))),4,6);
$db->Execute('insert into ' . TABLE_SUBSCRIBERS .
' (email_address, email_format, subscribed_date, confirmed) ' .
"VALUES ('".$email_address."', '".$email_format."', now(), '".$confirm_code."')"
);
// Send confirmation request.
// get the proper uri
$confirm_uri = zen_href_link(FILENAME_SUBSCRIBE_CONFIRM, 'confirm='.$confirm_code.'&email=' . $email_address, 'NONSSL');
// initial welcome
$email_text .= EMAIL_WELCOME;
$html_msg['EMAIL_WELCOME'] = str_replace('\n','',EMAIL_WELCOME);
// add in regular email welcome text
$email_text .= "\n\n" . EMAIL_TEXT . sprintf(EMAIL_CONFIRMATION_TEXT, $confirm_uri ). EMAIL_CONTACT . EMAIL_CLOSURE;
$html_msg['EMAIL_MESSAGE_HTML'] = str_replace('\n','',EMAIL_TEXT );
$html_msg['EMAIL_CONFIRMATION_LINK'] = str_replace('\n','', sprintf(EMAIL_CONFIRMATION_TEXT, '<a href="'.$confirm_uri.'">'.$confirm_uri.'</a>' ));
$html_msg['EMAIL_CONTACT_OWNER'] = str_replace('\n','',EMAIL_CONTACT);
$html_msg['EMAIL_CLOSURE'] = nl2br(EMAIL_CLOSURE);
// include create-account-specific disclaimer
$email_text .= "\n\n" . sprintf(EMAIL_DISCLAIMER_NEW_CUSTOMER, STORE_OWNER_EMAIL_ADDRESS). "\n\n";
$html_msg['EMAIL_DISCLAIMER'] = sprintf(EMAIL_DISCLAIMER_NEW_CUSTOMER, '<a href="mailto:' . STORE_OWNER_EMAIL_ADDRESS . '">'. STORE_OWNER_EMAIL_ADDRESS .' </a>');
// send welcome email
zen_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_NAME, EMAIL_FROM, $html_msg, 'newsletter_subscription');
}
}
}
$breadcrumb->add(NAVBAR_TITLE);
?>
includes/functions/functions_email.php
function zen_validate_email($email) {
$valid_address = true;
// fail if contains no @ symbol
if (!strstr($email,'@')) return false;
// split the email address into user and domain parts
// need to update to trap for addresses in the format of "first@last"@someplace.com
// this method will most likely break in that case
list( $user, $domain ) = explode( "@", $email );
$valid_ip_form = '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';
$valid_email_pattern = '^[a-z0-9]+[a-z0-9_\.\'\-]*@[a-z0-9]+[a-z0-9\.\-]*\.(([a-z]{2,6})|([0-9]{1,3}))$';
//preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9\._-]+)+$/', $email))
//preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*?[a-z]+$/is');
$space_check = '[ ]';
// strip beginning and ending quotes, if and only if both present
if( (ereg('^["]', $user) && ereg('["]$', $user)) ){
$user = ereg_replace ( '^["]', '', $user );
$user = ereg_replace ( '["]$', '', $user );
$user = ereg_replace ( $space_check, '', $user ); //spaces in quoted addresses OK per RFC (?)
$email = $user."@".$domain; // contine with stripped quotes for remainder
}
// fail if contains spaces in domain name
if (strstr($domain,' ')) return false;
// if email domain part is an IP address, check each part for a value under 256
if (ereg($valid_ip_form, $domain)) {
$digit = explode( ".", $domain );
for($i=0; $i<4; $i++) {
if ($digit[$i] > 255) {
$valid_address = false;
return $valid_address;
exit;
}
// stop crafty people from using internal IP addresses
if (($digit[0] == 192) || ($digit[0] == 10)) {
$valid_address = false;
return $valid_address;
exit;
}
}
}
if (!ereg($space_check, $email)) { // trap for spaces in
if ( eregi($valid_email_pattern, $email)) { // validate against valid email patterns
$valid_address = true;
} else {
$valid_address = false;
return $valid_address;
exit;
}
}
return $valid_address;
}
?>