mirror of
https://github.com/webmin/webmin.git
synced 2025-08-22 18:11:38 +00:00
More strict and ui-lib conversion
This commit is contained in:
@ -1,52 +1,46 @@
|
|||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
our (%text, %in);
|
||||||
do 'webalizer-lib.pl';
|
do 'webalizer-lib.pl';
|
||||||
|
|
||||||
# acl_security_form(&options)
|
# acl_security_form(&options)
|
||||||
# Output HTML for editing security options for the webalizer module
|
# Output HTML for editing security options for the webalizer module
|
||||||
sub acl_security_form
|
sub acl_security_form
|
||||||
{
|
{
|
||||||
print "<tr> <td><b>$text{'acl_view'}</b></td>\n";
|
my ($o) = @_;
|
||||||
printf "<td nowrap><input type=radio name=view value=1 %s> %s\n",
|
|
||||||
$_[0]->{'view'} ? "checked" : "", $text{'yes'};
|
|
||||||
printf "<input type=radio name=view value=0 %s> %s</td>\n",
|
|
||||||
$_[0]->{'view'} ? "" : "checked", $text{'no'};
|
|
||||||
|
|
||||||
print "<td><b>$text{'acl_global'}</b></td>\n";
|
print &ui_table_row($text{'acl_view'},
|
||||||
printf "<td nowrap><input type=radio name=global value=1 %s> %s\n",
|
&ui_yesno_radio("view", $o->{'view'}));
|
||||||
$_[0]->{'global'} ? "checked" : "", $text{'yes'};
|
|
||||||
printf "<input type=radio name=global value=0 %s> %s</td> </tr>\n",
|
|
||||||
$_[0]->{'global'} ? "" : "checked", $text{'no'};
|
|
||||||
|
|
||||||
print "<tr> <td><b>$text{'acl_add'}</b></td>\n";
|
print &ui_table_row($text{'acl_global'},
|
||||||
printf "<td nowrap><input type=radio name=add value=1 %s> %s\n",
|
&ui_yesno_radio("global", $o->{'global'}));
|
||||||
$_[0]->{'add'} ? "checked" : "", $text{'yes'};
|
|
||||||
printf "<input type=radio name=add value=0 %s> %s</td> </tr>\n",
|
|
||||||
$_[0]->{'add'} ? "" : "checked", $text{'no'};
|
|
||||||
|
|
||||||
print "<tr> <td><b>$text{'acl_user'}</b></td>\n";
|
print &ui_table_row($text{'acl_add'},
|
||||||
printf "<td colspan=3><input type=radio name=user_def value=1 %s> %s\n",
|
&ui_yesno_radio("add", $o->{'add'}));
|
||||||
$_[0]->{'user'} eq "" ? "checked" : "", $text{'acl_this'};
|
|
||||||
printf "<input type=radio name=user_def value=2 %s> %s\n",
|
|
||||||
$_[0]->{'user'} eq "*" ? "checked" : "", $text{'acl_any'};
|
|
||||||
printf "<input type=radio name=user_def value=0 %s>\n",
|
|
||||||
$_[0]->{'user'} eq "*" || $_[0]->{'user'} eq "" ? "" : "checked";
|
|
||||||
printf "<input name=user size=8 value='%s'> %s</td> </tr>\n",
|
|
||||||
$_[0]->{'user'} eq "*" ? "" : $_[0]->{'user'},
|
|
||||||
&user_chooser_button("user");
|
|
||||||
|
|
||||||
print "<tr> <td><b>$text{'acl_dir'}</b></td>\n";
|
print &ui_table_row($text{'acl_user'},
|
||||||
print "<td colspan=3><input name=dir size=50 value='$_[0]->{'dir'}'></td> </tr>\n";
|
&ui_radio("user_def", $o->{'user'} eq "" ? 1 :
|
||||||
|
$o->{'user'} eq "*" ? 2 : 0,
|
||||||
|
[ [ 1, $text{'acl_this'} ],
|
||||||
|
[ 2, $text{'acl_any'} ],
|
||||||
|
[ 0, &ui_userbox("user", $o->{'user'} eq "*" ? "" :
|
||||||
|
$o->{'user'}, 20) ] ]));
|
||||||
|
|
||||||
|
print &ui_table_row($text{'acl_dir'},
|
||||||
|
&ui_textbox("dir", $o->{'dir'}, 60), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
# acl_security_save(&options)
|
# acl_security_save(&options, &in)
|
||||||
# Parse the form for security options for the shell module
|
# Parse the form for security options for the shell module
|
||||||
sub acl_security_save
|
sub acl_security_save
|
||||||
{
|
{
|
||||||
$_[0]->{'view'} = $in{'view'};
|
my ($o, $in) = @_;
|
||||||
$_[0]->{'global'} = $in{'global'};
|
$o->{'view'} = $in->{'view'};
|
||||||
$_[0]->{'add'} = $in{'add'};
|
$o->{'global'} = $in->{'global'};
|
||||||
$_[0]->{'dir'} = $in{'dir'};
|
$o->{'add'} = $in->{'add'};
|
||||||
$_[0]->{'user'} = $in{'user_def'} == 2 ? "*" :
|
$o->{'dir'} = $in->{'dir'};
|
||||||
$in{'user_def'} == 1 ? "" : $in{'user'};
|
$o->{'user'} = $in->{'user_def'} == 2 ? "*" :
|
||||||
|
$in->{'user_def'} == 1 ? "" : $in->{'user'};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
our (%text, %in, $module_config_directory, $cron_cmd, %config);
|
||||||
do 'webalizer-lib.pl';
|
do 'webalizer-lib.pl';
|
||||||
|
|
||||||
# backup_config_files()
|
# backup_config_files()
|
||||||
# Returns files and directories that can be backed up
|
# Returns files and directories that can be backed up
|
||||||
sub backup_config_files
|
sub backup_config_files
|
||||||
{
|
{
|
||||||
local @rv = ( $config{'webalizer_conf'} );
|
my @rv = ( $config{'webalizer_conf'} );
|
||||||
local $f;
|
my $fh;
|
||||||
opendir(DIR, $module_config_directory);
|
opendir($fh, $module_config_directory);
|
||||||
while($f = readdir(DIR)) {
|
while(my $f = readdir($fh)) {
|
||||||
if ($f =~ /\.conf$/ || $f =~ /\.log$/) {
|
if ($f =~ /\.conf$/ || $f =~ /\.log$/) {
|
||||||
push(@rv, "$module_config_directory/$f");
|
push(@rv, "$module_config_directory/$f");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(DIR);
|
closedir($fh);
|
||||||
return @rv;
|
return @rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,12 +47,12 @@ sub post_restore
|
|||||||
{
|
{
|
||||||
# Re-setup all needed cron jobs
|
# Re-setup all needed cron jobs
|
||||||
&foreign_require("cron", "cron-lib.pl");
|
&foreign_require("cron", "cron-lib.pl");
|
||||||
local @jobs = &cron::list_cron_jobs();
|
my @jobs = &cron::list_cron_jobs();
|
||||||
foreach $log (&get_all_logs()) {
|
foreach my $log (&get_all_logs()) {
|
||||||
local $lconf = &get_log_config($log->{'file'});
|
my $lconf = &get_log_config($log->{'file'});
|
||||||
if ($lconf->{'sched'}) {
|
if ($lconf->{'sched'}) {
|
||||||
local ($job) = grep { $_->{'command'} eq
|
my ($job) = grep { $_->{'command'} eq
|
||||||
"$cron_cmd $log->{'file'}" } @jobs;
|
"$cron_cmd $log->{'file'}" } @jobs;
|
||||||
if (!$job) {
|
if (!$job) {
|
||||||
# Need to create!
|
# Need to create!
|
||||||
$job->{'user'} = 'root';
|
$job->{'user'} = 'root';
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
our (%text, %access);
|
||||||
do 'webalizer-lib.pl';
|
do 'webalizer-lib.pl';
|
||||||
|
|
||||||
sub cgi_args
|
sub cgi_args
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# install_check.pl
|
# install_check.pl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
our (%config);
|
||||||
do 'webalizer-lib.pl';
|
do 'webalizer-lib.pl';
|
||||||
|
|
||||||
# is_installed(mode)
|
# is_installed(mode)
|
||||||
@ -9,7 +12,8 @@ do 'webalizer-lib.pl';
|
|||||||
sub is_installed
|
sub is_installed
|
||||||
{
|
{
|
||||||
return 0 if (!&has_command($config{'webalizer'}));
|
return 0 if (!&has_command($config{'webalizer'}));
|
||||||
local $ver = &get_webalizer_version(\$dummy);
|
my $dummy;
|
||||||
|
my $ver = &get_webalizer_version(\$dummy);
|
||||||
return 0 if (!$ver || $ver < 2);
|
return 0 if (!$ver || $ver < 2);
|
||||||
return $_[0] ? 2 : 1;
|
return $_[0] ? 2 : 1;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
# log_parser.pl
|
# log_parser.pl
|
||||||
# Functions for parsing this module's logs
|
# Functions for parsing this module's logs
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
our (%text);
|
||||||
do 'webalizer-lib.pl';
|
do 'webalizer-lib.pl';
|
||||||
|
|
||||||
# parse_webmin_log(user, script, action, type, object, ¶ms)
|
# parse_webmin_log(user, script, action, type, object, ¶ms)
|
||||||
# Converts logged information from this module into human-readable form
|
# Converts logged information from this module into human-readable form
|
||||||
sub parse_webmin_log
|
sub parse_webmin_log
|
||||||
{
|
{
|
||||||
local ($user, $script, $action, $type, $object, $p) = @_;
|
my ($user, $script, $action, $type, $object, $p) = @_;
|
||||||
if ($type eq "log") {
|
if ($type eq "log") {
|
||||||
return &text("log_${action}_log", "<tt>".&html_escape($object)."</tt>");
|
return &text("log_${action}_log", "<tt>".&html_escape($object)."</tt>");
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,26 @@
|
|||||||
# webalizer.pl
|
# webalizer.pl
|
||||||
# Generate a report on schedule
|
# Generate a report on schedule
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
our ($no_acl_check, %config);
|
||||||
$no_acl_check++;
|
$no_acl_check++;
|
||||||
require './webalizer-lib.pl';
|
require './webalizer-lib.pl';
|
||||||
$lconf = &get_log_config($ARGV[0]);
|
my $lconf = &get_log_config($ARGV[0]);
|
||||||
$lconf || die "Logfile $ARGV[0] config file does not exist";
|
$lconf || die "Logfile $ARGV[0] config file does not exist";
|
||||||
|
|
||||||
open(NULL, ">/dev/null");
|
my $fh;
|
||||||
|
open($fh, ">/dev/null");
|
||||||
&clean_language();
|
&clean_language();
|
||||||
$ok = &generate_report($ARGV[0], NULL, 0);
|
my $ok = &generate_report($ARGV[0], $fh, 0);
|
||||||
&reset_environment();
|
&reset_environment();
|
||||||
close(NULL);
|
close($fh);
|
||||||
|
|
||||||
if ($ok && $lconf->{'clear'}) {
|
if ($ok && $lconf->{'clear'}) {
|
||||||
# Truncate or delete the files for this report
|
# Truncate or delete the files for this report
|
||||||
@files = $config{'skip_old'} ? ( $ARGV[0] ) : &all_log_files($ARGV[0]);
|
my @files = $config{'skip_old'} ? ( $ARGV[0] )
|
||||||
foreach $f (@files) {
|
: &all_log_files($ARGV[0]);
|
||||||
|
foreach my $f (@files) {
|
||||||
next if (!-r $f);
|
next if (!-r $f);
|
||||||
if ($f eq $ARGV[0]) {
|
if ($f eq $ARGV[0]) {
|
||||||
# Just truncate the main log file
|
# Just truncate the main log file
|
||||||
|
Reference in New Issue
Block a user