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:
|
#!/usr/local/bin/perl -w
####
#### PD-Admin Add-On: Gerüst für Weiterleitung
#### Michael 9/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: $!";
###
### Variablen Deklarierung
###
my $html_data;
my $Color = 'blue';
my $rest;
my $kill_time='180';
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};
####
#### Korrekte Session ueberpruefen
####
unless (defined $ENV{REQUEST_URI}) {die "no request url available!"};
$ENV{REQUEST_URI} =~ m/\S*\/(\w*)\/dein_addon.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();
$dbh->disconnect();
$time = time;
$rest = $time - $myTime;
if ($rest >= $kill_time) {
$html_data = `cat /opt/pdadmin/www/administrator/html/login.failed.html`;
my $dbh = DBI->connect($dsn,$user,$password) or die "can't connect!";
my $query = "DELETE 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'";
$sth->finish();
$dbh->disconnect();
} else {
###
### Update der Session
###
my $dbh = DBI->connect($dsn,$user,$password) or die "can't connect!";
my $query = "Update sessions set time ='$time' where session='$SessionID'";
my $sth = $dbh->prepare($query) or die "cannot prepare query '$query'";
my $rv = $sth->execute or die "cannot execute query '$query'";
$sth->finish;
$dbh->disconnect();
$html_data = `cat deine Normale Html Vorlage`;
#### Sowie der rest deines Scriptes ####
}
$html_data =~ s/\$\$color_scheme/$Color/g;
print header;
print $html_data;
exit |