Skip to content

Commit d5b5d3d

Browse files
author
Marius Cramer
committed
Merge branch 'master' of git.ispconfig.org:ispconfig/ispconfig3
Conflicts: interface/lib/classes/plugin_backuplist.inc.php interface/web/sites/templates/web_backup_list.htm
2 parents 513a178 + f757771 commit d5b5d3d

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

interface/lib/classes/plugin_backuplist.inc.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,16 @@ function onShow() {
6767
}
6868

6969
if($_GET['backup_action'] == 'download' && $backup_id > 0) {
70+
$server_id = $this->form->dataRecord['server_id'];
71+
$backup = $app->db->queryOneRecord("SELECT * FROM web_backup WHERE backup_id = ".$backup_id);
72+
if($backup['server_id'] > 0) $server_id = $backup['server_id'];
7073
$sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = '$backup_id'";
7174
$tmp = $app->db->queryOneRecord($sql);
7275
if($tmp['number'] == 0) {
7376
$message .= $wb['download_info_txt'];
7477
$sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " .
7578
"VALUES (".
76-
(int)$this->form->dataRecord['server_id'] . ", " .
79+
(int)$server_id . ", " .
7780
time() . ", " .
7881
"'backup_download', " .
7982
"'".$backup_id."', " .
@@ -86,13 +89,16 @@ function onShow() {
8689
}
8790
}
8891
if($_GET['backup_action'] == 'restore' && $backup_id > 0) {
92+
$server_id = $this->form->dataRecord['server_id'];
93+
$backup = $app->db->queryOneRecord("SELECT * FROM web_backup WHERE backup_id = ".$backup_id);
94+
if($backup['server_id'] > 0) $server_id = $backup['server_id'];
8995
$sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_restore' AND action_param = '$backup_id'";
9096
$tmp = $app->db->queryOneRecord($sql);
9197
if($tmp['number'] == 0) {
9298
$message .= $wb['restore_info_txt'];
9399
$sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " .
94100
"VALUES (".
95-
(int)$this->form->dataRecord['server_id'] . ", " .
101+
(int)$server_id . ", " .
96102
time() . ", " .
97103
"'backup_restore', " .
98104
"'".$backup_id."', " .
@@ -110,9 +116,22 @@ function onShow() {
110116
//* Get the data
111117
$server_ids = array();
112118
$web = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ".$app->functions->intval($this->form->id));
113-
$database = $app->db->queryOneRecord("SELECT server_id FROM web_database WHERE parent_domain_id = ".$app->functions->intval($this->form->id));
119+
$databases = $app->db->queryAllRecords("SELECT server_id FROM web_database WHERE parent_domain_id = ".$app->functions->intval($this->form->id));
114120
if($app->functions->intval($web['server_id']) > 0) $server_ids[] = $app->functions->intval($web['server_id']);
115-
if($app->functions->intval($database['server_id']) > 0) $server_ids[] = $app->functions->intval($database['server_id']);
121+
if(is_array($databases) && !empty($databases)){
122+
foreach($databases as $database){
123+
if($app->functions->intval($database['server_id']) > 0) $server_ids[] = $app->functions->intval($database['server_id']);
124+
}
125+
}
126+
$server_ids = array_unique($server_ids);
127+
$web = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ".$app->functions->intval($this->form->id));
128+
$databases = $app->db->queryAllRecords("SELECT server_id FROM web_database WHERE parent_domain_id = ".$app->functions->intval($this->form->id));
129+
if($app->functions->intval($web['server_id']) > 0) $server_ids[] = $app->functions->intval($web['server_id']);
130+
if(is_array($databases) && !empty($databases)){
131+
foreach($databases as $database){
132+
if($app->functions->intval($database['server_id']) > 0) $server_ids[] = $app->functions->intval($database['server_id']);
133+
}
134+
}
116135
$server_ids = array_unique($server_ids);
117136
$sql = "SELECT * FROM web_backup WHERE parent_domain_id = ".$app->functions->intval($this->form->id)." AND server_id IN (".implode(',', $server_ids).") ORDER BY tstamp DESC, backup_type ASC";
118137
$records = $app->db->queryAllRecords($sql);
@@ -127,6 +146,9 @@ function onShow() {
127146

128147
$rec['date'] = date($app->lng('conf_format_datetime'), $rec['tstamp']);
129148
$rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])];
149+
150+
$rec['download_available'] = true;
151+
if($rec['server_id'] != $web['server_id']) $rec['download_available'] = false;
130152

131153
$records_new[] = $rec;
132154
}

interface/web/sites/templates/web_backup_list.htm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ <h3><tmpl_var name="list_head_txt"></h3>
2929
<td class="text-right">
3030
<div class="buttons">
3131
<button class="btn btn-default formbutton-default" type="button" onclick="confirm_action('sites/web_domain_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=restore&backup_id={tmpl_var name='backup_id'}','{tmpl_var name='restore_confirm_txt'}');">{tmpl_var name="restore_backup_txt"}</button>
32-
<button class="btn btn-default formbutton-default" type="button" data-load-content="sites/web_domain_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=download&backup_id={tmpl_var name='backup_id'}">{tmpl_var name="download_backup_txt"}</button>
32+
<tmpl_if name="download_available">
33+
<button class="btn btn-default formbutton-default" type="button" data-load-content="sites/web_domain_edit.php?id={tmpl_var name='parent_id'}&next_tab=backup&backup_action=download&backup_id={tmpl_var name='backup_id'}">{tmpl_var name="download_backup_txt"}</button>
34+
</tmpl_if>
3335
</div>
3436
</td>
3537
</tr>

server/plugins-available/backup_plugin.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function backup_action($action_name, $data) {
6868

6969
$app->uses('ini_parser,file,getconf,system');
7070

71-
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$backup['parent_domain_id']);
71+
$web = $app->dbmaster->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$backup['parent_domain_id']);
7272
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
7373
$backup_dir = $server_config['backup_dir'].'/web'.$web['domain_id'];
7474

@@ -80,7 +80,7 @@ public function backup_action($action_name, $data) {
8080
//* Make backup available for download
8181
if($action_name == 'backup_download') {
8282
//* Copy the backup file to the backup folder of the website
83-
if(file_exists($backup_dir.'/'.$backup['filename']) && !stristr($backup_dir.'/'.$backup['filename'], '..') && !stristr($backup_dir.'/'.$backup['filename'], 'etc')) {
83+
if(file_exists($backup_dir.'/'.$backup['filename']) && file_exists($web['document_root'].'/backup/') && !stristr($backup_dir.'/'.$backup['filename'], '..') && !stristr($backup_dir.'/'.$backup['filename'], 'etc')) {
8484
copy($backup_dir.'/'.$backup['filename'], $web['document_root'].'/backup/'.$backup['filename']);
8585
chgrp($web['document_root'].'/backup/'.$backup['filename'], $web['system_group']);
8686
$app->log('cp '.$backup_dir.'/'.$backup['filename'].' '.$web['document_root'].'/backup/'.$backup['filename'], LOGLEVEL_DEBUG);

0 commit comments

Comments
 (0)