ht://Dig is normally run as a CGI script ("normally" meaning "by everyone who doesn't use PHP3!"). To run the search program from PHP, you will need a file called
which looks like this:
export QUERY_STRING REQUEST_METHOD
Just change the value of
HTBINDIR to whatever is appropriate for your setup (i.e. the path you picked for
CGIBIN_DIR in the
CONFIG file when you installed ht://Dig).
I recommend putting this file in the
search/ subdirectory as well, along with the template files. You also need to change file permissions so
htdig.sh is executable by your web server.
Next, we need to get PHP to talk to the search script. Finally, some PHP code! This is simply a matter of building the query string to pass to
htdig.sh, executing the search, and parsing the results.
results.php3, we build the query string:
$HTSEARCH_PROG = "/www/summerworks/search/htdig.sh";
$words = EscapeShellCmd(UrlEncode($search));
$config = "sw98";
$format = "sw98";
$query = "config=$config&format=$format&words=$words";
is the location of the
is passed from the form, and is the list of words to search for.
tells ht://Dig which
file to use, and
tells it which template map to use from the
Then we run the search:
This puts the results of the search into the array