1#!/usr/local/bin/perl
2# save_user.cgi
3# Save other user options
4
5require './spam-lib.pl';
6&error_setup($text{'user_err'});
7&ReadParse();
8&set_config_file_in(\%in);
9&can_use_check("user");
10&execute_before("user");
11&lock_spam_files();
12$conf = &get_config();
13
14if ($in{'dns'} == 1) {
15	&save_directives($conf, 'dns_available', [ 'yes' ], 1);
16	}
17elsif ($in{'dns'} == 0) {
18	&save_directives($conf, 'dns_available', [ 'no' ], 1);
19	}
20elsif ($in{'dns'} == -1) {
21	&save_directives($conf, 'dns_available', [ ], 1);
22	}
23else {
24	local $test = "test";
25	if ($in{'dnslist'}) {
26		$test .= ": $in{'dnslist'}";
27		}
28	if ($config{'defaults'} && !$in{'dnslist'}) {
29		&save_directives($conf, 'dns_available', [ ]);
30		}
31	else {
32		&save_directives($conf, 'dns_available', [ $test ], 1);
33		}
34	}
35
36&parse_opt($conf, "razor_timeout", \&check_timeout);
37
38&parse_opt($conf, "dcc_path", \&check_path);
39&parse_opt($conf, "dcc_body_max", \&check_max);
40&parse_opt($conf, "dcc_timeout", \&check_timeout);
41&parse_opt($conf, "dcc_fuz1_max", \&check_max);
42&parse_opt($conf, "dcc_fuz2_max", \&check_max);
43if (!&version_atleast(3)) {
44	&parse_yes_no($conf, "dcc_add_header");
45	}
46
47&parse_opt($conf, "pyzor_path", \&check_path);
48&parse_opt($conf, "pyzor_body_max", \&check_max);
49&parse_opt($conf, "pyzor_timeout", \&check_timeout);
50&parse_yes_no($conf, "pyzor_add_header");
51
52&flush_file_lines();
53&unlock_spam_files();
54&execute_after("user");
55&webmin_log("user");
56&redirect($redirect_url);
57
58sub check_timeout
59{
60$_[0] =~ /^\d+$/ || &error(&text('user_etimeout', $_[0]));
61}
62
63sub check_path
64{
65$_[0] =~ /^\// && -r $_[0] || &error(&text('user_epath', $_[0]));
66}
67
68sub check_max
69{
70$_[0] =~ /^\d+$/ || &error(&text('user_emax', $_[0]));
71}
72
73