Handle hostnames with upper-case letters
[webmin.git] / phpini / save_errors.cgi
1 #!/usr/local/bin/perl
2 # Update options related to error logging
3
4 require './phpini-lib.pl';
5 &error_setup($text{'errors_err'});
6 &ReadParse();
7 &can_php_config($in{'file'}) || &error($text{'list_ecannot'});
8
9 &lock_file($in{'file'});
10 $conf = &get_config($in{'file'});
11
12 &save_directive($conf, "display_errors", $in{"display_errors"} || undef);
13 &save_directive($conf, "log_errors", $in{"log_errors"} || undef);
14 &save_directive($conf, "ignore_repeated_errors",
15                 $in{"ignore_repeated_errors"} || undef);
16 &save_directive($conf, "ignore_repeated_source",
17                 $in{"ignore_repeated_source"} || undef);
18 if (defined($in{"error_reporting"})) {
19         # Custom expression
20         if ($in{"error_reporting_def"}) {
21                 &save_directive($conf, "error_reporting", undef);
22                 }
23         else {
24                 $in{"error_reporting"} =~ /\S/ ||
25                         &error($text{'errors_ereporting'});
26                 &save_directive($conf, "error_reporting",
27                                 $in{"error_reporting"}, undef, 1);
28                 }
29         }
30 else {
31         # Bitwise
32         &save_directive($conf, "error_reporting",
33                         join("|", split(/\0/, $in{"error_bits"})));
34         }
35
36 # Save max error length
37 $in{"log_errors_max_len_def"} || $in{"log_errors_max_len"} =~ /^\d+$/ ||
38         &error($text{'errors_emaxlen'});
39 &save_directive($conf, "log_errors_max_len", 
40         $in{"log_errors_max_len_def"} ? undef : $in{"log_errors_max_len"});
41
42 # Save log file
43 if ($in{"error_log_def"} == 0) {
44         &save_directive($conf, "error_log", undef);
45         }
46 elsif ($in{"error_log_def"} == 1) {
47         &save_directive($conf, "error_log", "syslog");
48         }
49 elsif ($in{"error_log_def"} == 2) {
50         $in{"error_log"} =~ /\S/ || &error($text{'errors_efile'});
51         &save_directive($conf, "error_log", $in{"error_log"});
52         }
53
54 &flush_file_lines_as_user($in{'file'});
55 &unlock_file($in{'file'});
56 &graceful_apache_restart();
57 &webmin_log("errors", undef, $in{'file'});
58
59 &redirect("list_ini.cgi?file=".&urlize($in{'file'}));
60