#!/usr/local/bin/perl # this doodad works with another script to create interactive hyperfiction # the other script--submobius.cgi--writes out the submit page that this script processes # this script takes the submission, writes it out as an html file and creates links for it in the hypertext # feel free to use of modify this script # though I can't see why anyone in their right mind would want to # this version is constructed for use with frames # thanks to Joey Slaughter for the original # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs){ ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } $theme = $FORM{'theme'}; $htmlname = "$FORM{'title'}.html"; &checkinput; #if (-e #"/usr/local/home/daniel/public_html/hyperwriting/becoming/$theme/$htmlname") { # &bail("file already exists, please rename your file"); # } open (FILE, ">/usr/local/home/daniel/public_html/hyperwriting/becoming/$theme/$htmlname") || print "couldn't open file\n\n"; print FILE "$FORM{'title'}\n"; print FILE "Episode: $FORM{'title'}\n"; print FILE "

Author: $FORM{'name'}

\n"; print FILE "
$FORM{'comment'}

\n"; #do the options for the first link if ($FORM{'linktheme1'} ne "") { print FILE "

Related Events:

\n"; print FILE "$FORM{'linktitle1a'}

\n"; if ($FORM{'linktitle1b'} ne "") { print FILE "$FORM{'linktitle1b'}

\n"; } if ($FORM{'linktitle1c'} ne "") { print FILE "$FORM{'linktitle1c'}

\n"; } if ($FORM{'linktitle1d'} ne "") { print FILE "$FORM{'linktitle1d'}

\n"; } } #do the options for the second link if ($FORM{'linktheme2'} ne "") { print FILE "$FORM{'linktitle2a'}

\n"; if ($FORM{'linktitle2b'} ne "") { print FILE "$FORM{'linktitle2b'}

\n"; } if ($FORM{'linktitle2c'} ne "") { print FILE "$FORM{'linktitle2c'}

\n"; } if ($FORM{'linktitle2d'} ne "") { print FILE "$FORM{'linktitle2d'}

\n"; } } #do the options for the third link if ($FORM{'linktheme3'} ne "") { print FILE "$FORM{'linktitle3a'}

\n"; if ($FORM{'linktitle3b'} ne "") { print FILE "$FORM{'linktitle3b'}

\n"; } if ($FORM{'linktitle3c'} ne "") { print FILE "$FORM{'linktitle3c'}

\n"; } if ($FORM{'linktitle3d'} ne "") { print FILE "$FORM{'linktitle3d'}

\n"; } } close FILE; #writes index entry opendir (NDIR, "/usr/local/home/daniel/public_html/hyperwriting/becoming/$theme"); open (DIRFILE, ">/usr/local/home/daniel/public_html/hyperwriting/becoming/$theme/moment.html"); print DIRFILE "$FORM{'theme'} timeline\n"; print DIRFILE "\n"; print DIRFILE "
\n"; print DIRFILE "$FORM{'theme'}

\n"; foreach $match (sort readdir (NDIR)) { if ($match ne ".") { if ($match ne "..") { if ($match ne "moment.html") { if ($match ne "index.html") { if ($match ne "upper.html") { if ($match ne "right.html") { if ($match ne "menu.html") { print DIRFILE "$match
\n"; } } } } } } } } print DIRFILE "

\n"; close DIRFILE; print "Location: http://www.cwrl.utexas.edu/~daniel/hyperwriting/becoming/$theme\n\n"; # make sure all required fields are filled in. sub checkinput { if ($FORM{'comment'} eq "") { &bail("

Did not submit because the body of the message was empty.

"); } if ($FORM{'name'} eq "") { &bail("

Did not submit because no name was given.

"); } if ($FORM{'title'} eq "") { &bail("

Did not submit because no episode was given.

"); } } sub bail { print "Content-type: text/html\n\n"; print "Processing Error:\n"; print "\n"; print @_; exit(1); } #end of program