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