2007-04-12 20:24:50 +00:00
|
|
|
# config-lib.pl
|
|
|
|
# Common functions for parsing config.info files
|
|
|
|
# Each module has a number of configurable parameters (stored in the config and
|
|
|
|
# config-* files in the module directory). Descriptions and possible values for
|
|
|
|
# each option are stored in the file config.info in the module directory.
|
|
|
|
# Each line of config.info looks like
|
|
|
|
# name=desc,type[,options]
|
|
|
|
# desc - A description of the parameter
|
|
|
|
# type - Possible types (and options) are
|
|
|
|
# 0 - Free text
|
|
|
|
# 1 - One of many (options are possibilities)
|
|
|
|
# 2 - Many of many (options are possibilities)
|
|
|
|
# 3 - Optional free text
|
|
|
|
# 4 - Like 1, but uses a pulldown menu
|
|
|
|
# 5 - User name
|
|
|
|
# 6 - Group name
|
|
|
|
# 7 - Directory
|
|
|
|
# 8 - File
|
|
|
|
# 9 - Multiline text
|
|
|
|
# 10 - Like 1, but with free text option
|
|
|
|
# 11 - Section header
|
|
|
|
# 12 - Password free text, with don't change option
|
|
|
|
# 13 - Like 2, but uses a list box
|
|
|
|
# 14 - Parameter is the name of a function in config_info.pl that
|
|
|
|
# returns an alternate set of config.info values.
|
|
|
|
# 15 - Parameter is the suffix for a pair of functions with show_
|
|
|
|
# and parse_ prepended.
|
|
|
|
# 16 - Password free text
|
|
|
|
|
|
|
|
# generate_config(&config, info-file, [module], [&can-config], [checkbox-name],
|
|
|
|
# [only-section])
|
2018-09-10 09:40:03 +03:00
|
|
|
# Prints HTML for
|
2007-04-12 20:24:50 +00:00
|
|
|
sub generate_config
|
|
|
|
{
|
2009-03-06 18:56:11 +00:00
|
|
|
my ($configref, $file, $module, $canconfig, $cbox, $section) = @_;
|
|
|
|
my %config = %$configref;
|
2007-04-12 20:24:50 +00:00
|
|
|
|
2020-04-07 15:48:52 +03:00
|
|
|
my $auto = $gconfig{"langauto_$remote_user"};
|
2025-05-26 16:46:09 +03:00
|
|
|
my $neutral = $gconfig{"langneutral_$remote_user"};
|
2020-04-07 15:48:52 +03:00
|
|
|
if (!defined($auto)) {
|
|
|
|
my $glangauto = $gconfig{'langauto'};
|
|
|
|
if (defined($glangauto)) {
|
|
|
|
$auto = $glangauto;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my ($clanginfo) = grep { $_->{'lang'} eq $current_lang } &list_languages();
|
|
|
|
$auto = $clanginfo->{'auto'};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-12 20:24:50 +00:00
|
|
|
# Read the .info file in the right language
|
2009-03-06 18:56:11 +00:00
|
|
|
my (%info, @info_order, %einfo, $o);
|
2007-04-12 20:24:50 +00:00
|
|
|
&read_file($file, \%info, \@info_order);
|
|
|
|
%einfo = %info;
|
|
|
|
foreach $o (@lang_order_list) {
|
|
|
|
&read_file("$file.$o", \%info, \@info_order);
|
2020-04-07 15:48:52 +03:00
|
|
|
&read_file("$file.$o.auto", \%info, \@info_order)
|
|
|
|
if ($auto && -r "$file.$o.auto");
|
2025-05-26 16:46:09 +03:00
|
|
|
&read_file("$file.$o.neutral", \%info, \@info_order)
|
|
|
|
if ($neutral && -r "$file.$o.neutral");
|
2007-04-12 20:24:50 +00:00
|
|
|
}
|
2021-10-27 00:03:01 +03:00
|
|
|
|
|
|
|
# Call any config pre-load function
|
2022-10-01 18:29:39 +03:00
|
|
|
if (&foreign_defined($module, 'config_pre_load')) {
|
2022-07-30 01:00:59 +03:00
|
|
|
&foreign_call($module, "config_pre_load", \%info, \@info_order);
|
|
|
|
&foreign_call($module, "config_pre_load", \%einfo);
|
2021-10-27 00:03:01 +03:00
|
|
|
}
|
|
|
|
|
2007-04-12 20:24:50 +00:00
|
|
|
@info_order = &unique(@info_order);
|
|
|
|
|
|
|
|
if ($section) {
|
|
|
|
# Limit to settings in one section
|
|
|
|
@info_order = &config_in_section($section, \@info_order, \%info);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Show the parameter editors
|
2009-03-06 18:56:11 +00:00
|
|
|
foreach my $c (@info_order) {
|
|
|
|
my $checkhtml;
|
2007-04-12 20:24:50 +00:00
|
|
|
if ($cbox) {
|
|
|
|
# Show checkbox to allow configuring
|
|
|
|
$checkhtml = &ui_checkbox($cbox, $c, "",
|
|
|
|
!$canconfig || $canconfig->{$c});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# Skip those not allowed to be configured
|
|
|
|
next if ($canconfig && !$canconfig->{$c});
|
|
|
|
}
|
2009-03-06 18:56:11 +00:00
|
|
|
my @p = split(/,/, $info{$c});
|
|
|
|
my @ep = split(/,/, $einfo{$c});
|
2007-04-12 20:24:50 +00:00
|
|
|
if (scalar(@ep) > scalar(@p)) {
|
|
|
|
push(@p, @ep[scalar(@p) .. @ep-1]);
|
|
|
|
}
|
|
|
|
if ($p[1] == 14) {
|
|
|
|
$module || &error($text{'config_ewebmin'});
|
|
|
|
&foreign_require($module, "config_info.pl");
|
2009-03-06 18:56:11 +00:00
|
|
|
my @newp = &foreign_call($module, $p[2], @p);
|
2007-04-12 20:24:50 +00:00
|
|
|
$newp[0] ||= $p[0];
|
|
|
|
@p = @newp;
|
|
|
|
}
|
|
|
|
if ($p[1] == 11) {
|
|
|
|
# Title row
|
|
|
|
print &ui_table_row(undef, "<b>$p[0]</b>", 2, [ undef, $tb ]);
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if ($p[1] == 16 && $gconfig{'config_16_insecure'}) {
|
|
|
|
# Don't allow mode 16
|
|
|
|
$p[1] = 12;
|
|
|
|
}
|
2009-03-06 18:56:11 +00:00
|
|
|
my $label;
|
2007-04-12 20:24:50 +00:00
|
|
|
if ($module && -r &help_file($module, "config_$c")) {
|
|
|
|
$label = $checkhtml." ".
|
|
|
|
&hlink($p[0], "config_$c", $module);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$label = $checkhtml." ".$p[0];
|
|
|
|
}
|
2009-03-06 18:56:11 +00:00
|
|
|
my $field;
|
2007-04-12 20:24:50 +00:00
|
|
|
if ($p[1] == 0) {
|
|
|
|
# Text value
|
|
|
|
$field = &ui_textbox($c, $config{$c}, $p[2] || 40, 0, $p[3]).
|
|
|
|
" ".$p[4];
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 1) {
|
|
|
|
# One of many
|
2009-03-06 18:56:11 +00:00
|
|
|
my $len = 0;
|
|
|
|
for(my $i=2; $i<@p; $i++) {
|
2020-04-08 20:03:39 +03:00
|
|
|
$p[$i] =~ /^(\S*)\-(.*)$/;
|
2007-04-12 20:24:50 +00:00
|
|
|
$len += length($2);
|
|
|
|
}
|
2009-03-06 18:56:11 +00:00
|
|
|
my @opts;
|
2007-04-12 20:24:50 +00:00
|
|
|
for($i=2; $i<@p; $i++) {
|
2020-04-08 20:03:39 +03:00
|
|
|
$p[$i] =~ /^(\S*)\-(.*)$/;
|
2007-04-12 20:24:50 +00:00
|
|
|
push(@opts, [ $1, $2.($len > 50 ? "<br>" : "") ]);
|
|
|
|
}
|
|
|
|
$field = &ui_radio($c, $config{$c}, \@opts);
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 2) {
|
|
|
|
# Many of many
|
2009-03-06 18:56:11 +00:00
|
|
|
my %sel;
|
2007-04-12 20:24:50 +00:00
|
|
|
map { $sel{$_}++ } split(/,/, $config{$c});
|
|
|
|
for($i=2; $i<@p; $i++) {
|
2020-04-08 20:03:39 +03:00
|
|
|
$p[$i] =~ /^(\S*)\-(.*)$/;
|
2007-04-12 20:24:50 +00:00
|
|
|
$field .= &ui_checkbox($c, $1, $2, $sel{$1});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 3) {
|
|
|
|
# Optional value
|
2009-03-06 18:56:11 +00:00
|
|
|
my $none = $p[2] || $text{'config_none'};
|
2007-04-12 20:24:50 +00:00
|
|
|
$field = &ui_opt_textbox($c, $config{$c}, $p[3] || 20, $none,
|
2008-07-25 18:04:12 +00:00
|
|
|
$p[6], 0, undef, $p[4])." ".$p[5];
|
2007-04-12 20:24:50 +00:00
|
|
|
}
|
|
|
|
elsif ($p[1] == 4) {
|
|
|
|
# One of many menu
|
2009-03-06 18:56:11 +00:00
|
|
|
my @opts;
|
2007-04-12 20:24:50 +00:00
|
|
|
for($i=2; $i<@p; $i++) {
|
2020-04-08 20:03:39 +03:00
|
|
|
$p[$i] =~ /^(\S*)\-(.*)$/;
|
2007-04-12 20:24:50 +00:00
|
|
|
push(@opts, [ $1, $2 ]);
|
|
|
|
}
|
|
|
|
$field = &ui_select($c, $config{$c}, \@opts);
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 5) {
|
|
|
|
# User chooser
|
|
|
|
if ($p[2]) {
|
|
|
|
$field = &ui_radio($c."_def", $config{$c} ? 0 : 1,
|
|
|
|
[ [ 1, $p[2] ], [ 0, " " ] ]);
|
|
|
|
}
|
|
|
|
if ($p[3]) {
|
|
|
|
$field .= &ui_textbox($c, $config{$c}, 30)." ".
|
|
|
|
&user_chooser_button($c, 1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$field .= &unix_user_input($c, $config{$c});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 6) {
|
|
|
|
# Group chooser
|
|
|
|
if ($p[2]) {
|
|
|
|
$field = &ui_radio($c."_def", $config{$c} ? 0 : 1,
|
|
|
|
[ [ 1, $p[2] ], [ 0, " " ] ]);
|
|
|
|
}
|
|
|
|
if ($p[3]) {
|
|
|
|
$field .= &ui_textbox($c, $config{$c}, 30)." ".
|
|
|
|
&group_chooser_button($c, 1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$field .= &unix_group_input($c, $config{$c});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 7) {
|
|
|
|
# Directory chooser
|
|
|
|
$field = &ui_textbox($c, $config{$c}, 40)." ".
|
|
|
|
&file_chooser_button($c, 1);
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 8) {
|
|
|
|
# File chooser
|
|
|
|
$field = &ui_textbox($c, $config{$c}, 40)." ".
|
|
|
|
&file_chooser_button($c, 0);
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 9) {
|
|
|
|
# Text area
|
2009-03-06 18:56:11 +00:00
|
|
|
my $cols = $p[2] || 40;
|
|
|
|
my $rows = $p[3] || 5;
|
|
|
|
my $sp = $p[4] ? eval "\"$p[4]\"" : " ";
|
2007-04-12 20:24:50 +00:00
|
|
|
$field = &ui_textarea($c, join("\n", split(/$sp/, $config{$c})),
|
|
|
|
$rows, $cols);
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 10) {
|
|
|
|
# Radios with freetext option
|
2009-03-06 18:56:11 +00:00
|
|
|
my $len = 20;
|
|
|
|
for(my $i=2; $i<@p; $i++) {
|
2020-04-08 20:03:39 +03:00
|
|
|
if ($p[$i] =~ /^(\S*)\-(.*)$/) {
|
2007-04-12 20:24:50 +00:00
|
|
|
$len += length($2);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$len += length($p[$i]);
|
|
|
|
}
|
|
|
|
}
|
2009-03-06 18:56:11 +00:00
|
|
|
my $fv = $config{$c};
|
|
|
|
my @opts;
|
|
|
|
for(my $i=2; $i<@p; $i++) {
|
2020-04-08 20:03:39 +03:00
|
|
|
($p[$i] =~ /^(\S*)\-(.*)$/) || next;
|
2007-04-12 20:24:50 +00:00
|
|
|
push(@opts, [ $1, $2.($len > 50 ? "<br>" : "") ]);
|
|
|
|
$fv = undef if ($config{$c} eq $1);
|
|
|
|
}
|
2020-04-08 20:03:39 +03:00
|
|
|
push(@opts, [ "free", $p[$#p] !~ /^(\S*)\-(.*)$/ ? $p[$#p]
|
2007-04-12 20:24:50 +00:00
|
|
|
: " " ]);
|
2007-04-24 16:36:10 +00:00
|
|
|
$field = &ui_radio($c, $fv ? "free" : $config{$c}, \@opts)." ".
|
2007-04-12 20:24:50 +00:00
|
|
|
&ui_textbox($c."_free", $fv, 20);
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 12) {
|
|
|
|
# Password field
|
|
|
|
$field = &ui_radio($c."_nochange", 1,
|
|
|
|
[ [ 1, $text{'config_nochange'} ],
|
|
|
|
[ 0, $text{'config_setto'} ] ])." ".
|
|
|
|
&ui_password($c, undef, $p[2] || 40, 0, $p[3]);
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 13) {
|
|
|
|
# Multiple selections from menu
|
2009-03-06 18:56:11 +00:00
|
|
|
my @sel = split(/,/, $config{$c});
|
|
|
|
my @opts;
|
2007-04-12 20:24:50 +00:00
|
|
|
for($i=2; $i<@p; $i++) {
|
2020-04-08 20:03:39 +03:00
|
|
|
$p[$i] =~ /^(\S*)\-(.*)$/;
|
2007-04-12 20:24:50 +00:00
|
|
|
push(@opts, [ $1, $2 ]);
|
|
|
|
}
|
|
|
|
$field = &ui_select($c, \@sel, \@opts, 5, 1);
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 15) {
|
|
|
|
# Input generated by function
|
|
|
|
$module || &error($text{'config_ewebmin'});
|
|
|
|
&foreign_require($module, "config_info.pl");
|
|
|
|
$field = &foreign_call($module, "show_".$p[2],
|
|
|
|
$config{$c}, @p);
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 16) {
|
|
|
|
# Password free text
|
|
|
|
$field = &ui_password($c, undef, $p[2] || 40, 0, $p[3]);
|
|
|
|
}
|
2008-02-08 22:48:02 +00:00
|
|
|
$label = "<a name=$c>$label</a>";
|
2007-04-12 20:24:50 +00:00
|
|
|
print &ui_table_row($label, $field, 1, [ "width=30% nowrap" ]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# parse_config(&config, info-file, [module], [&canconfig], [section])
|
|
|
|
# Updates the specified configuration with values from %in
|
|
|
|
sub parse_config
|
|
|
|
{
|
2009-03-06 18:56:11 +00:00
|
|
|
my ($config, $file, $module, $canconfig, $section) = @_;
|
2007-04-12 20:24:50 +00:00
|
|
|
|
|
|
|
# Read the .info file
|
2009-03-06 18:56:11 +00:00
|
|
|
my (%info, @info_order, $o);
|
2007-04-12 20:24:50 +00:00
|
|
|
&read_file($file, \%info, \@info_order);
|
|
|
|
foreach $o (@lang_order_list) {
|
|
|
|
&read_file("$file.$o", \%info, \@info_order);
|
|
|
|
}
|
|
|
|
@info_order = &unique(@info_order);
|
|
|
|
|
|
|
|
if ($section) {
|
|
|
|
# Limit to settings in one section
|
|
|
|
@info_order = &config_in_section($section, \@info_order, \%info);
|
|
|
|
}
|
|
|
|
|
2022-08-01 20:12:32 +03:00
|
|
|
# If config fields are conditional (not displayed)
|
|
|
|
# make sure to preserve system default values to
|
|
|
|
# prevent changing behaviour of a module
|
|
|
|
if (&foreign_exists($module) &&
|
|
|
|
&foreign_require($module) &&
|
2022-10-01 18:29:39 +03:00
|
|
|
&foreign_defined($module, 'config_pre_load')) {
|
2022-08-01 20:12:32 +03:00
|
|
|
&foreign_call($module, "config_pre_load", \%info, \@info_order);
|
|
|
|
}
|
|
|
|
|
2007-04-12 20:24:50 +00:00
|
|
|
# Actually parse the inputs
|
2009-03-06 18:56:11 +00:00
|
|
|
foreach my $c (@info_order) {
|
2007-04-12 20:24:50 +00:00
|
|
|
next if ($canconfig && !$canconfig->{$c});
|
2009-03-06 18:56:11 +00:00
|
|
|
my @p = split(/,/, $info{$c});
|
2007-04-12 20:24:50 +00:00
|
|
|
if ($p[1] == 14) {
|
|
|
|
$_[2] || &error($text{'config_ewebmin'});
|
|
|
|
&foreign_require($_[2], "config_info.pl");
|
2009-03-06 18:56:11 +00:00
|
|
|
my @newp = &foreign_call($_[2], $p[2]);
|
2007-04-12 20:24:50 +00:00
|
|
|
$newp[0] ||= $p[0];
|
|
|
|
@p = @newp;
|
|
|
|
}
|
|
|
|
if ($p[1] == 16 && $gconfig{'config_16_insecure'}) {
|
|
|
|
# Don't allow mode 16
|
|
|
|
$p[1] = 12;
|
|
|
|
}
|
|
|
|
if ($p[1] == 0 || $p[1] == 7 || $p[1] == 8 || $p[1] == 16) {
|
|
|
|
# Free text input
|
|
|
|
$config->{$c} = $in{$c};
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 1 || $p[1] == 4) {
|
|
|
|
# One of many
|
|
|
|
$config->{$c} = $in{$c};
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 5 || $p[1] == 6) {
|
|
|
|
# User or group
|
|
|
|
$config->{$c} = ($p[2] && $in{$c."_def"} ? "" : $in{$c});
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 2 || $p[1] == 13) {
|
|
|
|
# Many of many
|
|
|
|
$in{$c} =~ s/\0/,/g;
|
|
|
|
$config->{$c} = $in{$c};
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 3) {
|
|
|
|
# Optional free text
|
|
|
|
if ($in{$c."_def"}) { $config->{$c} = ""; }
|
|
|
|
else { $config->{$c} = $in{$c}; }
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 9) {
|
|
|
|
# Multilines of free text
|
2009-03-06 18:56:11 +00:00
|
|
|
my $sp = $p[4] ? eval "\"$p[4]\"" : " ";
|
2007-04-12 20:24:50 +00:00
|
|
|
$in{$c} =~ s/\r//g;
|
|
|
|
$in{$c} =~ s/\n/$sp/g;
|
|
|
|
$in{$c} =~ s/\s+$//;
|
|
|
|
$config->{$c} = $in{$c};
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 10) {
|
|
|
|
# One of many or free text
|
|
|
|
if ($in{$c} eq 'free') {
|
|
|
|
$config->{$c} = $in{$c.'_free'};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$config->{$c} = $in{$c};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 12) {
|
|
|
|
# Optionally changed password
|
|
|
|
if (!$in{"${c}_nochange"}) {
|
|
|
|
$config->{$c} = $in{$c};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 15) {
|
|
|
|
# Parse custom HTML field
|
|
|
|
$_[2] || &error($text{'config_ewebmin'});
|
|
|
|
&foreign_require($_[2], "config_info.pl");
|
|
|
|
$config->{$c} = &foreign_call($_[2], "parse_".$p[2],
|
|
|
|
$config->{$c}, @p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# config_in_section(§ion, &order, &config-info)
|
|
|
|
# Returns a list of config names that are in some section
|
|
|
|
sub config_in_section
|
|
|
|
{
|
2009-03-06 18:56:11 +00:00
|
|
|
my ($section, $info_order, $info) = @_;
|
2007-04-12 20:24:50 +00:00
|
|
|
my @new_order = ( );
|
|
|
|
my $in_section = 0;
|
|
|
|
foreach my $c (@$info_order) {
|
2009-03-06 18:56:11 +00:00
|
|
|
my @p = split(/,/, $info->{$c});
|
2007-04-12 20:24:50 +00:00
|
|
|
if ($p[1] == 11 && $c eq $section) {
|
|
|
|
$in_section = 1;
|
|
|
|
}
|
|
|
|
elsif ($p[1] == 11 && $c ne $section) {
|
|
|
|
$in_section = 0;
|
|
|
|
}
|
|
|
|
elsif ($in_section) {
|
|
|
|
push(@new_order, $c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return @new_order;
|
|
|
|
}
|
|
|
|
|
2021-02-22 15:18:29 +03:00
|
|
|
# save_module_preferences(module, &config)
|
|
|
|
# Check which user preferences can be save for
|
|
|
|
# given module based on module's prefs.info file
|
|
|
|
sub save_module_preferences
|
|
|
|
{
|
|
|
|
my ($module, $curr_config) = @_;
|
|
|
|
my $module_dir = &module_root_directory($module);
|
|
|
|
my $module_prefs_conf = "$module_dir/prefs.info";
|
|
|
|
if (-r $module_prefs_conf) {
|
|
|
|
my %module_prefs_conf_allowed;
|
|
|
|
&read_file($module_prefs_conf, \%module_prefs_conf_allowed);
|
|
|
|
mkdir("$config_directory/$module", 0700);
|
|
|
|
my $user_prefs_file = "$config_directory/$module/prefs.$remote_user";
|
|
|
|
&lock_file($user_prefs_file);
|
|
|
|
if ($module_prefs_conf_allowed{'allowed'} eq "*") {
|
|
|
|
&write_file($user_prefs_file, \%$curr_config);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my %newconfigtmp;
|
|
|
|
foreach my $key (keys %{$curr_config}) {
|
|
|
|
if (grep(/^$key$/, split(",", $module_prefs_conf_allowed{'allowed'}))) {
|
|
|
|
$newconfigtmp->{$key} = $curr_config->{$key};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
&write_file($user_prefs_file, \%$newconfigtmp);
|
|
|
|
}
|
|
|
|
&unlock_file($user_prefs_file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-10 16:57:24 -08:00
|
|
|
# hidden_config_cparams(&in)
|
|
|
|
# Return HTML for hidden inputs for params to pass back to whatever linked
|
|
|
|
# to config.cgi
|
|
|
|
sub hidden_config_cparams
|
|
|
|
{
|
|
|
|
my ($in) = @_;
|
|
|
|
my $rv = "";
|
|
|
|
foreach my $k (keys %$in) {
|
|
|
|
next if ($k !~ /^(_cparam_|_cscript)/);
|
|
|
|
foreach my $v (split(/\0/, $in{$k})) {
|
|
|
|
$rv .= &ui_hidden($k, $v)."\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $rv;
|
|
|
|
}
|
|
|
|
|
2024-04-16 19:49:58 -07:00
|
|
|
# link_config_cparams(module, &in, [add-cparam])
|
2023-11-10 16:57:24 -08:00
|
|
|
# Returns a URL to link to after the config is saved
|
|
|
|
sub link_config_cparams
|
|
|
|
{
|
2024-04-16 19:49:58 -07:00
|
|
|
my ($m, $in, $keep) = @_;
|
2024-04-17 15:33:47 +03:00
|
|
|
my $url = "/$m/";
|
2024-04-16 19:49:58 -07:00
|
|
|
my @w;
|
2023-11-10 16:57:24 -08:00
|
|
|
if ($in->{'_cscript'}) {
|
2024-04-16 19:49:58 -07:00
|
|
|
if ($keep) {
|
2024-04-18 23:26:55 +03:00
|
|
|
push(@w, "_cscript=".&urlize($in->{'_cscript'}));
|
2024-04-16 19:49:58 -07:00
|
|
|
}
|
|
|
|
else {
|
2024-04-17 15:33:47 +03:00
|
|
|
$url .= $in->{'_cscript'};
|
2024-04-16 19:49:58 -07:00
|
|
|
}
|
2023-11-10 16:57:24 -08:00
|
|
|
}
|
|
|
|
foreach my $k (keys %$in) {
|
|
|
|
if ($k =~ /^_cparam_(.*)$/) {
|
|
|
|
$n = $1;
|
|
|
|
foreach my $v (split(/\0/, $in{$k})) {
|
2024-04-18 23:26:55 +03:00
|
|
|
push(@w, &urlize($keep ? $k : $n)."=".&urlize($v));
|
2023-11-10 16:57:24 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (@w) {
|
|
|
|
$url .= "?".join("&", @w);
|
|
|
|
}
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
|
2007-04-12 20:24:50 +00:00
|
|
|
1;
|
2018-09-10 09:40:03 +03:00
|
|
|
|