2 # Drop multiple tables, views and indexes, after asking for confirmation
4 require './mysql-lib.pl';
6 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
7 $access{'edonly'} && &error($text{'dbase_ecannot'});
8 @tables = split(/\0/, $in{'d'});
9 @tables || &error($text{'tdrops_enone'});
12 # Drop the tables, views and indexes (tables last)
13 &error_setup($text{'tdrops_err'});
14 foreach $t (@tables) {
15 if ($t =~ /^\!(.*)$/) {
16 $str = &index_structure($in{'db'}, $1);
17 &execute_sql_logged($in{'db'}, "drop index "."estr($1)." on ".quotestr($str->{'table'}));
19 elsif ($t =~ /^\*(.*)$/) {
20 &execute_sql_logged($in{'db'}, "drop view "."estr($1));
27 &execute_sql_logged($in{'db'}, "drop table "."estr($t));
29 &webmin_log("delete", "tables", scalar(@tables), \%in);
30 &redirect("edit_dbase.cgi?db=$in{'db'}");
33 # Ask the user if he is sure..
34 &ui_print_header(undef, $text{'tdrops_title'}, "");
35 foreach $t (@tables) {
36 if ($t !~ /^\!/ && $t !~ /^\*/) {
37 $d = &execute_sql($in{'db'},
38 "select count(*) from "."estr($t));
39 $rows += $d->{'data'}->[0]->[0];
43 $msg = defined($rows) ? 'tdrops_rusure' : 'tdrops_rusure2';
44 print "<center><b>", &text($msg, scalar(@tables),
45 "<tt>$in{'db'}</tt>", $rows),"</b><p>\n";
46 print "<form action=drop_tables.cgi>\n";
47 print "<input type=hidden name=db value='$in{'db'}'>\n";
48 print "<input type=submit name=confirm value='$text{'tdrops_ok'}'>\n";
49 foreach $t (@tables) {
50 print &ui_hidden("d", $t),"\n";
52 print "</form></center>\n";
54 "edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
55 "", $text{'index_return'});