From patchwork Wed May 26 15:39:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthias Fischer X-Patchwork-Id: 4377 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4Fqw9r4nQpz3wbs for ; Wed, 26 May 2021 15:39:44 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Fqw9q3Y5Zz13x; Wed, 26 May 2021 15:39:43 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Fqw9q2HHmz2ydc; Wed, 26 May 2021 15:39:43 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Fqw9p08yKz2xGT for ; Wed, 26 May 2021 15:39:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4Fqw9n3Q3Zz9L for ; Wed, 26 May 2021 15:39:41 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1622043581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QWkCoSb9HbTU6DDvDBfpnZXIp4JkNiFSKdkdssFN1ms=; b=EbZ3veIj9I+674JMBlBaLuhkwd7NiuVbcgdd+gVJSu7jmZjvWlr3dkEHLPDycLBTVfzy3e NhIZ14IOrGB0yYAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1622043581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QWkCoSb9HbTU6DDvDBfpnZXIp4JkNiFSKdkdssFN1ms=; b=UrOCYZYyIj13wm8cpx0H91EOSeOwpVhaY0cF5AlKruddH58b44yoLOxXKwCKXr1lN1xTSR JyAh+Ab5UC6KAInLC/ttLiPPa/5yA4hqnDCTrk3J6vFLvcTgyUc7kReGDj8coPVU6aWdhm 1sB0XOrJr5MUiKUKIC8Gfe/NpQXrFeT3uSpxJmDBZg32jc7GLPaaywsWOuPrppetdIHFAx BEtXCiWKuayG6RF1gLGt1qxLHxOMhVbtwbRSXsL32teKnGE3w00ybquiXta2qgUlms05KZ xonIybKu7vMkyAsHbv/iDRqrk6yoVPP8+K3WfX2r4963DIvez9UFyWoiiFkQbg== From: Matthias Fischer To: development@lists.ipfire.org Subject: [PATCH] backup.cgi: Table layout - onclick confirm Date: Wed, 26 May 2021 17:39:37 +0200 Message-Id: <20210526153937.2720-1-matthias.fischer@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This is just a diff for testing people... ;-) Changelog in short: - Added tables - Cleaned up the code a bit, some if-queries were unnessecary (if ($cgiparams{'ACTION'} eq...) - Deleted unused lang strings (downloadiso, downloadaddon, logs) - Separated the ISO files from the IPF files for better overview. - Added query for deleting a backup file (onclick=\"return confirm...) ToDo: Change table layout to alternating rows. If "someone" has some hints how to do this, I'll be grateful. Signed-off-by: Matthias Fischer --- html/cgi-bin/backup.cgi | 218 +++++++++++++++++++++++++++++----------- langs/de/cgi-bin/de.pl | 8 +- langs/en/cgi-bin/en.pl | 8 +- langs/es/cgi-bin/es.pl | 1 - langs/fr/cgi-bin/fr.pl | 1 - langs/it/cgi-bin/it.pl | 1 - langs/nl/cgi-bin/nl.pl | 1 - langs/pl/cgi-bin/pl.pl | 1 - langs/ru/cgi-bin/ru.pl | 1 - langs/tr/cgi-bin/tr.pl | 1 - 10 files changed, 174 insertions(+), 67 deletions(-) diff --git a/html/cgi-bin/backup.cgi b/html/cgi-bin/backup.cgi index 683f8add4..04473428c 100644 --- a/html/cgi-bin/backup.cgi +++ b/html/cgi-bin/backup.cgi @@ -32,7 +32,7 @@ require "${General::swroot}/header.pl"; my %color = (); my %mainsettings = (); -my %cgiparams=(); +my %cgiparams = (); my %checked = (); my $message = ""; my $errormessage = ""; @@ -59,25 +59,13 @@ system("/usr/local/bin/backupctrl makedirs >/dev/null 2>&1 ") unless ( -e '/var/ ############################################################################################################################ ############################################## System calls ohne Http Header ############################################### -if ($cgiparams{'ACTION'} eq "download") { +if ($cgiparams{'ACTION'} eq "$Lang::tr{'download'}") { my $file = &sanitise_file($cgiparams{'FILE'}); exit(1) unless defined($file); &deliver_file($file); exit(0); -} elsif ($cgiparams{'ACTION'} eq "downloadiso") { - my $file = &sanitise_file($cgiparams{'FILE'}); - exit(1) unless defined($file); - - &deliver_file($file); - exit(0); -} elsif ($cgiparams{'ACTION'} eq "downloadaddon") { - my $file = &sanitise_file($cgiparams{'FILE'}); - exit(1) unless defined($file); - - &deliver_file($file); - exit(0); -} elsif ( $cgiparams{'ACTION'} eq "restore") { +} elsif ( $cgiparams{'ACTION'} eq "$Lang::tr{'restore'}") { my $upload = $a->param("UPLOAD"); open UPLOADFILE, ">/tmp/restore.ipf"; binmode $upload; @@ -87,7 +75,7 @@ if ($cgiparams{'ACTION'} eq "download") { close UPLOADFILE; system("/usr/local/bin/backupctrl restore >/dev/null 2>&1"); } -elsif ( $cgiparams{'ACTION'} eq "restoreaddon" ) +elsif ( $cgiparams{'ACTION'} eq "$Lang::tr{'restoreaddon'}" ) { chomp($cgiparams{'UPLOAD'}); # we need to fix cause IE7 gives the full path and FF only the filename @@ -112,7 +100,7 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "/dev/null 2>&1"); @@ -122,7 +110,7 @@ if ( $cgiparams{'ACTION'} eq "backup" ) system("/usr/local/bin/backupctrl iso >/dev/null 2>&1"); } } -if ( $cgiparams{'ACTION'} eq "addonbackup" ) +if ( $cgiparams{'ACTION'} eq "$Lang::tr{'addonbackup'}" ) { # Exit if there is any dots or slashes in the addon name exit(1) if ($cgiparams{'ADDON'} =~ /(\.|\/)/); @@ -132,7 +120,7 @@ if ( $cgiparams{'ACTION'} eq "addonbackup" ) system("/usr/local/bin/backupctrl addonbackup $cgiparams{'ADDON'} >/dev/null 2>&1"); } -elsif ( $cgiparams{'ACTION'} eq "delete" ) +elsif ( $cgiparams{'ACTION'} eq "$Lang::tr{'delete'}" ) { my $file = &sanitise_file($cgiparams{'FILE'}); exit(1) unless defined($file); @@ -157,13 +145,13 @@ if ( -e "/var/tmp/backupiso/" ){ @backupisos = `cd /var/tmp/backupiso/ && ls *.iso 2>/dev/null`; } -&Header::openbox('100%', 'center', ); +&Header::openbox('100%', 'center', $Lang::tr{'backup config'}); print < - +
$Lang::tr{'logs'} $Lang::tr{'include logfiles'}
$Lang::tr{'exclude logfiles'}
@@ -177,8 +165,8 @@ print <
- - + +
@@ -189,10 +177,17 @@ END ############################################################################################################################ ############################################ Backups des Systems downloaden ################################################ -&Header::openbox('100%', 'center', $Lang::tr{'backups'}); +&Header::openbox('100%', 'center', $Lang::tr{'backups data'}); print < + + + + + + + + END ; foreach (@backups){ @@ -202,9 +197,44 @@ my $Datei = "/var/ipfire/backup/".$_; my @Info = stat($Datei); my $Size = $Info[7] / 1024 / 1024; $Size = sprintf("%0.2f", $Size); -print ""; -print ""; + +print " + + +"; + +print ""; } + +print < +END +; +&Header::closebox(); + +&Header::openbox('100%', 'center', $Lang::tr{'backups iso'}); + +print < + + + + + + + +END +; + foreach (@backupisos){ if ( $_ !~ /iso$/){next;} chomp($_); @@ -212,8 +242,22 @@ my $Datei = "/var/tmp/backupiso/".$_; my @Info = stat($Datei); my $Size = $Info[7] / 1024 / 1024; $Size = sprintf("%0.2f", $Size); -print ""; -print ""; + +print " + + +"; + +print ""; } print < @@ -235,7 +279,19 @@ foreach (@addons){ $addons{$addon}=''; } -print "
$Lang::tr{'filename'}$Lang::tr{'size'}$Lang::tr{'action'}
$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size MB
$_$Size MB
+ + + +
+
+ + + +
$Lang::tr{'filename'}$Lang::tr{'size'}$Lang::tr{'action'}
$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size MB
$_$Size MB
+ + + +
+
+ + + +
"; +print < + + + + + + + +END +; + foreach (@addonincluds){ chomp($_); delete $addons{$_}; @@ -245,69 +301,93 @@ my $Size = $Info[7] / 1024; if ( -e $Datei ){ if ($Size < 1) { - $Size = sprintf("%.2f", $Size); - print ""; - } else { - $Size = sprintf("%2d", $Size); - print ""; + $Size = sprintf("%.2f", $Size); +print " + + + "; + - } + } else { + $Size = sprintf("%2d", $Size); +print " + + + "; + + } print < + + - END ; } -else{ - print ""; + +else { + + print " + + + + "; } + print <
- + - + -
+ + END ; + } + foreach (keys(%addons)){ chomp($_); my $Datei = "/var/ipfire/backup/addons/backup/".$_.".ipf"; my @Info = stat($Datei); my $Size = $Info[7] / 1024; $Size = sprintf("%2d", $Size); -print ""; + +print " + + + "; + print < + - - + END ; } @@ -322,9 +402,31 @@ print "
$Lang::tr{'name'}$Lang::tr{'date'}$Lang::tr{'size'}$Lang::tr{'action'}
$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size KB $Lang::tr{'date'} ".localtime($Info[9])."
$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size KB $Lang::tr{'date'} ".localtime($Info[9])."
$_".localtime($Info[9])."$Size KB
$_".localtime($Info[9])."$Size KB
- + - +
+
- + - +
$Lang::tr{'backup from'} $_
$_ - - -
$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size KB $Lang::tr{'date'} ".localtime($Info[9])."
$_".localtime($Info[9])."$Size KB
- + - +
+
- + - +
"; print < -
$Lang::tr{'backupwarning'}


-$Lang::tr{'backup'}
-$Lang::tr{'backupaddon'}
+ +
$Lang::tr{'backupwarning'}


+ + + + $Lang::tr{'backup'} + +
+ + + + +
+ + + + $Lang::tr{'backupaddon'} +
+ + + + +
+ + END ; diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 95af3155b..37f0cab8a 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -158,6 +158,7 @@ 'add-route' => 'Zusätzlich zu propagierende Route', 'added from dhcp lease list' => 'hinzugefügt von der DHCP-Zuordnungsliste', 'addon' => 'Add-Ons', +'addonbackup' => 'Sichern', 'addons' => 'Add-Ons', 'admin user password has been changed' => 'Passwort für Benutzer admin wurde geändert.', 'admin users' => 'Liste der Benutzer mit Super User Rechten', @@ -470,8 +471,11 @@ 'backup sets' => 'Datensicherungssätze', 'backup to floppy' => 'Datensicherung auf Diskette', 'backupaddon' => 'Add-On-Sicherung', +'backup config' => 'Konfiguration', 'backupprofile' => 'Falls die Wiederverbindung scheitert, auf dieses Profil umschalten', 'backups' => 'Sicherungen', +'backups data' => 'IPF-Dateien', +'backups iso' => 'ISO-Dateien', 'backupwarning' => 'Spielen Sie zuerst Ihre Hauptsicherung und anschließend die Sicherung(en) der Addon-Konfiguration(en) ein.
Es werden lediglich die gesicherten Konfigurationsdatei(en) der Addons, nicht die installierten Addons wiederhergestellt!
Achten Sie außerdem darauf, dass die Sicherungen ihre originalen Dateinamen behalten.', 'bad characters in' => 'Ungültige Zeichen in ', 'bad characters in script field' => 'Nicht erlaubte Zeichen im Skriptnamen', @@ -735,6 +739,8 @@ 'defaultwarning' => 'ACHTUNG - Ihre Einstellungen gehen hiermit verloren und werden durch die Standarteinstellungen ersetzt.', 'delete' => 'Löschen', 'delete cron' => 'Cronjob löschen', +'delete file' => 'Möchten Sie diese Datei wirklich löschen?', +'delete item' => 'Möchten Sie diesen Eintrag wirklich löschen?', 'delete pc' => 'PC löschen', 'delete share' => 'Freigabe löschen', 'delete user' => 'Benutzer löschen', @@ -1600,7 +1606,6 @@ 'logging' => 'Protokollierung', 'logging server' => 'Protokollierungsserver', 'loginlogout' => 'Login/Logout', -'logs' => 'Protokolldateien', 'loosedirectorychecking' => 'Loose directorychecking', 'low' => 'Niedrig', 'ls_dhcpd' => 'DHCP-Server:', @@ -2136,6 +2141,7 @@ 'restart' => 'Neustart', 'restart ovpn server' => 'OpenVPN-Server neu starten', 'restore' => 'Wiederherstellen', +'restoreaddon' => 'Wiederherstellen (Addon)', 'restore defaults' => 'Voreinstellungen wiederherstellen', 'restore hardware settings' => 'Hardwareeinstellungen wiederherstellen', 'restore settings' => 'Einstellungen wiederherstellen', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index d86705772..a126b11ef 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -155,6 +155,7 @@ 'add xtaccess' => 'Add External Access', 'add-route' => 'Additional push route', 'added from dhcp lease list' => 'Added from DHCP lease list', +'addonbackup' => 'Backup', 'addons' => 'Addons', 'admin user password has been changed' => 'Admin user password has been changed.', 'admin users' => 'User with superuser rights', @@ -459,6 +460,7 @@ 'backup' => 'Backup', 'backup archive' => 'Backup File (.dat)', 'backup clear archive' => 'Clear Backup File (.gz)', +'backup config' => 'Configuration', 'backup config floppy' => 'Backup Configuration - Floppy Disk', 'backup configuration' => 'Backup Configuration:', 'backup erase key' => 'Erase key', @@ -486,6 +488,8 @@ 'backupaddon' => 'Addon Backup', 'backupprofile' => 'In case reconnection fails, switch to profile', 'backups' => 'backups', +'backups data' => 'IPF-Files', +'backups iso' => 'ISO-Files', 'backupwarning' => 'Import your main backup first and then the backup(s) of the addon configuration(s).
Only the backed up addon configuration file(s) will be restored, not the installed addons!
Also make sure that the backups keep their original file names.', 'bad characters in' => 'Bad characters in ', 'bad characters in script field' => 'Bad characters in script field', @@ -755,6 +759,8 @@ 'delete pc' => 'Delete workstation', 'delete share' => 'Delete share', 'delete user' => 'Delete user', +'delete file' => 'Do you really want to delete this file?', +'delete item' => 'Do you really want to delete this item?', 'demon login script' => 'Demon login script', 'deprecated fs warn' => 'Deprecated filesystem! Newer kernel drop the support. Backup and reformat!', 'description' => 'Description', @@ -1632,7 +1638,6 @@ 'logging' => 'Logging', 'logging server' => 'Logging Server', 'loginlogout' => 'Login/Logout', -'logs' => 'logs', 'loosedirectorychecking' => 'Loosedirectorychecking', 'low' => 'Low', 'ls_dhcpd' => 'DHCP Server:', @@ -2172,6 +2177,7 @@ 'restart' => 'Restart', 'restart ovpn server' => 'Restart OpenVPN server', 'restore' => 'Restore', +'restoreaddon' => 'Restore (Addon)', 'restore defaults' => 'Restore defaults', 'restore hardware settings' => 'Restore hardware settings', 'restore settings' => 'Reset Settings', diff --git a/langs/es/cgi-bin/es.pl b/langs/es/cgi-bin/es.pl index c9a7496bc..fa346233f 100644 --- a/langs/es/cgi-bin/es.pl +++ b/langs/es/cgi-bin/es.pl @@ -1149,7 +1149,6 @@ 'logging' => 'Conectando', 'logging server' => 'Servidor de conexión', 'loginlogout' => 'Login/Logout', -'logs' => 'registros', 'loosedirectorychecking' => 'Chequeo de loosedirectory', 'low' => 'Bajo', 'ls_dhcpd' => 'Servidor DHCP:', diff --git a/langs/fr/cgi-bin/fr.pl b/langs/fr/cgi-bin/fr.pl index 301109477..ea5985315 100644 --- a/langs/fr/cgi-bin/fr.pl +++ b/langs/fr/cgi-bin/fr.pl @@ -1633,7 +1633,6 @@ 'logging' => 'Connexion', 'logging server' => 'Serveur de connexion', 'loginlogout' => 'Connexion/Quitter', -'logs' => 'Journaux', 'loosedirectorychecking' => 'Echec de la vérification du répertoire', 'low' => 'Bas', 'ls_dhcpd' => 'Serveur DHCP :', diff --git a/langs/it/cgi-bin/it.pl b/langs/it/cgi-bin/it.pl index e82ecfd35..711b4bd4a 100644 --- a/langs/it/cgi-bin/it.pl +++ b/langs/it/cgi-bin/it.pl @@ -1408,7 +1408,6 @@ 'logging' => 'Logging', 'logging server' => 'Logging Server', 'loginlogout' => 'Login/Logout', -'logs' => 'Gestione Log', 'loosedirectorychecking' => 'Loosedirectorychecking', 'low' => 'Basso', 'ls_dhcpd' => 'DHCP Server:', diff --git a/langs/nl/cgi-bin/nl.pl b/langs/nl/cgi-bin/nl.pl index 55927839e..aea5e81b5 100644 --- a/langs/nl/cgi-bin/nl.pl +++ b/langs/nl/cgi-bin/nl.pl @@ -1390,7 +1390,6 @@ 'logging' => 'Logging', 'logging server' => 'Loggingserver', 'loginlogout' => 'Login/Logout', -'logs' => 'logs', 'loosedirectorychecking' => 'Loosedirectorychecking', 'low' => 'Laag', 'ls_dhcpd' => 'DHCP Server:', diff --git a/langs/pl/cgi-bin/pl.pl b/langs/pl/cgi-bin/pl.pl index 147db051c..604a834a7 100644 --- a/langs/pl/cgi-bin/pl.pl +++ b/langs/pl/cgi-bin/pl.pl @@ -1094,7 +1094,6 @@ 'logging' => 'Logowanie', 'logging server' => 'Serwer logowania', 'loginlogout' => 'Zalogowanie/wylogowanie', -'logs' => 'logi', 'loosedirectorychecking' => 'Loosedirectorychecking', 'low' => 'Niski', 'ls_dhcpd' => 'Serwer DHCP:', diff --git a/langs/ru/cgi-bin/ru.pl b/langs/ru/cgi-bin/ru.pl index 0d986135d..26ad6c338 100644 --- a/langs/ru/cgi-bin/ru.pl +++ b/langs/ru/cgi-bin/ru.pl @@ -1087,7 +1087,6 @@ 'logging' => 'Logging', 'logging server' => 'Сервер Логов', 'loginlogout' => 'Login/Logout', -'logs' => 'Логи', 'loosedirectorychecking' => 'Loosedirectorychecking', 'low' => 'Low', 'ls_dhcpd' => 'DHCP сервер:', diff --git a/langs/tr/cgi-bin/tr.pl b/langs/tr/cgi-bin/tr.pl index 36c4782d6..233de0995 100644 --- a/langs/tr/cgi-bin/tr.pl +++ b/langs/tr/cgi-bin/tr.pl @@ -1538,7 +1538,6 @@ 'logging' => 'Günlük', 'logging server' => 'Günlük Sunucusu', 'loginlogout' => 'Giriş/Çıkış', -'logs' => 'Günlükler', 'loosedirectorychecking' => 'Serbest Dizin Denetimi', 'low' => 'Düşük', 'ls_dhcpd' => 'DHCP Sunucusu:',