#!/usr/bin/perl
# A simple "shtml" script to display a list
# of categories from the products.dat database.
# NOTE: HTML Page name MUST end with: .shtml
#
# Example shtml page usage:
#
# Set your quikstore url here if different
my($quikstoreScriptURL) = "/cgi-bin/quikstore.cgi";
# Begin routine ------------------------------------------------
$| = 1;
print "Content-type: text/html\n\n";
use CGI::Carp;
# Set the path to this directory:
$cwd = $ENV{'SCRIPT_FILENAME'} || $0;
if(($ENV{'SCRIPT_FILENAME'} =~ /cgiwrap/ig)&&($0 ne "")){
$cwd = $0;
}
$cwd =~ s/\\/\//g;
my(@cwds) = split(/\//,$cwd);
pop(@cwds);
$cwd = join("/",@cwds);
# Database Path:
my($dataPath) = "$cwd/database/products.dat";
# Read database
my($line);
my(@list) = ();
open(DB, "<$dataPath")||die("can't open database? $!");
# Loop through and build a list of categories
while(defined($line = )){
my(@dbfields) = split(/\|/,$line);
my($cat) = $dbfields[1];
if($cat =~ /^category$/i){
next;
}
if($catList{$cat} eq ""){
push(@list,$cat);
$catList{$cat} = $cat;
}
}
close(DB);
# Sort the category list and display using
# a bullet () tag and a link.
foreach my $catTxt (sort(@list)){
my($textCategory) = "\u$catTxt";
$textCategory =~ s/\_/ /g;
print "$textCategory\n";
}
exit;
1;