3 # Drop an existing database
5 require './mysql-lib.pl';
7 &error_setup($text{'ddrop_err'});
8 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
9 $access{'edonly'} && &error($text{'dbase_ecannot'});
12 &execute_sql_logged($master_db, "drop database "."estr($in{'db'}));
13 &webmin_log("delete", "db", $in{'db'});
16 elsif ($in{'empty'}) {
17 # Delete all the tables
18 foreach $t (&list_tables($in{'db'})) {
19 &execute_sql_logged($in{'db'}, "drop table "."estr($t));
21 &webmin_log("delete", "db", $in{'db'});
22 &redirect("edit_dbase.cgi?db=$in{'db'}");
25 # Ask the user if he is sure..
26 &ui_print_header(undef, $text{'ddrop_title'}, "");
27 @tables = &list_tables($in{'db'});
29 foreach $t (@tables) {
30 $d = &execute_sql($in{'db'}, "select count(*) from "."estr($t));
31 $rows += $d->{'data'}->[0]->[0];
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);
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"
43 print "</form></center>\n";
44 &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
45 "", $text{'index_return'});