]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/backup.cgi
5 # This code is distributed under the terms of the GPL
10 # enable only the following on debugging purpose
12 use CGI
::Carp
'fatalsToBrowser';
15 require '/var/ipfire/general-functions.pl';
16 require "${General::swroot}/lang.pl";
17 require "${General::swroot}/header.pl";
20 my %mainsettings = ();
24 my $errormessage = "";
25 my @backups = `cd /srv/web/ipfire/html/backup && ls *.ipf`;
29 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
30 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
32 $cgiparams{'ACTION'} = '';
33 $cgiparams{'FILE'} = '';
34 $cgiparams{'UPLOAD'} = '';
35 $cgiparams{'BACKUPLOGS'} = '';
36 &Header
::getcgihash
(\
%cgiparams);
38 ############################################################################################################################
39 ######################################## Scanne Verzeichnisse nach Mp3 Dateien #############################################
41 if ( $cgiparams{'ACTION'} eq "backup" )
43 if ( $cgiparams{'BACKUPLOGS'} eq "include" ){system("/usr/local/bin/backupctrl include");}
44 else {system("/usr/local/bin/backupctrl exclude");}
46 elsif ( $cgiparams{'ACTION'} eq "download" )
48 open(DLFILE
, "</srv/web/ipfire/html/backup/$cgiparams{'FILE'}") or die "Unable to open $cgiparams{'FILE'}: $!";
49 my @fileholder = <DLFILE
>;
50 print "Content-Type:application/x-download\n";
51 print "Content-Disposition:attachment;filename=$cgiparams{'FILE'}\n\n";
55 elsif ( $cgiparams{'ACTION'} eq "restore" )
57 my $upload = $a->param("UPLOAD");
58 open UPLOADFILE
, ">/tmp/restore.ipf";
64 system("/usr/local/bin/backupctrl restore");
67 ############################################################################################################################
68 ########################################### rekursiv nach neuen Mp3s Scannen ##############################################รค
70 &Header
::showhttpheaders
();
71 &Header
::openpage
($Lang::tr
{'backup'}, 1, "");
72 &Header
::openbigbox
('100%', 'left', '', $errormessage);
74 if ( $message ne "" ){
75 &Header
::openbox
('100%','left',$Lang::tr
{'error messages'});
76 print "<font color='red'>$message</font>\n";
80 &Header
::openbox
('100%', 'center', $Lang::tr
{'backup'});
83 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
84 <table width='95%' cellspacing='0'>
85 <tr><td align='left' width='40%'>$Lang::tr{'logs'}</td><td align='left'>include Logfiles <input type='radio' name='BACKUPLOGS' value='include'/>/
86 <input type='radio' name='BACKUPLOGS' value='exclude' checked='checked'/> exclude Logfiles</td></tr>
87 <tr><td align='center' colspan='2'><input type='hidden' name='ACTION' value='backup' />
88 <input type='image' alt='$Lang::tr{'Scan for Files'}' title='$Lang::tr{'Scan for Files'}' src='/images/document-save.png' /></td></tr>
95 &Header
::openbox
('100%', 'center', $Lang::tr
{'backups'});
98 <table width='95%' cellspacing='0'>
103 my $Datei = "/srv/web/ipfire/html/backup/".$_;
104 my @Info = stat($Datei);
105 my $Size = $Info[7] / 1024;
106 $Size = sprintf("%02d", $Size);
107 print "<tr><td align='left'><form method='post' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'backup from'} $_ $Lang::tr{'size'} $Size KB <input type='hidden' name='ACTION' value='download' /><input type='hidden' name='FILE' value='$_' /><input type='image' src='/images/package-x-generic.png' /></form></td></tr>";
115 &Header
::openbox
('100%', 'center', $Lang::tr
{'restore'});
118 <table width='95%' cellspacing='0'>
119 <tr><td align='left'><form method='post' enctype='multipart/form-data' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'backup'}</td><td align='left'><input type="file" size='50' name="UPLOAD" /><input type='submit' name='ACTION' value='restore' /></form></td></tr>
124 &Header
::closebigbox
();
125 &Header
::closepage
();