//validate the customer's name if (validate_name_pattern($_POST['customer_name'])) { $customer_name = $_POST['customer_name']; $smarty->assign('customer_name', $customer_name); } } if (isset($_POST['company_name'])) { //validate the company's name if (validate_name_pattern($_POST['company_name'])) { $company_name = $_POST['company_name']; $smarty->assign('company_name', $company_name); } } if (isset($_POST['customer_email'])) { //validate the customer's name if (validate_email_pattern($_POST['customer_email'])) { $customer_email = $_POST['customer_email']; $smarty->assign('customer_email', $customer_email); } } if (isset($_POST['product_type'])) { //validate the product type enumeration if (validate_product_type($_POST['product_type'])) { $product_type = $_POST['product_type']; $smarty->assign('product_type', $product_type); } } if (isset($_POST['key_version'])) { //validate the key version enumeration if (validate_key_version($_POST['key_version'])) { $key_version = $_POST['key_version'];
/** * checks an email address for validity * * this function is special in that it checks the email prefix * <i>(the part before the '@' symbol)</i> to see if it is a valid * address by itself<i>(some cell users might do this)</i>. * * @author Mike Reinstein <*****@*****.**> * @param string $email_prefix the part before the '@' symbol * @param string $email_domain the part after the '@' symbol * @return array full email address, email prefix and email domain if valid address, returns FALSE otherwise */ function is_valid_email($email_prefix, $email_domain) { require_once 'constants.php'; global $EMAIL_DOMAINS, $EMAIL_REGISTRATION_BLACKLIST, $EMAIL_REGISTRATION_WHITELIST; //determine if the email address passed in is valid if (validate_email_pattern($email_prefix)) { $email = $email_prefix; } else { if (validate_email_pattern("{$email_prefix}@{$email_domain}")) { $email = "{$email_prefix}@{$email_domain}"; } else { return FALSE; } } //if we got here the email must be valid. split it into prefix and domain list($eprefix, $edomain) = explode('@', $email); //if we allow any addresses, this one is valid so return it if (ALLOW_ANY_EMAIL_ADDRESSES == TRUE) { //if the domain isn't in the list, set domain to other //no, the 3 '=' symbols below is NOT a bug its a comparison operatoor //this function can return 0, meaning that a match is encountered //at the first index of the array. but 0 evaluates to FALSE. FALSE is //returned by this function if no entries are found if (array_search($edomain, $EMAIL_DOMAINS) === FALSE) { return array($email, $email, OTHER); } else { return array($email, $eprefix, $edomain); } } else { if (array_search($edomain, $EMAIL_DOMAINS) !== FALSE || array_search($email, $EMAIL_REGISTRATION_WHITELIST) !== FALSE) { //if the email is NOT in the black list return the array if (array_search($email, $EMAIL_REGISTRATION_BLACKLIST) === FALSE) { return array($email, $eprefix, $edomain); } } } return FALSE; }