#!/usr/bin/perl ############################################################################# ## Program Name: pod.cgi version 1.60n ## ## Personal Open Directory (POD) - Netscape Version ## John M. Grohol ## Released: 25 May 1999 ## This version: 19 Dec 1999 ## http://grohol.com/ ## ## Copyright 1999 John M. Grohol and Checkpoint Computer Consultants ## Free to distribute, but you cannot charge for this work or any ## derivatives thereof. No warranties on this program are made or implied. ## ## Warning: ## Because of the dynamic nature of the ODP third-party provider we're ## using (Netscape), this script changes monthly to keep up-to-date ## with changes Netscape makes to the formatting of their site. ## Be prepared to update this script regularly. Starting with version 1.31, ## changes are noted also within the script itself. ## ## Adapted with permission from maxcomm.cgi: ## ## Author : Ross Faulds (Checkpoint Computer Consultants Ltd) ## email : ross@checkpoint.demon.co.uk ## Web : http://www.computer-mentors.co.uk/download.html ## Copyright : Checkpoint Computer Consultants (1999) ## Date : 06/04/1999 ## ############################################################################# ## Installation Instructions: ## ## ftp pod.cgi into your cgi-bin directory. ## set permissions for pod.cgi (For unix this should be 0755) ## ## Check with your webmaster that your web server has GET and POST ## allowed. ## ## Note that when you download the footer and header files, ## that they may have the extension .txt -- Change this to .html ## ## Note that you need to have the following perl modules and libraries ## installed or this script doesn't work: ## CGI, LWP, URI, HTTP, Fcntl ## Ask your system administrator or Webmaster to install these if they ## don't already exist on your system. The nature of perl is that you ## use pre-existing libraries as much as possible; they are quick and ## painless to install on any system. Download them from http://cpan.perl.org ## ## Change the following variables: ## ## $cgi-url - set to the path to your cgi-bin (ensure forward slash on end) ## $logging - set to 1 if you want to log searches 0 if you dont. ## $logdir - set to the FULL path to the file. ## $logfile - set to the log file name you want searches logged to. ## $templatedir - set to the FULL path to the file where the header.html ## and footer.html files are located ## ## $myhome - set to whatever your Web homepage is ## $pod_name - set to whatever you want to call your Personal Open Directory ## ## $ddj - set to the path of your system date program (whereis date) ## $fontface - set font face other than default ## $fontsize - set font size other than default ## ## The below automated book-linking feature requires 2 things: ## 1. You have access to or have installed the MaxComm script ## 2. You have an Amazon Associates ID ## If you do not have both of these, then leave $whichamazon alone. ## ## $whichamazon - set to the Amazon.com bookstore you'd like to link to ## or set to "" to turn off this feature ## $amazon_ID - set to your Amazon Associates ID ## $maxcomm - set to the complete URL of where to access the MaxComm script ## $bookstorename - Name of your link to Amazon.com (default = Amazon.com) ## ## Version Changes: ## v1.60n - Bug fixes; debugger message ## v1.55n - Bug fixes ## v1.54n - Internationalization option added ## v1.53n - Minor search patch ## v1.52 - Minor patch ## v1.51 - Formatting fixes (noted in code under 1.51) ## v1.50 - Minor bug fixes and moved variables out to separate file (podvars.pm) ## v1.36 - Fixed book string and added choices to Amazon links thanks to WizarDave! ## v1.35 - Directory URL fix (again) -> change search.netscape.com to directory.netscape.com ## v1.34 - Right column option (not released) (if you want this option, suggest download ## entire program and reinstall, because changes were extensive) ## v1.331 - Change directory.netscape.com to search.netscape.com ## v1.33 - Stupid google fix (again) ## v1.32 - Fixed ads which were appearing after search results ## v1.31 - Fixed Google "Next 10 Results" link ## v1.3 - Fixed Next 10 search results, other minor fixes ## v1.24 - Fixed google image problem ## v1.22/3 - Fixed "search more results" link ## v1.21 - Fixed "search again" form ## v1.20 - Fixed Netscape redesign and search engine 'more results' bug ## Change color of tables ## v1.19 - Misc search engine formatting bug fixes ## v1.18 - Fixed book link when conducting multi-word POD searches ## Fixed about from homepage suggest-a-site ## v1.17 - Added font control ## v1.16 - Fixed image problem with Hot sites ## v1.15 - Fixed 600 width problem, improved installation instructions, ## added $bookstorename variable ## v1.14 - Fixed World subdirectory problem ## v1.13 - NR ## v1.12 - Original public release ############################################################################# ## Modules needed: use CGI; use LWP::UserAgent; use URI::Escape; use HTTP::Request; use HTTP::Response; use Fcntl; ############################################################################# ## Configuration area ## ## Configuration variables are now in separate file called "podvars.pm" ## Place this file in the same directory as POD (add full path before ## filename below if you're having troubles). require "podvars.pm"; ############################################################################# ## Main program ## Let's grab the variables being passed to the program and clean them ## up and assign them. $q = new CGI; $tag = $q->param(tag); $footer = &page_footer; print $q->header; &page_header; $dir = $q->param(dir); $dir =~ s/%([\dA-Fa-f]{2})/pack("C", hex($1))/eisg; $ssrch = "search"; $which_dir = "http://directory.netscape.com"; $keyword = $q->param(search); # 1.52 if (($dir =~ /search/) && (!($dir =~ /srp/))) { $trg = rindex($dir, "search"); $tre = index($dir,"=",$trg); $trra = rindex($dir,"\&"); $keyword = substr($dir,$tre+1); } $keyword =~ s/\`//g; $keyword =~ s/\'//g; $all = $q->param(all); $cat = $q->param(cat); $start = $q->param(start); $fo = $q->param(fo); $so = $q->param(so); $co = $q->param(co); $cp = $q->param(cp); $jsites = $q->param(jsites); $jstart = $q->param(jstart); $mcat = $q->param(morecat); if ($dir =~ /morecat/) { $mcat = 1; } if ($logging == 1) { &log_search($keyword,$ddj); } $tag = $q->param(tag); $mode = $q->param(mode); $content = &get_first_page($keyword,$all,$cat,$dir,$jsites,$jstart,$start,$mcat,$fo,$so,$co,$cp); &modify_content($pod_name,$content,$which_dir,$dir,$keyword,$whichamazon,$amazon_ID,$maxcomm,$bookstorename,$fontface,$fontsize,$start,$jstart,$cp,$lighttable,$darktable,$medtable,$tabletext,$right_column,$ssrch); exit 0; ## This is where the magic occurs. We do a number of checks for certain HTML ## on the Netscape site and begin the massive search and replace on each page fetched. ## This isn't pretty, is very dependent on the HTML, but it works. sub modify_content() { my $pod_name = shift(@_); my $content = shift(@_); my $which_dir = shift(@_); my $dir = shift(@_); my $keyword = shift(@_); my $whichamazon = shift(@_); my $amazon_ID = shift(@_); my $maxcomm = shift(@_); my $bookstorename = shift(@_); my $fontface = shift(@_); my $fontsize = shift(@_); my $start = shift(@_); my $jstart = shift(@_); my $cp = shift(@_); my $lighttable = shift(@_); my $darktable = shift(@_); my $medtable = shift(@_); my $tabletext = shift(@_); my $right_column = shift(@_); my $ssrch = shift(@_); printf "
|
Personal Open Directory is open source software by
J. Grohol &
R. Faulds
Copyright 1999. v1.60n. All rights reserved.