About MAPFSLITE
===============

MAPFSLITE is a simple program that exports the Wildcat! Files.dat file to a SQLITE3
Database and allows simple CLI based SQL Queries.

This program does not alter your Wildcat! Files.dat it is a READ-ONLY program from 
Wildcat! prospective.

It will create a database file called mapfslite.db

About SQLITE3
=============

SQLITE is a popular small foot print SQL database suitable for personal and/or small
business use.

To learn more about SQLite follow this web link:

   	http://www.sqlite.org/about.html

Target Audience
===============

Sysops who have a small (0 to 50,000) record File Database may find the utility useful 
to lookup specific file details or as a basis for producing PHP based reports.

It is not suitable for Sysops with large and growing File Databases.

Quick Start
===========

Step 1: Run the mapfslite-setup.exe

The setup program will create a subdirectory and copy the application and dependency
files into the target directory.

Step 2: Make sure your Wildcat! root directory is in the system path so the program can
find wcsrv2.dll

Step 3: At the CLI (Command Prompt) change to the mapfslite directory

  	cd\wc5\mapfslite    or     cd\wc6\mapfslite

Step 4: Run the following command:

  	mapfslite /q

Unless you receive an error youre done!

Command Line Options
====================

To get help type:

	mapfslite /?

Switch	Purpose

  /?	Show this Help Message
  /a	Analyze (Optimize Indexing) mapfslite.db
  /c	Create mapfslite.db & Files Table
  /e	Export Wildcat! Files.dat to Files Table
  /d	Drop filename, area, description Indexes
  /I	Create filename, area, description Indexes
  /q	Quick Start - Create DB, Export, Index & Analyze
  /r	ReIndex mapfslite.db Tables
  /s	SQL Query - /s "sql-statement" [OPTIONALLY] /w
  /u	Update / Sync Wildcat! & Files Table
  /v	Vacuum (Compact Empty Space) in mapfslite.db

Query Examples
==============

Example 1a: Get All Files Details - Not recommended if you have lots of files...

   mapfslite /s "select * from files"

Example 1b: Get All Files Details - Limited to first 10 files

   mapfslite /s "select * from files limit 10" /w

*** Note here we use /w to say WIDE Display plus output to sqloutput.htm

Example 2: Get a specific file record:
  
  mapfslite /s "select * from files where fileid='1'"

  mapfslite /s "select * from files where fileid='100'"

Example 3: Get the top ten most downloaded files:

mapfslite /s "select filename,area,downloads from files order by downloads desc limit 10" /w

Example 4: Get files from a particular date onwards:

mapfslite /s "select filename,area,filedate from files where filedate > '2008-07-01'" /w

Example 5: Get files between particular dates:

mapfslite /s "select filename,area,filedate from files where filedate > '2006-07-01' and filedate < '2008-08-20'" /w

The fields in the FILES Table
=============================

Field Name		Type			Example Content
fileid          	integer			1
area			integer			10
areaname		varchar(255)		Night Owl CD-ROM
filename		varchar(255)		wildcat.zip
description		text			Short File Description
longdescription 	text			Long File Description
password		varchar(40)		File password
privateid		integer			3
size			integer			10000
filedate		text			2008-01-01
lastaccesseddate	text			2008-08-25
filetime		text			12:10
lastaccessedtime	text			17:15
neveroverwrite		char(3)			No
neverdelete		char(3)			No
freefile		char(3)			Yes
copybeforedownload	char(3)			No
offline			char(3)			No
failedscan		char(3)			Yes
freetime		char(3)			No
downloads		integer			101
cost			integer			0
uploader		varchar(30)		Sysop
haslongdescription	char(3)			Yes
storedpath		varchar(80)		[cd\files\000]
syncflag		integer			0

SQL Query Syntax
================

The SQLite website has a good basic summary of the SQL Syntax

	http://www.sqlite.org/lang.html

SQLOUTPUT.HTM
=============

When you use the /w switch the screen display is in wide format and also produces a
file called  SQLOUTPUT.HTM which contains a table formatted copy of your output data.

UPDATE MAPFILES.DB AFTER CREATION
=================================

If you find the program handy then create a nightly batch file to run in the early hours

   @echo off
   cd\wc5\mapfslite
   mapfslite /u

PHP General
===========

There is a verbose example of how to connect to the database using PHP in the archive 
file called mapfslite.php

In order for it to work you must ensure the following lines are UNcommented in your
PHP.INI File

        extension=php_pdo.dll
        extension=php_pdo_sqlite.dll
 
If you are interested in developing in PHP please use a templating system like smarty

	http://www.smarty.net/
	
rather than echoing or printing information to the browser.  

WCPHP-Lite
==========

If you have installed wcPHP-Lite the PDO extensions are already installed for you.

WcBASIC
=======

I have provided a wcBASIC example html-mapfslite.wcc, which illustrates how
to connect to the database using wcODBC.

You will need to download the ODBC driver from here:

     http://www.ch-werner.de/sqliteodbc/

and setup a System DSN via:
  
     Control Panel > Administrator Tools -> Data Sources ODBC -> System DSN -> Add

Select the SQLite3 ODBC Driver

The DSN settings should be something like:

Data Source Name:	mapfslite
Database Name:		c:\wc5\mapfslite\mapfslite.db
Lock Timeout [ms]	100000
Sync Mode:		NORMAL

Once you have setup the DSN run the sample .wcx application thus:

          www.yourdomain.com/code/mapfslite/html-mapfslite.wcx

Archive Contents
================

File			Purpose

Html-mapfslite.wcc 	Sample wcBasic program source
Html-mapfslite.wct	Template for sample program
Html-mapfslite.wcx	Sample wcBasic program
Mapfslite.exe		Main Program
Mapfslite.php		A verbose example of running a query using PHP
Msvcm90.dll		Microsoft Dependency File (Only distributed with the latest 0S Versions)	
Msvcp90.dll		Microsoft Dependency File (Only distributed with the latest 0S Versions)	
Msvcr90.dll		Microsoft Dependency File (Only distributed with the latest 0S Versions)	
query.bat		Sample query via a batch file
Sqlite3.dll		SQLite 3 Dependency File

Questions / Help
================

Contact me directly not via the Winserver Lists

Email: michael.purdy@mapurdy.com.au
Skype: mike_Purdy

Register for an account on my BBS at:

       http://www.mapurdy.com.au/public/info/wct/wcsysop_info.wct

Disclaimer & Warning
====================

The software in this archive are provided "AS IS" with No Warranty either expressed or
implied, this includes any implied warranty of merchantability or fitness for a
particular purpose.

The software developer neither assumes (nor authorises any other individual to accept)
liability for any damages resulting from the use of the software 	
