ZofCMS/Plugin/UserLogin.pm

filter: Statementstmt 13.1% 23 / 175 Branchbran 0.0% 0 / 98 Conditioncond 0.0% 0 / 47 MC/DCmcdc 0.0% 0 / 25 Subroutinesub 28.0% 7 / 25 Podpod 0.0% 0 / 17 totaltotal 7.7% 30 / 387 CC 71 SCAR 51.3
CC
71
Cov
7%
process
462.0
is_page_restricted
272.0
page_matches
72.0
CRAP 169.4
« ZofCMS/Plugin/FloodControl.pm ↑ Summary ZofCMS/Plugin/CRUD.pm »
1 package App::ZofCMS::Plugin::UserLogin;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.001010'; # VERSION
7  
8 1 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use HTML::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Digest::MD5 (qw/md5_hex/);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # create TABLE users (login TEXT, password VARCHAR(32), login_time VARCHAR(10), session_id VARCHAR(55), role VARCHAR(20));
14  
15  
16 0 ▶sub new { bless {}, shift }
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
17  
18 0 ▶sub process {
Subroutine process: not called CC=21 SCAR=61.4
Pod undocumented
19 0 my ( $self, $template, $query_ref, $config ) = @_;
20  
21  
22 return
23 unless $template->{plug_login}
24 0 ▶ or $config->conf->{plug_login};
Branch: 1 branch
BranchTrueFalseTotal
unless $template->{"plug_login"} or $config->conf->{"plug_login"} 0 0 0
Condition0%0/3
$template->{"plug_login"} or $config->conf->{"plug_login"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$template->{"plug_login"} or $config->conf->{"plug_login"}
$template->{"plug_login"} $config->conf->{"plug_login"}
Truth table0%0/3
A or B
A= $template->{"plug_login"}B= $config->conf->{"plug_login"}
ABresult
1X1
011
000
25  
26 my %opts = (
27 login_page => '/login',
28 table => 'users',
29 0 ▶ user_ref => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 my ( $user_ref, $template ) = @_;
31 0 $template->{d}{plug_login_user} = $user_ref;
32 },
33 opt => { RaiseError => 1, AutoCommit => 0 },
34 redirect_on_restricted => '/',
35  
36 login_button => '<input type="submit" class="input_submit" value="Login">',
37 logout_button => '<input type="submit" class="input_submit" value="Logout">',
38  
39 0 ▶ %{ $config->conf->{plug_login} || {} },
Condition0%0/2
$config->conf->{'plug_login'} || {}
l!l
00
MC/DC0%0/1
$config->conf->{'plug_login'} || {}
$config->conf->{'plug_login'}
Truth table0%0/2
A
A= $config->conf->{'plug_login'}
Aresult
11
00
40 0 ▶ %{ delete $template->{plug_login} || {} },
Condition0%0/2
delete $template->{'plug_login'} || {}
l!l
00
MC/DC0%0/1
delete $template->{'plug_login'} || {}
delete $template->{'plug_login'}
Truth table0%0/2
A
A= delete $template->{'plug_login'}
Aresult
11
00
41 );
42  
43 0 $self->opts( \%opts );
44  
45 $self->{COOKIE_LOGIN} = $config->cgi->cookie( $opts{preserve_login} )
46 if defined $opts{preserve_login}
47 and length $opts{preserve_login}
48 0 ▶ and not $opts{no_cookies};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"preserve_login"} and length $opts{"preserve_login"} and not $opts{"no_cookies"} 0 0 0
Condition0%0/6
defined $opts{"preserve_login"} and length $opts{"preserve_login"} and not $opts{"no_cookies"}
!ll&&!rl&&r
000
defined $opts{"preserve_login"} and length $opts{"preserve_login"}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $opts{"preserve_login"} and length $opts{"preserve_login"} and not $opts{"no_cookies"}
defined $opts{"preserve_login"} length $opts{"preserve_login"} not $opts{"no_cookies"}
Truth table0%0/4
A and B and not(C)
A= defined $opts{"preserve_login"}B= length $opts{"preserve_login"}C= not $opts{"no_cookies"}
ABCresult
0XX0
10X0
1100
1111
49  
50 0 my %query = %$query_ref;
51 0 for ( values %query ) {
52 0 ▶ $_ = ''
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 0 0
53 unless defined;
54 }
55 0 $query{page} = $query{dir} . $query{page};
56  
57 0 ▶ if ( ( ref $opts{login_page} eq 'Regexp'
Branch: 1 branch
BranchTrueFalseTotal
if (ref $opts{"login_page"} eq "Regexp" and $query{"page"} =~ /$opts{"login_page"}/ or not ref $opts{"login_page"} and $query{"page"} eq $opts{"login_page"}) 0 0 0
Condition0%0/9
ref $opts{"login_page"} eq "Regexp" and $query{"page"} =~ /$opts{"login_page"}/ or not ref $opts{"login_page"} and $query{"page"} eq $opts{"login_page"}
l!l&&r!l&&!r
000
ref $opts{"login_page"} eq "Regexp" and $query{"page"} =~ /$opts{"login_page"}/
!ll&&!rl&&r
000
not ref $opts{"login_page"} and $query{"page"} eq $opts{"login_page"}
!ll&&!rl&&r
000
MC/DC0%0/4
ref $opts{"login_page"} eq "Regexp" and $query{"page"} =~ /$opts{"login_page"}/ or not ref $opts{"login_page"} and $query{"page"} eq $opts{"login_page"}
ref $opts{"login_page"} eq "Regexp" $query{"page"} =~ /$opts{"login_page"}/ not ref $opts{"login_page"} $query{"page"} eq $opts{"login_page"}
Truth table0%0/7
A and B or not(C) and D
A= ref $opts{"login_page"} eq "Regexp"B= $query{"page"} =~ /$opts{"login_page"}/C= not ref $opts{"login_page"}D= $query{"page"} eq $opts{"login_page"}
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
58 and
59 $query{page} =~ /$opts{login_page}/
60 )
61 or (
62 not ref $opts{login_page}
63 and $query{page} eq $opts{login_page}
64 )
65 ) {
66 0 $self->process_login_page( $template, \%query, $config );
67 }
68  
69 0 my ( $user_ref, $user_ref_raw ) = $self->is_logged_in( \%query, $config );
70  
71 0 ▶ if ( $opts{user_ref} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"user_ref"}) 0 0 0
72 0 $opts{user_ref}->( $user_ref_raw, $template, $query_ref, $config->conf );
73 }
74  
75 0 ▶ if ( $self->is_page_restricted( $query{page}, $user_ref ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_page_restricted($query{"page"}, $user_ref)) 0 0 0
76 0 ▶ if ( $opts{redirect_on_restricted} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"redirect_on_restricted"}) 0 0 0
77 print $config->cgi->redirect(
78 $opts{redirect_on_restricted}
79 0 . process_smart_deny( \%opts )
80 );
81 0 exit;
82 }
83 }
84 0 ▶ if ( $user_ref ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($user_ref) 0 0 0
85 0 ▶ if ( exists $query{zofcms_plugin_login}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $query{'zofcms_plugin_login'} and $query{'zofcms_plugin_login'} eq 'logout_user') { } 0 0 0
Condition0%0/3
exists $query{"zofcms_plugin_login"} and $query{"zofcms_plugin_login"} eq "logout_user"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $query{"zofcms_plugin_login"} and $query{"zofcms_plugin_login"} eq "logout_user"
exists $query{"zofcms_plugin_login"} $query{"zofcms_plugin_login"} eq "logout_user"
Truth table0%0/3
A and B
A= exists $query{"zofcms_plugin_login"}B= $query{"zofcms_plugin_login"} eq "logout_user"
ABresult
0X0
100
111
86 and $query{zofcms_plugin_login} eq 'logout_user' ) {
87 0 $self->log_user_out( $user_ref );
88 0 ▶ if ( $opts{redirect_on_logout} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"redirect_on_logout"}) 0 0 0
89 0 print $config->cgi->redirect( $opts{redirect_on_logout} );
90 0 exit;
91 }
92 }
93 else {
94 0 my $t = HTML::Template->new_scalar_ref(
95 \ $self->logout_form_template()
96 );
97 $t->param(
98 page => $query{page},
99 logout_button => $opts{logout_button},
100 0 );
101 0 $template->{t}{plug_login_logout} = $t->output;
102 }
103  
104 0 $template->{t}{plug_login_user} = $user_ref->{login};
105 }
106  
107 0 return 1;
108 }
109  
110 0 ▶sub log_user_out {
Subroutine log_user_out: not called CC=1 SCAR=6.9
Pod undocumented
111 0 my ( $self, $user_ref ) = @_;
112 0 my $opts = $self->opts;
113  
114 my $dbh = DBI->connect_cached(
115 0 @$opts{ qw/dsn user pass opt/ },
116 );
117  
118 $dbh->do(
119 "UPDATE $opts->{table} SET session_id = ?, login_time = ? WHERE "
120 . "login = ?; ",
121 undef,
122 0,
123 0,
124 $user_ref->{login},
125 0 );
126 }
127  
128 0 ▶sub is_page_restricted {
Subroutine is_page_restricted: not called CC=16 SCAR=56.1
Pod undocumented
129 0 my ( $self, $page, $user_ref ) = @_;
130 0 my $opts = $self->opts;
131  
132 0 ▶ if ( $page eq $opts->{login_page} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($page eq $opts->{"login_page"}) 0 0 0
133 0 return;
134 }
135  
136 0 ▶ for ( @{ $opts->{not_restricted} || [] } ) {
Condition0%0/2
$opts->{'not_restricted'} || []
l!l
00
MC/DC0%0/1
$opts->{'not_restricted'} || []
$opts->{'not_restricted'}
Truth table0%0/2
A
A= $opts->{'not_restricted'}
Aresult
11
00
137 0 ▶ if ( $self->page_matches( $page, $_ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->page_matches($page, $_)) 0 0 0
138 0 ▶ if ( ref eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ eq 'HASH') { } 0 0 0
139 0 ▶ if ( exists $_->{role} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_->{'role'}) { } 0 0 0
140 0 ▶ return if ref $_->{role} eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_->{"role"} eq "SCALAR" 0 0 0
141 0 ▶ return exists $user_ref->{role}{ $_->{role} } ? () : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $user_ref->{'role'}{$_->{'role'}} ? : 0 0 0
142 }
143 else {
144 0 return;
145 }
146 }
147 else {
148 0 return;
149 }
150 }
151 }
152  
153 0 ▶ for ( @{ $opts->{restricted} || [] } ) {
Condition0%0/2
$opts->{'restricted'} || []
l!l
00
MC/DC0%0/1
$opts->{'restricted'} || []
$opts->{'restricted'}
Truth table0%0/2
A
A= $opts->{'restricted'}
Aresult
11
00
154 0 ▶ if ( $self->page_matches( $page, $_ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->page_matches($page, $_)) 0 0 0
155 0 ▶ defined $user_ref
Branch: 1 branch
BranchTrueFalseTotal
defined $user_ref or return 1 0 0 0
156 or return 1;
157  
158 0 ▶ if ( ref eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ eq 'HASH') { } 0 0 0
159 0 ▶ return 1 if ref $_->{role} eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_->{"role"} eq "SCALAR" 0 0 0
160 0 ▶ return exists $user_ref->{role}{ $_->{role} } ? 1 : ();
Branch: 1 branch
BranchTrueFalseTotal
exists $user_ref->{'role'}{$_->{'role'}} ? : 0 0 0
161 }
162 else {
163 0 return 0;
164 }
165 }
166 }
167  
168 0 return;
169 }
170  
171 0 ▶sub page_matches {
Subroutine page_matches: not called CC=8 SCAR=42.8
Pod undocumented
172 0 my ( $self, $page, $what ) = @_;
173  
174 0 ▶ if ( ref $what eq 'Regexp' ) {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $what eq 'Regexp') { } 0 0 0
elsif (ref $what eq 'HASH') { } 0 0 0
elsif ($what eq $page) { } 0 0 0
175 0 ▶ return $page =~ /$what/ ? 1 : ();
Branch: 1 branch
BranchTrueFalseTotal
$page =~ /$what/ ? : 0 0 0
176 }
177 elsif ( ref $what eq 'HASH' ) {
178 0 ▶ if ( ref $what->{page} eq 'Regexp' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $what->{'page'} eq 'Regexp') { } 0 0 0
elsif ($what->{'page'} eq $page) { } 0 0 0
179 0 ▶ return $page =~ /$what->{page}/ ? 1 : ();
Branch: 1 branch
BranchTrueFalseTotal
$page =~ /$what->{'page'}/ ? : 0 0 0
180 }
181 elsif ( $what->{page} eq $page ) {
182 0 return 1;
183 }
184 0 return 0;
185 }
186 elsif ( $what eq $page ) {
187 0 return 1;
188 }
189 0 return;
190 }
191  
192 0 ▶sub is_logged_in {
Subroutine is_logged_in: not called CC=8 SCAR=42.8
Pod undocumented
193 0 my ( $self, $query, $config) = @_;
194  
195 0 my $opts = $self->opts;
196 0 my ( $cookie_l, $cookie_s ) = ( $self->cookie_l, $self->cookie_s );
197 0 ▶ my $login_hash =
Branch: 1 branch
BranchTrueFalseTotal
defined $cookie_l ? : 0 0 0
198 defined $cookie_l ? $cookie_l : $config->cgi->cookie('zofcms_plug_login_l');
199  
200 0 ▶ my $session_id =
Branch: 1 branch
BranchTrueFalseTotal
defined $cookie_s ? : 0 0 0
201 defined $cookie_s ? $self->cookie_s : $config->cgi->cookie('zofcms_plug_login_s');
202  
203 my $dbh = DBI->connect_cached(
204 0 @$opts{ qw/dsn user pass opt/ }
205 );
206  
207 0 my $users = $dbh->selectall_arrayref(
208 "SELECT * FROM $opts->{table} WHERE session_id = ?",
209 undef,
210 $session_id,
211 );
212  
213 0 my $user_ref;
214 0 for ( @$users ) {
215 0 ▶ if ( md5_hex($_->[0]) eq $login_hash ) { # login
Branch: 1 branch
BranchTrueFalseTotal
if (md5_hex($_->[0]) eq $login_hash) 0 0 0
216 0 $user_ref = $_;
217 0 last;
218 }
219 }
220  
221 $user_ref
222 0 ▶ or return;
Branch: 1 branch
BranchTrueFalseTotal
$user_ref or return 0 0 0
223  
224 0 my $user_ref_raw = $user_ref;
225 0 @{ $user_ref = {} }{ qw/login password login_time session_id role/ }
226 = @$user_ref;
227 0 $user_ref->{role} = { map { $_ => 1 } split /,/, $user_ref->{role} };
228  
229 0 ▶ if ( $opts->{limited_time}
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"limited_time"} and $user_ref->{"login_time"} < time - $opts->{"limited_time"}) 0 0 0
Condition0%0/3
$opts->{"limited_time"} and $user_ref->{"login_time"} < time - $opts->{"limited_time"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"limited_time"} and $user_ref->{"login_time"} < time - $opts->{"limited_time"}
$opts->{"limited_time"} $user_ref->{"login_time"} < time - $opts->{"limited_time"}
Truth table0%0/3
A and B
A= $opts->{"limited_time"}B= $user_ref->{"login_time"} < time - $opts->{"limited_time"}
ABresult
0X0
100
111
230 and $user_ref->{login_time} < time() - $opts->{limited_time}
231 ) {
232 $dbh->do(
233 "UPDATE $opts->{table} SET login_time = ? WHERE login = ?;",
234 undef,
235 0,
236 $user_ref->{login},
237 0 );
238 0 return;
239 }
240  
241 $dbh->do(
242 "UPDATE $opts->{table} SET login_time = ? WHERE login = ?;",
243 undef,
244 time(),
245 $user_ref->{login},
246 0 );
247  
248 0 return $user_ref, $user_ref_raw;
249 }
250  
251 0 ▶sub process_login_page {
Subroutine process_login_page: not called CC=8 SCAR=42.8
Pod undocumented
252 0 my ( $self, $template, $query, $config ) = @_;
253 0 my $opts = $self->opts;
254  
255 0 $query->{login} = lc $query->{login};
256  
257 0 ▶ if ( $query->{zofcms_plugin_login} ne 'login_user' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query->{'zofcms_plugin_login'} ne 'login_user') { } 0 0 0
258 $template->{t}{plug_login_form} = $self->make_login_form(
259 login_button => $opts->{login_button},
260 page => $query->{page},
261 (
262 $opts->{preserve_login}
263 ? ( cookie_login => $self->{COOKIE_LOGIN} ) : ()
264 ),
265 smart_deny_name => $opts->{smart_deny},
266 smart_deny_value => $query->{ $opts->{smart_deny} },
267 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$opts->{'preserve_login'} ? : 0 0 0
268 0 return 1;
269 }
270 else {
271 0 my $session_id = $self->login_user( @$query{ qw/login pass/ } );
272 0 ▶ unless ( $session_id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($session_id) 0 0 0
273 $template->{t}{plug_login_form} = $self->make_login_form(
274 login_button => $opts->{login_button},
275 error => $self->login_error,
276 page => $query->{page},
277 (
278 $opts->{preserve_login}
279 ? ( cookie_login => $self->{COOKIE_LOGIN} ) : ()
280 ),
281 smart_deny_name => $opts->{smart_deny},
282 smart_deny_value => $query->{ $opts->{smart_deny} },
283 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$opts->{'preserve_login'} ? : 0 0 0
284 0 return;
285 }
286  
287 0 ▶ if ( $opts->{no_cookies} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'no_cookies'}) { } 0 0 0
288 0 $template->{t}{plug_login_session_id} = $session_id;
289 }
290 else {
291 print "Set-Cookie: $opts->{preserve_login}=$query->{login}; path=/; expires=Sat, 23 May 2037 23:38:25 GMT\n"
292 0 ▶ if $opts->{preserve_login};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"preserve_login"} 0 0 0
293  
294 0 print "Set-Cookie: zofcms_plug_login_s=$session_id; path=/;\n";
295 printf "Set-Cookie: zofcms_plug_login_l=%s; path=/;\n",
296 0 md5_hex($query->{login});
297 }
298  
299 0 ▶ if ( $opts->{redirect_on_login} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'redirect_on_login'}) { } 0 0 0
300 0 print $config->cgi->redirect(
301 process_smart_deny_logon( $opts, $query )
302 );
303 0 exit;
304 }
305 else {
306 0 $self->cookie_l( md5_hex($query->{login}) );
307 0 $self->cookie_s( $session_id );
308 }
309  
310 0 return 1;
311 }
312 }
313  
314 0 ▶sub login_user {
Subroutine login_user: not called CC=2 SCAR=17.9
Pod undocumented
315 0 my ( $self, $login, $pass ) = @_;
316 0 my $opts = $self->opts;
317  
318 0 $login = lc $login;
319  
320 my $dbh = DBI->connect_cached(
321 0 @$opts{ qw/dsn user pass opt/ }
322 );
323  
324 0 my $users_ref = $dbh->selectall_arrayref(
325 "SELECT * FROM $opts->{table} WHERE login = ? AND password = ?;",
326 undef,
327 $login,
328 md5_hex($pass),
329 );
330 # create TABLE users (login TEXT, password TEXT, login_time VARCHAR(10), session_id VARCHAR(55), role VARCHAR(20));
331 0 ▶ unless ( @$users_ref ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$users_ref) 0 0 0
332 0 $self->login_error("Invalid login or password");
333 0 return;
334 }
335  
336 0 my $session_id = rand() . rand() . rand();
337 0 $dbh->do(
338 "UPDATE $opts->{table} SET login_time = ?, session_id = ?"
339 . " WHERE login = ?;",
340 undef,
341 time(),
342 $session_id,
343 $login,
344 );
345  
346 0 return $session_id;
347 }
348  
349 0 ▶sub make_login_form {
Subroutine make_login_form: not called CC=3 SCAR=24.8
Pod undocumented
350 0 my ( $self, %args ) = @_;
351  
352 0 my $t = HTML::Template->new_scalar_ref( \ login_form_template() );
353  
354 $t->param(
355 %args,
356 smart_deny => (
357 (
358 defined $args{smart_deny_name}
359 and length $args{smart_deny_name}
360 0 ▶ ) ? 1 : 0
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'smart_deny_name'} && length $args{'smart_deny_name'} ? : 0 0 0
Condition0%0/3
defined $args{"smart_deny_name"} and length $args{"smart_deny_name"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"smart_deny_name"} and length $args{"smart_deny_name"}
defined $args{"smart_deny_name"} length $args{"smart_deny_name"}
Truth table0%0/3
A and B
A= defined $args{"smart_deny_name"}B= length $args{"smart_deny_name"}
ABresult
0X0
100
111
361 ),
362 );
363  
364 0 return $t->output;
365 }
366  
367 0 ▶sub opts {
Subroutine opts: not called CC=2 SCAR=17.9
Pod undocumented
368 0 my $self = shift;
369 0 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
370 0 $self->{OPTS} = shift;
371 }
372 0 return $self->{OPTS};
373 }
374  
375 0 ▶sub login_error {
Subroutine login_error: not called CC=2 SCAR=17.9
Pod undocumented
376 0 my $self = shift;
377 0 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
378 0 $self->{LOGIN_ERROR} = shift;
379 }
380 0 return $self->{LOGIN_ERROR};
381 }
382  
383 0 ▶sub process_smart_deny_logon {
Subroutine process_smart_deny_logon: not called CC=5 SCAR=34.0
Pod undocumented
384 0 my ( $opts, $q ) = @_;
385  
386 return $opts->{redirect_on_login}
387 unless defined $opts->{smart_deny}
388 and length $opts->{smart_deny}
389 and defined $q->{ $opts->{smart_deny} }
390 0 ▶ and length $q->{ $opts->{smart_deny} };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"smart_deny"} and length $opts->{"smart_deny"} and defined $$q{$opts->{"smart_deny"}} and length $$q{$opts->{"smart_deny"}} 0 0 0
Condition0%0/9
defined $opts->{"smart_deny"} and length $opts->{"smart_deny"} and defined $$q{$opts->{"smart_deny"}} and length $$q{$opts->{"smart_deny"}}
!ll&&!rl&&r
000
defined $opts->{"smart_deny"} and length $opts->{"smart_deny"} and defined $$q{$opts->{"smart_deny"}}
!ll&&!rl&&r
000
defined $opts->{"smart_deny"} and length $opts->{"smart_deny"}
!ll&&!rl&&r
000
MC/DC0%0/4
defined $opts->{"smart_deny"} and length $opts->{"smart_deny"} and defined $$q{$opts->{"smart_deny"}} and length $$q{$opts->{"smart_deny"}}
defined $opts->{"smart_deny"} length $opts->{"smart_deny"} defined $$q{$opts->{"smart_deny"}} length $$q{$opts->{"smart_deny"}}
Truth table0%0/5
A and B and C and D
A= defined $opts->{"smart_deny"}B= length $opts->{"smart_deny"}C= defined $$q{$opts->{"smart_deny"}}D= length $$q{$opts->{"smart_deny"}}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
391  
392 0 return $q->{ $opts->{smart_deny} };
393 }
394  
395 0 ▶sub process_smart_deny {
Subroutine process_smart_deny: not called CC=4 SCAR=25.0
Pod undocumented
396 0 my ( $opts ) = @_;
397  
398 return ''
399 unless defined $opts->{smart_deny}
400 0 ▶ and length $opts->{smart_deny};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"smart_deny"} and length $opts->{"smart_deny"} 0 0 0
Condition0%0/3
defined $opts->{"smart_deny"} and length $opts->{"smart_deny"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opts->{"smart_deny"} and length $opts->{"smart_deny"}
defined $opts->{"smart_deny"} length $opts->{"smart_deny"}
Truth table0%0/3
A and B
A= defined $opts->{"smart_deny"}B= length $opts->{"smart_deny"}
ABresult
0X0
100
111
401  
402 1 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
403  
404  
405 0 ▶ my $appended_value = $opts->{redirect_on_restricted} =~ /\?/
Branch: 1 branch
BranchTrueFalseTotal
$opts->{'redirect_on_restricted'} =~ /\?/ ? : 0 0 0
406 ? '' : '?';
407  
408 0 $appended_value .= $opts->{smart_deny} . '=' . uri_escape( $ENV{REQUEST_URI} );
409  
410 0 return $appended_value;
411 }
412  
413 0 ▶sub login_form_template {
Subroutine login_form_template: not called CC=1 SCAR=6.9
Pod undocumented
414 0 return <<'END_TEMPLATE';
415 <form action="" method="POST" id="zofcms_plugin_login">
416 <div><tmpl_if name="error"><p class="error"><tmpl_var escape="html" name="error"></p></tmpl_if>
417 <input type="hidden" name="page" value="<tmpl_var escape="html" name="page">">
418 <input type="hidden" name="zofcms_plugin_login" value="login_user">
419 <tmpl_if name="smart_deny">
420 <input type="hidden" name="<tmpl_var escape="html" name="smart_deny_name">" value="<tmpl_var escape="html" name="smart_deny_value">">
421 </tmpl_if>
422 <ul>
423 <li>
424 <label for="zofcms_plugin_login_login">Login: </label
425 ><input type="text" class="input_text" name="login" id="zofcms_plugin_login_login" value="<tmpl_var escape='html' name='cookie_login'>">
426 </li>
427 <li>
428 <label for="zofcms_plugin_login_pass">Password: </label
429 ><input type="password" class="input_password" name="pass" id="zofcms_plugin_login_pass">
430 </li>
431 </ul>
432 <tmpl_var name='login_button'>
433 </div>
434 </form>
435 END_TEMPLATE
436 }
437  
438 0 ▶sub logout_form_template {
Subroutine logout_form_template: not called CC=1 SCAR=6.9
Pod undocumented
439 0 return <<'END_TEMPLATE';
440 <form action="" method="POST" id="zofcms_plugin_login_logout">
441 <div><tmpl_if name="error"><p class="error"><tmpl_var escape="html" name="error"></p></tmpl_if>
442 <input type="hidden" name="page" value="<tmpl_var escape="html" name="page">">
443 <input type="hidden" name="zofcms_plugin_login" value="logout_user">
444 <tmpl_var name='logout_button'>
445 </div>
446 </form>
447 END_TEMPLATE
448 }
449  
450 0 ▶sub cookie_l {
Subroutine cookie_l: not called CC=2 SCAR=17.9
Pod undocumented
451 0 my $self = shift;
452 0 ▶ @_ and $self->{COOKIE_L} = shift;
Branch: 1 branch
BranchTrueFalseTotal
@_ and $self->{"COOKIE_L"} = shift() 0 0 0
453 0 $self->{COOKIE_L};
454 }
455  
456 0 ▶sub cookie_s {
Subroutine cookie_s: not called CC=2 SCAR=17.9
Pod undocumented
457 0 my $self = shift;
458 0 ▶ @_ and $self->{COOKIE_S} = shift;
Branch: 1 branch
BranchTrueFalseTotal
@_ and $self->{"COOKIE_S"} = shift() 0 0 0
459 0 $self->{COOKIE_S};
460 }
461  
462 1 1;
463 __END__
« ZofCMS/Plugin/FloodControl.pm ↑ Summary ZofCMS/Plugin/CRUD.pm »