#!/usr/bin/perl use CGI qw/:standard/; $width=int(200+rand(200)); $height=int(200+rand(200)); $num=int(rand(10000)); $data=param('me'); open HFH,"state/$ENV{'REMOTE_ADDR'}.keywords"; @hfh=; close HFH; $hfhThen=$#hfh; if ($data ne undef) { # Find all plaintext files in the datastore (no dirs) @textfiles = `find bank -type f | grep .txt`; @bankfiles = `find bank -type f | grep -v .txt`; for (@textfiles) { chomp } for (@bankfiles) { chomp } for (@textfiles) { $clean=$_; $clean=~s/\.(.*)$//; # Remove extensions $clean=~s/^(.*)\///; # Remove paths if ($data =~ /$clean/i) { push @textreplies,$_; open FH,">>state/$ENV{'REMOTE_ADDR'}.keywords"; print FH "$clean\n"; close FH; } } for (@bankfiles) { $clean=$_; $clean=~s/\.(.*)$//; # Remove extensions $clean=~s/^(.*)\///; # Remove paths if ($data =~ /$clean/i) { push @bankreplies,$_; open FH,">>state/$ENV{'REMOTE_ADDR'}.keywords"; print FH "$clean\n"; close FH; } } `sort < state/$ENV{'REMOTE_ADDR'}.keywords | uniq > state/$ENV{'REMOTE_ADDR'}.keywords`; if ($#textreplies >= 0) { $textchosen=$textreplies[rand(@textreplies)]; open FH,"$textchosen"; $quote=join('',); close FH; } else { if (-e "state/$ENV{'REMOTE_ADDR'}.keywords") { @history=`sort < state/$ENV{'REMOTE_ADDR'}.keywords | uniq`; $textchosen=$history[rand(@history)]; chomp($textchosen); @quotes=( 'Excuse me', 'Ah, I\'d forgotton all about this.', 'Changing the subject slightly, what do you think about education?', 'Changing the subject slightly, what do you think about politics?', 'Changing the subject slightly, what do you think about families?', 'Changing the subject slightly, what do you think about health issues?', 'Changing the subject slightly, what do you think about art?', 'Changing the subject slightly, what do you think about popular culture?', 'Changing the subject slightly, what do you think about %!%?' ); $quote=$quotes[rand(@quotes)]; $quote=~s/%!%/$textchosen/gi; } else { $quote="I have nothing to say on this."; } } } else { $quote="Hello."; } if ($#bankreplies >= 0) { $bankchosen=$bankreplies[rand(@bankreplies)]; $bankclean=$bankchosen; $bankclean=~s/\.(.*)$//; # Remove extensions $bankclean=~s/^(.*)\///; # Remove paths if ($bankchosen=~/\.url$/i) { open FH,"$bankchosen"; $bankchosen=; chomp($bankchosen); close FH; } if ($bankchosen =~ /\.mp3/) { $height=100; } if ($bankchosen =~ /\.mov/) { $width=160; $height=120 + 24; # 24 is height of top frame } $js=" "; open HFH,"state/$ENV{'REMOTE_ADDR'}.keywords"; @hfh=; close HFH; $hfhNow=$#hfh; if ( (($hfhNow > 3) && ($hfhThen < 4)) || (($hfhNow > 3) && (rand(150)<10)) ) { # History is at 3 keywords, fire up the montage $js=" "; } } print < AUTOICON $js
donald.rodney:autoicon

$quote

EOHTML