mcramer
2012-08-15 23765ce5ddbfae0de7d91b56808285270a25da9d
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 files modified
23 ■■■■■ changed files
interface/web/sites/database_edit.php 23 ●●●●● patch | view | raw | blame | history
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();
    }