Después de volver a leerme los manuales de los módulos que necesito, me he puesto a modificar el ejemplo anterior, para configurarlo con una base de datos... Me da un error, y no sé qué significa, que estoy poniendo mal.
Si alguien me puede ayudar una vez más, gracias...
Using perl Syntax Highlighting
#!/usr/bin/perl
#
# Sample application
#
# Just place this file in a CGI enabled part of your website, and
# load it up in your browser. The only valid username/password
# combination is 'test' and '123'.
#
use strict;
use warnings;
{
package SampleLogin;
use base qw(CGI::Application);
use CGI::Application::Plugin::Session;
use CGI::Application::Plugin::Authentication;
use CGI::Application::Plugin::AutoRunmode;
use CGI::Application::Plugin::DBH (qw/dbh_config dbh/);
use CGI::Carp qw(fatalsToBrowser);
SampleLogin->dbh_config("dbi:mysql:database=GESTION_USUARIOS:host=localhost", "admin", "123");
SampleLogin->session_config(
CGI_SESSION_OPTIONS => [
"driver:mysql;serializer:Storable",
SampleLogin->query,
{Handle=>SampleLogin->dbh}
]
);
my %config = (
DRIVER => [ 'DBI',
DBH => SampleLogin->dbh,
TABLE => 'user',
CONSTRAINTS => {
'u_username' => '__CREDENTIAL_1__',
'MD5:u_password' => '__CREDENTIAL_2__'
}
],
STORE => 'Session',
LOGOUT_RUNMODE => 'one',
);
SampleLogin->authen->config(%config);
SampleLogin->authen->protected_runmodes('two');
sub setup {
my $self = shift;
$self->start_mode('one');
}
sub one : Runmode {
my $self = shift;
return CGI::start_html( -style => { -code => $self->authen->login_styles } )
. CGI::h2('This page is NOT protected')
. CGI::a( { -href => '?rm=two' }, 'Protected Runmode' )
. CGI::end_html();
}
sub two : Runmode {
my $self = shift;
return CGI::start_html( -style => { -code => $self->authen->login_styles } )
. CGI::h2('This page is protected')
. CGI::h2( 'username: ' . $self->authen->username )
. CGI::a( { -href => '?rm=one' }, 'Un-Protected Runmode' )
. CGI::br()
. CGI::a( { -href => '?authen_logout=1' }, 'Logout' )
. CGI::end_html();
}
}
SampleLogin->new->run;
Coloreado en 0.007 segundos, usando
GeSHi 1.0.8.4
El error que me sale es :
Using text Syntax Highlighting
Software error:
Can't use string ("SampleLogin") as a HASH ref while "strict refs" in use at /usr/local/share/perl5/CGI/Application/Plugin/DBH.pm line 54.
Coloreado en 0.000 segundos, usando
GeSHi 1.0.8.4
y la línea 54 es
my $self = shift; de sub setup