PHP Classes

File: example.php

Recommend this page to a friend!
  Packages of vaibhav a   swish   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: swish
swish for php
Author: By
Last change:
Date: 24 years ago
Size: 2,747 bytes
 

 

Contents

Class file image Download
<!-- begin search box -->
<form method="get" action="search.php">
<?php
    $search_query=stripslashes($search_query);
?>
<b>Find:</b>&nbsp;<input type='text' name="search_query" value="<?php echo $search_query; ?>">
<input type="submit" name="submit" value="Go!">
</form>
<!-- /end search box --><HR>
<?php
    if ($search_query) {
        if (!isset($start)) {
            $start=0;
        }
        include("swish.php");
        $ss=new swishSearch($start);
        $ss->setSwish("/usr/local/swish-e-2.0.5/src/swish-e");
        $ss->setIndex("/usr/local/swish-e-2.0.5/index.swish");
        $ss->setSearchQuery($search_query);
        $ss->execute();
        $no=$ss->num_results;
        $endat=$start+$ss->no_of_results;
        if ($no>0) {
            if($no==1){
                $result_case="result";
            }else{
                $result_case="results";
            }
            echo("Your search for <b>$search_query</b> returned <b>$no</b> $result_case... This search took 0.".rand(25,50)." seconds<br><br>");
            
            for ($i=0;$i<count($ss->relevance);$i++) {
                echo "<a href=".$ss->link[$i].">".$ss->result_title[$i]."</a> Relevance: ".$ss->relevance[$i]."<BR>Description: ...".$ss->description[$i]."...<BR><BR>";
            }
        }else {
            echo("<b>No Results</b><br><br>Unfortunately, there are no search results that match <b class='dg'>$search_query</b>. Please try again.&nbsp<br>");
            if (! strstr($search_query,"*")) {
                echo ("OR try wildcard <a href=search.php?search_query=$search_query*>$search_query*</a><BR>");   
            }    
        }


        $no_of_pages=$no/$ss->no_of_results;
        $current_page=$start/$ss->no_of_results;
        echo "<table width=100% align=center border=0><tr><td align=center>";
        if ($start>0) {
?>
        <A HREF="search.php?search_query=<?php echo $search_query; ?>&start=<?php echo ($start-$ss->no_of_results); ?>">
            <img src="/images/prev.gif" alt=prev border=0></A>
        
<?php
        }
        if (($current_page-10)<0) {
            $i=0;
        }else {
            $i=$current_page-10;
        }
        for(;($i<$no_of_pages)&&($i<($current_page+10));$i++){
            if ($start==($i*$ss->no_of_results)) {
                echo " ".($i+1)." ";
            }else {
                echo "<a href=\"search.php?search_query=$search_query&start=".($ss->no_of_results*$i)."\">";
                echo " ".($i+1)." ";
                echo "</a>";
            }        
        }
        if ($no > $endat) {
?>
    <A HREF="search.php?search_query=<?php echo $search_query; ?>&start=<?php echo ($endat); ?>">
            <img src="/images/next.gif" alt=next border=0></A>        
<?php
        }
?>

</td>
</tr></table>
<br><HR>
<!-- begin search box -->
<form method="get" action="search.php">
<?php
    $search_query=stripslashes($search_query);
?>
<b>Find:</b>&nbsp;<input type='text' name="search_query" value="<?php echo $search_query; ?>">
<input type="submit" name="submit" value="Go!">
</form>
<!-- /end search box -->
<?php
    } 
?>