#!/usr/bin/perl require 'session.cgi'; my %form = map { $_ => join "\0",$cgi->param($_) } $cgi->param(); if($form{'page'} eq 'index'){ $footer = "footer_top.inc"; }else{ $footer = "footer.inc"; } &IncludeFile('header.inc',\%form); if($form{'page'} ne ''){ $form{'page'} .= ".html"; if(-f "$form{'page'}"){ &ShowPage($form{'page'}); } } else{ $form{'index'} = 1 if(!$form{'index'}); ($docs_list,$rows) = &GetDocumentList($form{'index'}); if($rows > 1){ &ShowIndex($docs_list); } elsif($rows == 0){ } else{ &ShowPage($docs_list->[0][2]); } } &IncludeFile($footer); ## --------- sub routines ---------------- sub ShowPage{ my($page) = shift; $start = 0; $end = 0; open(PAGE, "$page") || die "Can't open $page: $!\n"; while(){ if(/Enter CONTENT HERE/){ $start = 1; } elsif(/End of CONTENT/){ $start = 0; $end = 1; } if($start){ s///g; s/SIDVALUE/$SID/g; s/xxxx_xxxx/$SID/g; print "$_"; } elsif($end){ last; } else{ next; } } close(PAGE); return; } # ---------------------------------------- sub GetDocumentList{ my($key) = shift; my($statement, $sth, $rv, $list); $statement = "SELECT * FROM text_docs,text_link WHERE section='$key' AND text_docs.id=text_link.textid AND text_link.siteid='1' ORDER BY name"; $sth = $dbh->prepare($statement) || die "Can't prepare $statement: $dbh->errstr\n"; $rv = $sth->execute || die "Can't execute the query: $sth->errstr\n"; $list = $sth->fetchall_arrayref; $rows = $sth->rows; return ($list,$rows); } # ---------------------------------------- sub ShowIndex{ my($list) = shift; %section_names = ( '1' => "Tips", '2' => "Policies", '3' => "Definitions", '5' => "Ordering", '6' => "Links" ); print "\n"; print "\n"; print "\n"; for $i (0 .. $#{$list}){ if($list->[$i][2] =~ /(.*)\.txt/){ #text file, set up link for new window print "\n"; } else{ $list->[$i][2] =~ s/(.*)\.html/wrapper\.cgi\?SID=$SID\&page=$1/g; print "\n"; } } print "
$section_names{$main::index}
\ \;
[$i][2]\" target=\"new\">$list->[$i][1]
[$i][2]\">$list->[$i][1]
\n"; }