#!/usr/bin/perl use strict; use CGI qw( param header ); sub image { # Give it a word, it gives you an image! use LWP::UserAgent; my $word = shift; my $ua = LWP::UserAgent->new; $ua->agent('Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/2525010 +1'); my $request = HTTP::Request->new('GET','http://images.google.com/i +mages?hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&q=' . $word); my $response = $ua->request($request); my $data = $response->content; my @urls = ($data =~ m/\?imgurl=(.*?)&/g); my $url = $urls[rand @urls]; $url = 'http://' . $url; } print header; my $word = param("word"); $word =~ s/<(.*?)>//g; $word =~ s/\+//g; !($word =~ / /) || die "ONE WORD ONLY"; if ($word) { print <<HEAD; <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" +> <title>The Stream</title> <head> <body text="#ffffff" bgcolor="#000000" link="#ffffff" alink="#ffffff" +vlink="#ffffff"> <center><font size=+8>The Stream</font><center> <hr size=1 width=35%> HEAD my $ip = $ENV{"REMOTE_ADDR"}; open(RLASTIP,"lastip") || die "File Open Failed: $!"; my $lastip = <RLASTIP>; close(RLASTIP); if (!($ip eq $lastip)) { my $url = image($word); open(WLIST,">>list"); print WLIST "$word $url\n"; close WLIST; open(WLASTIP,">lastip") || die "File Open Failed: $!"; print WLASTIP "$ip"; close(WLASTIP); } else { print "<script>alert(\"Your association was not added because you +did the last one. You cannot respond to your own.\\n Try again later +when someone has responded to your thought.\");</script>"; } open(RLIST,"list"); my @list = <RLIST>; close(RLIST); foreach $_(@list) { my ($link,$linkurl); ($link,$linkurl) = split(" ", $_); print "<center><A HREF=\"$linkurl\">$link</A></center>"; } print "<hr size=1 width=35%>\n</body>\n</html>"; } else { open(RLIST,"list") || die "File Open Failed: $!";; my $lastline; $lastline = $_ while <RLIST>; close(RLIST); my ($lastword,$lasturl); ($lastword,$lasturl) = split(" ", $lastline); print <<MONKEY; <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" +> <title>Stream of Consciousness</title> <head> <body text="#ffffff" bgcolor="#000000" link="#ffffff" alink="#ffffff" +vlink="#ffffff6"> <center><font size=+8>Stream of Consciousness</font><center> <hr size=1 width=55%> <br> <center><img src="$lasturl"><center> <center><font size=+5>$lastword</font></center> <center> <hr size=1 width=55%> <br> <b>Enter The First Word That Comes To Mind</b> <form method="post" action="stream.cgi"> <center><input type="text" name="word" style="background:#000000; colo +r:#ffffff"></center> <br> <center><input type="Submit" name="submit" value="submit" class="butto +n" style="background:#000000; color:#ffffff"></center> </form> </center> </body> </html> MONKEY }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Stream of Consciousness
by gjb (Vicar) on Jun 28, 2003 at 20:06 UTC | |
by beretboy (Chaplain) on Jun 29, 2003 at 17:37 UTC | |
by gjb (Vicar) on Jun 29, 2003 at 18:38 UTC | |
by chunlou (Curate) on Jun 29, 2003 at 19:02 UTC | |
by chunlou (Curate) on Jun 29, 2003 at 18:02 UTC | |
|
Re: Stream of Consciousness
by chunlou (Curate) on Jun 29, 2003 at 17:07 UTC | |
|
Re: Stream of Consciousness
by diotalevi (Canon) on Jun 28, 2003 at 13:16 UTC | |
|
Re: Stream of Consciousness
by beretboy (Chaplain) on Jun 30, 2003 at 01:21 UTC | |
|
Re: Stream of Consciousness
by John M. Dlugosz (Monsignor) on Jul 11, 2003 at 16:24 UTC |