[- BEGIN { unshift(@INC, $ENV{SW_PERLDIR}); } use HTML::Table; use SW::Site::rcm; use SW::XML::Object::LoginID; use SW::DB; use XML::LibXSLT; use XML::LibXML; use Data::Dumper; use XML::Sablotron; # # create site object and connect to db # my $site = SW::Site::rcm->new( $ENV{SW_CONFIG} ); my $db = SW::DB->new( $ENV{SW_CONFIG} ); if ( $db->connect() ) { } else { print OUT $site->start(); print OUT "sorry can't connect to db"; print OUT $site->end(); exit; } my $content; # # create login object # my $login = SW::XML::Object::LoginID->new( $db ); $login->fromHash( \%fdat ); #if ( ! $login->createTable ) { # $content .= "Can't create table"; #} # # stylesheet selection # $style_base = $site->base_dir . '/client/'; my $default = 'login'; my $xslfile = $default; # select different xsl file if provided if ( defined( $fdat{s} ) ) { $xslfile = $fdat{s}; } # # validate login # #$content .= $fdat{username}; $show_toc = 0; if ( defined( $fdat{username} ) && defined($fdat{passwd}) ) { if ( $login->validate( $fdat{username}, $fdat{passwd})) { $show_toc = 1; $xslfile = "success"; # print OUT "hey!!!"; # set md5 cookie } else { $xslfile = "fail"; } } $xslfile = $style_base . $xslfile . '.xsl'; sub myMHMakeCode { my ($self, $processor, $severity, $facility, $code); return $code; # I can deal with internal numbers } sub myMHLog { my ($self, $processor, $code, $level, @fields); # open( FILE, ">>/tmp/sablo.log" ); # print FILE @_; # close( FILE ); } sub myMHError { # my ($self, $processor, $code, $level, @fields); open( FILE, ">>/tmp/sablo.err" ); foreach my $m(@_) { print FILE $m."\n"; } close( FILE ); } my $sab = new XML::Sablotron; my $sit = new XML::Sablotron::Situation; $sab->RegHandler(0, { MHMakeCode => \&myMHMakeCode, MHLog => \&myMHLog, MHError => \&myMHError }); $sab->addArg( $sit, 'input', $login->toXML ); $sab->process($sit, $xslfile, 'arg:/input', 'arg:/output'); my $result = $sab->getResultArg('arg:/output'); $content .= $result; # # show toc # my $toc; if ( $show_toc ) { $toc = "Log in successful. Forwarding to your secure area."; $http_headers_out{Location} = "http://www.strategicriskcontrol.com/client/view.epl?u=$fdat{username}"; } if ( $@ ) { $toc .= "Error processing XML: $@"; } # # output page # print OUT $site->start(); if ( $show_toc ) { print OUT $site->frameContent( $toc ); } else { print OUT $site->frameContent( $content ); } print OUT $site->end(); -]