| 1 | #!/bin/perl | ||
| 2 | |||
| 3 | # ----------------------------------------------------------------------------- | ||
| 4 | # | ||
| 5 | # Nes by Skriptke | ||
| 6 | # Copyright 2009 - 2010 Enrique F. Castañón Barbero | ||
| 7 | # Licensed under the GNU GPL. | ||
| 8 | # | ||
| 9 | # CPAN: | ||
| 10 | # http://search.cpan.org/dist/Nes/ | ||
| 11 | # | ||
| 12 | # Sample: | ||
| 13 | # http://nes.sourceforge.net/ | ||
| 14 | # | ||
| 15 | # Repository: | ||
| 16 | # http://github.com/Skriptke/nes | ||
| 17 | # | ||
| 18 | # Version 1.03 | ||
| 19 | # | ||
| 20 | # DOCUMENTATION: | ||
| 21 | # perldoc Nes::Obj::secure_login | ||
| 22 | # | ||
| 23 | # ----------------------------------------------------------------------------- | ||
| 24 | |||
| 25 | use Nes; | ||
| 26 | |||
| 27 | package secure_login; | ||
| 28 | |||
| 29 | { | ||
| 30 | |||
| 31 | sub new { | ||
| 32 | my $class = shift; | ||
| 33 | my $self = bless {}, $class; | ||
| 34 | |||
| 35 | my $nes = Nes::Singleton->new(); | ||
| 36 | my $obj = $nes->{'query'}->{'q'}{'obj_param_0'}; | ||
| 37 | my $cfg = $nes->{'CFG'}; | ||
| 38 | my $ddumper = '('.$nes->{'query'}->{'q'}{$obj.'_param_1'}.')'; | ||
| 39 | my %param = eval "$ddumper"; | ||
| 40 | |||
| 41 | # get parameters | ||
| 42 | $self->{'script_handler'} = ''; | ||
| 43 | $self->{'function_handler'} = ''; | ||
| 44 | |||
| 45 | $self->{'from_table'} = undef; | ||
| 46 | $self->{'from_user_field'} = undef; | ||
| 47 | $self->{'from_pass_field'} = undef; | ||
| 48 | $self->{'from_user_function'} = undef; | ||
| 49 | $self->{'from_pass_function'} = undef; | ||
| 50 | |||
| 51 | $self->{'min_len_name'} = 2; | ||
| 52 | $self->{'max_len_name'} = 15; | ||
| 53 | $self->{'min_len_pass'} = 2; | ||
| 54 | $self->{'max_len_pass'} = 15; | ||
| 55 | $self->{'attempts'} = 3; | ||
| 56 | $self->{'form_attempts'} = '10/5'; | ||
| 57 | $self->{'form_location'} = 'none'; | ||
| 58 | $self->{'form_exp_last'} = '1m'; | ||
| 59 | $self->{'form_expire'} = '10m'; | ||
| 60 | $self->{'form_name'} = 'secure_login'; | ||
| 61 | $self->{'captcha_name'} = 'secure_login'; | ||
| 62 | $self->{'captcha_type'} = 'ascii'; | ||
| 63 | $self->{'captcha_digits'} = 6; | ||
| 64 | $self->{'captcha_size'} = 2; | ||
| 65 | $self->{'captcha_noise'} = 3; | ||
| 66 | $self->{'captcha_sig'} = ''; | ||
| 67 | $self->{'captcha_spc'} = ' '; | ||
| 68 | $self->{'captcha_expire'} = '1m'; | ||
| 69 | $self->{'captcha_atempts'} = '10/5'; | ||
| 70 | $self->{'captcha_tag_start'} = '<pre style="font-size:2px; line-height:1.0;">'; | ||
| 71 | $self->{'captcha_tag_start'} = '' if $param{'captcha_size'} ne 'none'; | ||
| 72 | $self->{'captcha_tag_end'} = '<br></pre>'; | ||
| 73 | $self->{'captcha_tag_end'} = '' if $param{'captcha_size'} ne 'none'; | ||
| 74 | $self->{'out_page'} = 'http://'.$ENV{'SERVER_NAME'}.$ENV{'REQUEST_URI'}; | ||
| 75 | $self->{'expire_session'} = '12h'; | ||
| 76 | $self->{'expire_session_re'} = '48h'; | ||
| 77 | $self->{'msg_legend'} = ''; | ||
| 78 | $self->{'msg_name'} = 'User:'; | ||
| 79 | $self->{'msg_pass'} = 'Password:'; | ||
| 80 | $self->{'msg_remember'} = ''; | ||
| 81 | $self->{'msg_login'} = 'Enter'; | ||
| 82 | $self->{'msg_captcha'} = 'Security code'; | ||
| 83 | $self->{'msg_error_form'} = '<img src="'.$cfg->{'img_dir'}.'/error.gif"> Incorrect User/Pass<br>'; | ||
| 84 | $self->{'msg_error_captcha'} = '<img src="'.$cfg->{'img_dir'}.'/error.gif">'; | ||
| 85 | $self->{'id_form'} = 'secure_login_id'; | ||
| 86 | $self->{'class_form'} = 'secure_login_class'; | ||
| 87 | $self->{'msg_error_name'} = '<img src="'.$cfg->{'img_dir'}.'/error.gif">'; | ||
| 88 | $self->{'msg_error_pass'} = '<img src="'.$cfg->{'img_dir'}.'/error.gif">'; | ||
| 89 | $self->{'tpl_errors'} = 'secure_login_errors.nhtml'; | ||
| 90 | $self->{'tpl_options'} = ''; | ||
| 91 | |||
| 92 | |||
| 93 | foreach my $this (keys %param) { | ||
| 94 | $self->{$this} = $param{$this}; | ||
| 95 | } | ||
| 96 | |||
| 97 | $self->{'expire_session'} = $self->{'expire_session_re'} if $nes->{'query'}->{'q'}{'l_Remember'}; | ||
| 98 | |||
| 99 | return $self; | ||
| 100 | } | ||
| 101 | |||
| 102 | } | ||
| 103 | |||
| 104 | # don't forget to return a true value from the file | ||
| 105 | 1; | ||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 |