Falko Timme
2014-06-16 f43ef975d75a57973886e7f8eabb068d2ac15cc0
- 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.
1 files added
2 files modified
8 ■■■■■ changed files
install/sql/incremental/upd_0078.sql 1 ●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql 2 ●●● patch | view | raw | blame | history
interface/lib/classes/validate_domain.inc.php 5 ●●●●● patch | view | raw | blame | history
install/sql/incremental/upd_0078.sql
New file
@@ -0,0 +1 @@
ALTER TABLE  `web_domain` DROP INDEX `serverdomain`, ADD UNIQUE  `serverdomain` (  `server_id` , `ip_address`, `domain` );
install/sql/ispconfig3.sql
@@ -1879,7 +1879,7 @@
  `added_date` date NOT NULL DEFAULT '0000-00-00',
  `added_by` varchar(255) DEFAULT NULL,
  PRIMARY KEY  (`domain_id`),
  UNIQUE KEY `serverdomain` (  `server_id` ,  `domain` )
  UNIQUE KEY `serverdomain` (  `server_id` , `ip_address`,  `domain` )
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
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;