example1.html 100644 0 0 734 6524542606 11534 0 ustar root root
*** sorry, database not available or wrong path **" elseif nCust == 0 ? "
*** 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 ? "
*** error, cannot open database or index" else seek nCust if !found() ? "
*** sorry, no data available for this cust no." else ? "
"
while !eof() .and. custID == nCust
? custID, name, trim(address), "
"
skip
enddo
?? ""
endif
endif
endif
? "
" /* write HTML reply postfix */ #ifdef USE_WEB_FUNCTIONS WebHtmlEnd() // write HTML postfix #else ? "" ? "" #endif ? quit /* disable curses, disable start-up messages if any */ FUNCTION ProgramInit() // required for CALL fgsUse4html // FS 4.4x RETURN NIL // see fsman sect SYS.2.9 FUNCTION CursesInit() // required for FS 4.4x RETURN NIL ** eof example1.prg ----------------------------------------------- example1.sh 100755 0 0 442 6524542606 11201 0 ustar root root #!/bin/sh set -f TERMINFO=/cgi-bin ; export TERMINFO TERM=dummy ; export TERM # # enable following lines LD_... when linked dynamically, see # details in fs4web.html or fs4web.txt # # LD_LIBRARY_PATH=/cgi_bin ; export LD_LIBRARY_PATH # LD_RUN_PATH=/cgi_bin ; export LD_RUN_PATH ./example1 fs4web.html 100666 0 0 40435 6524542606 11260 0 ustar root root
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
fs4web.txt 100644 0 0 27112 6524542606 11124 0 ustar root root Using FlagShip on Web
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.
1. Data Structure on the Server
1.a. Directory for HTML documents (Document root directory)
The html documents (*.html) accessed by the Web browser (Navigator,
Communicator, Arena, Mosaic, IE etc.) usually resides in a special directory
on the server (e.g. /usr/local/httpd/htdocs or /var/local/public/html/docs
etc). The Web server (e.g. Apache, Netscape, AOLserver etc.) hides (maps)
the true directory structure so, that the Web browser will see this
directory (named "Document root directory") as "root", i.e. the / path only.
Hence, the Web user (usually of the group "nobody") can access files and
subdirectories located below, but not above this Document root directory (an
important security aspect). The links from a html document to another one on
the same server may be done relatively, e.g. "/other.html" instead of the
URL (Uniform Resource Locator) naming convention
"http://www.domain.org/other.html", which reduce the Internet transfer and
increases the access speed significantly.
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--).
1.b. Directory for CGI Scripts and Executables
The Common Gateway Interface, or CGI, is a means for the HTTP server to
"talk" to programs (scripts, executables) on the local or server's machine.
As opposite to the static model of reading predefined html documents, the
CGI allows to react on the client request and creates specific text or html
documents for the browser. The requests from the browser to CGI are passed
via environment variables (the most important are QUERY_STRING and
PATH_INFO) and/or via stdin, depending on the request type. The QUERY_STRING
is filled when the preferred "GET" method is used. The request is in the
form *** sorry, database not available or wrong path **"
elseif nCust == 0
? " *** 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
? " *** error, cannot open database or index"
else
seek nCust
if !found()
? " *** sorry, no data available for this cust no."
else
? " "
while !eof() .and. custID == nCust
? custID, name, trim(address), " "
? ""
? ""
?
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 -----------------------------------------------
Note the CGI output prefix when #define HEADER_REQUIRED is enabled. It is
required for the most common Web servers. The CALL fgsUse4html in the
FUNCTION ProgramInit() is required here only for the Demo version of
FlagShip, and available in the FS release 4.42.0448 and newer. For older
releases, only the Pro or Personal license can be used here.
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...".
2.d Database maintenance
We have to create a small maintenance program first (or use e.g. dbu). Often
the main program checks for the existence of database and indices and
creates it when required. But for security purposes on the server, it is
better to maintain it separately by the web administrator which has
sufficient access rights.
** mainten1.prg ----------------------------------------------------
#define DBFNAME "example1"
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 ----------------------------------------------
Compile
FlagShip mainten1.prg -omainten1
set the access rights for the web administrator only
chmod 700 mainten1
and invoke it to create (or modify) the database and index
./mainten1
After the first invocation, change the permissions of the database and
index:
chmod 666 example1.dbf example1.idx
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.
3. Additional hints
* Keep in mind, the Web user has a very limited access to the system and
will usually not be able to access the most Unix tools as you can as
administrator or ordinary user.
* You may preferably compile and link statically your public executables
(see the FSconfig file and the manual sections FSC.1.4.2, FSC.1.7).
Otherwise, when linking dynamically, you will need to copy the
libFlagShip.so file into the /cgi-bin directory, make it readable for
all (644) and modify the start-up script (see 2.b) to read
#!/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
* You should be very careful when using the RUN command in the
application; it may create a security hole when you use variable
parameters and don't check them properly.
* The examples and sources used here are available in the fs4web.tar
archive file.
------------------------------------------------------------------------
This page will be continued.
Last update: Friday, 08-May-1998 by webmaster@fship.com
Back to FlagShip home page
mainten1.prg 100644 0 0 2063 6524542606 11375 0 ustar root root ** mainten1.prg ----------------------------------------------------
*
* Compile: FlagShip mainten1.prg -omainten1
* Execute: [newfscons] ./mainten1
#define DBFNAME "example1"
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 1234, name with "name 1234", address with "address 1234"
append blank
repla custID with 10, name with "name 10", address with "address 10"
append blank
repla custID with 1, name with "FlagShip", address with "http://www.fship.com"
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 ----------------------------------------------
"
skip
enddo
?? ""
endif
endif
endif
? "