#!/usr/bin/perl use DBI; use CGI; my $q = new CGI; select(STDERR); $|++; select(STDOUT); ############## my %desc; my $data; { local $/ = undef; open(DATA, "mysqltable.html"); $data = ; } $data =~ s/<(?:TR|TD|\/TD|\/TR|TABLE|TBODY|\/TABLE|\/TBODY)>//g; my @lines = split "\n\n", $data; my $key; foreach my $val (@lines) { $val =~ s/(.*)<\/CODE>/$key=$1;"";/e; $desc{$key} = $val if $key; } ############### my $rootpwd = $q->param('rootpwd'); if($rootpwd) { status(); } else { login(); } sub login { my $wasproblem = shift; my $html = "MySQLStatus

MySQLStatus

"; $html .= "$wasproblem
" if $wasproblem; $html .= "In order to view the status of your MySQL server, please enter the MySQL root password.
" . "
MySQL root password: " . "
\n"; print $html; exit; } sub status { my $dbh = DBI->connect('dbi:mysql:mysql:localhost:3306', 'root', $rootpwd) or login($DBI::errstr); my $sth = $dbh->prepare("SHOW STATUS;"); $sth->execute(); my($key, $val, $bgcolor); my $color = 0; print "MySQLStatus

MySQL Server on localhost:3306

"; while(($key, $val) = $sth->fetchrow_array()) { $bgcolor = ($color++ % 2? "#BECDDA" : "#DEE6ED"); print ""; } print "
$key$val$desc{$key}
"; }