PHP Classes

File: search.php

Recommend this page to a friend!
  Classes of Eduardo Baldan dos Santos   Ape Search!!   search.php   Download  
File: search.php
Role: Example script
Content type: text/plain
Description: Performs the search
Class: Ape Search!!
A non-index page search
Author: By
Last change: Verify if any page was found
Date: 21 years ago
Size: 2,306 bytes
 

Contents

Class file image Download
<? include("./_classSearch.php"); ?>

<form name=search action="" method=post>
<table cellpadding=2 cellspacing=2>
  <tr>
    <td>
      <font face=Arial>Keyword: </font>
    </td>
    <td>
      <input type=text name=keyword value="<?=$keyword?>">
    </td>
  </tr>
  <tr>
    <td colspan=2 align=right>
       <input type=submit value="Search">
    </td>
  </tr>
</table>
</form>

<?

if($keyword) {
   
$search = new search();
   
   
# Set a message when the user does not fill the field, (the class already has a default msg)
   
$search->emptySearch = "ENTER A WORD!!!";
   
   
# Set a message when the keyword is not found, (the class already has a default msg)
   
$search->notFound = "Sorry, no pages with your keyword";
   
   
# Set the path ( if not set the class assumes the actual dir )
   
$search->path = "./";
   
   
# set the file-extensions that you want to look ( if not set , the class assumes all of them ( included images =O( ) )
   
$search->ext = array("html","htm","php","php3","php4","txt");
   
   
# set the directories you DON'T want to look
   
$search->excDir = array("admin","db");
   
   
# performs the search ( returns an array with PageName, WebPath, ModifyDate, FileSize(bytes) )
   
$result = $search->Find($keyword);
   
   
# gets the count of the items
   
$total = $search->totalRes;

   
# gets the searchtime in seconds
   
$stime = $search->searchTime;
   
   
?>

    <? if(is_array($result)) { ?>
<br><br><font face=arial> <b>The search tooks <?=$stime?> seconds</b> <br>
        Found <?=$total?> items</font><br><br>
        <table cellpadding=2 cellspacing=2 bgcolor=#000000>
            <tr bgcolor=#FFFFFF>
                <td bgcolor=#000000>
                    <Font color=#FFFFFF face=Arial><b>File Name</b></font>
                </td>
                <td bgcolor=#000000>
                    <Font color=#FFFFFF face=Arial><b>Link</b></font>
                </td>
                <td bgcolor=#000000>
                    <Font color=#FFFFFF face=Arial><b>Date</b></font>
                </td>
                <td bgcolor=#000000>
                    <Font color=#FFFFFF face=Arial><b>Size</b></font>
                </td>
            </tr>
        <? foreach($result as $item) { ?>
<tr>
             <? foreach($item as $field) { ?>
<td bgcolor=#FFFFFF>
                    <font face=arial><?=$field?></font>
                </td>
             <? } ?>
</tr>
        <? } ?>
</table>
    <? } else { ?>
<font face=arial><?=$search->notFound?></font>
    <? } ?>
<?
} ?>