| 1 | package CGI::WebToolkit; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use CGI qw(param header); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use CGI::Carp qw(fatalsToBrowser); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Data::Dump qw(dump); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use DBI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | our $WTK = undef; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | our @XHTML_TAGS | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | = qw(a abbr acronym address applet area b base bdo big blockquote | |||||||||||||||||||||||||||||||||||||||||
| 19 | body br button caption cite code col colgroup dd del dfn div | ||||||||||||||||||||||||||||||||||||||||||
| 20 | dl DOCTYPE dt em fieldset form frame frameset h1 h2 h3 h4 h5 | ||||||||||||||||||||||||||||||||||||||||||
| 21 | h6 head hr html i iframe img input ins kbd label legend li | ||||||||||||||||||||||||||||||||||||||||||
| 22 | link map meta noframes noscript object ol optgroup option p | ||||||||||||||||||||||||||||||||||||||||||
| 23 | param pre q samp script select small span strong style sub sup | ||||||||||||||||||||||||||||||||||||||||||
| 24 | table tbody td textarea tfoot th thead title tr tt ul var marquee | ||||||||||||||||||||||||||||||||||||||||||
| 25 | section header footer nav article | ||||||||||||||||||||||||||||||||||||||||||
| 26 | emph); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 29 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # constructor | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | return $self->__init( @args ); | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 40 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # methods | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | sub handle | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handle: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my ($self) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | # clear cache | ||||||||||||||||||||||||||||||||||||||||||
| 48 | $self->__clear_cache() | ||||||||||||||||||||||||||||||||||||||||||
| 49 | if $self->{'allowclearcache'} == 1 | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | && defined param($self->{'clearcacheparam'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"allowclearcache"} == 1 and defined param($self->{"clearcacheparam"})
MC/DC0%0/2
$self->{"allowclearcache"} == 1 and defined param($self->{"clearcacheparam"})
$self->{"allowclearcache"} == 1
defined param($self->{"clearcacheparam"})
Truth table0%0/3
A and B
A= $self->{"allowclearcache"} == 1B= defined param($self->{"clearcacheparam"})
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | # determine name of workflow function | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $workflow_function_name = param($self->{'workflowparam'}); | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $workflow_function_name = $self->{'entryaction'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | unless defined $workflow_function_name; | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $mimetype = ''; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $message = ''; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $function_name = $workflow_function_name; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $args = []; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $result = $self->call( $function_name, @{$args} ); | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | __die("function '$function_name' returned invalid result.". | ||||||||||||||||||||||||||||||||||||||||||
| 66 | " Use the methods output() or followup() to generate a valid result.") | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ref $result ne 'HASH' || !exists $result->{'type'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $result ne "HASH" or not exists $result->{"type"}
MC/DC0%0/2
ref $result ne "HASH" or not exists $result->{"type"}
ref $result ne "HASH"
not exists $result->{"type"}
Truth table0%0/3
A or not(B)
A= ref $result ne "HASH"B= not exists $result->{"type"}
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ($result->{'type'} eq 'output') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (exists $result->{'status'} && $result->{'status'} == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $result->{"status"} and $result->{"status"} == 1
MC/DC0%0/2
exists $result->{"status"} and $result->{"status"} == 1
exists $result->{"status"}
$result->{"status"} == 1
Truth table0%0/3
A and B
A= exists $result->{"status"}B= $result->{"status"} == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | __die("missing mimetype in result from function '$function_name'") | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | unless exists $result->{'mimetype'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | __die("missing content in result from function '$function_name'") | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | unless exists $result->{'content'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $mimetype = $result->{'mimetype'}; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $message = $result->{'content'}; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($mimetype eq 'text/html') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | # replace any {...:...} placeholders with their default values | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $message =~ s/\{[a-zA-Z0-9\.\_]+\:([^\}]*)\}/$1/mg; | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | # replace any {...} placeholders with empty string | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $message =~ s/\{[a-zA-Z0-9\.\_]+\}//mg; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $function_name = 'core.error'; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | elsif ($result->{'type'} eq 'followup') { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | __die("missing followup function name in result from function '$function_name'") | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | unless exists $result->{'function_name'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $function_name = $result->{'function_name'}; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $args = $result->{'arguments'} if exists $result->{'arguments'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | __die("function '$function_name' returned unknown type of result.". | |||||||||||||||||||||||||||||||||||||||||
| 104 | " Use the methods output() or followup() to generate a valid result."); | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $| = 1; | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | # add session to every link that points to the cgi script | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if (exists $ENV{'SCRIPT_NAME'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $script = quotemeta $ENV{'SCRIPT_NAME'}; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $url_addon = $self->{'idparam'}.'='.$self->{'session_id'}.'&'; | |||||||||||||||||||||||||||||||||||||||||
| 114 | my $form_addon = | ||||||||||||||||||||||||||||||||||||||||||
| 115 | '<input type="hidden" name="'.$self->{'idparam'} | ||||||||||||||||||||||||||||||||||||||||||
| 116 | .'" value="'.$self->{'session_id'}.'"/>'. | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | '<input type="hidden" name="'.$self->{'clearcacheparam'} | |||||||||||||||||||||||||||||||||||||||||
| 118 | .'" value="1"/>'; | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if ($mimetype eq 'text/html') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | # add session id to internal links | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $message =~ s/(href=[\"\']($script)?\?)/$1$url_addon/mig; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $message =~ s/(href=[\"\']$script)/$1?$url_addon/mig; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | # add session id as hidden field to internal forms | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $message =~ s/(<form[^\>]*action=[\"\']$script[^\>]*>)/$1$form_addon/mig; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $self->__cleanup(); | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return header( -type => $mimetype ).$message; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | sub call | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my ($self, $function_name, @args) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | # check if user is allowed to execute workflow function | ||||||||||||||||||||||||||||||||||||||||||
| 140 | $function_name = $self->{'entryaction'} | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if $self->{'checkrights'} == 1 && !$self->allowed($function_name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"checkrights"} == 1 and not $self->allowed($function_name)
MC/DC0%0/2
$self->{"checkrights"} == 1 and not $self->allowed($function_name)
$self->{"checkrights"} == 1
not $self->allowed($function_name)
Truth table0%0/3
A and not(B)
A= $self->{"checkrights"} == 1B= not $self->allowed($function_name)
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # check for cache entry | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $cachehash; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ($self->{'cachetable'} ne '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $cachehash = $self->__get_cache_hash($function_name, @args); | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $result = $self->__load_cache($cachehash); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | return $result if defined $result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | unless (exists $self->{"workflow_function_cache"}->{$function_name}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $function_filename | |||||||||||||||||||||||||||||||||||||||||
| 154 | = $self->__get_external_function_filename('workflows', $function_name); | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if (defined $function_filename) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | # load function ref. into cache | ||||||||||||||||||||||||||||||||||||||||||
| 158 | $self->{"workflow_function_cache"}->{$function_name} | ||||||||||||||||||||||||||||||||||||||||||
| 159 | = __load_file_as_subref($function_filename) | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | unless exists $self->{'workflow_function_cache'}->{$function_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 163 | # define error function | ||||||||||||||||||||||||||||||||||||||||||
| 164 | $self->{"workflow_function_cache"}->{$function_name} | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | = sub { __die("failed to load function '$function_name'") }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | # load library path for modules | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $libpath = $self->{'privatepath'}.'/modules'; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | eval('use lib "'.$libpath.'"'); | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | __die("loading of library path '$libpath' failed: $@") if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | # load all modules for workflow function | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | foreach my $module (@{$self->{'modules'}}) { | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | eval('use '.$module); | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | __die("loading of module '$module' failed: $@") if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | # call workflow function | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->{'current_workflow_function'} = $function_name; | |||||||||||||||||||||||||||||||||||||||||
| 182 | my $result = | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $self->{"workflow_function_cache"}->{$function_name}->( | |||||||||||||||||||||||||||||||||||||||||
| 184 | $self, @args ); | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $self->{'current_workflow_function'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | # save result to cache | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ($self->{'cachetable'} ne '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $self->__save_cache($cachehash, $result); | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | sub output | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my ($self, $status, $info, $content, $mimetype) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $status = 1 unless defined $status; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | $info = 'ok' unless defined $info; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | $content = '' unless defined $content; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | $mimetype = 'text/html' unless defined $mimetype; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | 'type' => 'output', | |||||||||||||||||||||||||||||||||||||||||
| 204 | 'status' => $status, | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 'info' => $info, | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 'content' => $content, | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 'mimetype' => $mimetype, | ||||||||||||||||||||||||||||||||||||||||||
| 208 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | sub followup | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
followup: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my ($self, $function_name, @args) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 214 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | 'type' => 'followup', | |||||||||||||||||||||||||||||||||||||||||
| 216 | 'function_name' => $function_name, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 'arguments' => [ @args ], | ||||||||||||||||||||||||||||||||||||||||||
| 218 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | sub get | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my ($self, $varname) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | return 1 if $self->{'sessiontable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if (exists $self->{'session'}->{$varname}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | return $self->{'session'}->{$varname}; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | sub set | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my ($self, $varname, $value) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | return 1 if $self->{'sessiontable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | $self->{'session'}->{$varname} = (defined $value ? $value : ''); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | sub unset | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unset: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my ($self, $name) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | return 1 if $self->{'sessiontable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | delete $self->{'session'}->{$name} | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if exists $self->{'session'}->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | sub fill | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fill: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my ($self, $template_name, $data) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | my @data = (ref($data) eq 'ARRAY' ? @{$data} : ($data)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my $filename1 = $self->__get_external_function_filename( 'generators', $template_name ); | |||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my $filename2 = $self->__get_external_function_filename( 'generators', 'core.'.$template_name ); | |||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if (defined $filename1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | # load function ref. into cache | ||||||||||||||||||||||||||||||||||||||||||
| 267 | $self->{"template_function_cache"}->{$template_name} | ||||||||||||||||||||||||||||||||||||||||||
| 268 | = __load_file_as_subref($filename1) | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | unless exists $self->{'template_function_cache'}->{$template_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | elsif (defined $filename2) { | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # load function ref. into cache | ||||||||||||||||||||||||||||||||||||||||||
| 273 | $self->{"template_function_cache"}->{$template_name} | ||||||||||||||||||||||||||||||||||||||||||
| 274 | = __load_file_as_subref($filename2) | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | unless exists $self->{'template_function_cache'}->{$template_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 278 | # load static template file from theme | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my @fallback_themes = @{$self->{'templatefallbacks'}}; | |||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | # check for specific theme | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if ($template_name =~ /^([^\:]+)\:(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my ($theme, $name) = $template_name =~ /^([^\:]+)\:(.*)$/; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | @fallback_themes = ($theme); | |||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $template_name = $name; | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | # look into themes for file | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $filename; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | foreach my $theme (@fallback_themes) { | |||||||||||||||||||||||||||||||||||||||||
| 292 | $filename = __identifier_to_filename( | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $self->{'privatepath'}.'/templates/'.$theme.'/', | |||||||||||||||||||||||||||||||||||||||||
| 294 | $template_name, '.html'); | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | last if -f $filename; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | # load file | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | open TMPLFILE, '<'.$filename or __die("failed to open file '$filename': $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $content = join '', <TMPLFILE>; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | close TMPLFILE; | |||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | # create generic function to parse the content | ||||||||||||||||||||||||||||||||||||||||||
| 304 | $self->{"template_function_cache"}->{$template_name} = | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my ($self, @data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my $result = ''; | |||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | foreach my $data (@data) { | |||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | my $tmpl = $content; | |||||||||||||||||||||||||||||||||||||||||
| 310 | # expand macros | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | $self->__expand_macros(\$tmpl) if $self->{'allowmacros'} == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | # replace variables | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | __replace_placeholders(\$tmpl, $data); | |||||||||||||||||||||||||||||||||||||||||
| 314 | # replace common variables | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | __replace_placeholders(\$tmpl, $self->{'common_placeholders'}); | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $result .= $tmpl; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | # call template function | ||||||||||||||||||||||||||||||||||||||||||
| 323 | return | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $self->{"template_function_cache"}->{$template_name}->( | |||||||||||||||||||||||||||||||||||||||||
| 325 | $self, @data ); | ||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | sub _ | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my ($self, $phrase, $language) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | return '' unless defined $phrase; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | return $phrase | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if $self->{'phrasetable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | $language = $self->get('language') unless defined $language; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | $language = $self->{'defaultlanguage'} unless defined $language; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | # query db for phrase | ||||||||||||||||||||||||||||||||||||||||||
| 342 | my $query | ||||||||||||||||||||||||||||||||||||||||||
| 343 | = $self->find( | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | -tables => [$self->{'phrasetable'}], | |||||||||||||||||||||||||||||||||||||||||
| 345 | -where => {'name' => $phrase}, | ||||||||||||||||||||||||||||||||||||||||||
| 346 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | if (my $row = $query->fetchrow_hashref()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | if ($row->{'language'} eq $language) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return $phrase; | |||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 353 | # look for translation | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $translation = __find_translation($row->{'translations'}, $language); | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | return (defined $translation ? $translation : $phrase); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | return $phrase; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | sub lang | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lang: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my ($self, $language) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if (defined $language) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | # set | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $self->set($language); | |||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | # get | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $lang = $self->get('language'); | |||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | return (defined $lang ? $lang : $self->{'defaultlanguage'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | sub translate | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
translate: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my ($self, @pairs) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 382 | return 0 | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if $self->{'phrasetable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | __die("translate() expects language/phrase pairs as parameters") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar(@pairs) % 2 == 1 or scalar @pairs < 4
MC/DC0%0/2
scalar(@pairs) % 2 == 1 or scalar @pairs < 4
scalar(@pairs) % 2 == 1
scalar @pairs < 4
Truth table0%0/3
A or B
A= scalar(@pairs) % 2 == 1B= scalar @pairs < 4
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | if scalar(@pairs) % 2 == 1 || scalar(@pairs) < 4; | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | # erease any bad characters | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | foreach my $p (0..$#pairs) { | |||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $pairs[$p] =~ s/[\n\r\:]//g; | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | # create real tuples | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my ($key_language, $key_phrase) = (shift(@pairs), shift(@pairs)); | |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my %phrases; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | for (my $i = 0; $i < scalar @pairs; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $phrases{$pairs[$i]} = $pairs[$i + 1]; | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | # query db for phrase entry | ||||||||||||||||||||||||||||||||||||||||||
| 401 | my $query | ||||||||||||||||||||||||||||||||||||||||||
| 402 | = $self->find( | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | -tables => [$self->{'phrasetable'}], | |||||||||||||||||||||||||||||||||||||||||
| 404 | -where => {'name' => $key_phrase, 'language' => $key_language}, | ||||||||||||||||||||||||||||||||||||||||||
| 405 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if (my $row = $query->fetchrow_hashref()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | # update | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my $translations = __find_translation($row->{'translations'}); | |||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | foreach my $lang (keys %phrases) { | |||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $translations->{$lang} = $phrases{$lang}; | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | $self->update( | ||||||||||||||||||||||||||||||||||||||||||
| 414 | -table => $self->{'phrasetable'}, | ||||||||||||||||||||||||||||||||||||||||||
| 415 | -set => { | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 'name' => $key_phrase, | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 'language' => $key_language, | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | 'translations' => join("\n", map { $_.':'.$translations->{$_} } keys %{$translations}), | |||||||||||||||||||||||||||||||||||||||||
| 419 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 420 | -where => {'name' => $key_phrase, 'language' => $key_language}, | ||||||||||||||||||||||||||||||||||||||||||
| 421 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | # insert | ||||||||||||||||||||||||||||||||||||||||||
| 425 | $self->create( | ||||||||||||||||||||||||||||||||||||||||||
| 426 | -table => $self->{'phrasetable'}, | ||||||||||||||||||||||||||||||||||||||||||
| 427 | -row => { | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 'name' => $key_phrase, | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 'language' => $key_language, | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | 'translations' => join("\n", map { $_.':'.$phrases{$_} } keys %phrases), | |||||||||||||||||||||||||||||||||||||||||
| 431 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 432 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | sub find | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my ($self, %options) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $opts = __parse_params( \%options, | |||||||||||||||||||||||||||||||||||||||||
| 442 | { | ||||||||||||||||||||||||||||||||||||||||||
| 443 | tables => [], | ||||||||||||||||||||||||||||||||||||||||||
| 444 | where => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 445 | wherelike => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 446 | group => [], | ||||||||||||||||||||||||||||||||||||||||||
| 447 | order => [], | ||||||||||||||||||||||||||||||||||||||||||
| 448 | limit => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 449 | distinct => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 450 | columns => [], | ||||||||||||||||||||||||||||||||||||||||||
| 451 | joins => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 452 | sortdir => 'asc', # 'asc' or 'desc' | ||||||||||||||||||||||||||||||||||||||||||
| 453 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my @tables = map { $self->__quotename($_) } @{$opts->{'tables'}}; | |||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my @columns = map { $self->__quotename($_) } @{$opts->{'columns'}}; | |||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | my @joins = | ||||||||||||||||||||||||||||||||||||||||||
| 460 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | $self->__quotename($_).' = '.$self->__quotename($opts->{'joins'}->{$_}); | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | keys %{$opts->{'joins'}}; | |||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | my @group = map { $self->__quotename($_) } @{$opts->{'group'}}; | |||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my @order = map { $self->__quotename($_) } @{$opts->{'order'}}; | |||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | my $sql | ||||||||||||||||||||||||||||||||||||||||||
| 470 | = 'SELECT' | ||||||||||||||||||||||||||||||||||||||||||
| 471 | .(defined $opts->{'distinct'} ? ' DISTINCT' : '') | ||||||||||||||||||||||||||||||||||||||||||
| 472 | .' '.(scalar @columns ? join(', ', @columns) : '*') | ||||||||||||||||||||||||||||||||||||||||||
| 473 | .' FROM '.join(', ', @tables) | ||||||||||||||||||||||||||||||||||||||||||
| 474 | .' WHERE ' | ||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | .(scalar keys %{$opts->{'where'}} ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | $self->__make_sql_where_clause($opts->{'where'}) | ||||||||||||||||||||||||||||||||||||||||||
| 477 | : '1') | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | .(scalar keys %{$opts->{'wherelike'}} ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | ' AND '.$self->__make_sql_where_clause($opts->{'wherelike'}, 1) | ||||||||||||||||||||||||||||||||||||||||||
| 480 | : '') | ||||||||||||||||||||||||||||||||||||||||||
| 481 | .(scalar @joins ? ' AND '.join(' AND ', @joins) : '') | ||||||||||||||||||||||||||||||||||||||||||
| 482 | .(scalar @group ? ' GROUP BY '.join(', ', @group) : '') | ||||||||||||||||||||||||||||||||||||||||||
| 483 | .(scalar @order ? ' ORDER BY '.join(', ', @order).' '.uc($opts->{'sortdir'}) : '') | ||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | .($opts->{'limit'} > 0 ? ' LIMIT '.$opts->{'limit'} : ''); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | return $self->query($sql); | |||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | sub create | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my ($self, %options) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my $opts = __parse_params( \%options, | |||||||||||||||||||||||||||||||||||||||||
| 493 | { | ||||||||||||||||||||||||||||||||||||||||||
| 494 | table => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 495 | row => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 496 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my @columns; | |||||||||||||||||||||||||||||||||||||||||
| 499 | my @values; | ||||||||||||||||||||||||||||||||||||||||||
| 500 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | push @columns, $self->__quotename($_); | |||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | push @values, $self->__quote($opts->{'row'}->{$_}); | |||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | keys %{$opts->{'row'}}; | |||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | my $sql | ||||||||||||||||||||||||||||||||||||||||||
| 507 | = 'INSERT' | ||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | .' INTO '.$self->__quotename($opts->{'table'}) | |||||||||||||||||||||||||||||||||||||||||
| 509 | .' ('.join(', ', @columns).')' | ||||||||||||||||||||||||||||||||||||||||||
| 510 | .' VALUES ('.join(', ', @values).')'; | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $self->query($sql); | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | return $self->{'dbh'}->last_insert_id(undef, undef, $opts->{'table'}, 'id'); | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | sub update | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | my ($self, %options) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | my $opts = __parse_params( \%options, | |||||||||||||||||||||||||||||||||||||||||
| 520 | { | ||||||||||||||||||||||||||||||||||||||||||
| 521 | table => '', | ||||||||||||||||||||||||||||||||||||||||||
| 522 | set => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 523 | where => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 524 | wherelike => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 525 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | my @sets = | ||||||||||||||||||||||||||||||||||||||||||
| 528 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | $self->__quotename($_).' = '.$self->__quote($opts->{'set'}->{$_}); | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | keys %{$opts->{'set'}}; | |||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | my $sql | ||||||||||||||||||||||||||||||||||||||||||
| 534 | = 'UPDATE' | ||||||||||||||||||||||||||||||||||||||||||
| 535 | .' '.$self->__quotename($opts->{'table'}) | ||||||||||||||||||||||||||||||||||||||||||
| 536 | .' SET '.join(', ', @sets) | ||||||||||||||||||||||||||||||||||||||||||
| 537 | .' WHERE ' | ||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | .(scalar keys %{$opts->{'where'}} ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | $self->__make_sql_where_clause($opts->{'where'}) | ||||||||||||||||||||||||||||||||||||||||||
| 540 | : '1') | ||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | .(scalar keys %{$opts->{'wherelike'}} ? | |||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | ' AND '.$self->__make_sql_where_clause($opts->{'wherelike'}, 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | : ''); | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | return $self->query($sql); | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | sub remove | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my ($self, %options) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $opts = __parse_params( \%options, | |||||||||||||||||||||||||||||||||||||||||
| 552 | { | ||||||||||||||||||||||||||||||||||||||||||
| 553 | table => '', | ||||||||||||||||||||||||||||||||||||||||||
| 554 | where => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 555 | wherelike => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 556 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | my $sql | ||||||||||||||||||||||||||||||||||||||||||
| 559 | = 'DELETE' | ||||||||||||||||||||||||||||||||||||||||||
| 560 | .' FROM '.$self->__quotename($opts->{'table'}) | ||||||||||||||||||||||||||||||||||||||||||
| 561 | .' WHERE ' | ||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | .(scalar keys %{$opts->{'where'}} ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | $self->__make_sql_where_clause($opts->{'where'}) | ||||||||||||||||||||||||||||||||||||||||||
| 564 | : '1') | ||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | .(scalar keys %{$opts->{'wherelike'}} ? | |||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | ' AND '.$self->__make_sql_where_clause($opts->{'wherelike'}, 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | : ''); | ||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | return $self->query($sql); | |||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | sub load | ||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my ($self, $group, $recordset, $tablename) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my $records = __load_data_file($self->{'privatepath'}.'/data/'.$group.'/'.$recordset.'.txt'); | |||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my $inserted = 0; | |||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | foreach my $record (@{$records}) { | |||||||||||||||||||||||||||||||||||||||||
| 580 | __die("record does not have an id field, in data file '$group/$recordset'") | ||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | unless exists $record->{'id'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | my $query | ||||||||||||||||||||||||||||||||||||||||||
| 584 | = $self->find( | ||||||||||||||||||||||||||||||||||||||||||
| 585 | -tables => [$tablename], | ||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | -where => {'id' => $record->{'id'}}, | |||||||||||||||||||||||||||||||||||||||||
| 587 | -limit => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 588 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | if (my $row = $query->fetchrow_hashref()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | # do nothing | ||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 594 | # insert | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $self->create( | |||||||||||||||||||||||||||||||||||||||||
| 596 | -table => $tablename, | ||||||||||||||||||||||||||||||||||||||||||
| 597 | -row => $record, | ||||||||||||||||||||||||||||||||||||||||||
| 598 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | $inserted ++; | |||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | return (scalar @{$records}, $inserted); | |||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | sub query | ||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | my ($self, $sql) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | $self->__connect_to_db(); | |||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | my $query = $self->{'dbh'}->prepare($sql); | |||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | $query->execute() | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | or __die('the query ['.$sql.'] failed: '.DBI->errstr()); | ||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | return $query; | |||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | sub getparam | ||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getparam: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my ($self, $name, $default, $regex) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | $regex = '.*' unless defined $regex; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | my $value = param($name); | |||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | return (defined $value && $value =~ /$regex/ ? $value : $default); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $value =~ /$regex/
MC/DC0%0/2
defined $value and $value =~ /$regex/
defined $value
$value =~ /$regex/
Truth table0%0/3
A and B
A= defined $valueB= $value =~ /$regex/
| |||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | sub login | ||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
login: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | my ($self, $loginname, $password) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | return 1 if $self->{'usertable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | return 0 unless defined $loginname; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | return 0 unless defined $password; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | return 0 if $self->{'usertable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | my $query | ||||||||||||||||||||||||||||||||||||||||||
| 638 | = find( | ||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | -tables => [$self->{'usertable'}], | |||||||||||||||||||||||||||||||||||||||||
| 640 | -where => { | ||||||||||||||||||||||||||||||||||||||||||
| 641 | 'loginname' => $loginname, | ||||||||||||||||||||||||||||||||||||||||||
| 642 | 'password' => md5_hex($password), | ||||||||||||||||||||||||||||||||||||||||||
| 643 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 644 | -limit => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 645 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | if (my $user = $query->fetchrow_hashref()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | return 0 if $user->{'active'} == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | # associate session with user id | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | set('user', $user); | |||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||
| 653 | # set language | ||||||||||||||||||||||||||||||||||||||||||
| 654 | $self->set('language', $user->{'ui_language'}) | ||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | if $user->{'ui_language'} ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||
| 657 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | sub logout | ||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logout: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | my ($self) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | return 1 if $self->{'usertable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | $self->unset('user'); | |||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||
| 675 | sub allowed | ||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
allowed: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my ($self, | |||||||||||||||||||||||||||||||||||||||||
| 678 | $function_name, # workflow function name | ||||||||||||||||||||||||||||||||||||||||||
| 679 | $loginname, # loginname of user | ||||||||||||||||||||||||||||||||||||||||||
| 680 | ) = __parse_args(@_); | ||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | return 1 if $self->{'accessconfig'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||
| 684 | # load access config from <privatepath>/accessconfigs/<name>.txt | ||||||||||||||||||||||||||||||||||||||||||
| 685 | # $mappings = { <regex> => <functionname>, ... } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | my $mappings | ||||||||||||||||||||||||||||||||||||||||||
| 687 | = __load_config_file( | ||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | $self->{'privatepath'}.'/accessconfigs/'.$self->{'accessconfig'}.'.txt'); | |||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | # determine and call appropriate access check function(s) | ||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my $has_access = 0; | |||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | foreach my $rgx (keys %{$mappings}) { | |||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if ($function_name =~ /$rgx/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | my $check_function_name = $mappings->{$rgx}; | |||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my $filename = | |||||||||||||||||||||||||||||||||||||||||
| 696 | $self->__get_external_function_filename( | ||||||||||||||||||||||||||||||||||||||||||
| 697 | 'accesschecks', $check_function_name); | ||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | # load function as subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 700 | $self->{"access_function_cache"}->{$check_function_name} | ||||||||||||||||||||||||||||||||||||||||||
| 701 | = __load_file_as_subref($filename) | ||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | unless exists $self->{"access_function_cache"}->{$check_function_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | my $check_function = $self->{"access_function_cache"}->{$check_function_name}; | |||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | $has_access = $has_access && $check_function->( $self, $function_name, $loginname ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$has_access && &$check_function($self, $function_name, $loginname)
MC/DC0%0/2
$has_access && &$check_function($self, $function_name, $loginname)
$has_access
&$check_function($self, $function_name, $loginname)
Truth table0%0/3
A && B
A= $has_accessB= &$check_function($self, $function_name, $loginname)
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | return $has_access; | |||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | sub logmsg | ||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logmsg: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my ($self, $msg, $priority) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | $msg .= "\r\n" if $msg !~ /\r?\n$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | $priority = 'DEBUG' | ||||||||||||||||||||||||||||||||||||||||||
| 722 | if !defined $priority | ||||||||||||||||||||||||||||||||||||||||||
| 723 | || !scalar | ||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | grep { $_ eq uc($priority) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $priority and scalar grep({$_ eq uc $priority;} "DEBUG", "INFO", "WARNING", "ERROR", "FATAL")
MC/DC0%0/2
defined $priority and scalar grep({$_ eq uc $priority;} "DEBUG", "INFO", "WARNING", "ERROR", "FATAL")
defined $priority
scalar grep({$_ eq uc $priority;} "DEBUG", "INFO", "WARNING", "ERROR", "FATAL")
Truth table0%0/3
A and B
A= defined $priorityB= scalar grep({$_ eq uc $priority;} "DEBUG", "INFO", "WARNING", "ERROR", "FATAL")
| |||||||||||||||||||||||||||||||||||||||||||
| 725 | qw(DEBUG INFO WARNING ERROR FATAL); | ||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | # log to priority-logfile | ||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | my $logfile = $self->{'privatepath'}.'/logs/'.uc($priority).'.txt'; | |||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | __file_append($logfile, $msg); | |||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | if (defined $self->{'current_workflow_function'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 732 | # log to workflow-function-specific logfile as well | ||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | my $logfile2 = $self->{'privatepath'}.'/logs/'.uc($self->{'current_workflow_function'}).'.txt'; | |||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | __file_append($logfile2, $msg); | |||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | sub fail | ||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fail: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | my ($self, $msg) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | __die($msg); | |||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | sub upload | ||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upload: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | my ($self, $paramname, $groupname) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | # retrieve file from parameters | ||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | my $file = $self->getparam($paramname, undef); | |||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | __die("cannot retrieve upload via unknown parameter '$paramname'") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 756 | unless defined $file; | ||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | my $upload_info = CGI::uploadInfo($file); | |||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | my $ending = $upload_info->{'Content-Disposition'}; | |||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | $ending =~ s/^.*\.//; | |||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | $ending =~ s/\"$//; | |||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | # generate filename | ||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | my $filepath = $self->{'publicpath'}.'/uploads/'.$groupname.'/'; | |||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | my $filename = $self->{'session_id'}.'_'.$now.'.'.$ending; | |||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | # write data to file | ||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | open UPLOAD, '>'.$filepath.$filename | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 771 | or __die("failed to write upload to file '$filepath$filename': $!"); | ||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | # Dateien in den Binaer-Modus schalten | ||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | binmode $file; | |||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | binmode UPLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | my $info = { | |||||||||||||||||||||||||||||||||||||||||
| 778 | 'status' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 779 | 'info' => 'The file has been successfully saved.', | ||||||||||||||||||||||||||||||||||||||||||
| 780 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | my $data; | |||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | my $bytes_written = 0; | |||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | ▶ | while (read $file, $data, 1024) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | print UPLOAD $data; | |||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | $bytes_written += 1024; | |||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | ▶ | if ($bytes_written > $self->{'uploadmaxsize'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | $info->{'status'} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | $info->{'info'} = | |||||||||||||||||||||||||||||||||||||||||
| 790 | 'The filesize exceeded the maximum upload size. '. | ||||||||||||||||||||||||||||||||||||||||||
| 791 | 'Aborted after '.$bytes_written.' Bytes.'; | ||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | close UPLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | my $mimetype = $upload_info->{'Content-Type'}; | |||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | my $original_filename = $upload_info->{'Content-Disposition'}; | |||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | $original_filename =~ s/^.*filename\=\"(.*)\"$/$1/; | |||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | # success | ||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | if ($info->{'status'} == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | $info->{'path'} = $filepath; | |||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | $info->{'filename'} = $filename; | |||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $info->{'created'} = $now; | |||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | $info->{'mimetype'} = $mimetype; | |||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | $info->{'original_filename'} = $original_filename; | |||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||
| 810 | # save info in session | ||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | push @{$self->{'session'}->{'uploads'}}, $info; | |||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | return $info->{'status'}; | |||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | sub AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | my ($self, @args) = __parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | my $function_name = $CGI::WebToolkit::AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | $function_name =~ s/.*\://g; | |||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | if ($function_name eq 'DESTROY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | return SUPER::DESTROY(@args); | |||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||
| 828 | elsif ($function_name =~ /^\_[^\_]/) { | ||||||||||||||||||||||||||||||||||||||||||
| 829 | # module function execution call | ||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | # try to find subroutine in | ||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | $function_name =~ s/^\_//; | |||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | foreach my $module (@{$self->{'modules'}}) { | |||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | my $is_sub = 0; | |||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | eval('$is_sub = (defined &CGI::WebToolkit::Modules::'.ucfirst($module).'::'.$function_name.')'); | |||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | __die("eval failed: $@") if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | if ($is_sub) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 838 | # call subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | eval('@result = CGI::WebToolkit::Modules::'.ucfirst($module).'::'.$function_name.'($self, @args)'); | |||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | __die("eval for subroutine call failed: $@") if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | return (wantarray ? @result : (scalar @result ? $result[0] : undef)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | __die("could not find subroutine named 'CGI::WebToolkit::Modules::*::".$function_name."'"); | |||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||
| 847 | elsif ($function_name =~ /^[A-Z]/) { | ||||||||||||||||||||||||||||||||||||||||||
| 848 | # template loading call | ||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my ($theme, $template_name) = split /\_/, $function_name; | |||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | unless (defined $template_name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | $template_name = $theme; | |||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | $theme = ''; | |||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | $theme = lc $theme; | |||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||
| 857 | # create template name | ||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | $template_name =~ s/([A-Z])/_$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | $template_name =~ s/^\_//g; | |||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | $template_name =~ s/\_/./g; | |||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | $template_name = lc $template_name; | |||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | return | ||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | ▶ | $self->fill( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 865 | (length $theme ? $theme.':' : '').$template_name, | ||||||||||||||||||||||||||||||||||||||||||
| 866 | { @args }, | ||||||||||||||||||||||||||||||||||||||||||
| 867 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||
| 869 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | __die("Unknown function/method called '$function_name'."); | |||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||
| 874 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 875 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 876 | # cleanup | ||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||
| 878 | sub __cleanup | ||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__cleanup: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | $self->__save_session(); | |||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | $self->__disconnect_from_db(); | |||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 887 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 888 | # internal helper functions/methods | ||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | sub __expand_macros | ||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__expand_macros: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | my ($self, $stringref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | my $string = ${$stringref}; | |||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | my $tokens = __tokenize_xml($string); | |||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||
| 897 | # the generated tokens are now beeing expanded | ||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my $parsed = ''; | |||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | my $t = 0; # offset of current token | |||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | my $abort = 0; | |||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | ▶ | last if $t >= scalar @{$tokens}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | my $token = $tokens->[$t]; | |||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | if (!ref $token) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | $parsed .= $token; | |||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | $t ++; | |||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||
| 911 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | my ($type, $name, $attribs) = @{$token}; | |||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | ▶ | if ($type eq 'start' || $type eq 'single') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$type eq "start" or $type eq "single"
MC/DC0%0/2
$type eq "start" or $type eq "single"
$type eq "start"
$type eq "single"
Truth table0%0/3
A or B
A= $type eq "start"B= $type eq "single"
| |||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | my $data = __attribs_to_hash($attribs); | |||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | $data->{'content'} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | my $t_span = 1; # assume a "single" tag | |||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | ▶ | if ($type eq 'start') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 920 | # find end tag | ||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | $t_span = __get_token_span($tokens, $t); | |||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | unless (defined $t_span) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 923 | # if no end tag: tag end is end of tokens | ||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | $t_span = scalar(@{$tokens}) - $t; | |||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||
| 927 | # get tokens from start tag till end tag | ||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | my @subtokens = splice @{$tokens}, $t, $t_span; | |||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | shift @subtokens; | |||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | pop @subtokens; | |||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | # convert sub-tokenlist back to xml | ||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | $data->{'content'} = __render_tokens(\@subtokens); | |||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||
| 935 | elsif ($type eq 'single') { | ||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | splice @{$tokens}, $t, 1; | |||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||
| 939 | # fill template | ||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | my $filled = $self->fill($name, $data); | |||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||
| 942 | # tokenize template | ||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | my $sub_tokens = __tokenize_xml($filled); | |||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | # replace tag with sub-tokenlist | ||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | splice @{$tokens}, $t, 0, @{$sub_tokens}; | |||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||
| 948 | # restart expanding at previous token | ||||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||
| 950 | elsif ($type eq 'end') { | ||||||||||||||||||||||||||||||||||||||||||
| 951 | # this end tag actually belongs to a start tag | ||||||||||||||||||||||||||||||||||||||||||
| 952 | # which is out of the scope of this token list | ||||||||||||||||||||||||||||||||||||||||||
| 953 | # -> ignore this end tag | ||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | $t ++; | |||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | $abort ++; | |||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | __die("macro expansion ran into endless loop.") if $abort == 100; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | ${$stringref} = $parsed; | |||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||
| 965 | sub __render_tokens | ||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__render_tokens: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | my ($tokens) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | my $string = ''; | |||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | foreach my $token (@{$tokens}) { | |||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | ▶ | if (ref $token) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | ▶ | $string .= | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 972 | '<'.($token->[0] eq 'end' ? '/' : ''). | ||||||||||||||||||||||||||||||||||||||||||
| 973 | $token->[1].($token->[0] eq 'end' ? '' : ' '.$token->[2]). | ||||||||||||||||||||||||||||||||||||||||||
| 974 | ($token->[0] eq 'single' ? '/' : '').'>'; | ||||||||||||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||||||||||||
| 976 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | $string .= $token; | |||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||
| 983 | sub __attribs_to_hash | ||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__attribs_to_hash: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | my ($attribs) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | my %hash; | |||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | my @pairs = split /[\s\t]+/, $attribs; | |||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | foreach my $pair (@pairs) { | |||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | my ($key, $value) = split /\=/, $pair; | |||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | $value =~ s/^[\"\']?//; | |||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | $value =~ s/[\"\']?$//; | |||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | $hash{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | return \%hash; | |||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||
| 997 | sub __get_token_span | ||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__get_token_span: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | my ($tokens, $t) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | my $open = 0; # open tags with same name as token at position $t | |||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | my $s; | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | foreach my $i ($t+1..scalar(@{$tokens})-1) { | |||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | $s = $i; | |||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | ▶ | next unless ref $tokens->[$s]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | ▶ | if ($tokens->[$s]->[1] eq $tokens->[$t]->[1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | ▶ | if ($tokens->[$s]->[0] eq 'start') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | $open ++; | |||||||||||||||||||||||||||||||||||||||||
| 1009 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | elsif ($tokens->[$s]->[0] eq 'end') { | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | ▶ | if ($open <= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | $found = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | $open --; | |||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | ▶ | my $span = ($found ? ($s - $t + 1) : undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | return $span; | |||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | sub __dump_tokens | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__dump_tokens: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | my ($tokens) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | my $s = "[\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1030 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | if (!ref $_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | $s .= " [".sprintf('%0d',$i)."] ...\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | elsif ($_->[0] eq 'start') { | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | $s .= " [".sprintf('%0d',$i)."] <".$_->[1].">\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1036 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | elsif ($_->[0] eq 'end') { | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | $s .= " [".sprintf('%0d',$i)."] </".$_->[1].">\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1039 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | elsif ($_->[0] eq 'single') { | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | $s .= " [".sprintf('%0d',$i)."] <".$_->[1]."/>\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | $i ++; | |||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | } @{$tokens}; | |||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | return $s."]\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | sub __tokenize_xml | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__tokenize_xml: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | my ($string) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||
| 1052 | # remove comments | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | $string =~ s/<!(?:--(?:[^-]*|-[^-]+)*--\s*)>//sg; | |||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||
| 1055 | # this regex parses an xml tag (sloppy...) | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | my $tagregex = '^(\/?)([a-zA-Z0-9\:\_\.]+)([\s\t\n\r]*)([^\>]*[^\/])?(\/?)>(.*)$'; | |||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||
| 1058 | # what follows is actually a very rudimentary tokenizer | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | # that splits the source into an array of tokens, either | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | # tag (start-tag, end-tag or single-tag) and strings | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | my @tokens = (''); | |||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | foreach my $tag (split /</s, $string) { | |||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | if ($tag =~ /$tagregex/s) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | my ($is_end, $tagname, $space, $attribs, $is_single, $rest) | |||||||||||||||||||||||||||||||||||||||||
| 1067 | = $tag =~ /$tagregex/s; | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | ▶ | $space = '' unless defined $space; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | ▶ | $attribs = '' unless defined $attribs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | ▶ | $is_single = '' unless defined $is_single; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | ▶ | $rest = '' unless defined $rest; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | ▶ | if (scalar grep { $tagname eq $_ } @XHTML_TAGS) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1075 | # normal html tag | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | ▶ | ref $tokens[-1] ? push(@tokens,'<'.$tag) : ($tokens[-1] .= '<'.$tag); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1077 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | # macro | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | 0 | ▶ | if (length $is_end) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1081 | # end tag | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | push @tokens, ['end', $tagname]; | |||||||||||||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | elsif (length $is_single) { | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | # single tag | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | push @tokens, ['single', $tagname, $attribs]; | |||||||||||||||||||||||||||||||||||||||||
| 1087 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | # start tag | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | push @tokens, ['start', $tagname, $attribs]; | |||||||||||||||||||||||||||||||||||||||||
| 1091 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | ▶ | ref $tokens[-1] ? push(@tokens,$rest) : ($tokens[-1] .= $rest); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | ▶ | ref $tokens[-1] ? push(@tokens,$tag) : ($tokens[-1] .= $tag); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1097 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | return \@tokens; | |||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||
| 1103 | sub __load_data_file | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__load_data_file: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | my ($datafilename) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | if (-f $datafilename && -r $datafilename) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $datafilename and -r $datafilename
MC/DC0%0/2
-f $datafilename and -r $datafilename
-f $datafilename
-r $datafilename
Truth table0%0/3
A and B
A= -f $datafilenameB= -r $datafilename
| |||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | open DATAFILE, '<'.$datafilename | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1109 | or _die("failed to open file '$datafilename': $!"); | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | my @records; | |||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | my $current_id = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | my $current_field = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | my $current_record = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | foreach my $line (<DATAFILE>) { | |||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | ▶ | if (defined $current_id && defined $current_field && $line =~ /^[\s\t]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $current_id and defined $current_field and $line =~ /^[\s\t]/
defined $current_id and defined $current_field
MC/DC0%0/3
defined $current_id and defined $current_field and $line =~ /^[\s\t]/
defined $current_id
defined $current_field
$line =~ /^[\s\t]/
Truth table0%0/4
A and B and C
A= defined $current_idB= defined $current_fieldC= $line =~ /^[\s\t]/
| |||||||||||||||||||||||||||||||||||||||||||
| 1118 | # possibly field value line | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | $line =~ s/^[\s\t]//; | |||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | $current_record->{$current_field} .= $line; | |||||||||||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | ▶ | if ($line =~ /^\[(\d+)\][\s\t\n\r]*$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1124 | # id line | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | ▶ | if (defined $current_id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1126 | # save previous record | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | push @records, $current_record; | |||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | # reset | ||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | $current_id = $line; | |||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | $current_id =~ s/^\[(\d+)\][\s\t\n\r]*$/$1/; | |||||||||||||||||||||||||||||||||||||||||
| 1132 | 0 | $current_record = { 'id' => $current_id }; | |||||||||||||||||||||||||||||||||||||||||
| 1133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | elsif ($line =~ /^(\w+)[\s\t]*([\:\.])(.*)\n\r?$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | # field line | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | my ($fieldname, $type, $value) | |||||||||||||||||||||||||||||||||||||||||
| 1137 | = $line =~ /^(\w+)[\s\t]*([\:\.])(.*)\n\r?$/; | ||||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | ▶ | if ($type eq ':') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | $current_record->{$fieldname} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | $current_field = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | $current_record->{$fieldname} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | $current_field = $fieldname; | |||||||||||||||||||||||||||||||||||||||||
| 1145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | ▶ | if (defined $current_id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1150 | # save last record | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | push @records, $current_record; | |||||||||||||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | return \@records; | |||||||||||||||||||||||||||||||||||||||||
| 1154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | __die("failed to open file '$datafilename': no file or not readable"); | |||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||
| 1160 | sub __parse_translations | ||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__parse_translations: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | my ($translations) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | my %phrases; | |||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | foreach my $translation (split /\n/, @{$translations}) { | |||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | my ($language, $phrase) =~ /^([^\:]+)\:(.*)$/; | |||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | $phrases{$language} = $phrase; | |||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | return \%phrases; | |||||||||||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||
| 1171 | sub __find_translation | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__find_translation: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | my ($translations, $find_language) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | foreach my $translation (split /\n\r?/, $translations) { | |||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | my ($language, $phrase) = $translation =~ /^([^\:]+)\:(.*)$/; | |||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | ▶ | return $phrase | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1177 | if $language eq $find_language; | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||
| 1182 | sub __get_cache_hash | ||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__get_cache_hash: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | my ($self, $function_name, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||
| 1186 | # string of which hash is computed | ||||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | my $string = ''; | |||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | my $cfgfile = $self->{'privatepath'}.'/cacheconfigs/'.$function_name.'.txt'; | |||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | ▶ | if (-f $cfgfile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1191 | # open cache config | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | my $cfg | |||||||||||||||||||||||||||||||||||||||||
| 1193 | = __read_config_file($cfgfile, { | ||||||||||||||||||||||||||||||||||||||||||
| 1194 | 'session' => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | 'params' => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1196 | 'lifetime' => 3600, | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | map { $string .= __serialize($self->get($_)) } @{$cfg->{'session'}}; | |||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | map { $string .= __serialize(param($_)) } @{$cfg->{'params'}}; | |||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | $string .= __serialize(\@args); | |||||||||||||||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1203 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1204 | # hash is created out of complete session, post/get and arguments | ||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||
| 1206 | # commented, because makes cache renew too often... | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | #map { $string .= __serialize($self->get($_)) } keys %{$self->{'session'}}; | ||||||||||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||||||||||
| 1209 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | $string .= | |||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | ▶ | ($_ eq $self->{'idparam'} || $_ eq $self->{'clearcacheparam'} ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ eq $self->{"idparam"} or $_ eq $self->{"clearcacheparam"}
MC/DC0%0/2
$_ eq $self->{"idparam"} or $_ eq $self->{"clearcacheparam"}
$_ eq $self->{"idparam"}
$_ eq $self->{"clearcacheparam"}
Truth table0%0/3
A or B
A= $_ eq $self->{"idparam"}B= $_ eq $self->{"clearcacheparam"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1212 | '' : __serialize(param($_))); | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | } param(); | ||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | $string .= __serialize(\@args); | |||||||||||||||||||||||||||||||||||||||||
| 1215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | return md5_hex($string); | |||||||||||||||||||||||||||||||||||||||||
| 1218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||
| 1220 | sub __load_cache | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__load_cache: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | my ($self, $cachehash) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1223 | my $query | ||||||||||||||||||||||||||||||||||||||||||
| 1224 | = $self->find( | ||||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | -tables => [$self->{'cachetable'}], | |||||||||||||||||||||||||||||||||||||||||
| 1226 | -where => {'hash' => $cachehash}, | ||||||||||||||||||||||||||||||||||||||||||
| 1227 | -limit => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1228 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | ▶ | if (my $entry = $query->fetchrow_hashref()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | return __deserialize($entry->{'content'}); | |||||||||||||||||||||||||||||||||||||||||
| 1232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1233 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||
| 1238 | sub __save_cache | ||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__save_cache: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | my ($self, $cachehash, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||
| 1242 | $self->create( | ||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | -table => $self->{'cachetable'}, | |||||||||||||||||||||||||||||||||||||||||
| 1244 | -row => { | ||||||||||||||||||||||||||||||||||||||||||
| 1245 | 'content' => __serialize($data), | ||||||||||||||||||||||||||||||||||||||||||
| 1246 | 'hash' => $cachehash, | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | 'last_update' => time(), | ||||||||||||||||||||||||||||||||||||||||||
| 1248 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1249 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||
| 1254 | sub __clear_cache | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__clear_cache: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | ▶ | return 1 if $self->{'cachetable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | $self->remove( -table => $self->{'cachetable'} ); | |||||||||||||||||||||||||||||||||||||||||
| 1259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||
| 1261 | sub __file_append | ||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__file_append: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1263 | 0 | my ($filename, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1264 | 0 | ▶ | open OUTFILE, '>>'.$filename or __die("failed to open file '$filename': $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | print OUTFILE $text; | |||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | close OUTFILE; | |||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||
| 1270 | # returns the args array with the | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | # current CGI::WebToolkit instance as first argument | ||||||||||||||||||||||||||||||||||||||||||
| 1272 | sub __parse_args | ||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__parse_args: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | ▶ | if (scalar @_ && ref($_[0]) eq 'CGI::WebToolkit') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @_ and ref $_[0] eq "CGI::WebToolkit"
MC/DC0%0/2
scalar @_ and ref $_[0] eq "CGI::WebToolkit"
scalar @_
ref $_[0] eq "CGI::WebToolkit"
Truth table0%0/3
A and B
A= scalar @_B= ref $_[0] eq "CGI::WebToolkit"
| |||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | return @_; | |||||||||||||||||||||||||||||||||||||||||
| 1276 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | return ($WTK, @_); | |||||||||||||||||||||||||||||||||||||||||
| 1278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||
| 1281 | sub __replace_placeholders | ||||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__replace_placeholders: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | my ($stringref, $hash) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | foreach my $key (keys %{$hash}) { | |||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | my $cleankey = $key; | |||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | $cleankey =~ s/[^a-zA-Z0-9\_]//g; | |||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | ${$stringref} =~ s/\{$cleankey[^\}]*\}/$hash->{$key}/mig; | |||||||||||||||||||||||||||||||||||||||||
| 1288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||
| 1292 | sub __make_sql_where_clause | ||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__make_sql_where_clause: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | my ($self, $where, $use_like) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1295 | 0 | ▶ | $use_like = 0 unless defined $use_like; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||
| 1297 | my @parts = | ||||||||||||||||||||||||||||||||||||||||||
| 1298 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | my $fieldname = $self->__quotename($_); | |||||||||||||||||||||||||||||||||||||||||
| 1300 | 0 | my $fieldvalue = $self->__quote($where->{$_}); | |||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||
| 1302 | 0 | my $s = $fieldname; | |||||||||||||||||||||||||||||||||||||||||
| 1303 | 0 | ▶ | $s .= ($use_like == 1 ? ' LIKE ' : ' = '); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | $s .= ''.$fieldvalue; | |||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | $s; | |||||||||||||||||||||||||||||||||||||||||
| 1306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1307 | 0 | keys %{$where}; | |||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||
| 1309 | 0 | return join(' AND ', @parts); | |||||||||||||||||||||||||||||||||||||||||
| 1310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||
| 1312 | sub __quote | ||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__quote: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1314 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | $self->__connect_to_db(); | |||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||
| 1317 | 0 | return $self->{'dbh'}->quote(@args) | |||||||||||||||||||||||||||||||||||||||||
| 1318 | or __die('quote failed: '.DBI->errstr()); | ||||||||||||||||||||||||||||||||||||||||||
| 1319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||
| 1321 | # escapes a CGI::WebToolkit field identifier, e.g. "mytable.myfield" or "myfield" etc. | ||||||||||||||||||||||||||||||||||||||||||
| 1322 | sub __quotename | ||||||||||||||||||||||||||||||||||||||||||
| 1323 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__quotename: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | my ($self, $fieldname) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1325 | 0 | $self->__connect_to_db(); | |||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | my @parts = split /\./, $fieldname; | |||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||
| 1329 | 0 | my $quoted; | |||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | ▶ | if (scalar @parts == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1331 | #$quoted = $self->{'dbh'}->quote_identifier(undef, undef, $parts[0]) | ||||||||||||||||||||||||||||||||||||||||||
| 1332 | # or _die("quote_identifier() failed: ".DBI->errstr()); | ||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | $quoted = '`'.$parts[0].'`'; | |||||||||||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1335 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1336 | #$quoted = $self->{'dbh'}->quote_identifier(undef, $parts[0], $parts[1]) | ||||||||||||||||||||||||||||||||||||||||||
| 1337 | # or _die("quote_identifier() failed: ".DBI->errstr()); | ||||||||||||||||||||||||||||||||||||||||||
| 1338 | 0 | $quoted = '`'.$parts[0].'`'.'.'.'`'.$parts[1].'`'; | |||||||||||||||||||||||||||||||||||||||||
| 1339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | return $quoted; | |||||||||||||||||||||||||||||||||||||||||
| 1341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||
| 1343 | sub __get_external_function_filename | ||||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__get_external_function_filename: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | my ($self, | |||||||||||||||||||||||||||||||||||||||||
| 1346 | $type, # "functions" or "templates" or other subdirectory in <privatepath> | ||||||||||||||||||||||||||||||||||||||||||
| 1347 | $name, # name of function in dot-syntax, e.g. "page.home.default" | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1349 | = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||||||||||||||||
| 1351 | # untaint name | ||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | $name =~ s/^(([a-z\_]+)(\.([a-z\_]+))*).*$/$1/; | |||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||
| 1354 | my $filename = __identifier_to_filename( | ||||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | $self->{'privatepath'}.'/'.$type.'/', $name, '.pl'); | |||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | ▶ | if (-f $filename) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | return $filename; | |||||||||||||||||||||||||||||||||||||||||
| 1359 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1360 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||
| 1364 | # bla.bla.bla -> bla/bla/bla | ||||||||||||||||||||||||||||||||||||||||||
| 1365 | sub __identifier_to_filename | ||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__identifier_to_filename: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1367 | 0 | my ($prefix, $identifier, $suffix) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1368 | 0 | ▶ | $suffix = '' unless defined $suffix; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | my $filename = $identifier; | |||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | $filename =~ s#\.#/#g; | |||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | return $prefix.$filename.$suffix; | |||||||||||||||||||||||||||||||||||||||||
| 1374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||||||||||||||||
| 1376 | # loads an external file into an anonymous perl function ref. | ||||||||||||||||||||||||||||||||||||||||||
| 1377 | # and returns this ref. | ||||||||||||||||||||||||||||||||||||||||||
| 1378 | sub __load_file_as_subref | ||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__load_file_as_subref: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | my ($filename) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1381 | |||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | ▶ | __die("cannot load file '$filename': does not exist.") unless -f $filename; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1383 | 0 | ▶ | __die("cannot load file '$filename': is not readable.") unless -r $filename; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||
| 1385 | 0 | my $subref = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | ▶ | open PERLFILE, '<'.$filename or __die("failed to open file '$filename': $!"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | my $code = join '', <PERLFILE>; | |||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | $code =~ /^(.*).*$/sm; # untaint | |||||||||||||||||||||||||||||||||||||||||
| 1389 | 0 | $code = "$1"; | |||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | $code = '$subref = sub { my ($wtk, @args) = @_;'."\n".$code."\n".'}'; | |||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | close PERLFILE; | |||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | eval($code); | |||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | ▶ | __die("function (file '$filename') failed to load with error: $@") if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | return $subref; | |||||||||||||||||||||||||||||||||||||||||
| 1396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||
| 1398 | sub __load_session | ||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__load_session: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1401 | 0 | ▶ | return 1 if $self->{'sessiontable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||
| 1403 | # determine session id | ||||||||||||||||||||||||||||||||||||||||||
| 1404 | $self->{'session_id'} = | ||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | $self->getparam( $self->{'idparam'}, undef, '^[a-zA-Z0-9]{32}$' ); | |||||||||||||||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||||||||||||||||
| 1407 | $self->{'session_id'} = md5_hex( time() ) | ||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | ▶ | unless defined $self->{'session_id'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||
| 1410 | # try to find it in db | ||||||||||||||||||||||||||||||||||||||||||
| 1411 | my $query = | ||||||||||||||||||||||||||||||||||||||||||
| 1412 | $self->find( | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | -tables => [ $self->{'sessiontable'} ], | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | 0 | -where => { 'session_id' => $self->{'session_id'} }, | |||||||||||||||||||||||||||||||||||||||||
| 1415 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||
| 1417 | 0 | my $sessionstart = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1418 | 0 | ▶ | if (my $session = $query->fetchrow_hashref()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1419 | 0 | ▶ | if (time() - $session->{'last_update'} < $self->{'sessiontimeout'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | $self->{'session'} = __deserialize($session->{'content'}); | |||||||||||||||||||||||||||||||||||||||||
| 1421 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1422 | # session timed out | ||||||||||||||||||||||||||||||||||||||||||
| 1423 | 0 | $self->{'session_id'} = md5_hex( time() ); # gets new session id! | |||||||||||||||||||||||||||||||||||||||||
| 1424 | 0 | $self->{'session'} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||
| 1426 | 0 | $self->set('session_timed_out', 1); | |||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | $sessionstart = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1431 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1432 | # create empty session | ||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | $self->{'session'} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1434 | |||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | $sessionstart = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1437 | |||||||||||||||||||||||||||||||||||||||||||
| 1438 | # trigger callback | ||||||||||||||||||||||||||||||||||||||||||
| 1439 | $self->call($self->{'onsessionstart'}) | ||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | ▶ | if $sessionstart && $self->{'onsessionstart'} ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sessionstart and $self->{"onsessionstart"} ne ""
MC/DC0%0/2
$sessionstart and $self->{"onsessionstart"} ne ""
$sessionstart
$self->{"onsessionstart"} ne ""
Truth table0%0/3
A and B
A= $sessionstartB= $self->{"onsessionstart"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 1441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||
| 1443 | sub __save_session | ||||||||||||||||||||||||||||||||||||||||||
| 1444 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__save_session: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | ▶ | return 1 if $self->{'sessiontable'} eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||
| 1448 | # check if session row exists in database | ||||||||||||||||||||||||||||||||||||||||||
| 1449 | my $query = | ||||||||||||||||||||||||||||||||||||||||||
| 1450 | $self->find( | ||||||||||||||||||||||||||||||||||||||||||
| 1451 | -tables => [ $self->{'sessiontable'} ], | ||||||||||||||||||||||||||||||||||||||||||
| 1452 | 0 | -where => { 'session_id' => $self->{'session_id'} }, | |||||||||||||||||||||||||||||||||||||||||
| 1453 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | ▶ | if (my $session = $query->fetchrow_hashref()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1456 | # update | ||||||||||||||||||||||||||||||||||||||||||
| 1457 | $self->update( | ||||||||||||||||||||||||||||||||||||||||||
| 1458 | -table => $self->{'sessiontable'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1459 | -set => { | ||||||||||||||||||||||||||||||||||||||||||
| 1460 | 'content' => __serialize($self->{'session'}), | ||||||||||||||||||||||||||||||||||||||||||
| 1461 | 'last_update' => time(), | ||||||||||||||||||||||||||||||||||||||||||
| 1462 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1463 | 0 | -where => { 'session_id' => $self->{'session_id'} }, | |||||||||||||||||||||||||||||||||||||||||
| 1464 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1466 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1467 | # insert | ||||||||||||||||||||||||||||||||||||||||||
| 1468 | $self->create( | ||||||||||||||||||||||||||||||||||||||||||
| 1469 | -table => $self->{'sessiontable'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1470 | -row => { | ||||||||||||||||||||||||||||||||||||||||||
| 1471 | 'session_id' => $self->{'session_id'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1472 | 0 | 'content' => __serialize($self->{'session'}), | |||||||||||||||||||||||||||||||||||||||||
| 1473 | 'last_update' => time(), | ||||||||||||||||||||||||||||||||||||||||||
| 1474 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1475 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1478 | |||||||||||||||||||||||||||||||||||||||||||
| 1479 | sub __serialize | ||||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__serialize: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1481 | 0 | my ($structure) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1482 | 0 | return dump($structure); | |||||||||||||||||||||||||||||||||||||||||
| 1483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||
| 1485 | sub __deserialize | ||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__deserialize: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | my ($string) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1488 | 0 | ▶ | return {} unless length $string; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1489 | 0 | my $structure = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1490 | 0 | eval('$structure = '.$string); | |||||||||||||||||||||||||||||||||||||||||
| 1491 | 0 | ▶ | __die("deserialization of string failed: $@") if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | return $structure; | |||||||||||||||||||||||||||||||||||||||||
| 1493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||||||||||||||||
| 1495 | sub __connect_to_db | ||||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__connect_to_db: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1497 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | ▶ | return 1 if defined $self->{'dbh'}; # && ref($self->{'dbh'}) eq 'DBI'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||
| 1500 | $self->{'dbh'} | ||||||||||||||||||||||||||||||||||||||||||
| 1501 | = DBI->connect( | ||||||||||||||||||||||||||||||||||||||||||
| 1502 | "DBI:".$self->{'engine'}.":".$self->{'name'}.":".$self->{'host'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1503 | 0 | ▶ | $self->{'user'}, $self->{'password'}, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1504 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1505 | #PrintError => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1506 | #RaiseError => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1507 | #AutoCommit => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1508 | #PrintWarn => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1509 | }) | ||||||||||||||||||||||||||||||||||||||||||
| 1510 | or __die("Could not connect to database"); | ||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||
| 1512 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||
| 1515 | sub __disconnect_from_db | ||||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__disconnect_from_db: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | return $self->{'dbh'}->disconnect(); | |||||||||||||||||||||||||||||||||||||||||
| 1520 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||||||||||||
| 1522 | sub __init | ||||||||||||||||||||||||||||||||||||||||||
| 1523 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__init: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1524 | 0 | my ($self, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1525 | |||||||||||||||||||||||||||||||||||||||||||
| 1526 | 0 | my $optdefaults = | |||||||||||||||||||||||||||||||||||||||||
| 1527 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1528 | # path parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1529 | publicpath => '', | ||||||||||||||||||||||||||||||||||||||||||
| 1530 | publicurl => '', | ||||||||||||||||||||||||||||||||||||||||||
| 1531 | privatepath => '', | ||||||||||||||||||||||||||||||||||||||||||
| 1532 | cgipath => '', | ||||||||||||||||||||||||||||||||||||||||||
| 1533 | cgiurl => '', | ||||||||||||||||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||||||||||||||||
| 1535 | # configuration parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1536 | config => "", | ||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||
| 1538 | # database parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1539 | engine => "mysql", | ||||||||||||||||||||||||||||||||||||||||||
| 1540 | user => "guest", | ||||||||||||||||||||||||||||||||||||||||||
| 1541 | name => "", | ||||||||||||||||||||||||||||||||||||||||||
| 1542 | password => "", | ||||||||||||||||||||||||||||||||||||||||||
| 1543 | host => "localhost", | ||||||||||||||||||||||||||||||||||||||||||
| 1544 | port => "", | ||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||
| 1546 | # template parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1547 | templatefallbacks => ['core'], | ||||||||||||||||||||||||||||||||||||||||||
| 1548 | allowmacros => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||||||||||||||||
| 1550 | # form creation parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1551 | # ... | ||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||
| 1553 | # session parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1554 | idparam => 'sid', | ||||||||||||||||||||||||||||||||||||||||||
| 1555 | sessiontable => '', | ||||||||||||||||||||||||||||||||||||||||||
| 1556 | sessiontimeout => 1800, | ||||||||||||||||||||||||||||||||||||||||||
| 1557 | |||||||||||||||||||||||||||||||||||||||||||
| 1558 | # user/rights management | ||||||||||||||||||||||||||||||||||||||||||
| 1559 | usertable => '', | ||||||||||||||||||||||||||||||||||||||||||
| 1560 | checkrights => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||
| 1562 | # caching | ||||||||||||||||||||||||||||||||||||||||||
| 1563 | cachetable => '', | ||||||||||||||||||||||||||||||||||||||||||
| 1564 | allowclearcache => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1565 | clearcacheparam => 'clearcache', | ||||||||||||||||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||||||||||||||||
| 1567 | # locale | ||||||||||||||||||||||||||||||||||||||||||
| 1568 | phrasetable =>'', | ||||||||||||||||||||||||||||||||||||||||||
| 1569 | defaultlanguage => 'en_GB', | ||||||||||||||||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||||||||||||||||
| 1571 | # workflow parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1572 | workflowparam => 'to', | ||||||||||||||||||||||||||||||||||||||||||
| 1573 | entryaction => 'core.default', | ||||||||||||||||||||||||||||||||||||||||||
| 1574 | modules => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||||||||||||||||
| 1576 | # combinable files | ||||||||||||||||||||||||||||||||||||||||||
| 1577 | cssfiles => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1578 | jsfiles => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1579 | |||||||||||||||||||||||||||||||||||||||||||
| 1580 | # triggers | ||||||||||||||||||||||||||||||||||||||||||
| 1581 | onsessionstart => '', | ||||||||||||||||||||||||||||||||||||||||||
| 1582 | onsessionoutofdate => '', | ||||||||||||||||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||||||||||||||||
| 1584 | # uploads | ||||||||||||||||||||||||||||||||||||||||||
| 1585 | uploadmaxsize => (1024 * 1024 * 6), # 6MB | ||||||||||||||||||||||||||||||||||||||||||
| 1586 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1587 | |||||||||||||||||||||||||||||||||||||||||||
| 1588 | # check if config filename is given -> if so, load it first | ||||||||||||||||||||||||||||||||||||||||||
| 1589 | # (so that it can be overwritten by settings from %options later!) | ||||||||||||||||||||||||||||||||||||||||||
| 1590 | 0 | my $cfgopts = $optdefaults; | |||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | foreach my $key (keys %options) { | |||||||||||||||||||||||||||||||||||||||||
| 1592 | 0 | my $name = lc $key; | |||||||||||||||||||||||||||||||||||||||||
| 1593 | 0 | $name =~ s/^\-*//; | |||||||||||||||||||||||||||||||||||||||||
| 1594 | 0 | ▶ | if ($name eq 'config') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1595 | 0 | $cfgopts = __load_config_file( $options{$key}, $optdefaults ); | |||||||||||||||||||||||||||||||||||||||||
| 1596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1597 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | my $opts = __parse_params( \%options, $cfgopts ); | |||||||||||||||||||||||||||||||||||||||||
| 1600 | 0 | map { $self->{$_} = $opts->{$_} } keys %{$opts}; | |||||||||||||||||||||||||||||||||||||||||
| 1601 | |||||||||||||||||||||||||||||||||||||||||||
| 1602 | # add 'default' theme as last fallback if not already added | ||||||||||||||||||||||||||||||||||||||||||
| 1603 | 0 | push @{$self->{'templatefallbacks'}}, 'core' | |||||||||||||||||||||||||||||||||||||||||
| 1604 | 0 | if !scalar @{$self->{'templatefallbacks'}} | |||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | ▶ | || $self->{'templatefallbacks'}->[-1] ne 'core'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not scalar @{$self->{"templatefallbacks"};} or $self->{"templatefallbacks"}[-1] ne "core"
MC/DC0%0/2
not scalar @{$self->{"templatefallbacks"};} or $self->{"templatefallbacks"}[-1] ne "core"
not scalar @{$self->{"templatefallbacks"};}
$self->{"templatefallbacks"}[-1] ne "core"
Truth table0%0/3
not(A) or B
A= not scalar @{$self->{"templatefallbacks"};}B= $self->{"templatefallbacks"}[-1] ne "core"
| |||||||||||||||||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||||||||||||||||
| 1607 | 0 | $self->{'dbh'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1608 | 0 | $self->{'session'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1609 | 0 | $self->{'session_id'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1610 | |||||||||||||||||||||||||||||||||||||||||||
| 1611 | # caches for function refs. | ||||||||||||||||||||||||||||||||||||||||||
| 1612 | 0 | $self->{'workflow_function_cache'} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1613 | 0 | $self->{"template_function_cache"} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1614 | 0 | $self->{"access_function_cache"} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1615 | |||||||||||||||||||||||||||||||||||||||||||
| 1616 | 0 | $self->__load_session(); | |||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||
| 1618 | # common placeholders | ||||||||||||||||||||||||||||||||||||||||||
| 1619 | $self->{'common_placeholders'} = { | ||||||||||||||||||||||||||||||||||||||||||
| 1620 | 'script_url' => (exists $ENV{'SCRIPT_NAME'} ? $ENV{'SCRIPT_NAME'} : '?'), | ||||||||||||||||||||||||||||||||||||||||||
| 1621 | 'public_url' => $self->{'publicurl'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1622 | 'clear' => '<div class="clear"></div>', | ||||||||||||||||||||||||||||||||||||||||||
| 1623 | 'session_id' => $self->{'session_id'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1624 | 'do_nothing_url' => 'javascript:void(1);', | ||||||||||||||||||||||||||||||||||||||||||
| 1625 | 'javascript_url' => (exists $ENV{'SCRIPT_NAME'} ? $ENV{'SCRIPT_NAME'} : '').'?to=core.combine.javascript', | ||||||||||||||||||||||||||||||||||||||||||
| 1626 | 0 | ▶ | 'css_url' => (exists $ENV{'SCRIPT_NAME'} ? $ENV{'SCRIPT_NAME'} : '').'?to=core.combine.css', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1627 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||||||||||||||||
| 1629 | # name of workflow function that is currently executed | ||||||||||||||||||||||||||||||||||||||||||
| 1630 | 0 | $self->{'current_workflow_function'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||
| 1632 | # set current language | ||||||||||||||||||||||||||||||||||||||||||
| 1633 | 0 | $self->set('language', $self->{'defaultlanguage'}); | |||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||
| 1635 | # uploads info | ||||||||||||||||||||||||||||||||||||||||||
| 1636 | 0 | $self->{'session'}->{'uploads'} = []; | |||||||||||||||||||||||||||||||||||||||||
| 1637 | |||||||||||||||||||||||||||||||||||||||||||
| 1638 | # save global CGI::WebToolkit instance | ||||||||||||||||||||||||||||||||||||||||||
| 1639 | 0 | $WTK = $self; | |||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||
| 1641 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 1642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1643 | |||||||||||||||||||||||||||||||||||||||||||
| 1644 | sub __load_config_file | ||||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__load_config_file: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | my ($filename, $defaults) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1647 | |||||||||||||||||||||||||||||||||||||||||||
| 1648 | 0 | ▶ | open CFGFILE, '<'.$filename | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1649 | or _die("failed to load config file '$filename': $!"); | ||||||||||||||||||||||||||||||||||||||||||
| 1650 | 0 | my $options = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1651 | 0 | ▶ | if (defined $defaults) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1652 | # copy defaults | ||||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | map { $options->{$_} = $defaults->{$_} } keys %{$defaults}; | |||||||||||||||||||||||||||||||||||||||||
| 1654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | ▶ | while (<CFGFILE>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1656 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | s/^(.*)\#.*$/$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | ▶ | next if /^[\s\t\n\r]*$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | s/^[\s\t\n\r]*//g; | |||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | s/[\s\t\n\r]*$//g; | |||||||||||||||||||||||||||||||||||||||||
| 1661 | 0 | ▶ | my $rgx = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1662 | (defined $defaults ? | ||||||||||||||||||||||||||||||||||||||||||
| 1663 | '^([a-zA-Z0-9\_]+)[\s\t]*\:[\s\t]*(.*)$' : | ||||||||||||||||||||||||||||||||||||||||||
| 1664 | '^([^\:]+)[\s\t]*\:[\s\t]*(.*)$'); | ||||||||||||||||||||||||||||||||||||||||||
| 1665 | 0 | ▶ | if (/$rgx/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1666 | 0 | my ($key, $value) = $_ =~ /$rgx/; | |||||||||||||||||||||||||||||||||||||||||
| 1667 | 0 | $key = lc $key; | |||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | $key =~ s/^\-*//g; | |||||||||||||||||||||||||||||||||||||||||
| 1669 | |||||||||||||||||||||||||||||||||||||||||||
| 1670 | 0 | ▶ | if (defined $defaults) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | ▶ | if (ref $defaults->{$key} eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1672 | # array variable | ||||||||||||||||||||||||||||||||||||||||||
| 1673 | $options->{$key} = [ split(/\s*\,\s*/, $value) ] | ||||||||||||||||||||||||||||||||||||||||||
| 1674 | 0 | ▶ | if exists $defaults->{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1675 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1676 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1677 | # string variable | ||||||||||||||||||||||||||||||||||||||||||
| 1678 | $options->{$key} = $value | ||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | ▶ | if exists $defaults->{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1682 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | $options->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 1684 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1686 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | close CFGFILE; | |||||||||||||||||||||||||||||||||||||||||
| 1688 | 0 | return $options; | |||||||||||||||||||||||||||||||||||||||||
| 1689 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||||||||||||||||
| 1691 | # dumps data to browser | ||||||||||||||||||||||||||||||||||||||||||
| 1692 | sub __dd | ||||||||||||||||||||||||||||||||||||||||||
| 1693 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__dd: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1694 | 0 | print header(); | |||||||||||||||||||||||||||||||||||||||||
| 1695 | 0 | print '<pre>'.dump($_[0]).'</pre><br/>'; | |||||||||||||||||||||||||||||||||||||||||
| 1696 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1697 | |||||||||||||||||||||||||||||||||||||||||||
| 1698 | sub __parse_params | ||||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__parse_params: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1700 | 0 | my ($params, $defaults) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1701 | 0 | my $values = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1702 | 0 | foreach my $key (keys %{$defaults}) { | |||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | $values->{$key} = $defaults->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | foreach my $key (keys %{$params}) { | |||||||||||||||||||||||||||||||||||||||||
| 1706 | 0 | my $cleankey = lc $key; | |||||||||||||||||||||||||||||||||||||||||
| 1707 | 0 | $cleankey =~ s/^\-//; | |||||||||||||||||||||||||||||||||||||||||
| 1708 | $values->{$cleankey} = $params->{$key} | ||||||||||||||||||||||||||||||||||||||||||
| 1709 | 0 | ▶ | if exists $defaults->{$cleankey}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1710 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1711 | 0 | return $values; | |||||||||||||||||||||||||||||||||||||||||
| 1712 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||||||||||||||||
| 1714 | sub __die | ||||||||||||||||||||||||||||||||||||||||||
| 1715 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__die: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1716 | 0 | my ($msg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1717 | 0 | print header(); | |||||||||||||||||||||||||||||||||||||||||
| 1718 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 1719 | '<html></head><title>Lowlevel Error</title></head><body>'. | ||||||||||||||||||||||||||||||||||||||||||
| 1720 | '<span style="color:red">Lowlevel Error: <b>'.$msg.'</b></span>'. | ||||||||||||||||||||||||||||||||||||||||||
| 1721 | '</body></html>'; | ||||||||||||||||||||||||||||||||||||||||||
| 1722 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 1723 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1724 | |||||||||||||||||||||||||||||||||||||||||||
| 1725 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 1726 | # ------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 1727 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1728 | __END__ | ||||||||||||||||||||||||||||||||||||||||||