Skip to content

Commit 98dd6b9

Browse files
committed
backup exclusions
1 parent f32b111 commit 98dd6b9

File tree

6 files changed

+346
-2
lines changed

6 files changed

+346
-2
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?php
2+
// Init
3+
error_reporting(NULL);
4+
ob_start();
5+
session_start();
6+
7+
$TAB = 'BACKUP EXCLUSIONS';
8+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
9+
10+
// Header
11+
include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
12+
13+
// Panel
14+
top_panel($user,$TAB);
15+
16+
// Edit as someone else?
17+
if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
18+
$user=escapeshellarg($_GET['user']);
19+
}
20+
21+
exec (VESTA_CMD."v-list-user-backup-exclusions ".$user." 'json'", $output, $return_var);
22+
check_return_code($return_var,$output);
23+
if (empty($_SESSION['error_msg'])) {
24+
$data = json_decode(implode('', $output), true);
25+
unset($output);
26+
$v_username = $user;
27+
28+
foreach ($data['WEB'] as $key => $value) {
29+
if (!empty($value)){
30+
$v_web .= $key . ":" . $value. "\n";
31+
} else {
32+
$v_web .= $key . "\n";
33+
}
34+
}
35+
36+
foreach ($data['DNS'] as $key => $value) {
37+
if (!empty($value)){
38+
$v_dns .= $key . ":" . $value. "\n";
39+
} else {
40+
$v_dns .= $key . "\n";
41+
}
42+
}
43+
44+
foreach ($data['MAIL'] as $key => $value) {
45+
if (!empty($value)){
46+
$v_mail .= $key . ":" . $value. "\n";
47+
} else {
48+
$v_mail .= $key . "\n";
49+
}
50+
}
51+
52+
foreach ($data['DB'] as $key => $value) {
53+
if (!empty($value)){
54+
$v_db .= $key . ":" . $value. "\n";
55+
} else {
56+
$v_db .= $key . "\n";
57+
}
58+
}
59+
60+
foreach ($data['USER'] as $key => $value) {
61+
if (!empty($value)){
62+
$v_userdir .= $key . ":" . $value. "\n";
63+
} else {
64+
$v_userdir .= $key . "\n";
65+
}
66+
}
67+
68+
69+
// Action
70+
if (!empty($_POST['save'])) {
71+
72+
$v_web = $_POST['v_web'];
73+
$v_web_tmp = str_replace("\r\n", ",", $_POST['v_web']);
74+
$v_web_tmp = rtrim($v_web_tmp, ",");
75+
$v_web_tmp = "WEB=" . escapeshellarg($v_web_tmp);
76+
77+
$v_dns = $_POST['v_dns'];
78+
$v_dns_tmp = str_replace("\r\n", ",", $_POST['v_dns']);
79+
$v_dns_tmp = rtrim($v_dns_tmp, ",");
80+
$v_dns_tmp = "DNS=" . escapeshellarg($v_dns_tmp);
81+
82+
$v_mail = $_POST['v_mail'];
83+
$v_mail_tmp = str_replace("\r\n", ",", $_POST['v_mail']);
84+
$v_mail_tmp = rtrim($v_mail_tmp, ",");
85+
$v_mail_tmp = "MAIL=" . escapeshellarg($v_mail_tmp);
86+
87+
$v_db = $_POST['v_db'];
88+
$v_db_tmp = str_replace("\r\n", ",", $_POST['v_db']);
89+
$v_db_tmp = rtrim($v_db_tmp, ",");
90+
$v_db_tmp = "DB=" . escapeshellarg($v_db_tmp);
91+
92+
$v_userdir = $_POST['v_userdir'];
93+
$v_userdir_tmp = str_replace("\r\n", ",", $_POST['v_userdir']);
94+
$v_userdir_tmp = rtrim($v_userdir_tmp, ",");
95+
$v_userdir_tmp = "USER=" . escapeshellarg($v_userdir_tmp);
96+
97+
exec ('mktemp', $mktemp_output, $return_var);
98+
$tmp = $mktemp_output[0];
99+
$fp = fopen($tmp, 'w');
100+
fwrite($fp, $v_web_tmp . "\n" . $v_dns_tmp . "\n" . $v_mail_tmp . "\n" . $v_db_tmp . "\n" . $v_userdir_tmp . "\n");
101+
fclose($fp);
102+
exec (VESTA_CMD."v-update-user-backup-exclusions ".$user." ".$tmp, $output, $return_var);
103+
check_return_code($return_var,$output);
104+
if (empty($_SESSION['error_msg'])) {
105+
$_SESSION['ok_msg'] = __("Changes has been saved.");
106+
}
107+
}
108+
}
109+
110+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_backup_exclusions.html');
111+
unset($_SESSION['error_msg']);
112+
unset($_SESSION['ok_msg']);
113+
114+
// Footer
115+
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');

web/inc/i18n/en.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,11 @@
400400
'RESTORE_SCHEDULED' => 'Task has been added to the queue. You will receive an email notification when your backup is ready for download.',
401401
'RESTORE_EXISTS' => 'An existing restoration task is already running. Please wait for it to finish before launching it again.',
402402

