# The code included below is used by Campus Crusade for Christ # with permission of Alphalogic Systems, Inc. # No portion of this code made be used or replicated without # permission. # PrintHeader # # Returns the magic line which tells WWW that we're an HTML document # if a cookie existes, it sets the cookie also sub PrintHeader { print "Content-type: text/html\n"; if ($gCookieValue ne "") { &SetCookies($gCookieName,$gCookieValue); print "\n"; } else { print "\n"; } } # # SendTemplate # # This subroutine is used to display a web page template and then add information # onto that template. The information comes from the tokens created by the # perl script. sub SendTemplate { my ($template)=@_; my ($key, $filecontents); open (FILE, "$template"); # opens file containing web page template if (eof(FILE)==1) { # If file doesn't open, provides a basic web page with an error message. # Then proceeds to post raw data onto the web page. &PrintHeader(); $key = ''; print "$gTokens{$key}

Sorry, There has been an error in calling the Template.

"; print "

The information you requested is listed below.

"; foreach $key (sort keys %gTokens){ print "$key","\t", $gTokens{$key},"

\n"; } print ""; return; } # The following commands will dump everything in the web template file into $filecontents undef $/; $filecontents=; close FILE; $/ = "\n"; # This loop will search $filecontents and replace any tokens found with the HTML code # that the token is associated with in the hash %gToken hash. foreach $key (sort keys %gTokens){ $filecontents=~s/$key/$gTokens{$key}/g; } &PrintHeader(); print $filecontents; return true; }