diff options
Diffstat (limited to 'httemplate/config')
-rw-r--r-- | httemplate/config/config-process.cgi | 45 | ||||
-rw-r--r-- | httemplate/config/config-view.cgi | 49 | ||||
-rw-r--r-- | httemplate/config/config.cgi | 62 |
3 files changed, 156 insertions, 0 deletions
diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi new file mode 100644 index 000000000..a296abfe4 --- /dev/null +++ b/httemplate/config/config-process.cgi @@ -0,0 +1,45 @@ +<% + 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); + } + } else { + } + $n++; + } + # warn @touch; + $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 new file mode 100644 index 000000000..225c29507 --- /dev/null +++ b/httemplate/config/config-view.cgi @@ -0,0 +1,49 @@ +<!-- mason kludge --> +<%= header('View Configuration', menubar( 'Main Menu' => $p, + 'Edit Configuration' => 'config.cgi' ) ) %> + +<% my $conf = new FS::Conf; my @config_items = $conf->config_items; %> + +<% foreach my $section ( qw(required billing username password UI session + shell mail radius apache BIND + ), + '', 'depreciated') { %> + <%= table("#cccccc", 2) %> + <tr> + <th colspan="2" bgcolor="#dcdcdc"> + <%= ucfirst($section || 'unclassified') %> configuration options + </th> + </tr> + <% foreach my $i (grep $_->section eq $section, @config_items) { %> + <tr> + <td><a name="<%= $i->key %>"> + <b><%= $i->key %></b> - <%= $i->description %> + </a></td> + <td><table border=0> + <% foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { + my $n = 0; %> + <% if ( $type eq '' ) { %> + <tr><td><font color="#ff0000">no type</font></td></tr> + <% } elsif ( $type eq 'textarea' ) { %> + <tr><td bgcolor="#ffffff"> +<pre> +<%= encode_entities(join("\n", $conf->config($i->key) ) ) %> +</pre> + </td></tr> + <% } elsif ( $type eq 'checkbox' ) { %> + <tr><td bgcolor="#<%= $conf->exists($i->key) ? '00ff00">YES' : 'ff0000">NO' %></td></tr> + <% } elsif ( $type eq 'text' || $type eq 'select' ) { %> + <tr><td bgcolor="#ffffff"><%= $conf->exists($i->key) ? $conf->config($i->key) : '' %></td></tr> + <% } else { %> + <tr><td> + <font color="#ff0000">unknown type <%= $type %></font> + </td></tr> + <% } %> + <% $n++; } %> + </table></td> + </tr> + <% } %> + </table><br><br> +<% } %> + +</body></html> diff --git a/httemplate/config/config.cgi b/httemplate/config/config.cgi new file mode 100644 index 000000000..f640d0b5e --- /dev/null +++ b/httemplate/config/config.cgi @@ -0,0 +1,62 @@ +<!-- mason kludge --> +<%= header('Edit Configuration', menubar( 'Main Menu' => $p ) ) %> + +<% my $conf = new FS::Conf; my @config_items = $conf->config_items; %> + +<form action="config-process.cgi" METHOD="POST"> + +<% foreach my $section ( qw(required billing username password UI session + shell mail radius apache BIND + ), + '', 'depreciated') { %> + <%= table("#cccccc", 2) %> + <tr> + <th colspan="2" bgcolor="#dcdcdc"> + <%= ucfirst($section || 'unclassified') %> configuration options + </th> + </tr> + <% foreach my $i (grep $_->section eq $section, @config_items) { %> + <tr> + <td> + <% my $n = 0; + foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { + #warn $i->key unless defined($type); + %> + <% if ( $type eq '' ) { %> + <font color="#ff0000">no type</font> + <% } elsif ( $type eq 'textarea' ) { %> + <textarea name="<%= $i->key. $n %>" rows=5><%= join("\n", $conf->config($i->key) ) %></textarea> + <% } elsif ( $type eq 'checkbox' ) { %> + <input name="<%= $i->key. $n %>" type="checkbox" value="1"<%= $conf->exists($i->key) ? ' CHECKED' : '' %>> + <% } elsif ( $type eq 'text' ) { %> + <input name="<%= $i->key. $n %>" type="<%= $type %>" value="<%= $conf->exists($i->key) ? $conf->config($i->key) : '' %>"> + <% } elsif ( $type eq 'select' ) { %> + <select name="<%= $i->key. $n %>"> + <% my %saw; + foreach my $value ( "", @{$i->select_enum} ) { + local($^W)=0; next if $saw{$value}++; %> + <option value="<%= $value %>"<%= $value eq $conf->config($i->key) ? ' SELECTED' : '' %>><%= $value %> + <% } %> + <% if ( $conf->exists($i->key) && $conf->config($i->key) && ! grep { $conf->config($i->key) eq $_ } @{$i->select_enum}) { %> + <option value=<%= $conf->config($i->key) %> SELECTED><%= conf->config($i->key) %> + <% } %> + <% } else { %> + <font color="#ff0000">unknown type <%= $type %></font> + <% } %> + <% $n++; } %> + </td> + <td><a name="<%= $i->key %>"> + <b><%= $i->key %></b> - <%= $i->description %> + </a></td> + </tr> + <% } %> + </table><br><br> +<% } %> + +You may need to restart Apache and/or freeside-queued for configuration +changes to take effect.<BR> + +<input type="submit" value="Apply changes"> +</form> + +</body></html> |