Handle hostnames with upper-case letters
[webmin.git] / majordomo / save_mesg.cgi
1 #!/usr/local/bin/perl
2 # save_mesg.cgi
3 # Save message options
4
5 require './majordomo-lib.pl';
6 &ReadParse();
7 %access = &get_module_acl();
8 &can_edit_list(\%access, $in{'name'}) || &error($text{'edit_ecannot'});
9 $list = &get_list($in{'name'}, &get_config());
10 &lock_file($list->{'config'});
11 $conf = &get_list_config($list->{'config'});
12 &save_opt($conf, $list->{'config'}, "reply_to", \&check_reply);
13 &save_opt($conf, $list->{'config'}, "sender", \&check_sender);
14 &save_opt($conf, $list->{'config'}, "resend_host", \&check_host);
15 &save_opt($conf, $list->{'config'}, "subject_prefix");
16 &save_select($conf, $list->{'config'}, "precedence");
17 &save_choice($conf, $list->{'config'}, "purge_received");
18 &save_opt($conf, $list->{'config'}, "maxlength", \&check_maxlength);
19 &flush_file_lines();
20 &unlock_file($list->{'config'});
21 &webmin_log("mesg", undef, $in{'name'}, \%in);
22 &redirect("edit_list.cgi?name=$in{'name'}");
23
24 sub check_reply
25 {
26 return $_[0] =~ /^\S+$/ ? undef : $text{'mesg_ereply'};
27 }
28
29 sub check_sender
30 {
31 return $_[0] =~ /\@/ ? $text{'mesg_esender2'} :
32        $_[0] =~ /^\S+$/ ? undef : $text{'mesg_esender'};
33 }
34
35 sub check_host
36 {
37 return $_[0] =~ /^[A-z0-9\-\.]+$/ ? undef : $text{'mesg_ehost'};
38 }
39
40 sub check_maxlength
41 {
42 return $_[0] =~ /^\d+$/ ? undef : $text{'mesg_emaxlength'};
43 }
44