#!/usr/bin/perl print "Content-type:text/html\n\n"; #Program to open a database of merchants and display a list #Display is for either ALPHABETICAL or CATAGORY list, plus a list of ALL Merchants #Needs a either POST from a Form or GET including:- # "List" which is the type of list (alpha or category or all), and # "db" which is the name of the database to be opened $localtime = localtime(); $header = "html/catheader.html"; $footer = "html/catfooter.html"; $fontcolor = "000000"; $fontsize = "2"; $fontface = "Verdana"; &parse_input; &variables; &print_header; &get_data; &print_footer; #print "end of script"; exit; #==================================================================================== # Parse User Input sub parse_input{ if ($ENV{'REQUEST_METHOD'} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } @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; $FORM{$name} = $value; } } #==================================================================================== sub variables{ $list = "$FORM{'list'}"; $database = "$FORM{'db'}"; $pageopen = $list; $pageopen .= $database; $datafile = $database; $datafile .= ".dat"; } exit; #==================================================================================== sub get_data{ $longdesc = ""; $banner = ""; $count = "0"; open(LIST2, "<../database/$list/$datafile") || &error("Cannot open HTML source file : $pageopen, Error $!\n"); @list = ; close(LIST2); foreach $line(@list) { chomp($line); ($memid,$company,$websitename,$weburl,$desc,$mytime) = split(/\|/,$line); $count++; if($memid ne ""){ &get_longdesc; print <
$company $banlink $bansrc
Accreditation Number $memid
$websitename
$desc
$longdesc
Accredited since: $mytime
EndHTML $longdesc = ""; $banner = ""; } } if($count eq "0"){ print < Sorry there are no members for your selection
EndNOWT } } exit; #==================================================================================== sub get_longdesc{ $banlink = ""; $bansrc = "Web Site"; open(LIST3, "<../database/longdescription/total.dat"); @list3 = ; close(LIST3); foreach $rec(@list3) { chomp($rec); ($lookup_memid,$lookup_longdesc,$lookup_banner) = split(/\|/,$rec); if ($memid eq $lookup_memid){ $longdesc = $lookup_longdesc; $banlink = ""; $bansrc = "Web Site"; if($lookup_banner ne ""){ $banlink = ""; $bansrc = ""; } return; } } } #==================================================================================== sub print_header { $show = $list; if($list eq "alpha"){ $show = "Alphabetical"; } # print "Content-type:text/html\n\n"; open(FILE,"$header") || &error("The header file failed to open."); @data = ; close(FILE); foreach $newline (@data){ $newline =~ s/\$show/$show/gi; $newline =~ s/\$database/$database/gi; } print @data; } exit; #==================================================================================== sub print_footer { open(FILE,"$footer") || &error("The footer file failed to open."); @data = ; close(FILE); foreach $line (@data) { print "$line"; } } exit; #==================================================================================== sub error { $error = $_[0]; # &header; print "\n"; print "Error - $error\n"; print "Error - $error\n"; print "
"; print ""; print "
"; print "

\n"; print "\n"; # &footer; exit(0); } exit; #==================================================================================== sub dienice{ print <Ooops - sorry but something has gone wrong with your request
Please press the Button below and try again

Thank you

$error

EndHTML exit; } exit; #=======================================================================