Handle hostnames with upper-case letters
[webmin.git] / sarg / save_log.cgi
1 #!/usr/local/bin/perl
2 # Save options for report source and dest
3
4 require './sarg-lib.pl';
5 &ReadParse();
6 $conf = &get_config();
7 $config_prefix = "log_";
8 &error_setup($text{'log_err'});
9
10 &lock_sarg_files();
11 if ($in{'access_log_def'} == 0) {
12         &save_directive($conf, "access_log", [ ]);
13         }
14 elsif ($in{'access_log_def'} == 1) {
15         &save_directive($conf, "access_log", [ $in{'squid_log'} ]);
16         }
17 else {
18         &save_textbox($conf, "access_log", \&check_log);
19         }
20 &save_opt_textbox($conf, "output_dir", \&check_output_dir);
21 &save_opt_textbox($conf, "lastlog", \&check_lastlog);
22 &save_opt_textbox($conf, "useragent_log", \&check_log);
23 &save_opt_textbox($conf, "squidguard_log_path", \&check_log);
24 &save_opt_textbox($conf, "output_email", \&check_email);
25 &save_opt_textbox($conf, "mail_utility", \&check_mailx);
26
27 &flush_file_lines();
28 &unlock_sarg_files();
29 &webmin_log("log");
30 &redirect("");
31
32 sub check_log
33 {
34 return -r $_[0] ? undef : $text{'log_elog'};
35 }
36
37 sub check_output_dir
38 {
39 return -d $_[0] ? undef : $text{'log_edir'};
40 }
41
42 sub check_lastlog
43 {
44 return $_[0] =~ /^\d+$/ ? undef : $text{'log_elastlog'};
45 }
46
47 sub check_email
48 {
49 return $_[0] =~ /^\S+$/ ? undef : $text{'log_eemail'};
50 }
51
52 sub check_mailx
53 {
54 return $_[0] =~ /^(\S+)/ && &has_command($1) ? undef : $text{'log_emailx'};
55 }
56