add comments on initCaptcha method
This commit is contained in:
parent
cce1a6365a
commit
6702a5068c
|
@ -766,22 +766,31 @@ sub buildHiddenForm {
|
||||||
# @return nothing
|
# @return nothing
|
||||||
sub initCaptcha {
|
sub initCaptcha {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
# Store captcha data
|
||||||
opendir( OUTPUT, $self->{captcha_output} )
|
opendir( OUTPUT, $self->{captcha_output} )
|
||||||
or $self->lmLog( "Can't open captcha output dir", "error" );
|
or $self->lmLog( "Can't open captcha output dir", "error" );
|
||||||
opendir( DATA, $self->{captcha_data} )
|
opendir( DATA, $self->{captcha_data} )
|
||||||
or $self->lmLog( "Can't open captcha data dir", "error" );
|
or $self->lmLog( "Can't open captcha data dir", "error" );
|
||||||
|
|
||||||
|
# Clean previous captcha datas
|
||||||
foreach ( readdir(OUTPUT) ) {
|
foreach ( readdir(OUTPUT) ) {
|
||||||
next if ( $_ eq ".." or $_ eq "." );
|
next if ( $_ eq ".." or $_ eq "." );
|
||||||
system("rm -f $_ &>/dev/null")
|
system("rm -f $_ &>/dev/null")
|
||||||
or $self->lmLog( "Can't clean captcha output dir!", "warn" );
|
or $self->lmLog( "Can't clean captcha output dir!", "warn" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Build Authen::Captcha object
|
||||||
$self->{captcha} = Authen::Captcha->new(
|
$self->{captcha} = Authen::Captcha->new(
|
||||||
data_folder => $self->{captcha_data},
|
data_folder => $self->{captcha_data},
|
||||||
output_folder => $self->{captcha_output}
|
output_folder => $self->{captcha_output}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Generate a new captcha from captcha object
|
||||||
$self->{captcha_code} =
|
$self->{captcha_code} =
|
||||||
$self->{captcha}->generate_code( $self->{captcha_size} );
|
$self->{captcha}->generate_code( $self->{captcha_size} );
|
||||||
$self->{captcha_img} = "/captcha_output/" . $self->{captcha_code} . ".png";
|
$self->{captcha_img} = "/captcha_output/" . $self->{captcha_code} . ".png";
|
||||||
|
|
||||||
closedir(DATA) and closedir(OUTPUT);
|
closedir(DATA) and closedir(OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user