]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
added option to download and delete iso backup
authorDaniel Glanzmann <dg@ipfire.org>
Wed, 1 Oct 2008 13:43:22 +0000 (15:43 +0200)
committerDaniel Glanzmann <dg@ipfire.org>
Wed, 1 Oct 2008 13:43:22 +0000 (15:43 +0200)
config/backup/backup.pl
html/cgi-bin/backup.cgi

index 5633569fda217449790de58d1d0f6ee68577f9a0..e67a958f471d01f41b8e675e43fe0b57c8f69c2c 100644 (file)
@@ -76,6 +76,9 @@ elsif ($ARGV[0] eq 'addonbackup') {
 elsif ($ARGV[0] =~ /ipf$/ ) {
   system("rm /var/ipfire/backup/$ARGV[0]");
 }
+elsif ($ARGV[0] =~ /iso$/ ) {
+  system("rm /var/tmp/backupiso/$ARGV[0]");
+}
 elsif ($ARGV[0] eq '') {
  printf "No argument given, please use <include><exclude><cli>\n"
 }
index 0592ef82cdbd63204b98153d765d0e999f2fd23c..eacfd789b297b0496dafce3958bb98c00edb8381 100644 (file)
@@ -56,6 +56,8 @@ system("/usr/local/bin/backupctrl makedirs >/dev/null 2>&1 ") unless ( -e '/var/
 ############################################################################################################################
 ############################################## System calls ohne Http Header ###############################################
 
+# Replace slashes from filename
+$cgiparams{'FILE'} =~ s/\///;
 
 if ( $cgiparams{'ACTION'} eq "download" )
 {
@@ -66,6 +68,15 @@ if ( $cgiparams{'ACTION'} eq "download" )
                print @fileholder;
                exit (0);
 }
+if ( $cgiparams{'ACTION'} eq "downloadiso" )
+{
+               open(DLFILE, "</var/tmp/backupiso/$cgiparams{'FILE'}") or die "Unable to open $cgiparams{'FILE'}: $!";
+               my @fileholder = <DLFILE>;
+               print "Content-Type:application/x-download\n";
+               print "Content-Disposition:attachment;filename=$cgiparams{'FILE'}\n\n";
+               print @fileholder;
+               exit (0);
+}
 if ( $cgiparams{'ACTION'} eq "downloadaddon" )
 {
                open(DLFILE, "</var/ipfire/backup/addons/backup/$cgiparams{'FILE'}") or die "Unable to open $cgiparams{'FILE'}: $!";
@@ -140,6 +151,7 @@ if ( $message ne "" ){
 }
 
 my @backups = `cd /var/ipfire/backup/ && ls *.ipf 2>/dev/null`;
+my @backupisos = `cd /var/tmp/backupiso/ && ls *.iso 2>/dev/null`;
 
 &Header::openbox('100%', 'center', $Lang::tr{'backup'});
 
@@ -182,6 +194,15 @@ $Size = sprintf("%02d", $Size);
 print "<tr><td align='center'>$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size KB</td><td width='5'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='download' /><input type='hidden' name='FILE' value='$_' /><input type='image' alt='$Lang::tr{'download'}' title='$Lang::tr{'download'}' src='/images/package-x-generic.png' /></form></td>";
 print "<td width='5'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='delete' /><input type='hidden' name='FILE' value='$_' /><input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' /></form></td></tr>";
 }
+foreach (@backupisos){
+chomp($_);
+my $Datei = "/var/tmp/backupiso/".$_;
+my @Info = stat($Datei);
+my $Size = $Info[7] / 1024;
+$Size = sprintf("%02d", $Size);
+print "<tr><td align='center'>$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size KB</td><td width='5'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='downloadiso' /><input type='hidden' name='FILE' value='$_' /><input type='image' alt='$Lang::tr{'download'}' title='$Lang::tr{'download'}' src='/images/package-x-generic.png' /></form></td>";
+print "<td width='5'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='delete' /><input type='hidden' name='FILE' value='$_' /><input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' /></form></td></tr>";
+}
 print <<END
 </table>
 END