From 23765ce5ddbfae0de7d91b56808285270a25da9d Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Wed, 15 Aug 2012 13:14:59 -0400
Subject: [PATCH] On multiserver setups, if the parent_domain lies on a different server than the database automatically enable remote access and add the webserver's ip to the remote_ips list
---
interface/web/sites/database_edit.php | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/interface/web/sites/database_edit.php b/interface/web/sites/database_edit.php
index 501c650..7f675fa 100644
--- a/interface/web/sites/database_edit.php
+++ b/interface/web/sites/database_edit.php
@@ -238,6 +238,18 @@
$tmp = $app->db->queryOneRecord("SELECT count(database_id) as dbnum FROM web_database WHERE database_name = '".$this->dataRecord['database_name']."' AND server_id = '".$this->dataRecord["server_id"]."' AND database_id != '".$this->id."'");
if($tmp['dbnum'] > 0) $app->tform->errorMessage .= $app->lng('database_name_error_unique').'<br />';
+ // get the web server ip (parent domain)
+ $tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = '".$this->dataRecord['parent_domain_id']."'");
+ if($tmp['server_id'] && $tmp['server_id'] != $this->dataRecord['server_id']) {
+ // we need remote access rights for this server, so get it's ip address
+ $server_config = $app->getconf->get_server_config($tmp['server_id'], 'server');
+ if($server_config['ip_address']!='') {
+ $this->dataRecord['remote_access'] = 'y';
+ $this->dataRecord['remote_ips'] .= ($this->dataRecord['remote_ips'] != '' ? ',' : '') . $server_config['ip_address'];
+ }
+ }
+
+
parent::onBeforeUpdate();
}
@@ -282,6 +294,17 @@
$tmp = $app->db->queryOneRecord("SELECT count(database_id) as dbnum FROM web_database WHERE database_name = '".$this->dataRecord['database_name']."' AND server_id = '".$this->dataRecord["server_id"]."'");
if($tmp['dbnum'] > 0) $app->tform->errorMessage .= $app->tform->lng('database_name_error_unique').'<br />';
+ // get the web server ip (parent domain)
+ $tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = '".$this->dataRecord['parent_domain_id']."'");
+ if($tmp['server_id'] && $tmp['server_id'] != $this->dataRecord['server_id']) {
+ // we need remote access rights for this server, so get it's ip address
+ $server_config = $app->getconf->get_server_config($tmp['server_id'], 'server');
+ if($server_config['ip_address']!='') {
+ $this->dataRecord['remote_access'] = 'y';
+ $this->dataRecord['remote_ips'] .= (trim($this->dataRecord['remote_ips']) != '' ? ',' : '') . $server_config['ip_address'];
+ }
+ }
+
parent::onBeforeInsert();
}
--
Gitblit v1.9.1