#!/usr/bin/perl 
# data.cgi 
# Feb 17, 2011


use CGI  qw(:standard) ;
my $q = CGI-> new ;
# process form variables.
$name = $q -> param('name') ;

print $q -> header("Aldham's Dynamic Page Generation") ;
print "<H1> Danny's Dynamic Page ",$pick,"</H1> ";
#print "Hello :  @ENV \n";
 
#print "at INC is @INC \n";
srand(time|$$) ;
$pick = int(rand(9999) +1) ;

# Create 5 fields, choose 4, and put them up in random order.
#print " Hello ", $ENV{REMOTE_HOST}, "<BR>You are using", $ENV{HTTP_USER_AGENT} ;
#print "<P> Environment", %ENV ;

&intro ;
# Fortune cookie.
&fortune ;
&gif ;

print "<P> To try that again: " ;
print "<A HREF=http://www.aldham.net/aldham/dyna.pl>Again! </A><BR> " ;
print "<A HREF=http://www.aldham.net/aldham/dyna.cgi>Download cgi code </A><BR> " ;


sub fortune {
        print "<P>fortune cookie :" ;
        srand(time|$$) ;
        $roll = int(rand(7) + 1) ;
        print "Rolled ", $roll,"\n" ;

        if ("$roll" eq 1) {
        print "<BR> There is no secret to success. It is the result of preparation, hard work, learning from failure.- Gen. Colin L. Powell " ;
} elsif ("$roll" eq 2) {
                print "<BR> If you want to truly understand something, try to change it.- Kurt Lewin ";
} elsif ("$roll" eq 3 ) {
                print "<BR> If you haven't any charity in your heart, you have the worst kind of heart trouble.- Bob Hope" ;
} elsif ("$roll" eq 4) {
        print "<BR> When patterns are broken, new worlds can emerge.- Tuli Kupferberg ";
} elsif ("$roll" eq 5) {
        print "<BR> The worst prison would be a closed heart.- Pope John Paul II ";
} elsif ("$roll" eq 6) {
        print "<BR> Keep your stick on the ice.- Red Green";
} elsif ("$roll" eq 7) {
        print "<BR> Square meals often make round people.- E.Joseph Cossman ";
}
 

}


# Fortune cookie.
#&fortune ;

sub gif {
	srand(time^$$) ;
	$pick = int(rand(11) +1) ;
#	print "\n<P>Picked gif number $pick \n";
	%gif = ("1","garfield.gif","2","critic.gif","3","surfer.gif","4","malefemale.gif","5","dogbert.gif","6","simp.bart.gif","7","robotman.gif","8","opus.gif","9","icon.hobbes.gif","10","simp.boss.gif","11","airkeyboard.gif") ;
	print "<P><IMG SRC=http:$gif{$pick}>" ;
	#print "GIF Image here!!!" ;

}
sub intro {

	srand(time^$$) ;
	$pick = int(rand(2) +1) ;
	if ("$pick" eq 1) {
	print "\n Hello your IP is :", @ENV , $ENV{REMOTE_ADDR} ;
	} else { print  "<BR>You are using", $ENV{HTTP_USER_AGENT},"\n" ;
	}

}

