]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - html/cgi-bin/backup.cgi
Die beiden Control Dateien angepasst
[people/teissler/ipfire-2.x.git] / html / cgi-bin / backup.cgi
CommitLineData
cf29614f
CS
1#!/usr/bin/perl
2#
3# IPFire CGIs
4#
5# This code is distributed under the terms of the GPL
6#
7# (c) The IPFire Team
8
9use strict;
10# enable only the following on debugging purpose
11use warnings;
12use CGI::Carp 'fatalsToBrowser';
8e8bbd9d 13use File::Copy;
cf29614f
CS
14
15require '/var/ipfire/general-functions.pl';
16require "${General::swroot}/lang.pl";
17require "${General::swroot}/header.pl";
18
19my %color = ();
20my %mainsettings = ();
8e8bbd9d 21my %cgiparams=();
cf29614f
CS
22my %checked = ();
23my $message = "";
24my $errormessage = "";
8e8bbd9d 25my @backups = `cd /srv/web/ipfire/html/backup && ls *.ipf`;
cf29614f 26
8e8bbd9d 27$a = new CGI;
cf29614f
CS
28
29&General::readhash("${General::swroot}/main/settings", \%mainsettings);
30&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
31
8e8bbd9d
CS
32$cgiparams{'ACTION'} = '';
33$cgiparams{'FILE'} = '';
34$cgiparams{'UPLOAD'} = '';
35$cgiparams{'BACKUPLOGS'} = '';
36&Header::getcgihash(\%cgiparams);
cf29614f
CS
37
38############################################################################################################################
39######################################## Scanne Verzeichnisse nach Mp3 Dateien #############################################
40
8e8bbd9d 41if ( $cgiparams{'ACTION'} eq "backup" )
cf29614f 42{
8e8bbd9d 43 if ( $cgiparams{'BACKUPLOGS'} eq "include" ){system("/usr/local/bin/backupctrl include");}
cf29614f
CS
44 else {system("/usr/local/bin/backupctrl exclude");}
45}
8e8bbd9d
CS
46elsif ( $cgiparams{'ACTION'} eq "download" )
47{
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";
52 print @fileholder;
53 exit (0);
54}
55elsif ( $cgiparams{'ACTION'} eq "restore" )
56{
57 my $upload = $a->param("UPLOAD");
58 open UPLOADFILE, ">/tmp/restore.ipf";
59 binmode $upload;
60 while ( <$upload> ) {
61 print UPLOADFILE;
62 }
63 close UPLOADFILE;
64 system("/usr/local/bin/backupctrl restore");
65}
cf29614f
CS
66
67############################################################################################################################
68########################################### rekursiv nach neuen Mp3s Scannen ##############################################รค
69
8e8bbd9d
CS
70&Header::showhttpheaders();
71&Header::openpage($Lang::tr{'backup'}, 1, "");
72&Header::openbigbox('100%', 'left', '', $errormessage);
73
74if ( $message ne "" ){
75 &Header::openbox('100%','left',$Lang::tr{'error messages'});
76 print "<font color='red'>$message</font>\n";
77 &Header::closebox();
78}
cf29614f
CS
79
80&Header::openbox('100%', 'center', $Lang::tr{'backup'});
81
82print <<END
83<form method='post' action='$ENV{'SCRIPT_NAME'}'>
84<table width='95%' cellspacing='0'>
8e8bbd9d
CS
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>
cf29614f 87<tr><td align='center' colspan='2'><input type='hidden' name='ACTION' value='backup' />
8e8bbd9d 88 <input type='image' alt='$Lang::tr{'Scan for Files'}' title='$Lang::tr{'Scan for Files'}' src='/images/document-save.png' /></td></tr>
cf29614f
CS
89</table>
90</form>
91END
92;
93&Header::closebox();
94
95&Header::openbox('100%', 'center', $Lang::tr{'backups'});
96
97print <<END
cf29614f
CS
98<table width='95%' cellspacing='0'>
99END
100;
101foreach (@backups){
8e8bbd9d
CS
102chomp($_);
103my $Datei = "/srv/web/ipfire/html/backup/".$_;
104my @Info = stat($Datei);
105my $Size = $Info[7] / 1024;
106$Size = sprintf("%02d", $Size);
107print "<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>";
cf29614f
CS
108}
109print <<END
110</table>
8e8bbd9d
CS
111END
112;
113&Header::closebox();
114
115&Header::openbox('100%', 'center', $Lang::tr{'restore'});
116
117print <<END
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>
120</table>
cf29614f
CS
121END
122;
123&Header::closebox();
124&Header::closebigbox();
125&Header::closepage();