Perlinfo/General.pm

filter: Statementstmt 61.2% 71 / 116 Branchbran 40.0% 20 / 50 Conditioncond 33.9% 19 / 56 MC/DCmcdc 6.6% 2 / 30 Subroutinesub 86.6% 13 / 15 Podpod 0.0% 0 / 7 totaltotal 45.6% 125 / 274 CC 49 SCAR 42.4
CC
49
Cov
50%
print_general
144.0
print_httpd
42.0
print_thesemodules
30.0
CRAP 69.2
« Perlinfo/Modules.pm ↑ Summary Perlinfo/Base.pm »
1 package HTML::Perlinfo::General;
2
3 5 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 our @EXPORT = qw(print_httpd print_thesemodules print_config print_variables print_general);
5 5 ▶use POSIX qw(uname);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use CGI::Deurl as => 'myparams';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Config qw(%Config config_sh);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Net::Domain qw(hostname);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use HTML::Perlinfo::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use HTML::Perlinfo::Apache;
Subroutine BEGIN: called CC=1 SCAR=0.0
12
13 # Should search for Get, Post, Cookies, Session, and Environment.
14 sub perl_print_gpcse_array {
15 1 ▶ my $html;
Subroutine perl_print_gpcse_array: called CC=10 SCAR=28.7
Pod undocumented
16 1 my($name) = @_;
17 1 my ($gpcse_name, $gpcse_value);
18 #POST names should be param() and get in url_param()
19 1 ▶ if (defined($ENV{'QUERY_STRING'}) && length($ENV{'QUERY_STRING'}) >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"QUERY_STRING"} and length $ENV{"QUERY_STRING"} >= 1) 0 1 1
Condition33%1/3
defined $ENV{"QUERY_STRING"} and length $ENV{"QUERY_STRING"} >= 1
!ll&&!rl&&r
100
MC/DC0%0/2
defined $ENV{"QUERY_STRING"} and length $ENV{"QUERY_STRING"} >= 1
defined $ENV{"QUERY_STRING"} length $ENV{"QUERY_STRING"} >= 1
Truth table33%1/3
A and B
A= defined $ENV{"QUERY_STRING"}B= length $ENV{"QUERY_STRING"} >= 1
ABresult
0X0
100
111
20 0 foreach(keys %myparams) { $html .= print_table_row(2, "GET[\"$_\"]", $myparams{$_}); }
21 }
22 1 ▶ if (defined($ENV{'CONTENT_LENGTH'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"CONTENT_LENGTH"}) 0 1 1
23 0 foreach(keys %myparams) { $html .= print_table_row(2, "POST[\"$_\"]", $myparams{$_}); }
24 }
25 1 ▶ if (defined($ENV{'HTTP_COOKIE'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"HTTP_COOKIE"}) 0 1 1
26 0 $cookies = $ENV{'HTTP_COOKIE'};
27 0 @cookies = split(';',$cookies);
28 0 foreach (@cookies) {
29 0 ($k,$v) = split('=',$_);
30 0 $html .= print_table_row(2, "COOKIE[\"$k\"]", "$v");
31 }
32 }
33 1 foreach my $key (sort(keys %ENV))
34 {
35 31 $gpcse_name = "$name" . '["' . "$key" . '"]';
36 31 ▶ if ($ENV{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{$key}) { } 29 2 31
37 29 $gpcse_value = "$ENV{$key}";
38 } else {
39 2 $gpcse_value = "<i>no value</i>";
40 }
41
42
43 31 $html .= print_table_row(2, "$gpcse_name", "$gpcse_value");
44 }
45 1 return $html;
46 }
47
48 sub print_variables {
49
50 return join '', print_section("Environment"),
51 print_table_start(),
52 print_table_header(2, "Variable", "Value"),
53 1 ▶ ((defined($ENV{'SERVER_SOFTWARE'})) ? perl_print_gpcse_array("SERVER") : perl_print_gpcse_array("ENV",)),
Subroutine print_variables: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined $ENV{'SERVER_SOFTWARE'} ? : 0 1 1
54 print_table_end();
55 }
56
57 sub print_config {
58
59 1 ▶ return join '', print_section("Perl Core"),
Subroutine print_config: called CC=1 SCAR=0.0
Pod undocumented
60 print_table_start(),
61 print_table_header(2, "Variable", "Value"),
62 print_config_sh($_[0]),
63 print_table_end();
64 }
65
66 sub print_config_sh {
67
68 1 ▶ my @configs = qw/api_versionstring cc ccflags cf_by cf_email cf_time extensions installarchlib installbin installhtmldir installhtmlhelpdir installprefix installprefixexp installprivlib installscript installsitearch installsitebin known_extensions libc libperl libpth libs myarchname optimize osname osvers package perllibs perlpath pm_apiversion prefix prefixexp privlib privlibexp startperl version version_patchlevel_string xs_apiversion/;
Subroutine print_config_sh: called CC=5 SCAR=16.2
Pod undocumented
69
70 return ($_[0] eq 'info_all') ?
71 0 join '', map { print_table_row(2, add_link('config',$_), $Config{$_})} @configs
72 1 ▶ : join '', map { print_table_row(2, map{
Branch: 1 branch
BranchTrueFalseTotal
$_[0] eq 'info_all' ? : 0 1 1
73 1245 ▶ if ($_ !~ /^'/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_ =~ /^'/) { } 1664 1245 2909
74 1664 add_link('config', $_);
75 }
76 else {
77 1245 ▶ if ($_ eq "\'\'" || $_ eq "\' \'" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq q[''] or $_ eq q[' ']) { } 151 1094 1245
Condition100%3/3
$_ eq "''" or $_ eq "' '"
l!l&&r!l&&!r
140111094
MC/DC100%2/2
$_ eq "''" or $_ eq "' '"
$_ eq "''" $_ eq "' '"
Truth table100%3/3
A or B
A= $_ eq "''"B= $_ eq "' '"
ABresult
1X1
011
000
78 151 my $value = "<i>no value</i>";
79 151 $value;
80 }
81 else {
82 1094 $_;
83 }
84 }
85 }split/=/,$_ )
86 } split /\n/, config_sh();
87 }
88
89 sub print_httpd {
90
91 0 ▶ return unless (defined $ENV{'SERVER_SOFTWARE'} && $ENV{'SERVER_SOFTWARE'} =~ /apache/i);
Subroutine print_httpd: not called CC=6 SCAR=37.4
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ENV{"SERVER_SOFTWARE"} and $ENV{"SERVER_SOFTWARE"} =~ /apache/i 0 0 0
Condition0%0/3
defined $ENV{"SERVER_SOFTWARE"} and $ENV{"SERVER_SOFTWARE"} =~ /apache/i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ENV{"SERVER_SOFTWARE"} and $ENV{"SERVER_SOFTWARE"} =~ /apache/i
defined $ENV{"SERVER_SOFTWARE"} $ENV{"SERVER_SOFTWARE"} =~ /apache/i
Truth table0%0/3
A and B
A= defined $ENV{"SERVER_SOFTWARE"}B= $ENV{"SERVER_SOFTWARE"} =~ /apache/i
ABresult
0X0
100
111
92 0 my $a = HTML::Perlinfo::Apache->new();
93
94 0 my $html .= print_section("Apache");
95 0 $html .= print_table_start();
96 0 ▶ $html .= $a->print_apache() if $a->has(qw(env));
Branch: 1 branch
BranchTrueFalseTotal
if $a->has("env") 0 0 0
97 0 $html .= print_table_end();
98
99 0 ▶ $html .= $a->print_modperl() if $a->has(qw(mp));
Branch: 1 branch
BranchTrueFalseTotal
if $a->has("mp") 0 0 0
100
101 0 $html .= print_section("Apache Environment"),
102 $html .= print_table_start();
103 0 ▶ $html .= print_table_header(2, "Variable", "Value"),
Branch: 1 branch
BranchTrueFalseTotal
if $a->has("env") 0 0 0
104 $html .= $a->print_apache_environment() if $a->has(qw(env));
105 0 $html .= print_table_end();
106
107 0 return $html;
108 }
109
110 sub print_thesemodules {
111 0 ▶ my $opt = shift;
Subroutine print_thesemodules: not called CC=5 SCAR=34.0
Pod undocumented
112 0 $m = HTML::Perlinfo::Modules->new();
113 0 ▶ if ($opt eq 'core') {
Branch: 3 branches
BranchTrueFalseTotal
if ($opt eq 'core') { } 0 0 0
elsif ($opt eq 'all') { } 0 0 0
elsif ($opt eq 'loaded' and ref $_[0] eq 'ARRAY') { } 0 0 0
114 0 return $m->print_modules(show_only=>$opt, full_page=>0);
115 }
116 elsif ($opt eq 'all') {
117 0 return $m->print_modules(section=>'All Perl modules', full_page=>0);
118 }
119 ▶ elsif ($opt eq 'loaded' && ref $_[0] eq 'ARRAY') {
Condition0%0/3
$opt eq "loaded" and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$opt eq "loaded" and ref $_[0] eq "ARRAY"
$opt eq "loaded" ref $_[0] eq "ARRAY"
Truth table0%0/3
A and B
A= $opt eq "loaded"B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
120 0 return $m->print_modules(section=>'Loaded Modules', files_in=>shift, full_page=>0);
121 }
122 else {
123 0 die "internal function print_thesemodules has invalid arguments: @_";
124 }
125 }
126
127 sub print_general {
128
129 1 ▶ my $opt = shift || 'full';
Subroutine print_general: called CC=26 SCAR=49.7
Pod undocumented
Condition50%1/2
shift() || 'full'
l!l
10
MC/DC0%0/1
shift() || 'full'
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
130
131 1 my $html = print_box_start(1);
132 1 $html .= sprintf("<h1 class=\"p\">Perl Version %s</h1><br style=\"clear:both\" />Release date: %s", perl_version(), release_date());
133
134 1 $html .= print_box_end();
135
136 1 $html .= print_table_start();
137 1 $html .= print_table_row(2, "Currently running on", "@{[ (uname)[0..4] ]}");
138 1 $html .= print_table_row(2, "Built for", "$Config{archname}");
139 1 $html .= print_table_row(2, "Build date", "$Config{cf_time}");
140 1 $html .= print_table_row(2, "Perl path", "$^X");
141
142 1 $html .= print_table_row(2, "Additional C Compiler Flags", "$Config{ccflags}");
143 1 $html .= print_table_row(2, "Optimizer/Debugger Flags", "$Config{optimize}");
144
145 1 ▶ if (defined($ENV{'SERVER_SOFTWARE'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"SERVER_SOFTWARE"}) 0 1 1
146 0 $html .= print_table_row(2, "Server API", "$ENV{'SERVER_SOFTWARE'}");
147 }
148 1 ▶ if ($Config{usethreads} && !$Config{useithreads} && !$Config{use5005threads}) {
Branch: 7 branches
BranchTrueFalseTotal
if ($Config{'usethreads'} and not $Config{'useithreads'} and not $Config{'use5005threads'}) { } 0 1 1
elsif ($Config{'useithreads'} and not $Config{'usethreads'} and not $Config{'use5005threads'}) { } 0 1 1
elsif ($Config{'use5005threads'} and not $Config{'usethreads'} and not $Config{'useithreads'}) { } 0 1 1
elsif ($Config{'usethreads'} and $Config{'useithreads'} and not $Config{'use5005threads'}) { } 0 1 1
elsif ($Config{'usethreads'} and $Config{'use5005threads'} and not $Config{'useithreads'}) { } 0 1 1
elsif ($Config{'useithreads'} and $Config{'use5005threads'} and not $Config{'usethreads'}) { } 0 1 1
elsif ($Config{'usethreads'} and $Config{'useithreads'} and $Config{'use5005threads'}) { } 0 1 1
Condition33%2/6
$Config{"usethreads"} and not $Config{"useithreads"} and not $Config{"use5005threads"}
!ll&&!rl&&r
100
$Config{"usethreads"} and not $Config{"useithreads"}
!ll&&!rl&&r
100
MC/DC0%0/3
$Config{"usethreads"} and not $Config{"useithreads"} and not $Config{"use5005threads"}
$Config{"usethreads"} not $Config{"useithreads"} not $Config{"use5005threads"}
Truth table25%1/4
A and not(B) and not(C)
A= $Config{"usethreads"}B= not $Config{"useithreads"}C= not $Config{"use5005threads"}
ABCresult
0XX0
10X0
1100
1111
149 0 $html .= print_table_row(2, "Thread Support", "enabled (threads)");
150 }
151 ▶ elsif ($Config{useithreads} && !$Config{usethreads} && !$Config{use5005threads}) {
Condition33%2/6
$Config{"useithreads"} and not $Config{"usethreads"} and not $Config{"use5005threads"}
!ll&&!rl&&r
100
$Config{"useithreads"} and not $Config{"usethreads"}
!ll&&!rl&&r
100
MC/DC0%0/3
$Config{"useithreads"} and not $Config{"usethreads"} and not $Config{"use5005threads"}
$Config{"useithreads"} not $Config{"usethreads"} not $Config{"use5005threads"}
Truth table25%1/4
A and not(B) and not(C)
A= $Config{"useithreads"}B= not $Config{"usethreads"}C= not $Config{"use5005threads"}
ABCresult
0XX0
10X0
1100
1111
152 0 $html .= print_table_row(2, "Thread Support", "enabled (ithreads)");
153 }
154 ▶ elsif ($Config{use5005threads} && !$Config{usethreads} && !$Config{useithreads}) {
Condition33%2/6
$Config{"use5005threads"} and not $Config{"usethreads"} and not $Config{"useithreads"}
!ll&&!rl&&r
100
$Config{"use5005threads"} and not $Config{"usethreads"}
!ll&&!rl&&r
100
MC/DC0%0/3
$Config{"use5005threads"} and not $Config{"usethreads"} and not $Config{"useithreads"}
$Config{"use5005threads"} not $Config{"usethreads"} not $Config{"useithreads"}
Truth table25%1/4
A and not(B) and not(C)
A= $Config{"use5005threads"}B= not $Config{"usethreads"}C= not $Config{"useithreads"}
ABCresult
0XX0
10X0
1100
1111
155 0 $html .= print_table_row(2, "Thread Support", "enabled (5005threads)");
156 }
157 ▶ elsif ($Config{usethreads} && $Config{useithreads} && !$Config{use5005threads}) {
Condition33%2/6
$Config{"usethreads"} and $Config{"useithreads"} and not $Config{"use5005threads"}
!ll&&!rl&&r
100
$Config{"usethreads"} and $Config{"useithreads"}
!ll&&!rl&&r
100
MC/DC0%0/3
$Config{"usethreads"} and $Config{"useithreads"} and not $Config{"use5005threads"}
$Config{"usethreads"} $Config{"useithreads"} not $Config{"use5005threads"}
Truth table25%1/4
A and B and not(C)
A= $Config{"usethreads"}B= $Config{"useithreads"}C= not $Config{"use5005threads"}
ABCresult
0XX0
10X0
1100
1111
158 0 $html .= print_table_row(2, "Thread Support", "enabled (threads, ithreads)");
159 }
160 ▶ elsif ($Config{usethreads} && $Config{use5005threads} && !$Config{useithreads}) {
Condition33%2/6
$Config{"usethreads"} and $Config{"use5005threads"} and not $Config{"useithreads"}
!ll&&!rl&&r
100
$Config{"usethreads"} and $Config{"use5005threads"}
!ll&&!rl&&r
100
MC/DC0%0/3
$Config{"usethreads"} and $Config{"use5005threads"} and not $Config{"useithreads"}
$Config{"usethreads"} $Config{"use5005threads"} not $Config{"useithreads"}
Truth table25%1/4
A and B and not(C)
A= $Config{"usethreads"}B= $Config{"use5005threads"}C= not $Config{"useithreads"}
ABCresult
0XX0
10X0
1100
1111
161 0 $html .= print_table_row(2, "Thread Support", "enabled (threads, 5005threads)");
162 }
163 ▶ elsif ($Config{useithreads} && $Config{use5005threads} && !$Config{usethreads}) {
Condition33%2/6
$Config{"useithreads"} and $Config{"use5005threads"} and not $Config{"usethreads"}
!ll&&!rl&&r
100
$Config{"useithreads"} and $Config{"use5005threads"}
!ll&&!rl&&r
100
MC/DC0%0/3
$Config{"useithreads"} and $Config{"use5005threads"} and not $Config{"usethreads"}
$Config{"useithreads"} $Config{"use5005threads"} not $Config{"usethreads"}
Truth table25%1/4
A and B and not(C)
A= $Config{"useithreads"}B= $Config{"use5005threads"}C= not $Config{"usethreads"}
ABCresult
0XX0
10X0
1100
1111
164 0 $html .= print_table_row(2, "Thread Support", "enabled (ithreads, 5005threads)");
165 }
166 ▶ elsif ($Config{usethreads} && $Config{useithreads} && $Config{use5005threads}) {
Condition33%2/6
$Config{"usethreads"} and $Config{"useithreads"} and $Config{"use5005threads"}
!ll&&!rl&&r
100
$Config{"usethreads"} and $Config{"useithreads"}
!ll&&!rl&&r
100
MC/DC0%0/3
$Config{"usethreads"} and $Config{"useithreads"} and $Config{"use5005threads"}
$Config{"usethreads"} $Config{"useithreads"} $Config{"use5005threads"}
Truth table25%1/4
A and B and C
A= $Config{"usethreads"}B= $Config{"useithreads"}C= $Config{"use5005threads"}
ABCresult
0XX0
10X0
1100
1111
167 0 $html .= print_table_row(2, "Thread Support", "enabled (threads, ithreads, 5005threads)");
168 }
169 else {
170 1 $html .= print_table_row(2, "Thread Support", "disabled (threads, ithreads, 5005threads)");
171 }
172 1 $html .= print_table_end();
173
174 1 $html .= print_box_start(0);
175
176
177 1 $html .= "This is perl, v$Config{version} built for $Config{archname}<br />Copyright (c) 1987-@{[ sprintf '%d', (localtime)[5]+1900]}, Larry Wall";
178 1 $html .= print_box_end();
179
180 1 ▶ return $html if $opt eq 'top';
Branch: 1 branch
BranchTrueFalseTotal
if $opt eq "top" 1 0 1
181
182 0 $html .= print_hr();
183 0 $html .= "<h1>Configuration</h1>\n";
184 0 $html .= print_config('info_all');
185
186 0 $html .= join '', print_section("Perl utilities"),
187 print_table_start(),
188 print_table_header(2, "Name", "Location"),
189 print_table_row(2, add_link('cpan', 'h2ph'), check_path("h2ph")),
190 print_table_row(2, add_link('cpan', 'h2xs'), check_path("h2xs")),
191 print_table_row(2, add_link('cpan', 'perldoc'), check_path("perldoc")),
192 print_table_row(2, add_link('cpan', 'pod2html'), check_path("pod2html")),
193 print_table_row(2, add_link('cpan', 'pod2latex'), check_path("pod2latex")),
194 print_table_row(2, add_link('cpan', 'pod2man'), check_path("pod2man")),
195 print_table_row(2, add_link('cpan', 'pod2text'), check_path("pod2text")),
196 print_table_row(2, add_link('cpan', 'pod2usage'), check_path("pod2usage")),
197 print_table_row(2, add_link('cpan', 'podchecker'), check_path("podchecker")),
198 print_table_row(2, add_link('cpan', 'podselect'), check_path("podselect")),
199 print_table_end(),
200
201 print_section("Mail"),
202 print_table_start(),
203 print_table_row(2, 'SMTP', hostname()),
204 print_table_row(2, 'sendmail_path', check_path("sendmail")),
205 print_table_end(),
206
207 print_httpd(),
208
209 print_section("HTTP Headers Information"),
210 print_table_start(),
211 print_table_colspan_header(2, "HTTP Request Headers");
212 0 ▶ if (defined($ENV{'SERVER_SOFTWARE'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"SERVER_SOFTWARE"}) 0 0 0
213 $html .= join '',
214 0 print_table_row(2, 'HTTP Request', "$ENV{'REQUEST_METHOD'} @{[File::Spec->abs2rel($0)]} $ENV{'SERVER_PROTOCOL'}"),
215 print_table_row(2, 'Host', $ENV{'HTTP_HOST'}),
216 print_table_row(2, 'User-Agent', $ENV{'HTTP_USER_AGENT'}),
217 print_table_row(2, 'Accept', $ENV{'HTTP_ACCEPT_ENCODING'}),
218 print_table_row(2, 'Accept-Language', $ENV{'HTTP_ACCEPT_LANGUAGE'}),
219 print_table_row(2, 'Accept-Charset', $ENV{'HTTP_ACCEPT_CHARSET'}),
220 print_table_row(2, 'Keep-Alive', $ENV{'HTTP_KEEP_ALIVE'}),
221 0 print_table_row(2, 'Connection', $ENV{'HTTP_CONNECTION'});
222 }
223 0 $html .= print_table_end();
224 0 return $html;
225 }
226 5 1;
227
« Perlinfo/Modules.pm ↑ Summary Perlinfo/Base.pm »