#!/usr/bin/perl require "var.pl"; require "master.pl"; require "$siteroot/store/library/store_subs.pl"; require "$siteroot/store/data/settings.dat"; if(-e "$siteroot/store/store.cgi") { $sc_order_script_url = "http://$domainroot/store/store.cgi"; } if(-e "$siteroot/cgi-bin/store.cgi") { $sc_order_script_url = "http://$domainroot/cgi-bin/store.cgi"; } if(-e "$siteroot/store.cgi") { $sc_order_script_url = "http://$domainroot/store.cgi"; } if(-e "$siteroot/cgi-bin/help.cgi") { $help_script_url = "http://$domainroot/cgi-bin/help.cgi"; } if(-e "$siteroot/help.cgi") { $help_script_url = "http://$domainroot/help.cgi"; } print "Content-type: text/html\n\n"; if ($ENV{'CONTENT_LENGTH'} ne "") { my( @pairs, $pair, $name, $value ); read(STDIN, $value, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $value); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $form_data{$name} = "$value"; } } if ($ENV{'QUERY_STRING'} ne "") { @pairs = split(/&/, $ENV{QUERY_STRING}); foreach $pair (@pairs) { ($name,$value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; $form_data{$name} = $value; } } $case_sensitive = 0; $toc = "faq"; $file = $form_data{'topic'}; $window = $form_data{'window'}; $search = $form_data{'search'}; $cart_id = $form_data{'cart_id'}; $refer_id = $form_data{'refer_id'}; if(-e "$siteroot/help/text.txt") { open(DAT, "$siteroot/help/text.txt") || die("Could not open file!"); @dat=; close(DAT); $faq_text=join('', @dat); } $title=qq~Questions and Answers~; $side_title=qq~Questions and Answers~; $side_info=qq~ $faq_text
These Questions and Answers have been prepared to help you use this site. Find Answers and Questions relating to a topic by entering a Search term , or browse the Questions pages.
~; &StoreHeader; if ($toc ne "" && $search ne "") { &search_faqs; } elsif ($toc ne "" && $file eq "" && $search eq "") { &display_toc; } elsif ($toc ne "" && $file ne "") { &show_answer; } sub display_toc { if($window eq "") { opendir (DIR,"$siteroot/help") || &CgiDie ("Can't open [directory_location]"); @filenames = grep (!/^\.\.?$/, readdir (DIR)); closedir (DIR); foreach $file_name (@filenames) { if($file_name=~ /faq/) { push(@files_to_open, $file_name); } } } else { $file_name="$window.faq"; push(@files_to_open, $file_name); } foreach $fop (@files_to_open) { print "$template_top"; open(FAQ, "$siteroot/help/$fop"); @news=; close FAQ; $window=$fop; $window=~ s/\.faq//g; $faq_title =shift(@news); chomp $faq_title; print qq~

$faq_title :
\n~; $question_number = 1; foreach $new_line(@news) { if ($new_line=~ /^::/) {$new_line=~ s/^:://; print qq~\n~; $question_number++; } } print "\n
$question_number - $new_line
                                                                                                                                               
"; } &StoreFooter; } sub show_answer { $back_to = ""; $forward_to = ""; $back_to_name = ""; $forward_to_name = ""; $count = 0; $question = 1; open (FAQ, "$siteroot/help/$window.faq") || handle_error("Can't open file \"$file.faq\"
$!"); $_ = ; chomp; print qq~

$_
\n~; while () { if (/^::[ ]*(.+)/) { if ($question eq "$file") { print qq~\n~; } } else { if ($question eq "$file") { print qq~\n\n~; } $question++; } } close FAQ; print "\n
$question- $1
$_
"; &StoreFooter; } sub search_faqs { opendir (DIR,"$siteroot/help") || &CgiDie ("Can't open [directory_location]"); @filenames = grep (!/^\.\.?$/, readdir (DIR)); closedir (DIR); foreach $file_name (@filenames) { if($file_name=~ /faq/) { push(@files_to_open, $file_name); } } $htmlsearch = $search; @search_data=split(/\s/, $htmlsearch); print "

Search results for $htmlsearch. The following links contain information regarding your query.

\n"; foreach $fop (@files_to_open) { open(FAQ, "$siteroot/help/$fop"); @news=; close FAQ; $window=$fop; $window=~ s/\.faq//g; $faq_title =shift(@news); chomp $faq_title; $sr=qq~

$faq_title :
\n~; $question_number = 1; foreach $new_line (@news) { if ($new_line=~ /^::/) {$new_line=~ s/^:://; $part1=qq~\n~; $question_number++; } else { foreach $sdata (@search_data) { if ($new_line=~ /$sdata/) { $sr .="$part1"; $doit="yes"; } } } } if($doit eq "yes") { print $sr; $doit=""; $sr=""; } } print "\n
$question_number - $new_line
                                                                                                                                               
"; } # # main part of the script # exit;