Handle hostnames with upper-case letters
[webmin.git] / mysql / table_form.cgi
1 #!/usr/local/bin/perl
2 # table_form.cgi
3 # Display a form for creating a table
4
5 require './mysql-lib.pl';
6 &ReadParse();
7 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
8
9 # Redirect to other pages depending on button
10 if ($in{'addview'}) {
11         &redirect("edit_view.cgi?new=1&db=".&urlize($in{'db'}));
12         return;
13         }
14 elsif ($in{'dropdb'}) {
15         &redirect("drop_dbase.cgi?db=".&urlize($in{'db'}));
16         return;
17         }
18 elsif ($in{'backupdb'}) {
19         &redirect("backup_form.cgi?db=".&urlize($in{'db'}));
20         return;
21         }
22 elsif ($in{'exec'}) {
23         &redirect("exec_form.cgi?db=".&urlize($in{'db'}));
24         return;
25         }
26
27 $access{'edonly'} && &error($text{'dbase_ecannot'});
28 $desc = "<tt>$in{'db'}</tt>";
29 &ui_print_header($desc, $text{'table_title2'}, "", "table_form");
30
31 print &ui_form_start("create_table.cgi", "post");
32 print &ui_hidden("db", $in{'db'}),"\n";
33 print &ui_table_start($text{'table_header2'}, undef, 2);
34
35 print &ui_table_row($text{'table_name'},
36                     &ui_textbox("name", undef, 30));
37
38 @dbs = grep { &can_edit_db($_) } &list_databases();
39 if (@dbs > $max_dbs) {
40         # Enter source table name manually
41         print &ui_table_row($text{'table_copy2'},
42                 &ui_select("copydb", $in{'db'}, \@dbs).
43                 " $text{'table_copy2t'} ".
44                 &ui_textbox("copytable", undef, 20));
45         }
46 else {
47         # Show all tables in all DBs
48         foreach $d (@dbs) {
49                 foreach $t (&list_tables($d, 1)) {
50                         push(@tables, [ "$d.$t" ]);
51                         }
52                 }
53         print &ui_table_row($text{'table_copy'},
54                             &ui_select("copy", undef,
55                                        [ [ "", $text{'table_copynone'} ],
56                                          @tables ]));
57         }
58
59 print &ui_table_row($text{'table_type'},
60                     &ui_select("type", "",
61                       [ [ "", $text{'default'} ], [ "isam" ], [ "myisam" ],
62                         [ "heap" ], [ "merge" ], [ "innodb" ], [ "ndbcluster" ]
63                       ]));
64
65 $out = &capture_function_output(\&show_table_form, $in{"fields"} || 4);
66 print &ui_table_row(undef, $out, 2);
67
68 print &ui_table_end();
69 print &ui_form_end([ [ "create", $text{'create'} ] ]);
70
71 &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
72         "", $text{'index_return'});
73