Commit 9adcf583 authored by tbrehm's avatar tbrehm

Added: FS#687 - Add a replication and mirroring mode for server settings

parent f2ea1ac2
......@@ -102,6 +102,12 @@ $form["tabs"]['services'] = array (
'default' => '0',
'value' => array(0 => 0,1 => 1)
),
'mirror_server_id' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'default' => '',
'value' => ''
),
/*
'update' => array (
'datatype' => 'INTEGER',
......
<?php
$wb["config_txt"] = 'config';
$wb["server_name_txt"] = 'Servername';
$wb["mail_server_txt"] = 'Mailserver';
$wb["web_server_txt"] = 'Webserver';
$wb["dns_server_txt"] = 'DNS-Server';
$wb["file_server_txt"] = 'Fileserver';
$wb["db_server_txt"] = 'DB-Server';
$wb["vserver_server_txt"] = 'VServer-Server';
$wb["active_txt"] = 'Active';
<?php
$wb["config_txt"] = 'config';
$wb["server_name_txt"] = 'Servername';
$wb["mail_server_txt"] = 'Mailserver';
$wb["web_server_txt"] = 'Webserver';
$wb["dns_server_txt"] = 'DNS-Server';
$wb["file_server_txt"] = 'Fileserver';
$wb["db_server_txt"] = 'DB-Server';
$wb["vserver_server_txt"] = 'VServer-Server';
$wb["active_txt"] = 'Active';
$wb["mirror_server_id_txt"] = 'Is mirror of Server';
$wb["- None -"] = '- None -';
?>
\ No newline at end of file
......@@ -46,8 +46,41 @@ $app->auth->check_module_permissions('admin');
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
// let tform_actions handle the page
$app->tform_actions->onLoad();
class page_action extends tform_actions {
function onShowEnd() {
global $app, $conf;
// Getting Servers
$sql = "SELECT server_id,server_name FROM server WHERE 1 ORDER BY server_name";
$mirror_servers = $app->db->queryAllRecords($sql);
$mirror_server_select = '<option value="0">'.$app->tform->lng('- None -').'</option>';
if(is_array($mirror_servers)) {
foreach( $mirror_servers as $mirror_server) {
$selected = ($mirror_server["server_id"] == $this->dataRecord['mirror_server_id'])?'SELECTED':'';
$mirror_server_select .= "<option value='$mirror_server[server_id]' $selected>$mirror_server[server_name]</option>\r\n";
}
}
$app->tpl->setVar("mirror_server_id",$mirror_server_select);
parent::onShowEnd();
}
function onSubmit() {
global $app;
//* We do not want to mirror the the server itself
if($this->id == $this->dataRecord['mirror_server_id']) $this->dataRecord['mirror_server_id'] = 0;
parent::onSubmit();
}
}
$page = new page_action;
$page->onLoad();
?>
\ No newline at end of file
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server">
<div class="pnl_formsarea">
<fieldset class="inlineLabels">
<div class="ctrlHolder">
<label for="server_name">{tmpl_var name='server_name_txt'}</label>
<input name="server_name" id="server_name" value="{tmpl_var name='server_name'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='mail_server_txt'}</p>
<div class="multiField">
{tmpl_var name='mail_server'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='web_server_txt'}</p>
<div class="multiField">
{tmpl_var name='web_server'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='dns_server_txt'}</p>
<div class="multiField">
{tmpl_var name='dns_server'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='file_server_txt'}</p>
<div class="multiField">
{tmpl_var name='file_server'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='db_server_txt'}</p>
<div class="multiField">
{tmpl_var name='db_server'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='vserver_server_txt'}</p>
<div class="multiField">
{tmpl_var name='vserver_server'}
</div>
</div>
<div class="ctrlHolder">
<label for="active">{tmpl_var name='active_txt'}</label>
<select name="active" id="active" class="selectInput formLengthBool">
{tmpl_var name='active'}
</select>
</div>
</fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
<div class="buttonHolder buttons">
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
<button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
</div>
</div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server">
<div class="pnl_formsarea">
<fieldset class="inlineLabels">
<div class="ctrlHolder">
<label for="server_name">{tmpl_var name='server_name_txt'}</label>
<input name="server_name" id="server_name" value="{tmpl_var name='server_name'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='mail_server_txt'}</p>
<div class="multiField">
{tmpl_var name='mail_server'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='web_server_txt'}</p>
<div class="multiField">
{tmpl_var name='web_server'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='dns_server_txt'}</p>
<div class="multiField">
{tmpl_var name='dns_server'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='file_server_txt'}</p>
<div class="multiField">
{tmpl_var name='file_server'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='db_server_txt'}</p>
<div class="multiField">
{tmpl_var name='db_server'}
</div>
</div>
<div class="ctrlHolder">
<p class="label">{tmpl_var name='vserver_server_txt'}</p>
<div class="multiField">
{tmpl_var name='vserver_server'}
</div>
</div>
<div class="ctrlHolder">
<label for="mirror_server_id">{tmpl_var name='mirror_server_id_txt'}</label>
<select name="mirror_server_id" id="server_id" class="selectInput">
{tmpl_var name='mirror_server_id'}
</select>
</div>
<div class="ctrlHolder">
<label for="active">{tmpl_var name='active_txt'}</label>
<select name="active" id="active" class="selectInput formLengthBool">
{tmpl_var name='active'}
</select>
</div>
</fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}">
<div class="buttonHolder buttons">
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
<button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
</div>
</div>
</div>
......@@ -62,7 +62,7 @@ $form["tabs"]['dns_soa'] = array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['blacklist'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['filter'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['domain'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['mailget'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['transport'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['blacklist'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['users'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['whitelist'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -62,7 +62,7 @@ $form["tabs"]['cron'] = array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND web_server = 1 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['database'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} AND db_server = 1 ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} AND db_server = 1 ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['ftp'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['shell'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['domain'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -72,7 +72,7 @@ $form["tabs"]['domain'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND web_server = 1 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -63,7 +63,7 @@ $form["tabs"]['domain'] = array (
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
......
......@@ -84,7 +84,12 @@ class modules {
//* If its a multiserver setup
if($app->db->dbHost != $app->dbmaster->dbHost) {
$sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = 0) ORDER BY datalog_id";
if($conf["mirror_server_id"] > 0) {
$sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = ".$conf["mirror_server_id"]." OR server_id = 0) ORDER BY datalog_id";
} else {
$sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = 0) ORDER BY datalog_id";
}
$records = $app->dbmaster->queryAllRecords($sql);
foreach($records as $d) {
......
......@@ -53,14 +53,17 @@ if($server_db_record == false) {
//* Load the server configuration
if($app->dbmaster->connect()) {
// get the dalaog_id of the last performed record
$server_db_record = $app->dbmaster->queryOneRecord("SELECT updated, config FROM server WHERE server_id = ".$conf["server_id"]);
$server_db_record = $app->dbmaster->queryOneRecord("SELECT * FROM server WHERE server_id = ".$conf["server_id"]);
$conf['last_datalog_id'] = (int)$server_db_record['updated'];
$conf["mirror_server_id"] = (int)$server_db_record['mirror_server_id'];
// Load the ini_parser
$app->uses('ini_parser');
// Get server configuration
$conf["serverconfig"] = $app->ini_parser->parse_ini_string(stripslashes($server_db_record["config"]));
// Set the loglevel
$conf["log_priority"] = intval($conf["serverconfig"]["server"]["loglevel"]);
unset($server_db_record);
}
......@@ -89,7 +92,12 @@ $app->log("Set Lock: ".$conf["temppath"].$conf["fs_div"].".ispconfig_lock", LOGL
if($app->db->connect() && $app->dbmaster->connect()) {
// Check if there is anything to update
$tmp_rec = $app->dbmaster->queryOneRecord("SELECT count(server_id) as number from sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = 0)");
if($conf["mirror_server_id"] > 0) {
$tmp_rec = $app->dbmaster->queryOneRecord("SELECT count(server_id) as number from sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = ".$conf["mirror_server_id"]." OR server_id = 0)");
} else {
$tmp_rec = $app->dbmaster->queryOneRecord("SELECT count(server_id) as number from sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf["server_id"]." OR server_id = 0)");
}
$tmp_num_records = $tmp_rec["number"];
unset($tmp_rec);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment