4 require './itsecur-lib.pl';
5 &can_edit_error("backup");
6 &error_setup($text{'backup_err'});
10 if ($in{'dest_mode'} == 0) {
13 elsif ($in{'dest_mode'} == 1) {
14 $orig_dest = $in{'dest'};
16 $in{'dest'} .= "/firewall.zip";
18 $in{'dest'} =~ /^(.*)\// || &error($text{'backup_edest'});
19 -d $1 || &error($text{'backup_edestdir'});
21 $done = &text('backup_done1', $file);
23 elsif ($in{'dest_mode'} == 2) {
24 gethostbyname($in{'ftphost'}) || &error($text{'backup_eftphost'});
25 $in{'ftpfile'} =~ /^\/\S+/ || &error($text{'backup_eftpfile'});
26 $in{'ftpuser'} =~ /\S/ || &error($text{'backup_eftpuser'});
27 $file = "ftp://$in{'ftpuser'}:$in{'ftppass'}\@$in{'ftphost'}$in{'ftpfile'}";
28 $done = &text('backup_done2', $in{'ftphost'}, $in{'ftpfile'});
30 elsif ($in{'dest_mode'} == 3) {
31 $in{'email'} =~ /^\S+\@\S+$/ || &error($text{'backup_eemail'});
32 $file = "mailto:$in{'email'}";
33 $done = &text('backup_done3', $in{'email'});
35 if (!$in{'pass_def'}) {
36 $in{'pass'} || &error($text{'backup_epass'});
38 @what = split(/\0/, $in{'what'});
39 @what || &error($text{'backup_ewhat'});
43 $err = &backup_firewall(\@what, $file, $in{'pass_def'} ? undef
45 &error($err) if ($err);
49 $config{'backup_dest'} = $in{'dest_mode'} == 0 ? undef : $file;
50 $config{'backup_what'} = join(" ", @what);
51 $config{'backup_pass'} = $in{'pass_def'} ? undef : $in{'pass'};
52 &write_file($module_config_file, \%config);
55 # Tell the user about the cron job
56 &header($text{'backup_title'}, "",
57 undef, undef, undef, undef, &apply_button());
60 print "<p>",&text('backup_donesched'),"<p>\n";
63 &footer("", $text{'index_return'});
65 elsif ($in{'dest_mode'} == 0) {
67 print "Content-type: application/octet-stream\n\n";
74 &remote_webmin_log("backup");
78 &header($text{'backup_title'}, "",
79 undef, undef, undef, undef, &apply_button());
82 print "<p>$done<p>\n";
85 &footer("", $text{'index_return'});
86 &remote_webmin_log("backup", undef, $in{'dest'});
90 $job = &find_backup_job();
92 &cron::delete_cron_job($job);
94 if (!$in{'sched_def'}) {
95 $job = { 'special' => $in{'sched'},
97 'command' => $cron_cmd,
99 &cron::create_wrapper($cron_cmd, $module_name, "backup.pl");
100 &cron::create_cron_job($job);