Perlinfo/General.pm

filter: Statementstmt 60.5% 72 / 119 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.4% 126 / 277 SCAR 58.9
CC
49
Cov
49%
print_general
144.0
print_httpd
42.0
print_thesemodules
30.0
CRAP 361.3
« Perlinfo/Base.pm ↑ Summary Perlinfo/Apache.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 Config qw(%Config config_sh);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Net::Domain qw(hostname);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use CGI::Lite;
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 $cgi = CGI::Lite->new();
Subroutine perl_print_gpcse_array: called CC=10 SCAR=29.3
Pod undocumented
16 1 my $html;
17 1 my($name) = @_;
18 1 my ($gpcse_name, $gpcse_value);
19 #CGI.pm: POST names should be param() and get in url_param()
20 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
21 0 my $myparams = $cgi->parse_form_data();
22 0 foreach(keys %myparams) { $html .= print_table_row(2, "GET[\"$_\"]", $myparams{$_}); }
23 }
24 1 ▶ if (defined($ENV{'CONTENT_LENGTH'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"CONTENT_LENGTH"}) 0 1 1
25 0 my $myparams = $cgi->parse_form_data();
26 0 foreach(keys %myparams) { $html .= print_table_row(2, "POST[\"$_\"]", $myparams{$_}); }
27 }
28 1 ▶ if (defined($ENV{'HTTP_COOKIE'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"HTTP_COOKIE"}) 0 1 1
29 0 $cookies = $ENV{'HTTP_COOKIE'};
30 0 @cookies = split(';',$cookies);
31 0 foreach (@cookies) {
32 0 ($k,$v) = split('=',$_);
33 0 $html .= print_table_row(2, "COOKIE[\"$k\"]", "$v");
34 }
35 }
36 1 foreach my $key (sort(keys %ENV))
37 {
38 30 $gpcse_name = "$name" . '["' . "$key" . '"]';
39 30 ▶ if ($ENV{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{$key}) { } 28 2 30
40 28 $gpcse_value = "$ENV{$key}";
41 } else {
42 2 $gpcse_value = "<i>no value</i>";
43 }
44
45
46 30 $html .= print_table_row(2, "$gpcse_name", "$gpcse_value");
47 }
48 1 return $html;
49 }
50
51 sub print_variables {
52
53 return join '', print_section("Environment"),
54 print_table_start(),
55 print_table_header(2, "Variable", "Value"),
56 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
57 print_table_end();
58 }
59
60 sub print_config {
61
62 1 ▶ return join '', print_section("Perl Core"),
Subroutine print_config: called CC=1 SCAR=0.0
Pod undocumented
63 print_table_start(),
64 print_table_header(2, "Variable", "Value"),
65 print_config_sh($_[0]),
66 print_table_end();
67 }
68
69 sub print_config_sh {
70
71 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
72
73 return ($_[0] eq 'info_all') ?
74 0 join '', map { print_table_row(2, add_link('config',$_), $Config{$_})} @configs
75 1 ▶ : join '', map { print_table_row(2, map{
Branch: 1 branch
BranchTrueFalseTotal
$_[0] eq 'info_all' ? : 0 1 1
76 1245 ▶ if ($_ !~ /^'/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_ =~ /^'/) { } 1664 1245 2909
77 1664 add_link('config', $_);
78 }
79 else {
80 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
81 151 my $value = "<i>no value</i>";
82 151 $value;
83 }
84 else {
85 1094 $_;
86 }
87 }
88 }split/=/,$_ )
89 } split /\n/, config_sh();
90 }
91
92 sub print_httpd {
93
94 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
95 0 my $a = HTML::Perlinfo::Apache->new();
96
97 0 my $html .= print_section("Apache");
98 0 $html .= print_table_start();
99 0 ▶ $html .= $a->print_apache() if $a->has(qw(env));
Branch: 1 branch
BranchTrueFalseTotal
if $a->has("env") 0 0 0
100 0 $html .= print_table_end();
101
102 0 ▶ $html .= $a->print_modperl() if $a->has(qw(mp));
Branch: 1 branch
BranchTrueFalseTotal
if $a->has("mp") 0 0 0
103
104 0 $html .= print_section("Apache Environment"),
105 $html .= print_table_start();
106 0 ▶ $html .= print_table_header(2, "Variable", "Value"),
Branch: 1 branch
BranchTrueFalseTotal
if $a->has("env") 0 0 0
107 $html .= $a->print_apache_environment() if $a->has(qw(env));
108 0 $html .= print_table_end();
109
110 0 return $html;
111 }
112
113 sub print_thesemodules {
114 0 ▶ my $opt = shift;
Subroutine print_thesemodules: not called CC=5 SCAR=34.0
Pod undocumented
115 0 $m = HTML::Perlinfo::Modules->new();
116 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
117 0 return $m->print_modules(show_only=>$opt, full_page=>0);
118 }
119 elsif ($opt eq 'all') {
120 0 return $m->print_modules(section=>'All Perl modules', full_page=>0);
121 }
122 ▶ 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
123 0 return $m->print_modules(section=>'Loaded Modules', files_in=>shift, full_page=>0);
124 }
125 else {
126 0 die "internal function print_thesemodules has invalid arguments: @_";
127 }
128 }
129
130 sub print_general {
131
132 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
133
134 1 my $html = print_box_start(1);
135 1 $html .= sprintf("<h1 class=\"p\">Perl Version %s</h1><br style=\"clear:both\" />Release date: %s", perl_version(), release_date());
136
137 1 $html .= print_box_end();
138
139 1 $html .= print_table_start();
140 1 $html .= print_table_row(2, "Currently running on", "@{[ (uname)[0..4] ]}");
141 1 $html .= print_table_row(2, "Built for", "$Config{archname}");
142 1 $html .= print_table_row(2, "Build date", "$Config{cf_time}");
143 1 $html .= print_table_row(2, "Perl path", "$^X");
144
145 1 $html .= print_table_row(2, "Additional C Compiler Flags", "$Config{ccflags}");
146 1 $html .= print_table_row(2, "Optimizer/Debugger Flags", "$Config{optimize}");
147
148 1 ▶ if (defined($ENV{'SERVER_SOFTWARE'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"SERVER_SOFTWARE"}) 0 1 1
149 0 $html .= print_table_row(2, "Server API", "$ENV{'SERVER_SOFTWARE'}");
150 }
151 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
152 0 $html .= print_table_row(2, "Thread Support", "enabled (threads)");
153 }
154 ▶ 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
155 0 $html .= print_table_row(2, "Thread Support", "enabled (ithreads)");
156 }
157 ▶ 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
158 0 $html .= print_table_row(2, "Thread Support", "enabled (5005threads)");
159 }
160 ▶ 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
161 0 $html .= print_table_row(2, "Thread Support", "enabled (threads, ithreads)");
162 }
163 ▶ 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
164 0 $html .= print_table_row(2, "Thread Support", "enabled (threads, 5005threads)");
165 }
166 ▶ 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
167 0 $html .= print_table_row(2, "Thread Support", "enabled (ithreads, 5005threads)");
168 }
169 ▶ 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
170 0 $html .= print_table_row(2, "Thread Support", "enabled (threads, ithreads, 5005threads)");
171 }
172 else {
173 1 $html .= print_table_row(2, "Thread Support", "disabled (threads, ithreads, 5005threads)");
174 }
175 1 $html .= print_table_end();
176
177 1 $html .= print_box_start(0);
178
179
180 1 $html .= "This is perl, v$Config{version} built for $Config{archname}<br />Copyright (c) 1987-@{[ sprintf '%d', (localtime)[5]+1900]}, Larry Wall";
181 1 $html .= print_box_end();
182
183 1 ▶ return $html if $opt eq 'top';
Branch: 1 branch
BranchTrueFalseTotal
if $opt eq "top" 1 0 1
184
185 0 $html .= print_hr();
186 0 $html .= "<h1>Configuration</h1>\n";
187 0 $html .= print_config('info_all');
188
189 0 $html .= join '', print_section("Perl utilities"),
190 print_table_start(),
191 print_table_header(2, "Name", "Location"),
192 print_table_row(2, add_link('cpan', 'h2ph'), check_path("h2ph")),
193 print_table_row(2, add_link('cpan', 'h2xs'), check_path("h2xs")),
194 print_table_row(2, add_link('cpan', 'perldoc'), check_path("perldoc")),
195 print_table_row(2, add_link('cpan', 'pod2html'), check_path("pod2html")),
196 print_table_row(2, add_link('cpan', 'pod2latex'), check_path("pod2latex")),
197 print_table_row(2, add_link('cpan', 'pod2man'), check_path("pod2man")),
198 print_table_row(2, add_link('cpan', 'pod2text'), check_path("pod2text")),
199 print_table_row(2, add_link('cpan', 'pod2usage'), check_path("pod2usage")),
200 print_table_row(2, add_link('cpan', 'podchecker'), check_path("podchecker")),
201 print_table_row(2, add_link('cpan', 'podselect'), check_path("podselect")),
202 print_table_end(),
203
204 print_section("Mail"),
205 print_table_start(),
206 print_table_row(2, 'SMTP', hostname()),
207 print_table_row(2, 'sendmail_path', check_path("sendmail")),
208 print_table_end(),
209
210 print_httpd(),
211
212 print_section("HTTP Headers Information"),
213 print_table_start(),
214 print_table_colspan_header(2, "HTTP Request Headers");
215 0 ▶ if (defined($ENV{'SERVER_SOFTWARE'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"SERVER_SOFTWARE"}) 0 0 0
216 $html .= join '',
217 0 print_table_row(2, 'HTTP Request', "$ENV{'REQUEST_METHOD'} @{[File::Spec->abs2rel($0)]} $ENV{'SERVER_PROTOCOL'}"),
218 print_table_row(2, 'Host', $ENV{'HTTP_HOST'}),
219 print_table_row(2, 'User-Agent', $ENV{'HTTP_USER_AGENT'}),
220 print_table_row(2, 'Accept', $ENV{'HTTP_ACCEPT_ENCODING'}),
221 print_table_row(2, 'Accept-Language', $ENV{'HTTP_ACCEPT_LANGUAGE'}),
222 print_table_row(2, 'Accept-Charset', $ENV{'HTTP_ACCEPT_CHARSET'}),
223 print_table_row(2, 'Keep-Alive', $ENV{'HTTP_KEEP_ALIVE'}),
224 0 print_table_row(2, 'Connection', $ENV{'HTTP_CONNECTION'});
225 }
226 0 $html .= print_table_end();
227 0 return $html;
228 }
229 5 1;
230
« Perlinfo/Base.pm ↑ Summary Perlinfo/Apache.pm »