[feladat @ 197]
authorrejo
Thu, 27 Mar 2008 17:44:49 +0000
changeset 97 090be08858db
parent 96 35cd9e082b90
child 98 9c10fd623368
[feladat @ 197] Bugfix for name field validation. Now done right. I hope.
inc/dns.inc.php
--- a/inc/dns.inc.php	Thu Mar 27 16:39:29 2008 +0000
+++ b/inc/dns.inc.php	Thu Mar 27 17:44:49 2008 +0000
@@ -61,26 +61,25 @@
 	}
 
 	// Prepare total hostname.
-
 	if ($name == '*') {
 		$wildcard = true;
 	} else {
 		$wildcard = false;
 	}
 
-	if (preg_match('!@\.!i', $name))
-	{
-		$name = str_replace('@.', '@', $name);
-	}
-	
-	if ($name == "" || $name == "@") {
-		$test_name = $domain;
-	} else {
-		$test_name = $name . "." . $domain ;
+	if (preg_match("/@/", $name)) {
+		$name = $domain ;
+	} elseif ( !(preg_match("/$domain$/i", $name))) {
+
+		if ( isset($name) && $name != "" ) {
+			$name = $name . "." . $domain ;
+		} else {
+			$name = $domain ;
+		}
 	}
 
 	if(!$wildcard) {
-		if(!is_valid_hostname($test_name)) {
+		if(!is_valid_hostname($name)) {
 			error(ERR_DNS_HOSTNAME);
 			return false;
 		}