Create a folder in your root directory that contains all the contents of each page, e.g: about.txt, contact.php etc. NO coding, just plain text content.
search.php
<?
function get_param($name, $type="post", $default = "")
{
$returnee = "";
if(isset($_POST[$name]) && (($type == "post") || ($type == "both")))
$returnee = $_POST[$name];
else if(isset($_GET[$name]) && (($type == "get") || ($type == "both")) )
$returnee = $_GET[$name];
else
$returnee = $default;
if (1 == get_magic_quotes_gpc())
$returnee = stripslashes($returnee);
return trim($returnee);
}
function get_dir($name){
$temp = array();
$cnt = 0;
if($dh = opendir($name)) {
while(($file = readdir($dh)) !== false){
if($cnt >= 2)
array_push($temp, $file);
$cnt++;
}
$cnt = 0;
closedir($dh);
}
return $temp;
}
function search($text_search, $dir="search_docs/"){
$text_search = explode(" ", $text_search);
$files = get_dir($dir);
$buffer = array();
foreach($files as $i => $v)
if(is_file($dir.$v))
array_push($buffer, array($dir.$v, file_get_contents($dir.$v)));
$found = array();
foreach($buffer as $i => $v)
foreach($text_search as $ti => $tv)
if(strpos($v[1], $tv) !== false && !in_array($v[0], $found))
array_push($found, $v[0]);
return $found;
}
$index = array();
$index["search_docs/contact.txt"] = array("contact.php", "Contact page");
$index["search_docs/disclaimer.txt"] = array("disclaimer.php", "Disclaimer page");
$index["search_docs/downloads.txt"] = array("downloads.php", "Downloads page");
$index["search_docs/estimation.txt"] = array("estimation.php", "Estimation page");
$index["search_docs/faq.txt"] = array("faq.php", "FAQ page");
$index["search_docs/index.txt"] = array("index.php", "Home page");
$index["search_docs/onlinep.txt"] = array("onlinep.php", "Online Proofs page");
$index["search_docs/quote.txt"] = array("quote.php", "Quote page");
$index["search_docs/repro.txt"] = array("repro.php", "Repro page");
$index["search_docs/services.txt"] = array("services.php", "Services page");
$user_input = get_param("search", "get");
if($user_input != "" && $user_input != "Type search text here")
$found = search($user_input);
?>
IN THE HTML
<?
if($user_input != "" && $user_input != "Type search text here"){
?>
<span style="font-size:18px;">Search results for <span style="color:#01a4a6;">"<?=$user_input;?>"</span></span><br/><br/>
<?
if(count($found) == 0)
{?>
No results found
<?}
else{
foreach($found as $i => $v)
echo "<a href='".$index[$v][0]."'>".$index[$v][1]."</a><br/>";
}
}
else{?>
Please enter text in the search box and press enter
<?}?>