1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
|
#!/usr/local/bin/perl -w -U
####
#### PD-Admin Add-On: mySql checking
#### miko 10/2005 + 11/2005
####
use CGI ':standard';
use DBI;
use strict;
use vars qw($dsn $user $password $color_scheme $color_scheme_administrator);
do "/opt/pdadmin/etc/pdadmin.conf" or die "Can't read configuration: $!";
####
#### Korrekte Session ueberpruefen
####
unless (defined $ENV{REQUEST_URI}) {die "no request url available!"};
$ENV{REQUEST_URI} =~ m/\S*\/(\w*)\/addon_mysql.cgi$/;
my $SessionID = $1;
my $dbh = DBI->connect($dsn,$user,$password) or die "can't connect!";
my $query = "select time from sessions where session='$SessionID' limit 1";
my $sth = $dbh->prepare($query) or die "cannot prepare query '$query'";
my $rv = $sth->execute or die "cannot execute query '$query'";
my $myTime = $sth->fetchrow;
$sth->finish();
$myTime or die "session not found!";
####
#### Session Time aktualisieren
####
my $time = time;
$query = "Update sessions set time ='$time' where session='$SessionID'";
$sth = $dbh->prepare($query) or die "cannot prepare query '$query'";
$rv = $sth->execute or die "cannot execute query '$query'";
$sth->finish;
####
#### Version anzeigen
####
$query = "select version()";
$sth = $dbh->prepare($query) or die "cannot prepare query '$query'";
$rv = $sth->execute or die "cannot execute query '$query'";
my $data1 = $sth->fetchrow;
$sth->finish;
$dbh->disconnect();
####
#### Geforderte Aktionen durchführen
####
my $mcg = CGI->new;
my $action = $mcg->param('action') || '';
my $pw = `cat /opt/pdadmin/etc/mysql_rootpw.conf 2>/dev/null`;
# Variable "untainted" machen, um spaetere Fehlermeldungen zu verhindern
$pw =~ m/(.*)$/;
$pw = $1;
# Aktionen ausfuehren
my $data2 = '';
if ($action eq '1')
{ $data2 = `export TERM=dumb; /usr/local/pd-admin2/bin/mysqlcheck -ec -A -uroot -p$pw`; }
elsif ($action eq '2')
{ $data2 = `export TERM=dumb; /usr/local/pd-admin2/bin/mysqlcheck -eo -A -uroot -p$pw`; }
####
#### Html-Template parsen und die eigentlichen Daten ausgeben
####
my $html_data = `cat /opt/pdadmin/www/addons/addons.mysql.main.html`;
my $Color = 'blue';
if (defined $color_scheme and length $color_scheme)
{$Color = $color_scheme;}
elsif (defined $color_scheme_administrator and length $color_scheme_administrator )
{$Color = $color_scheme_administrator};
$html_data =~ s/\$\$form_data1/$data1/g;
$html_data =~ s/\$\$form_data2/$data2/g;
$html_data =~ s/\$\$form_link/$ENV{REQUEST_URI}/g;
$html_data =~ s/\$\$color_scheme/$Color/g;
print header;
print $html_data;
exit |