for eg. if I search for the keywords <tax rate> separated by a delimiter ' ' it should show all pages that have the tax separately, rate separately as well as the combination of tax and rate in them. Can anyone help me on this. I know i am doing something really stupid. Please advise.
the code is
Code: Select all
$search_term = explode(' ', $string); // explode info
$num_keywords = count($search_term);
function search_dir () {
global $cur_path, $dir_depth, $matches;
if ($matches > 100) { return; }
$s_dir="rfp";
for ($c=0; $c<=$dir_depth; $c++) { $s_dir .= $cur_path[$c]; }
$dhandle=opendir("$s_dir");
while ($file = readdir($dhandle)) {
if (($file!=".") && ($file!="..")) {
if (is_file($s_dir.$file)) {
$file_ext = substr($file, strlen($file)-3, 3);
if ($file_ext == "php") search_file($s_dir.$file);
}
elseif (is_dir($s_dir.$file)) {
$cur_path[++$dir_depth] = ($file."/");
search_dir();
$dir_depth--;
}
}
}
}
function search_file ($file) {
global $cur_path, $dir_depth, $results, $r_text, $r_title, $matches, $search_term;
$s_dir="rfp";
for ($c=0; $c<=$dir_depth; $c++) $s_dir .= $cur_path[$c];
$f_size = filesize($file);
$f_handle = fopen($file, "r");
$f_data = fread($f_handle, $f_size);
if ($text = strstr($f_data, 'SSIGNORE')) return;
$f_dlc = strtolower($f_data);
$t_text = "";
$in_tag = 0;
if ($text = strstr(strip_tags($f_dlc), $search_term[$i])) {
$results[$matches] = $file;
$text = substr($text, 0, 200);
$text = str_replace ($search_term[$i], "<font color="#127A84"><b>".$search_term[$i]. "</b></font>", $text);
$r_text [$matches] = "...". $text. "...";
$t_start = strpos ($f_dlc, "<title>") + 7;
$t_end = strpos ($f_dlc, "</title>");
$r_title[$matches++] = substr($f_data, $t_start, $t_end-$t_start);
}
fclose($f_handle);
}
search_dir ();
for ($i=0; $i<$num_keywords; $i++){
echo $search_term[$i];
search_file ($file);<tr>
Code: Select all
$dir_depth=0;
$matches=0;
$cur_path = array("/");
$results = array("");
$r_text = array("");
$r_title = array("");
$search_term[$i]=strtolower($search_term[$i]);
if (strcmp($search_term[$i], "")!=0) { search_dir(); }
}
$c="#ffffff";
for ($a=0; $a<$matches; $a++) {
if ($c=="#ffffff") {$c="#ffffff";} else {$c="#ffffff";}
echo "<tr><td class="a" align="center" bgcolor="$c">";
echo "<a class="five" href="$results[$a]" title="Go To This Page"><font color="#127A84">$r_title[$a]</font></a>";
// echo "<br> <code>$results[$a]</code>";
echo "</td><td class="a" align="left" bgcolor="$c">$r_text[$a]</td></tr>";
}
echo "</table><br><p>$matches Matches.<br><br>";