403+
'WEB_EXCLUSIONS' => "Type domain name, one per line. To exlude all domains use *. To exclude specific dirs use following format: domain.com:public_html/cache:public_html/tmp",
404+
'DNS_EXCLUSIONS' => "Type domain name, one per line. To exlude all domains use *",
405+
'MAIL_EXCLUSIONS' => "Type domain name, one per line. To exlude all domains use *. To exclude specific accounts use following format: domain.com:info:support:postmaster",
406+
'DB_EXCLUSIONS' => "Type full database name, one per line. To exlude all databases use *",
407+
'USER_EXCLUSIONS' => "Type directory name, one per line. Directories should not include leading or trailing slashes. To exlude all dirs use *",
403408

404409
'Welcome to Vesta Control Panel' => 'Welcome to Vesta Control Panel',
405410
'MAIL_FROM' => 'Vesta Control Panel <noreply@%s>',
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
session_start();
3+
$TAB = 'BACKUP EXCLUSIONS';
4+
5+
// Main include
6+
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
7+
8+
// Header
9+
include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
10+
11+
// Panel
12+
top_panel($user,$TAB);
13+
14+
// Data
15+
exec (VESTA_CMD."v-list-user-backup-exclusions $user json", $output, $return_var);
16+
$data = json_decode(implode('', $output), true);
17+
unset($output);
18+
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_backup_exclusions.html');
19+
20+
// Back uri
21+
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
22+
23+
// Footer
24+
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
$back = $_SESSION['back'];
3+
if (empty($back)) {
4+
$back = "location.href='/list/backup/exclusions'";
5+
} else {
6+
$back = "location.href='".$back."'";
7+
}
8+
?>
9+
<table class="submenu">
10+
<tr>
11+
<td style="padding: 20px 10px;" ><a class="name"><b><?php print __('Editing Backup Exclusions');?></b></a>
12+
<?php
13+
if (!empty($_SESSION['error_msg'])) {
14+
echo "<span class=\"vst-error\"> → ".$_SESSION['error_msg']."</span>";
15+
} else {
16+
if (!empty($_SESSION['ok_msg'])) {
17+
echo "<span class=\"vst-ok\"> → ".$_SESSION['ok_msg']."</span>";
18+
}
19+
}
20+
?>
21+
</td>
22+
</tr>
23+
</table>
24+
</div>
25+
26+
<form id="vstobjects" name="v_edit_backup_exclusions" method="post">
27+
<table class='data'>
28+
<tr class="data-add">
29+
<td class="data-dotted">
30+
<table class="data-col1">
31+
<tr>
32+
<td>
33+
</td>
34+
</tr>
35+
<tr><td class="data-<?php echo $v_status ?>"><b><?php echo __($v_status) ?></b></td></tr>
36+
</table>
37+
</td>
38+
<td class="data-dotted">
39+
<table class="data-col2" width="600px">
40+
<tr>
41+
<td class="vst-text" style="padding: 24px 0 0 0;">
42+
<?php print __('Web Domains');?>
43+
</td>
44+
</tr>
45+
<tr>
46+
<td>
47+
<textarea class="vst-textinput" name="v_web" placeholder="<?php echo __('WEB_EXCLUSIONS') ?>"><?php if (isset($v_web)) echo $v_web; ?></textarea>
48+
</td>
49+
</tr>
50+
<tr>
51+
<td class="vst-text" style="padding: 12px 0 0 0;">
52+
<?php print __('DNS Domains');?>
53+
</td>
54+
</tr>
55+
<tr>
56+
<td>
57+
<textarea class="vst-textinput" name="v_dns" placeholder="<?php echo __('DNS_EXCLUSIONS') ?>"><?php if (isset($v_dns)) echo $v_dns; ?></textarea>
58+
</td>
59+
</tr>
60+
<tr>
61+
<td class="vst-text" style="padding: 12px 0 0 0;">
62+
<?php print __('Mail Domains');?>
63+
</td>
64+
</tr>
65+
<tr>
66+
<td>
67+
<textarea class="vst-textinput" name="v_mail" placeholder="<?php echo __('MAIL_EXCLUSIONS') ?>"><?php if (isset($v_mail)) echo $v_mail; ?></textarea>
68+
</td>
69+
</tr>
70+
<tr>
71+
<td class="vst-text" style="padding: 12px 0 0 0;">
72+
<?php print __('Databases');?>
73+
</td>
74+
</tr>
75+
<tr>
76+
<td>
77+
<textarea class="vst-textinput" name="v_db" placeholder="<?php echo __('DB_EXCLUSIONS') ?>"><?php if (isset($v_db)) echo $v_db; ?></textarea>
78+
</td>
79+
</tr>
80+
<tr>
81+
<td class="vst-text" style="padding: 12px 0 0 0;">
82+
<?php print __('User Directories');?>
83+
</td>
84+
</tr>
85+
<tr>
86+
<td>
87+
<textarea size="20" class="vst-textinput" name="v_userdir" placeholder="<?php echo __('USER_EXCLUSIONS') ?>"><?php if (isset($v_userdir)) echo $v_userdir; ?></textarea>
88+
</td>
89+
</tr>
90+
</table>
91+
<table class="data-col2">
92+
<tr>
93+
<td style="padding: 24px 0 0 0;" width="116px">
94+
<input type="submit" class="button" name="save" value="<?php print __('Save');?>">
95+
</td>
96+
<td style="padding: 24px 0 0 0;">
97+
<input type="button" class="button" value="<?php print __('Back');?>" onclick="<?php echo $back ?>">
98+
</td>
99+
</tr>
100+
</table>
101+
</td>
102+
</tr>
103+
</table>
104+
</form>

