PageRenderTime 50ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/phpini/save_errors.cgi

http://github.com/webmin/webmin
Perl | 60 lines | 46 code | 8 blank | 6 comment | 15 complexity | 0034c8bf82e9d8c99cde1b6dce1beded MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-3.0, CC-BY-SA-3.0
  1. #!/usr/local/bin/perl
  2. # Update options related to error logging
  3. require './phpini-lib.pl';
  4. &error_setup($text{'errors_err'});
  5. &ReadParse();
  6. &can_php_config($in{'file'}) || &error($text{'list_ecannot'});
  7. &lock_file($in{'file'});
  8. $conf = &get_config($in{'file'});
  9. &save_directive($conf, "display_errors", $in{"display_errors"} || undef);
  10. &save_directive($conf, "log_errors", $in{"log_errors"} || undef);
  11. &save_directive($conf, "ignore_repeated_errors",
  12. $in{"ignore_repeated_errors"} || undef);
  13. &save_directive($conf, "ignore_repeated_source",
  14. $in{"ignore_repeated_source"} || undef);
  15. if (defined($in{"error_reporting"})) {
  16. # Custom expression
  17. if ($in{"error_reporting_def"}) {
  18. &save_directive($conf, "error_reporting", undef);
  19. }
  20. else {
  21. $in{"error_reporting"} =~ /\S/ ||
  22. &error($text{'errors_ereporting'});
  23. &save_directive($conf, "error_reporting",
  24. $in{"error_reporting"}, undef, 1);
  25. }
  26. }
  27. else {
  28. # Bitwise
  29. &save_directive($conf, "error_reporting",
  30. join("|", split(/\0/, $in{"error_bits"})));
  31. }
  32. # Save max error length
  33. $in{"log_errors_max_len_def"} || $in{"log_errors_max_len"} =~ /^\d+$/ ||
  34. &error($text{'errors_emaxlen'});
  35. &save_directive($conf, "log_errors_max_len",
  36. $in{"log_errors_max_len_def"} ? undef : $in{"log_errors_max_len"});
  37. # Save log file
  38. if ($in{"error_log_def"} == 0) {
  39. &save_directive($conf, "error_log", undef);
  40. }
  41. elsif ($in{"error_log_def"} == 1) {
  42. &save_directive($conf, "error_log", "syslog");
  43. }
  44. elsif ($in{"error_log_def"} == 2) {
  45. $in{"error_log"} =~ /\S/ || &error($text{'errors_efile'});
  46. &save_directive($conf, "error_log", $in{"error_log"});
  47. }
  48. &flush_file_lines_as_user($in{'file'});
  49. &unlock_file($in{'file'});
  50. &graceful_apache_restart();
  51. &webmin_log("errors", undef, $in{'file'});
  52. &redirect("list_ini.cgi?file=".&urlize($in{'file'}));