#!/usr/local/bin/perl -Tw - # $Id: catfaq.cgi,v 1.10 2002/04/20 07:08:39 chip Exp $ use HTML::Entities; use strict; use vars qw(%ENV %FaqTitles); %FaqTitles = ( "austx-usenet-list" => "Welcome to Austin.*", "austx-ann" => "Welcome to Austin.Announce", "austx-jobs" => "Welcome to Austin.Jobs", "gn" => "The gn Gopher/HTTP Server FAQ", "sco-xenix" => "Welcome to comp.unix.xenix.sco", "pubnet" => "The pubnet Mailing List FAQ", ); sub main { my $faq_id = shift or send_errordoc("Could not obtain FAQ request."); $faq_id =~ s!.*/!!; $faq_id =~ s!\.faq$!!; my $faq_title = $FaqTitles{$faq_id} || "The $faq_id FAQ"; my $faq_filename = "faq/${faq_id}.faq"; (-f $faq_filename) or send_errordoc("Could not locate requested FAQ."); open(FP, $faq_filename) or send_errordoc("open($faq_filename): $!"); my $faq_content = encode_entities(join("", )); close(FP); my $faq_doc = q[ %FAQTITLE%

An FAQ Document
%FAQTITLE%

%FAQCONTENT%


Chip Rosenthal
<chip@unicom.com>

Back to Paperware Archive.
Home to Unicom Systems Development.
Let us know your comments, corrections, additions, suggestions. ]; $faq_doc =~ s/%FAQTITLE%/$faq_title/g; $faq_doc =~ s/%FAQCONTENT%/$faq_content/; send_document($faq_doc); } sub send_document { my $doc = shift; print "Content-Type: text/html\n", "Content-Length: ", length($doc), "\n", "\n", $doc; } sub send_errordoc { my $errmssg = join("\n", @_); $errmssg = encode_entities($errmssg); $errmssg =~ s/\n/
/g; my $errdoc = q[ An Error Has Occurred

An Error Has Occurred

] . $errmssg . q[ ]; send_document($errdoc); exit(0); } main($ENV{REQUEST_URI}); exit(0);