Commit 5a43e7a2 authored by tbrehm's avatar tbrehm

- Implemented new backup and restore functions for websites and databases (see also FS#1389)

- Added "actions" framework in server to replace the functions provided by the core modules
- Moved system update function from remoteactins core module to software update plugin.
parent 819fd7f2
ALTER TABLE `web_database` ADD `parent_domain_id` int(11) unsigned NOT NULL DEFAULT '0' AFTER `server_id`;
ALTER TABLE `web_database` ADD `backup_interval` VARCHAR( 255 ) NOT NULL DEFAULT 'none', ADD `backup_copies` INT NOT NULL DEFAULT '1' AFTER `remote_ips`;
CREATE TABLE `web_backup` (
`backup_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`server_id` int(10) unsigned NOT NULL,
`parent_domain_id` int(10) unsigned NOT NULL,
`backup_type` enum('web','mysql') NOT NULL DEFAULT 'web',
`backup_mode` varchar(64) NOT NULL DEFAULT '',
`tstamp` int(10) unsigned NOT NULL,
`filename` varchar(255) NOT NULL,
PRIMARY KEY (`backup_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
...@@ -1437,6 +1437,23 @@ CREATE TABLE `webdav_user` ( ...@@ -1437,6 +1437,23 @@ CREATE TABLE `webdav_user` (
-- -------------------------------------------------------- -- --------------------------------------------------------
--
-- Table structure for table `web_backup`
--
CREATE TABLE `web_backup` (
`backup_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`server_id` int(10) unsigned NOT NULL,
`parent_domain_id` int(10) unsigned NOT NULL,
`backup_type` enum('web','mysql') NOT NULL DEFAULT 'web',
`backup_mode` varchar(64) NOT NULL DEFAULT '',
`tstamp` int(10) unsigned NOT NULL,
`filename` varchar(255) NOT NULL,
PRIMARY KEY (`backup_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
-- --
-- Table structure for table `web_database` -- Table structure for table `web_database`
-- --
...@@ -1449,6 +1466,7 @@ CREATE TABLE `web_database` ( ...@@ -1449,6 +1466,7 @@ CREATE TABLE `web_database` (
`sys_perm_group` varchar(5) DEFAULT NULL, `sys_perm_group` varchar(5) DEFAULT NULL,
`sys_perm_other` varchar(5) DEFAULT NULL, `sys_perm_other` varchar(5) DEFAULT NULL,
`server_id` int(11) unsigned NOT NULL DEFAULT '0', `server_id` int(11) unsigned NOT NULL DEFAULT '0',
`parent_domain_id` int(11) unsigned NOT NULL DEFAULT '0',
`type` varchar(16) NOT NULL DEFAULT 'y', `type` varchar(16) NOT NULL DEFAULT 'y',
`database_name` varchar(64) DEFAULT NULL, `database_name` varchar(64) DEFAULT NULL,
`database_user` varchar(64) DEFAULT NULL, `database_user` varchar(64) DEFAULT NULL,
...@@ -1456,6 +1474,8 @@ CREATE TABLE `web_database` ( ...@@ -1456,6 +1474,8 @@ CREATE TABLE `web_database` (
`database_charset` varchar(64) DEFAULT NULL, `database_charset` varchar(64) DEFAULT NULL,
`remote_access` enum('n','y') NOT NULL DEFAULT 'y', `remote_access` enum('n','y') NOT NULL DEFAULT 'y',
`remote_ips` text NOT NULL, `remote_ips` text NOT NULL,
`backup_interval` VARCHAR( 255 ) NOT NULL DEFAULT 'none',
`backup_copies` INT NOT NULL DEFAULT '1',
`active` enum('n','y') NOT NULL DEFAULT 'y', `active` enum('n','y') NOT NULL DEFAULT 'y',
PRIMARY KEY (`database_id`) PRIMARY KEY (`database_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
......
...@@ -13,7 +13,7 @@ hostname=server1.domain.tld ...@@ -13,7 +13,7 @@ hostname=server1.domain.tld
nameservers=192.168.0.1,192.168.0.2 nameservers=192.168.0.1,192.168.0.2
loglevel=2 loglevel=2
backup_dir=/var/backup backup_dir=/var/backup
backup_dir_ftpread=n backup_mode=rootgz
[mail] [mail]
module=postfix_mysql module=postfix_mysql
......
<?php
/*
Copyright (c) 2012, Till Brehm, ISPConfig UG
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class plugin_backuplist extends plugin_base {
var $module;
var $form;
var $tab;
var $record_id;
var $formdef;
var $options;
function onShow() {
global $app;
$listTpl = new tpl;
$listTpl->newTemplate('templates/web_backup_list.htm');
//* Loading language file
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_web_backup_list.lng";
include($lng_file);
$listTpl->setVar($wb);
$message = '';
$error = '';
if(isset($_GET['backup_action'])) {
$backup_id = intval($_GET['backup_id']);
if($_GET['backup_action'] == 'download' && $backup_id > 0) {
$sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = '$backup_id'";
$tmp = $app->db->queryOneRecord($sql);
if($tmp['number'] == 0) {
$message .= $wb['download_info_txt'];
$sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " .
"VALUES (".
(int)$this->form->dataRecord['server_id'] . ", " .
time() . ", " .
"'backup_download', " .
"'".$backup_id."', " .
"'pending', " .
"''" .
")";
$app->db->query($sql);
} else {
$error .= $wb['download_pending_txt'];
}
}
if($_GET['backup_action'] == 'restore' && $backup_id > 0) {
$sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_restore' AND action_param = '$backup_id'";
$tmp = $app->db->queryOneRecord($sql);
if($tmp['number'] == 0) {
$message .= $wb['restore_info_txt'];
$sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " .
"VALUES (".
(int)$this->form->dataRecord['server_id'] . ", " .
time() . ", " .
"'backup_restore', " .
"'".$backup_id."', " .
"'pending', " .
"''" .
")";
$app->db->query($sql);
} else {
$error .= $wb['restore_pending_txt'];
}
}
}
//* Get the data
$sql = "SELECT * FROM web_backup WHERE parent_domain_id = ".$this->form->id." ORDER BY tstamp DESC, backup_type ASC";
$records = $app->db->queryAllRecords($sql);
$bgcolor = "#FFFFFF";
if(is_array($records)) {
foreach($records as $rec) {
// Change of color
$bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF";
$rec["bgcolor"] = $bgcolor;
$rec['date'] = date($app->lng('conf_format_datetime'),$rec['tstamp']);
$rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])];
$records_new[] = $rec;
}
}
$listTpl->setLoop('records',@$records_new);
$listTpl->setVar('parent_id',$this->form->id);
$listTpl->setVar('msg',$message);
$listTpl->setVar('error',$error);
// Setting Returnto information in the session
$list_name = 'backup_list';
// $_SESSION["s"]["list"][$list_name]["parent_id"] = $app->tform_actions->id;
$_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id;
$_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"];
$_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"];
$_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"];
$_SESSION["s"]["form"]["return_to"] = $list_name;
return $listTpl->grab();
}
}
?>
\ No newline at end of file
...@@ -138,11 +138,13 @@ $form["tabs"]['server'] = array( ...@@ -138,11 +138,13 @@ $form["tabs"]['server'] = array(
'width' => '40', 'width' => '40',
'maxlength' => '255' 'maxlength' => '255'
), ),
'backup_dir_ftpread' => array( 'backup_mode' => array(
'datatype' => 'VARCHAR', 'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX', 'formtype' => 'SELECT',
'default' => 'y', 'default' => 'userzip',
'value' => array(0 => 'n', 1 => 'y') 'value' => array('userzip' => 'backup_mode_userzip', 'rootgz' => 'backup_mode_rootgz'),
'width' => '40',
'maxlength' => '255'
), ),
################################## ##################################
# ENDE Datatable fields # ENDE Datatable fields
......
...@@ -87,7 +87,9 @@ $wb["network_config_warning_txt"] = 'The network configuration option is only av ...@@ -87,7 +87,9 @@ $wb["network_config_warning_txt"] = 'The network configuration option is only av
$wb["CA_path_txt"] = 'CA Path'; $wb["CA_path_txt"] = 'CA Path';
$wb["CA_pass_txt"] = 'CA passphrase'; $wb["CA_pass_txt"] = 'CA passphrase';
$wb["fastcgi_config_syntax_txt"] = 'FastCGI config syntax'; $wb["fastcgi_config_syntax_txt"] = 'FastCGI config syntax';
$wb["backup_dir_ftpread_txt"] = 'Backup dir. readable for website FTP users.'; $wb["backup_mode_txt"] = 'Backup mode';
$wb["backup_mode_userzip"] = 'Backup web files owned by web user as zip';
$wb["backup_mode_rootgz"] = 'Backup all files in web directory as root user';
$wb["server_type_txt"] = 'Server Type'; $wb["server_type_txt"] = 'Server Type';
$wb["nginx_vhost_conf_dir_txt"] = 'Nginx Vhost config dir'; $wb["nginx_vhost_conf_dir_txt"] = 'Nginx Vhost config dir';
$wb["nginx_vhost_conf_enabled_dir_txt"] = 'Nginx Vhost config enabled dir'; $wb["nginx_vhost_conf_enabled_dir_txt"] = 'Nginx Vhost config enabled dir';
...@@ -153,7 +155,6 @@ $wb["set_folder_permissions_on_update_txt"] = 'Set folder permissions on update' ...@@ -153,7 +155,6 @@ $wb["set_folder_permissions_on_update_txt"] = 'Set folder permissions on update'
$wb["add_web_users_to_sshusers_group_txt"] = 'Add web users to -sshusers- group'; $wb["add_web_users_to_sshusers_group_txt"] = 'Add web users to -sshusers- group';
$wb["connect_userid_to_webid_txt"] = 'Connect Linux userid to webid'; $wb["connect_userid_to_webid_txt"] = 'Connect Linux userid to webid';
$wb["connect_userid_to_webid_start_txt"] = 'Start ID for userid/webid connect'; $wb["connect_userid_to_webid_start_txt"] = 'Start ID for userid/webid connect';
$wb["realtime_blackhole_list_txt"] = 'Real-time Blackhole List'; $wb["realtime_blackhole_list_txt"] = 'Real-time Blackhole List';
$wb["realtime_blackhole_list_note_txt"] = '(Separate RBL\'s with commas)'; $wb["realtime_blackhole_list_note_txt"] = '(Separate RBL\'s with commas)';
?> ?>
\ No newline at end of file
...@@ -43,11 +43,11 @@ ...@@ -43,11 +43,11 @@
<input name="backup_dir" id="backup_dir" value="{tmpl_var name='backup_dir'}" size="40" maxlength="255" type="text" class="textInput" /> <input name="backup_dir" id="backup_dir" value="{tmpl_var name='backup_dir'}" size="40" maxlength="255" type="text" class="textInput" />
</div> </div>
<div class="ctrlHolder"> <div class="ctrlHolder">
<p class="label">{tmpl_var name='backup_dir_ftpread_txt'}</p> <label for="backup_mode">{tmpl_var name='backup_mode_txt'}</label>
<div class="multiField"> <select name="backup_mode" id="backup_mode" class="selectInput">
{tmpl_var name='backup_dir_ftpread'} {tmpl_var name='backup_mode'}
</div> </select>
</div> </div>
</fieldset> </fieldset>
<input type="hidden" name="id" value="{tmpl_var name='id'}"> <input type="hidden" name="id" value="{tmpl_var name='id'}">
......
...@@ -269,6 +269,12 @@ function del_record(link,confirmation) { ...@@ -269,6 +269,12 @@ function del_record(link,confirmation) {
} }
} }
function confirm_action(link,confirmation) {
if(window.confirm(confirmation)) {
loadContent(link);
}
}
function loadContentInto(elementid,pagename) { function loadContentInto(elementid,pagename) {
var pageContentObject2 = jQuery.ajax({ type: "GET", var pageContentObject2 = jQuery.ajax({ type: "GET",
url: pagename, url: pagename,
......
...@@ -231,14 +231,14 @@ class page_action extends tform_actions { ...@@ -231,14 +231,14 @@ class page_action extends tform_actions {
// Spamfilter policy // Spamfilter policy
$policy_id = intval($this->dataRecord["policy"]); $policy_id = intval($this->dataRecord["policy"]);
if($policy_id > 0) { if($policy_id > 0) {
$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".mysql_real_escape_string($this->dataRecord["email"])."'"); $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".$app->db->quote($this->dataRecord["email"])."'");
if($tmp_user["id"] > 0) { if($tmp_user["id"] > 0) {
// There is already a record that we will update // There is already a record that we will update
$app->db->datalogUpdate('spamfilter_users', "policy_id = $policy_id", 'id', $tmp_user["id"]); $app->db->datalogUpdate('spamfilter_users', "policy_id = $policy_id", 'id', $tmp_user["id"]);
} else { } else {
// We create a new record // We create a new record
$insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
VALUES (".$_SESSION["s"]["user"]["userid"].", ".$domain["sys_groupid"].", 'riud', 'riud', '', ".$domain["server_id"].", 10, ".$policy_id.", '".mysql_real_escape_string($this->dataRecord["email"])."', '".mysql_real_escape_string($this->dataRecord["email"])."', 'Y')"; VALUES (".$_SESSION["s"]["user"]["userid"].", ".$domain["sys_groupid"].", 'riud', 'riud', '', ".$domain["server_id"].", 10, ".$policy_id.", '".$app->db->quote($this->dataRecord["email"])."', '".$app->db->quote($this->dataRecord["email"])."', 'Y')";
$app->db->datalogInsert('spamfilter_users', $insert_data, 'id'); $app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
} }
} // endif spamfilter policy } // endif spamfilter policy
...@@ -266,7 +266,7 @@ class page_action extends tform_actions { ...@@ -266,7 +266,7 @@ class page_action extends tform_actions {
// Spamfilter policy // Spamfilter policy
$policy_id = intval($this->dataRecord["policy"]); $policy_id = intval($this->dataRecord["policy"]);
$tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".mysql_real_escape_string($this->dataRecord["email"])."'"); $tmp_user = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '".$app->db->quote($this->dataRecord["email"])."'");
if($policy_id > 0) { if($policy_id > 0) {
if($tmp_user["id"] > 0) { if($tmp_user["id"] > 0) {
// There is already a record that we will update // There is already a record that we will update
...@@ -274,7 +274,7 @@ class page_action extends tform_actions { ...@@ -274,7 +274,7 @@ class page_action extends tform_actions {
} else { } else {
// We create a new record // We create a new record
$insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`) $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `priority`, `policy_id`, `email`, `fullname`, `local`)
VALUES (".$_SESSION["s"]["user"]["userid"].", ".$domain["sys_groupid"].", 'riud', 'riud', '', ".$domain["server_id"].", 10, ".$policy_id.", '".mysql_real_escape_string($this->dataRecord["email"])."', '".mysql_real_escape_string($this->dataRecord["email"])."', 'Y')"; VALUES (".$_SESSION["s"]["user"]["userid"].", ".$domain["sys_groupid"].", 'riud', 'riud', '', ".$domain["server_id"].", 10, ".$policy_id.", '".$app->db->quote($this->dataRecord["email"])."', '".$app->db->quote($this->dataRecord["email"])."', 'Y')";
$app->db->datalogInsert('spamfilter_users', $insert_data, 'id'); $app->db->datalogInsert('spamfilter_users', $insert_data, 'id');
} }
}else { }else {
......
...@@ -91,20 +91,6 @@ class page_action extends tform_actions { ...@@ -91,20 +91,6 @@ class page_action extends tform_actions {
$tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = $client[default_webserver]"); $tmp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = $client[default_webserver]");
$app->tpl->setVar("server_id","<option value='$client[default_webserver]'>$tmp[server_name]</option>"); $app->tpl->setVar("server_id","<option value='$client[default_webserver]'>$tmp[server_name]</option>");
unset($tmp); unset($tmp);
// Fill the client select field
$sql = "SELECT groupid, name FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']." ORDER BY name";
$clients = $app->db->queryAllRecords($sql);
$tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']);
$client_select = '<option value="'.$tmp['groupid'].'">'.$client['contact_name'].'</option>';
//$tmp_data_record = $app->tform->getDataRecord($this->id);
if(is_array($clients)) {
foreach( $clients as $client) {
$selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid']))?'SELECTED':'';
$client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n";
}
}
$app->tpl->setVar("client_group_id",$client_select);
} else { } else {
...@@ -117,33 +103,6 @@ class page_action extends tform_actions { ...@@ -117,33 +103,6 @@ class page_action extends tform_actions {
$server_id = $tmp['server_id']; $server_id = $tmp['server_id'];
} }
$sql = "SELECT ip_address FROM server_ip WHERE server_id = $server_id";
$ips = $app->db->queryAllRecords($sql);
$ip_select = "<option value='*'>*</option>";
//$ip_select = "";
if(is_array($ips)) {
foreach( $ips as $ip) {
$selected = ($ip["ip_address"] == $this->dataRecord["ip_address"])?'SELECTED':'';
$ip_select .= "<option value='$ip[ip_address]' $selected>$ip[ip_address]</option>\r\n";
}
}
$app->tpl->setVar("ip_address",$ip_select);
unset($tmp);
unset($ips);
// Fill the client select field
$sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name";
$clients = $app->db->queryAllRecords($sql);
$client_select = "<option value='0'></option>";
//$tmp_data_record = $app->tform->getDataRecord($this->id);
if(is_array($clients)) {
foreach( $clients as $client) {
$selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid']))?'SELECTED':'';
$client_select .= "<option value='$client[groupid]' $selected>$client[name]</option>\r\n";
}
}
$app->tpl->setVar("client_group_id",$client_select);
} }
/* /*
...@@ -212,9 +171,6 @@ class page_action extends tform_actions { ...@@ -212,9 +171,6 @@ class page_action extends tform_actions {
} }
} }
// Clients may not set the client_group_id, so we unset them if user is not a admin and the client is not a reseller
if(!$app->auth->has_clients($_SESSION['s']['user']['userid'])) unset($this->dataRecord["client_group_id"]);
} }
...@@ -224,10 +180,8 @@ class page_action extends tform_actions { ...@@ -224,10 +180,8 @@ class page_action extends tform_actions {
function onBeforeUpdate() { function onBeforeUpdate() {
global $app, $conf, $interfaceConf; global $app, $conf, $interfaceConf;
/* //* Site shell not be empty
* If the names should be restricted -> do it! if($this->dataRecord['parent_domain_id'] == 0) $app->tform->errorMessage .= $app->tform->lng("database_site_error_empty").'<br />';
*/
//* Get the database name and database user prefix //* Get the database name and database user prefix
$app->uses('getconf'); $app->uses('getconf');
...@@ -290,6 +244,9 @@ class page_action extends tform_actions { ...@@ -290,6 +244,9 @@ class page_action extends tform_actions {
function onBeforeInsert() { function onBeforeInsert() {
global $app, $conf, $interfaceConf; global $app, $conf, $interfaceConf;
//* Site shell not be empty
if($this->dataRecord['parent_domain_id'] == 0) $app->tform->errorMessage .= $app->tform->lng("database_site_error_empty").'<br />';
//* Database username and database name shall not be empty //* Database username and database name shall not be empty
if($this->dataRecord['database_name'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_name_error_empty"].'<br />'; if($this->dataRecord['database_name'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_name_error_empty"].'<br />';
if($this->dataRecord['database_user'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_user_error_empty"].'<br />'; if($this->dataRecord['database_user'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_user_error_empty"].'<br />';
...@@ -330,31 +287,33 @@ class page_action extends tform_actions { ...@@ -330,31 +287,33 @@ class page_action extends tform_actions {
function onAfterInsert() { function onAfterInsert() {
global $app, $conf; global $app, $conf;
// make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it if($this->dataRecord["parent_domain_id"] > 0) {
// also make sure that the user can not delete domain created by a admin $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
$client_group_id = intval($this->dataRecord["client_group_id"]); //* The Database user shall be owned by the same group then the website
$app->db->query("UPDATE web_database SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE database_id = ".$this->id); $sys_groupid = $web['sys_groupid'];
} $backup_interval = $web['backup_interval'];
if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { $backup_copies = $web['backup_copies'];
$client_group_id = intval($this->dataRecord["client_group_id"]);
$app->db->query("UPDATE web_database SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE database_id = ".$this->id); $sql = "UPDATE web_database SET sys_groupid = '$sys_groupid', backup_interval = '$backup_interval', backup_copies = '$backup_copies' WHERE database_id = ".$this->id;
$app->db->query($sql);
} }
} }
function onAfterUpdate() { function onAfterUpdate() {
global $app, $conf; global $app, $conf;
// make sure that the record belongs to the client group and not the admin group when a admin inserts it if($this->dataRecord["parent_domain_id"] > 0) {
// also make sure that the user can not delete domain created by a admin $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
$client_group_id = intval($this->dataRecord["client_group_id"]); //* The Database user shall be owned by the same group then the website
$app->db->query("UPDATE web_database SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE database_id = ".$this->id); $sys_groupid = $web['sys_groupid'];
} $backup_interval = $web['backup_interval'];
if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { $backup_copies = $web['backup_copies'];
$client_group_id = intval($this->dataRecord["client_group_id"]);
$app->db->query("UPDATE web_database SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE database_id = ".$this->id); $sql = "UPDATE web_database SET sys_groupid = '$sys_groupid', backup_interval = '$backup_interval', backup_copies = '$backup_copies' WHERE database_id = ".$this->id;
$app->db->query($sql);
} }
} }
......
...@@ -69,6 +69,17 @@ $form["tabs"]['database'] = array ( ...@@ -69,6 +69,17 @@ $form["tabs"]['database'] = array (
), ),
'value' => '' 'value' => ''
), ),
'parent_domain_id' => array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => "SELECT domain_id,domain FROM web_domain WHERE type = 'vhost' AND {AUTHSQL} ORDER BY domain",
'keyfield'=> 'domain_id',
'valuefield'=> 'domain'
),
'value' => array('0' => $app->tform->lng('select_site_txt'))
),
'type' => array ( 'type' => array (
'datatype' => 'VARCHAR', 'datatype' => 'VARCHAR',
'formtype' => 'SELECT', 'formtype' => 'SELECT',
......
...@@ -431,7 +431,7 @@ $form["tabs"]['stats'] = array ( ...@@ -431,7 +431,7 @@ $form["tabs"]['stats'] = array (
) )
); );
if($_SESSION["s"]["user"]["typ"] == 'admin') { // if($_SESSION["s"]["user"]["typ"] == 'admin') {
//* Backup //* Backup
$form["tabs"]['backup'] = array ( $form["tabs"]['backup'] = array (
...@@ -458,10 +458,17 @@ $form["tabs"]['backup'] = array ( ...@@ -458,10 +458,17 @@ $form["tabs"]['backup'] = array (
################################## ##################################
# ENDE Datatable fields # ENDE Datatable fields
################################## ##################################
),
'plugins' => array (
'backup_records' => array (
'class' => 'plugin_backuplist',
'options' => array(
)
)
) )
); );
} // }
if($_SESSION["s"]["user"]["typ"] == 'admin') { if($_SESSION["s"]["user"]["typ"] == 'admin') {
......
...@@ -22,4 +22,9 @@ $wb["database_name_change_txt"] = 'The database name can not be changed'; ...@@ -22,4 +22,9 @@ $wb["database_name_change_txt"] = 'The database name can not be changed';
$wb["database_charset_change_txt"] = 'The database charset can not be changed'; $wb["database_charset_change_txt"] = 'The database charset can not be changed';
$wb[