From fbfffdabe931d704aae420984058e61dc4196b01 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 27 Feb 2007 01:51:52 +0000 Subject: config goes in database --- httemplate/config/config-download.cgi | 14 ++++++++++++++ httemplate/config/config-process.cgi | 12 ++++++++++-- httemplate/config/config-view.cgi | 8 ++++++++ httemplate/config/config.cgi | 6 +++++- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 httemplate/config/config-download.cgi (limited to 'httemplate') diff --git a/httemplate/config/config-download.cgi b/httemplate/config/config-download.cgi new file mode 100644 index 000000000..d4b88ded9 --- /dev/null +++ b/httemplate/config/config-download.cgi @@ -0,0 +1,14 @@ +% +% +%my $conf=new FS::Conf; +% +%http_header('Content-Type' => 'application/x-unknown' ); +% +%die "No configuration variable specified (bad URL)!" # umm +% unless $cgi->keywords; +%my($query) = $cgi->keywords; +%$query =~ /^([\w -\)+-\/@;:?=[\]]+)$/; +%my $name = $1; +% +%http_header('Content-Disposition' => "attachment; filename=$name" ); +% print $conf->config_binary($name); diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index d8f0d8e93..3e49b4f99 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -1,5 +1,4 @@ <%init> - die "access denied\n" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); @@ -28,6 +27,16 @@ foreach my $i ( @config_items ) { } else { $conf->delete($i->key); } + } elsif ( $type eq 'binary' ) { + if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) { + my $fh = $cgi->upload($i->key. $n); + if (defined($fh)) { + local $/; + $conf->set_binary($i->key, <$fh>); + } + }else{ + warn "Condition failed for " . $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) ) { @@ -57,6 +66,5 @@ foreach my $i ( @config_items ) { $conf->touch($_) foreach @touch; $conf->delete($_) foreach @delete; } - <% $cgi->redirect("config-view.cgi") %> diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi index 91ba33769..7f2a1b293 100644 --- a/httemplate/config/config-view.cgi +++ b/httemplate/config/config-view.cgi @@ -42,6 +42,14 @@ no type +% } elsif ( $type eq 'binary' ) { + + + <% $conf->exists($i->key) + ? qq!download! + : 'empty' + %> + % } elsif ( $type eq 'textarea' % || $type eq 'editlist' % || $type eq 'selectmultiple' ) { diff --git a/httemplate/config/config.cgi b/httemplate/config/config.cgi index 6c3a51aca..df9af47a6 100644 --- a/httemplate/config/config.cgi +++ b/httemplate/config/config.cgi @@ -21,7 +21,7 @@ function SafeOnsubmit() { % my $conf = new FS::Conf; my @config_items = $conf->config_items; -
+ % foreach my $section ( qw(required billing username password UI session % shell BIND % ), @@ -61,6 +61,10 @@ function SafeOnsubmit() { no type +% } elsif ( $type eq 'binary' ) { + + + Filename % } elsif ( $type eq 'textarea' ) { -- cgit v1.2.1