Selaa lähdekoodia

delete backup exclusions

Serghey Rodin 12 vuotta sitten
vanhempi
sitoutus
a85aa52b22

+ 77 - 0
bin/v-delete-user-backup-exclusions

@@ -0,0 +1,77 @@
+#!/bin/bash
+# info: delete backup exclusion
+# options: USER [SYSTEM]
+#
+# The function for deleteing backup exclusion
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+system=$(echo $2 | tr '[:lower:]' '[:upper:]')
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'USER [SYSTEM]'
+validate_format 'user'
+is_object_valid 'user' 'USER' "$user"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Delete system exclusion
+if [ -z "$system" ]; then
+    WEB=''
+    DNS=''
+    MAIL=''
+    DB=''
+    CRON=''
+    USER=''
+else
+    touch $USER_DATA/backup-excludes.conf
+    source $USER_DATA/backup-excludes.conf
+    case $system in
+        WEB)   WEB='';;
+        DNS)   DNS='';;
+        MAIL)  MAIL='';;
+        DB)    DB='';;
+        CRON)  CRON='';;
+        USER)  USER='';;
+    esac
+fi
+
+# Updating exlusion list
+echo "WEB='$WEB'" > $USER_DATA/backup-excludes.conf
+echo "DNS='$DNS'" >> $USER_DATA/backup-excludes.conf
+echo "MAIL='$MAIL'" >> $USER_DATA/backup-excludes.conf
+echo "DB='$DB'" >> $USER_DATA/backup-excludes.conf
+echo "CRON='$DB'" >> $USER_DATA/backup-excludes.conf
+echo "USER='$USER'" >> $USER_DATA/backup-excludes.conf
+chmod 660 $USER_DATA/backup-excludes.conf
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+if [ -z "$system" ]; then
+    log_history "deleted all exlusions"
+else
+    log_history "deleted $system exlusion"
+fi
+log_event "$OK" "$EVENT"
+
+exit

+ 23 - 0
web/bulk/backup/exclusions/index.php

@@ -0,0 +1,23 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+$backup = $_POST['system'];
+$action = $_POST['action'];
+
+switch ($action) {
+    case 'delete': $cmd='v-delete-user-backup-exclusions';
+        break;
+    default: header("Location: /list/backup/exclusions"); exit;
+}
+
+foreach ($backup as $value) {
+    $value = escapeshellarg($value);
+    exec (VESTA_CMD.$cmd." ".$user." ".$value, $output, $return_var);
+}
+
+header("Location: /list/backup/exclusions");

+ 27 - 0
web/delete/backup/exclusion/index.php

@@ -0,0 +1,27 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+if (($_SESSION['user'] == 'admin') && (!empty($_GET['user']))) {
+    $user=$_GET['user'];
+}
+
+if (!empty($_GET['system'])) {
+    $v_username = escapeshellarg($user);
+    $v_system = escapeshellarg($_GET['system']);
+    exec (VESTA_CMD."v-delete-user-backup-exclusions ".$v_username." ".$v_system, $output, $return_var);
+}
+check_return_code($return_var,$output);
+unset($output);
+
+$back = $_SESSION['back'];
+if (!empty($back)) {
+    header("Location: ".$back);
+    exit;
+}
+
+header("Location: /list/backup/exclusions/");
+exit;

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

@@ -382,6 +382,7 @@ $LANG['en'] = array(
     'SUSPEND_CRON_CONFIRMATION' => 'Are you sure to suspend cron job?',
     'SUSPEND_CRON_CONFIRMATION' => 'Are you sure to suspend cron job?',
     'UNSUSPEND_CRON_CONFIRMATION' => 'Are you sure to unsuspend cron job?',
     'UNSUSPEND_CRON_CONFIRMATION' => 'Are you sure to unsuspend cron job?',
     'DELETE_BACKUP_CONFIRMATION'  => 'Are you sure to delete %s backup?',
     'DELETE_BACKUP_CONFIRMATION'  => 'Are you sure to delete %s backup?',
+    'DELETE_EXCLUSION_CONFIRMATION' => 'Are you sure to delete %s exclusion?',
     'DELETE_PACKAGE_CONFIRMATION'  => 'Are you sure to delete package %s?',
     'DELETE_PACKAGE_CONFIRMATION'  => 'Are you sure to delete package %s?',
     'DELETE_IP_CONFIRMATION'  => 'Are you sure to delere IP address %s?',
     'DELETE_IP_CONFIRMATION'  => 'Are you sure to delere IP address %s?',
     'Welcome'  => 'Welcome',
     'Welcome'  => 'Welcome',

+ 4 - 4
web/templates/admin/list_backup_exclusions.html

@@ -11,7 +11,7 @@
                             </form>
                             </form>
                         </div>
                         </div>
                         <div class="submenu-select-block">
                         <div class="submenu-select-block">
-                            <form action="/bulk/backup/" method="post" id="objects">
+                            <form action="/bulk/backup/exclusions/" method="post" id="objects">
                             <a class="submenu-select-link" href='javascript:checkedAll("objects");'> <?php print __('toggle all');?> </a>
                             <a class="submenu-select-link" href='javascript:checkedAll("objects");'> <?php print __('toggle all');?> </a>
                             <select class="submenu-select-dropdown" name="action">
                             <select class="submenu-select-dropdown" name="action">
                                 <option value=""><?php print __('apply to selected');?></option>
                                 <option value=""><?php print __('apply to selected');?></option>
@@ -35,7 +35,7 @@
                 <tr class="data-row">
                 <tr class="data-row">
                     <td class="data-dotted">
                     <td class="data-dotted">
                         <table class="data-col1">
                         <table class="data-col1">
-                            <tr><td><input type="checkbox" class="ch-toggle" name="exclusion[]" value="<?php echo $key ?>" ></td></tr>
+                            <tr><td><input type="checkbox" class="ch-toggle" name="system[]" value="<?php echo $key ?>" ></td></tr>
                         </table>
                         </table>
                     </td>
                     </td>
                     <td class="data-dotted" width="830px">
                     <td class="data-dotted" width="830px">
@@ -43,9 +43,9 @@
                             <span class="do_delete">
                             <span class="do_delete">
                                 <img src="/images/delete.png" width="7px" height="7px">
                                 <img src="/images/delete.png" width="7px" height="7px">
                                 <?php print __('delete');?> 
                                 <?php print __('delete');?> 
-                                <input type="hidden" name="delete_url" value="/delete/backup/exclusion/?excl=<?php echo "$key" ?>" />
+                                <input type="hidden" name="delete_url" value="/delete/backup/exclusion/?system=<?php echo "$key" ?>" />
                                 <div id="delete_dialog_<?php echo $i ?>" class="confirmation-text-delete hidden" title="<?php print __('Confirmation');?>">
                                 <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>
+                                    <p class="counter-value"><?php print __('DELETE_EXCLUSION_CONFIRMATION',$key);?></p>
                                 </div>
                                 </div>
                             </span>
                             </span>
                         </a>
                         </a>