Error: You don't have access to administer databases." unless (LJ::check_priv($remote, "siteadmin", "mysqlstatus")); my $dbh = LJ::get_db_writer(); if ($format eq "text") { BML::set_content_type("text/plain"); } my ($sth, $ret); if ($format eq "html") { $ret .= "\n"; } my @modes = qw(status variables tables); my $mode = $FORM{'mode'} || "status"; foreach my $m (@modes) { if ($mode eq $m) { $mode = $m; $ret .= "[ $mode ] " if ($format eq "html"); } else { if ($format eq "html") { $ret .= "[ $m}); $ret .= "\">$m ] "; } } } if ($format eq "html") { $ret .= "

Or, view as text.

"; } if ($mode eq "status") { $sth = $dbh->prepare("SHOW STATUS"); $sth->execute; my %s; while (my ($k, $v) = $sth->fetchrow_array) { $s{$k} = $v; } $sth = $dbh->prepare("SHOW STATUS"); $sth->execute; if ($format eq "html") { $ret .= ""; } while (my ($k, $v) = $sth->fetchrow_array) { my $delta = $v - $s{$k}; if ($delta == 0) { $delta = ""; } elsif ($delta > 0) { $delta = "+$delta"; } else { $delta = "-$delta"; } if ($format eq "html") { $ret .= "\n"; } elsif ($format eq "text") { $ret .= "$k,$v,$delta\n"; } } $ret .= "
$k$v$delta
\n" if ($format eq "html"); return $ret; } if ($mode eq "variables") { $sth = $dbh->prepare("SHOW VARIABLES"); $sth->execute; $ret .= "" if ($format eq "html"); while (my ($k, $v) = $sth->fetchrow_array) { if ($format eq "html") { $ret .= "\n"; } else { $ret .= "$k,$v\n"; } } $ret .= "
$k$v
\n" if ($format eq "html"); return $ret; } if ($mode eq "tables") { $sth = $dbh->prepare("SHOW TABLE STATUS"); $sth->execute; if ($format eq "html") { $ret .= ""; $ret .= ""; } my @cols = @{$sth->{'NAME'}}; foreach (@cols) { if ($format eq "html") { $ret .= ""; } else { $ret .= "$_,"; } } if ($format eq "html") { $ret .= "\n"; } else { $ret .= "\n"; } while (my $t = $sth->fetchrow_hashref) { $ret .= "" if ($format eq "html"); foreach my $c (@cols) { if ($format eq "html") { $ret .= ""; } elsif ($format eq "text") { $ret .= "$t->{$c},"; } } if ($format eq "html") { $ret .= ""; } elsif ($format eq "text") { $ret .= "\n"; } } $ret .= "
$_
$t->{$c}
\n" if ($format eq "html"); return $ret; } _code?>