cvs: phpweb / search.php

From: Date: Wed, 23 Apr 2003 16:07:12 +0000
Subject: cvs: phpweb / search.php
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-16949@lists.php.net to get a copy of this message
goba Wed Apr 23 12:07:12 2003 EDT Modified files: /phpweb search.php Log: Getting rid of php.net's search bug once and for all... Index: phpweb/search.php diff -u phpweb/search.php:1.68 phpweb/search.php:1.69 --- phpweb/search.php:1.68 Fri Mar 14 18:31:06 2003 +++ phpweb/search.php Wed Apr 23 12:07:11 2003 @@ -1,5 +1,5 @@ <?php -/* $Id: search.php,v 1.68 2003/03/14 23:31:06 jacques Exp $ */ +/* $Id: search.php,v 1.69 2003/04/23 16:07:11 goba Exp $ */ include_once "prepend.inc"; @@ -204,11 +204,7 @@ // This means that some error occured (the output templates are in // Mirrors-htdig.tgz, and one of those should appear on the output) - if ($rc < 2) { - echo "<b>There was an error executing this query.</b><br /><br />Please try later.<br /><br />"; - commonFooter(); - exit; - } + if ($rc < 2) { searchError(); } // Create versions insertable in HTML output and URLs too $htmlpt = htmlspecialchars($pattern); @@ -225,6 +221,13 @@ exit; } + // If we have not received the NOMATCH sign, then there need to + // be at least one result. The first 7 rows are meta information, + // the 8th row is the first result. Htdig seems to have a bug to + // return valid meta information even if there are no results + // returned, we would like to avoid that here... + if ($rc < 8) { searchError(); } + // We have matches, so grab the info from the output // (the template for this is phphead.html in Mirrors-htdig.tgz) list(, , $matches, $firstdisplayed, $lastdisplayed, $page, $pages) = $result; @@ -371,6 +374,17 @@ echo '<td align="right">' . $next . '<br></td>'; echo '</tr>'; echo '</table><br>' . "\n"; +} + +// This message is printed out if an error +// is encountered while searching the site +function searchError() +{ + echo '<b>There was an error executing this query.</b><br /><br /> + Please try later, or <a href="/mirrors.php">use another mirror + with local search support</a>.<br /><br />'; + commonFooter(); + exit; } ?>

« previous php.mirrors (#16949) next »