>Date: Mon, 18 Jun 2001 14:29:56 -0400
>To: [EMAIL PROTECTED]
>From: Curtis Ireland <[EMAIL PROTECTED]>
>Subject: Re: [htdig-dev] completing a php wrapper
>
>These were the blocks I ran into when I made my PHP wrapper. The
>particularly annoying one was that htdig follows the standard of using ;
>to separate variables where PHP doesn't follow that standard yet. Attached
>is a fully working PHP wrapper. I cleaned out my personal site-specific
>code, so feel free to use it as needed.
> -C
>
>At 06:34 PM 6/17/01 -0400, you wrote:
>>I'm in the process of using the PHP wrapper guide as found at:
>>
>>http://htdig.org/contrib/guides.html which points to
>>http://www.devshed.com/Server_Side/PHP/search/
>>
>>The DevShed article is good as it's shown me the way to get started.
>>But there are a few little niggles which are preventing me from finishing.
>>I'm posting this message as a request for clues and in the hope that
>>someone will say "look here, it's already been done...".
>>
>>The sticking point is result sets which span more than one page.
>>
>>The work in progress is available at:
>>http://diary.unixathome.org/htdig/results.php
>>
>>If you search on 'langille', you'll get two pages of results. If you
>>examine
>>the URLS provided for the (2) link, you'll find:
>>
>>http://diary.unixathome.org/htdig/?config=htdig;format=htdig;words=langil
>>le;page=2
>>
>>As I see it, there are two problems to solve:
>>
>>1 - get the correct URL in there. It should be
>>http://diary.unixathome.org/htdig/results.php
>>
>>2 - parse the arguments
>>"?config=htdig;format=htdig;words=langille;page=2" into something php
>>can use.
>>
>>any ideas?
>>
>>thanks.
>>
>>--
>>Dan Langille
>>pgpkey - finger [EMAIL PROTECTED] | http://unixathome.org/finger.php
>>
>>_______________________________________________
>>htdig-dev mailing list
>>[EMAIL PROTECTED]
>>http://lists.sourceforge.net/lists/listinfo/htdig-dev
>
>--
>Curtis Ireland - [EMAIL PROTECTED]
>Solidum Systems - http://www.solidum.com
>(T) (613)724-6004 x284 - (F) (613)724-6008
--
Curtis Ireland - [EMAIL PROTECTED]
Solidum Systems - http://www.solidum.com
(T) (613)724-6004 x284 - (F) (613)724-6008
<?php
# $Id: gl_results.php,v 1.1.1.2 2001/05/10 20:41:16 cireland Exp $
if(! isset($page)) {$page=1;} #Make sure we are on the right page
$HTSEARCH_PROG = "/lhome/httpd/cgi-bin/htdig.sh";
$words = EscapeShellCmd(UrlEncode($words));
$format = "wsc"; # Use the template defined in htdig.conf
# I use this to merge databases together
for($i=0;$i<sizeof($config);$i++) {
$squery .= "config=" . $config[$i] . ";";
}
$squery .= "format=$format;words=$words;sort=$sort;method=$method;page=$page";
# Run the actual query
$command="$HTSEARCH_PROG \"$squery\"";
exec($command, $result);
$rc = count($result);
# Display what we need to show
if($rc<3) {
print("<P><FONT FACE=\"Arial, Helvetica, sans-serif\">There was an error executing
this query. Please try later.</FONT></P>\n");
} elseif($result[2] == "NOMATCH") {
print("<P><FONT FACE=\"Arial, Helvetica, sans-serif\">There were no matches for
<B>$words</B> found</FONT></P>\n");
} elseif($result[2] == "SYNTAXERROR") {
print("<P><FONT FACE=\"Arial, Helvetica, sans-serif\">There is a syntax error in
your search for <B>$words</B>;</FONT><BR>\n");
print("<BLOCKQUOTE><PRE>" . $result[3] . "</PRE></BLOCKQUOTE></P>\n");
} elseif(strip_tags($result[2]) == "htsearch error") {
for($i=4; $i < sizeof($result); $i++) {
print($result[$i]."\n");
}
} else {
$matches = $result[2];
$firstdisplayed = $result[3];
$lastdisplayed = $result[4];
$words = $result[5];
# Notice what I did to $pagelist to get around PHP not recognizing ; as a variable
separator
$pagelist = $result[6];
$pagelist = str_replace("config","config[]",str_replace(";","&",$pagelist));
$page = $result[7];
print("<P><FONT FACE=\"Arial, Helvetica, sans-serif\">Your search for <B>$words</B>
returned <B>$matches</B> match");
if($matches != 1) {
print("es");
}
print(".</FONT><BR>\n");
print("<FONT FACE=\"Arial, Helvetica, sans-serif\">Displaying page <B>$page</B>
results: <B>$firstdisplayed</B> to <B>$lastdisplayed</B>:</FONT></P>\n");
for($i=0;$i < ($lastdisplayed - $firstdisplayed + 1);$i++) {
$index=4 * $i + 8;
$title = $result[$index];
$url = $result[$index+1];
$percent = $result[$index+2];
$excerpt = $result[$index+3];
print("<FONT FACE=\"Arial, Helvetica, sans-serif\"><FONT SIZE=\"+1\"><DL><DT>" .
($i+$firstdisplayed) . ": <A HREF=\"$url\">$title</A></FONT> ($percent%
match)</FONT></DT>\n");
# print("<FONT FACE=\"Arial, Helvetica, sans-serif\">($percent%
match)</FONT><BR>\n");
print("<DD><FONT FACE=\"Arial, Helvetica, sans-serif\"
SIZE=\"-1\">$excerpt</FONT><BR>\n");
print("<FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"-1\">(<A
HREF=\"$url\">$url</A>)</FONT></DD></DL>\n");
}
print("<P ALIGN=\"CENTER\">$pagelist</P>\n");
}
?>