#!/usr/bin/perl

################################################################
# METANET GmbH, Switzerland
# Perl Info Linux Server 
################################################################

################################################################
#                PLEASE DO NOT MODIFY               #

$sendmail       =`whereis sendmail`;$plocation  =`whereis perl`;@perlloc = split(" ",$plocation);@mailloc = split(" ",$sendmail);$font = '<FONT FACE="Verdana, sans serif" SIZE=2>';&vars;print "Content-type:  text/html\n\n";print qq~<HTML><HEAD><TITLE>METANET: Perl Umgebungs-Informationen</TITLE></HEAD><LINK REL="stylesheet" HREF="http://www.scriptsolutions.com/images/style.css" TYPE="text/css"><body bgcolor="#FFFFFF" ALINK="#FDB900" LINK="#BF0425" VLINK="#1200FD" TOPMARGIN=0 LEFTMARGIN=0 RIGHTMARGIN=0><TABLE WIDTH=100% BGCOLOR=black CELLPADDING=2 CELLSPACING=0 BORDER=0 BACKGROUND="white"><TR> <TH>&nbsp;<BR>&nbsp;</TD> <img src="http://metanet.ch/meta_white.gif">  </TR></TABLE><P ALIGN=CENTER><FONT FACE="Verdana,Arial" SIZE=3 COLOR="black"><B><BR><FONT SIZE=6>Perl Infos</FONT></FONT></P></B><P><DIV ALIGN=CENTER><TABLE WIDTH=100% BGCOLOR="silver" CELLPADDING=2 CELLSPACING=0 BORDER=0><TR><TH>$font<FONT SIZE=4>Server Pfade</FONT></TD></TR></TABLE><P><TABLE BORDER=0 CELLPADDING=3 WIDTH=95%>    <TR><TD BGCOLOR="$bgcolor" WIDTH=35%>${font}<B>Perl Executable:</B></TD>            <TD WIDTH=65%>${font}$^X</TD></TR>      <TR><TD BGCOLOR="$bgcolor">${font}<B>Perl Version:</B></TD><TD>${font}$]</TD></TR> <TR><TD BGCOLOR="$bgcolor">${font}<B>Betriebssystem:</B></TD>           <TD>${font}$^O</TD></TR>        <TR><TD BGCOLOR="$bgcolor">${font}<B>GID</B></TD>           <TD>${font}$<</TD></TR> <TR><TD VALIGN=TOP BGCOLOR="$bgcolor">${font}<B>Location of Perl:</B></TD>          <TD>${font}~;foreach $loc(@perlloc){    print "$loc<BR>\n";}            print qq~</TD></TR>     <TR><TD VALIGN=TOP BGCOLOR="$bgcolor">${font}<B>Location of Sendmail:</B></TD>              <TD>${font}~;foreach $ml(@mailloc){     print "$ml<BR>\n";}         print qq~</TD></TR>     <TR><TD VALIGN=TOP BGCOLOR="$bgcolor">${font} <B>Directory locations searched for perl executables</B></TD><TD>$font~;foreach $item(@INC){  print "$item <BR>\n";}  print qq~</TD></TR></TABLE><P><TABLE WIDTH=100% BGCOLOR="silver" CELLPADDING=2 CELLSPACING=0 BORDER=0><TR><TH>$font<FONT SIZE=4>Umgebungsvariablen</FONT></TD></TR></TABLE><P><TABLE BORDER=0 CELLPADDING=3 WIDTH=95%>~;foreach $fieldname(keys %ENV){  print qq~       <TR><TD BGCOLOR="$bgcolor" WIDTH=35%><B>${font}$fieldname</B></TD>          <TD WIDTH=65%>${font}$ENV{$fieldname}</TD></TR>~;}      print qq~</TABLE><P><TABLE WIDTH=100% BGCOLOR="silver" CELLPADDING=2 CELLSPACING=0 BORDER=0><TR><TH>$font<FONT SIZE=4>Installierte Module</FONT></TD></TR></TABLE><P><TABLE BORDER=0 CELLPADDING=3 WIDTH=100%>~;find(\&wanted,@INC);$modcount = 0;foreach $line(@foundmods){            $match = lc($line);             if ($found{$line}[0] >0)    {$found{$line} = [$found{$line}[0]+1,$match]}           else                            {$found{$line} = ["1",$match];$modcount++}}@foundmods = sort count keys(%found);sub count {return $found{$a}[1] cmp $found{$b}[1]}$third = $modcount/3;$count=0;print "<TR><TD WIDTH=33% VALIGN=TOP><TABLE BORDER=0 CELLPADDING=1>";foreach $mod(@foundmods){   chomp $mod;     $count++;if ($count <= $third){                  print qq~<TR><TD>${font}$mod</TD></TR>~;        }       else {push (@mod1,$mod)}}print "</TABLE></TD><TD WIDTH=33% VALIGN=TOP><TABLE BORDER=0 CELLPADDING=1>";$count = 0;foreach $mod1(@mod1){      chomp $mod1;    $count++;if ($count <= $third){                  print qq~<TR><TD>${font}$mod1</TD></TR>~;       }       else {push (@mod2,$mod1)}}print "</TABLE></TD><TD WIDTH=33% VALIGN=TOP><TABLE BORDER=0 CELLPADDING=1>";$count = 0;foreach $mod2(@mod2){     chomp $mod2;    $count++;if ($count <= $third){                  print qq~<TR><TD>${font}$mod2</TD></TR>~;       }}print qq~</TABLE></TD></TR></TABLE><P><HR COLOR="#efefef" SIZE=1><P>${font}<TABLE WIDTH=100% BGCOLOR=#0000a0 CELLPADDING=2 CELLSPACING=0 BORDER=0 BACKGROUND="white"><TR><TH ALIGN=RIGHT>&nbsp;<BR>&nbsp;</TD></TR></TABLE></BODY></HTML>~;exit;sub vars {$dev="METANET";use File::Find;$bgcolor = "#efefef";$program="perl diver";$version="1.1";}sub wanted {   $count = 0;     if ($File::Find::name =~ /\.pm$/){              open(MODFILE,$File::Find::name) || return;          while(<MODFILE>){                       if (/^ *package +(\S+);/){                              push (@foundmods, $1);                              last;                   }               }       }}
