From 3ce7691203a7737406bf2d4442f7fd84b81f847e Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 23 Aug 2006 22:25:39 +0000 Subject: Will things ever be the same again? It's the final masonize --- httemplate/config/config-process.cgi | 101 ++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 50 deletions(-) (limited to 'httemplate/config/config-process.cgi') diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index 259713260..fe04b324c 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -1,51 +1,52 @@ -<% - my $conf = new FS::Conf; - $FS::Conf::DEBUG = 1; - my @config_items = $conf->config_items; +% +% my $conf = new FS::Conf; +% $FS::Conf::DEBUG = 1; +% my @config_items = $conf->config_items; +% +% foreach my $i ( @config_items ) { +% my @touch = (); +% my @delete = (); +% my $n = 0; +% foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { +% if ( $type eq '' ) { +% } elsif ( $type eq 'textarea' ) { +% if ( $cgi->param($i->key. $n) ne '' ) { +% my $value = $cgi->param($i->key. $n); +% $value =~ s/\r\n/\n/g; #browsers? +% $conf->set($i->key, $value); +% } else { +% $conf->delete($i->key); +% } +% } elsif ( $type eq 'checkbox' ) { +%# if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) { +% if ( defined $cgi->param($i->key. $n) ) { +% #$conf->touch($i->key); +% push @touch, $i->key; +% } else { +% #$conf->delete($i->key); +% push @delete, $i->key; +% } +% } elsif ( $type eq 'text' || $type eq 'select' ) { +% if ( $cgi->param($i->key. $n) ne '' ) { +% $conf->set($i->key, $cgi->param($i->key. $n)); +% } else { +% $conf->delete($i->key); +% } +% } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) { +% if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) { +% $conf->set($i->key, join("\n", @{[ $cgi->param($i->key. $n) ]} )); +% } else { +% $conf->delete($i->key); +% } +% } else { +% } +% $n++; +% } +% # warn @touch; +% $conf->touch($_) foreach @touch; +% $conf->delete($_) foreach @delete; +% } +% +% - foreach my $i ( @config_items ) { - my @touch = (); - my @delete = (); - my $n = 0; - foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { - if ( $type eq '' ) { - } elsif ( $type eq 'textarea' ) { - if ( $cgi->param($i->key. $n) ne '' ) { - my $value = $cgi->param($i->key. $n); - $value =~ s/\r\n/\n/g; #browsers? - $conf->set($i->key, $value); - } else { - $conf->delete($i->key); - } - } elsif ( $type eq 'checkbox' ) { -# if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) { - if ( defined $cgi->param($i->key. $n) ) { - #$conf->touch($i->key); - push @touch, $i->key; - } else { - #$conf->delete($i->key); - push @delete, $i->key; - } - } elsif ( $type eq 'text' || $type eq 'select' ) { - if ( $cgi->param($i->key. $n) ne '' ) { - $conf->set($i->key, $cgi->param($i->key. $n)); - } else { - $conf->delete($i->key); - } - } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) { - if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) { - $conf->set($i->key, join("\n", @{[ $cgi->param($i->key. $n) ]} )); - } else { - $conf->delete($i->key); - } - } else { - } - $n++; - } - # warn @touch; - $conf->touch($_) foreach @touch; - $conf->delete($_) foreach @delete; - } - -%> -<%= $cgi->redirect("config-view.cgi") %> +<% $cgi->redirect("config-view.cgi") %> -- cgit v1.2.1 From 514bcfc98bba47b1cc0a117fcd1f1ab5c21b9f65 Mon Sep 17 00:00:00 2001 From: lawrence Date: Thu, 31 Aug 2006 21:26:55 +0000 Subject: make select-sub parameters work --- httemplate/config/config-process.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/config/config-process.cgi') diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index fe04b324c..a78f3978c 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -26,7 +26,7 @@ % #$conf->delete($i->key); % push @delete, $i->key; % } -% } elsif ( $type eq 'text' || $type eq 'select' ) { +% } elsif ( $type eq 'text' || $type eq 'select' || $type eq 'select-sub' ) { % if ( $cgi->param($i->key. $n) ne '' ) { % $conf->set($i->key, $cgi->param($i->key. $n)); % } else { -- cgit v1.2.1 From e75e410d0cdc5ca62af1888c3cb75163ca22d2ad Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 29 Jan 2007 23:16:18 +0000 Subject: putting the C in ACL --- httemplate/config/config-process.cgi | 110 +++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 50 deletions(-) (limited to 'httemplate/config/config-process.cgi') diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index a78f3978c..d8f0d8e93 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -1,52 +1,62 @@ -% -% my $conf = new FS::Conf; -% $FS::Conf::DEBUG = 1; -% my @config_items = $conf->config_items; -% -% foreach my $i ( @config_items ) { -% my @touch = (); -% my @delete = (); -% my $n = 0; -% foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { -% if ( $type eq '' ) { -% } elsif ( $type eq 'textarea' ) { -% if ( $cgi->param($i->key. $n) ne '' ) { -% my $value = $cgi->param($i->key. $n); -% $value =~ s/\r\n/\n/g; #browsers? -% $conf->set($i->key, $value); -% } else { -% $conf->delete($i->key); -% } -% } elsif ( $type eq 'checkbox' ) { -%# if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) { -% if ( defined $cgi->param($i->key. $n) ) { -% #$conf->touch($i->key); -% push @touch, $i->key; -% } else { -% #$conf->delete($i->key); -% push @delete, $i->key; -% } -% } elsif ( $type eq 'text' || $type eq 'select' || $type eq 'select-sub' ) { -% if ( $cgi->param($i->key. $n) ne '' ) { -% $conf->set($i->key, $cgi->param($i->key. $n)); -% } else { -% $conf->delete($i->key); -% } -% } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) { -% if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) { -% $conf->set($i->key, join("\n", @{[ $cgi->param($i->key. $n) ]} )); -% } else { -% $conf->delete($i->key); -% } -% } else { -% } -% $n++; -% } -% # warn @touch; -% $conf->touch($_) foreach @touch; -% $conf->delete($_) foreach @delete; -% } -% -% +<%init> +die "access denied\n" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +# errant GET/POST protection +my $Vars = scalar($cgi->Vars); +my $num_Vars = scalar(keys %$Vars); +die "only received $num_Vars params; errant or truncated GET/POST?". + " aborting - not updating config\n" + unless $num_Vars > 100; + +my $conf = new FS::Conf; +$FS::Conf::DEBUG = 1; +my @config_items = $conf->config_items; + +foreach my $i ( @config_items ) { + my @touch = (); + my @delete = (); + my $n = 0; + foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { + if ( $type eq '' ) { + } elsif ( $type eq 'textarea' ) { + if ( $cgi->param($i->key. $n) ne '' ) { + my $value = $cgi->param($i->key. $n); + $value =~ s/\r\n/\n/g; #browsers? + $conf->set($i->key, $value); + } else { + $conf->delete($i->key); + } + } elsif ( $type eq 'checkbox' ) { +# if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) { + if ( defined $cgi->param($i->key. $n) ) { + #$conf->touch($i->key); + push @touch, $i->key; + } else { + #$conf->delete($i->key); + push @delete, $i->key; + } + } elsif ( $type eq 'text' || $type eq 'select' || $type eq 'select-sub' ) { + if ( $cgi->param($i->key. $n) ne '' ) { + $conf->set($i->key, $cgi->param($i->key. $n)); + } else { + $conf->delete($i->key); + } + } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) { + if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) { + $conf->set($i->key, join("\n", @{[ $cgi->param($i->key. $n) ]} )); + } else { + $conf->delete($i->key); + } + } else { + } + $n++; + } + # warn @touch; + $conf->touch($_) foreach @touch; + $conf->delete($_) foreach @delete; +} + + <% $cgi->redirect("config-view.cgi") %> -- cgit v1.2.1