2007-04-12 20:24:50 +00:00
|
|
|
#!/usr/local/bin/perl
|
|
|
|
# Display all existing databases
|
|
|
|
|
|
|
|
require './mysql-lib.pl';
|
|
|
|
&ReadParse();
|
|
|
|
|
|
|
|
# Check for MySQL programs
|
2013-08-14 13:59:37 -07:00
|
|
|
if ($config{'start_cmd'} =~ /^(\S+)/ && &is_mysql_local()) {
|
2013-03-16 22:41:24 -07:00
|
|
|
$start = $1;
|
|
|
|
}
|
2007-04-12 20:24:50 +00:00
|
|
|
foreach $p ( [ $config{'mysqladmin'}, 'index_eadmin', 'index_mysqladmin' ],
|
|
|
|
[ $config{'mysql'}, 'index_esql', 'index_mysql' ],
|
2013-03-16 22:41:24 -07:00
|
|
|
[ $config{'mysqlshow'}, 'index_eshow', 'index_mysqlshow' ],
|
|
|
|
$start ? ( [ $start, 'index_estart', 'index_mysqlstart' ] )
|
|
|
|
: ( )) {
|
|
|
|
if (!&has_command($p->[0])) {
|
2007-04-12 20:24:50 +00:00
|
|
|
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
|
|
|
|
&help_search_link("mysql", "man", "doc", "google"));
|
|
|
|
print &text($p->[1], "<tt>$p->[0]</tt>",
|
2021-09-28 16:30:05 +03:00
|
|
|
"@{[&get_webprefix()]}/config.cgi?$module_name"),"<p>\n";
|
2007-04-12 20:24:50 +00:00
|
|
|
|
|
|
|
&foreign_require("software", "software-lib.pl");
|
|
|
|
$lnk = &software::missing_install_link(
|
|
|
|
"mysql", $text{$p->[2]},
|
|
|
|
"../$module_name/", $text{'index_title'});
|
|
|
|
print $lnk,"<p>\n" if ($lnk);
|
|
|
|
|
|
|
|
&ui_print_footer("/", $text{'index'});
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Try to get the MySQL version
|
|
|
|
$mysql_version = &get_mysql_version(\$out);
|
|
|
|
if ($mysql_version < 0) {
|
|
|
|
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
|
|
|
|
&help_search_link("mysql", "man", "doc", "google"));
|
|
|
|
print &text('index_elibrary', "<tt>$config{'mysql'}</tt>",
|
2009-02-06 23:17:42 +00:00
|
|
|
"../config.cgi?$module_name"),"<p>\n";
|
2007-04-12 20:24:50 +00:00
|
|
|
print &text('index_mysqlver', "$config{'mysql'} -V"),"\n";
|
|
|
|
print "<pre>$out</pre>\n";
|
|
|
|
&ui_print_footer("/", $text{'index'});
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
elsif (!$mysql_version) {
|
|
|
|
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
|
|
|
|
&help_search_link("mysql", "man", "doc", "google"));
|
|
|
|
print &text('index_ever', "<tt>$config{'mysql'}</tt>",
|
2009-02-06 23:17:42 +00:00
|
|
|
"../config.cgi?$module_name"),"<p>\n";
|
2007-04-12 20:24:50 +00:00
|
|
|
print &text('index_mysqlver', "$config{'mysql'} -V"),"\n";
|
|
|
|
print "<pre>$out</pre>\n";
|
|
|
|
&ui_print_footer("/", $text{'index'});
|
|
|
|
exit;
|
|
|
|
}
|
2017-01-02 13:19:01 -08:00
|
|
|
&save_mysql_version($mysql_version);
|
2021-04-21 21:54:07 -07:00
|
|
|
&create_module_info_overrides();
|
2007-04-12 20:24:50 +00:00
|
|
|
|
2009-02-06 23:17:42 +00:00
|
|
|
# Check if MYSQL_PWD works
|
2007-04-12 20:24:50 +00:00
|
|
|
($r, $rout) = &is_mysql_running();
|
2009-02-06 23:17:42 +00:00
|
|
|
if ($r > 0 && !&working_env_pass()) {
|
|
|
|
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
|
|
|
|
&help_search_link("mysql", "man", "doc", "google"));
|
|
|
|
print &text('index_eenvpass', "<tt>$config{'mysql'}</tt>",
|
|
|
|
"../config.cgi?$module_name"),"<p>\n";
|
|
|
|
&ui_print_footer("/", $text{'index'});
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2018-05-04 21:33:22 -07:00
|
|
|
# Check if my.cnf was found
|
|
|
|
if (&is_mysql_local() && $config{'my_cnf'} && !-r $config{'my_cnf'}) {
|
|
|
|
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
|
|
|
|
&help_search_link("mysql", "man", "doc", "google"));
|
|
|
|
print &text('index_ecnf', "<tt>$config{'my_cnf'}</tt>",
|
|
|
|
"../config.cgi?$module_name"),"<p>\n";
|
|
|
|
&ui_print_footer("/", $text{'index'});
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2007-04-12 20:24:50 +00:00
|
|
|
if ($r == 0) {
|
|
|
|
# Not running .. need to start it
|
|
|
|
&main_header();
|
2020-11-29 21:34:19 +03:00
|
|
|
print &ui_alert_box($text{'index_notrun'}, 'danger');
|
2007-04-12 20:24:50 +00:00
|
|
|
|
2020-11-29 21:34:19 +03:00
|
|
|
if ($rout) {
|
2020-11-29 21:48:51 +03:00
|
|
|
print &ui_details({
|
|
|
|
'title' => $text{'syslog_desc2'},
|
|
|
|
'content' => &text('index_emsg',"<tt>$rout</tt>"),
|
2020-11-29 22:31:57 +03:00
|
|
|
'class' =>'error',
|
|
|
|
'html' => 1}, 1);
|
2020-11-29 21:34:19 +03:00
|
|
|
}
|
2017-07-08 21:32:32 -07:00
|
|
|
|
2007-04-12 20:24:50 +00:00
|
|
|
if ($access{'stop'} && &is_mysql_local()) {
|
2008-05-10 02:43:09 +00:00
|
|
|
print &ui_hr();
|
2017-07-08 21:28:55 -07:00
|
|
|
print &ui_buttons_start();
|
|
|
|
print &ui_buttons_row("start.cgi",
|
|
|
|
$text{'index_start'},
|
|
|
|
&text('index_startmsg',
|
|
|
|
"<tt>$config{'start_cmd'}</tt>"));
|
|
|
|
print &ui_buttons_end();
|
2007-04-12 20:24:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($r == -1) {
|
|
|
|
# Running, but webmin doesn't know the root (or user's) password!
|
|
|
|
&main_header();
|
2020-11-29 21:34:19 +03:00
|
|
|
|
|
|
|
print &ui_alert_box($text{'index_nopass'}, 'warn');
|
|
|
|
|
|
|
|
if ($rout) {
|
2020-11-29 21:48:51 +03:00
|
|
|
print &ui_details({
|
|
|
|
'title' => $text{'syslog_desc2'},
|
|
|
|
'content' => &text('index_emsg',"<tt>$rout</tt>"),
|
|
|
|
'class' => 'error',
|
2020-11-29 22:31:57 +03:00
|
|
|
'html' => 1}, 1) . "<br>";
|
2020-11-29 21:48:51 +03:00
|
|
|
}
|
2008-01-11 00:50:48 +00:00
|
|
|
|
|
|
|
print &ui_form_start("login.cgi", "post");
|
|
|
|
print &ui_table_start($text{'index_ltitle'}, undef, 2);
|
|
|
|
|
|
|
|
print &ui_table_row($text{'index_login'},
|
|
|
|
&ui_textbox("login", $access{'user'} || $config{'login'}, 40));
|
|
|
|
|
|
|
|
print &ui_table_row($text{'index_pass'},
|
2020-11-29 18:07:39 +03:00
|
|
|
&ui_password("pass", undef, 40) . "<br>" .
|
|
|
|
&ui_checkbox("force", 1, $text{'mysqlpass_echange_forcepass'}));
|
2008-01-11 00:50:48 +00:00
|
|
|
|
|
|
|
print &ui_table_end();
|
|
|
|
print &ui_form_end([ [ undef, $text{'save'} ] ]);
|
|
|
|
|
2020-11-29 18:51:28 +03:00
|
|
|
|
2007-04-12 20:24:50 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
# Check if we can re-direct to a single DB's page
|
|
|
|
@alldbs = &list_databases();
|
|
|
|
@titles = grep { &can_edit_db($_) } @alldbs;
|
|
|
|
$can_all = (@alldbs == @titles);
|
|
|
|
if (@titles == 1 && $access{'dbs'} ne '*' && !$access{'perms'} &&
|
|
|
|
!$access{'stop'} && !$access{'create'} && $access{'noconfig'}) {
|
|
|
|
# Only one DB, so go direct to it!
|
|
|
|
&redirect("edit_dbase.cgi?db=$titles[0]");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2019-11-24 21:55:34 -08:00
|
|
|
&main_header(&get_remote_mysql_variant());
|
2022-02-10 15:27:06 +03:00
|
|
|
print &ui_subheading($text{'index_dbs'})
|
|
|
|
if ($access{'perms'} &&
|
|
|
|
$displayconfig{'style'} != 1);
|
2007-04-12 20:24:50 +00:00
|
|
|
if ($in{'search'}) {
|
|
|
|
# Limit to those matching search
|
|
|
|
@titles = grep { /\Q$in{'search'}\E/i } @titles;
|
|
|
|
print "<table width=100%><tr>\n";
|
|
|
|
print "<td> <b>",&text('index_showing',
|
2008-02-24 22:00:41 +00:00
|
|
|
"<tt>".&html_escape($in{'search'})."</tt>"),"</b></td>\n";
|
2007-04-12 20:24:50 +00:00
|
|
|
print "<td align=right><a href='index.cgi'>",
|
|
|
|
"$text{'view_searchreset'}</a></td>\n";
|
|
|
|
print "</tr></table>\n";
|
|
|
|
}
|
|
|
|
elsif ($in{'show'}) {
|
|
|
|
# Limit to specific databases
|
2008-02-24 22:00:41 +00:00
|
|
|
%show = map { $_, 1 } split(/\0/, $in{'show'});
|
|
|
|
@titles = grep { $show{$_} } @titles;
|
2007-04-12 20:24:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# DB is running .. list databases
|
|
|
|
@icons = map { "images/db.gif" } @titles;
|
|
|
|
@links = map { "edit_dbase.cgi?db=$_" } @titles;
|
|
|
|
$can_create = $access{'create'} == 1 ||
|
|
|
|
$access{'create'} == 2 && @titles < $access{'max'};
|
|
|
|
|
|
|
|
@rowlinks = ( );
|
|
|
|
push(@rowlinks, "<a href=newdb_form.cgi>$text{'index_add'}</a>")
|
|
|
|
if ($can_create);
|
|
|
|
if (!@icons) {
|
|
|
|
# No databases .. tell user
|
2011-12-05 16:18:50 -08:00
|
|
|
if ($in{'search'}) {
|
|
|
|
print "<b>$text{'index_nodbs3'}</b> <p>\n";
|
|
|
|
}
|
|
|
|
elsif (@alldbs) {
|
2007-04-12 20:24:50 +00:00
|
|
|
print "<b>$text{'index_nodbs'}</b> <p>\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "<b>$text{'index_nodbs2'}</b> <p>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif (@icons > $max_dbs && !$in{'search'} && !$in{'show'}) {
|
|
|
|
# Too many databases to show .. display search and jump forms
|
|
|
|
print &ui_form_start("index.cgi");
|
|
|
|
print $text{'index_toomany'},"\n";
|
|
|
|
print &ui_textbox("search", undef, 20),"\n";
|
|
|
|
print &ui_submit($text{'index_search'}),"<br>\n";
|
|
|
|
print &ui_form_end();
|
|
|
|
|
|
|
|
print &ui_form_start("edit_dbase.cgi");
|
|
|
|
print $text{'index_jump'},"\n";
|
2008-09-18 21:08:31 +00:00
|
|
|
print &ui_select("db", undef, [ map { [ $_ ] } @titles ],
|
|
|
|
1, 0, 0, 0, "onChange='form.submit()'"),"\n";
|
2007-04-12 20:24:50 +00:00
|
|
|
print &ui_submit($text{'index_jumpok'}),"<br>\n";
|
|
|
|
print &ui_form_end();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# Show table of databases
|
|
|
|
if ($access{'delete'}) {
|
|
|
|
print &ui_form_start("drop_dbases.cgi");
|
|
|
|
unshift(@rowlinks, &select_all_link("d", 0),
|
|
|
|
&select_invert_link("d", 0));
|
|
|
|
}
|
|
|
|
print &ui_links_row(\@rowlinks);
|
|
|
|
@checks = @titles;
|
2008-02-15 02:24:17 +00:00
|
|
|
if ($displayconfig{'style'} == 1) {
|
|
|
|
# Show as DB names and table counts
|
2021-01-19 20:58:11 -08:00
|
|
|
my (@tables, @indexes, @views);
|
|
|
|
my $sv = &supports_views();
|
|
|
|
foreach my $db (@titles) {
|
|
|
|
my @t = &list_tables($db);
|
|
|
|
my @i = &list_indexes($db);
|
|
|
|
my @v = $sv ? &list_views($db) : ( );
|
|
|
|
push(@tables, scalar(@t));
|
|
|
|
push(@indexes, scalar(@i));
|
|
|
|
push(@views, scalar(@v));
|
|
|
|
}
|
2007-04-12 20:24:50 +00:00
|
|
|
@tables = map { @t = &list_tables($_); scalar(@t) }
|
|
|
|
@titles;
|
|
|
|
@titles = map { &html_escape($_) } @titles;
|
|
|
|
&split_table([ "", $text{'index_db'},
|
2021-01-19 20:58:11 -08:00
|
|
|
$text{'index_tables'},
|
|
|
|
$text{'index_indexes'},
|
|
|
|
$text{'index_views'} ],
|
|
|
|
\@checks, \@links, \@titles, \@tables,
|
|
|
|
\@indexes, \@views)
|
2007-04-12 20:24:50 +00:00
|
|
|
if (@titles);
|
|
|
|
}
|
2008-02-15 02:24:17 +00:00
|
|
|
elsif ($displayconfig{'style'} == 2) {
|
|
|
|
# Show just DB names
|
|
|
|
@grid = ( );
|
|
|
|
for(my $i=0; $i<@links; $i++) {
|
|
|
|
push(@grid, &ui_checkbox("d", $titles[$i]).
|
|
|
|
" <a href='$links[$i]'>".
|
|
|
|
&html_escape($titles[$i])."</a>");
|
|
|
|
}
|
|
|
|
print &ui_grid_table(\@grid, 4, 100, undef, undef, "");
|
|
|
|
}
|
2007-04-12 20:24:50 +00:00
|
|
|
else {
|
2008-02-15 02:24:17 +00:00
|
|
|
# Show name icons
|
2007-04-12 20:24:50 +00:00
|
|
|
@checks = map { &ui_checkbox("d", $_) } @checks;
|
|
|
|
@titles = map { &html_escape($_) } @titles;
|
|
|
|
&icons_table(\@links, \@titles, \@icons, 5,
|
|
|
|
undef, undef, undef, \@checks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print &ui_links_row(\@rowlinks);
|
2007-07-26 23:02:56 +00:00
|
|
|
if (@icons && $access{'delete'} &&
|
|
|
|
(@icons <= $max_dbs || $in{'search'})) {
|
2007-04-12 20:24:50 +00:00
|
|
|
print &ui_form_end([ [ "delete", $text{'index_drops'} ] ]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($access{'perms'}) {
|
|
|
|
# Show icons for editing user permissions and server settings
|
2008-05-10 02:43:09 +00:00
|
|
|
print &ui_hr();
|
2007-04-12 20:24:50 +00:00
|
|
|
print &ui_subheading($text{'index_global'});
|
|
|
|
$canvars = &supports_variables();
|
2016-01-01 15:10:45 -08:00
|
|
|
$canhosts = &supports_hosts();
|
|
|
|
@links = ( 'list_users.cgi', 'list_dbs.cgi',
|
|
|
|
$canhosts ? ( 'list_hosts.cgi' ) : ( ),
|
2007-04-12 20:24:50 +00:00
|
|
|
'list_tprivs.cgi', 'list_cprivs.cgi',
|
2018-01-20 15:28:03 -08:00
|
|
|
'edit_cnf.cgi', 'edit_manual.cgi', 'list_procs.cgi',
|
2007-04-12 20:24:50 +00:00
|
|
|
$canvars ? ( 'list_vars.cgi' ) : ( ),
|
2023-01-21 17:13:52 -08:00
|
|
|
'edit_ssl.cgi', 'root_form.cgi',
|
2007-04-12 20:24:50 +00:00
|
|
|
);
|
|
|
|
@titles = ( $text{'users_title'}, $text{'dbs_title'},
|
2016-01-01 15:10:45 -08:00
|
|
|
$canhosts ? ( $text{'hosts_title'} ) : ( ),
|
2018-01-20 15:28:03 -08:00
|
|
|
$text{'tprivs_title'}, $text{'cprivs_title'},
|
|
|
|
$text{'cnf_title'}, $text{'manual_title'},
|
2007-04-12 20:24:50 +00:00
|
|
|
$text{'procs_title'},
|
|
|
|
$canvars ? ( $text{'vars_title'} ) : ( ),
|
2023-01-21 17:13:52 -08:00
|
|
|
$text{'ssl_title'}, $text{'root_title'},
|
2007-04-12 20:24:50 +00:00
|
|
|
);
|
|
|
|
@images = ( 'images/users.gif', 'images/dbs.gif',
|
2016-01-01 15:10:45 -08:00
|
|
|
$canhosts ? ( 'images/hosts.gif' ) : ( ),
|
2018-01-20 15:28:03 -08:00
|
|
|
'images/tprivs.gif', 'images/cprivs.gif',
|
|
|
|
'images/cnf.gif', 'images/manual.gif',
|
2007-04-12 20:24:50 +00:00
|
|
|
'images/procs.gif',
|
|
|
|
$canvars ? ( 'images/vars.gif' ) : ( ),
|
2023-01-21 17:13:52 -08:00
|
|
|
'images/ssl.gif', 'images/root.gif',
|
2007-04-12 20:24:50 +00:00
|
|
|
);
|
|
|
|
if ($access{'perms'} == 2) {
|
|
|
|
# Remove my.cnf and database connections icons
|
|
|
|
@links = @links[0..4];
|
|
|
|
@titles = @titles[0..4];
|
|
|
|
@images = @images[0..4];
|
|
|
|
}
|
2022-12-21 14:36:51 +02:00
|
|
|
@images = map { $_ = &get_webprefix()."/mysql/$_" } @images;
|
2007-04-12 20:24:50 +00:00
|
|
|
&icons_table(\@links, \@titles, \@images, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($access{'stop'} && &is_mysql_local() ||
|
|
|
|
$can_all && !$access{'edonly'} && $access{'buser'}) {
|
2008-05-10 02:43:09 +00:00
|
|
|
print &ui_hr();
|
2007-04-12 20:24:50 +00:00
|
|
|
print &ui_buttons_start();
|
|
|
|
$started_buttons_row = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Show stop button
|
|
|
|
if ($access{'stop'} && &is_mysql_local()) {
|
2024-11-07 21:31:47 -08:00
|
|
|
print &ui_buttons_row("restart.cgi", $text{'index_restart'},
|
|
|
|
$text{'index_restartmsg'});
|
|
|
|
|
2007-04-12 20:24:50 +00:00
|
|
|
print &ui_buttons_row("stop.cgi", $text{'index_stop'},
|
|
|
|
$text{'index_stopmsg'});
|
|
|
|
}
|
|
|
|
|
|
|
|
# Show backup all button
|
|
|
|
if ($can_all && !$access{'edonly'} && $access{'buser'}) {
|
|
|
|
print &ui_buttons_row("backup_form.cgi", $text{'index_backup'},
|
|
|
|
$text{'index_backupmsg'},
|
|
|
|
&ui_hidden("all", 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
print &ui_buttons_end() if ($started_buttons_row);
|
|
|
|
|
|
|
|
# Check if the optional perl modules are installed
|
|
|
|
if (foreign_available("cpan")) {
|
|
|
|
eval "use DBI";
|
|
|
|
push(@needs, "DBI") if ($@);
|
|
|
|
$nodbi++ if ($@);
|
|
|
|
eval "use DBD::mysql";
|
|
|
|
push(@needs, "DBD::mysql") if ($@);
|
|
|
|
if (@needs) {
|
|
|
|
$needs = &urlize(join(" ", @needs));
|
2023-05-24 20:24:32 +03:00
|
|
|
print &ui_alert_box(&text(@needs == 2 ? 'index_nomods' : 'index_nomod', @needs,
|
2022-08-15 23:02:17 +03:00
|
|
|
"../cpan/download.cgi?source=3&cpan=$needs&mode=2&return=/$module_name/&returndesc=".
|
2023-05-24 20:24:32 +03:00
|
|
|
&urlize($text{'index_return'})), 'warn');
|
2007-04-12 20:24:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&ui_print_footer("/", "index");
|
|
|
|
|
2019-11-24 21:55:34 -08:00
|
|
|
# main_header(ver, variant)
|
2007-04-12 20:24:50 +00:00
|
|
|
sub main_header
|
|
|
|
{
|
2019-11-24 21:55:34 -08:00
|
|
|
my ($ver, $variant) = @_;
|
|
|
|
if (!$ver) {
|
|
|
|
$ver = $mysql_version;
|
|
|
|
$variant = "mysql";
|
|
|
|
}
|
|
|
|
my $vn = $variant eq "mysql" ? "MySQL" : "MariaDB";
|
2023-06-23 13:50:01 +03:00
|
|
|
my $cmd = $variant ne "mysql" && $ver >= 11 ? 'mariadb' : 'mysql';
|
2007-04-12 20:24:50 +00:00
|
|
|
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
|
2023-06-23 13:50:01 +03:00
|
|
|
&help_search_link($cmd, "man", "doc", "google"),
|
2017-07-15 19:31:39 -07:00
|
|
|
undef, undef,
|
|
|
|
$config{'host'} ?
|
2019-11-24 21:55:34 -08:00
|
|
|
&text('index_version2', $ver, $config{'host'}, $vn) :
|
|
|
|
&text('index_version', $ver, $vn));
|
2007-04-12 20:24:50 +00:00
|
|
|
}
|
|
|
|
|