Handle hostnames with upper-case letters
[webmin.git] / acl / edit_sql.cgi
1 #!/usr/local/bin/perl
2 # Show form for an external user / group database
3
4 require './acl-lib.pl';
5 $access{'sql'} || &error($text{'sql_ecannot'});
6 &ui_print_header(undef, $text{'sql_title'}, "");
7 &get_miniserv_config(\%miniserv);
8
9 print &ui_form_start("save_sql.cgi");
10 print &ui_table_start($text{'sql_header'}, undef, 2);
11
12 ($proto, $user, $pass, $host, $prefix, $args) =
13         &split_userdb_string($miniserv{'userdb'});
14
15 # Build inputs for MySQL backend
16 @mysqlgrid = ( );
17 push(@mysqlgrid,
18      $text{'sql_host'},
19      &ui_textbox("mysql_host", $proto eq "mysql" ? $host : "", 30));
20 push(@mysqlgrid,
21      $text{'sql_user'},
22      &ui_textbox("mysql_user", $proto eq "mysql" ? $user : "", 30));
23 push(@mysqlgrid,
24      $text{'sql_pass'},
25      &ui_textbox("mysql_pass", $proto eq "mysql" ? $pass : "", 30));
26 push(@mysqlgrid,
27      $text{'sql_db'},
28      &ui_textbox("mysql_db", $proto eq "mysql" ? $prefix : "", 30));
29 $mysqlgrid = &ui_grid_table(\@mysqlgrid, 2, 100);
30
31 # Build inputs for PostgreSQL backend
32 @postgresqlgrid = ( );
33 push(@postgresqlgrid,
34      $text{'sql_host'},
35      &ui_textbox("postgresql_host", $proto eq "postgresql" ? $host : "", 30));
36 push(@postgresqlgrid,
37      $text{'sql_user'},
38      &ui_textbox("postgresql_user", $proto eq "postgresql" ? $user : "", 30));
39 push(@postgresqlgrid,
40      $text{'sql_pass'},
41      &ui_textbox("postgresql_pass", $proto eq "postgresql" ? $pass : "", 30));
42 push(@postgresqlgrid,
43      $text{'sql_db'},
44      &ui_textbox("postgresql_db", $proto eq "postgresql" ? $prefix : "", 30));
45 $postgresqlgrid = &ui_grid_table(\@postgresqlgrid, 2, 100);
46
47 # Build inputs for LDAP backend
48 @ldapgrid = ( );
49 push(@ldapgrid,
50      $text{'sql_host'},
51      &ui_textbox("ldap_host", $proto eq "ldap" ? $host : "", 30));
52 push(@ldapgrid,
53      $text{'sql_ssl'},
54      &ui_radio("ldap_ssl", $args->{'scheme'} eq 'ldaps' ? 1 :
55                            $args->{'tls'} ? 2 : 0,
56                [ [ 0, $text{'sql_ssl0'} ],
57                  [ 1, $text{'sql_ssl1'} ],
58                  [ 2, $text{'sql_ssl2'} ] ]));
59 push(@ldapgrid,
60      $text{'sql_user'},
61      &ui_textbox("ldap_user", $proto eq "ldap" ? $user : "", 30));
62 push(@ldapgrid,
63      $text{'sql_pass'},
64      &ui_textbox("ldap_pass", $proto eq "ldap" ? $pass : "", 30));
65 push(@ldapgrid,
66      $text{'sql_prefix'},
67      &ui_textbox("ldap_prefix", $proto eq "ldap" ? $prefix : "", 30));
68 push(@ldapgrid,
69      $text{'sql_userclass'},
70      &ui_textbox("ldap_userclass", $proto eq "ldap" && $args->{'userclass'} ?
71                                      $args->{'userclass'} : "webminUser", 30));
72 push(@ldapgrid,
73      $text{'sql_groupclass'},
74      &ui_textbox("ldap_groupclass", $proto eq "ldap" && $args->{'groupclass'} ?
75                                      $args->{'groupclass'} : "webminGroup",30));
76 push(@ldapgrid,
77      &ui_button($text{'sql_schema'}, undef, 0,
78                 "onClick='window.location=\"schema.cgi\"'"), "");
79 $ldapgrid = &ui_grid_table(\@ldapgrid, 2, 100);
80
81 print &ui_table_row(undef,
82         &ui_radio_table("proto", $proto,
83                 [ [ '', $text{'sql_none'} ],
84                   [ 'mysql', $text{'sql_mysql'}, $mysqlgrid ],
85                   [ 'postgresql', $text{'sql_postgresql'}, $postgresqlgrid ],
86                   [ 'ldap', $text{'sql_ldap'}, $ldapgrid ] ]), 2);
87
88 print &ui_table_row(undef,
89         &ui_radio("addto", int($miniserv{'userdb_addto'}),
90                   [ [ 0, $text{'sql_addto0'} ],
91                     [ 1, $text{'sql_addto1'} ] ]), 2);
92
93 print &ui_table_end();
94 print &ui_form_end([ [ undef, $text{'save'} ] ]);
95
96 &ui_print_footer("", $text{'index_return'});