#!/usr/local/bin/perl # edit_log.cgi # Display a form for adding a new logfile or editing an existing one. # Allows you to set the schedule on which the log is analysed require './webalizer-lib.pl'; &foreign_require("cron", "cron-lib.pl"); &ReadParse(); $access{'view'} && &error($text{'edit_ecannot'}); if ($in{'new'}) { $access{'add'} || &error($text{'edit_ecannot'}); &ui_print_header(undef, $text{'edit_title1'}, ""); } else { &can_edit_log($in{'file'}) || &error($text{'edit_ecannot'}); &ui_print_header(undef, $text{'edit_title2'}, ""); $lconf = &get_log_config($in{'file'}); } print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$text{'edit_header'}
\n"; print "\n"; if (!$in{'new'}) { @all = &all_log_files($in{'file'}); if (@all > 1) { print " ", "\n"; } } print "\n"; print "\n", $lconf->{'dir'}, &file_chooser_button("dir", 1); print "\n"; if ($access{'user'} eq '*') { # User that webalizer runs as can be chosen printf "\n", $lconf->{'user'} || "root"; } else { # User is fixed printf "\n", !$in{'new'} && $lconf->{'dir'} ? $lconf->{'user'} || "root" : $access{'user'} eq "" ? $remote_user : $access{'user'}; } print "\n"; printf "\n", $lconf->{'over'} ? "" : "checked", $text{'no'}; $cfile = &config_file_name($in{'file'}); $cmode = -l $cfile ? 2 : -r $cfile ? 1 : 0; print "\n", $cmode == 2 ? readlink($cfile) : "", &file_chooser_button("cfile"); print "\n", $lconf->{'sched'} ? "checked" : "", $text{'edit_sched1'}; print "\n"; printf "\n", $lconf->{'clear'} ? "" : "checked", $text{'no'}; print "
$text{'edit_file'} \n"; if ($in{'new'}) { print " ",&file_chooser_button("file"); } else { print "\n"; print "$in{'file'}"; } print "
$text{'edit_files'}\n"; foreach $a (@all) { print "$a
\n"; } print "
$text{'edit_type'} \n"; if ($in{'new'}) { print "\n"; } else { print "\n"; print $text{'index_type'.$in{'type'}}; } print "
$text{'edit_dir'} \n"; printf " %s
$text{'edit_user'} %s
%s
$text{'edit_over'} %s\n", $lconf->{'over'} ? "checked" : "", $text{'yes'}; printf " %s
$text{'edit_conf'} \n"; printf " %s\n", $cmode == 0 ? "checked" : "", $text{'edit_cmode0'}; printf " %s\n", $cmode == 1 ? "checked" : "", $text{'edit_cmode1'}; printf " %s\n", $cmode == 2 ? "checked" : "", $text{'edit_cmode2'}; printf " %s
$text{'edit_sched'} \n"; printf " %s\n", $lconf->{'sched'} ? "" : "checked", $text{'edit_sched0'}; printf " %s
$text{'edit_clear'} %s\n", $lconf->{'clear'} ? "checked" : "", $text{'yes'}; printf " %s
\n"; print "\n"; if ($lconf->{'mins'} eq '') { $lconf->{'mins'} = $lconf->{'hours'} = 0; $lconf->{'days'} = $lconf->{'months'} = $lconf->{'weekdays'} = '*'; } &foreign_call("cron", "show_times_input", $lconf); print "
\n"; print "
\n"; if ($in{'new'}) { push(@b, ""); } else { push(@b, ""); push(@b, "") if ($cmode); if ($lconf->{'dir'}) { push(@b, ""); } if ($lconf->{'dir'} && -r "$lconf->{'dir'}/index.html") { push(@b, ""); } if ($in{'custom'}) { push(@b, ""); } } &spaced_buttons(@b); print "
\n"; &ui_print_footer("", $text{'index_return'});