Forráskód Böngészése

backup exclusions

Serghey Rodin 12 éve
szülő
commit
98dd6b9d5d

+ 115 - 0
web/edit/backup/exclusions/index.php

@@ -0,0 +1,115 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+
+$TAB = 'BACKUP EXCLUSIONS';
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+// Header
+include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
+
+// Panel
+top_panel($user,$TAB);
+
+// Edit as someone else?
+if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
+    $user=escapeshellarg($_GET['user']);
+}
+
+exec (VESTA_CMD."v-list-user-backup-exclusions ".$user." 'json'", $output, $return_var);
+check_return_code($return_var,$output);
+if (empty($_SESSION['error_msg'])) {
+    $data = json_decode(implode('', $output), true);
+    unset($output);
+    $v_username = $user;
+
+    foreach ($data['WEB'] as $key => $value) {
+        if (!empty($value)){
+            $v_web .= $key . ":" . $value. "\n";
+        } else {
+            $v_web .= $key . "\n";
+        }
+    }
+
+    foreach ($data['DNS'] as $key => $value) {
+        if (!empty($value)){
+            $v_dns .= $key . ":" . $value. "\n";
+        } else {
+            $v_dns .= $key . "\n";
+        }
+    }
+
+    foreach ($data['MAIL'] as $key => $value) {
+        if (!empty($value)){
+            $v_mail .= $key . ":" . $value. "\n";
+        } else {
+            $v_mail .= $key . "\n";
+        }
+    }
+
+    foreach ($data['DB'] as $key => $value) {
+        if (!empty($value)){
+            $v_db .= $key . ":" . $value. "\n";
+        } else {
+            $v_db .= $key . "\n";
+        }
+    }
+
+    foreach ($data['USER'] as $key => $value) {
+        if (!empty($value)){
+            $v_userdir .= $key . ":" . $value. "\n";
+        } else {
+            $v_userdir .= $key . "\n";
+        }
+    }
+
+
+    // Action
+    if (!empty($_POST['save'])) {
+
+        $v_web = $_POST['v_web'];
+        $v_web_tmp = str_replace("\r\n", ",", $_POST['v_web']);
+        $v_web_tmp = rtrim($v_web_tmp, ",");
+        $v_web_tmp = "WEB=" . escapeshellarg($v_web_tmp);
+
+        $v_dns = $_POST['v_dns'];
+        $v_dns_tmp = str_replace("\r\n", ",", $_POST['v_dns']);
+        $v_dns_tmp = rtrim($v_dns_tmp, ",");
+        $v_dns_tmp = "DNS=" . escapeshellarg($v_dns_tmp);
+
+        $v_mail = $_POST['v_mail'];
+        $v_mail_tmp = str_replace("\r\n", ",", $_POST['v_mail']);
+        $v_mail_tmp = rtrim($v_mail_tmp, ",");
+        $v_mail_tmp = "MAIL=" . escapeshellarg($v_mail_tmp);
+
+        $v_db = $_POST['v_db'];
+        $v_db_tmp = str_replace("\r\n", ",", $_POST['v_db']);
+        $v_db_tmp = rtrim($v_db_tmp, ",");
+        $v_db_tmp = "DB=" . escapeshellarg($v_db_tmp);
+
+        $v_userdir = $_POST['v_userdir'];
+        $v_userdir_tmp = str_replace("\r\n", ",", $_POST['v_userdir']);
+        $v_userdir_tmp = rtrim($v_userdir_tmp, ",");
+        $v_userdir_tmp = "USER=" . escapeshellarg($v_userdir_tmp);
+
+        exec ('mktemp', $mktemp_output, $return_var);
+        $tmp = $mktemp_output[0];
+        $fp = fopen($tmp, 'w');
+        fwrite($fp, $v_web_tmp . "\n" . $v_dns_tmp . "\n" . $v_mail_tmp . "\n" .  $v_db_tmp . "\n" . $v_userdir_tmp . "\n");
+        fclose($fp);
+        exec (VESTA_CMD."v-update-user-backup-exclusions ".$user." ".$tmp, $output, $return_var);
+        check_return_code($return_var,$output);
+        if (empty($_SESSION['error_msg'])) {
+            $_SESSION['ok_msg'] = __("Changes has been saved.");
+        }
+    }
+}
+
+include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_backup_exclusions.html');
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);
+
+// Footer
+include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');

+ 5 - 0
web/inc/i18n/en.php

