You've already forked postfixadmin
mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2025-08-07 17:42:53 +03:00
functions.inc.php:
- check_domain(), check_email(): use Lang::read and Config::read instead of global variables (global variables, at least $PALANG, don't seem to work with CLI) - boolconf(): - use Config::read instead of global $CONF - drop isset() check - doesn't make sense when using Config::read git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1452 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
@@ -228,14 +228,11 @@ function check_string ($var) {
|
|||||||
* TODO: skip DNS check if the domain exists in PostfixAdmin?
|
* TODO: skip DNS check if the domain exists in PostfixAdmin?
|
||||||
*/
|
*/
|
||||||
function check_domain ($domain) {
|
function check_domain ($domain) {
|
||||||
global $CONF;
|
|
||||||
global $PALANG;
|
|
||||||
|
|
||||||
if (!preg_match ('/^([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,6}$/i', ($domain))) {
|
if (!preg_match ('/^([-0-9A-Z]+\.)+' . '([0-9A-Z]){2,6}$/i', ($domain))) {
|
||||||
return sprintf($PALANG['pInvalidDomainRegex'], htmlentities($domain));
|
return sprintf(Lang::read('pInvalidDomainRegex'), htmlentities($domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($CONF['emailcheck_resolve_domain']) && 'YES' == $CONF['emailcheck_resolve_domain'] && 'WINDOWS'!=(strtoupper(substr(php_uname('s'), 0, 7)))) {
|
if (boolconf('emailcheck_resolve_domain') && 'WINDOWS'!=(strtoupper(substr(php_uname('s'), 0, 7)))) {
|
||||||
|
|
||||||
// Look for an AAAA, A, or MX record for the domain
|
// Look for an AAAA, A, or MX record for the domain
|
||||||
|
|
||||||
@@ -246,7 +243,7 @@ function check_domain ($domain) {
|
|||||||
}
|
}
|
||||||
if (checkdnsrr($domain,'A')) return '';
|
if (checkdnsrr($domain,'A')) return '';
|
||||||
if (checkdnsrr($domain,'MX')) return '';
|
if (checkdnsrr($domain,'MX')) return '';
|
||||||
return sprintf($PALANG['pInvalidDomainDNS'], htmlentities($domain));
|
return sprintf(Lang::Read('pInvalidDomainDNS'), htmlentities($domain));
|
||||||
} else {
|
} else {
|
||||||
return 'emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!';
|
return 'emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!';
|
||||||
}
|
}
|
||||||
@@ -264,28 +261,25 @@ function check_domain ($domain) {
|
|||||||
* TODO: make check_email able to handle already added domains
|
* TODO: make check_email able to handle already added domains
|
||||||
*/
|
*/
|
||||||
function check_email ($email) {
|
function check_email ($email) {
|
||||||
global $CONF;
|
|
||||||
global $PALANG;
|
|
||||||
|
|
||||||
$ce_email=$email;
|
$ce_email=$email;
|
||||||
|
|
||||||
//strip the vacation domain out if we are using it
|
//strip the vacation domain out if we are using it
|
||||||
//and change from blah#foo.com@autoreply.foo.com to blah@foo.com
|
//and change from blah#foo.com@autoreply.foo.com to blah@foo.com
|
||||||
if ($CONF['vacation'] == 'YES') {
|
if (boolconf('vacation')) {
|
||||||
$vacation_domain = $CONF['vacation_domain'];
|
$vacation_domain = Config::read('vacation_domain');
|
||||||
$ce_email = preg_replace("/@$vacation_domain\$/", '', $ce_email);
|
$ce_email = preg_replace("/@$vacation_domain\$/", '', $ce_email);
|
||||||
$ce_email = preg_replace("/#/", '@', $ce_email);
|
$ce_email = preg_replace("/#/", '@', $ce_email);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform non-domain-part sanity checks
|
// Perform non-domain-part sanity checks
|
||||||
if (!preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '[^@]+$/i', $ce_email)) {
|
if (!preg_match ('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_{|}~]+' . '@' . '[^@]+$/i', $ce_email)) {
|
||||||
return $PALANG['pInvalidMailRegex'];
|
return Lang::read('pInvalidMailRegex');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine domain name
|
// Determine domain name
|
||||||
$matches=array();
|
$matches=array();
|
||||||
if (!preg_match('|@(.+)$|',$ce_email,$matches)) {
|
if (!preg_match('|@(.+)$|',$ce_email,$matches)) {
|
||||||
return $PALANG['pInvalidMailRegex'];
|
return Lang::read('pInvalidMailRegex');
|
||||||
}
|
}
|
||||||
$domain=$matches[1];
|
$domain=$matches[1];
|
||||||
|
|
||||||
@@ -2186,11 +2180,9 @@ function getRemoteAddr() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function boolconf($setting) {
|
function boolconf($setting) {
|
||||||
global $CONF;
|
$value = Config::read($setting);
|
||||||
if (!isset($CONF[$setting])) { # not set
|
|
||||||
# TODO: show/log error message on unknown settings?
|
if (strtoupper($value) == 'YES') { # YES
|
||||||
return false;
|
|
||||||
} elseif (strtoupper($CONF[$setting]) == 'YES') { # YES
|
|
||||||
return true;
|
return true;
|
||||||
} else { # NO, unknown value
|
} else { # NO, unknown value
|
||||||
# TODO: show/log error message on unknown value?
|
# TODO: show/log error message on unknown value?
|
||||||
|
Reference in New Issue
Block a user