| 1 | package CGI::Ex; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | CGI::Ex - CGI utility suite - makes powerful application writing fun and easy | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | version 2.54 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =for markdown [](https://travis-ci.org/ljepson/CGI-Ex) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =for HTML <a href="https://travis-ci.org/ljepson/CGI-Ex"><img src="https://travis-ci.org/ljepson/CGI-Ex.svg?branch=master"></a> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # Copyright - Paul Seamons # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # Distributed under the Perl Artistic License without warranty # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ### See perldoc at bottom | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 9 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 9 | our $VERSION = '2.54'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 9 | our ($PREFERRED_CGI_MODULE, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | $PREFERRED_CGI_REQUIRED, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | $AUTOLOAD, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | $DEBUG_LOCATION_BOUNCE, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | @EXPORT, @EXPORT_OK | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 9 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 9 | ▶ | $PREFERRED_CGI_MODULE ||= 'CGI'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=7 SCAR=28.7
Condition50%1/2
$CGI::Ex::PREFERRED_CGI_MODULE ||= "CGI"
MC/DC0%0/1
$CGI::Ex::PREFERRED_CGI_MODULE ||= "CGI"
$CGI::Ex::PREFERRED_CGI_MODULE
Truth table50%1/2
A
A= $CGI::Ex::PREFERRED_CGI_MODULE
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 9 | @EXPORT = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 9 | @EXPORT_OK = qw(get_form | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | get_cookies | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | print_content_type | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | content_type | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | content_typed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | set_cookie | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | location_bounce | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ### cache mod_perl version (light if or if not mod_perl) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | my $v = (! $ENV{'MOD_PERL'}) ? 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # mod_perl/1.27 or mod_perl/1.99_16 or mod_perl/2.0.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # if MOD_PERL is set - don't die if regex fails - just assume 1.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 9 | ▶ | : ($ENV{'MOD_PERL'} =~ m{ ^ mod_perl / (\d+\.[\d_]+) (?: \.\d+)? $ }x) ? $1 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | : '1.0_0'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub _mod_perl_version () { $v } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mod_perl_version: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 9 | ▶ | sub _is_mod_perl_1 () { $v < 1.98 && $v > 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_mod_perl_1: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 9 | ▶ | sub _is_mod_perl_2 () { $v >= 1.98 } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_mod_perl_2: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ### cache apache request getter (light if or if not mod_perl) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 9 | my $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 9 | ▶ | if (_is_mod_perl_1) { # old mod_perl | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | require Apache; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $sub = sub { Apache->request }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } elsif (_is_mod_perl_2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if (eval { require Apache2::RequestRec }) { # debian style | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | require Apache2::RequestUtil; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $sub = sub { Apache2::RequestUtil->request }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } else { # fedora and mandrake style | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | require Apache::RequestUtil; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $sub = sub { Apache->request }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 9 | ▶ | $sub = sub {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 13 | ▶ | sub apache_request_sub () { $sub } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apache_request_sub: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # my $cgix = CGI::Ex->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 16 | ▶ | my $class = shift || die "Missing class name"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.1
Pod
undocumented
Condition50%1/2
shift() || die('Missing class name')
MC/DC0%0/1
shift() || die('Missing class name')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 16 | ▶ | my $self = ref($_[0]) ? shift : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 16 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ### allow for holding another classed CGI style object | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # my $query = $cgix->object; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # $cgix->object(CGI->new); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | sub object { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 6 | ▶ | my $self = shift || die 'Usage: my $query = $cgix_obj->object'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object: called CC=7 SCAR=20.6
Pod
documented
Condition50%1/2
shift() || die('Usage: my $query = $cgix_obj->object')
MC/DC0%0/1
shift() || die('Usage: my $query = $cgix_obj->object')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 6 | ▶ | $self->{'object'} = shift if $#_ != -1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 6 | ▶ | if (! defined $self->{'object'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 3 | ▶ | $PREFERRED_CGI_REQUIRED ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$PREFERRED_CGI_REQUIRED ||= do {
my $file = $self->{"cgi_module"} || $PREFERRED_CGI_MODULE;
$file .= '.pm';
$file =~ s[::][/]g;
eval {
do {
require $file
}
};
die "Couldn't require ${PREFERRED_CGI_MODULE}: $@" if $@;
1
}
MC/DC0%0/2
$PREFERRED_CGI_REQUIRED ||= do {
my $file = $self->{"cgi_module"} || $PREFERRED_CGI_MODULE;
$file .= '.pm';
$file =~ s[::][/]g;
eval {
do {
require $file
}
};
die "Couldn't require ${PREFERRED_CGI_MODULE}: $@" if $@;
1
}
$PREFERRED_CGI_REQUIRED
do {
my $file = $self->{"cgi_module"} || $PREFERRED_CGI_MODULE;
$file .= '.pm';
$file =~ s[::][/]g;
eval {
do {
require $file
}
};
die "Couldn't require ${PREFERRED_CGI_MODULE}: $@" if $@;
1
}
Truth table33%1/3
A ||= B
A= $PREFERRED_CGI_REQUIREDB= do {
my $file = $self->{"cgi_module"} || $PREFERRED_CGI_MODULE;
$file .= '.pm';
$file =~ s[::][/]g;
eval {
do {
require $file
}
};
die "Couldn't require ${PREFERRED_CGI_MODULE}: $@" if $@;
1
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | my $file = $self->{'cgi_module'} || $PREFERRED_CGI_MODULE; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'cgi_module'} || $PREFERRED_CGI_MODULE
MC/DC0%0/2
$self->{'cgi_module'} || $PREFERRED_CGI_MODULE
$self->{'cgi_module'}
$PREFERRED_CGI_MODULE
Truth table33%1/3
A || B
A= $self->{'cgi_module'}B= $PREFERRED_CGI_MODULE
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | $file .= ".pm"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | $file =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | eval { require $file }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | ▶ | die "Couldn't require $PREFERRED_CGI_MODULE: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | 1; # return of do | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | $self->{'object'} = $PREFERRED_CGI_MODULE->new; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 6 | return $self->{'object'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ### allow for calling CGI MODULE methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my $meth = ($AUTOLOAD =~ /(\w+)$/) ? $1 : die "Invalid method $AUTOLOAD"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | return $self->object->$meth(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ▶ | sub DESTROY { } | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ### Form getter that will act like CGI->new->Vars only it will return arrayrefs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ### for values that are arrays | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # my $hash = $cgix->get_form; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # my $hash = $cgix->get_form(CGI->new); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # my $hash = get_form(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # my $hash = get_form(CGI->new); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | sub get_form { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 6 | ▶ | my $self = shift || __PACKAGE__->new; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_form: called CC=9 SCAR=24.1
Pod
documented
Condition33%1/3
shift() || __PACKAGE__->new
MC/DC0%0/2
shift() || __PACKAGE__->new
shift()
__PACKAGE__->new
Truth table33%1/3
A || B
A= shift()B= __PACKAGE__->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 6 | ▶ | if (! $self->isa(__PACKAGE__)) { # get_form(CGI->new) syntax | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $obj = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self = __PACKAGE__->new; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->object($obj); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 6 | ▶ | return $self->{'form'} if $self->{'form'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ### get the info out of the object | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 4 | ▶ | my $obj = shift || $self->object; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
shift() || $self->object
MC/DC0%0/2
shift() || $self->object
shift()
$self->object
Truth table66%2/3
A || B
A= shift()B= $self->object
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | my %hash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | ### this particular use of $cgi->param in list context is safe | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 4 | local $CGI::LIST_CONTEXT_WARN = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 4 | ▶ | my $mp = $obj->can('multi_param') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 4 | foreach my $key ($obj->param) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | ▶ | my @val = $mp ? $obj->multi_param($key) : $obj->param($key); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | ▶ | $hash{$key} = ($#val <= 0) ? $val[0] : \@val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 4 | return $self->{'form'} = \%hash; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ### allow for a setter | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ### $cgix->set_form(\%form); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | sub set_form { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | ▶ | my $self = shift || die 'Usage: $cgix_obj->set_form(\%form)'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_form: called CC=3 SCAR=12.0
Pod
documented
Condition50%1/2
shift() || die('Usage: $cgix_obj->set_form(\\%form)')
MC/DC0%0/1
shift() || die('Usage: $cgix_obj->set_form(\\%form)')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | ▶ | return $self->{'form'} = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ### Combined get and set form | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # my $hash = $cgix->form; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # $cgix->form(\%form); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub form { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | ▶ | return $self->set_form(shift) if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | return $self->get_form; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ### allow for creating a url encoded key value sequence | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # my $str = $cgix->make_form(\%form); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # my $str = $cgix->make_form(\%form, \@keys_to_include); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | sub make_form { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | my $self = shift || die 'Usage: $cgix_obj->make_form(\%form)'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_form: called CC=7 SCAR=19.9
Pod
documented
Condition50%1/2
shift() || die('Usage: $cgix_obj->make_form(\\%form)')
MC/DC0%0/1
shift() || die('Usage: $cgix_obj->make_form(\\%form)')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | ▶ | my $form = shift || $self->get_form; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
shift() || $self->get_form
MC/DC0%0/2
shift() || $self->get_form
shift()
$self->get_form
Truth table33%1/3
A || B
A= shift()B= $self->get_form
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | ▶ | my $keys = ref($_[0]) ? shift : [sort keys %$form]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | my $str = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | foreach (@$keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | my $key = $_; # make a copy | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | my $val = $form->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 3 | $key =~ s/([^\w.\-\ ])/sprintf('%%%02X', ord $1)/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | $key =~ y/ /+/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 3 | ▶ | foreach (ref($val) eq 'ARRAY' ? @$val : $val) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 5 | my $_val = $_; # make a copy | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 5 | $_val =~ s/([^\w.\-\ ])/sprintf('%%%02X', ord $1)/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 5 | $_val =~ y/ /+/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 5 | $str .= "$key=$_val&"; # intentionally not using join | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | chop $str; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ### like get_form - but a hashref of cookies | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ### cookies are parsed depending upon the functionality of ->cookie | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # my $hash = $cgix->get_cookies; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # my $hash = $cgix->get_cookies(CGI->new); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # my $hash = get_cookies(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # my $hash = get_cookies(CGI->new); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | sub get_cookies { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 3 | ▶ | my $self = shift || __PACKAGE__->new; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cookies: called CC=8 SCAR=24.5
Pod
documented
Condition33%1/3
shift() || __PACKAGE__->new
MC/DC0%0/2
shift() || __PACKAGE__->new
shift()
__PACKAGE__->new
Truth table33%1/3
A || B
A= shift()B= __PACKAGE__->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 3 | ▶ | if (! $self->isa(__PACKAGE__)) { # get_cookies(CGI->new) syntax | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $obj = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $self = __PACKAGE__->new; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $self->object($obj); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 3 | ▶ | return $self->{'cookies'} if $self->{'cookies'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | ▶ | my $obj = shift || $self->object; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
shift() || $self->object
MC/DC0%0/2
shift() || $self->object
shift()
$self->object
Truth table33%1/3
A || B
A= shift()B= $self->object
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | my %hash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | foreach my $key ($obj->cookie) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | my @val = $obj->cookie($key); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | $hash{$key} = ($#val == -1) ? "" : ($#val == 0) ? $val[0] : \@val; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | return $self->{'cookies'} = \%hash; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | ### Allow for a setter | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | ### $cgix->set_cookies(\%cookies); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | sub set_cookies { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | ▶ | my $self = shift || die 'Usage: $cgix_obj->set_cookies(\%cookies)'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_cookies: called CC=3 SCAR=12.0
Pod
documented
Condition50%1/2
shift() || die('Usage: $cgix_obj->set_cookies(\\%cookies)')
MC/DC0%0/1
shift() || die('Usage: $cgix_obj->set_cookies(\\%cookies)')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | return $self->{'cookies'} = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | ### Combined get and set cookies | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # my $hash = $cgix->cookies; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # $cgix->cookies(\%cookies); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | sub cookies { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cookies: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 3 | ▶ | return $self->set_cookies(shift) if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | return $self->get_cookies; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | ### Allow for shared apache request object | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # my $r = $cgix->apache_request | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # $cgix->apache_request($r); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | sub apache_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 13 | ▶ | my $self = shift || die 'Usage: $cgix_obj->apache_request'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apache_request: called CC=4 SCAR=16.1
Pod
undocumented
Condition50%1/2
shift() || die('Usage: $cgix_obj->apache_request')
MC/DC0%0/1
shift() || die('Usage: $cgix_obj->apache_request')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 13 | ▶ | $self->{'apache_request'} = shift if $#_ != -1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 13 | ▶ | return $self->{'apache_request'} ||= apache_request_sub()->(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"apache_request"} ||= &apache_request_sub()->()
MC/DC0%0/2
$self->{"apache_request"} ||= &apache_request_sub()->()
$self->{"apache_request"}
&apache_request_sub()->()
Truth table33%1/3
A ||= B
A= $self->{"apache_request"}B= &apache_request_sub()->()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ### Get the version of mod_perl running (0 if not mod_perl) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | # my $version = $cgix->mod_perl_version; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub mod_perl_version { _mod_perl_version } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mod_perl_version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | sub is_mod_perl_1 { _is_mod_perl_1 } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_mod_perl_1: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub is_mod_perl_2 { _is_mod_perl_2 } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_mod_perl_2: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ### Allow for a setter | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # $cgix->set_apache_request($r) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub set_apache_request { shift->apache_request(shift) } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_apache_request: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | ### same signature as print_content_type | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub content_type { &print_content_type } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_type: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ### will send the Content-type header | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # $cgix->print_content_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # $cgix->print_content_type('text/plain'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # print_content_type(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # print_content_type('text/plain); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | sub print_content_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 10 | ▶ | my ($self, $type, $charset) = (@_ && ref $_[0]) ? @_ : (undef, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_content_type: called CC=12 SCAR=27.4
Pod
undocumented
Branch: 1 branch
Condition100%3/3
@_ and ref $_[0]
MC/DC100%2/2
@_ and ref $_[0]
@_
ref $_[0]
Truth table100%3/3
A and B
A= @_B= ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 10 | ▶ | $self = __PACKAGE__->new if ! $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 10 | ▶ | if ($type) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 8 | ▶ | die "Invalid type: $type" if $type !~ m|^[\w\-\.]+/[\w\-\.\+]+$|; # image/vid.x-foo | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | $type = 'text/html'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 10 | ▶ | $type .= "; charset=$charset" if $charset && $charset =~ m|^[\w\-\.\:\+]+$|; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$charset and $charset =~ /^[\w\-\.\:\+]+$/
MC/DC50%1/2
$charset and $charset =~ /^[\w\-\.\:\+]+$/
$charset
$charset =~ /^[\w\-\.\:\+]+$/
Truth table66%2/3
A and B
A= $charsetB= $charset =~ /^[\w\-\.\:\+]+$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 10 | ▶ | if (my $r = $self->apache_request) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | return if $r->bytes_sent; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $r->content_type($type); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | $r->send_http_header if $self->is_mod_perl_1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 10 | ▶ | if (! $ENV{'CONTENT_TYPED'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 10 | print "Content-Type: $type\r\n\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 10 | $ENV{'CONTENT_TYPED'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 10 | $ENV{'CONTENT_TYPED'} .= sprintf("%s, %d\n", (caller)[1,2]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ### Boolean check if content has been typed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # $cgix->content_typed; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # content_typed(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | sub content_typed { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | ▶ | my $self = shift || __PACKAGE__->new; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_typed: called CC=4 SCAR=15.6
Pod
undocumented
Condition33%1/3
shift() || __PACKAGE__->new
MC/DC0%0/2
shift() || __PACKAGE__->new
shift()
__PACKAGE__->new
Truth table33%1/3
A || B
A= shift()B= __PACKAGE__->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | ▶ | if (my $r = $self->apache_request) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | return $r->bytes_sent; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | ▶ | return $ENV{'CONTENT_TYPED'} ? 1 : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | ### location bounce nicely - even if we have already sent content | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | ### may be called as function or a method | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # $cgix->location_bounce($url); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # location_bounce($url); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | sub location_bounce { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | my ($self, $loc) = ($#_ == 1) ? (@_) : (undef, shift); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
location_bounce: not called CC=9 SCAR=45.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | $self = __PACKAGE__->new if ! $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | $loc =~ s{(\s)}{sprintf("%%%02X", ord $1)}xge if $loc; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $html_loc = $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if ($html_loc) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $html_loc =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $html_loc =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $html_loc =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $html_loc =~ s/\"/"/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ($self->content_typed) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if ($DEBUG_LOCATION_BOUNCE) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | print "<a class=debug href=\"$html_loc\">Location: $html_loc</a><br />\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | print "<meta http-equiv=\"refresh\" content=\"0;url=$html_loc\" />\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } elsif (my $r = $self->apache_request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $r->status(302); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ($self->is_mod_perl_1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $r->header_out("Location", $loc); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $r->content_type('text/html'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $r->send_http_header; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $r->print("Bounced to $html_loc\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $r->headers_out->add("Location", $loc); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $r->rflush; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $r->custom_response(302, "Bounced to $html_loc\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | print "Location: $loc\r\n", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | "Status: 302 Bounce\r\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | "Content-Type: text/html\r\n\r\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | "Bounced to $html_loc\r\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | ### set a cookie nicely - even if we have already sent content | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | ### may be called as function or a method - fancy algo to allow for first argument of args hash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # $cgix->set_cookie({name => $name, ...}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # $cgix->set_cookie( name => $name, ... ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # set_cookie({name => $name, ...}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # set_cookie( name => $name, ... ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | sub set_cookie { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 2 | ▶ | my $self = UNIVERSAL::isa($_[0], __PACKAGE__) ? shift : __PACKAGE__->new; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_cookie: called CC=10 SCAR=26.4
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | ▶ | my $args = ref($_[0]) ? shift : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | foreach (keys %$args) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | ▶ | next if /^-/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 4 | $args->{"-$_"} = delete $args->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | ### default path to / and allow for 1hour instead of 1h | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | ▶ | $args->{-path} ||= '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"-path"} ||= "/"
MC/DC0%0/1
$args->{"-path"} ||= "/"
$args->{"-path"}
Truth table50%1/2
A
A= $args->{"-path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 2 | ▶ | $args->{-expires} = time_calc($args->{-expires}) if $args->{-expires}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 2 | my $obj = $self->object; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 2 | my $cookie = "" . $obj->cookie(%$args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 2 | ▶ | if ($self->content_typed) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 1 | print "<script>document.cookie = '$cookie'</script>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | ▶ | if (my $r = $self->apache_request) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if ($self->is_mod_perl_1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $r->header_out("Set-cookie", $cookie); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $r->headers_out->add("Set-Cookie", $cookie); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | print "Set-Cookie: $cookie\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | ### print the last modified time | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | ### takes a time or filename and an optional keyname | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # $cgix->last_modified; # now | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # $cgix->last_modified((stat $file)[9]); # file's time | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # $cgix->last_modified(time, 'Expires'); # different header | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | sub last_modified { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | my $self = shift || die 'Usage: $cgix_obj->last_modified($time)'; # may be called as function or method | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_modified: not called CC=7 SCAR=40.3
Pod
documented
Condition0%0/2
shift() || die('Usage: $cgix_obj->last_modified($time)')
MC/DC0%0/1
shift() || die('Usage: $cgix_obj->last_modified($time)')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | my $time = shift || time; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || time
MC/DC0%0/2
shift() || time
shift()
time
Truth table0%0/3
A || B
A= shift()B= time
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | my $key = shift || 'Last-Modified'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'Last-Modified'
MC/DC0%0/1
shift() || 'Last-Modified'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | ### get a time string - looks like: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | ### Mon Dec 9 18:03:21 2002 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | ### valid RFC (although not prefered) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $time = scalar gmtime time_calc($time); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | if ($self->content_typed) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | print "<meta http-equiv=\"$key\" content=\"$time\" />\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } elsif (my $r = $self->apache_request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | if ($self->is_mod_perl_1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $r->header_out($key, $time); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $r->headers_out->add($key, $time); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | print "$key: $time\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | ### add expires header | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | sub expires { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | my $self = ref($_[0]) ? shift : __PACKAGE__->new; # may be called as a function or method | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expires: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | my $time = shift || time; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || time
MC/DC0%0/2
shift() || time
shift()
time
Truth table0%0/3
A || B
A= shift()B= time
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | return $self->last_modified($time, 'Expires'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | ### similar to expires_calc from CGI::Util | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | ### allows for lenient calling, hour instead of just h, etc | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ### takes time or 0 or now or filename or types of -23minutes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | sub time_calc { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 7 | ▶ | my $time = shift; # may only be called as a function | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time_calc: called CC=7 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 7 | ▶ | if (! $time || lc($time) eq 'now') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
not $time or lc $time eq "now"
MC/DC50%1/2
not $time or lc $time eq "now"
not $time
lc $time eq "now"
Truth table66%2/3
not(A) or B
A= not $timeB= lc $time eq "now"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 1 | return time; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } elsif ($time =~ m/^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | return $time; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } elsif ($time =~ m/^([+-]?)\s*(\d+|\d*\.\d+)\s*([a-z])[a-z]*$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 4 | my $m = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 's' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 'm' => 60, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 'h' => 60 * 60, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 'd' => 60 * 60 * 24, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 'w' => 60 * 60 * 24 * 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 'M' => 60 * 60 * 24 * 30, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 'y' => 60 * 60 * 24 * 365, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 4 | ▶ | return time + ($m->{lc($3)} || 1) * "$1$2"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$m{lc $3} || 1
MC/DC0%0/1
$$m{lc $3} || 1
$$m{lc $3}
Truth table50%1/2
A
A= $$m{lc $3}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 1 | my @stat = stat $time; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1 | ▶ | die "Could not find file \"$time\" for time_calc. You should pass one of \"now\", time(), \"[+-] \\d+ [smhdwMy]\" or a filename." if $#stat == -1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | return $stat[9]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | ### allow for generic status send | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | sub send_status { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | my $self = shift || die 'Usage: $cgix_obj->send_status(302 => "Bounced")'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_status: not called CC=7 SCAR=40.3
Pod
documented
Condition0%0/2
shift() || die('Usage: $cgix_obj->send_status(302 => "Bounced")')
MC/DC0%0/1
shift() || die('Usage: $cgix_obj->send_status(302 => "Bounced")')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | my $code = shift || die "Missing status"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die('Missing status')
MC/DC0%0/1
shift() || die('Missing status')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $mesg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if (! defined $mesg) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | $mesg = "HTTP Status of $code received\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if ($self->content_typed) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | die "Cannot send a status ($code - $mesg) after content has been sent"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | if (my $r = $self->apache_request) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $r->status($code); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | if ($self->is_mod_perl_1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $r->content_type('text/html'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | $r->send_http_header; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $r->print($mesg); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $r->content_type('text/html'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $r->print($mesg); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $r->rflush; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | print "Status: $code\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $self->print_content_type; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | print $mesg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | ### allow for sending a simple header | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | sub send_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | my $self = shift || die 'Usage: $cgix_obj->send_header'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_header: not called CC=5 SCAR=34.0
Pod
documented
Condition0%0/2
shift() || die('Usage: $cgix_obj->send_header')
MC/DC0%0/1
shift() || die('Usage: $cgix_obj->send_header')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | if ($self->content_typed) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | die "Cannot send a header ($key - $val) after content has been sent"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | if (my $r = $self->apache_request) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | if ($self->is_mod_perl_1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $r->header_out($key, $val); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $r->headers_out->add($key, $val); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | print "$key: $val\r\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | ### allow for printing out a static javascript file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | ### for example $self->print_js("CGI::Ex::validate.js"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | sub print_js { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | my $self = shift || die 'Usage: $cgix_obj->print_js($js_file)'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_js: not called CC=16 SCAR=56.1
Pod
documented
Condition0%0/2
shift() || die('Usage: $cgix_obj->print_js($js_file)')
MC/DC0%0/1
shift() || die('Usage: $cgix_obj->print_js($js_file)')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | my $js_file = shift || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | $self = $self->new if ! ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | ### fix up the file - force .js on the end | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | $js_file .= '.js' if $js_file && $js_file !~ /\.js$/i; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$js_file and not $js_file =~ /\.js$/i
MC/DC0%0/2
$js_file and not $js_file =~ /\.js$/i
$js_file
not $js_file =~ /\.js$/i
Truth table0%0/3
A and not(B)
A= $js_fileB= not $js_file =~ /\.js$/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $js_file =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | ### get file info | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my $stat; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if ($js_file && $js_file =~ m|^/*(\w+(?:/+\w+)*\.js)$|i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$js_file and $js_file =~ m[^/*(\w+(?:/+\w+)*\.js)$]i
MC/DC0%0/2
$js_file and $js_file =~ m[^/*(\w+(?:/+\w+)*\.js)$]i
$js_file
$js_file =~ m[^/*(\w+(?:/+\w+)*\.js)$]i
Truth table0%0/3
A and B
A= $js_fileB= $js_file =~ m[^/*(\w+(?:/+\w+)*\.js)$]i
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | foreach my $path (@INC) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $_file = "$path/$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | next if ! -f $_file; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $js_file = $_file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $stat = [stat _]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ### no file = 404 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | if (! $stat) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | if (! $self->content_typed) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $self->send_status(404, "JS File not found for print_js\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | print "<h1>JS File not found for print_js</h1>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | ### do headers | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | if (! $self->content_typed) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | $self->last_modified($stat->[9]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | $self->expires('+ 1 year'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | $self->print_content_type('application/x-javascript'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | return if $ENV{'REQUEST_METHOD'} && $ENV{'REQUEST_METHOD'} eq 'HEAD'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"REQUEST_METHOD"} and $ENV{"REQUEST_METHOD"} eq "HEAD"
MC/DC0%0/2
$ENV{"REQUEST_METHOD"} and $ENV{"REQUEST_METHOD"} eq "HEAD"
$ENV{"REQUEST_METHOD"}
$ENV{"REQUEST_METHOD"} eq "HEAD"
Truth table0%0/3
A and B
A= $ENV{"REQUEST_METHOD"}B= $ENV{"REQUEST_METHOD"} eq "HEAD"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | ### send the contents | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | local *FH; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | open(FH, "<$js_file") || die "Couldn't open file $js_file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | print <FH>; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | close FH; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | ### form filler that will use either HTML::FillInForm, CGI::Ex::Fill | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | ### or another specified filler. Argument style is similar to | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | ### HTML::FillInForm. May be called as a method or a function. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | sub fill { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 10 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fill: called CC=19 SCAR=45.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 10 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 10 | ▶ | if (ref($args)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | if (! UNIVERSAL::isa($args, 'HASH')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | $args = {text => $args}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | @$args{'form','target','fill_password','ignore_fields'} = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 10 | $args = {$args, @_}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 10 | ▶ | my $module = $self->{'fill_module'} || 'CGI::Ex::Fill'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'fill_module'} || 'CGI::Ex::Fill'
MC/DC0%0/1
$self->{'fill_module'} || 'CGI::Ex::Fill'
$self->{'fill_module'}
Truth table50%1/2
A
A= $self->{'fill_module'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | ### allow for using the standard HTML::FillInForm | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | ### too bad it won't modify our file in place for us | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 10 | ▶ | if ($module eq 'HTML::FillInForm') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | eval { require HTML::FillInForm }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | die "Couldn't require HTML::FillInForm: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | $args->{scalarref} = $args->{text} if $args->{text}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | $args->{fdat} = $args->{form} if $args->{form}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $filled = HTML::FillInForm->new->fill(%$args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | if ($args->{text}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my $ref = $args->{text}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $$ref = $filled; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | return $filled; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 10 | require CGI::Ex::Fill; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | ### get the text to work on | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 10 | my $ref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 10 | ▶ | if ($args->{text}) { # preferred method - gets modified in place | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 1 | $ref = $args->{text}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } elsif ($args->{scalarref}) { # copy to mimic HTML::FillInForm | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 8 | my $str = ${ $args->{scalarref} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 8 | $ref = \$str; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } elsif ($args->{arrayref}) { # joined together (copy) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 1 | my $str = join "", @{ $args->{arrayref} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 1 | $ref = \$str; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } elsif ($args->{file}) { # read it in | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | open (IN, $args->{file}) || die "Couldn't open $args->{file}: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $str = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | read(IN, $str, -s _) || die "Couldn't read $args->{file}: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | close IN; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $ref = \$str; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | die "No suitable text found for fill."; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | ### allow for data to be passed many ways | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | my $form = $args->{form} || $args->{fobject} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 10 | ▶ | || $args->{fdat} || $self->object; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%3/9
$args->{'form'} || $args->{'fobject'} || $args->{'fdat'} || $self->object
$args->{"form"} or $args->{"fobject"} or $args->{"fdat"}
$args->{"form"} or $args->{"fobject"}
MC/DC0%0/4
$args->{'form'} || $args->{'fobject'} || $args->{'fdat'} || $self->object
$args->{"form"}
$args->{"fobject"}
$args->{"fdat"}
$self->object
Truth table20%1/5
A or B or C || D
A= $args->{"form"}B= $args->{"fobject"}C= $args->{"fdat"}D= $self->object
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | CGI::Ex::Fill::form_fill($ref, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | $form, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | $args->{target}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | $args->{fill_password}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | $args->{ignore_fields}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 10 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 10 | ▶ | return ! $args->{text} ? $$ref : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | sub validate { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 2 | ▶ | my $self = shift || die 'Usage: my $er = $cgix_obj->validate($form, $val_hash_or_file)'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: called CC=4 SCAR=14.5
Pod
documented
Condition50%1/2
shift() || die('Usage: my $er = $cgix_obj->validate($form, $val_hash_or_file)')
MC/DC0%0/1
shift() || die('Usage: my $er = $cgix_obj->validate($form, $val_hash_or_file)')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 2 | ▶ | my ($form, $file) = (@_ == 2) ? (shift, shift) : ($self->object, shift); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 2 | require CGI::Ex::Validate; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 2 | my $args = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 2 | ▶ | $args->{raise_error} = 1 if $self->{raise_error}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 2 | return CGI::Ex::Validate->new($args)->validate($form, $file); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | sub conf_obj { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | my $self = shift || die 'Usage: my $ob = $cgix_obj->conf_obj($args)'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conf_obj: not called CC=3 SCAR=24.8
Pod
undocumented
Condition0%0/2
shift() || die('Usage: my $ob = $cgix_obj->conf_obj($args)')
MC/DC0%0/1
shift() || die('Usage: my $ob = $cgix_obj->conf_obj($args)')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | return $self->{conf_obj} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"conf_obj"} ||= do {
require CGI::Ex::Conf;
"CGI::Ex::Conf"->new(@_)
}
MC/DC0%0/2
$self->{"conf_obj"} ||= do {
require CGI::Ex::Conf;
"CGI::Ex::Conf"->new(@_)
}
$self->{"conf_obj"}
do {
require CGI::Ex::Conf;
"CGI::Ex::Conf"->new(@_)
}
Truth table0%0/3
A ||= B
A= $self->{"conf_obj"}B= do {
require CGI::Ex::Conf;
"CGI::Ex::Conf"->new(@_)
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | require CGI::Ex::Conf; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | CGI::Ex::Conf->new(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | sub conf_read { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | my $self = shift || die 'Usage: my $conf = $cgix_obj->conf_read($file)'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conf_read: not called CC=2 SCAR=17.9
Pod
undocumented
Condition0%0/2
shift() || die('Usage: my $conf = $cgix_obj->conf_read($file)')
MC/DC0%0/1
shift() || die('Usage: my $conf = $cgix_obj->conf_read($file)')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | return $self->conf_obj->read(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | sub swap_template { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 2 | ▶ | my $self = shift || die 'Usage: my $out = $cgix_obj->swap_template($file, \%vars, $template_args)'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
swap_template: called CC=9 SCAR=22.7
Pod
documented
Condition50%1/2
shift() || die('Usage: my $out = $cgix_obj->swap_template($file, \\%vars, $template_args)')
MC/DC0%0/1
shift() || die('Usage: my $out = $cgix_obj->swap_template($file, \\%vars, $template_args)')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 2 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 2 | my $form = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 2 | ▶ | my $args = shift || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 2 | ▶ | $form = $self if ! $form && ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $form and ref $self
MC/DC0%0/2
not $form and ref $self
not $form
ref $self
Truth table33%1/3
not(A) and B
A= not $formB= ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 2 | ▶ | $form = $self->get_form if UNIVERSAL::isa($form, __PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 2 | ▶ | my ($ref, $return) = ref($str) ? ($str, 0) : (\$str, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | ### look up the module | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 2 | ▶ | my $module = $self->{'template_module'} || 'CGI::Ex::Template'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'template_module'} || 'CGI::Ex::Template'
MC/DC0%0/1
$self->{'template_module'} || 'CGI::Ex::Template'
$self->{'template_module'}
Truth table50%1/2
A
A= $self->{'template_module'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 2 | my $pkg = "$module.pm"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 2 | $pkg =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 2 | require $pkg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | ### swap it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 2 | my $out = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 2 | $module->new($args)->process($ref, $form, \$out); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 2 | ▶ | if (! $return) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 1 | $$ref = $out; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 1 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | ###----------------------------------------------------------------### | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||