@@ -400,6 +400,11 @@ $LANG['en'] = array(
     'RESTORE_SCHEDULED'  => 'Task has been added to the queue. You will receive an email notification when your backup is ready for download.',
     'RESTORE_SCHEDULED'  => 'Task has been added to the queue. You will receive an email notification when your backup is ready for download.',
     'RESTORE_EXISTS'  => 'An existing restoration task is already running. Please wait for it to finish before launching it again.',
     'RESTORE_EXISTS'  => 'An existing restoration task is already running. Please wait for it to finish before launching it again.',
 
 
+    '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",
+    'DNS_EXCLUSIONS' => "Type domain name, one per line. To exlude all domains use *",
+    '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",
+    'DB_EXCLUSIONS' => "Type full database name, one per line. To exlude all databases use *",
+    'USER_EXCLUSIONS' => "Type directory name, one per line. Directories should not include leading or trailing slashes. To exlude all dirs use *",
 
 
     'Welcome to Vesta Control Panel'  => 'Welcome to Vesta Control Panel',
     'Welcome to Vesta Control Panel'  => 'Welcome to Vesta Control Panel',
     'MAIL_FROM'  => 'Vesta Control Panel <noreply@%s>',
     'MAIL_FROM'  => 'Vesta Control Panel <noreply@%s>',

+ 24 - 0
web/list/backup/exclusions/index.php

@@ -0,0 +1,24 @@
+<?php
+session_start();
+$TAB = 'BACKUP EXCLUSIONS';
+
+// Main include
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+// Header
+include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
+
+// Panel
+top_panel($user,$TAB);
+
+// Data
+exec (VESTA_CMD."v-list-user-backup-exclusions $user json", $output, $return_var);
+$data = json_decode(implode('', $output), true);
+unset($output);
+include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/list_backup_exclusions.html');
+
+// Back uri
+$_SESSION['back'] = $_SERVER['REQUEST_URI'];
+
+// Footer
+include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');

+ 104 - 0
web/templates/admin/edit_backup_exclusions.html

@@ -0,0 +1,104 @@
+            <?php
+                $back = $_SESSION['back'];
+                if (empty($back)) {
+                    $back = "location.href='/list/backup/exclusions'";
+                } else {
+                    $back = "location.href='".$back."'";
+                }
+            ?> 
+            <table class="submenu">
+                <tr>
+                    <td style="padding: 20px 10px;" ><a class="name"><b><?php print __('Editing Backup Exclusions');?></b></a>
+                        <?php
+                            if (!empty($_SESSION['error_msg'])) {
+                                echo "<span class=\"vst-error\"> → ".$_SESSION['error_msg']."</span>";
+                            } else {
+                                if (!empty($_SESSION['ok_msg'])) {
+                                    echo "<span class=\"vst-ok\"> → ".$_SESSION['ok_msg']."</span>";
+                                }
+                            }
+                        ?> 
+                    </td>
+                </tr>
+            </table>
+        </div>
+
+        <form id="vstobjects" name="v_edit_backup_exclusions" method="post">
+            <table class='data'>
+                <tr class="data-add">
+                    <td class="data-dotted">
+                        <table class="data-col1">
+                            <tr>
+                                <td>
+                                </td>
+                            </tr>
+                            <tr><td class="data-<?php echo $v_status ?>"><b><?php echo __($v_status) ?></b></td></tr>
+                        </table>
+                    </td>
+                    <td class="data-dotted">
+                        <table class="data-col2" width="600px">
+                            <tr>
+                                <td class="vst-text" style="padding: 24px 0 0 0;">
+                                    <?php print __('Web Domains');?>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td>
+                                    <textarea class="vst-textinput" name="v_web" placeholder="<?php echo __('WEB_EXCLUSIONS') ?>"><?php if (isset($v_web)) echo $v_web; ?></textarea>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td class="vst-text" style="padding: 12px 0 0 0;">
+                                    <?php print __('DNS Domains');?>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td>
+                                    <textarea class="vst-textinput" name="v_dns" placeholder="<?php echo __('DNS_EXCLUSIONS') ?>"><?php if (isset($v_dns)) echo $v_dns; ?></textarea>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td class="vst-text" style="padding: 12px 0 0 0;">
+                                    <?php print __('Mail Domains');?>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td>
+                                    <textarea class="vst-textinput" name="v_mail" placeholder="<?php echo __('MAIL_EXCLUSIONS') ?>"><?php if (isset($v_mail)) echo $v_mail; ?></textarea>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td class="vst-text" style="padding: 12px 0 0 0;">
+                                    <?php print __('Databases');?>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td>
+                                    <textarea class="vst-textinput" name="v_db" placeholder="<?php echo __('DB_EXCLUSIONS') ?>"><?php if (isset($v_db)) echo $v_db; ?></textarea>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td class="vst-text" style="padding: 12px 0 0 0;">
+                                    <?php print __('User Directories');?>
+                                </td>
+                            </tr>
+                            <tr>
+                                <td>
+                                    <textarea size="20" class="vst-textinput" name="v_userdir" placeholder="<?php echo __('USER_EXCLUSIONS') ?>"><?php if (isset($v_userdir)) echo $v_userdir; ?></textarea>
+                                </td>
+                            </tr>
+                        </table>
+                        <table class="data-col2">
+                            <tr>
+                                <td style="padding: 24px 0 0 0;" width="116px">
+                                    <input type="submit" class="button" name="save" value="<?php print __('Save');?>">
+                                </td>
+                                <td style="padding: 24px 0 0 0;">
+                                    <input type="button" class="button" value="<?php print __('Back');?>" onclick="<?php echo $back ?>">
+                                </td>
+                            </tr>
+                        </table>
+                    </td>
+                </tr>
+            </table>
+        </form>

+ 5 - 2
web/templates/admin/list_backup.html

@@ -7,7 +7,7 @@
                         <div class="submenu-search-block">
                         <div class="submenu-search-block">
                             <form action="/search/" method="get">
                             <form action="/search/" method="get">
                             <input type="text" name="q" class="submenu-search-field">
                             <input type="text" name="q" class="submenu-search-field">
-                            <input type="submit" value="<?php print __('Search');?>" class="submenu-button" style="width: 96px;">
+                            <input type="submit" value="<?php print __('Search');?>" class="submenu-button-search">
                             </form>
                             </form>
                         </div>
                         </div>
                         <div class="submenu-select-block">
                         <div class="submenu-select-block">
@@ -17,7 +17,10 @@
                                 <option value=""><?php print __('apply to selected');?></option>
                                 <option value=""><?php print __('apply to selected');?></option>
                                 <option value="delete"><?php print __('delete');?></option>
                                 <option value="delete"><?php print __('delete');?></option>
                             </select>
                             </select>
-                            <input type="submit" name="ok" value="›" class="submenu-button" style="width: 36px;">
+                            <input type="submit" name="ok" value="›" class="submenu-button-select">
+                        </div>
+                        <div class="submenu-select-block">
+                            <a class="submenu-select-link" href="/list/backup/exclusions/">[ <?php print __('backup exclusions');?> ]</a>
                         </div>
                         </div>
                         <?php display_error_block(); ?> 
                         <?php display_error_block(); ?> 
                     </td>
                     </td>

+ 93 - 0
web/templates/admin/list_backup_exclusions.html

@@ -0,0 +1,93 @@
+           <table class="submenu">
+                <tr>
+                    <td style="padding: 14px 10px">
+                        <div class="submenu-button-block">
+                            <button class="submenu-button-main" onclick="location.href='/edit/backup/exclusions/'"> <?php print __('Configure');?> </button>
+                        </div>
+                        <div class="submenu-search-block">
+                            <form action="/search/" method="get">
+                            <input type="text" name="q" class="submenu-search-field">
+                            <input type="submit" value="<?php print __('Search');?>" class="submenu-button-search">
+                            </form>
+                        </div>
+                        <div class="submenu-select-block">
+                            <form action="/bulk/backup/" method="post" id="objects">
+                            <a class="submenu-select-link" href='javascript:checkedAll("objects");'> <?php print __('toggle all');?> </a>
+                            <select class="submenu-select-dropdown" name="action">
+                                <option value=""><?php print __('apply to selected');?></option>
+                                <option value="delete"><?php print __('delete');?></option>
+                            </select>
+                            <input type="submit" name="ok" value="›" class="submenu-button-select">
+                        </div>
+                        <?php display_error_block(); ?> 
+                    </td>
+                </tr>
+            </table>
+        </div>
+
+        <div id="vstobjects">
+            <table class="data">
+
+                <?php
+                    foreach ($data as $key => $value) {
+                ?> 
+
+                <tr class="data-row">
+                    <td class="data-dotted">
+                        <table class="data-col1">
+                            <tr><td><input type="checkbox" class="ch-toggle" name="exclusion[]" value="<?php echo $key ?>" ></td></tr>
+                        </table>
+                    </td>
+                    <td class="data-dotted" width="830px">
+                        <a id="delete_link_<?php echo $i ?>" class="data-controls do_delete">
+                            <span class="do_delete">
+                                <img src="/images/delete.png" width="7px" height="7px">
+                                <?php print __('delete');?> 
+                                <input type="hidden" name="delete_url" value="/delete/backup/exclusion/?excl=<?php echo "$key" ?>" />
+                                <div id="delete_dialog_<?php echo $i ?>" class="confirmation-text-delete hidden" title="<?php print __('Confirmation');?>">
+                                    <p class="counter-value"><?php print __('DELETE_BACKUP_CONFIRMATION',$key);?></p>
+                                </div>
+                            </span>
+                        </a>
+                        <table class="data-col5">
+                            <tr>
+                                <td class="cron" width="116px" style="vertical-align:top;">
+                                    <b><?php echo $key ?></b>
+                                </td>
+                                <td style="vertical-align:top;" class="counter-value">
+                                    <?php if (empty($value)) print __('no exclusions'); ?> 
+                                    <table>
+                                    <?php
+                                        foreach ($value as $ex_key => $ex_value) {
+                                    ?> 
+                                        <tr>
+                                            <td class="counter-value"><b><?php echo $ex_key ?></b></td>
+                                            <td class="counter-value" style="padding-left:12px;"><?php echo $ex_value ?></td>
+                                        </tr>
+                                    <?php
+                                        }
+                                    ?> 
+                                    </table>
+                                </td>
+                            </tr>
+                        </table>
+                    </td>
+                </tr>
+
+                <?php
+                    }
+                ?> 
+
+            </table>
+            </form>
+
+            <table class="data-count">
+                <tr>
+                    <td width="174px"></td>
+                    <td>
+                        ...
+                    </td>
+                </tr>
+            </table>
+        </div>
+