====== Perl stuff ====== Old, probably badly written and not maintained! You have been warned. ===== cgi-bin bits ===== ==== env.pl ==== - Prints out webserver variables available to your script #!/bin/perl - or whatever your path to perl is # env.pl # This script dumps the environment variables in HTML format use strict; use warnings; $|=1; print "Content-type:text/html\n\n"; foreach my $var (sort keys %ENV) { print $var . "=" . $ENV{$var} . "
\n"; }
==== about.pl ==== #!/usr/sbin/perl use strict; use warnings; $now = localtime ; print "Content-type: text/html", "\n\n"; print "", "\n"; print "About this server", "\n"; print "

About this server

", "\n"; print "
";

print "Today is                 ", $now, "
", "\n"; print "Server Name: ", $ENV{'SERVER_NAME'}, "
", "\n"; print "Running on Port: ", $ENV{'SERVER_PORT'}, "
", "\n"; print "Server Software: ", $ENV{'SERVER_SOFTWARE'}, "
", "\n"; print "Server Protocol: ", $ENV{'SERVER_PROTOCOL'}, "
", "\n"; print "CGI Revision: ", $ENV{'GATEWAY_INTERFACE'}, "
", "\n\n"; print "You are ", $ENV{'REMOTE_ADDR'}, "
", "\n"; print "Your machine is ", $ENV{REMOTE_HOST}, "
", "\n"; print "
", "\n"; print "", "\n"; exit (0)
==== my-ip.pl ==== #!/usr/bin/perl #developed from original script by Andrew Stringer 09/10/2002 onwards. use strict; use warnings; #Set to ip passed from apache or if undefined, use Google. my $remotehost=$ENV{'REMOTE_ADDR'} || '8.8.8.8'; my $ENVIRO=`env` ; print "Content-type:text/html\n\n"; print < My ip Your ipaddress is:- $remotehost

ENDOFTEXT1 #print $ENVIRO ; my @traceroute=`/usr/bin/tcptraceroute $remotehost`; print "@traceroute \n"; # Again, you can print (or do whatever with) the answer: my $i; foreach $i (@traceroute) { # Here you can print or analize each line of the answer print "$i\n
"; } print < ENDOFTEXT2 exit (0);
==== convert2html.pl ==== Convert to HTML #!/usr/bin/perl #written by Andrew Stringer 30-04-2006 #this is intended to be run from an ssi:- # #it takes an html file or xml file and converts the < to < etc. and #prints to stdout enclosed in a
 
tag. This allows code listings #to appear in web pages correctly formatted. use warnings; use strict; MAIN: { my $line; #set prefix to path to webroot my $prefix = '/data/rainsbrook/http'; my $query = $ENV{'QUERY_STRING'} ; my $debug = '0' ; #remove double dots (..) to prevent file system traversal #Only naughty boys would want to do this, should not affect normal users. $query =~ s/\.\.//g; $query =~ s/\/\//\//g; #only allow files below the webroot to be readout my $url = "$prefix/$query" ; open (FILE, "$url"); print "Content-type: text/html\n\n" ; if($debug){ print "ENV{'QUERY_STRING'} is $query \n
\n" ; print "URL is $url \n"; } print "
\n";

while ($line = ) 
	{
#use /g to catch all occurances on each line
	$line =~ s/\/\>\;/g;

	print $line;
	}
print "
\n"; } exit(0);