You've already forked postfixadmin
mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2025-08-06 06:42:37 +03:00
functions.inc.php:
- move DNS checks from check_email() to check_domain() - add clear error message on non-resolvable domains (using flash_error() - this is probably not the best solution, but better than nothing) - made error messages translatable create-domain.php: - avoid duplicated call to check_domain (to avoid duplicated error message) - domains are now DNS-checked on creation - see the changes in check_domain() in functions.inc.php languages/*: - added error messages for the above changes git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@429 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
@@ -227,14 +227,37 @@ function check_string ($var)
|
||||
// TODO: make check_domain able to handle as example .local domains
|
||||
function check_domain ($domain)
|
||||
{
|
||||
if (preg_match ('/([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,6}$/i', trim ($domain)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
global $CONF;
|
||||
global $PALANG;
|
||||
|
||||
if (!preg_match ('/([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,6}$/i', trim ($domain)))
|
||||
{
|
||||
flash_error(sprintf($PALANG['pInvalidDomainRegex'], htmlentities($domain)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($CONF['emailcheck_resolve_domain']) && 'YES' == $CONF['emailcheck_resolve_domain'] && 'WINDOWS'!=(strtoupper(substr(php_uname('s'), 0, 7))))
|
||||
{
|
||||
|
||||
// Look for an AAAA, A, or MX record for the domain
|
||||
|
||||
if(function_exists('checkdnsrr')) {
|
||||
// AAAA (IPv6) is only available in PHP v. >= 5
|
||||
if (version_compare(phpversion(), "5.0.0", ">="))
|
||||
{
|
||||
if (checkdnsrr($domain,'AAAA')) return true;
|
||||
}
|
||||
if (checkdnsrr($domain,'A')) return true;
|
||||
if (checkdnsrr($domain,'MX')) return true;
|
||||
flash_error(sprintf($PALANG['pInvalidDomainDNS'], htmlentities($domain)));
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
flash_error("emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -260,47 +283,24 @@ function check_email ($email)
|
||||
$ce_email = preg_replace("/#/", '@', $ce_email);
|
||||
}
|
||||
|
||||
if (isset($CONF['emailcheck_resolve_domain']) && 'YES' == $CONF['emailcheck_resolve_domain'] && 'WINDOWS'!=(strtoupper(substr(php_uname('s'), 0, 7))))
|
||||
// Perform non-domain-part sanity checks
|
||||
if (!preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '[^@]+$/i', trim ($ce_email)))
|
||||
{
|
||||
|
||||
// Perform non-domain-part sanity checks
|
||||
if (!preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '[^@]+$/i', trim ($ce_email)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine domain name
|
||||
$matches=array();
|
||||
if (!preg_match('|@(.+)$|',$ce_email,$matches))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$domain=$matches[1];
|
||||
|
||||
// Look for an AAAA, A, or MX record for the domain
|
||||
|
||||
if(function_exists('checkdnsrr')) {
|
||||
// AAAA (IPv6) is only available in PHP v. >= 5
|
||||
if (version_compare(phpversion(), "5.0.0", ">="))
|
||||
{
|
||||
if (checkdnsrr($domain,'AAAA')) return true;
|
||||
}
|
||||
if (checkdnsrr($domain,'A')) return true;
|
||||
if (checkdnsrr($domain,'MX')) return true;
|
||||
flash_error("Invalid domain, and/or not discoverable in DNS");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
flash_error("emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!");
|
||||
}
|
||||
flash_error($PALANG['pInvalidMailRegex']);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,6}$/i', trim ($ce_email)))
|
||||
// Determine domain name
|
||||
$matches=array();
|
||||
if (!preg_match('|@(.+)$|',$ce_email,$matches))
|
||||
{
|
||||
return true;
|
||||
flash_error($PALANG['pInvalidMailRegex']);
|
||||
return false;
|
||||
}
|
||||
flash_error("Invalid email address, fails regexp check");
|
||||
return false;
|
||||
$domain=$matches[1];
|
||||
|
||||
# check domain name
|
||||
return check_domain($domain);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user