Skip to content

Commit 23765ce

Browse files
author
mcramer
committed
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
1 parent fa1c26f commit 23765ce

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

interface/web/sites/database_edit.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,18 @@ function onBeforeUpdate() {
238238
$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."'");
239239
if($tmp['dbnum'] > 0) $app->tform->errorMessage .= $app->lng('database_name_error_unique').'<br />';
240240

241+
// get the web server ip (parent domain)
242+
$tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = '".$this->dataRecord['parent_domain_id']."'");
243+
if($tmp['server_id'] && $tmp['server_id'] != $this->dataRecord['server_id']) {
244+
// we need remote access rights for this server, so get it's ip address
245+
$server_config = $app->getconf->get_server_config($tmp['server_id'], 'server');
246+
if($server_config['ip_address']!='') {
247+
$this->dataRecord['remote_access'] = 'y';
248+
$this->dataRecord['remote_ips'] .= ($this->dataRecord['remote_ips'] != '' ? ',' : '') . $server_config['ip_address'];
249+
}
250+
}
251+
252+
241253
parent::onBeforeUpdate();
242254
}
243255

@@ -282,6 +294,17 @@ function onBeforeInsert() {
282294
$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"]."'");
283295
if($tmp['dbnum'] > 0) $app->tform->errorMessage .= $app->tform->lng('database_name_error_unique').'<br />';
284296

297+
// get the web server ip (parent domain)
298+
$tmp = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = '".$this->dataRecord['parent_domain_id']."'");
299+
if($tmp['server_id'] && $tmp['server_id'] != $this->dataRecord['server_id']) {
300+
// we need remote access rights for this server, so get it's ip address
301+
$server_config = $app->getconf->get_server_config($tmp['server_id'], 'server');
302+
if($server_config['ip_address']!='') {
303+
$this->dataRecord['remote_access'] = 'y';
304+
$this->dataRecord['remote_ips'] .= (trim($this->dataRecord['remote_ips']) != '' ? ',' : '') . $server_config['ip_address'];
305+
}
306+
}
307+
285308
parent::onBeforeInsert();
286309
}
287310

0 commit comments

Comments
 (0)