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