File: save_afile.cgi

package info (click to toggle)
webmin-virtual-server 2.50-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,608 kB
  • ctags: 392
  • sloc: perl: 15,687; makefile: 95; sh: 8
file content (25 lines) | stat: -rwxr-xr-x 695 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/local/bin/perl
# save_afile.cgi
# Save an addresses file

require './virtual-server-lib.pl';
&ReadParseMime();
$d = &get_domain($in{'dom'});
&can_edit_domain($d) || &error($text{'aliases_ecannot'});
$config{'edit_afiles'} || &master_admin() ||
	&error($text{'afile_ecannot'});

&switch_to_domain_user($d);
$in{'text'} =~ s/\r//g;
$in{'text'} =~ s/\n*$/\n/;
&lock_file($in{'file'});
open(FILE, ">$in{'file'}") ||
	&error(&text('afile_ewrite', $in{'file'}, $dom->{'user'}, $!));
print FILE $in{'text'};
close(FILE);
&unlock_file($in{'file'});
&webmin_log("save", "afile", $in{'file'});

$what = $in{'alias'} ? 'alias' : 'user';
&redirect("edit_$what.cgi?$what=$in{$what}&dom=$in{'dom'}");