This document describes how to use FlagShip for html Web document purposes. It tries not to be a detailed manual for configuration of the Web Server or browser, nor a full reference to the HTML language, but gives a general overview sufficient for the programmer to use FlagShip as a database manager for HTML documents. The examples are hold very simple and are ment as a basis for your own programs even without or with a basic HTML knowledge only.
Configuration: The name of the document root directory is specified in the /etc/httpd/access.conf and /etc/httpd/srm.conf (or similarly named) configuration files used by the Web server daemon and described in detail in the server documentation. On a remote Web server, contact your provider for the setup details.
Permissions: The document root directory should have a "read"
access for everybody (e.g. 755, drwxr-xr-x). The html documents
itselves (*.html) have usually only read permission (644, -rw-r--r--).
That script directory contains scripts, executables and data accessed by the HTML documents indirectly via the CGI interface, e.g. by the <FORM ...> tag. This directory will contain the by FlagShip created executable among the databases and indices.
For security reasons, this CGI directory should not be equivalent to, or reside below the Document root directory. Usually, this directory is named cgi-bin and reside parallel to the Document root directory, e.g. /usr/local/httpd/cgi-bin or /var/local/public/html/cgi-bin.
Configuration: The location and its mapping to the Web browser (e.g. visible as /cgi-bin) is specified in the above named Web server configuration files. You should also change the properties of the directory to Options none, AllowOveride none in the access.conf file. On a remote Web server, contact your provider for the setup details.
Permissions: The CGI directory may have only execute permissions
for everybody (711, drwx--x--x). The scripts or executables have
usually only read & execute permission (755, -rwxr-xr-x),
while the databases and indices are r/w (666, -rw-rw-rw-).
#define DBFNAME "example1"
#define DBFPATH "/cgi-bin"
#define HEADER_REQUIRED
parameter cCust
field custID, name, address
if empty(cCust)
cCust := getenv("QUERY_STRING")
if !empty(cCust) .and. ("=" $ cCust)
cCust := trim(substr(cCust,
rat("=",cCust)+1))
endif
endif
nCust := val(cCust)
#ifdef HEADER_REQUIRED
?? "Content-Type: text/html"
?
#endif
? "<HTML>"
? "<HEAD><TITLE>Test Web Page</TITLE></HEAD>"
? "<BODY>"
// or: ? '<BODY BCOLOR="#FFFFFF">'
if !file(DBFNAME + ".dbf")
set default to (DBFPATH)
endif
if !file(DBFNAME + ".dbf") .or. !file(DBFNAME + ".idx")
? "<P>*** sorry, database not
available or wrong path **"
elseif nCust == 0
? "<P>*** sorry, no data without
customer ID **"
else
use (DBFNAME) index (DBFNAME) shared
ok := used() .and. !neterr()
? "Listing the data for customer
no. " + ltrim(str(nCust))
if !ok
? "<P>*** error,
cannot open database or index"
else
seek nCust
if !found()
? "<P>*** sorry, no data available for this cust no."
else
? "<P><TT>"
while !eof() .and. custID == nCust
? custID, name, trim(address), "<BR>"
skip
enddo
?? "</TT>"
endif
endif
endif
? "<P>"
? "</BODY>"
? "</HTML>"
?
quit
// disable curses, disable start-up messages if any
//
FUNCTION ProgramInit() // required
for the Demo in
* CALL fgsUse4html
// release 4.42.0448 and newer
RETURN NIL
// see fsman sect SYS.2.9
FUNCTION CursesInit()
RETURN NIL
** eof example1.prg -----------------------------------------------
Now, compile the program (on the server system) by
FlagShip example1.prg -oexample1
and post the executable into the /cgi-bin directory (see 1.b).
You may invoke it from the command-line by
./example1 1234
It displays a HTML document but first reports en error "database not
available...".
if !file(DBFNAME + ".dbf")
dbcreate(DBFNAME, {{"custID", "N",
5, 0}, ;
{"name", "C", 20, 0}, ;
{"address","C", 30, 0}} )
endif
use (DBFNAME) exclusive
if eof() // add some records
append blank
repla custID with 1, name with "Multisoft",
address with "http://www.fship.com"
append blank
repla custID with 1, name with "FlagShip",
address with "http://www.fship.com"
append blank
repla custID with 1234, name with "name
1234", address with "address 1234"
append blank
repla custID with 10, name with "name
10", address with "address 10"
endif
if file(DBFNAME + ".idx")
set index to (DBFNAME)
else
index on custID to (DBFNAME)
endif
browse() // maintain, add, edit the database
example1.dbf
use
** eof of mainten1.prg ----------------------------------------------
Check the output of the invocation "./example1 1", it should display a HTML document with two lines of data from the database.
If everything is ok, you're now ready to use the document example1.html (see 2.a) by your preferred Web browser. If something fails, check the access rights.
#!/bin/sh
set -f
TERMINFO=/cgi-bin ; export TERMINFO
TERM=dummy ; export TERM
LD_LIBRARY_PATH=/cgi_bin ; export LD_LIBRARY_PATH
LD_RUN_PATH=/cgi_bin ; export LD_RUN_PATH
./example1
Last update: Friday, 08-May-1998 by webmaster@fship.com
Back to FlagShip home page