mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Compare commits
9 Commits
dev/patch-
...
dev/config
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3885773f6e | ||
|
|
dc3ed53c43 | ||
|
|
24ca182b18 | ||
|
|
54c7856672 | ||
|
|
9b3fb73aea | ||
|
|
692c9cc5e1 | ||
|
|
62bcd25eb9 | ||
|
|
a6d23844ce | ||
|
|
a9cd02aa6d |
@@ -407,5 +407,89 @@ if (-r $module_prefs_conf) {
|
||||
}
|
||||
}
|
||||
|
||||
# read_config_params(url, insert-prefix)
|
||||
# Parses the URL parameters from a URL, and returns a hash ref
|
||||
sub read_config_params
|
||||
{
|
||||
my ($url, $pref) = @_;
|
||||
# Extract the part of the URL after the question mark
|
||||
my ($query_string) = $url =~ /\?(.*)$/;
|
||||
my %params;
|
||||
|
||||
# Split the query string on '&' to get the individual key-value pairs
|
||||
for my $pair (split(/&/, $query_string)) {
|
||||
my ($key, $value) = split /=/, $pair;
|
||||
$value = &un_urlize($value);
|
||||
my $param_prefix = $pref ? "_cparam-" : "";
|
||||
$params{"$param_prefix$key"} = $value;
|
||||
}
|
||||
return \%params;
|
||||
}
|
||||
|
||||
# print_config_posted_params()
|
||||
# Prints hidden fields for all the parameters in the referrer URL
|
||||
sub print_config_posted_params
|
||||
{
|
||||
my $env_referer = $ENV{'HTTP_REFERER'};
|
||||
my $params_referer = &read_config_params($env_referer);
|
||||
my $params_url = &read_config_params($ENV{'REQUEST_URI'});
|
||||
my $params = { %$params_referer, %$params_url };
|
||||
my @params;
|
||||
if (%$params) {
|
||||
foreach my $param (keys %{$params}) {
|
||||
my $param_prefix = "_cparam-";
|
||||
if ($param =~ /section|module|mode|section_next|nnext|nprev|xnavigation/ ||
|
||||
!$params->{$param} || $env_referer =~ /$param_prefix$param=/ ||
|
||||
$params_url =~ /$param_prefix$param=/ || &indexof($param, @params) > -1) {
|
||||
next;
|
||||
}
|
||||
$param_prefix = "" if ($param =~ /^$param_prefix/);
|
||||
push(@params, $param);
|
||||
print &ui_hidden("$param_prefix$param", $params->{$param}), "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# get_query_config_posted_params(url)
|
||||
# Returns the currently posted parameters from the URL
|
||||
sub get_query_config_posted_params
|
||||
{
|
||||
my ($url) = @_;
|
||||
foreach my $key (keys %in) {
|
||||
if ($key =~ /^_cparam-/) {
|
||||
my $value = $in{$key};
|
||||
if ($value) {
|
||||
my $delimiter = ($url =~ /\?/) ? "&" : '?';
|
||||
$url .= "$delimiter$key=$value"
|
||||
}
|
||||
}
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
# get_config_posted_params(target)
|
||||
# Returns the referrer URL with all the parameters from the POST request
|
||||
sub get_config_posted_params
|
||||
{
|
||||
my ($target) = @_;
|
||||
my $param_prefix = "_cparam-";
|
||||
my $env_referer = $ENV{'HTTP_REFERER'};
|
||||
my $env_referer_prefixed = ($env_referer =~ /$param_prefix/ ? 1 : 0);
|
||||
my $params_referer = &read_config_params($env_referer, !$env_referer_prefixed);
|
||||
my %keys = (%in, %$params_referer);
|
||||
foreach my $key (keys %keys) {
|
||||
if ($key =~ /^$param_prefix(.*)/) {
|
||||
my $k = $1;
|
||||
my $v = $keys{$key};
|
||||
if ($v && $target !~ /$k=/) {
|
||||
my $delimiter = ($target =~ /\?/) ? "&" : '?';
|
||||
$v = &urlize($v) if ($v =~ /^\//);
|
||||
$target .= "$delimiter$k=$v"
|
||||
}
|
||||
}
|
||||
}
|
||||
return $target;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ else {
|
||||
|
||||
print &ui_form_start("config_save.cgi", "post");
|
||||
print &ui_hidden("module", $m),"\n";
|
||||
&print_config_posted_params();
|
||||
print &ui_table_start(&text('config_header', $module_info{'desc'}),
|
||||
"width=100%", 2);
|
||||
&read_file("$config_directory/$m/config", \%newconfig);
|
||||
@@ -51,5 +52,5 @@ if (!$func) {
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ "save", $text{'save'} ] ]);
|
||||
|
||||
&ui_print_footer("/$m", $text{'index'});
|
||||
&ui_print_footer(&get_config_posted_params("/$m/"), $text{'index'});
|
||||
|
||||
|
||||
@@ -56,5 +56,5 @@ if (&foreign_check("webmin")) {
|
||||
}
|
||||
|
||||
&webmin_log("_config_", undef, undef, \%in, $m);
|
||||
&redirect("/$m/");
|
||||
&redirect(&get_config_posted_params("/$m/"));
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ if (@sections > 1) {
|
||||
print &ui_form_start("config.cgi");
|
||||
print &ui_hidden("module", $m),"\n";
|
||||
print $text{'config_section'},"\n";
|
||||
&print_config_posted_params();
|
||||
print &ui_select("section", $in{'section'}, \@sections,
|
||||
1, 0, 0, 0, "onChange='form.submit()'");
|
||||
print &ui_submit($text{'config_change'});
|
||||
@@ -76,6 +77,7 @@ if (@sections > 1) {
|
||||
print &ui_form_start("config_save.cgi", "post");
|
||||
print &ui_hidden("module", $m),"\n";
|
||||
print &ui_hidden("section", $in{'section'}),"\n";
|
||||
&print_config_posted_params();
|
||||
if ($s) {
|
||||
# Find next section
|
||||
$idx = &indexof($s, @sections);
|
||||
@@ -122,6 +124,6 @@ if ($m eq "virtual-server") {
|
||||
&ui_print_footer("/right.cgi", $text{'config_return'});
|
||||
}
|
||||
else {
|
||||
&ui_print_footer("/$m", $text{'index'});
|
||||
&ui_print_footer(&get_config_posted_params("/$m/"), $text{'index'});
|
||||
}
|
||||
|
||||
|
||||
@@ -41,13 +41,14 @@ if (&foreign_require($m) &&
|
||||
}
|
||||
|
||||
&webmin_log("_config_", undef, undef, \%in, $m);
|
||||
my $redirect_url;
|
||||
if ($in{'save_next'}) {
|
||||
&redirect("config.cgi?module=$in{'module'}§ion=$in{'section_next'}");
|
||||
$redirect_url = &get_query_config_posted_params("config.cgi?module=$in{'module'}§ion=$in{'section_next'}");
|
||||
}
|
||||
elsif ($m eq "virtual-server") {
|
||||
&redirect("/right.cgi");
|
||||
$redirect_url = "/right.cgi";
|
||||
}
|
||||
else {
|
||||
&redirect("/$m/");
|
||||
$redirect_url = &get_config_posted_params("/$m/");
|
||||
}
|
||||
|
||||
&redirect($redirect_url);
|
||||
|
||||
Reference in New Issue
Block a user