#!/usr/bin/perl #!C:\perl\bin\perl.exe =Copyright Infomation ========================================================== Program Name : Mewsoft Search Engine Program Version : 4.00 Program Author : Elsheshtawy, A. A. Home Page : http://www.mewsoft.com Copyrights © 2001-2002 Mewsoft. All rights reserved. ========================================================== =cut #========================================================== print "Content-Type: text/html\n\n"; # Unbuffer Output $| = 1; print &Get_Server_Test; exit 0; #========================================================== sub Get_Sys_OS{ $OS = $^O; if (($OS eq "MSWin32") || ($OS eq "Windows_NT") || ($OS =~ /win/i)) { $OS = "WINNT"; } else { $OS = "UNIX"; } return $OS; } #========================================================== sub Get_Perl_Path{ my ($Out, $Outs); $OS = &Get_Sys_OS; if ($OS =~ m/unix/i) { $Outs=qq!!; $Out=`which perl`; @Path = split(" ", $Out); $Out = join("
", @Path); $Outs.=qq!!; $Out=`whereis perl`; @Path = split(" ", $Out); $Out = join("
", @Path); $Outs.=qq!!; $Out=`which sendmail`; @Path = split(" ", $Out); $Out = join("
", @Path); $Outs.=qq!!; $Out=`whereis sendmail`; @Path = split(" ", $Out); $Out = join("
", @Path); $Outs.=qq!!; $Outs.=qq!
Perl Path (which perl): $Out
\n
Perl Path(whereis perl): $Out
\n
Sendmail Location(which sendmail): $Out
\n
Sendmail Location(whereis sendmail): $Out
\n
!; } else{ $Outs="Windows System, can't detemine perl and sendmail path...!" } return ($Outs); } #========================================================== sub OS_Version{ my ($Out, $OS_Info); $OS = &Get_Sys_OS; if ($OS =~ m/unix/i) { $OS_Info = `uname -a`; } $Out = qq!!; $Out .= qq!\n!; $Out .= qq!!; $Out .=qq!
Perl Version: $]
Server Operating System:$^O: $OS_Info
\n
!; return $Out; } #========================================================== sub SQL_Drivers{ my (@drivers, $Out); eval "use DBI"; if ($@) { return "SQL Drivers: None!!";} $Out = qq!!; @drivers= DBI->available_drivers();# or $Out.="No drivers found!\n
"; foreach my $driver (@drivers) { $Out.=qq!!; #my @dataSources = DBI->data_sources($driver); foreach my $dataSource (@dataSources ) { # $Out.= "\tData Source is $dataSource\n
"; } #$Out.="\n
"; } $Out.=qq!
Driver $driver\nInstalled
!; return $Out; } #========================================================== sub Module_Test { my ($Out, $Module, $Modules, @Modules); @Modules = ( "File::Copy", "DBI", "DBD::mysql", "Cwd", "GD", "Net::SMTP", "LWP::Simple", "LWP::UserAgent", "Archive::Zip", "constant", "Crypt::SSLeay", "Time::Local", "HTML::LinkExtor", "URI::URL", "HTML::Parser", "HTML::Entities", "HTML::HeadParser", "CGI::Carp", "Carp::Heavy", "LWP::UserAgent", "Business::OnlinePayment", "Finance::Quote", "Finance::QuoteHist" ); $Modules = ""; foreach $Module (@Modules) { eval "use $Module;"; ($Name, $Arg) = split (/\s+/, $Module); $Name ||= $Module; if ($@) { $Modules .= qq!$NameNot Installed
\n!; } else{ $Modules .= qq!$NameInstalled
\n!; } } $Out =< $Modules HTML return $Out; } #========================================================== sub Server_Config{ my ($Out, $key, %EN, @EN); @EN= sort keys %ENV; $Out = qq!!; $Out.=qq!!; foreach $key(@EN) { $Out .= qq!!; } $Out .= qq!
VariableValue
$key:$ENV{$key}
!; return $Out; } #========================================================== sub Get_Server_Test{ my ($Out, $Out1, $Out2, $Out3, $Out4, $Modules); $Out1 = &Module_Test; $Out2 = &Server_Config; $Out3 = &OS_Version; $Out4 = &SQL_Drivers; $Out5 = &Get_Perl_Path; $Modules = &Get_Perl_Modules; $Out=< Mewsoft Server Test Tool Operating System and Perl Version $Out3 Perl Path and Sendmail Location $Out5 Required perl modules $Out1 DBI Installed Drivers and Data Sources $Out4 Server Environment Variables $Out2 Installed perl modules $Modules Back to the previous page   Copyright © 2000 Mewsoft. All rights Reserved.   HTML return $Out; } #========================================================== sub Get_Perl_Modules{ my(@Modules, $Rows, $Col, $Table, $x, $y, $Count); @Modules = &Get_Installed_Perl_Modules; @Modules = sort @Modules; $Rows = ""; $Col = 0; $Counter = 0; $Count = @Modules; for $x(0..$Count -1){ if ($Col == 0){$Rows .= qq!!;} if (!$Modules[$x]) {$Modules[$x] = " ";} $Counter ++; $y = $Modules[$x]; $y =~ s/^(\S+::)/\$1\<\/B\>/; $Rows .= qq!$Counter- $y!; $Col++; if ($Col > 2){$Rows .= qq!!; $Col = 0;} } if ($Col >0 && $Col< 3) { for $x($Col..2){ $Rows .= qq! !; } } $Table = qq!$Rows
!; } #========================================================== sub Get_Installed_Perl_Modules{ my(@Modules, $Perl_Include_Dir, @Found, @Temp_Modules); undef @Modules; foreach $Perl_Include_Dir(@INC) { $Perl_Include_Dir =~ s/^\s//g; $Perl_Include_Dir =~ s/\s$//g; if ($Perl_Include_Dir) { @Found = &Scan_Directory($Perl_Include_Dir); @Temp_Modules = &Filter_Perl_Modules(@Found); push @Modules, @Temp_Modules; } } return @Modules; } #========================================================== sub Scan_Directory{ my($Directory)=@_; my(@Files, %Found); %Found = (); @Files = (); my $CRLF = "\015\012"; # how lines should be terminated; "\r\n" is not correct on all systems, for instance MacPerl defines it to "\012\015" %Found = &Scan_Dir($Directory); while (($Key, $Value)= each %Found) { if (!$Value) { push @Files, $Key; } } return @Files; } #========================================================== sub Scan_Dir{ my($Directory)=@_; my(@Directories, @Files, %Found); my($Current_Directory); undef @Directories; undef %Found; undef @Files; if (!$Directory) {$Directory = '.';} push @Directories, $Directory; while (@Directories) { $Current_Directory = shift (@Directories); opendir (DIR, "$Current_Directory") or return undef;# die ("Can't open $Current_Directory: $!"); @Files = readdir (DIR); closedir (DIR); foreach $File (@Files) { $Temp = "$Current_Directory/$File"; if (-d $Temp && $File ne "." && $File ne "..") { push @Directories, $Temp; $Found{$Temp} = 1; next; } else{ if ($File ne "." && $File ne "..") { $Found{$Temp} = 0; } } } } return %Found; } #========================================================== sub Filter_Perl_Modules{ my(@Files)=@_; my(%Modules); foreach $File(@Files){ if ($File =~ m/\.pm$/){ open(FILE, $File) or return undef; while(){ if (/^ *package +(\S+);/){ $Modules{$1}++; last; } } } } return keys %Modules; } #========================================================== #==========================================================