| blib/lib/HTML/Perlinfo/General.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % |
| statement | 24 | 117 | 20.5 |
| branch | 0 | 50 | 0.0 |
| condition | 0 | 56 | 0.0 |
| subroutine | 8 | 15 | 53.3 |
| pod | 0 | 7 | 0.0 |
| total | 32 | 245 | 13.0 |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package HTML::Perlinfo::General; | ||||||
| 2 | |||||||
| 3 | 1 | 1 | 6 | use base qw(Exporter); | |||
| 1 | 2 | ||||||
| 1 | 121 | ||||||
| 4 | our @EXPORT = qw(print_httpd print_thesemodules print_config print_variables print_general); | ||||||
| 5 | 1 | 1 | 517 | use POSIX qw(uname); | |||
| 1 | 6238 | ||||||
| 1 | 6 | ||||||
| 6 | 1 | 1 | 1460 | use Config qw(%Config config_sh); | |||
| 1 | 2 | ||||||
| 1 | 38 | ||||||
| 7 | 1 | 1 | 541 | use Net::Domain qw(hostname); | |||
| 1 | 8354 | ||||||
| 1 | 65 | ||||||
| 8 | 1 | 1 | 661 | use CGI::Lite; | |||
| 1 | 5751 | ||||||
| 1 | 68 | ||||||
| 9 | 1 | 1 | 7 | use File::Spec; | |||
| 1 | 2 | ||||||
| 1 | 34 | ||||||
| 10 | 1 | 1 | 7 | use HTML::Perlinfo::Common; | |||
| 1 | 2 | ||||||
| 1 | 120 | ||||||
| 11 | 1 | 1 | 6 | use HTML::Perlinfo::Apache; | |||
| 1 | 2 | ||||||
| 1 | 1983 | ||||||
| 12 | |||||||
| 13 | # Should search for Get, Post, Cookies, Session, and Environment. | ||||||
| 14 | sub perl_print_gpcse_array { | ||||||
| 15 | 0 | 0 | 0 | my $cgi = CGI::Lite->new(); | |||
| 16 | 0 | my $html; | |||||
| 17 | 0 | my($name) = @_; | |||||
| 18 | 0 | my ($gpcse_name, $gpcse_value); | |||||
| 19 | #CGI.pm: POST names should be param() and get in url_param() | ||||||
| 20 | 0 | 0 | 0 | if (defined($ENV{'QUERY_STRING'}) && length($ENV{'QUERY_STRING'}) >= 1) { | |||
| 21 | 0 | my $myparams = $cgi->parse_form_data(); | |||||
| 22 | 0 | foreach(keys %myparams) { $html .= print_table_row(2, "GET[\"$_\"]", $myparams{$_}); } | |||||
| 0 | |||||||
| 23 | } | ||||||
| 24 | 0 | 0 | if (defined($ENV{'CONTENT_LENGTH'})) { | ||||
| 25 | 0 | my $myparams = $cgi->parse_form_data(); | |||||
| 26 | 0 | foreach(keys %myparams) { $html .= print_table_row(2, "POST[\"$_\"]", $myparams{$_}); } | |||||
| 0 | |||||||
| 27 | } | ||||||
| 28 | 0 | 0 | if (defined($ENV{'HTTP_COOKIE'})) { | ||||
| 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 | 0 | foreach my $key (sort(keys %ENV)) | |||||
| 37 | { | ||||||
| 38 | 0 | $gpcse_name = "$name" . '["' . "$key" . '"]'; | |||||
| 39 | 0 | 0 | if ($ENV{$key}) { | ||||
| 40 | 0 | $gpcse_value = "$ENV{$key}"; | |||||
| 41 | } else { | ||||||
| 42 | 0 | $gpcse_value = "no value"; | |||||
| 43 | } | ||||||
| 44 | |||||||
| 45 | |||||||
| 46 | 0 | $html .= print_table_row(2, "$gpcse_name", "$gpcse_value"); | |||||
| 47 | } | ||||||
| 48 | 0 | 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 | 0 | 0 | 0 | 0 | ((defined($ENV{'SERVER_SOFTWARE'})) ? perl_print_gpcse_array("SERVER") : perl_print_gpcse_array("ENV",)), | ||
| 57 | print_table_end(); | ||||||
| 58 | } | ||||||
| 59 | |||||||
| 60 | sub print_config { | ||||||
| 61 | |||||||
| 62 | 0 | 0 | 0 | return join '', print_section("Perl Core"), | |||
| 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 | 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/; | |||
| 72 | |||||||
| 73 | return ($_[0] eq 'info_all') ? | ||||||
| 74 | 0 | join '', map { print_table_row(2, add_link('config',$_), $Config{$_})} @configs | |||||
| 75 | 0 | 0 | : join '', map { print_table_row(2, map{ | ||||
| 76 | 0 | 0 | if ($_ !~ /^'/) { | ||||
| 0 | |||||||
| 77 | 0 | add_link('config', $_); | |||||
| 78 | } | ||||||
| 79 | else { | ||||||
| 80 | 0 | 0 | 0 | if ($_ eq "\'\'" || $_ eq "\' \'" ) { | |||
| 81 | 0 | my $value = "no value"; | |||||
| 82 | 0 | $value; | |||||
| 83 | } | ||||||
| 84 | else { | ||||||
| 85 | 0 | $_; | |||||
| 86 | } | ||||||
| 87 | } | ||||||
| 88 | }split/=/,$_ ) | ||||||
| 89 | } split /\n/, config_sh(); | ||||||
| 90 | } | ||||||
| 91 | |||||||
| 92 | sub print_httpd { | ||||||
| 93 | |||||||
| 94 | 0 | 0 | 0 | 0 | 0 | return unless (defined $ENV{'SERVER_SOFTWARE'} && $ENV{'SERVER_SOFTWARE'} =~ /apache/i); | |
| 95 | 0 | my $a = HTML::Perlinfo::Apache->new(); | |||||
| 96 | |||||||
| 97 | 0 | my $html .= print_section("Apache"); | |||||
| 98 | 0 | $html .= print_table_start(); | |||||
| 99 | 0 | 0 | $html .= $a->print_apache() if $a->has(qw(env)); | ||||
| 100 | 0 | $html .= print_table_end(); | |||||
| 101 | |||||||
| 102 | 0 | 0 | $html .= $a->print_modperl() if $a->has(qw(mp)); | ||||
| 103 | |||||||
| 104 | 0 | $html .= print_section("Apache Environment"), | |||||
| 105 | $html .= print_table_start(); | ||||||
| 106 | 0 | 0 | $html .= print_table_header(2, "Variable", "Value"), | ||||
| 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 | 0 | 0 | my $opt = shift; | |||
| 115 | 0 | $m = HTML::Perlinfo::Modules->new(); | |||||
| 116 | 0 | 0 | 0 | if ($opt eq 'core') { | |||
| 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') { | ||||||
| 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 | 0 | 0 | 0 | 0 | my $opt = shift || 'full'; | ||
| 133 | |||||||
| 134 | 0 | my $html = print_box_start(1); | |||||
| 135 | 0 | $html .= sprintf("Perl Version %sRelease date: %s", perl_version(), release_date()); |
|||||
| 136 | |||||||
| 137 | 0 | $html .= print_box_end(); | |||||
| 138 | |||||||
| 139 | 0 | $html .= print_table_start(); | |||||
| 140 | 0 | $html .= print_table_row(2, "Currently running on", "@{[ (uname)[0..4] ]}"); | |||||
| 0 | |||||||
| 141 | 0 | $html .= print_table_row(2, "Built for", "$Config{archname}"); | |||||
| 142 | 0 | $html .= print_table_row(2, "Build date", "$Config{cf_time}"); | |||||
| 143 | 0 | $html .= print_table_row(2, "Perl path", "$^X"); | |||||
| 144 | |||||||
| 145 | 0 | $html .= print_table_row(2, "Additional C Compiler Flags", "$Config{ccflags}"); | |||||
| 146 | 0 | $html .= print_table_row(2, "Optimizer/Debugger Flags", "$Config{optimize}"); | |||||
| 147 | |||||||
| 148 | 0 | 0 | if (defined($ENV{'SERVER_SOFTWARE'})) { | ||||
| 149 | 0 | $html .= print_table_row(2, "Server API", "$ENV{'SERVER_SOFTWARE'}"); | |||||
| 150 | } | ||||||
| 151 | 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 | |||||||
| 152 | 0 | $html .= print_table_row(2, "Thread Support", "enabled (threads)"); | |||||
| 153 | } | ||||||
| 154 | elsif ($Config{useithreads} && !$Config{usethreads} && !$Config{use5005threads}) { | ||||||
| 155 | 0 | $html .= print_table_row(2, "Thread Support", "enabled (ithreads)"); | |||||
| 156 | } | ||||||
| 157 | elsif ($Config{use5005threads} && !$Config{usethreads} && !$Config{useithreads}) { | ||||||
| 158 | 0 | $html .= print_table_row(2, "Thread Support", "enabled (5005threads)"); | |||||
| 159 | } | ||||||
| 160 | elsif ($Config{usethreads} && $Config{useithreads} && !$Config{use5005threads}) { | ||||||
| 161 | 0 | $html .= print_table_row(2, "Thread Support", "enabled (threads, ithreads)"); | |||||
| 162 | } | ||||||
| 163 | elsif ($Config{usethreads} && $Config{use5005threads} && !$Config{useithreads}) { | ||||||
| 164 | 0 | $html .= print_table_row(2, "Thread Support", "enabled (threads, 5005threads)"); | |||||
| 165 | } | ||||||
| 166 | elsif ($Config{useithreads} && $Config{use5005threads} && !$Config{usethreads}) { | ||||||
| 167 | 0 | $html .= print_table_row(2, "Thread Support", "enabled (ithreads, 5005threads)"); | |||||
| 168 | } | ||||||
| 169 | elsif ($Config{usethreads} && $Config{useithreads} && $Config{use5005threads}) { | ||||||
| 170 | 0 | $html .= print_table_row(2, "Thread Support", "enabled (threads, ithreads, 5005threads)"); | |||||
| 171 | } | ||||||
| 172 | else { | ||||||
| 173 | 0 | $html .= print_table_row(2, "Thread Support", "disabled (threads, ithreads, 5005threads)"); | |||||
| 174 | } | ||||||
| 175 | 0 | $html .= print_table_end(); | |||||
| 176 | |||||||
| 177 | 0 | $html .= print_box_start(0); | |||||
| 178 | |||||||
| 179 | |||||||
| 180 | 0 | $html .= "This is perl, v$Config{version} built for $Config{archname} Copyright (c) 1987-@{[ sprintf '%d', (localtime)[5]+1900]}, Larry Wall"; |
|||||
| 0 | |||||||
| 181 | 0 | $html .= print_box_end(); | |||||
| 182 | |||||||
| 183 | 0 | 0 | return $html if $opt eq 'top'; | ||||
| 184 | |||||||
| 185 | 0 | $html .= print_hr(); | |||||
| 186 | 0 | $html .= "Configuration\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 | 0 | if (defined($ENV{'SERVER_SOFTWARE'})) { | ||||
| 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 | 1; | ||||||
| 230 |