=========================================
search.php frontend for UdmSearch engine
=========================================

This is a stable version.

Main features are:
-----------------
* ispell support. Can load ispell data both from database
  (as udmsearch 2.x does) and from plain text (as 3.x versions)
* MySQL, Oracle (both v7 and v8), PostgreSQL backend support 
*    both in native and ODBC modes
* "crc" and "crc-multi" storage table modes support
* Multi-dict and Single-dict storage table modes
* boolean query language support
* best documents are found first
* HTML templates to easily customize search results
* Multiple output formats for search results support
* PHP4 compatibility
* MS Windows compatibility


Reqirements:
------------
search.php requires PHP 3.0.9 or later built with perl-compatible
regular expressions and MySQL and/or Oracle and/or PostgreSQL support.
Frontend successfully tested with PHP4 and with Microsoft Windows.

Files:
------
Makefile	       - Makefile for building some support binaries
crc32.c	       	       - C source code for building crc32 binary file
search.php             - main PHP script
config.inc             - include file for search.php with configuration part
common.inc             - include file for search.php with common functions
crc32.inc              - include file for search.php with crc32 functions
db_func.inc            - include file for search.php with databases interface
init.inc               - include file for search.php with init functions
ispell.inc             - include file for search.php with ispell interface
parse.inc              - include file for search.php with query parsing functions
template.inc           - include file for search.php with template functions
search.htm.mysql       - template for MySQL in single mode in native mode (without ispell support)
search.htm.mysql.odbc  - template for MySQL in single mode in ODBC mode (without ispell support)
search.htm.ora.crc     - template for Oracle in "crc" mode (with ispell support in text mode)
search.htm.pgsql.multi - template for Postgres in "multi-dict" mode (with ispell support in db mode)

How do I use it?
----------------

1. Copy all distribution files into one directory.
2. Edit config.inc settings at the beginning of the script:

     $template_file='/path/to/search.htm';  // path to template file
   
     $grep='/bin/grep';                     // path to grep utility
     $crc32='./crc32';			    // paty to crc32 utility (see below)

     $DEBUG=0;				    // set to 1 if you want to see all sql-queries sent to backent
     $MAX_NP=1000;                          // maximum allowed results page number
     $MAX_PS=100;                           // maximum allowed results per page
     
     $LC_ALL='ru_RU.KOI8-R';     	    // (optional) define it if you with to hardcode locate settings. 
     
     $DEFAULT_QUERY_TYPE='and';             // (optional) default query type. 
                                            // Possible values : "and", "or" 
					    // Default value - "and". This can be reassigned via search template.

     $dbodbc_cursor_type=SQL_CUR_USE_IF_NEEDED; // (optional) odbc cursor type. Use if your ODBC driver fails to work.
						// Possible values are: SQL_CUR_USE_IF_NEEDED, SQL_CUR_USE_ODBC,
						//                      SQL_CUR_USE_DRIVER, SQL_CUR_DEFAULT 

3. Edit search.htm. Php frontend adds several additional variables to standart
   template file.
   
   DBAddr <URL-style database description>
   Database options (type, host, database name, port, user and password) 
   to connect to SQL database.
   Should be used only once and before any other commands.
   Command have global effect for whole config file.
   Format: DBAddr <DBType>:[//DBUser[:DBPass]@DBHost[:DBPort]]/DBName/

   DBType describes your sql-frontend. Currently supported "oracle",
   "oracle7", "oracle8", "mysql" and "pgsql" types. "oracle" is a 
   synonym for "oracle8". If you wish to use this backends in ODBC
   mode you should add "-odbc" to DBType. For example to use mysql
   in ODBC mode you should set DBType to "mysql-odbc".

   DBMode used to set your dict table structure. For multi-dict mode you
   should use DBMode multi, for "crc" mode please use DBMode crc,
   for "crl-multi" mode please use DBMode crc-multi,  otherwise you 
   should set it to "single". In ODBC mode DBName used as DSN name.
   
   If you are using "crc" or "crc-multi" table mode, you should also 
   compile crc32 binary. Distribution contains Makefile to do that. 
   Run make at command prompt to begin compilation. If success, you 
   should get "crc32" binary file. 
   
   Clones variable values can be "yes" or "no". Default is "yes".
   "Yes" means that frontend should show clones of pages found. 

   IspellMode activates ispell support. Can be "text","db" or "none".
   Default - "none". NOTE, that before using ispell in "db" mode you
   should load ispell file into database (please refer to udmsearch v2.x).

   If you decided to use "text" mode you should specify additional
   variables:

   Affix <lang> <ispell affixes file name>
   Spell <lang> <ispell dictionary filename>

   The first parameter of both commands is two letters language abbrevation.
   The second one is filename. File name are relative to search.php directory.
   Absolute paths can be also specified.

   Note that loading of several languages is supported at the same time.

   For example,

   Affix en en.aff
   Spell en en.dict
   Addix de de.aff
   Spell de de.dict

   will load ispell support for both English anf German languages.

   Examples of variable section of template:

   a) mysql/single mode (without ispell support):
      <!--variables
      DBAddr    mysql://udm:udm@localhost/udmsearch/
      DBMode    single
      IspellMode none
      -->
   b) oracle/crc mode (with ispell support in text mode):
      <!--variables
      DBAddr    oracle://udm:udm@localhost/udmsearch/
      DBMode    crc
      IspellMode text
      Affix   en /usr/local/udmsearch/ispell/en.aff
      Spell   en /usr/local/udmsearch/ispell/en.dict
      -->
   c) postgres/multidict mode (with ispell support in db mode):
      <!--variables
      DBAddr    pgsql://udm:udm@localhost/udmsearch/      
      DBMode    multi
      IspellMode db
      -->
   
NOTE FOR ORACLE USERS:
-----------------------
OCIPLogon function uses only DBName, DBUser and DBPass variable to
connect to the backend.

PHP says:
The DBName parameter can either contain the name of the local Oracle
instance or the name of the entry in tnsnames.ora to which you want
to connect. If the DBName is not specified, PHP uses the environment
variables ORACLE_SID (Oracle instance) or TWO_TASK (tnsnames.ora) to
determine which database to connect to. 
