Jump to content

PHP Search


mastercool

Recommended Posts

I recently moved my entire site from one web host to another. The search function had worked previously but now that it has been moved it doesn't seem to work. It goes through the search but then says the keyword isn't found. Below is the code, any help would be appreciated. Thanks.

 

<?php

$keyword = $found = $count = $file = $filescope = 0;

$titl = array();

$keyword = @$HTTP_GET_VARS['keyword'];

if ($keyword and strlen($keyword) > 2) : ?>

<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">

<tr height="23">

<td align="center" width="20" height="23"></td>

<td align="center" width="2" height="23"></td>

<td align="center" height="23">

<div align="left">

<font size="2" color="black" face="Arial, Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">search result(s) for word:</font> <b><?php echo $keyword ?></b></div>

</td>

</tr>

<tr>

<td colspan="3" height="2"></td>

</tr>

<tr>

<td></td>

<td colspan="2"><font size="2" face="Arial, Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">found on page(s)</font></td>

</tr>

<?php

if(!isset($_SERVER["DOCUMENT_ROOT"])) {  $_SERVER["DOCUMENT_ROOT"]=substr($_SERVER['PATH_TRANSLATED'] , 0 , 39 );

}

$DOCROOT = $_SERVER['DOCUMENT_ROOT'];

//echo $DOCROOT;

//echo $_SERVER["DOCUMENT_ROOT"];

//echo $_SERVER['PATH_TRANSLATED'];

//echo "test";

//echo $_SERVER['PHP_SELF'];

$patch=opendir($DOCROOT);

while($file = readdir($patch)) :

$tmpfile = $DOCROOT . $file;

if (is_file($tmpfile) and preg_match("/.*\.html/i", $tmpfile)){

$fop = fopen($tmpfile, "r");

$search = fread($fop, filesize($tmpfile));

fclose($fop);

$filecope2 = $search;

$search = preg_replace("/<option.*>(.*)\n/i", "", $search);

$search = strip_tags($search, "<title>");

$filecope = $search;

if (preg_match("/\s($keyword)\s/i", $search, $result)) {

//                        echo $result[1];/\<title\>(+*)\</i

if (!$found) { $found="yes"; }

preg_match("/<title>(.*)/i", $filecope2, $result);

?><!--  -->

<tr>

<td colspan="3" height="6"></td>

</tr>

<tr>

<td class="count" align="center"><?php

$count++;

echo $count; ?></td>

<td></td>

<td>  <a href="<?php echo $file ?>"><?php echo $result[1]; ?></a></td>

</tr>

<tr>

<td colspan="3" height="6"></td>

</tr>

<?php

              }

        }

endwhile;

closedir($patch);

if (!$found) : ?>

<tr>

<td colspan="3" height="5"></td>

</tr>

<td colspan="3">

<div align="center">

<b>The required word is not found</b></div>

</td>

</table>

</td>

</tr>

<?php endif; ?>

 

Link to comment
https://forums.phpfreaks.com/topic/138184-php-search/
Share on other sites

Thank you for the advice, unfortunately that isn't it.

 

unfortunately just saying that and not trying it doesn't actually help your case, I was getting at what premiso said and if your server has register_globals off then you can have them "try" to have them turn it on but it is not recommended.

Link to comment
https://forums.phpfreaks.com/topic/138184-php-search/#findComment-722507
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.