diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php
index 03bd11d390616b08dff94a4202b746e55d7ba49a..3a9fcb9a10d4a891a2a36fbb637250646a759796 100644
--- a/interface/lib/classes/functions.inc.php
+++ b/interface/lib/classes/functions.inc.php
@@ -302,7 +302,11 @@ class functions {
 
 		if($encode == true) {
 			if(function_exists('idn_to_ascii')) {
-				$domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
+				if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) {
+					$domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
+				} else {
+					$domain = idn_to_ascii($domain);
+				}
 			} elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) {
 				/* use idna class:
                  * @author  Matthias Sommerfeld <mso@phlylabs.de>
@@ -319,7 +323,11 @@ class functions {
 			}
 		} else {
 			if(function_exists('idn_to_utf8')) {
-				$domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
+				if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) {
+					$domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
+				} else {
+					$domain = idn_to_utf8($domain);
+				}
 			} elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) {
 				/* use idna class:
                  * @author  Matthias Sommerfeld <mso@phlylabs.de>
diff --git a/server/lib/classes/functions.inc.php b/server/lib/classes/functions.inc.php
index 6a46d5e7fc3f2deb260ff7a5ce65af6a1515942a..1f9c6b6efcbf18f3f14267a33389b2543dac590b 100644
--- a/server/lib/classes/functions.inc.php
+++ b/server/lib/classes/functions.inc.php
@@ -354,7 +354,11 @@ class functions {
 
 		if($encode == true) {
 			if(function_exists('idn_to_ascii')) {
-				$domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
+				if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) {
+					$domain = idn_to_ascii($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
+				} else {
+					$domain = idn_to_ascii($domain);
+				}
 			} elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) {
 				/* use idna class:
                  * @author  Matthias Sommerfeld <mso@phlylabs.de>
@@ -371,7 +375,11 @@ class functions {
 			}
 		} else {
 			if(function_exists('idn_to_utf8')) {
-				$domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
+				if(defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46') && constant('IDNA_NONTRANSITIONAL_TO_ASCII')) {
+					$domain = idn_to_utf8($domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46);
+				} else {
+					$domain = idn_to_utf8($domain);
+				}
 			} elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) {
 				/* use idna class:
                  * @author  Matthias Sommerfeld <mso@phlylabs.de>