00001 <?PHP $intTimeBegan = time(); unset($debug); require("search.inc");?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/DTD/HTML4-loose.dtd">
00002 <HTML lang="en-us">
00003 <?PHP
00004 00005 00006 00007
00008 ?>
00009 <HEAD>
00010 <TITLE>
00011 Simple Web Search for "<?PHP print $words;?>"
00012 </TITLE>
00013 <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
00014 <META name="robots" content="index,nofollow">
00015 <META name="description" content="Simple Web Search!">
00016 <LINK href="<?php print $strStyleName ?>" rel="stylesheet" type="text/css" title="Simple Search Style">
00017 </HEAD>
00018 <BODY>
00019 <h2>Simple Web Search</h2>
00020 <div class="cool" style="text-align: center;">
00021 <form method="POST" action="<?php print $strSelf ?>">
00022 <table style="Width: 40%;" class="panel">
00023 <tr>
00024 <td style="Vertical-Align: Middle; Text-Align: Center;" colspan="2">Search for
00025 <input type="hidden" name="do" value="now">
00026 <input type="text" size="25" name="words" value="<?PHP print $words;?>">
00027 <?PHP
00028 if (isset ($strSearchSiteKey)) {
00029 $strSearchSiteIndex = $arySearchSiteIndices[chop($strSearchSiteKey)];
00030 } else {
00031 reset ($arySearchSiteIndices);
00032 list( $dummy, $strSearchSiteIndex ) = each( $arySearchSiteIndices );
00033 if (count($arySearchSiteIndices) == 1) {
00034 $strSearchSiteKey = $dummy;
00035 }
00036 }
00037
00038
00039 if (count($arySearchSiteIndices) > 1) {
00040 echo "<select name=\"strSearchSiteKey\">\n";
00041 reset ($arySearchSiteIndices);
00042 while (list($key,$val) = each( $arySearchSiteIndices ) ) {
00043 if ($strSearchSiteKey == $key) { echo "\t<option selected>".stripslashes($key)."\n"; }
00044 else {echo "\t<option>".stripslashes($key)."\n"; }
00045 }
00046 echo "</select>\n";
00047 };
00048
00049
00050 if (count($aryMaxHits) > 1) {
00051 echo "<select name=\"intMaxHits\">\n";
00052 $m = 0;
00053 while($aryMaxHits[$m]) {
00054 if ($intMaxHits == $aryMaxHits[$m]) { echo "\t<option selected>$intMaxHits\n"; }
00055 else { echo "\t<option>$aryMaxHits[$m]\n"; }
00056 $m++ ;
00057 };
00058 echo "</select>\n";
00059 } else {
00060 $intMaxHits = $aryMaxHits[0];
00061 };
00062
00063
00064 $intMaxHitsOffset = $intPageOffset + $intMaxHits;
00065
00066 ?>
00067 <input type="submit" value="Find It!">
00068 </td>
00069 </tr>
00070 <tr>
00071 <td colspan="2">
00072 <div style="Font-Size: 10pt; Font-Family: Verdana, Arial, Serif;">This <a
00073 href="http://sunsite.berkeley.edu/SWISH-E/">SWISH-E
00074 2.0</a> based
00075 search will honor boolean (AND OR NOT), parentheses(), and wild-card*
00076 stemming queries. Examples: <em>john and doe or jane</em>, <em>john and (doe or
00077 jane)</em>, <em>not (john or jane) and doe</em>, <em>j* and doe</em>
00078 </div>
00079 </td>
00080 </tr>
00081 <?PHP
00082
00083 if ($intUseLimits) {
00084 ?>
00085 <tr>
00086 <td>Limit Search:
00087 </td>
00088 <td style="Vertical-Align: Middle; Text-Align: Center;">
00089 <?PHP
00090
00091
00092
00093 If (is_array($aryLimits)){$strLimit = implode($aryLimits, "");};
00094
00095
00096 reset ($arySearchDelimiter);
00097 while (list($key,$val) = each($arySearchDelimiter)) {
00098 echo "\t\t<INPUT type=\"checkbox\" name=\"aryLimits[]\" value=\"$val\"";
00099 if (strstr($strLimit,$val)){
00100 print " checked"; }
00101 echo ">$key\n";
00102 };
00103
00104
00105 if ($strLimit != ""){
00106 $strLimitLine = "-t $strLimit";
00107 } else {
00108 $strLimitLine = "";
00109 };
00110 print "</TD></TR>\n";
00111 };
00112
00113 ?>
00114 </table>
00115 </form>
00116 </div>
00117 <?PHP
00118
00119 If($do != "now") {fncPrintFooter();};
00120 ?><h2 class="indexed">Searching for
00121 <q lang="UTF-7">
00122 <?PHP print "$words";?></q>:</h2>
00123 <?PHP
00124
00125
00126 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>";
00127
00128 00129 00130 00131 00132 00133 00134 00135 00136
00137
00138 $words = '"'.chop(str_replace('\(','(',str_replace('\)',')',str_replace('\*','*',escapeshellcmd($words).' ')))).'"';
00139
00140
00141 $strCommandLine = $strSearchEngine.escapeshellcmd(" -m $intMaxHitsOffset -f $strSearchSiteIndex $strLimitLine -w ").$words;
00142
00143 fncDebug("CommandLine", $strCommandLine, 1);
00144
00145
00146 Exec($strCommandLine, $aryResults, $return) or fncPrintFooter("<H3>Error performing search!</H3>\n<DL>\n\t<DT>Administrator\n\t\t<DD>Please check System-Specific variables defined at the beginning of the script.</DL>");
00147
00148
00149
00150 $i=0;
00151 while(substr($aryResults[$i],0,1) == "#" || substr($aryResults[$i],0,3) == "err" && $i < 50):
00152 $strResultsClean = $aryResults[$i];
00153
00154 $intPageOffsetCorrect++;
00155
00156 $aryComment = Explode(": ", strstr($strResultsClean, " "));
00157 fncDebug($aryComment[0], $aryComment[1], 2);
00158
00159
00160 If (trim($aryComment[0]) == "Number of hits") {
00161 $intNumHits = trim($aryComment[1]);
00162 if ($intNumHits > 0) {
00163 if ($intNumHits >= $intMaxHits) {
00164
00165
00166 If($intPageOffset == 0){$intPageOffsetOne = $intPageOffset + 1;}
00167 Else{$intPageOffsetOne = $intPageOffset;};
00168
00169
00170 If ($intNumHits > $intMaxHitsOffset){$intPageHitsThru = $intMaxHitsOffset;}
00171 Else {$intPageHitsThru = $intNumHits;};
00172
00173
00174 echo "Displaying $intPageOffsetOne through $intPageHitsThru of $intNumHits results.<BR>\n\n";
00175 print "<DL class=\"result\">\n";
00176 } else {
00177
00178 print "$intNumHits results found.<BR>\n\n";
00179 print "<DL class=\"result\">\n";
00180 };
00181 };
00182 };
00183
00184 If (trim($aryComment[0]) == "Soundex Applied") {
00185 if (trim($aryComment[1]) == "1"){
00186 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>";
00187 };
00188 };
00189
00190 If (trim($aryComment[0]) == "Stemming Applied") {
00191 if (trim($aryComment[1]) == "1"){
00192 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>";
00193 };
00194 };
00195
00196 If (trim($aryComment[0]) == "Pointer" && !isset($strBaseURL)){
00197 $strBaseURL = trim($aryComment[1]);
00198 fncDebug("URL Pointer",$strBaseURL, 3);
00199 };
00200 fncDebug("strResultsClean", $strResultsClean, 3);
00201
00202
00203 if(substr($strResultsClean,0,3) == "err"){
00204 print "<H3>No match for your search!</H3>\n";
00205 print "<P>\n\t<STRONG>User:</STRONG> Please try adjusting the search criteria and/or changing the words.\n</P>";
00206 };
00207
00208 $i++;
00209 endwhile;
00210
00211
00212 $i = $intPageOffset + $intPageOffsetCorrect;
00213 while(substr($aryResults[$i],0,1) != "#" && substr($aryResults[$i],0,3) != "err" && $aryResults[$i] != "" && $aryResults[$i] != "." && $i <= $intPageOffset + $intPageOffsetCorrect + $intMaxHits):
00214
00215 $strResultsClean = $aryResults[$i];
00216
00217
00218
00219
00220
00221
00222
00223
00224 00225
00226 $aryResultLine = explode("\"", $strResultsClean);
00227
00228 $j=0;
00229 while($aryResultLine[$j]):
00230
00231
00232 $intResultRank = trim(substr($aryResultLine[0], 0, strpos($aryResultLine[0]," ")));
00233
00234 00235 00236 00237 00238
00239
00240
00241 $strResultURL = ereg_replace($strSiteRootDir, "", trim(strstr($aryResultLine[0]," ")));
00242
00243
00244
00245 if(trim($aryResultLine[1])){
00246 $strResultTitle = trim($aryResultLine[1]);
00247 }else {
00248 $strResultTitle = $strResultURL;
00249 };
00250 $intResultBytes = trim($aryResultLine[2]);
00251
00252
00253 if (count($aryMetaList) > 0) {
00254 unset($aryMetaTags);
00255 $strCurrentFile = $strSiteRootDir.$strResultURL ;
00256 if (file_exists($strCurrentFile) && $intGetFileData > 0) {
00257
00258 $aryMetaTags = get_meta_tags($strCurrentFile);
00259
00260 $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));
00261
00262 }
00263 }
00264 00265 00266
00267 $j++;
00268 endwhile;
00269
00270 print "\t<DT><A href=\"$strBaseURL$strResultURL\">$strResultTitle</A>\n";
00271 print "\t<DD>\n";
00272 fncDebug("Current File", $strCurrentFile, 4);
00273 reset ($aryMetaList);
00274 $p = 0;
00275 while($aryMetaList[$p]) {
00276 list ($strMetaName, $strLineHeading) = explode("|",$aryMetaList[$p]);
00277 if ($aryMetaTags["$strMetaName"]){print "\t\t$strLineHeading".$aryMetaTags["$strMetaName"]."<BR>\n";}
00278 $p++;
00279 };
00280 print "\t\t<SPAN style=\"Font-Size: 75%; Font-Weight:900;\">Score: $intResultRank, Size: $intResultBytes Bytes, $strResultModDate</SPAN><P>\n";
00281 $i++;
00282 endwhile;
00283
00284 If ($intNumHits > 0) {print "</DL>\n";}
00285
00286
00287 If ($intNumHits > $intMaxHits) {
00288 print "<TABLE>\n<TR>\n";
00289 If ($intMaxHits < $intMaxHitsOffset){
00290 print "\t<TD>\n";
00291 $intPrevVal = $intMaxHitsOffset - (2 * $intMaxHits);
00292 print "\t<FORM action=\"$strSelf\" method=\"POST\" name=\"frmPrev\">\n";
00293 print "\t\t<INPUT type=\"HIDDEN\" name=\"do\" value=\"now\">\n";
00294 00295 00296 00297
00298 print "\t\t<INPUT type=\"HIDDEN\" name=\"words\" value=\"".stripslashes(str_replace('"','',$words)) ."\">\n";
00299 print "\t\t<INPUT type=\"HIDDEN\" name=\"strSearchSiteKey\" value=\"" . stripslashes($strSearchSiteKey) . "\">\n";
00300 print "\t\t<INPUT type=\"HIDDEN\" name=\"intMaxHits\" value=\"$intMaxHits\">\n";
00301 print "\t\t<INPUT type=\"HIDDEN\" name=\"intPageOffset\" value=\"$intPrevVal\">\n";
00302
00303 reset ($arySearchDelimiter);
00304 while (list($key,$val) = each($arySearchDelimiter)) {
00305 if (strstr($strLimit,$val)){print "\t\t<INPUT type=\"HIDDEN\" name=\"aryLimits[]\" value=\"$val\">\n";};
00306 };
00307 print "\t\t<INPUT type=\"SUBMIT\" name=\"prev$intMaxHits\" value=\"<< Previous $intMaxHits\">\n";
00308 print "\t</FORM>\n";
00309 print "\t</TD>\n";
00310 };
00311
00312 If ($intNumHits > $intMaxHitsOffset){
00313 if ( ( $intNumHits - $intPageHitsThru ) < $intMaxHits ) {
00314 $intNextVal = ( $intNumHits - $intPageHitsThru );
00315 } else {
00316 $intNextVal = $intMaxHits ;
00317 }
00318 print "\t<TD>\n";
00319 print "\t<FORM action=\"$strSelf\" method=\"POST\" name=\"frmNext\">\n";
00320 print "\t\t<INPUT type=\"HIDDEN\" name=\"do\" value=\"now\">\n";
00321 00322 00323 00324
00325 print "\t\t<INPUT type=\"HIDDEN\" name=\"words\" value=\"".stripslashes(str_replace('"','',$words)) ."\">\n";
00326 print "\t\t<INPUT type=\"HIDDEN\" name=\"strSearchSiteKey\" value=\"" . stripslashes($strSearchSiteKey) . "\">\n";
00327 print "\t\t<INPUT type=\"HIDDEN\" name=\"intMaxHits\" value=\"$intMaxHits\">\n";
00328 print "\t\t<INPUT type=\"HIDDEN\" name=\"intPageOffset\" value=\"$intMaxHitsOffset\">\n";
00329
00330 reset ($arySearchDelimiter);
00331 while (list($key,$val) = each($arySearchDelimiter)) {
00332 if (strstr($strLimit,$val)){print "\t\t<INPUT type=\"HIDDEN\" name=\"aryLimits[]\" value=\"$val\">\n";};
00333 };
00334 print "\t\t<INPUT type=\"SUBMIT\" name=\"next$intNextVal\" value=\"Next $intNextVal >>\">\n";
00335 print "\t</FORM>\n";
00336 print "\t</TD>\n";
00337 };
00338 print "\t</TR>\n</TABLE>\n";
00339 };
00340
00341 $intTimeComplete = time() - $intTimeBegan;
00342 If ($intTimeComplete < 1){$intTimeComplete = "less than 1 second";}
00343 Else {$intTimeComplete = $intTimeComplete." seconds";};
00344 fncPrintFooter("<P>Search completed in $intTimeComplete.");
00345 ?>