This page displays its source

The page may change at random since this is my site for testing new things
It is now 11:49:59 AM

::



You gave me 0 parameter(s):


Back Home

Source Code thing.cgi:

#!/usr/bin/perl -wT

#use LWP::Simple;

# Programmed by Andrew Brenner 8/7/2004 - 8/14/2004 (c)

@t = localtime(time);
$am_pm = "AM";
if ($t[2] >= 12) {   $am_pm = "PM";}
if ($t[2] > 12)  {   $t[2] -= 12;  }
if ($t[2] == 0)  {   $t[2] = 12;   }
$time = sprintf("%01d:%02d:%02d $am_pm", $t[2],$t[1],$t[0]);   #time formatting

$len = $ENV{'CONTENT_LENGTH'};
$params = <>;
#   s/</&lt;/g;   s/>/&gt;/g;      # Make sure user can't embed html code
#   s/(%20|\+)/&nbsp;/g;

@args = split /&/, $params;#$ENV{'QUERY_STRING'}; #$ARGV[0];
#@args = `head -n 1`;   # Post ??? - unnecessary

$web_path = $ENV{PATH_INFO};
$web_path =~ s/\/(.*?)\/.*/$1/;

$params =~ s/&/&amp;/g;

print "Content-type:text/html\nCache-control: no-cache\n\n";   # HTTP Header information
print <<TOPstuff;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Things that Happen</title>
<link rel="stylesheet" href="../stylesheet.css" type="text/css" />
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
</head>
<body onload="sf()">
<script type="text/javascript">function sf(){document.myform.text1.focus();}</script>
<h1>This page displays its source</h1>
<h6>The page may change at <span style="text-decoration: blink">random</span> since this is my site for testing new things</h6>
It is now $time<br />
$web_path<br />
$len :: $params<br /><br />
<table><tr><td align="center">
<form name="myform" method="post" action="thing.cgi">
   <input type="submit" value="Go" /><input type="reset" value="Wipe it!" /><input type="submit" name="submit" value="New" /><br />
TOPstuff

foreach my $i (0 .. $#args)  #(@args)
{
   while ($args[$i] =~ m/%(..)/)
   {
      $hexcode = hex($1);               #change hex code to decimal
      $args[$i] =~ s/%../&#$hexcode;/;   #put html code
   }
   $args[$i] =~ s/</&lt;/g;   $args[$i] =~ s/>/&gt;/g;      # Make sure user can't embed html code
   $args[$i] =~ s/\+/&nbsp;/g;
   ($name,$value) = split /=/, $args[$i];
   if ($name =~ s/submit/text$i/) {$value="";}
   print "$name<input type=\"text\" name=\"text$i\" size=\"35\" value=\"$value\" /><br />\n";
}

print <<TOPstuff2;
   <input type="submit" value="Go" /><input type="reset" value="Wipe it!" /><input type="submit" name="submit" value="New" />
</form>

<form method="post" action="thing.cgi"><input type="submit" value="Reset" /></form>
</td>
<td width="20%"></td>
<td>
TOPstuff2

print "<hr />You gave me " . @args . " parameter(s):<br />\n<table><tr><td colspan=\"2\"><hr /></td></tr>\n";
foreach (@args)
{
   ($name,$value) = split /=/;
   print "<tr><td><b>Name:</b> $name</td><td><b>Value:</b> $value</td></tr>\n";
}
print "<tr><td colspan=\"2\"><hr /></td></tr></table>\n";

print <<TOPstuff3;
</td></tr></table>
<small><a href="..">Back Home</a></small><br /><hr />
TOPstuff3

$0 =~ s/.*\///;   # Take full file location and strip to just filename
print "<h2>Source Code $0:</h2>\n<code><small>\n";
open(FILE,$0);
$_ = do { local $/; <FILE>};      # Slurp the file
s/&/&amp;/g;
s/</&lt;/g;
s/>/&gt;/g;
s/\t/   /g;
s/ /&nbsp;/g;
s/\n/<br \/>/g;   
print;

print "\n</small></code>\n</body>\n</html>";