status.cgi -- others


#!/usr/bin/perl -TwI/home/drf5n/public_html/cgi-bin #use strict; use CGI qw(:standard); use CGI::Carp 'fatalsToBrowser'; $CGI::POST_MAX=1024 * 100; # max 100K posts $CGI::DISABLE_UPLOADS = 1; # no uploads # http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html if( $CGI::DISABLE_UPLOADS || $CGI::POST_MAX) {;} # 1999-07-12 15:56:36 my ( $Boiler_Plate, $junk, $choice, $This_Script,$Log_Dir, $Script_Name, ); #System Environment $ENV{'ENV'} =""; $ENV{'TERM'} = "vt100"; $ENV{'PATH'}="/bin:/usr/bin:/usr/local/bin"; $Script_Name="status.cgi"; $This_Script="/~drf5n/cgi-bin/$Script_Name"; $Log_Dir="/var/adm"; $choice = param('choice') || "2.1"; $Boiler_Plate= qq! <a href="/">Top of Server</a> | <a href="/~drf5n">drf5n</a> | <a href="">/~drf5n/cgi-bin</a> | <br>Status of: <a href="http://www.people.virginia.edu/~drf5n/cgi-bin/status.pl" >www.people.virginia.edu</a> | <a href="http://freney.sys.virginia.edu/cgi-bin/Secret/status.pl" >freney.sys.virginia.edu</a> | <a href="validate.cgi">validate</a><br> <a href="$This_Script?choice=9">Environment</a> <br> <a href="$This_Script?choice=2">httpd logs</a>, <a href="$This_Script?choice=2.1">error_log</a>, <a href="$This_Script?choice=2.2">access_log</a>, <a href="$This_Script?choice=2.3">referer_log</a><br> <a href="$This_Script?choice=4">Apache conf</a>, <a href="$This_Script?choice=4.1">srm.conf</a>, <a href="$This_Script?choice=4.2">httpd.conf</a>, <a href="$This_Script?choice=4.3">access.conf</a>, <a href="http://www.apache.org/docs/">Documentation</a><br> <a href="$This_Script?choice=5">ps -eaf|grep drf5n</a>, <br> <a href="lister.cgi?file=status.cgi">my source code</a>, <a href="$This_Script?choice=6.1">cgi-lib.pl</a>, <a href="man.cgi?name=CGI.pm;type=perl">CGI.pm</a>, <a href="$This_Script?choice=6.2">wang_lib.pl</a><br> <a href="$This_Script?choice=7">ps -eaf</a><br> <hr> !; print header, qq%<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">%; print start_html( self_url ); print $Boiler_Plate; if($choice==9) { print &PrintEnv; ;} elsif($choice==1) { print CGI::dump(); } elsif($choice==2) { $junk = `ls -la $Log_Dir/`; print "<pre>$junk</pre>\n"; } elsif($choice==2.1) { $_ = `/usr/bin/tail -200 $Log_Dir/error_log `; $_ = (join("\n", reverse (split '\n'))); $_ = &Html_Escape("$_"); print "<pre>$_</pre>\n"; } elsif($choice==2.2) { $_ = `/usr/bin/tail -200 $Log_Dir/access_log`; $_ = (join("\n", reverse (split '\n'))); $_ = &Html_Escape("$_"); print "<pre>$_</pre>\n"; } elsif($choice==3) { $junk = `ls -la /var/adm/`; print "<pre>$junk</pre>\n"; } elsif($choice==5) { $junk = `ps -eaf|grep drf5n`; $junk= &Html_Escape($junk); print "<pre>$junk</pre>\n"; } elsif($choice==6) { $junk = `cat $Script_Name`; $junk= &Html_Escape($junk); print "<pre>$junk</pre>\n"; } elsif($choice==4) { $junk = `ls -la /var/lib/apache/conf`; print "<pre>$junk</pre>\n"; } elsif($choice==4.1) { $junk = `cat /var/lib/apache/conf/srm.conf`; $junk= &Html_Escape($junk); print "<pre>$junk</pre>\n"; } elsif($choice==4.2) { $junk = `/bin/cat /var/lib/apache/conf/httpd.conf`; $junk= &Html_Escape($junk); print "<pre>$junk</pre>\n"; } elsif($choice==4.3) { $junk = `cat /var/lib/apache/conf/access.conf`; $junk= &Html_Escape($junk); print "<pre>$junk</pre>\n"; } elsif($choice==7) { $junk = `ps -eaf`; $junk= &Html_Escape($junk); print "<pre>$junk</pre>\n"; } else { print qq! <pre> choice=2 prints the environment variables otherwise this prints this page <pre>! ;} print end_html; #---------------------------------------- #usage # $Html_String=&Html_Escape("unescaped text") # drf5n 1/19/98 sub Html_Escape { my ($instring)= @_; $instring =~ s/&/&amp;/gm; # HTML Escape character $instring =~ s/</&lt;/gm; # HTML Markup Tags $instring =~ s/>/&gt;/gm; # HTML Markup Tags return ($instring); } #---------------------------------------- # PrintVariables # Nicely formats variables. Three calling options: # A non-null associative array - prints the items in that array # A type-glob - prints the items in the associated assoc array # nothing - defaults to use %in # Typical use: &PrintVariables() sub PrintVariables { local (*in) = @_ if @_ == 1; local (%in) = @_ if @_ > 1; local ($out, $key, $output); $output = "\n<dl compact>\n"; foreach $key (sort keys(%in)) { foreach (split("\0", $in{$key})) { ($out = $_) =~ s/\n/<br>\n/g; $output .= "<dt><b>$key</b>\n <dd>:<i>$out</i>:<br>\n"; } } $output .= "</dl>\n"; return $output; } # PrintEnv # Nicely formats all environment variables and returns HTML string sub PrintEnv { &PrintVariables(*ENV); } 1;