<?PHP
$intTimeBegan = time();
unset($debug);
require("search.inc");?>
<HTML lang="en-us">
<?PHP
?>
<HEAD>
<TITLE>
Simple Web Search for &quot;<?PHP print $words;?>&quot;
</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META name="robots" content="index,nofollow">
<META name="description" content="Simple Web Search!">
<LINK href="<?php print $strStyleName ?>" rel="stylesheet" type="text/css" title="Simple Search Style">
</HEAD>
<BODY>
<h2>Simple Web Search</h2>
<div class="cool" style="text-align: center;">
<form method="POST" action="<?php print $strSelf ?>">
<table style="Width: 40%;" class="panel">
<tr>
<td style="Vertical-Align: Middle; Text-Align: Center;" colspan="2">Search for
<input type="hidden" name="do" value="now">
<input type="text" size="25" name="words" value="<?PHP print $words;?>">
<?PHP
if (isset ($strSearchSiteKey)) {
$strSearchSiteIndex = $arySearchSiteIndices[chop($strSearchSiteKey)];
} else {
reset ($arySearchSiteIndices);
list( $dummy, $strSearchSiteIndex ) = each( $arySearchSiteIndices );
if (count($arySearchSiteIndices) == 1) {
$strSearchSiteKey = $dummy;
}
}
// Print out available Site Indices to select field.
if (count($arySearchSiteIndices) > 1) {
echo "<select name=\"strSearchSiteKey\">\n";
reset ($arySearchSiteIndices);
while (list($key,$val) = each( $arySearchSiteIndices ) ) {
if ($strSearchSiteKey == $key) { echo "\t<option selected>".stripslashes($key)."\n"; }
else {echo "\t<option>".stripslashes($key)."\n"; }
}
echo "</select>\n";
};
// Print out available Max Hits to select field.
if (count($aryMaxHits) > 1) {
echo "<select name=\"intMaxHits\">\n";
$m = 0;
while($aryMaxHits[$m]) {
if ($intMaxHits == $aryMaxHits[$m]) { echo "\t<option selected>$intMaxHits\n"; }
else { echo "\t<option>$aryMaxHits[$m]\n"; }
$m++ ;
};
echo "</select>\n";
} else {
$intMaxHits = $aryMaxHits[0];
};
// Make sure MaxHits is larger than returned results.
$intMaxHitsOffset = $intPageOffset + $intMaxHits;
?>
<input type="submit" value="Find It!">
</td>
</tr>
<tr>
<td colspan="2">
<div style="Font-Size: 10pt; Font-Family: Verdana, Arial, Serif;">Ttest
from Saman</div>
</td>
</tr>
<?PHP
// Determine if we want to use [t] limiting code.
if ($intUseLimits) {
?>
<tr>
<td>Limit Search:
</td>
<td style="Vertical-Align: Middle; Text-Align: Center;">
<?PHP
// Lump all of the [t] delimiters together in preparation for the commandline.
// $strLimit is, also, used to determine if a box is checked.
If (is_array($aryLimits)){$strLimit = implode($aryLimits, "");};
// Print out Search delimiters to checkbox fields.
reset ($arySearchDelimiter);
while (list($key,$val) = each($arySearchDelimiter)) {
echo "\t\t<INPUT type=\"checkbox\" name=\"aryLimits[]\" value=\"$val\"";
if (strstr($strLimit,$val)){
print " checked"; }
echo ">$key\n";
};
// Setup Limit code
if ($strLimit != ""){
$strLimitLine = "-t $strLimit";
} else {
$strLimitLine = "";
};
print "</TD></TR>\n";
}; // EndIf intUseLimits
?>
</table>
</form>
</div>
<?PHP
// Why waste time and resources if they haven't performed a search?
If($do != "now") {fncPrintFooter();};
?><h2 class="indexed">Searching for
<q lang="UTF-7">
<?PHP print "$words";?></q>:</h2>
<?PHP
/* Added DN: Adds last updated time of index November 17, 1999 */
print "<p class=\"updated\">Index of <em>" . ereg_replace("_", " ", stripslashes($strSearchSiteKey)) ."</em> last updated on " . date("D, M jS, Y H:i:s", filemtime($strSearchSiteIndex)) . "</p>";
/* Bug Fix JB: Parenthesis July 13, 1998
**
** $words = str_replace('\(','(',str_replace('\)',')',str_replace('\*','*',escapeshellcmd($words))));
**
**
** Bug Fix JB: Fixes parenthesis fix July 14, 1998
** $words = '"'.str_replace('\(','(',str_replace('\)',')',str_replace('\*','*',escapeshellcmd($words).' '))).'"';
**
*/
$words = '"'.chop(str_replace('\(','(',str_replace('\)',')',str_replace('\*','*',escapeshellcmd($words).' ')))).'"';
$strCommandLine = $strSearchEngine.escapeshellcmd(" -m $intMaxHitsOffset -f $strSearchSiteIndex $strLimitLine -w ").$words;
fncDebug("CommandLine", $strCommandLine, 1);
// Must find a better error message, possibly fix the HTML as well.
exec($strCommandLine, $aryResults, $return);
if( $return != 0 ) fncPrintFooter("<H3>Error performing search!</H3>\n<DL>\n\t<DT>Administrator\n\t\t<DD>Execution
of the command failed. Please check the search.conf file. Make sure there
are no special characters in the index array.</DL>");
// Jump out to HTML and set the table...
/************************************/
$i=0;
while(substr($aryResults[$i],0,1) == "#" || substr($aryResults[$i],0,3) == "err" && $i < 50):
$strResultsClean = $aryResults[$i];
// Correct for offset caused by SWISH-E Comments.
$intPageOffsetCorrect++;
//Explodes the Comment into an array
$aryComment = Explode(": ", strstr($strResultsClean, " "));
fncDebug($aryComment[0], $aryComment[1], 2);
// Print number of results
If (trim($aryComment[0]) == "Number of hits") {
$intNumHits = trim($aryComment[1]);
if ($intNumHits > 0) {
if ($intNumHits >= $intMaxHits) {
//Print 0 as 1
If($intPageOffset == 0){$intPageOffsetOne = $intPageOffset + 1;}
Else{$intPageOffsetOne = $intPageOffset;};
// What is the result number of the last document
If ($intNumHits > $intMaxHitsOffset){$intPageHitsThru = $intMaxHitsOffset;}
Else {$intPageHitsThru = $intNumHits;};
// At which results am I looking
echo "Displaying $intPageOffsetOne through $intPageHitsThru of $intNumHits results.<BR>\n\n";
print "<DL class=\"result\">\n";
} else {
// If in the off chance it is a small result, under MaxHits.
print "$intNumHits results found.<BR>\n\n";
print "<DL class=\"result\">\n";
};
};
};
// Soundex Yes or ...
If (trim($aryComment[0]) == "Soundex Applied") {
if (trim($aryComment[1]) == "1"){
print"<dl><dt>Note:<dd>Resulting matches are sound-alikes according to <a href=\"http://www.nara.gov/genealogy/coding.html\">US Census SoundEx codes</a>.</dl>";
};
};
// Stemming yes or ...
If (trim($aryComment[0]) == "Stemming Applied") {
if (trim($aryComment[1]) == "1"){
print"<dl><dt>Note:<dd>Resulting matches are based on stems of the words in your query. A search for 'testing' will return matches for 'testing', 'tested', 'test', etc.</dl>";
};
};
// Set the strBaseURL if it isn't in the config already.
If (trim($aryComment[0]) == "Pointer" && !isset($strBaseURL)){
$strBaseURL = trim($aryComment[1]);
fncDebug("URL Pointer",$strBaseURL, 3);
};
fncDebug("strResultsClean", $strResultsClean, 3);
// Crappy No Results "err:" handling. Will be fixed someday, maybe...
if(substr($strResultsClean,0,3) == "err"){
print "<H3>No match for your search!</H3>\n";
print "<P>\n\t<STRONG>User:</STRONG> Please try adjusting the search criteria and/or changing the words.\n</P>";
};
$i++;
endwhile;
/******************************************/
$i = $intPageOffset + $intPageOffsetCorrect;
while(substr($aryResults[$i],0,1) != "#" && substr($aryResults[$i],0,3) != "err" && $aryResults[$i] != "" && $aryResults[$i] != "." && $i <= $intPageOffset + $intPageOffsetCorrect + $intMaxHits):
$strResultsClean = $aryResults[$i];
// if (substr($strResultsClean,0,1) != "#" && substr($strResultsClean,0,3) != "err"){
// if (!ereg("^#.*",$strResultsClean) && !ereg("^e.*",$strResultsClean) && $i >= $intPageOffset){
//$strResultsClean String Format:
// <RANK> <URL> "<TITLE>" <SIZE>
// Array exploded on Double-Quote ("):
// [RANK URL :0][TITLE:1][ SIZE:2]
/* Take note of evil whitespace in the array values,
** which must be trimmed later.*/
$aryResultLine = explode("\"", $strResultsClean);
$j=0;
while($aryResultLine[$j]):
// Find the position, from begin, of the first space, then:
// Rank is everything from begin to the first space trimming whitespace.
$intResultRank = trim(substr($aryResultLine[0], 0, strpos($aryResultLine[0]," ")));
/* URL everything following first space trimming whitespace.
** Assuming file is under the DOCUMENT_ROOT directory somewhere.
** If not, the file may not be found via HTTP... However,
** if the indexer is configured correctly this is a
** waste of time. Too easy of a mistake to ignore, though. */
// $strResultURL = trim(strstr($aryResultLine[0]," "));
$strResultURL = ereg_replace($strSiteRootDir, "", trim(strstr($aryResultLine[0]," ")));
// The rest is a piece of cake...
if(trim($aryResultLine[1])){
$strResultTitle = trim($aryResultLine[1]);
}else {
$strResultTitle = $strResultURL;
};
$intResultBytes = trim($aryResultLine[2]);
// Attempt to grab data from each file
if (count($aryMetaList) > 0) {
unset($aryMetaTags);
$strCurrentFile = $strSiteRootDir.$strResultURL ;
if (file_exists($strCurrentFile) && $intGetFileData > 0) {
// Get the META tags from the file
$aryMetaTags = get_meta_tags($strCurrentFile);
// Get the modification date stored in the file system
$strResultModDate = gmdate("\M\o\d\i\f\i\e\d \a\\t H:i:s, \o\\n M d, Y \G\M\T", filemtime($strCurrentFile));
// $aryMetaTags = get_meta_tags("/www/share/apache/htdocs/test/test.html");
}
}
$j++;
endwhile;
print "\t<DT><A href=\"$strBaseURL$strResultURL\">$strResultTitle</A>\n";
print "\t<DD>\n";
fncDebug("Current File", $strCurrentFile, 4);
reset ($aryMetaList);
$p = 0;
while($aryMetaList[$p]) {
list ($strMetaName, $strLineHeading) = explode("|",$aryMetaList[$p]);
if ($aryMetaTags["$strMetaName"]){print "\t\t$strLineHeading".$aryMetaTags["$strMetaName"]."<BR>\n";}
$p++;
};
print "\t\t<SPAN style=\"Font-Size: 75%; Font-Weight:900;\">Score: $intResultRank, Size: $intResultBytes Bytes, $strResultModDate</SPAN><P>\n";
$i++;
endwhile;
If ($intNumHits > 0) {print "</DL>\n";}
// Print out the Previous and Next buttons
If ($intNumHits > $intMaxHits) {
print "<TABLE>\n<TR>\n";
If ($intMaxHits < $intMaxHitsOffset){
print "\t<TD>\n";
$intPrevVal = $intMaxHitsOffset - (2 * $intMaxHits);
print "\t<FORM action=\"$strSelf\" method=\"POST\" name=\"frmPrev\">\n";
print "\t\t<INPUT type=\"HIDDEN\" name=\"do\" value=\"now\">\n";
/*
** Bug Fix JB: Parenthesis July 13, 1999
** print "\t\t<INPUT type=\"HIDDEN\" name=\"words\" value=\"". stripslashes($words) ."\">\n";
*/
print "\t\t<INPUT type=\"HIDDEN\" name=\"words\" value=\"".stripslashes(str_replace('"','',$words)) ."\">\n";
print "\t\t<INPUT type=\"HIDDEN\" name=\"strSearchSiteKey\" value=\"" . stripslashes($strSearchSiteKey) . "\">\n";
print "\t\t<INPUT type=\"HIDDEN\" name=\"intMaxHits\" value=\"$intMaxHits\">\n";
print "\t\t<INPUT type=\"HIDDEN\" name=\"intPageOffset\" value=\"$intPrevVal\">\n";
// Print out Search delimiters to hidden fields.
reset ($arySearchDelimiter);
while (list($key,$val) = each($arySearchDelimiter)) {
if (strstr($strLimit,$val)){print "\t\t<INPUT type=\"HIDDEN\" name=\"aryLimits[]\" value=\"$val\">\n";};
};
print "\t\t<INPUT type=\"SUBMIT\" name=\"prev$intMaxHits\" value=\"<< Previous $intMaxHits\">\n";
print "\t</FORM>\n";
print "\t</TD>\n";
};
If ($intNumHits > $intMaxHitsOffset){
if ( ( $intNumHits - $intPageHitsThru ) < $intMaxHits ) {
$intNextVal = ( $intNumHits - $intPageHitsThru );
} else {
$intNextVal = $intMaxHits ;
}
print "\t<TD>\n";
print "\t<FORM action=\"$strSelf\" method=\"POST\" name=\"frmNext\">\n";
print "\t\t<INPUT type=\"HIDDEN\" name=\"do\" value=\"now\">\n";
print "\t\t<INPUT type=\"HIDDEN\" name=\"words\" value=\"".stripslashes(str_replace('"','',$words)) ."\">\n";
print "\t\t<INPUT type=\"HIDDEN\" name=\"strSearchSiteKey\" value=\"" . stripslashes($strSearchSiteKey) . "\">\n";
print "\t\t<INPUT type=\"HIDDEN\" name=\"intMaxHits\" value=\"$intMaxHits\">\n";
print "\t\t<INPUT type=\"HIDDEN\" name=\"intPageOffset\" value=\"$intMaxHitsOffset\">\n";
// Print out Search delimiters to hidden fields.
reset ($arySearchDelimiter);
while (list($key,$val) = each($arySearchDelimiter)) {
if (strstr($strLimit,$val)){print "\t\t<INPUT type=\"HIDDEN\" name=\"aryLimits[]\" value=\"$val\">\n";};
};
print "\t\t<INPUT type=\"SUBMIT\" name=\"next$intNextVal\" value=\"Next $intNextVal >>\">\n";
print "\t</FORM>\n";
print "\t</TD>\n";
};
print "\t</TR>\n</TABLE>\n";
};
//Print the footer and exit
$intTimeComplete = time() - $intTimeBegan;
If ($intTimeComplete < 1){$intTimeComplete = "less than 1 second";}
Else {$intTimeComplete = $intTimeComplete." seconds";};
fncPrintFooter("<P>Search completed in $intTimeComplete.");
?>