]>
Commit | Line | Data |
---|---|---|
cf29614f | 1 | #!/usr/bin/perl |
70df8302 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
cf29614f CS |
21 | |
22 | use strict; | |
23 | # enable only the following on debugging purpose | |
cb5e9c6c CS |
24 | #use warnings; |
25 | #use CGI::Carp 'fatalsToBrowser'; | |
8e8bbd9d | 26 | use File::Copy; |
cf29614f CS |
27 | |
28 | require '/var/ipfire/general-functions.pl'; | |
29 | require "${General::swroot}/lang.pl"; | |
30 | require "${General::swroot}/header.pl"; | |
31 | ||
32 | my %color = (); | |
33 | my %mainsettings = (); | |
8e8bbd9d | 34 | my %cgiparams=(); |
cf29614f CS |
35 | my %checked = (); |
36 | my $message = ""; | |
37 | my $errormessage = ""; | |
8c384f97 | 38 | my @backups = `cd /var/ipfire/backup/ && ls *.ipf 2>/dev/null`; |
cf29614f | 39 | |
8e8bbd9d | 40 | $a = new CGI; |
cf29614f CS |
41 | |
42 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
43 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
44 | ||
8e8bbd9d CS |
45 | $cgiparams{'ACTION'} = ''; |
46 | $cgiparams{'FILE'} = ''; | |
47 | $cgiparams{'UPLOAD'} = ''; | |
48 | $cgiparams{'BACKUPLOGS'} = ''; | |
69addbb8 | 49 | |
8e8bbd9d | 50 | &Header::getcgihash(\%cgiparams); |
cf29614f CS |
51 | |
52 | ############################################################################################################################ | |
69addbb8 | 53 | ############################################## System calls ohne Http Header ############################################### |
cf29614f | 54 | |
69addbb8 CS |
55 | |
56 | if ( $cgiparams{'ACTION'} eq "download" ) | |
8e8bbd9d | 57 | { |
69addbb8 | 58 | open(DLFILE, "</var/ipfire/backup/$cgiparams{'FILE'}") or die "Unable to open $cgiparams{'FILE'}: $!"; |
8e8bbd9d CS |
59 | my @fileholder = <DLFILE>; |
60 | print "Content-Type:application/x-download\n"; | |
61 | print "Content-Disposition:attachment;filename=$cgiparams{'FILE'}\n\n"; | |
62 | print @fileholder; | |
63 | exit (0); | |
64 | } | |
65 | elsif ( $cgiparams{'ACTION'} eq "restore" ) | |
66 | { | |
67 | my $upload = $a->param("UPLOAD"); | |
68 | open UPLOADFILE, ">/tmp/restore.ipf"; | |
69 | binmode $upload; | |
70 | while ( <$upload> ) { | |
71 | print UPLOADFILE; | |
72 | } | |
73 | close UPLOADFILE; | |
8c384f97 | 74 | system("/usr/local/bin/backupctrl restore >/dev/null 2>&1"); |
8e8bbd9d | 75 | } |
cf29614f | 76 | |
8e8bbd9d | 77 | &Header::showhttpheaders(); |
69addbb8 CS |
78 | |
79 | sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();} | |
80 | ||
8e8bbd9d CS |
81 | &Header::openpage($Lang::tr{'backup'}, 1, ""); |
82 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
83 | ||
69addbb8 CS |
84 | ############################################################################################################################ |
85 | ################################################### Default System calls ################################################### | |
86 | ||
87 | if ( $cgiparams{'ACTION'} eq "backup" ) | |
88 | { | |
8c384f97 CS |
89 | if ( $cgiparams{'BACKUPLOGS'} eq "include" ){system("/usr/local/bin/backupctrl include >/dev/null 2>&1");} |
90 | else {system("/usr/local/bin/backupctrl exclude >/dev/null 2>&1");} | |
69addbb8 CS |
91 | refreshpage(); |
92 | } | |
93 | elsif ( $cgiparams{'ACTION'} eq "delete" ) | |
94 | { | |
8c384f97 | 95 | system("/usr/local/bin/backupctrl $cgiparams{'FILE'} >/dev/null 2>&1"); |
69addbb8 CS |
96 | refreshpage(); |
97 | } | |
98 | ||
99 | ############################################################################################################################ | |
100 | ########################################### rekursiv nach neuen Mp3s Scannen ##############################################รค | |
101 | ||
8e8bbd9d CS |
102 | if ( $message ne "" ){ |
103 | &Header::openbox('100%','left',$Lang::tr{'error messages'}); | |
104 | print "<font color='red'>$message</font>\n"; | |
105 | &Header::closebox(); | |
106 | } | |
cf29614f CS |
107 | |
108 | &Header::openbox('100%', 'center', $Lang::tr{'backup'}); | |
109 | ||
110 | print <<END | |
111 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
112 | <table width='95%' cellspacing='0'> | |
8e8bbd9d CS |
113 | <tr><td align='left' width='40%'>$Lang::tr{'logs'}</td><td align='left'>include Logfiles <input type='radio' name='BACKUPLOGS' value='include'/>/ |
114 | <input type='radio' name='BACKUPLOGS' value='exclude' checked='checked'/> exclude Logfiles</td></tr> | |
cf29614f | 115 | <tr><td align='center' colspan='2'><input type='hidden' name='ACTION' value='backup' /> |
8e8bbd9d | 116 | <input type='image' alt='$Lang::tr{'Scan for Files'}' title='$Lang::tr{'Scan for Files'}' src='/images/document-save.png' /></td></tr> |
cf29614f CS |
117 | </table> |
118 | </form> | |
119 | END | |
120 | ; | |
121 | &Header::closebox(); | |
122 | ||
123 | &Header::openbox('100%', 'center', $Lang::tr{'backups'}); | |
124 | ||
125 | print <<END | |
cf29614f CS |
126 | <table width='95%' cellspacing='0'> |
127 | END | |
128 | ; | |
129 | foreach (@backups){ | |
8e8bbd9d | 130 | chomp($_); |
69addbb8 | 131 | my $Datei = "/var/ipfire/backup/".$_; |
8e8bbd9d CS |
132 | my @Info = stat($Datei); |
133 | my $Size = $Info[7] / 1024; | |
134 | $Size = sprintf("%02d", $Size); | |
69addbb8 CS |
135 | 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>"; |
136 | 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>"; | |
cf29614f CS |
137 | } |
138 | print <<END | |
139 | </table> | |
8e8bbd9d CS |
140 | END |
141 | ; | |
142 | &Header::closebox(); | |
143 | ||
144 | &Header::openbox('100%', 'center', $Lang::tr{'restore'}); | |
145 | ||
146 | print <<END | |
147 | <table width='95%' cellspacing='0'> | |
69addbb8 | 148 | <tr><td align='left'>$Lang::tr{'backup'}</td><td align='left'><form method='post' enctype='multipart/form-data' action='$ENV{'SCRIPT_NAME'}'><input type="file" size='50' name="UPLOAD" /><input type='hidden' name='ACTION' value='restore' /><input type='hidden' name='FILE' value='$_' /><input type='image' alt='$Lang::tr{'restore'}' title='$Lang::tr{'restore'}' src='/images/media-floppy.png' /></form></td></tr> |
8e8bbd9d | 149 | </table> |
cf29614f CS |
150 | END |
151 | ; | |
152 | &Header::closebox(); | |
153 | &Header::closebigbox(); | |
154 | &Header::closepage(); |