#! /usr/skunk/bin/perl
# PERL script
# Searches the gifs directory for keywords.

$HTDOCS="/usr/skunk/pics/gif/";
$GIFDIR="buttons";
$QUERY_STRING= $ENV{'QUERY_STRING'};
print "Content-type: text/html\n\n";

if ($QUERY_STRING) {
	print "<HEAD>\n";
	print "<TITLE>Find GIF \"$QUERY_STRING\"</TITLE>\n";
	print "</HEAD>\n";
	print "<BODY>\n";
	print "<H1>Find GIF \"$QUERY_STRING\"</H1>\n";

	print "<UL>\n";
	open(DIR, "ls $HTDOCS$GIFDIR/*.gif |");
	while (<DIR>) {
		if (/$QUERY_STRING/i) {
			($NAME) = m|$GIFDIR/(.*)|;
			print "<LI> $HTDOCS/$GIFDIR/$NAME\n" ;
			print "<IMG SRC=\"file:$HTDOCS/$GIFDIR/$NAME\">\n";
			print "<P>\n";
		}
	}
	print "</UL>\n";
	print "<HR>\n";
} 
else {
	print <<EOM;
<HEAD>
<TITLE>Find GIF</TITLE>
</HEAD>
<BODY>
<H1>Find GIF</H1>
EOM
}
print <<EOM;
Enter a keyword to search the gif directory for.
Some sample keywords are:
<UL>
<LI> Icon
<LI> Calvin
<LI> Eye
</UL>
<ISINDEX>
<A HREF="http://www.stanford.edu/">
<IMG SRC="file:/usr/skunk/pics/gif/buttons/stanford.seal56.gif" ALT="Stanford"></A>

<A HREF="http://www-cs.stanford.edu/">
<IMG SRC="file:/usr/skunk/pics/gif/buttons/logo.csd.gif" ALT="CS dept"></A>

<A HREF="http://www-pcd.stanford.edu/">
<IMG SRC="file:/usr/skunk/pics/gif/buttons/logo.pcd.gif" ALT="PCD grp"></A>

<A HREF="file:/usr/skunk/pics/gif/buttons/">
<IMG SRC="file:/usr/skunk/pics/gif/buttons/painting.gif" ALT="Pictures"></A>
<HR>

</BODY>
EOM


exit;
