#!/usr/bin/perl
# Data
# --------------
# Set this line to the location of the data file you wish to search and display
# *This is a server path without a slash on the end.*
$datafile = "/usr/www/docs/antique-directory.com/database/data/data.txt";
# HTML Files
# --------------
$data_path = "/usr/www/docs/antique-directory.com/database/html";
# HTML Files Required
# -------------------
# These files must exist, even if empty. They must be in the directory set above.
# display_header.dat
# display_footer.dat
# search_form.dat
#
# Revolving Color Option
# ----------------------
# If you want a Table of results to use rotating colors.
$bgcolor1 = "#FFCC99";
$bgcolor2 = "#FFFFCC";
# Use cgi-lib.pl CGI library for PERL.
require "/usr/www/docs/antique-directory.com/cgi-local/cgi-lib.pl";
# Table Header Sub-routine
# ------------------------------
sub table_header
{
print qq!
| Dealers |
!; # end of print statement
}
# Individual search result
# -----------------------------
sub table_row
{
$name=""; $email="";
if ($field[25] ne "")
{$name="$field[4]";}
else
{$name="$field[4]";}
if ($field[24] ne "")
{$email="E-Mail: $field[24]";}
else
{$email = "";}
if ($field[15] ne "")
{$phone1 = "Phone: ($field[15]) $field[16]-$field[17]";}
else
{$phone1="";}
if ($field[18] ne "")
{$phone2 = "Toll Free: ($field[18]) $field[19]-$field[20]";}
else
{$phone2 = "";}
if ($field[21] ne "")
{$phone3 = "Fax: ($field[21]) $field[22]-$field[23]";}
else
{$phone3 = "";}
print qq!
$name
$field[5] $field[6]
$field[7]
$field[8], $field[9] $field[10]
|
$phone1
$phone2
$phone3
$email
|
|
$field[26]
|
|
Highway: $field[28]
|
Area: $field[27]
|
Specialties for $field[4] are:
$field[29] . . .
|
!;
}
# Table Footer
# ---------------
#
sub table_footer
{
print qq!
| |
|
!;
}
##############################################################
##############################################################
# End Of configure
##############################################################
##############################################################
##############################################################
# Parse from the web form
##############################################################
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@cgiPairs = split(/&/,$buffer);
foreach $cgiPair (@cgiPairs)
{
($name,$value) = split(/=/,$cgiPair);
$value =~ s/\+/ /g;
$value =~ s/%(..)/pack("c",hex($1))/ge;
$form{$name} .= "\0" if (defined($form{$name}));
$form{$name} .= "$value";
}
print "Content-type: text/html\n\n";
##############################################################
# Read in data and decide what to do
##############################################################
open (FILE, "$data_path/display_header.dat") || die print "$html_path/display_header.dat";
while()
{$row = $_;chop $row;
$header .= "$row\n";}
close (FILE);
open (FILE, "$data_path/display_footer.dat") || die print "$data_path/display_footer.dat";
while()
{$row = $_;chop $row;
$footer .= "$row\n";}
close (FILE);
open (FILE, "$data_path/search_form.dat") || die print "$data_path/search_form.dat";
while()
{$row = $_;chop $row;
$search_form .= "$row\n";}
close (FILE);
################################################
# Search & Print Output
################################################
open (DATABASE, "$datafile") || die print "$datafile";
@data=;
close (DATABASE);
$Fcount = 0;
print "$header";
print "$search_form
";
print "
";
$Input = ""; $FLD = ""; $NUM = "";
&table_header;
foreach $data(@data)
{
@field = split (/\|/, $data);
if (($field[3]) =~ (Featured))
{
if ($bgcount > 1)
{$bgcolor=$bgcolor2;$bgcount=1;}
else
{$bgcolor=$bgcolor1;$bgcount=2;}
$Fcount += 1;
&table_row;
}
}
&table_footer;
print "
$search_form
";
print "$footer
";
Close DB;