Handle hostnames with upper-case letters
[webmin.git] / postgresql / newdb_form.cgi
1 #!/usr/local/bin/perl
2 # newdb_form.cgi
3 # Display a form for creating a new database
4
5 require './postgresql-lib.pl';
6 $access{'create'} || &error($text{'newdb_ecannot'});
7 &ui_print_header(undef, $text{'newdb_title'}, "", "newdb_form");
8
9 # Start of form block
10 print &ui_form_start("newdb.cgi", "post");
11 print &ui_table_start($text{'newdb_header'}, undef, 2);
12
13 # Database name
14 print &ui_table_row($text{'newdb_db'},
15         &ui_textbox("db", undef, 40));
16
17 if (&get_postgresql_version() >= 7) {
18         # Owner option
19         $u = &execute_sql($config{'basedb'}, "select usename from pg_shadow");
20         @users = map { $_->[0] } @{$u->{'data'}};
21         print &ui_table_row($text{'newdb_user'},
22                 &ui_radio("user_def", 1,
23                     [ [ 1, $text{'default'} ],
24                       [ 0, &ui_select("user", undef, \@users) ] ]));
25         }
26
27 if (&get_postgresql_version() >= 8) {
28         # Encoding option
29         print &ui_table_row($text{'newdb_encoding'},
30                 &ui_opt_textbox("encoding", undef, 20, $text{'default'}));
31         }
32
33 # Path to database file
34 print &ui_table_row($text{'newdb_path'},
35         &ui_opt_textbox("path", undef, 40, $text{'default'}));
36
37 # Template DB
38 print &ui_table_row($text{'newdb_template'},
39         &ui_select("template", undef,
40                    [ [ undef, "<".$text{'newdb_notemplate'}.">" ],
41                      &list_databases() ]));
42
43 print &ui_table_end();
44 print &ui_form_end([ [ undef, $text{'create'} ] ]);
45
46 &ui_print_footer("", $text{'index_return'});
47