From 6250b7ea002fd99e40d0170d31e7e19e69f97ccd Mon Sep 17 00:00:00 2001
From: Dominik <info@profi-webdesign.net>
Date: Thu, 23 Jan 2014 13:53:43 -0500
Subject: [PATCH] Merge remote-tracking branch 'ispc3master/master'

---
 interface/web/sites/web_domain_edit.php |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php
index 2d9c774..7673895 100644
--- a/interface/web/sites/web_domain_edit.php
+++ b/interface/web/sites/web_domain_edit.php
@@ -133,11 +133,21 @@
 			} else {
 				$server_id = (isset($web_servers[0])) ? intval($web_servers[0]) : 0;
 			}
-
+			
+			if($app->functions->intval($this->dataRecord["server_id"]) > 0) {
+				// check if server is in client's servers or add it.
+				$chk_sid = explode(',', $client['web_servers']);
+				if(in_array($this->dataRecord["server_id"], $client['web_servers']) == false) {
+					if($client['web_servers'] != '') $client['web_servers'] .= ',';
+					$client['web_servers'] .= $app->functions->intval($this->dataRecord["server_id"]);
+				}
+			}
+			
 			//* Fill the IPv4 select field with the IP addresses that are allowed for this client
 			$sql = "SELECT ip_address FROM server_ip WHERE server_id IN (" . $client['web_servers'] . ") AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
 			$ips = $app->db->queryAllRecords($sql);
 			$ip_select = ($web_config['enable_ip_wildcard'] == 'y')?"<option value='*'>*</option>":"";
+			//if(!in_array($this->dataRecord["ip_address"], $ips)) $ip_select .= "<option value='".$this->dataRecord["ip_address"]."' SELECTED>".$this->dataRecord["ip_address"]."</option>\r\n";
 			//$ip_select = "";
 			if(is_array($ips)) {
 				foreach( $ips as $ip) {
@@ -234,10 +244,20 @@
 			}
 			$app->tpl->setVar("client_group_id", $client_select);
 
+			if($app->functions->intval($this->dataRecord["server_id"]) > 0) {
+				// check if server is in client's servers or add it.
+				$chk_sid = explode(',', $client['web_servers']);
+				if(in_array($this->dataRecord["server_id"], $client['web_servers']) == false) {
+					if($client['web_servers'] != '') $client['web_servers'] .= ',';
+					$client['web_servers'] .= $app->functions->intval($this->dataRecord["server_id"]);
+				}
+			}
+			
 			//* Fill the IPv4 select field with the IP addresses that are allowed for this client
 			$sql = "SELECT ip_address FROM server_ip WHERE server_id IN (" . $client['web_servers'] . ") AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
 			$ips = $app->db->queryAllRecords($sql);
 			$ip_select = ($web_config['enable_ip_wildcard'] == 'y')?"<option value='*'>*</option>":"";
+			//if(!in_array($this->dataRecord["ip_address"], $ips)) $ip_select .= "<option value='".$this->dataRecord["ip_address"]."' SELECTED>".$this->dataRecord["ip_address"]."</option>\r\n";
 			//$ip_select = "";
 			if(is_array($ips)) {
 				foreach( $ips as $ip) {
@@ -992,7 +1012,7 @@
 			$records = $app->db->queryAllRecords("SELECT domain_id, `domain`, `type`, `web_folder` FROM web_domain WHERE parent_domain_id = ".$this->id);
 			foreach($records as $rec) {
 				$update_columns = "sys_userid = '".$web_rec['sys_userid']."', sys_groupid = '".$web_rec['sys_groupid']."'";
-				if($rec['type'] == 'vhostsubdomain') {
+				if($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') {
 					$php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$rec['web_folder'], $web_config["php_open_basedir"]);
 					$php_open_basedir = str_replace("[website_domain]/web", $rec['domain'].'/'.$rec['web_folder'], $php_open_basedir);
 					$php_open_basedir = str_replace("[website_path]", $document_root, $php_open_basedir);
@@ -1017,7 +1037,7 @@
 
 		//* If the domain name has been changed, we will have to change all subdomains + APS instances
 		if(!empty($this->dataRecord["domain"]) && !empty($this->oldDataRecord["domain"]) && $this->dataRecord["domain"] != $this->oldDataRecord["domain"]) {
-			$records = $app->db->queryAllRecords("SELECT domain_id,domain FROM web_domain WHERE (type = 'subdomain' OR type = 'vhostsubdomain') AND domain LIKE '%.".$app->db->quote($this->oldDataRecord["domain"])."'");
+			$records = $app->db->queryAllRecords("SELECT domain_id,domain FROM web_domain WHERE (type = 'subdomain' OR type = 'vhostsubdomain' OR type = 'vhostalias') AND domain LIKE '%.".$app->db->quote($this->oldDataRecord["domain"])."'");
 			foreach($records as $rec) {
 				$subdomain = $app->db->quote(str_replace($this->oldDataRecord["domain"], $this->dataRecord["domain"], $rec['domain']));
 				$app->db->datalogUpdate('web_domain', "domain = '".$subdomain."'", 'domain_id', $rec['domain_id']);
@@ -1077,9 +1097,9 @@
 			unset($backup_interval);
 		}
 
-		//* Change vhost subdomain ip/ipv6 if domain ip/ipv6 has changed
+		//* Change vhost subdomain and alias ip/ipv6 if domain ip/ipv6 has changed
 		if(isset($this->dataRecord['ip_address']) && ($this->dataRecord['ip_address'] != $this->oldDataRecord['ip_address'] || $this->dataRecord['ipv6_address'] != $this->oldDataRecord['ipv6_address'])) {
-			$records = $app->db->queryAllRecords("SELECT domain_id FROM web_domain WHERE type = 'vhostsubdomain' AND parent_domain_id = ".$this->id);
+			$records = $app->db->queryAllRecords("SELECT domain_id FROM web_domain WHERE (type = 'vhostsubdomain' OR type = 'vhostalias') AND parent_domain_id = ".$this->id);
 			foreach($records as $rec) {
 				$app->db->datalogUpdate('web_domain', "ip_address = '".$app->db->quote($web_rec['ip_address'])."', ipv6_address = '".$app->db->quote($web_rec['ipv6_address'])."'", 'domain_id', $rec['domain_id']);
 			}

--
Gitblit v1.9.1