#!/usr/bin/perl
###################################################################
# POWERdirectory Version 1.08 ###
# Script ID: P-RS-DIR-108 #
# Script Coordinator: MR. T. Dworzanski (employee #107) #
# Created on 8 June 2000 Last Modified on 15 October 2000 #
# Script purchased by: n/a ##
###################################################################
# Set the following variable to a template HTML file on your server
# on which this script will display any necessary results. A sample
# is includes with this distribution, and available from
# www.trdweb.com/cgi. The template file will be opened by this
# script, and edited to include ODP content. The rules for this file
# are simple. Where you'd like to have the directory (branch of a
# directory) put: SCRIPT(location). Where you'd like to have the
# directory content put: SCRIPT(content). Where you'd like to have
# the required ODP table put: SCRIPT(table). There is no real way I
# can describe this. Here is an example of how this file may look:
#
Directory
# Your are here: SCRIPT(location)
#
# Here are some links:
# SCRIPT(content)
#
# SCRIPT(table)
#
# That's it! Just save a file like that on your server and set the
# following variable to the complete path (on the server) to that
# file.
# (This should be a server path -- e.g. /home/username/www/temp.html --
# *NOT* http://www.domain.com/temp.html)
$PathToTemplate = " /home/domains/dictomail.com/web/direcory/search_template.html";
# You have now finished editing this script. No further change to the
# code is necessary. Enjoy POWERdirectory!
### DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING! ###
&GetForm;
$Address = &GetAddress;
$DMOZPage = &GetPage($Address);
$PageLocation = &GetLocation($DMOZPage);
$PageListings = &GetListings($DMOZPage);
$PageFooter = &GetFooter;
open (TEMPLATE, "$PathToTemplate") || die "Content-type: text/html\n\nUnable to open template.";
@InFileData = ;
close (TEMPLATE);
print "Content-type: text/html\n\n";
foreach $Line (@InFileData) {
$Line =~ s/SCRIPT\(location\)/$PageLocation/gis;
$Line =~ s/SCRIPT\(content\)/$PageListings/gis;
$Line =~ s/SCRIPT\(table\)/$PageFooter/gis;
print $Line;
}
sub GetForm {
%form = ();
my (@pairs,$pair,$buffer);
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
else {
@pairs = @ARGV;
}
foreach $pair (@pairs) {
my($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;
if ($Form{$name} && $value) {
die('Form value inputed twice.');
}
else {
$form{$name} = $value;
}
}
}
sub GetAddress {
my $which_dir = "http://dmoz.org";
$dir = '/';
$dir = $form{'dir'} if $form{'dir'};
my $url = $which_dir . $dir;
return $url;
}
sub GetPage {
use LWP::Simple;
my($request_this_url) = shift;
my($requested_content) = get($request_this_url);
return $requested_content;
}
sub GetLocation {
my ($content,$CurrentContent);
$content = shift;
$content =~ /(Top<\/a>.*?<\/table>)/s;
if($1){
$CurrentContent = $1;
$CurrentContent =~ s/