[! use strict; use Proxmox::Form; use Proxmox::Utils; use Proxmox::Config::System; use Proxmox::ConfigServer; use Proxmox::License; !] [- my $system_cfg = $fdat{__system_config}; my $lic = $system_cfg->{license}; if (my $msg = $lic->no_backup()) { my $out = "

" . __("Unsupported feature!") . "


"; $out .= "

$msg

"; print OUT $out; return; } my $frm = Proxmox::Form->new (\%fdat); my $conn = Proxmox::ConfigClient::connect (); $frm->add_element("section_factory", "hsection", undef, __("Factory Defaults")); $frm->add_element(__("Reset"), "link", "?action=resetdb", __("Rule Database")); $frm->add_element("section_restore", "section", undef, __("Restore")); $frm->add_element('restore_file', "file", '', __('Restore Backup'), ''); $frm->add_element('restore_mode', "dropdown", "", __("Selection"), [[0, __('Everything')], [1, __('System Configuration')], [2, __('Rule Database')]]); if ($udat{action}) { if ($udat{AM} eq 'w') { if ($udat{action} eq 'resetdb') { $conn->reset_ruledb (); } else { $udat{popup_error} = Proxmox::Utils::msg ('nowr'); } } else { $udat{popup_error} = Proxmox::Utils::msg ('nowr'); } } if ($frm->submit==1) { if ($udat{AM} eq 'w') { if ($fdat{restore_file} !~ m/^\s*$/) { my $tmpfn = "/tmp/tmp_$$" . '_' . time . ".bin"; eval { my $buffer = ""; open FILE, "> $tmpfn" || die "open failed"; print FILE $buffer while read($fdat{restore_file}, $buffer, 32768); close FILE; $conn->proxmox_restore ($tmpfn, $fdat{restore_mode}); eval { $conn->service_cmd ('apache', 'restart'); }; }; unlink $tmpfn; if ($@) { $udat{popup_error} = $@; } else { if ($fdat{restore_mode} != 2) { my $ref = "reboot.htm?action=reboot"; $frm->add_element('error', "html", sprintf (__("Restore successful.") . " " . __("Please reboot the server."), $ref), '', ''); } else { $frm->add_element('error', "html", __("Restore successful.")); } } } } else { $udat{popup_error} = Proxmox::Utils::msg ('nowr'); } } print OUT $frm->out_form; -]