#!/usr/bin/perl # save_log.cgi # Save, create or delete options for a log file use strict; use warnings; no warnings 'redefine'; no warnings 'uninitialized'; our (%text, %config, %gconfig, %access, $module_name, %in, $remote_user, $cron_cmd, $custom_logs_file); require './webalizer-lib.pl'; &foreign_require("cron", "cron-lib.pl"); &ReadParse(); &error_setup($text{'save_err'}); $access{'view'} && &error($text{'edit_ecannot'}); !$in{'new'} || $access{'add'} || &error($text{'edit_ecannot'}); &can_edit_log($in{'file'}) || &error($text{'edit_efilecannot'}); # Find the cron job my $job; if (!$in{'new'} && !$in{'view'} && !$in{'run'}) { my @jobs = &cron::list_cron_jobs(); foreach my $j (@jobs) { $job = $j if ($j->{'command'} eq "$cron_cmd $in{'file'}"); } } if ($in{'view'}) { # Re-direct to the view page &redirect("view_log.cgi/".&urlize(&urlize($in{'file'}))."/index.html"); exit; } elsif ($in{'global'}) { # Re-direct to the options page &redirect("edit_global.cgi?file=".&urlize($in{'file'})."&type=$in{'type'}&custom=$in{'custom'}"); exit; } elsif ($in{'run'}) { # Force report generation and show the output &ui_print_unbuffered_header(undef, $text{'gen_title'}, ""); my $lconf = &get_log_config($in{'file'}); print "<b>",&text('gen_header', "<tt>$in{'file'}</tt>"),"</b><br>\n"; print "<pre>"; my $rv = &generate_report($in{'file'}, \*STDOUT, 1); print "</pre>\n"; if ($rv && -r "$lconf->{'dir'}/index.html") { print "<b>$text{'gen_done'}</b><p>\n"; print &ui_link("view_log.cgi/".&urlize(&urlize($in{'file'})). "/index.html", $text{'gen_view'})."<p>\n"; } elsif ($rv) { print "<b>$text{'gen_nothing'}</b><p>\n"; } else { print "<b>$text{'gen_failed'}</b><p>\n"; } &webmin_log("generate", "log", $in{'file'}); &ui_print_footer("edit_log.cgi?file=".&urlize($in{'file'}). "&type=$in{'type'}&custom=$in{'custom'}", $text{'edit_return'}, "", $text{'index_return'}); exit; } elsif ($in{'delete'}) { # Delete this custom log file from the configuration &lock_file($custom_logs_file); my @custom = &read_custom_logs(); @custom = grep { $_->{'file'} ne $in{'file'} } @custom; if ($job) { &lock_file($job->{'file'}); &foreign_call("cron", "delete_cron_job", $job); &unlock_file($job->{'file'}); } &write_custom_logs(@custom); &unlock_file($custom_logs_file); my $cfile = &log_config_name($in{'file'}); &unlink_logged($cfile); &webmin_log("delete", "log", $in{'file'}); } else { # Validate and store inputs if ($in{'new'}) { -r $in{'file'} && !-d $in{'file'} || &error($text{'save_efile'}); } -d $in{'dir'} || &error($text{'save_edir'}); $in{'cmode'} != 2 || -r $in{'cfile'} || &error($text{'save_ecfile'}); my $lconf = { }; if ($access{'user'} eq '*') { # Set the user to whatever was entered defined(getpwnam($in{'user'})) || &error($text{'save_euser'}); $lconf->{'user'} = $in{'user'}; } elsif (!$in{'new'} && $lconf->{'dir'}) { # This is not a new log, so the user cannot be changed } elsif ($access{'user'} eq '') { # This is a new log, or one that has not been saved for # the first time yet. Use the webmin user as the user defined(getpwnam($remote_user)) || &error(&text('save_ewuser', $remote_user)); $lconf->{'user'} = $remote_user; } else { # This is a new log, or one that has not been saved for # the first time yet. Use the user set in the ACL $lconf->{'user'} = $access{'user'}; } $lconf->{'dir'} = $in{'dir'}; $lconf->{'sched'} = $in{'sched'}; $lconf->{'type'} = $in{'type'}; $lconf->{'over'} = $in{'over'}; $lconf->{'clear'} = $in{'clear'}; &cron::parse_times_input($lconf, \%in); # Create or delete the cron job my $oldjob = $job; if ($lconf->{'sched'}) { # Create cron job and script $job->{'user'} = 'root'; $job->{'active'} = 1; $job->{'command'} = "$cron_cmd $in{'file'}"; &lconf_to_cron($lconf, $job); &lock_file($cron_cmd); &cron::create_wrapper($cron_cmd, $module_name, "webalizer.pl"); &unlock_file($cron_cmd); } &lock_file(&cron::cron_file($job)) if ($job); if ($lconf->{'sched'} && !$oldjob) { # Create the cron job &foreign_call("cron", "create_cron_job", $job); } elsif ($lconf->{'sched'} && $oldjob) { # Update the cron job &foreign_call("cron", "change_cron_job", $job); } elsif (!$lconf->{'sched'} && $oldjob) { # Delete the cron job &foreign_call("cron", "delete_cron_job", $job); } &unlock_file(&cron::cron_file($job)) if ($job); if ($in{'new'}) { # Add a new custom log file to the configuration &lock_file($custom_logs_file); my @custom = &read_custom_logs(); push(@custom, { 'file' => $in{'file'}, 'type' => $in{'type'} }); &write_custom_logs(@custom); &unlock_file($custom_logs_file); } # Create or link the custom webalizer.conf file my $cfile = &config_file_name($in{'file'}); if ($in{'cmode'} == 0) { # None at all &unlink_logged($cfile); } elsif ($in{'cmode'} == 1) { # File under /etc/webmin/webalizer if (-l $cfile) { &unlink_logged($cfile); } if (!-r $cfile) { # Need to copy into place ©_source_dest($config{'webalizer_conf'}, $cfile); } } elsif ($in{'cmode'} == 2) { # Symbolic link to somewhere &unlink_logged($cfile); symlink($in{'cfile'}, $cfile); } # Update the log file's options $cfile = &log_config_name($in{'file'}); &lock_file($cfile); &save_log_config($in{'file'}, $lconf); &unlock_file($cfile); &webmin_log($in{'new'} ? "create" : "modify", "log", $in{'file'}); } &redirect("");
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
images | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
CHANGELOG | File | 855 B | 0644 |
|
acl_security.pl | File | 1.2 KB | 0755 |
|
backup_config.pl | File | 1.63 KB | 0755 |
|
cgi_args.pl | File | 840 B | 0755 |
|
config | File | 158 B | 0644 |
|
config-ALL-linux | File | 107 B | 0644 |
|
config-debian-linux-4.0-ALL | File | 172 B | 0644 |
|
config-freebsd | File | 176 B | 0644 |
|
config-gentoo-linux | File | 107 B | 0644 |
|
config-mandrake-linux-10.3-ALL | File | 107 B | 0644 |
|
config-netbsd | File | 120 B | 0644 |
|
config-openbsd | File | 179 B | 0644 |
|
config-openmamba-linux | File | 113 B | 0644 |
|
config-solaris-10-ALL | File | 175 B | 0644 |
|
config-syno-linux | File | 222 B | 0644 |
|
config.info | File | 425 B | 0644 |
|
config.info.ca | File | 514 B | 0644 |
|
config.info.cs | File | 226 B | 0644 |
|
config.info.de | File | 471 B | 0644 |
|
config.info.es | File | 310 B | 0644 |
|
config.info.fa | File | 365 B | 0644 |
|
config.info.fi | File | 0 B | 0644 |
|
config.info.fr | File | 465 B | 0644 |
|
config.info.hr | File | 0 B | 0644 |
|
config.info.hu | File | 407 B | 0644 |
|
config.info.ms | File | 387 B | 0644 |
|
config.info.nl | File | 396 B | 0644 |
|
config.info.no | File | 379 B | 0644 |
|
config.info.pl | File | 488 B | 0644 |
|
config.info.ru | File | 308 B | 0644 |
|
config.info.tr | File | 372 B | 0644 |
|
config.info.uk | File | 314 B | 0644 |
|
defaultacl | File | 46 B | 0644 |
|
edit_global.cgi | File | 4.8 KB | 0755 |
|
edit_log.cgi | File | 3.67 KB | 0755 |
|
index.cgi | File | 5.13 KB | 0755 |
|
install_check.pl | File | 545 B | 0755 |
|
log_parser.pl | File | 707 B | 0755 |
|
mass.cgi | File | 1.81 KB | 0755 |
|
module.info | File | 201 B | 0644 |
|
module.info.af | File | 0 B | 0644 |
|
module.info.af.auto | File | 131 B | 0644 |
|
module.info.ar | File | 0 B | 0644 |
|
module.info.ar.auto | File | 184 B | 0644 |
|
module.info.be | File | 0 B | 0644 |
|
module.info.be.auto | File | 224 B | 0644 |
|
module.info.bg | File | 0 B | 0644 |
|
module.info.bg.auto | File | 203 B | 0644 |
|
module.info.ca | File | 156 B | 0644 |
|
module.info.ca.auto | File | 21 B | 0644 |
|
module.info.cs | File | 46 B | 0644 |
|
module.info.cs.auto | File | 108 B | 0644 |
|
module.info.da | File | 0 B | 0644 |
|
module.info.da.auto | File | 119 B | 0644 |
|
module.info.de | File | 113 B | 0644 |
|
module.info.de.auto | File | 18 B | 0644 |
|
module.info.el | File | 0 B | 0644 |
|
module.info.el.auto | File | 248 B | 0644 |
|
module.info.es | File | 52 B | 0644 |
|
module.info.es.auto | File | 118 B | 0644 |
|
module.info.eu | File | 0 B | 0644 |
|
module.info.eu.auto | File | 153 B | 0644 |
|
module.info.fa | File | 0 B | 0644 |
|
module.info.fa.auto | File | 230 B | 0644 |
|
module.info.fi | File | 0 B | 0644 |
|
module.info.fi.auto | File | 151 B | 0644 |
|
module.info.fr | File | 45 B | 0644 |
|
module.info.fr.auto | File | 125 B | 0644 |
|
module.info.he | File | 0 B | 0644 |
|
module.info.he.auto | File | 154 B | 0644 |
|
module.info.hr | File | 0 B | 0644 |
|
module.info.hr.auto | File | 142 B | 0644 |
|
module.info.hu | File | 37 B | 0644 |
|
module.info.hu.auto | File | 116 B | 0644 |
|
module.info.it | File | 0 B | 0644 |
|
module.info.it.auto | File | 142 B | 0644 |
|
module.info.ja | File | 0 B | 0644 |
|
module.info.ja.auto | File | 181 B | 0644 |
|
module.info.ko | File | 0 B | 0644 |
|
module.info.ko.auto | File | 147 B | 0644 |
|
module.info.lt | File | 0 B | 0644 |
|
module.info.lt.auto | File | 164 B | 0644 |
|
module.info.lv | File | 0 B | 0644 |
|
module.info.lv.auto | File | 153 B | 0644 |
|
module.info.ms | File | 118 B | 0644 |
|
module.info.ms.auto | File | 18 B | 0644 |
|
module.info.mt | File | 0 B | 0644 |
|
module.info.mt.auto | File | 138 B | 0644 |
|
module.info.nl | File | 34 B | 0644 |
|
module.info.nl.auto | File | 101 B | 0644 |
|
module.info.no | File | 33 B | 0644 |
|
module.info.no.auto | File | 93 B | 0644 |
|
module.info.pl | File | 91 B | 0644 |
|
module.info.pl.auto | File | 18 B | 0644 |
|
module.info.pt | File | 0 B | 0644 |
|
module.info.pt.auto | File | 152 B | 0644 |
|
module.info.pt_BR | File | 0 B | 0644 |
|
module.info.pt_BR.auto | File | 161 B | 0644 |
|
module.info.ro | File | 0 B | 0644 |
|
module.info.ro.auto | File | 145 B | 0644 |
|
module.info.ru | File | 53 B | 0644 |
|
module.info.ru.auto | File | 153 B | 0644 |
|
module.info.sk | File | 0 B | 0644 |
|
module.info.sk.auto | File | 174 B | 0644 |
|
module.info.sl | File | 0 B | 0644 |
|
module.info.sl.auto | File | 160 B | 0644 |
|
module.info.sv | File | 0 B | 0644 |
|
module.info.sv.auto | File | 130 B | 0644 |
|
module.info.th | File | 0 B | 0644 |
|
module.info.th.auto | File | 294 B | 0644 |
|
module.info.tr | File | 0 B | 0644 |
|
module.info.tr.auto | File | 154 B | 0644 |
|
module.info.uk | File | 0 B | 0644 |
|
module.info.uk.auto | File | 225 B | 0644 |
|
module.info.ur | File | 0 B | 0644 |
|
module.info.ur.auto | File | 194 B | 0644 |
|
module.info.vi | File | 0 B | 0644 |
|
module.info.vi.auto | File | 147 B | 0644 |
|
module.info.zh | File | 0 B | 0644 |
|
module.info.zh.auto | File | 130 B | 0644 |
|
module.info.zh_TW | File | 24 B | 0644 |
|
module.info.zh_TW.auto | File | 100 B | 0644 |
|
save_global.cgi | File | 4.14 KB | 0755 |
|
save_log.cgi | File | 5.38 KB | 0755 |
|
view_log.cgi | File | 1.74 KB | 0755 |
|
webalizer-lib.pl | File | 8.74 KB | 0755 |
|
webalizer.pl | File | 822 B | 0755 |
|