home *** CD-ROM | disk | FTP | other *** search
- -==-start www_pl-==-
-
- #
- # www_pl - perl subroutines for use w/WWW development
- #
- # by: Eric Hall
- # date: 8/11/94
- #
- # desc: this file contains many useful and reusable subroutines
- # included are GENFOOT (generates standard footer, printing
- # it to a file), PRNFOOT (ditto but prints to stdout)
- # GENHEAD (generates header and recognition), etc.
- #
- # Enjoy,
- # --eric hall
- # --ehall1@duck.ford.com
- # --hallway@ais.org
-
-
- #used for alphabetical sorts
- sub alpha { $a cmp $b; }
-
-
- #parses the standard input (STDIN) and generates
- #an associative array called %FORM w/the key=input box name
- #and value=what user typed into input box
- sub PARSEFORM {
-
- local($name,$value,$pair,$buffer,@pairs,%FORM);
-
- #this should be done first
- #unshift(@INC,'/usr/local/etc/httpd/cgi-bin');
-
- # Get the input
- read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
-
- # Split the name-value pairs
- @pairs = split(/&/, $buffer);
-
- # Uncommend for debugging purposes
- #print "Content-type: text/html\n\n";
-
- foreach $pair (@pairs)
- {
- ($name, $value) = split(/=/, $pair);
-
- # Un-Webify plus signs and %-encoding
- $value =~ tr/+/ /;
- $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
-
- #want to skip submissions of default values
- next if (grep(/\?\?\?\?\?/,$value));
-
- # Stop people from using subshells to execute commands
- # Not a big deal when using sendmail, but very important
- # when using UCB mail (aka mailx).
- $value =~ s/~!/ ~!/g;
-
- # Uncomment for debugging purposes
- #print "Setting $name to $value<P>";
-
- $FORM{$name} = $value;
- }
-
- return (%FORM);
-
- } #end sub PARSEFORM
-
-
- #generates footer to file
- sub PRNFOOT2 {
-
- local($url,$to) = @_;
-
- print "\n";
- print "<HR>\n";
- print "<!<h5>\n";
- print "<a href=\"http://$url\">\n";
- print "<img src=\"http://www.ais.org/~hallway/icons/smalleft.gif\">\n";
- print "Return to $to</i></a>\n";
- print "<!</h5>\n";
- print "\n";
- print "\n";
- print "</html>\n";
- print "</body>\n";
-
- } #end sub PRNFOOT
-
-
- #generates footer to file
- sub PRNFOOT {
-
- local($url,$to) = @_;
-
- print "\n";
- print "<HR>\n";
- print "<!<h5>\n";
- print "Click <b>BACK</b> button or arrow to return.\n";
- print "<!</h5>\n";
- print "\n";
- print "</html>\n";
- print "</body>\n";
-
- } #end sub PRNFOOT
-
-
- #generates footer to file
- sub GENFOOT2 {
-
- local(*FILE,$url,$to) = @_;
-
- print FILE "\n";
- print FILE "<HR>\n";
- print FILE "<h5>\n";
- print FILE "<a href=\"http://$url\">\n";
- print FILE "<img src=\"http://www.ais.org/~hallway/icons/smalleft.gif\">\n";
- print FILE "Return to $to</a>\n";
- print FILE "</h5>\n";
- print FILE "\n";
- print FILE "</html>\n";
- print FILE "</body>\n";
-
- } #end sub GENFOOT
-
-
- #generates footer to file
- sub GENFOOT {
-
- local(*FILE) = @_;
-
- print FILE "\n";
- print FILE "<HR>\n";
- print FILE "<h5>\n";
- print FILE "Click <b>BACK</b> button or arrow to return.\n";
- print FILE "</h5>\n";
- print FILE "\n";
- print FILE "</html>\n";
- print FILE "</body>\n";
-
- } #end sub GENFOOT
-
-
- #generates required header
- #call w/title of page and recognition list
- sub PRNHEAD {
-
- local($title, @flist) = @_;
-
- print "Content-type: text/html\n\n";
- print "<html>\n";
- print "<head>\n";
- if (@flist[0] ne "") { &PRNREC(@flist); }
- print "<Title>$title</Title>\n";
- print "</head>\n";
- print "<body>\n";
- print "\n";
-
- } #end sub PRNHEAD
-
-
- #generates required header
- #call w/pointer to filehandle, title of page and recognition list
- sub GENHEAD {
-
- local(*FILE,$title,@flist) = @_;
-
- print FILE "<html>\n";
- print FILE "<head>\n";
- if (@flist[0] ne "") { &GENREC(@flist); }
- print FILE "<Title>$title</Title>\n";
- print FILE "</head>\n";
- print FILE "<body>\n";
- print FILE "\n";
-
- } #end sub GENHEAD
-
-
- #generates a recognition header
- sub PRNREC {
-
- local($fname,$ftease,$fauth,$fdesc) = @_;
-
- print "\n";
- print "<!--------------------------------------------------------------->\n\
- n";
- print "<!-- $fname >\n";
- print "<!-- $ftease >\n\n";
- print "<!-- author: $fauth >\n";
- print "<!-- description: $fdesc >\n\n";
- print "<!--------------------------------------------------------------->\n\
- n";
-
- } #end sub PRNREC
-
-
- #generates a recognition header
- sub GENREC {
-
-
- local($fname,$ftease,$fauth,$fdesc) = @_;
-
- print FILE "\n";
- print FILE "<!--------------------------------------------------------------
- ->\n\n";
- print FILE "<!-- $fname >\n";
- print FILE "<!-- $ftease >\n\n";
- print FILE "<!-- author: $fauth >\n";
- print FILE "<!-- description: $fdesc >\n\n";
- print FILE "<!--------------------------------------------------------------
- ->\n\n";
-
- } #end sub GENREC
-
- 1;
-
-
-
-
-