functions.inc.php: reindent (as per inline vim settings) and add in flash_error calls when validating an email address (I suspect the strings need changing as per translation issues)

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@426 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
David Goodwin 17 years ago
parent e15068af3a
commit 544c7ebe82

@ -260,11 +260,8 @@ function check_email ($email)
$ce_email = preg_replace("/#/", '@', $ce_email); $ce_email = preg_replace("/#/", '@', $ce_email);
} }
if ( if (isset($CONF['emailcheck_resolve_domain']) && 'YES' == $CONF['emailcheck_resolve_domain'] && 'WINDOWS'!=(strtoupper(substr(php_uname('s'), 0, 7))))
isset($CONF['emailcheck_resolve_domain']) {
&& 'YES'==$CONF['emailcheck_resolve_domain']
&& 'WINDOWS'!=(strtoupper(substr(php_uname('s'), 0, 7)))
) {
// Perform non-domain-part sanity checks // Perform non-domain-part sanity checks
if (!preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '[^@]+$/i', trim ($ce_email))) if (!preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '[^@]+$/i', trim ($ce_email)))
@ -290,19 +287,20 @@ function check_email ($email)
} }
if (checkdnsrr($domain,'A')) return true; if (checkdnsrr($domain,'A')) return true;
if (checkdnsrr($domain,'MX')) return true; if (checkdnsrr($domain,'MX')) return true;
} flash_error("Invalid domain, and/or not discoverable in DNS");
# TODO: different error message for non-existing domains (instead of "email is invalid")
return false; return false;
} }
else {
flash_error("emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!");
}
}
if (preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,6}$/i', trim ($ce_email))) if (preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,6}$/i', trim ($ce_email)))
{ {
return true; return true;
} }
else flash_error("Invalid email address, fails regexp check");
{
return false; return false;
}
} }
@ -851,7 +849,7 @@ function domain_exist ($domain)
{ {
global $table_domain; global $table_domain;
$result = db_query ("SELECT 1 FROM $table_domain WHERE domain='$domain'"); $result = db_query("SELECT 1 FROM $table_domain WHERE domain='$domain'");
if ($result['rows'] != 1) if ($result['rows'] != 1)
{ {
return false; return false;

Loading…
Cancel
Save