DbaseWeb Lite download
Registrati per ricevere news e aggiornamenti. I dati conferiti saranno trattati nel rispetto della normativa sulla protezione dei dati. L'informativa completa č disponibile qui: Informativa Privacy
// myip sample program - Author: Daniele Campagna
#include "dbwheaders.ch"
//-------------------------------------------------
// myFnAcl
//-------------------------------------------------
function myFnACL()
DECLARE COMMAND myip NOSID NOHTML
return nil
//-------------------------------------------------
// myExec / cCmd is the command received
//-------------------------------------------------
function myExec(cCmd, nStartRec, acDat,nRecPag)
// command myip
do case
case cCmd=="myip"
cgiout 'Content-type: text/html'+chr(10)
cgiout getenv('REMOTE_ADDR')
otherwise
dbwHtmTag("body",1)
cgiout cCmd+" - Command not recognized!<BR>"
endcase
return nil
//-------------------------------------------------
// dbwmksid dbwset_up
//-------------------------------------------------
#include "custfn.prg"
Samples
/cgi-bin/dbwmyip.cgi?/dbw/&dbwmyip
// dbw 1.0
// start.prg sample program - Author: Daniele Campagna
//-----------------------------------------------------------------------------
// standard include
#include "dbwheaders.ch"
//-----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
// mySetDb - Setup file structure - CALLED BY MAIN put here the definition of your databases
/////////////////////////////////////////////////////////////////////////////////
function mySetDb()
// custom file descriptors=============================
DECLARE DATABASE customers ID CUST DBFCDX
DECLARE INDEX custord OF CUST KEY LASTORDER
DEFINE DEFAULTVIEW OF CUST
ADDCOLUMN NAME HEADER Nome
ADDCOLUMN ADDRESS HEADER Indirizzo
ADDCOLUMN CITY HEADER Cittā
ADDCOLUMN STATE HEADER Stato
END DEFAULTVIEW
return nil
//======================================================
// Init Procedure
//======================================================
INIT PROCEDURE RddInit
REQUEST DBFCDX
REQUEST DBFNTX
RETURN
///////////////////////////////////////////////////////////////////////////////////
// myFnACL: add functions to aNoSID (no SID needed), aNoHTML (no HTML output)
///////////////////////////////////////////////////////////////////////////////////
function myFnACL()
DECLARE COMMAND start NOSID
DECLARE COMMAND gettop NOSID
DECLARE COMMAND getdown NOSID
DECLARE COMMAND formadd NOSID
DECLARE COMMAND formed NOSID
DECLARE COMMAND addrec NOSID
DECLARE COMMAND updrec NOSID
return nil
///////////////////////////////////////////////////////////////////////////////////
// function dbwExec: main selector
///////////////////////////////////////////////////////////////////////////////////
function myExec(cCmd, nStartRec, acDat,nRecPag)
do case
case cCmd=="start"
nPixel:=100
OPEN TAG body
cgiout "<IFRAME name='up' style='width:100%;height:"+tostring(nPixel)+"px;' src='"+stdcmd+sepa1+"gettop"+sepa1+"0"+"'></IFRAME>"
cgiout "<iframe name='down' style='position:fixed; top:"+tostring(nPixel+1)+"px; width:100%;height:100%;' src='http://"+servername+cHtmlDir+"framelight.html'></iframe>"
case cCmd=="gettop"
sendtop(nStartREc,acDat)
case cCmd=="getdown"
OPEN TAG body
CGIOUT "<h2>This is the output of command getdown!</h2><br>"
HTMLBUTTON "Back" ACTION "history.go(-1)" NOADDPATH
case cCmd=="formadd"
formadd(nstartrec,acdat)
case cCmd=="formed"
formed(nstartrec,acdat)
case cCmd=="addrec"
dummyadd(nStartrec,acDat)
case cCmd=="updrec"
dummyupd(nStartRec,acDat)
otherwise
OPEN TAG body
cgiout cCmd+" - "+_I("Comando non riconosciuto")+"!<BR>"
endcase
return nil
///////////////////////////////////////////////////////////////////////////////////
// customizable functions dbwmksid: session identifier, dbwset_up
///////////////////////////////////////////////////////////////////////////////////
#include "custfn.prg"
//-----------------------------------------------------------------------------
// END SYSTEM FUNCTIONS
//-----------------------------------------------------------------------------
/*---------
sendtop : creates the content for upper iframe
---------*/
function sendtop(nStartrec,acDat)
//manually emitting the standard CSS
dbwcss()
// goto the <body> tag
OPEN TAG body
//
// how to write to the body of the document
//
// 1) using TEXT...ENDTEXT
//========================
TEXT
<div id=left style="background-color:#383838; width:18%; height:90px; float:left; vertical-align:middle;" align="center"><h3><font color="#98F6FF">dBaseWeb</font></h3></div>
<div name="cmd" style='background-color:#c0d2f3; width:58%; height:90px; float:left;'>
<table style="margin:0 auto;" height=100%><TR><TD>
ENDTEXT
// 2) using specialized commands
//==============================
// buttons to perform various actions
// button that calls a javascript function
HTMLBUTTON "Alert" ACTION "alert('button calls javascript')" NOADDPATH
CGIOUT "</TD><td>"
// button to call the cgi with a command
HTMLBUTTON "getdown" ACTION "getdown" CLASS "Btn1" TARGET "parent.down"
CGIOUT "</TD><td>"
// button to load a page
cVar="http://"+servername+cHtmldir+"dBaseWeb.html"
HTMLBUTTON "Load Page" ACTION "location.href='&cVar'" CLASS "Btn0s" TARGET "parent.down" NOADDPATH
CGIOUT "</TD><td>"
// call an embedded system function
HTMLBUTTON "Version" ACTION "version" NREC 0 ID "Btn1" TARGET "parent.down"
CGIOUT "</TD><td>"
// emit the command formadd to the CGI
HTMLBUTTON "Add Record" ACTION "formadd" NREC 0 TARGET "parent.down"
CGIOUT "</TD><td>"
// edit a record calls formed
HTMLBUTTON "Edit record" ACTION "formed" NREC nStartRec TARGET "parent.down"
// write the end of the page using cgiout
cgiout "</td></TR></table></div>"
cgiout "<div name="info" style='background-color:#b3d2fa; width:18%; height:90px; float:left;'>dBaseWeb 1.0</div>
// </body></html> added automatically
return nil
//--------------------------------------
// FORMADD
// FORM TO ADD A RECORD
//
//--------------------------------------
function formadd(nStartRec,acDat)
// array for SELECT control
astat:={" ","Italia","France","China","USA","Canada","Deutschland","United Kingdom","India","Russia","Switzerland","Kansas","Wogon","Turkey","The Nederlands","California","Other"}
// action for the FORM
// stdcmd (public) automatically set by main(): "/cgi-bin/<programName>?/<aliasDir>/"
//sepa1 is &, don't use directly in strings, it can confuse Harbour
cAct=stdcmd+sepa1+"addrec&0"
// use of DEFINE DBWELEMENTS
// Prepares the output of the page with all requested components as scripts, styles, html...
// init script,div and css for DATEPICKER
DEFINE DBWELEMENTS
ADDELEMENT DATEPICKER
END DBWELEMENTS
/after END DBWELEMENTS the tag <body> is already in place
cgiout "<h2>empty HTMLFORM to add a record</H2><BR>"
// Form creation with DEFINE HTMLFORM...END HTMLFORM
// Empty form
DEFINE HTMLFORM ACTION cAct METHOD POST SUBMIT Add ENDTAG ON
ADDCONTROL INPUT NAME NAME LABEL Name LEFT 5 SIZE 40
ADDCONTROL INPUT NAME ADDRESS LABEL Address LEFT 5 SIZE 40
ADDCONTROL SELECT NAME STATE LABEL State LEFT 5 SIZE 20 FROM astat
ADDCONTROL INPUT NAME CITY LABEL City LEFT 5 SIZE 30
ADDCONTROL DATE NAME LASTORD LABEL "Last ordet" LEFT 5 SIZE 10
END HTMLFORM
cgiout "<br>"
cgiout "Action on submit: "+cAct
cgiout "<hr><br>"
// a button "Back" generic (previous page)
HTMLBUTTON "Back" ACTION "history.go(-1)" ID "Btn1" NOADDPATH
return nil
//--------------------------------------
// FORMED
// FORM TO EDIT A RECORD
//
//--------------------------------------
function formed(nStartRec,acDat)
// array for SELECT control
astat:={" ","Italia","France","China","USA","Canada","Deutschland","United Kingdom","India","Russia","Switzerland","Kansas","Wogon","Turkey","The Nederlands","California","Other"}
// init script for DATEPICKER
DEFINE DBWELEMENTS
ADDELEMENT DATEPICKER
END DBWELEMENTS
// OPEN DATABASE
DBOPEN CUST
set index to
if nStartRec>0
goto nStartRec
else
go top
endif
// action for the FORM: updrec to write data
// stdcmd (public) automatically set by main(): "/cgi-bin/<programName>?/<aliasDir>/"
cAct=stdcmd+sepa1+"updrec&"+toString(Recno())
cgiout "<h2>HTMLFORM for editing a record</h2><BR>"
cgiout "(Record:"+toString(recno())+")<br>"
// Form creation with DEFINE HTMLFORM...END HTMLFORM with values from the record
//form with values
DEFINE HTMLFORM ACTION cAct METHOD POST SUBMIT Update ENDTAG ON
ADDCONTROL INPUT NAME NAME VALUE customers->NAME LABEL Name LEFT 5 SIZE 40
ADDCONTROL INPUT NAME ADDRESS VALUE customers->ADDRESS LABEL Address LEFT 5 SIZE 40
ADDCONTROL SELECT NAME STATE VALUE customers->STATE LABEL State LEFT 5 SIZE 20 FROM astat
ADDCONTROL INPUT NAME CITY VALUE customers->CITY LABEL City LEFT 5 SIZE 30
ADDCONTROL DATE NAME LASTORDER VALUE DTOC(customers->LASTORDER) LABEL "Last order" LEFT 5 SIZE 10
END HTMLFORM
cgiout "<br>"
cgiout "Action on submit: "+cAct
cgiout "<hr><br>"
// a button "Back" generic (previous page)
HTMLBUTTON "End" ACTION "history.go(-1)" ID "Btn1" NOADDPATH
HTMLBUTTON "Forward" ACTION "formed" NREC min(reccount(),recno()+1)
HTMLBUTTON "Back" ACTION "formed" NREC max(1,recno()-1)
return nil
// this function simulates the appending of a record but does nothing
function dummyadd(nStartrec,acDat)
local j
OPEN TAG body
cgiout "<h2><center>Record added</h2><br>"
cgiout "(not really)<br>"
cgiout "<hr>"
cgiout "Params received:<br>"
cgiout "RecordnUmber:"+toString(nStartRec)+"<br>"
for j=1 to len (acDat)
cgiout acDat[j,1]+" = "+acDat[j,2]+"<br>"
next j
HTMLBUTTON "Back" ACTION "start" NREC 0 TARGET "parent"
return nil
// this function simulates the updating of a record but does nothing
function dummyupd(nStartrec,acDat)
local j
OPEN TAG body
cgiout "<h2><center>Record updated</h2><br>"
cgiout "(not really)<br>"
cgiout "<hr>"
cgiout "Params received:<br>"
cgiout "RecordnUmber:"+toString(nStartRec)+"<br>"
for j=1 to len (acDat)
cgiout acDat[j,1]+" = "+acDat[j,2]+"<br>"
next j
HTMLBUTTON "Back" ACTION "start" NREC 0 TARGET "parent"
return nil
dbwStarter
/cgi-bin/starter.cgi?/dbw/&start&0
Sito a cura di Daniele Campagna - P. Iva: 06286840969