From f43ef975d75a57973886e7f8eabb068d2ac15cc0 Mon Sep 17 00:00:00 2001
From: Falko Timme <ft@falkotimme.com>
Date: Mon, 16 Jun 2014 12:06:06 -0400
Subject: [PATCH] - Make sure ISPConfig shows the correct error message (instad of an SQL error) when a website is renamed after an alias domain that still exists. - It should be possible to create two websites with the same domain on the same server as long as the IP differs. I therefore changed the serverdomain index of the web_domain table to include the IP address.

---
 interface/lib/classes/validate_domain.inc.php |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/interface/lib/classes/validate_domain.inc.php b/interface/lib/classes/validate_domain.inc.php
index 988945d..788b34b 100644
--- a/interface/lib/classes/validate_domain.inc.php
+++ b/interface/lib/classes/validate_domain.inc.php
@@ -137,7 +137,8 @@
 		//if($check['cnt'] > 0) return false;
 
 		// we can have the same domain on different servers or different IPs, so we have to check for identical domains on the same IP (or wildcard IPs)
-		$checks = $app->db->queryAllRecords("SELECT * FROM `web_domain` WHERE (`domain` = '" . $app->db->quote($domain_name) . "'".$additional_sql1.") AND `server_id` = ".intval($domain['server_id'])." AND `domain_id` != " . $app->functions->intval($primary_id).($additional_sql1 != '' ? " AND `parent_domain_id` != ".$app->functions->intval($primary_id) : ""));
+		$checks = $app->db->queryAllRecords("SELECT * FROM `web_domain` WHERE (`domain` = '" . $app->db->quote($domain_name) . "'".$additional_sql1.") AND `server_id` = ".intval($domain['server_id'])." AND `domain_id` != " . $app->functions->intval($primary_id).($additional_sql1 != '' && $domain['parent_domain_id'] > 0 ? " AND `parent_domain_id` != ".$app->functions->intval($primary_id) : ""));
+		
 
 		if(is_array($checks) && !empty($checks)){
 			foreach($checks as $check){
@@ -207,7 +208,7 @@
 			//$check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE CONCAT(`subdomain`, '.', `domain`) = '" . $app->db->quote($domain_name) . "' AND `domain_id` != " . $app->functions->intval($primary_id));
 			//if($check['cnt'] > 0) return false;
 			// we can have the same domain on different servers or different IPs, so we have to check for identical domains on the same IP (or wildcard IPs)
-			$checks = $app->db->queryAllRecords("SELECT * FROM `web_domain` WHERE (CONCAT(`subdomain`, '.', `domain`) = '" . $app->db->quote($domain_name) . "'".$additional_sql2.") AND `server_id` = ".intval($domain['server_id'])." AND `domain_id` != " . $app->functions->intval($primary_id).($additional_sql2 != '' ? " AND `parent_domain_id` != ".$app->functions->intval($primary_id) : ""));
+			$checks = $app->db->queryAllRecords("SELECT * FROM `web_domain` WHERE (CONCAT(`subdomain`, '.', `domain`) = '" . $app->db->quote($domain_name) . "'".$additional_sql2.") AND `server_id` = ".intval($domain['server_id'])." AND `domain_id` != " . $app->functions->intval($primary_id).($additional_sql2 != '' && $domain['parent_domain_id'] > 0 ? " AND `parent_domain_id` != ".$app->functions->intval($primary_id) : ""));
 			if(is_array($checks) && !empty($checks)){
 				foreach($checks as $check){
 					if($domain['ip_address'] == '*') return false;

--
Gitblit v1.9.1