Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

SiteSearch v1 0

Code Wizard, 12-30-2006

Here is a little Site Search I made, it Does require Editing.. I have the Original file Direcs on it

<?php

//SiteSearch v1.0 - Aracthus

//Begin Environment Variables. You need to set these!//

//List of directories to be included in the search.
//Usage "path" => "url" (path to directory and URL which corresponds to directory)
//remember to include the trailing / on the URL

$directories = array(
"/web/sites/95/aracthus/www.aracthus.f2s.com" => "http://www.aracthus.f2s.com/",
"/web/sites/95/aracthus/www.aracthus.f2s.com" => "http://www.aracthus.f2s.com/",
"/web/sites/95/aracthus/www.aracthus.f2s.com" => "http://www.aracthus.f2s.com/"
);

//End Environment Variables//

Function Keyword_Check($filenames,$keywords)
{

for($i = 0; $i < count($filenames); $i++)
{
$filename = $filenames[$i];
$match = 0;
$fd = fopen($filename, "r");
$contents = fread($fd, filesize ($filename));
fclose($fd);
//Remove HTML Tags before searching
$contents = strip_tags($contents);
$contents = explode(" ", $contents);
$j = 0;
for($j = 0; $j < count($keywords); $j++)
{
for($k = 0; $k < count($contents); $k++)
{
//compare contents with each keyword (case insensitive)
if (!strcasecmp ($contents[$k], $keywords[$j]))
{
$match++;
break;
}
}
}

if ($match == count($keywords) )
$retVal[count($retVal)] = $filename;
}
return $retVal;
}

function Get_Filenames($directory)
{
//Load Directory Into Array
$handle=opendir($directory);
while ($file = readdir($handle))
{
if ($file != "." && $file != "..")
$retVal[count($retVal)] = $file;
}

//Clean up and sort
closedir($handle);
sort($retVal);
return $retVal;
}


if ( isset($keyword) )
{
$keywords = explode(" ", $keyword);
$pages = array();
while (list ($key, $val) = each ($directories))
{
$directory = $key;
chdir($directory) or die("Directory $directory Not found");
$filenames = Get_Filenames($directory);
$found = Keyword_Check($filenames,$keywords);

//add any pages with keywords in current directory to array
for($i = 0;$i < count($found); $i++)
{
$add = "$val$found[$i]";
$pages[count($pages)] = $add;
}
}

?>
<HTML>
<HEAD>
<TITLE>Search Results</TITLE>
</HEAD>
<?php

$numfound = count($pages);
} else {
?>
<HTML>
<Head>
<Title>Website Search</Title>
</Head>
<?php } ?>
<Body>
<Form Action=search.php>
<Input Type=Text Name=keyword Value="keyword";>
<Input Type=Submit Value=Search>
<Input Type=Reset Value="New Search">
<?php
if ( isset($keyword) )
{
echo "<HR>
";
echo "<Font Color=Blue>$numfound pages matching your query were found</Font>";
echo "<HR>";
for ($i = 0; $i < count($pages); $i++)
echo "<A HREF="$pages[$i]">$pages[$i]</A><BR>";
}
?>
</Form>
</Body>
</HTML>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions