Handle hostnames with upper-case letters
[webmin.git] / mysql / drop_dbase.cgi
1 #!/usr/local/bin/perl
2 # drop_dbase.cgi
3 # Drop an existing database
4
5 require './mysql-lib.pl';
6 &ReadParse();
7 &error_setup($text{'ddrop_err'});
8 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
9 $access{'edonly'} && &error($text{'dbase_ecannot'});
10 if ($in{'confirm'}) {
11         # Drop the database
12         &execute_sql_logged($master_db, "drop database ".&quotestr($in{'db'}));
13         &webmin_log("delete", "db", $in{'db'});
14         &redirect("");
15         }
16 elsif ($in{'empty'}) {
17         # Delete all the tables
18         foreach $t (&list_tables($in{'db'})) {
19                 &execute_sql_logged($in{'db'}, "drop table ".&quotestr($t));
20                 }
21         &webmin_log("delete", "db", $in{'db'});
22         &redirect("edit_dbase.cgi?db=$in{'db'}");
23         }
24 else {
25         # Ask the user if he is sure..
26         &ui_print_header(undef, $text{'ddrop_title'}, "");
27         @tables = &list_tables($in{'db'});
28         $rows = 0;
29         foreach $t (@tables) {
30                 $d = &execute_sql($in{'db'}, "select count(*) from ".&quotestr($t));
31                 $rows += $d->{'data'}->[0]->[0];
32                 }
33
34         print "<center><b>",&text('ddrop_rusure', "<tt>$in{'db'}</tt>",
35                                   scalar(@tables), $rows),"\n";
36         print $text{'ddrop_mysql'},"\n" if ($in{'db'} eq $master_db);
37         print "</b><p>\n";
38         print "<form action=drop_dbase.cgi>\n";
39         print "<input type=hidden name=db value='$in{'db'}'>\n";
40         print "<input type=submit name=confirm value='$text{'ddrop_ok'}'>\n";
41         print "<input type=submit name=empty value='$text{'ddrop_empty'}'>\n"
42                 if (@tables);
43         print "</form></center>\n";
44         &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
45                 "", $text{'index_return'});
46         }
47
48