web/templates/admin/list_backup.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="submenu-search-block">
88
<form action="/search/" method="get">
99
<input type="text" name="q" class="submenu-search-field">
10-
<input type="submit" value="<?php print __('Search');?>" class="submenu-button" style="width: 96px;">
10+
<input type="submit" value="<?php print __('Search');?>" class="submenu-button-search">
1111
</form>
1212
</div>
1313
<div class="submenu-select-block">
@@ -17,7 +17,10 @@
1717
<option value=""><?php print __('apply to selected');?></option>
1818
<option value="delete"><?php print __('delete');?></option>
1919
</select>
20-
<input type="submit" name="ok" value="" class="submenu-button" style="width: 36px;">
20+
<input type="submit" name="ok" value="" class="submenu-button-select">
21+
</div>
22+
<div class="submenu-select-block">
23+
<a class="submenu-select-link" href="/list/backup/exclusions/">[ <?php print __('backup exclusions');?> ]</a>
2124
</div>
2225
<?php display_error_block(); ?>
2326
</td>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<table class="submenu">
2+
<tr>
3+
<td style="padding: 14px 10px">
4+
<div class="submenu-button-block">
5+
<button class="submenu-button-main" onclick="location.href='/edit/backup/exclusions/'"> <?php print __('Configure');?> </button>
6+
</div>
7+
<div class="submenu-search-block">
8+
<form action="/search/" method="get">
9+
<input type="text" name="q" class="submenu-search-field">
10+
<input type="submit" value="<?php print __('Search');?>" class="submenu-button-search">
11+
</form>
12+
</div>
13+
<div class="submenu-select-block">
14+
<form action="/bulk/backup/" method="post" id="objects">
15+
<a class="submenu-select-link" href='javascript:checkedAll("objects");'> <?php print __('toggle all');?> </a>
16+
<select class="submenu-select-dropdown" name="action">
17+
<option value=""><?php print __('apply to selected');?></option>
18+
<option value="delete"><?php print __('delete');?></option>
19+
</select>
20+
<input type="submit" name="ok" value="" class="submenu-button-select">
21+
</div>
22+
<?php display_error_block(); ?>
23+
</td>
24+
</tr>
25+
</table>
26+
</div>
27+
28+
<div id="vstobjects">
29+
<table class="data">
30+
31+
<?php
32+
foreach ($data as $key => $value) {
33+
?>
34+
35+
<tr class="data-row">
36+
<td class="data-dotted">
37+
<table class="data-col1">
38+
<tr><td><input type="checkbox" class="ch-toggle" name="exclusion[]" value="<?php echo $key ?>" ></td></tr>
39+
</table>
40+
</td>
41+
<td class="data-dotted" width="830px">
42+
<a id="delete_link_<?php echo $i ?>" class="data-controls do_delete">
43+
<span class="do_delete">
44+
<img src="/images/delete.png" width="7px" height="7px">
45+
<?php print __('delete');?>
46+
<input type="hidden" name="delete_url" value="/delete/backup/exclusion/?excl=<?php echo "$key" ?>" />
47+
<div id="delete_dialog_<?php echo $i ?>" class="confirmation-text-delete hidden" title="<?php print __('Confirmation');?>">
48+
<p class="counter-value"><?php print __('DELETE_BACKUP_CONFIRMATION',$key);?></p>
49+
</div>
50+
</span>
51+
</a>
52+
<table class="data-col5">
53+
<tr>
54+
<td class="cron" width="116px" style="vertical-align:top;">
55+
<b><?php echo $key ?></b>
56+
</td>
57+
<td style="vertical-align:top;" class="counter-value">
58+
<?php if (empty($value)) print __('no exclusions'); ?>
59+
<table>
60+
<?php
61+
foreach ($value as $ex_key => $ex_value) {
62+
?>
63+
<tr>
64+
<td class="counter-value"><b><?php echo $ex_key ?></b></td>
65+
<td class="counter-value" style="padding-left:12px;"><?php echo $ex_value ?></td>
66+
</tr>
67+
<?php
68+
}
69+
?>
70+
</table>
71+
</td>
72+
</tr>
73+
</table>
74+
</td>
75+
</tr>
76+
77+
<?php
78+
}
79+
?>
80+
81+
</table>
82+
</form>
83+
84+
<table class="data-count">
85+
<tr>
86+
<td width="174px"></td>
87+
<td>
88+
...
89+
</td>
90+
</tr>
91+
</table>
92+
</div>
93+

0 commit comments

Comments
 (0)