diff options
author | jeff <jeff> | 2007-02-27 01:51:52 +0000 |
---|---|---|
committer | jeff <jeff> | 2007-02-27 01:51:52 +0000 |
commit | fbfffdabe931d704aae420984058e61dc4196b01 (patch) | |
tree | 20b82398f278cb8a0aebd47e1beb433bba660e03 /httemplate/config | |
parent | 1d719ccff55b1a82208fdf44b6dcd2da96b3c42e (diff) |
config goes in database
Diffstat (limited to 'httemplate/config')
-rw-r--r-- | httemplate/config/config-download.cgi | 14 | ||||
-rw-r--r-- | httemplate/config/config-process.cgi | 12 | ||||
-rw-r--r-- | httemplate/config/config-view.cgi | 8 | ||||
-rw-r--r-- | httemplate/config/config.cgi | 6 |
4 files changed, 37 insertions, 3 deletions
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; } - </%init> <% $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 @@ <tr> <td><font color="#ff0000">no type</font></td> </tr> +% } elsif ( $type eq 'binary' ) { + + <tr> + <% $conf->exists($i->key) + ? qq!<a href="config-download.cgi?!. $i->key. qq!">download</a>! + : 'empty' + %> + </tr> % } 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; -<form name="OneTrueForm" action="config-process.cgi" METHOD="POST" onSubmit="SafeOnsubmit()"> +<form name="OneTrueForm" action="config-process.cgi" METHOD="POST" enctype="multipart/form-data" onSubmit="SafeOnsubmit()"> % foreach my $section ( qw(required billing username password UI session % shell BIND % ), @@ -61,6 +61,10 @@ function SafeOnsubmit() { <font color="#ff0000">no type</font> +% } elsif ( $type eq 'binary' ) { + + + Filename <input type="file" name="<% $i->key. $n %>"> % } elsif ( $type eq 'textarea' ) { |